williamr@4: /* williamr@4: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@4: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@4: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: * williamr@4: * Initial Contributors: williamr@4: * Nokia Corporation - initial contribution. williamr@4: * williamr@4: * Contributors: williamr@4: * williamr@4: * Description: williamr@4: * williamr@4: */ williamr@4: williamr@2: williamr@2: #ifndef __TXTGLOBL_H__ williamr@2: #define __TXTGLOBL_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: williamr@2: // forward declarations williamr@2: class CParaFormatLayer; williamr@2: class CCharFormatLayer; williamr@2: class TCharFormatX; williamr@2: class TCharFormatXMask; williamr@2: williamr@2: williamr@2: // Globally formatted text. williamr@2: // Uses one instance of each a paragraph format and character format class; Each presents williamr@2: // the formatting applied to the total document contents. Both of the format classes used williamr@2: // may utilise layering of formats through 'based on' links to achieve full format specification. williamr@2: // These global layers are *never* owned by global text, merely referenced. williamr@2: williamr@2: /** williamr@2: Text with globally applied formatting. williamr@2: williamr@2: Global text uses a single set of paragraph format attributes to describe the williamr@2: appearance of every paragraph and a single set of character format attributes williamr@2: to describe the appearance of every character. williamr@2: williamr@2: The paragraph formatting is stored in a CParaFormatLayer and the character williamr@2: formatting is stored in a CCharFormatLayer. A format layer is a set of character williamr@2: or paragraph format attributes, which may own a pointer to another format williamr@2: layer. This pointer is called a based-on link. The effective formatting of williamr@2: a global text object is the set of attributes specified in its two format williamr@2: layers, as well as any attributes inherited from the layers' chain of based-on williamr@2: links. To get the effective formatting, the links are read in turn, so that williamr@2: each attribute's value is taken from the first layer in the chain in which williamr@2: it has been set. Use GetCharFormat() and GetParaFormatL() to get the text williamr@2: object's effective formatting. williamr@2: williamr@2: A global text object references the two format layers; it does not own them. williamr@2: This allows more than one global text object to use the same formatting. The williamr@2: format layers may be modified (see ApplyParaFormatL() and ApplyCharFormatL()) williamr@2: or replaced (see SetGlobalParaFormat() and SetGlobalCharFormat()) during the williamr@2: text object's lifetime. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class CGlobalText : public CPlainText,public MLayDoc,public MFormatText williamr@2: { williamr@2: public: williamr@2: // Special member functions williamr@2: // Create new global text component whose sole content is an end-of-document character. williamr@2: IMPORT_C static CGlobalText* NewL(const CParaFormatLayer* aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer, williamr@2: TDocumentStorage aStorage=ESegmentedStorage,TInt aDefaultTextGranularity=EDefaultTextGranularity); williamr@2: // Restore a new global text, that uses the specified global layers. williamr@2: IMPORT_C static CGlobalText* NewL(const CStreamStore& aStore,TStreamId aStreamId, williamr@2: const CParaFormatLayer* aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer, williamr@2: MTextFieldFactory* aFieldFactory=NULL, williamr@2: TDocumentStorage=ESegmentedStorage); williamr@2: IMPORT_C ~CGlobalText(); williamr@2: // Global Format Layers williamr@2: IMPORT_C void SetGlobalParaFormat(const CParaFormatLayer* aParaFormatLayer); williamr@2: IMPORT_C void SetGlobalCharFormat(const CCharFormatLayer* aCharFormatLayer); williamr@2: inline const CParaFormatLayer* GlobalParaFormatLayer()const; williamr@2: inline const CCharFormatLayer* GlobalCharFormatLayer()const; williamr@2: // MLayDoc implementation williamr@2: IMPORT_C virtual TInt LdDocumentLength()const; williamr@2: IMPORT_C virtual TInt LdToParagraphStart(TInt& aCurrentPos)const; williamr@2: IMPORT_C virtual void GetParagraphFormatL(CParaFormat* aFormat,TInt aPos)const; williamr@2: IMPORT_C virtual void GetChars(TPtrC& aView,TCharFormat& aFormat,TInt aStartPos)const; williamr@2: IMPORT_C virtual TInt GetPictureSizeInTwips(TSize& aSize, TInt aPos)const; williamr@2: IMPORT_C virtual CPicture* PictureHandleL(TInt aPos,MLayDoc::TForcePictureLoad aForceLoad)const; williamr@2: IMPORT_C virtual TBool EnquirePageBreak(TInt aPos,TInt aLength=0)const; williamr@2: IMPORT_C virtual TBool SelectParagraphLabel(TInt aPos); williamr@2: IMPORT_C virtual void CancelSelectLabel(); williamr@2: // MFormatText implementation williamr@2: IMPORT_C virtual void GetParaFormatL(CParaFormat* aFormat,TParaFormatMask& aVaries,TInt aPos,TInt aLength, williamr@2: CParaFormat::TParaFormatGetMode aMode=CParaFormat::EAllAttributes)const; williamr@2: IMPORT_C virtual void ApplyParaFormatL(const CParaFormat* aFormat,const TParaFormatMask& aMask,TInt aPos,TInt aLength); williamr@2: IMPORT_C virtual void GetCharFormat(TCharFormat& aFormat,TCharFormatMask& aVaries,TInt aPos,TInt aLength)const; williamr@2: IMPORT_C virtual void ApplyCharFormatL(const TCharFormat& aFormat,const TCharFormatMask& aMask,TInt aPos,TInt aLength); williamr@2: protected: williamr@2: IMPORT_C CGlobalText(); williamr@2: IMPORT_C CGlobalText(const CParaFormatLayer* aGlobalParaLayer, williamr@2: const CCharFormatLayer* aGlobalCharLayer); williamr@2: private: williamr@2: CGlobalText(const CGlobalText& aGlobalText); williamr@2: CGlobalText& operator=(const CGlobalText& aGlobalText); williamr@2: protected: williamr@2: const CParaFormatLayer* iGlobalParaFormatLayer; // the global paragraph format layer; not owned williamr@2: const CCharFormatLayer* iGlobalCharFormatLayer; // the global character format layer; not owned williamr@2: __DECLARE_TEST; williamr@2: private: williamr@2: void* iReserved_2; williamr@2: }; williamr@2: williamr@2: williamr@2: #include williamr@2: williamr@2: williamr@2: #endif