1 // Copyright (c) 1997-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 __FLDBLTIN_H__
17 #define __FLDBLTIN_H__
23 // Classes declared in this file
24 class MFieldPageNumInfo;
25 class MFieldNumPagesInfo;
26 class MFieldFileNameInfo;
27 // the built-in field types
41 Specifies the mixin protocol for evaluating a current page number field.
43 You should implement the UpdateFieldPageNum() function in a concrete derived
44 class, then pass an object of the class to the page number field (using CPageNumField::SetPageNumInfo())
45 before the field can be evaluated.
49 class MFieldPageNumInfo
54 /** Implementations of this function should return the current page number.
56 @return The page number. */
57 virtual TInt UpdateFieldPageNum()const=0;
62 Specifies the mixin protocol for evaluating a total number of pages field.
64 You should implement the UpdateFieldNumPages() function in a concrete derived
65 class, then pass an object of the class to the number of pages field (using
66 CNumPagesField::SetNumPagesInfo()) before the field can be evaluated.
70 class MFieldNumPagesInfo
75 /** Implementations of this function should return the number of pages in the current
78 @return The total number of pages. */
79 virtual TInt UpdateFieldNumPages()const=0;
85 Specifies the mixin protocol for evaluating a filename field.
87 You should implement the UpdateFieldFileName() function in a concrete derived
88 class, then pass an object of the derived class to the filename field (using
89 CFileNameField::SetFileNameInfo()) before the field can be evaluated.
93 class MFieldFileNameInfo
98 /** Implementations of this function should set aValueText to the current document's
99 filename, if the buffer is large enough. If not, the function should return
100 the length which is required to hold the filename.
102 @param aValueText Descriptor which on return contains the document's filename.
104 @return Zero if aValueText is long enough to hold the filename. Otherwise,
105 the length of the buffer which is required to hold the filename. */
106 virtual TInt UpdateFieldFileName(TPtr& aValueText)const=0;
114 This may contain any or all components of the date and time, and can be formatted
115 in a variety of ways. It stores a format string, which is used by the Value()
116 function to format the current date/time. For information on date/time formatting,
117 see TTime::FormatL().
121 class CDateTimeField : public CTextField
124 IMPORT_C CDateTimeField();
125 IMPORT_C void SetFormat(const TDesC& aFormat);
127 IMPORT_C virtual TInt Value(TPtr& aValueText);
128 IMPORT_C virtual void InternalizeL(RReadStream& aStream);
129 IMPORT_C virtual void ExternalizeL(RWriteStream& aStream)const;
132 IMPORT_C const TDesC& FormatString()const;
133 IMPORT_C TUid Type()const;
135 TBuf<64> iFormatString;
142 Stores a style for displaying the value of numeric fields.
144 This style is used when converting the integer value of numeric fields into
145 a descriptor for display in another format, e.g. Arabic, Roman, alphabetic.
146 This is the base class for the numeric fields, CPageNumField and CNumPagesField.
150 class CPageFieldBase : public CTextField
155 /** Arabic numeral, e.g. 1, 2, 3. */
157 /** Upper case Roman numeral, e.g. I, II, III. */
158 ERomanUpper, // I,II,III
159 /** Lower case Roman numeral, e.g. i, ii, iii. */
160 ERomanLower, // i,ii,iii
161 /** Upper case alphabetic. */
162 EAlphabeticUpper, // A,B,C
163 /** Lower case alphabetic. */
164 EAlphabeticLower // a,b,c
168 /** Sets the numeric style.
170 @param aStyle The numeric style. */
171 inline void SetNumberStyle(TNumberStyle aStyle) { iStyle = aStyle; }
173 IMPORT_C void InternalizeL(RReadStream& aStream);
174 IMPORT_C void ExternalizeL(RWriteStream& aStream)const;
177 IMPORT_C TNumberStyle NumberStyle()const;
179 TInt InsertValue(TPtr& aValueText,TInt aValue);
187 A field which evaluates to the current page number in the document.
189 Before the page number field can be evaluated, it must be passed a pointer
190 to an object which implements the UpdateFieldPageNum() function.
194 class CPageNumField : public CPageFieldBase
197 /** Sets the object which implements UpdateFieldPageNum(), to get the current page
198 number. SetPageNumInfo() must be called before the page number field can be
201 @param aInfo Pointer to an object which implements UpdateFieldPageNum(). */
202 inline void SetPageNumInfo(MFieldPageNumInfo* aInfo) { iPageNumInfo=aInfo; }
204 IMPORT_C TInt Value(TPtr& aValueText);
205 IMPORT_C TUid Type()const;
207 MFieldPageNumInfo* iPageNumInfo;
213 A field which evaluates to the number of pages in the document.
215 Before the number of pages field can be evaluated, it must be passed a pointer
216 to an object which implements the UpdateFieldNumPages() function.
220 class CNumPagesField : public CPageFieldBase
223 /** Sets the object which implements UpdateFieldNumPages(), to get the number of
224 pages in the document. SetNumPagesInfo() must be called before the number
225 of pages field can be evaluated.
227 @param aInfo Pointer to an object which implements UpdateFieldNumPages(). */
228 inline void SetNumPagesInfo(MFieldNumPagesInfo* aInfo) { iNumPagesInfo=aInfo; }
230 IMPORT_C TInt Value(TPtr& aValueText);
231 IMPORT_C TUid Type()const;
233 MFieldNumPagesInfo* iNumPagesInfo;
242 This is a field which evaluates to the filename of the current document. Before
243 the filename field can be evaluated, it must be passed a pointer to an object
244 which implements the UpdateFieldFileName() function.
248 class CFileNameField : public CTextField
251 /** Sets the object which implements the UpdateFieldFileName() function, to get
252 the current document's filename. SetFileNameInfo() must be called before the
253 filename field can be evaluated.
255 @param aInfo Pointer to an object which implements the UpdateFieldFileName()
257 inline void SetFileNameInfo(MFieldFileNameInfo* aInfo) { iFileNameInfo=aInfo; }
259 IMPORT_C virtual TStreamId StoreL(CStreamStore& aStore)const; // returns KNullStreamId
260 IMPORT_C virtual void RestoreL(const CStreamStore& aStore,TStreamId aId); // does nothing.
261 IMPORT_C virtual TInt Value(TPtr& aValueText);
264 /** Overrides the base class method to do nothing, because this class has no persistent
266 inline virtual void InternalizeL(RReadStream& /*aStream*/) {}; // stream the formatting
267 IMPORT_C TUid Type()const;
269 MFieldFileNameInfo* iFileNameInfo;