williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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 williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __PRNINF_H__ williamr@2: #define __PRNINF_H__ williamr@2: williamr@2: #if !defined(__E32STD_H__) williamr@2: #include williamr@2: #endif williamr@2: #if !defined(__GDI_H__) williamr@2: #include williamr@2: #endif williamr@2: #if !defined(__FLDBASE_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: // Classes defined williamr@2: //class TPageNumbers; williamr@2: class CHeaderFooter; williamr@2: class TPrintParameters; williamr@2: class TPageMargins; williamr@2: class MPrintProcessObserver; williamr@2: williamr@2: // classes referenced williamr@2: class RReadStream; williamr@2: class RWriteStream; williamr@2: class CRichText; williamr@2: class CParaFormatLayer; williamr@2: class CCharFormatLayer; williamr@2: class MFieldFileNameInfo; williamr@2: class MFieldPageNumInfo; williamr@2: class MFieldNumPagesInfo; williamr@2: ////////////////// williamr@2: williamr@2: williamr@2: class TPrintParameters williamr@2: /** Print parameters. williamr@2: williamr@2: This data is associated with a particular print request, not with the document williamr@2: to be printed, so is separate from the print setup information. williamr@2: williamr@2: An object of this class is passed to CPrintSetup::StartPrintL() and to CPrintSetup::StartPreviewPrintL(). williamr@2: williamr@2: @see CPrintSetup williamr@2: @publishedAll williamr@2: @released */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TPrintParameters(); // sets to 1,0,0 williamr@2: public: williamr@2: /** The number of copies to print. */ williamr@2: TInt iNumCopies; williamr@2: /** The first page to be printed. williamr@2: williamr@2: This value should be less than or equal to iLastPage. Zero indicates the first page williamr@2: in the document. */ williamr@2: TInt iFirstPage; williamr@2: /** The last page to be printed. williamr@2: williamr@2: This value should be greater than or equal to iFirstPage. Zero indicates the first williamr@2: page in the document. */ williamr@2: TInt iLastPage; williamr@2: }; williamr@2: williamr@2: class TPageMargins williamr@2: /** Page margins. williamr@2: williamr@2: Page margins are accessed via the public iPageMarginsInTwips member of class williamr@2: CPrintSetup. A single margin settings object applies throughout a document, williamr@2: so that gutter margins are not supported. williamr@2: williamr@2: If the document contains headers and footers, they are located within the williamr@2: top and bottom margins respectively. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C void InternalizeL(RReadStream& aStream); williamr@2: IMPORT_C void ExternalizeL(RWriteStream& aStream)const; williamr@2: public: williamr@2: /** The distance between the top of the header and the top of the page in twips williamr@2: or pixels. williamr@2: williamr@2: This must be less than the height of the top margin to ensure that the header williamr@2: is visible. */ williamr@2: TInt iHeaderOffset; williamr@2: /** The distance between the top of the footer and the top of the bottom margin williamr@2: in twips or pixels. williamr@2: williamr@2: This must be less than the height of the bottom margin to ensure that the williamr@2: footer is visible. */ williamr@2: TInt iFooterOffset; williamr@2: /** The widths of each of the four margins in twips or pixels. williamr@2: williamr@2: @see TMargins */ williamr@2: TMargins iMargins; williamr@2: }; williamr@2: williamr@2: class CHeaderFooter : public CBase, private MTextFieldFactory williamr@2: /** A document header or footer. williamr@2: williamr@2: The header is located in the top page margin and the footer in the williamr@2: bottom page margin. No more than one header or footer can exist in a document. williamr@2: williamr@2: CHeaderFooter derives from MTextFieldFactory. This allows the insertion of williamr@2: various fields, including page number, current date or time and filename. williamr@2: williamr@2: Rich text manipulation and formatting functions can be accessed through williamr@2: the rich text object which is owned by the header/footer. williamr@2: williamr@2: The header and footer are retrieved using the CPrintSetup::Header() and Footer() williamr@2: functions and they are stored and restored together with the rest of the print williamr@2: setup information. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CHeaderFooter* NewL(); williamr@2: IMPORT_C virtual ~CHeaderFooter(); williamr@2: // williamr@2: IMPORT_C void CreateTextL(); williamr@2: IMPORT_C void SetFirstPageToPrintTo(TInt aPageNum); // allows the first few pages of a doc not to have a header on them williamr@2: inline TInt FirstPageToPrintTo()const; // relative to the first page being numbered 0 williamr@2: // williamr@2: // persistence williamr@2: IMPORT_C TStreamId StoreL(CStreamStore& aStore)const; williamr@2: IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aStreamId,MPictureFactory* aFactory); williamr@2: IMPORT_C void StoreComponentsL(CStreamStore& aStore,CStoreMap& aMap)const; williamr@2: IMPORT_C void RestoreComponentsL(const CStreamStore& aStore,MPictureFactory* aFactory); williamr@2: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; williamr@2: IMPORT_C void InternalizeL(RReadStream& aStream); williamr@2: // williamr@2: // text bits williamr@2: IMPORT_C CRichText* Text()const; williamr@2: IMPORT_C CParaFormatLayer* ParaFormat()const; williamr@2: IMPORT_C CCharFormatLayer* CharFormat()const; williamr@2: IMPORT_C void SetText(CRichText* aText); // takes ownership williamr@2: IMPORT_C void SetParaFormat(CParaFormatLayer* aParaFormat); // takes ownership williamr@2: IMPORT_C void SetCharFormat(CCharFormatLayer* aCharFormat); // takes ownership williamr@2: // williamr@2: // field bits williamr@2: IMPORT_C void SetFileNameInfo(const MFieldFileNameInfo& aFileNameInfo); // call if you want headers/footers to support filename fields williamr@2: IMPORT_C void SetNumPagesInfo(const MFieldNumPagesInfo& aNumPagesInfo); // call if you want headers/footers to support "total number of pages" fields williamr@2: inline MFieldFileNameInfo* FileNameFieldInfo()const; williamr@2: inline MFieldNumPagesInfo* NumPagesFieldInfo()const; williamr@2: // williamr@2: void SetPageNumInfo(const MFieldPageNumInfo& aPageNumInfo); // called by CPrintSetup williamr@2: private: williamr@2: CHeaderFooter(); williamr@2: void CreateFormatLayersL(); williamr@2: // from MTextFieldFactory williamr@2: CTextField* NewFieldL(TUid aFieldType); williamr@2: private: williamr@2: TInt iFirstPageToPrintTo; // relative to the first page being numbered 0 williamr@2: MFieldFileNameInfo* iFileNameInfo; williamr@2: MFieldPageNumInfo* iPageNumInfo; williamr@2: MFieldNumPagesInfo* iNumPagesInfo; williamr@2: CRichText* iText; // RichText Doc Handle williamr@2: CParaFormatLayer* iParaLayer; williamr@2: CCharFormatLayer* iCharLayer; williamr@2: private: williamr@2: enum { ETextExists = 0x0001 }; williamr@2: }; williamr@2: williamr@2: class MPrintProcessObserver williamr@2: /** Print progress and status notification interface class. williamr@2: williamr@2: The notification functions are called before, during and after a print or williamr@2: print preview operation, to give notification of its progress. williamr@2: williamr@2: The print process observer will often be the GUI's standard print progress williamr@2: or print preview dialog. williamr@2: williamr@2: An object of a class which implements this interface may be passed as a parameter williamr@2: to CPrintSetup::StartPrintL(), or to CPrintSetup::StartPreviewPrintL(). williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: { williamr@2: public: williamr@2: /** Notifies that a print or print preview operation is about to begin. williamr@2: williamr@2: It may be used to display information about the document to be printed. It williamr@2: is called once, immediately before printing or print previewing begins. williamr@2: williamr@2: When subclassing, add variables to store initialisation information as required. williamr@2: williamr@2: @param aPrintParams The parameters for the print job. */ williamr@2: virtual void NotifyPrintStarted(TPrintParameters aPrintParams)=0; williamr@2: /** Notifies that a band is about to be printed. williamr@2: williamr@2: It may be used to display print progress information, including the current williamr@2: page number. It is called immediately before each band is printed. williamr@2: williamr@2: @param aPercentageOfPagePrinted The percentage of the page that has been printed. williamr@2: @param aCurrentPageNum The number of the page currently being printed. williamr@2: @param aCurrentCopyNum The number of the copy currently being printed (if multiple williamr@2: copies are being printed). */ williamr@2: virtual void NotifyBandPrinted(TInt aPercentageOfPagePrinted, TInt aCurrentPageNum, TInt aCurrentCopyNum)=0; williamr@2: /** Notifies that the print or print preview operation has completed. williamr@2: williamr@2: It may be used to display information about how the operation completed, for williamr@2: example any errors that occurred. It is called once, immediately after the williamr@2: print job terminates. williamr@2: williamr@2: @param anErrorCode KErrNone if the print job completed successfully, otherwise williamr@2: another of the system-wide error codes. */ williamr@2: virtual void NotifyPrintEnded(TInt anErrorCode)=0; williamr@2: // williamr@2: }; williamr@2: williamr@2: williamr@2: // williamr@2: // inlines williamr@2: // williamr@2: williamr@2: inline TInt CHeaderFooter::FirstPageToPrintTo()const williamr@2: /** Gets the first page on which the header or footer is to be printed. williamr@2: williamr@2: Page numbering begins at zero. williamr@2: williamr@2: @return The number of the first page on which the header or footer is to be williamr@2: printed. */ williamr@2: { return iFirstPageToPrintTo; } williamr@2: williamr@2: inline MFieldFileNameInfo* CHeaderFooter::FileNameFieldInfo()const williamr@2: /** Gets the object which implements the MFieldFileNameInfo interface, as set by williamr@2: SetFileNameInfo(). williamr@2: williamr@2: @return The object which implements the MFieldFileNameInfo interface. */ williamr@2: { return iFileNameInfo; } williamr@2: williamr@2: inline MFieldNumPagesInfo* CHeaderFooter::NumPagesFieldInfo()const williamr@2: /** Gets the object which implements the MFieldNumPagesInfo interface, as set by williamr@2: SetNumPagesInfo(). williamr@2: williamr@2: @return The object which implements the MFieldNumPagesInfo interface. */ williamr@2: { return iNumPagesInfo; } williamr@2: williamr@2: #endif