epoc32/include/txtstyle.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     3
* All rights reserved.
williamr@4
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@4
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     8
*
williamr@4
     9
* Initial Contributors:
williamr@4
    10
* Nokia Corporation - initial contribution.
williamr@4
    11
*
williamr@4
    12
* Contributors:
williamr@4
    13
*
williamr@4
    14
* Description: 
williamr@4
    15
*
williamr@4
    16
*/
williamr@4
    17
williamr@2
    18
williamr@2
    19
#ifndef __TXTSTYLE_H__
williamr@2
    20
#define __TXTSTYLE_H__
williamr@2
    21
williamr@2
    22
#include <e32std.h>
williamr@2
    23
#include <e32base.h>
williamr@2
    24
#include <txtfmlyr.h>
williamr@2
    25
williamr@4
    26
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
williamr@4
    27
#include <txtstyle_internal.h>
williamr@4
    28
#endif
williamr@2
    29
williamr@2
    30
// Classes declared in this file:
williamr@2
    31
class CParagraphStyle;
williamr@2
    32
class CStyleTable;
williamr@2
    33
//
williamr@2
    34
// Classes referenced in this file:
williamr@2
    35
class RReadStream;
williamr@2
    36
class RWriteStream;
williamr@2
    37
williamr@2
    38
/** 
williamr@4
    39
The maximum number of characters in a paragraph style name.
williamr@4
    40
It should not be used by external developers.
williamr@2
    41
*/
williamr@2
    42
const TInt KMaxParagraphStyleName=0x20;
williamr@2
    43
williamr@2
    44
williamr@2
    45
/** 
williamr@2
    46
The name of a paragraph style, with a maximum of 32 characters, to uniquely 
williamr@4
    47
identify the style.
williamr@4
    48
It should not be used by external developers.
williamr@2
    49
*/
williamr@2
    50
typedef TBuf<KMaxParagraphStyleName> TParagraphStyleName;
williamr@2
    51
williamr@2
    52
//
williamr@2
    53
// Defines a paragraph style, and the paragraph style to use next.
williamr@2
    54
williamr@2
    55
williamr@2
    56
class RParagraphStyleInfo
williamr@2
    57
/** 
williamr@2
    58
A paragraph style.
williamr@2
    59
williamr@2
    60
This is a named set of paragraph and character format attributes, which can 
williamr@2
    61
only be applied to whole paragraphs. Paragraph styles may be used in rich 
williamr@2
    62
text. Global text does not support styles.
williamr@2
    63
williamr@2
    64
This class owns a pointer to an object of class CParagraphStyle, which stores 
williamr@2
    65
the style information for the current paragraph; it also references another 
williamr@2
    66
pointer which is optional, and stores the style information for the next paragraph. 
williamr@2
    67
After construction, the RParagraphStyleInfo object should be appended to a 
williamr@2
    68
style list (class CStyleList) which takes ownership of it. 
williamr@2
    69
@publishedAll
williamr@2
    70
@released
williamr@2
    71
*/
williamr@2
    72
	{
williamr@2
    73
public:
williamr@2
    74
	inline RParagraphStyleInfo();
williamr@2
    75
	inline RParagraphStyleInfo(CParagraphStyle* aStyle,CParagraphStyle* aStyleForNextPara=NULL);
williamr@2
    76
	inline void Discard();
williamr@2
    77
public:
williamr@2
    78
	/** Pointer to the paragraph style information. Owned by the RParagraphStyleInfo 
williamr@2
    79
	object. */
williamr@2
    80
	CParagraphStyle* iStyle;  // owned
williamr@2
    81
	/** Pointer to the paragraph style information for the next paragraph. May be NULL. */
williamr@2
    82
	CParagraphStyle* iStyleForNextPara;  // referenced, may be NULL
williamr@2
    83
	};
williamr@2
    84
williamr@2
    85
williamr@2
    86
williamr@2
    87
williamr@2
    88
class CParagraphStyle : public CParaFormatLayer
williamr@2
    89
// Defines a paragraph style as a named para format with richer attributes.
williamr@2
    90
/** 
williamr@2
    91
Defines a paragraph style. 
williamr@2
    92
williamr@2
    93
A paragraph style is a named paragraph format layer which owns a set of character 
williamr@2
    94
format attributes, has an outline level and a type UID. The outline level 
williamr@2
    95
controls which headings should be shown when in document outline view. The 
williamr@2
    96
type UID is used to differentiate between a word processor's built-in styles, 
williamr@2
    97
which cannot be deleted, and user-defined styles, which can be deleted.
williamr@2
    98
williamr@2
    99
The style's paragraph format attributes can be set using the functions derived 
williamr@2
   100
from the base class CParaFormatLayer. Its character format attributes can 
williamr@2
   101
be set through the owned CCharFormatLayer*. The style's character and paragraph 
williamr@2
   102
format attributes are based on the global format layers specified on construction. 
williamr@2
   103
@publishedAll
williamr@2
   104
@released
williamr@2
   105
*/
williamr@2
   106
	{
williamr@2
   107
public:
williamr@2
   108
	friend class CStyleList;
williamr@2
   109
	friend class CRichTextIndex;
williamr@2
   110
	
williamr@2
   111
williamr@2
   112
williamr@2
   113
/** Controls what happens to the styles when styled rich text is pasted into another 
williamr@2
   114
rich text object. */
williamr@2
   115
	enum TStylePasteMode
williamr@2
   116
		{
williamr@2
   117
	/** The pasted rich text retains all formatting and any new style definitions are 
williamr@2
   118
	added to the style list of the rich text object into which it is pasted. */
williamr@2
   119
		EAddNewStyles,
williamr@2
   120
	/** The pasted rich text retains all formatting, including that specified in the 
williamr@2
   121
	styles, but the new style definitions are not added to the style list of the 
williamr@2
   122
	rich text object into which it is pasted. The formatting specified in the 
williamr@2
   123
	styles becomes specific formatting. */
williamr@2
   124
		EConvertNewStyles,
williamr@2
   125
	/** The pasted rich text loses all formatting specified in the styles. */
williamr@2
   126
		EIgnoreNewStyles
williamr@2
   127
		};
williamr@2
   128
	
williamr@2
   129
williamr@2
   130
williamr@2
   131
/** Retention of specific formatting */
williamr@2
   132
	enum TApplyParaStyleMode
williamr@2
   133
		{
williamr@2
   134
	/** Specific character and paragraph formatting which has been applied to the paragraph 
williamr@2
   135
	is retained when a style is applied. If the style's formatting conflicts 
williamr@2
   136
	with the specific formatting, the specific formatting overrides the style. */
williamr@2
   137
		ERetainAllSpecificFormats,
williamr@2
   138
	/** Specific character and paragraph formatting which has been applied to the paragraph 
williamr@2
   139
	is removed when a style is applied, regardless of whether or not it conflicts 
williamr@2
   140
	with the style. */
williamr@2
   141
		ERetainNoSpecificFormats,
williamr@2
   142
	/** Specific paragraph formatting which has been applied to the paragraph is retained 
williamr@2
   143
	when a style is applied. If the style's formatting conflicts with the specific 
williamr@2
   144
	paragraph formatting, the specific formatting overrides the style.
williamr@2
   145
	
williamr@2
   146
	Specific character formatting which has been applied to the paragraph is removed, 
williamr@2
   147
	regardless of whether or not it conflicts with the style. */
williamr@2
   148
		ERetainSpecificParaFormat,
williamr@2
   149
	/** Specific character formatting which has been applied to the paragraph is retained 
williamr@2
   150
	when a style is applied. If the style's formatting conflicts with the specific 
williamr@2
   151
	character formatting, the specific formatting overrides the style.
williamr@2
   152
	
williamr@2
   153
	Specific paragraph formatting which has been applied to the paragraph is removed, 
williamr@2
   154
	regardless of whether or not it conflicts with the style. */
williamr@2
   155
		ERetainSpecificCharFormat
williamr@2
   156
		};
williamr@2
   157
public:
williamr@2
   158
	// Creates style & bases it on the speicfied global layers - the 'Normal' style.
williamr@2
   159
	IMPORT_C static CParagraphStyle* NewL(const CParaFormatLayer& aGlobalParaFormatLayer,const CCharFormatLayer& aGlobalCharFormatLayer);
williamr@2
   160
	IMPORT_C ~CParagraphStyle();
williamr@2
   161
	//
williamr@2
   162
	// Getters/Setters
williamr@2
   163
	inline CCharFormatLayer* CharFormatLayer()const;
williamr@2
   164
	inline TInt OutlineLevel()const;
williamr@2
   165
	inline void SetOutlineLevel(TInt aOutlineLevel);
williamr@2
   166
	//
williamr@2
   167
	// Utilities
williamr@2
   168
	IMPORT_C virtual TUid Type()const;
williamr@2
   169
	inline void SetType(TUid aType);
williamr@2
   170
	inline CParagraphStyle* CloneL()const;
williamr@2
   171
private:
williamr@2
   172
	CParagraphStyle();	
williamr@2
   173
	void ConstructL(const CParaFormatLayer& aGlobalParaFormatLayer,
williamr@2
   174
							 const CCharFormatLayer& aGlobalCharFormatLayer);
williamr@2
   175
	IMPORT_C virtual CFormatLayer* DoCloneL()const;
williamr@2
   176
	//
williamr@2
   177
	// Save/Load
williamr@2
   178
	static CParagraphStyle* NewL(RReadStream& aStream,const CParaFormatLayer& aGlobalParaFormatLayer,const CCharFormatLayer& aGlobalCharFormatLayer);
williamr@2
   179
	virtual void InternalizeL(RReadStream& aStream,const CFormatLayer* aParaLayerBase,const CFormatLayer* aCharLayerBase);
williamr@2
   180
	virtual void ExternalizeL(RWriteStream& aStream)const;
williamr@2
   181
private:
williamr@2
   182
	TUid iType;
williamr@2
   183
	TInt iOutlineLevel;
williamr@2
   184
	CCharFormatLayer* iCharFormatLayer;  // should never be NULL
williamr@2
   185
public:
williamr@2
   186
	/** Unique style name, with a maximum of 32 characters. */
williamr@2
   187
	TParagraphStyleName iName;
williamr@2
   188
	};
williamr@2
   189
williamr@2
   190
williamr@2
   191
/** 
williamr@2
   192
The number of entries by which a style list expands when its buffer is reallocated. 
williamr@4
   193
It should not be used by external developers.
williamr@2
   194
*/
williamr@2
   195
const TInt KMaxStyleListGranularity=0x04;
williamr@2
   196
williamr@2
   197
williamr@2
   198
williamr@2
   199
class CStyleList : public CBase
williamr@2
   200
/** 
williamr@2
   201
A container of paragraph styles. 
williamr@2
   202
williamr@2
   203
It is implemented as a fixed length array of pointers to RParagraphStyleInfos. 
williamr@2
   204
The array's granularity is specified on construction. The list takes ownership 
williamr@2
   205
of all paragraph styles appended to it. When the list is deleted, all styles 
williamr@2
   206
it owns are also deleted.
williamr@2
   207
williamr@2
   208
After the style list has been set up, it should normally be passed to a CRichText 
williamr@2
   209
object, either in the rich text object's constructor, or by calling CRichText::SetStyleListExternallyOwned(). 
williamr@2
   210
The rich text object takes ownership of the style list (unless SetStyleListExternallyOwned() 
williamr@2
   211
is used). Styles can be modified, added to and removed from the style list 
williamr@2
   212
after ownership of the list has been passed to the rich text object.
williamr@2
   213
williamr@2
   214
If CRichText::SetStyleListExternallyOwned() is used, the style list is not 
williamr@2
   215
owned by the rich text object, and it must be stored and restored separately 
williamr@2
   216
from the rich text object. 
williamr@2
   217
@publishedAll
williamr@2
   218
@released
williamr@2
   219
*/
williamr@2
   220
	{
williamr@2
   221
public:
williamr@2
   222
	IMPORT_C static CStyleList* NewL(TInt aCapacity=KMaxStyleListGranularity);
williamr@2
   223
	IMPORT_C static CStyleList* NewL(RReadStream& aStream,
williamr@2
   224
									const CParaFormatLayer* aGlobalParaFormatLayer,
williamr@2
   225
									const CCharFormatLayer* aGlobalCharFormatLayer);
williamr@2
   226
	IMPORT_C ~CStyleList();
williamr@2
   227
	//
williamr@2
   228
	inline const RParagraphStyleInfo& operator[](TInt aIndex)const;
williamr@2
   229
	inline RParagraphStyleInfo& operator[](TInt aIndex);
williamr@2
   230
	IMPORT_C const RParagraphStyleInfo& At(TInt aIndex)const;
williamr@2
   231
	IMPORT_C RParagraphStyleInfo& At(TInt aIndex);
williamr@2
   232
	//
williamr@2
   233
	// Persistence
williamr@2
   234
	IMPORT_C TStreamId StoreL(CStreamStore& aStore)const;
williamr@2
   235
	IMPORT_C void ExternalizeL(RWriteStream& aStream)const;
williamr@2
   236
	IMPORT_C void InternalizeL(RReadStream& aStream,
williamr@2
   237
								const CParaFormatLayer* aGlobalParaFormatLayer,
williamr@2
   238
								const CCharFormatLayer* aGlobalCharFormatLayer);
williamr@2
   239
	//
williamr@2
   240
	// Table maintenance
williamr@2
   241
	IMPORT_C void Reset();  // Delete all styles from the style list.
williamr@2
   242
	IMPORT_C TInt AppendL(RParagraphStyleInfo* aStyleSet);
williamr@2
   243
	IMPORT_C void Remove(CParagraphStyle* aStyle);
williamr@2
   244
	IMPORT_C TInt SetStyleToFollow(const RParagraphStyleInfo& aStyleSet);  // returns KErrNone or KErrNotFound
williamr@2
   245
	IMPORT_C CStyleList* DeepCloneL()const;
williamr@2
   246
	//
williamr@2
   247
	// Getters
williamr@2
   248
	IMPORT_C RParagraphStyleInfo* PtrByName(const TParagraphStyleName& aName)const;
williamr@2
   249
	IMPORT_C RParagraphStyleInfo* PtrByType(const TUid aType)const;
williamr@2
   250
	IMPORT_C TInt IndexByPtr(const CParaFormatLayer* aPtr)const;
williamr@2
   251
	// Returns KErrNotFound if the specified style is not located in the style list.
williamr@2
   252
	//
williamr@2
   253
	IMPORT_C TInt IndexByName(const TDesC& aName)const;
williamr@2
   254
	// Returns KErrNotFound if the specified style name is not located in the style list.
williamr@2
   255
	//
williamr@2
   256
	// General
williamr@2
   257
	inline TInt Count()const;
williamr@2
   258
protected:
williamr@2
   259
	IMPORT_C CStyleList();
williamr@2
   260
	IMPORT_C void ConstructL(TInt aGranularity);
williamr@2
   261
private:
williamr@2
   262
	void KillStyleList();
williamr@2
   263
private:
williamr@2
   264
	CArrayFixFlat<RParagraphStyleInfo>* iList;
williamr@2
   265
	__DECLARE_TEST;
williamr@2
   266
	};
williamr@2
   267
williamr@2
   268
williamr@2
   269
#include <txtstyle.inl>
williamr@2
   270
williamr@2
   271
#endif