1 txtlaydc.h |
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __TXTLAYDC_H__ |
|
17 #define __TXTLAYDC_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 |
|
21 class CParaFormat; |
|
22 class TCharFormat; |
|
23 class CPicture; |
|
24 |
|
25 |
|
26 class MLayDoc |
|
27 /** |
|
28 Specifies the interface for providing the information needed by the text |
|
29 layout engine to lay out a text object. |
|
30 |
|
31 Examples of derived classes are CRichText and CGlobalText. |
|
32 |
|
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. |
|
38 |
|
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) |
|
44 @publishedAll |
|
45 @released |
|
46 */ |
|
47 { |
|
48 // Defines interface for extracting content & format information from text source. |
|
49 // Designed to be 'mixed-in' with other classes. |
|
50 // |
|
51 public: |
|
52 |
|
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 |
|
56 { |
|
57 /** Do not load the picture data into memory. */ |
|
58 EForceLoadFalse, |
|
59 /** Load the picture data into memory. */ |
|
60 EForceLoadTrue |
|
61 }; |
|
62 public: |
|
63 |
|
64 /** Gets the the number of characters in the document. |
|
65 |
|
66 @return The number of characters contained in the document. */ |
|
67 virtual TInt LdDocumentLength()const=0; // Does not include final document terminator |
|
68 |
|
69 /** Gets the document position of the start of the paragraph containing a |
|
70 specified position. |
|
71 |
|
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 |
|
75 paragraph. */ |
|
76 virtual TInt LdToParagraphStart(TInt& aCurrentPos)const=0; |
|
77 |
|
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. |
|
81 |
|
82 @param aFormat On return, filled with the paragraph's effective paragraph |
|
83 formatting. |
|
84 @param aPos Any document position within the paragraph of interest. */ |
|
85 virtual void GetParagraphFormatL(CParaFormat* aFormat,TInt aPos)const=0; |
|
86 |
|
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: |
|
90 |
|
91 the last character which shares the same character formatting (rich text |
|
92 only), or |
|
93 |
|
94 the end of the document, or |
|
95 |
|
96 the end of the segment, if segmented storage is being used |
|
97 |
|
98 whichever occurs first. |
|
99 |
|
100 Also fills a character format object with the character formatting of the |
|
101 range of characters. |
|
102 |
|
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; |
|
108 |
|
109 /** Gets the size of a picture located at a specified document position. |
|
110 |
|
111 Note: The global text implementation of this function always returns |
|
112 KErrNotFound because global text does not support pictures. |
|
113 |
|
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; |
|
119 |
|
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). |
|
123 |
|
124 Note: The global text implementation of this function always returns NULL |
|
125 because global text does not support pictures. |
|
126 |
|
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; |
|
135 |
|
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(). |
|
138 |
|
139 @param aPos The document position from which to begin searching for a page |
|
140 break. |
|
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 |
|
144 EFalse. */ |
|
145 virtual TBool EnquirePageBreak(TInt aPos,TInt aLength=0)const=0; |
|
146 |
|
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 |
|
153 text. |
|
154 |
|
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). |
|
158 |
|
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; |
|
164 |
|
165 /** Cancels a paragraph label selection made by a call to |
|
166 SelectParagraphLabel() so that the main document reverts back to the main |
|
167 body of text. */ |
|
168 virtual void CancelSelectLabel()=0; |
|
169 |
|
170 /** |
|
171 @internalAll |
|
172 @prototype |
|
173 */ |
|
174 IMPORT_C virtual void MLayDoc_Reserved_1(); |
|
175 }; |
|
176 |
|
177 #endif |