1.1 --- a/epoc32/include/txtstyle.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/txtstyle.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,271 @@
1.4 -txtstyle.h
1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#ifndef __TXTSTYLE_H__
1.21 +#define __TXTSTYLE_H__
1.22 +
1.23 +#include <e32std.h>
1.24 +#include <e32base.h>
1.25 +#include <txtfmlyr.h>
1.26 +
1.27 +
1.28 +// Classes declared in this file:
1.29 +class CParagraphStyle;
1.30 +class CStyleTable;
1.31 +//
1.32 +// Classes referenced in this file:
1.33 +class RReadStream;
1.34 +class RWriteStream;
1.35 +
1.36 +/**
1.37 +The maximum number of characters in a paragraph style name.
1.38 +@internalAll
1.39 +*/
1.40 +const TInt KMaxParagraphStyleName=0x20;
1.41 +
1.42 +
1.43 +/**
1.44 +The name of a paragraph style, with a maximum of 32 characters, to uniquely
1.45 +identify the style.
1.46 +@internalComponent
1.47 +*/
1.48 +typedef TBuf<KMaxParagraphStyleName> TParagraphStyleName;
1.49 +
1.50 +/**
1.51 +@internalComponent
1.52 +*/
1.53 +const TUid KUserDefinedParagraphStyleUid={268435535};
1.54 +
1.55 +
1.56 +//
1.57 +// Defines a paragraph style, and the paragraph style to use next.
1.58 +
1.59 +
1.60 +class RParagraphStyleInfo
1.61 +/**
1.62 +A paragraph style.
1.63 +
1.64 +This is a named set of paragraph and character format attributes, which can
1.65 +only be applied to whole paragraphs. Paragraph styles may be used in rich
1.66 +text. Global text does not support styles.
1.67 +
1.68 +This class owns a pointer to an object of class CParagraphStyle, which stores
1.69 +the style information for the current paragraph; it also references another
1.70 +pointer which is optional, and stores the style information for the next paragraph.
1.71 +After construction, the RParagraphStyleInfo object should be appended to a
1.72 +style list (class CStyleList) which takes ownership of it.
1.73 +@publishedAll
1.74 +@released
1.75 +*/
1.76 + {
1.77 +public:
1.78 + inline RParagraphStyleInfo();
1.79 + inline RParagraphStyleInfo(CParagraphStyle* aStyle,CParagraphStyle* aStyleForNextPara=NULL);
1.80 + inline void Discard();
1.81 +public:
1.82 + /** Pointer to the paragraph style information. Owned by the RParagraphStyleInfo
1.83 + object. */
1.84 + CParagraphStyle* iStyle; // owned
1.85 + /** Pointer to the paragraph style information for the next paragraph. May be NULL. */
1.86 + CParagraphStyle* iStyleForNextPara; // referenced, may be NULL
1.87 + };
1.88 +
1.89 +
1.90 +
1.91 +
1.92 +class CParagraphStyle : public CParaFormatLayer
1.93 +// Defines a paragraph style as a named para format with richer attributes.
1.94 +/**
1.95 +Defines a paragraph style.
1.96 +
1.97 +A paragraph style is a named paragraph format layer which owns a set of character
1.98 +format attributes, has an outline level and a type UID. The outline level
1.99 +controls which headings should be shown when in document outline view. The
1.100 +type UID is used to differentiate between a word processor's built-in styles,
1.101 +which cannot be deleted, and user-defined styles, which can be deleted.
1.102 +
1.103 +The style's paragraph format attributes can be set using the functions derived
1.104 +from the base class CParaFormatLayer. Its character format attributes can
1.105 +be set through the owned CCharFormatLayer*. The style's character and paragraph
1.106 +format attributes are based on the global format layers specified on construction.
1.107 +@publishedAll
1.108 +@released
1.109 +*/
1.110 + {
1.111 +public:
1.112 + friend class CStyleList;
1.113 + friend class CRichTextIndex;
1.114 +
1.115 +
1.116 +
1.117 +/** Controls what happens to the styles when styled rich text is pasted into another
1.118 +rich text object. */
1.119 + enum TStylePasteMode
1.120 + {
1.121 + /** The pasted rich text retains all formatting and any new style definitions are
1.122 + added to the style list of the rich text object into which it is pasted. */
1.123 + EAddNewStyles,
1.124 + /** The pasted rich text retains all formatting, including that specified in the
1.125 + styles, but the new style definitions are not added to the style list of the
1.126 + rich text object into which it is pasted. The formatting specified in the
1.127 + styles becomes specific formatting. */
1.128 + EConvertNewStyles,
1.129 + /** The pasted rich text loses all formatting specified in the styles. */
1.130 + EIgnoreNewStyles
1.131 + };
1.132 +
1.133 +
1.134 +
1.135 +/** Retention of specific formatting */
1.136 + enum TApplyParaStyleMode
1.137 + {
1.138 + /** Specific character and paragraph formatting which has been applied to the paragraph
1.139 + is retained when a style is applied. If the style's formatting conflicts
1.140 + with the specific formatting, the specific formatting overrides the style. */
1.141 + ERetainAllSpecificFormats,
1.142 + /** Specific character and paragraph formatting which has been applied to the paragraph
1.143 + is removed when a style is applied, regardless of whether or not it conflicts
1.144 + with the style. */
1.145 + ERetainNoSpecificFormats,
1.146 + /** Specific paragraph formatting which has been applied to the paragraph is retained
1.147 + when a style is applied. If the style's formatting conflicts with the specific
1.148 + paragraph formatting, the specific formatting overrides the style.
1.149 +
1.150 + Specific character formatting which has been applied to the paragraph is removed,
1.151 + regardless of whether or not it conflicts with the style. */
1.152 + ERetainSpecificParaFormat,
1.153 + /** Specific character formatting which has been applied to the paragraph is retained
1.154 + when a style is applied. If the style's formatting conflicts with the specific
1.155 + character formatting, the specific formatting overrides the style.
1.156 +
1.157 + Specific paragraph formatting which has been applied to the paragraph is removed,
1.158 + regardless of whether or not it conflicts with the style. */
1.159 + ERetainSpecificCharFormat
1.160 + };
1.161 +public:
1.162 + // Creates style & bases it on the speicfied global layers - the 'Normal' style.
1.163 + IMPORT_C static CParagraphStyle* NewL(const CParaFormatLayer& aGlobalParaFormatLayer,const CCharFormatLayer& aGlobalCharFormatLayer);
1.164 + IMPORT_C ~CParagraphStyle();
1.165 + //
1.166 + // Getters/Setters
1.167 + inline CCharFormatLayer* CharFormatLayer()const;
1.168 + inline TInt OutlineLevel()const;
1.169 + inline void SetOutlineLevel(TInt aOutlineLevel);
1.170 + //
1.171 + // Utilities
1.172 + IMPORT_C virtual TUid Type()const;
1.173 + inline void SetType(TUid aType);
1.174 + inline CParagraphStyle* CloneL()const;
1.175 +private:
1.176 + CParagraphStyle();
1.177 + void ConstructL(const CParaFormatLayer& aGlobalParaFormatLayer,
1.178 + const CCharFormatLayer& aGlobalCharFormatLayer);
1.179 + IMPORT_C virtual CFormatLayer* DoCloneL()const;
1.180 + //
1.181 + // Save/Load
1.182 + static CParagraphStyle* NewL(RReadStream& aStream,const CParaFormatLayer& aGlobalParaFormatLayer,const CCharFormatLayer& aGlobalCharFormatLayer);
1.183 + virtual void InternalizeL(RReadStream& aStream,const CFormatLayer* aParaLayerBase,const CFormatLayer* aCharLayerBase);
1.184 + virtual void ExternalizeL(RWriteStream& aStream)const;
1.185 +private:
1.186 + TUid iType;
1.187 + TInt iOutlineLevel;
1.188 + CCharFormatLayer* iCharFormatLayer; // should never be NULL
1.189 +public:
1.190 + /** Unique style name, with a maximum of 32 characters. */
1.191 + TParagraphStyleName iName;
1.192 + };
1.193 +
1.194 +
1.195 +/**
1.196 +The number of entries by which a style list expands when its buffer is reallocated.
1.197 +@internalComponent
1.198 +*/
1.199 +const TInt KMaxStyleListGranularity=0x04;
1.200 +
1.201 +
1.202 +
1.203 +class CStyleList : public CBase
1.204 +/**
1.205 +A container of paragraph styles.
1.206 +
1.207 +It is implemented as a fixed length array of pointers to RParagraphStyleInfos.
1.208 +The array's granularity is specified on construction. The list takes ownership
1.209 +of all paragraph styles appended to it. When the list is deleted, all styles
1.210 +it owns are also deleted.
1.211 +
1.212 +After the style list has been set up, it should normally be passed to a CRichText
1.213 +object, either in the rich text object's constructor, or by calling CRichText::SetStyleListExternallyOwned().
1.214 +The rich text object takes ownership of the style list (unless SetStyleListExternallyOwned()
1.215 +is used). Styles can be modified, added to and removed from the style list
1.216 +after ownership of the list has been passed to the rich text object.
1.217 +
1.218 +If CRichText::SetStyleListExternallyOwned() is used, the style list is not
1.219 +owned by the rich text object, and it must be stored and restored separately
1.220 +from the rich text object.
1.221 +@publishedAll
1.222 +@released
1.223 +*/
1.224 + {
1.225 +public:
1.226 + IMPORT_C static CStyleList* NewL(TInt aCapacity=KMaxStyleListGranularity);
1.227 + IMPORT_C static CStyleList* NewL(RReadStream& aStream,
1.228 + const CParaFormatLayer* aGlobalParaFormatLayer,
1.229 + const CCharFormatLayer* aGlobalCharFormatLayer);
1.230 + IMPORT_C ~CStyleList();
1.231 + //
1.232 + inline const RParagraphStyleInfo& operator[](TInt aIndex)const;
1.233 + inline RParagraphStyleInfo& operator[](TInt aIndex);
1.234 + IMPORT_C const RParagraphStyleInfo& At(TInt aIndex)const;
1.235 + IMPORT_C RParagraphStyleInfo& At(TInt aIndex);
1.236 + //
1.237 + // Persistence
1.238 + IMPORT_C TStreamId StoreL(CStreamStore& aStore)const;
1.239 + IMPORT_C void ExternalizeL(RWriteStream& aStream)const;
1.240 + IMPORT_C void InternalizeL(RReadStream& aStream,
1.241 + const CParaFormatLayer* aGlobalParaFormatLayer,
1.242 + const CCharFormatLayer* aGlobalCharFormatLayer);
1.243 + //
1.244 + // Table maintenance
1.245 + IMPORT_C void Reset(); // Delete all styles from the style list.
1.246 + IMPORT_C TInt AppendL(RParagraphStyleInfo* aStyleSet);
1.247 + IMPORT_C void Remove(CParagraphStyle* aStyle);
1.248 + IMPORT_C TInt SetStyleToFollow(const RParagraphStyleInfo& aStyleSet); // returns KErrNone or KErrNotFound
1.249 + IMPORT_C CStyleList* DeepCloneL()const;
1.250 + //
1.251 + // Getters
1.252 + IMPORT_C RParagraphStyleInfo* PtrByName(const TParagraphStyleName& aName)const;
1.253 + IMPORT_C RParagraphStyleInfo* PtrByType(const TUid aType)const;
1.254 + IMPORT_C TInt IndexByPtr(const CParaFormatLayer* aPtr)const;
1.255 + // Returns KErrNotFound if the specified style is not located in the style list.
1.256 + //
1.257 + IMPORT_C TInt IndexByName(const TDesC& aName)const;
1.258 + // Returns KErrNotFound if the specified style name is not located in the style list.
1.259 + //
1.260 + // General
1.261 + inline TInt Count()const;
1.262 +protected:
1.263 + IMPORT_C CStyleList();
1.264 + IMPORT_C void ConstructL(TInt aGranularity);
1.265 +private:
1.266 + void KillStyleList();
1.267 +private:
1.268 + CArrayFixFlat<RParagraphStyleInfo>* iList;
1.269 + __DECLARE_TEST;
1.270 + };
1.271 +
1.272 +
1.273 +#include <txtstyle.inl>
1.274 +
1.275 +#endif