1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // 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
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __TXTLAYDC_H__
17 #define __TXTLAYDC_H__
28 Specifies the interface for providing the information needed by the text
29 layout engine to lay out a text object.
31 Examples of derived classes are CRichText and CGlobalText.
33 At the heart of the interface are two interrogation functions; one gives the
34 paragraph formatting for a document position, and the other gives a pointer
35 descriptor to a series of contiguous characters with identical character
36 formatting, and their character formatting. This information is sufficient
37 for the layout engine to find the formatting and content of an entire document.
39 The constructor for the layout engine (CTextLayout) is prototyped as:
40 static CTextLayout *NewL(MLayDoc *aDoc,TInt aWrapWidth);
41 By viewing the text object purely in terms of the MLayDoc interface, the layout
42 engine is insulated from any editable text implementation issues.
43 @see static CTextLayout *NewL(MLayDoc *aDoc,TInt aWrapWidth)
48 // Defines interface for extracting content & format information from text source.
49 // Designed to be 'mixed-in' with other classes.
53 /** Used as a parameter to the PictureHandleL() function to control whether
54 picture data should be loaded into memory or not. */
55 enum TForcePictureLoad
57 /** Do not load the picture data into memory. */
59 /** Load the picture data into memory. */
64 /** Gets the the number of characters in the document.
66 @return The number of characters contained in the document. */
67 virtual TInt LdDocumentLength()const=0; // Does not include final document terminator
69 /** Gets the document position of the start of the paragraph containing a
72 @param aCurrentPos A valid document position. On return contains the
73 document position of the first character in the paragraph.
74 @return The number of characters skipped in scanning to the start of the
76 virtual TInt LdToParagraphStart(TInt& aCurrentPos)const=0;
78 /** Gets the effective paragraph formatting which applies to the paragraph
79 which contains a specified document position. On return, aFormat is filled
80 with values for all paragraph format attributes.
82 @param aFormat On return, filled with the paragraph's effective paragraph
84 @param aPos Any document position within the paragraph of interest. */
85 virtual void GetParagraphFormatL(CParaFormat* aFormat,TInt aPos)const=0;
87 /** Gets a constant pointer descriptor to a portion of the text object with
88 constant character formatting. The view starts at the document position
89 specified, and ends at:
91 the last character which shares the same character formatting (rich text
94 the end of the document, or
96 the end of the segment, if segmented storage is being used
98 whichever occurs first.
100 Also fills a character format object with the character formatting of the
103 @param aView On return, a constant pointer to a portion of the text.
104 @param aFormat On return, contains the character formatting of the text.
105 @param aStartPos The start position for the view. Must be a valid document
106 position, or a panic occurs. */
107 virtual void GetChars(TPtrC& aView,TCharFormat& aFormat,TInt aStartPos)const=0;
109 /** Gets the size of a picture located at a specified document position.
111 Note: The global text implementation of this function always returns
112 KErrNotFound because global text does not support pictures.
114 @param aSize On return, contains the size of the picture located at aPos.
115 @param aPos Document position of the picture.
116 @return KErrNotFound if there is no picture at the specified document
117 position, KErrNone if there is. */
118 virtual TInt GetPictureSizeInTwips(TSize& aSize, TInt aPos)const=0;
120 /** Gets a pointer to the picture located at a specified document position,
121 if one exists. If the picture is not in memory, the function loads it (if
122 the second argument has a value of EForceLoadTrue).
124 Note: The global text implementation of this function always returns NULL
125 because global text does not support pictures.
127 @param aPos Document position of the picture character.
128 @param aForceLoad If the picture is not loaded into memory, EForceLoadTrue
129 loads it using the picture factory; EForceLoadFalse does not, and in this
130 case, the function returns NULL.
131 @return A pointer to the picture located at aPos. NULL if aPos does not
132 specify a picture character, or if there is a picture at aPos which is not
133 in memory, and the second argument is EForceLoadFalse. */
134 virtual CPicture* PictureHandleL(TInt aPos,TForcePictureLoad aForceLoad=EForceLoadTrue)const=0;
136 /** Tests whether a page break occurs within a range of characters. A page
137 table should have been set up first: see CPlainText::SetPageTable().
139 @param aPos The document position from which to begin searching for a page
141 @param aLength The number of characters to search for a page break,
142 beginning at aPos. The default is zero.
143 @return ETrue if a page break occurs within the specified range, otherwise
145 virtual TBool EnquirePageBreak(TInt aPos,TInt aLength=0)const=0;
147 /** This function should be implemented by text objects which support
148 paragraph labels. Each paragraph may have at most one label. By default,
149 the functions provided by MLayDoc apply to the main body of text. This
150 function is provided to change this so that the MLayDoc object is an
151 individual paragraph label, (each of which is treated as a separate
152 document). Paragraph labelling has not been implemented by global or rich
155 This function should select the paragraph label associated with the
156 paragraph containing document position aPos (aPos is a document position
157 in the main document).
159 @param aPos A document position within a paragraph. This paragraph's label
160 should be set as the main MLayDoc document.
161 @return Should return EFalse if the paragraph has no label, in which case
162 the function has no effect, ETrue otherwise. */
163 virtual TBool SelectParagraphLabel(TInt aPos)=0;
165 /** Cancels a paragraph label selection made by a call to
166 SelectParagraphLabel() so that the main document reverts back to the main
168 virtual void CancelSelectLabel()=0;
174 IMPORT_C virtual void MLayDoc_Reserved_1();