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 __FLDBLTIN_H__ williamr@2: #define __FLDBLTIN_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: williamr@2: // Classes declared in this file williamr@2: class MFieldPageNumInfo; williamr@2: class MFieldNumPagesInfo; williamr@2: class MFieldFileNameInfo; williamr@2: // the built-in field types williamr@2: class CDateTimeField; williamr@2: class CPageNumField; williamr@2: class CNumPagesField; williamr@2: class CFileNameField; williamr@2: class TRomanNumeral; williamr@2: // williamr@2: // Classes referenced williamr@2: class RReadStream; williamr@2: class RWriteStream; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: Specifies the mixin protocol for evaluating a current page number field. williamr@2: williamr@2: You should implement the UpdateFieldPageNum() function in a concrete derived williamr@2: class, then pass an object of the class to the page number field (using CPageNumField::SetPageNumInfo()) williamr@2: before the field can be evaluated. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class MFieldPageNumInfo williamr@2: { williamr@2: public: williamr@2: williamr@2: williamr@2: /** Implementations of this function should return the current page number. williamr@2: williamr@2: @return The page number. */ williamr@2: virtual TInt UpdateFieldPageNum()const=0; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: Specifies the mixin protocol for evaluating a total number of pages field. williamr@2: williamr@2: You should implement the UpdateFieldNumPages() function in a concrete derived williamr@2: class, then pass an object of the class to the number of pages field (using williamr@2: CNumPagesField::SetNumPagesInfo()) before the field can be evaluated. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class MFieldNumPagesInfo williamr@2: { williamr@2: public: williamr@2: williamr@2: williamr@2: /** Implementations of this function should return the number of pages in the current williamr@2: document. williamr@2: williamr@2: @return The total number of pages. */ williamr@2: virtual TInt UpdateFieldNumPages()const=0; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: Specifies the mixin protocol for evaluating a filename field. williamr@2: williamr@2: You should implement the UpdateFieldFileName() function in a concrete derived williamr@2: class, then pass an object of the derived class to the filename field (using williamr@2: CFileNameField::SetFileNameInfo()) before the field can be evaluated. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class MFieldFileNameInfo williamr@2: { williamr@2: public: williamr@2: williamr@2: williamr@2: /** Implementations of this function should set aValueText to the current document's williamr@2: filename, if the buffer is large enough. If not, the function should return williamr@2: the length which is required to hold the filename. williamr@2: williamr@2: @param aValueText Descriptor which on return contains the document's filename. williamr@2: williamr@2: @return Zero if aValueText is long enough to hold the filename. Otherwise, williamr@2: the length of the buffer which is required to hold the filename. */ williamr@2: virtual TInt UpdateFieldFileName(TPtr& aValueText)const=0; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: A date/time field. williamr@2: williamr@2: This may contain any or all components of the date and time, and can be formatted williamr@2: in a variety of ways. It stores a format string, which is used by the Value() williamr@2: function to format the current date/time. For information on date/time formatting, williamr@2: see TTime::FormatL(). williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class CDateTimeField : public CTextField williamr@2: { williamr@2: public: williamr@2: IMPORT_C CDateTimeField(); williamr@2: IMPORT_C void SetFormat(const TDesC& aFormat); williamr@2: // from TTextField williamr@2: IMPORT_C virtual TInt Value(TPtr& aValueText); williamr@2: IMPORT_C virtual void InternalizeL(RReadStream& aStream); williamr@2: IMPORT_C virtual void ExternalizeL(RWriteStream& aStream)const; williamr@2: // williamr@2: // Getters williamr@2: IMPORT_C const TDesC& FormatString()const; williamr@2: IMPORT_C TUid Type()const; williamr@2: protected: williamr@2: TBuf<64> iFormatString; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: Stores a style for displaying the value of numeric fields. williamr@2: williamr@2: This style is used when converting the integer value of numeric fields into williamr@2: a descriptor for display in another format, e.g. Arabic, Roman, alphabetic. williamr@2: This is the base class for the numeric fields, CPageNumField and CNumPagesField. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class CPageFieldBase : public CTextField williamr@2: { williamr@2: public: williamr@2: /** Numeric style */ williamr@2: enum TNumberStyle { williamr@2: /** Arabic numeral, e.g. 1, 2, 3. */ williamr@2: EArabic, // 1,2,3 williamr@2: /** Upper case Roman numeral, e.g. I, II, III. */ williamr@2: ERomanUpper, // I,II,III williamr@2: /** Lower case Roman numeral, e.g. i, ii, iii. */ williamr@2: ERomanLower, // i,ii,iii williamr@2: /** Upper case alphabetic. */ williamr@2: EAlphabeticUpper, // A,B,C williamr@2: /** Lower case alphabetic. */ williamr@2: EAlphabeticLower // a,b,c williamr@2: }; williamr@2: public: williamr@2: williamr@2: /** Sets the numeric style. williamr@2: williamr@2: @param aStyle The numeric style. */ williamr@2: inline void SetNumberStyle(TNumberStyle aStyle) { iStyle = aStyle; } williamr@2: // from TTextField williamr@2: IMPORT_C void InternalizeL(RReadStream& aStream); williamr@2: IMPORT_C void ExternalizeL(RWriteStream& aStream)const; williamr@2: // williamr@2: // Getters williamr@2: IMPORT_C TNumberStyle NumberStyle()const; williamr@2: protected: williamr@2: TInt InsertValue(TPtr& aValueText,TInt aValue); williamr@2: protected: williamr@2: TNumberStyle iStyle; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: A field which evaluates to the current page number in the document. williamr@2: williamr@2: Before the page number field can be evaluated, it must be passed a pointer williamr@2: to an object which implements the UpdateFieldPageNum() function. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class CPageNumField : public CPageFieldBase williamr@2: { williamr@2: public: williamr@2: /** Sets the object which implements UpdateFieldPageNum(), to get the current page williamr@2: number. SetPageNumInfo() must be called before the page number field can be williamr@2: evaluated. williamr@2: williamr@2: @param aInfo Pointer to an object which implements UpdateFieldPageNum(). */ williamr@2: inline void SetPageNumInfo(MFieldPageNumInfo* aInfo) { iPageNumInfo=aInfo; } williamr@2: // from TTextField williamr@2: IMPORT_C TInt Value(TPtr& aValueText); williamr@2: IMPORT_C TUid Type()const; williamr@2: protected: williamr@2: MFieldPageNumInfo* iPageNumInfo; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: A field which evaluates to the number of pages in the document. williamr@2: williamr@2: Before the number of pages field can be evaluated, it must be passed a pointer williamr@2: to an object which implements the UpdateFieldNumPages() function. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class CNumPagesField : public CPageFieldBase williamr@2: { williamr@2: public: williamr@2: /** Sets the object which implements UpdateFieldNumPages(), to get the number of williamr@2: pages in the document. SetNumPagesInfo() must be called before the number williamr@2: of pages field can be evaluated. williamr@2: williamr@2: @param aInfo Pointer to an object which implements UpdateFieldNumPages(). */ williamr@2: inline void SetNumPagesInfo(MFieldNumPagesInfo* aInfo) { iNumPagesInfo=aInfo; } williamr@2: // from TTextField williamr@2: IMPORT_C TInt Value(TPtr& aValueText); williamr@2: IMPORT_C TUid Type()const; williamr@2: protected: williamr@2: MFieldNumPagesInfo* iNumPagesInfo; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: A filename field. williamr@2: williamr@2: This is a field which evaluates to the filename of the current document. Before williamr@2: the filename field can be evaluated, it must be passed a pointer to an object williamr@2: which implements the UpdateFieldFileName() function. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class CFileNameField : public CTextField williamr@2: { williamr@2: public: williamr@2: /** Sets the object which implements the UpdateFieldFileName() function, to get williamr@2: the current document's filename. SetFileNameInfo() must be called before the williamr@2: filename field can be evaluated. williamr@2: williamr@2: @param aInfo Pointer to an object which implements the UpdateFieldFileName() williamr@2: function. */ williamr@2: inline void SetFileNameInfo(MFieldFileNameInfo* aInfo) { iFileNameInfo=aInfo; } williamr@2: // from TTextField williamr@2: IMPORT_C virtual TStreamId StoreL(CStreamStore& aStore)const; // returns KNullStreamId williamr@2: IMPORT_C virtual void RestoreL(const CStreamStore& aStore,TStreamId aId); // does nothing. williamr@2: IMPORT_C virtual TInt Value(TPtr& aValueText); williamr@2: williamr@2: williamr@2: /** Overrides the base class method to do nothing, because this class has no persistent williamr@2: data. */ williamr@2: inline virtual void InternalizeL(RReadStream& /*aStream*/) {}; // stream the formatting williamr@2: IMPORT_C TUid Type()const; williamr@2: protected: williamr@2: MFieldFileNameInfo* iFileNameInfo; williamr@2: }; williamr@2: williamr@2: williamr@2: #endif