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 "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __PRNSETUP_H__
17 #define __PRNSETUP_H__
19 #if !defined(__E32STD_H__)
22 #if !defined(__E32BASE_H__)
25 #if !defined(__FLDBLTIN_H__)
28 #if !defined(__PRNINF_H__)
32 #ifndef SYMBIAN_ENABLE_MIXED_HEADERS
33 #include <printinguisupport/prnpath.h>
39 const TInt KErrMorePages=4747; // Leave with this error code to print extra pages in PrintBandL
46 class CPreviewProcess;
54 class MPageRegionPrinter;
57 class CPrinterDriverUI;
60 class CPrintSetup : public CBase, private MFieldPageNumInfo
61 /** Print setup information.
63 This class stores the information needed to set up, start and stop a print
64 job. This includes the target printer device, the page margins and
65 the header and footer. The page specification, (page orientation and page
66 dimensions) can be set via the printer device.
68 Print setup information is associated with a document and is stored as part
69 of the persistent form of the document. Print parameters on the other hand,
70 (class TPrintParameters) are associated with a particular print request,
71 not with the document itself, so are not part of the print setup information.
77 IMPORT_C static CPrintSetup* NewL();
78 IMPORT_C virtual ~CPrintSetup();
80 // printer model selection/control functions
81 IMPORT_C void AddPrinterDriverDirL(const TDesC& aDriverDir);
82 IMPORT_C CPrinterModelList* ModelNameListL(RFs& aFs);
83 IMPORT_C void FreeModelList();
84 IMPORT_C void CreatePrinterDeviceL(TInt aModelIndex); // requires ModelList to exist
85 IMPORT_C void CreatePrinterDeviceL(TUid aModelUid,RFs& aFs);
86 IMPORT_C CPrinterDevice* PrinterDevice()const;
87 IMPORT_C CPrinterDriverUI* CreatePrinterDriverUIL(); // ownership is transfered to the caller
90 IMPORT_C void EndPrint();
91 IMPORT_C TInt StartPrintL(const TPrintParameters& aPrintParams,MPageRegionPrinter& aBodyPrinter,
92 CPrinterPort* aPort,MPrintProcessObserver* anObserver);
93 IMPORT_C TInt StartPreviewPrintL(const TPrintParameters& aPrintParams,MPageRegionPrinter& aBodyPrinter,
94 MPrintProcessObserver* anObserver,CGraphicsDevice& aPreviewDev,const TRect& aHeaderRectInPixels,
95 const TRect& aFooterRectInPixels,TInt aNumBands);
98 inline CHeaderFooter* Header()const;
99 inline CHeaderFooter* Footer()const;
102 IMPORT_C TStreamId StoreL(CStreamStore& aStore)const;
103 IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aStreamId,const MFieldFileNameInfo* aFileNameInfo=NULL,const MFieldNumPagesInfo* aNumPagesInfo=NULL,MPictureFactory* aFactory=NULL);
104 IMPORT_C void StoreComponentsL(CStreamStore& aStore,CStoreMap& aMap)const;
105 IMPORT_C void RestoreComponentsL(const CStreamStore& aStore,const MFieldFileNameInfo* aFileNameInfo=NULL,const MFieldNumPagesInfo* aNumPagesInfo=NULL,MPictureFactory* aFactory=NULL);
106 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
107 IMPORT_C void InternalizeL(RReadStream& aStream);
112 void DoStartPrintL(const TPrintParameters& aPrintParams,MPageRegionPrinter& aBodyPrinter,MPrintProcessObserver* aObserver,CPrinterPort* aPort);
113 void InitializePrintingL(CGraphicsDevice* aPrinterDev,const TPrintParameters& aPrintParams,MPrintProcessObserver* aObserver);
114 void InitializePrintingL(const TPrintParameters& aPrintParams,MPrintProcessObserver* aObserver,
115 const TRect& aHeaderRectInPixels,const TRect& aFooterRectInPixels);
116 // from MFieldPageNumInfo
117 TInt UpdateFieldPageNum()const;
119 // Info regarding print setup etc.
120 /** The header and footer offset and the width of the four margins.
122 All measurements are in twips.
125 TPageMargins iPageMarginsInTwips;
126 /** The number of the first page in the document.
128 This value is used for printing or displaying page numbering. Note that all
129 other page numbering is zero indexed, to preserve independence from user-defined
131 TInt iNumOfFirstPage; // value to start page numbering at
134 ENumberFirstPage = 0x0001,
137 CHeaderFooter* iHeader;
138 CHeaderFooter* iFooter;
139 CPrinterDriver* iPrinterDriver; // the target printer driver
140 CPreviewProcess* iPrintProcess;
141 CPdrModelList* iModelList;
142 MPrintProcessObserver* iPrintObserver;
143 TPrintParameters iPrintParams; // not persisted
144 CArrayFixSeg<TFileName>* iDriverDirList;
152 inline CHeaderFooter* CPrintSetup::Header()const
155 The CPrintSetup object owns the header and footer. CPrintSetup implements
156 the MFieldPageNumInfo interface, which allows page numbering to be easily
159 @return The header. */
162 inline CHeaderFooter* CPrintSetup::Footer()const
165 @return The footer. */