1 prninf.h |
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __PRNINF_H__ |
|
17 #define __PRNINF_H__ |
|
18 |
|
19 #if !defined(__E32STD_H__) |
|
20 #include <e32std.h> |
|
21 #endif |
|
22 #if !defined(__GDI_H__) |
|
23 #include <gdi.h> |
|
24 #endif |
|
25 #if !defined(__FLDBASE_H__) |
|
26 #include <fldbase.h> |
|
27 #endif |
|
28 |
|
29 // Classes defined |
|
30 //class TPageNumbers; |
|
31 class CHeaderFooter; |
|
32 class TPrintParameters; |
|
33 class TPageMargins; |
|
34 class MPrintProcessObserver; |
|
35 |
|
36 // classes referenced |
|
37 class RReadStream; |
|
38 class RWriteStream; |
|
39 class CRichText; |
|
40 class CParaFormatLayer; |
|
41 class CCharFormatLayer; |
|
42 class MFieldFileNameInfo; |
|
43 class MFieldPageNumInfo; |
|
44 class MFieldNumPagesInfo; |
|
45 ////////////////// |
|
46 |
|
47 |
|
48 class TPrintParameters |
|
49 /** Print parameters. |
|
50 |
|
51 This data is associated with a particular print request, not with the document |
|
52 to be printed, so is separate from the print setup information. |
|
53 |
|
54 An object of this class is passed to CPrintSetup::StartPrintL() and to CPrintSetup::StartPreviewPrintL(). |
|
55 |
|
56 @see CPrintSetup |
|
57 @publishedAll |
|
58 @released */ |
|
59 { |
|
60 public: |
|
61 IMPORT_C TPrintParameters(); // sets to 1,0,0 |
|
62 public: |
|
63 /** The number of copies to print. */ |
|
64 TInt iNumCopies; |
|
65 /** The first page to be printed. |
|
66 |
|
67 This value should be less than or equal to iLastPage. Zero indicates the first page |
|
68 in the document. */ |
|
69 TInt iFirstPage; |
|
70 /** The last page to be printed. |
|
71 |
|
72 This value should be greater than or equal to iFirstPage. Zero indicates the first |
|
73 page in the document. */ |
|
74 TInt iLastPage; |
|
75 }; |
|
76 |
|
77 class TPageMargins |
|
78 /** Page margins. |
|
79 |
|
80 Page margins are accessed via the public iPageMarginsInTwips member of class |
|
81 CPrintSetup. A single margin settings object applies throughout a document, |
|
82 so that gutter margins are not supported. |
|
83 |
|
84 If the document contains headers and footers, they are located within the |
|
85 top and bottom margins respectively. |
|
86 |
|
87 @publishedAll |
|
88 @released */ |
|
89 { |
|
90 public: |
|
91 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
92 IMPORT_C void ExternalizeL(RWriteStream& aStream)const; |
|
93 public: |
|
94 /** The distance between the top of the header and the top of the page in twips |
|
95 or pixels. |
|
96 |
|
97 This must be less than the height of the top margin to ensure that the header |
|
98 is visible. */ |
|
99 TInt iHeaderOffset; |
|
100 /** The distance between the top of the footer and the top of the bottom margin |
|
101 in twips or pixels. |
|
102 |
|
103 This must be less than the height of the bottom margin to ensure that the |
|
104 footer is visible. */ |
|
105 TInt iFooterOffset; |
|
106 /** The widths of each of the four margins in twips or pixels. |
|
107 |
|
108 @see TMargins */ |
|
109 TMargins iMargins; |
|
110 }; |
|
111 |
|
112 class CHeaderFooter : public CBase, private MTextFieldFactory |
|
113 /** A document header or footer. |
|
114 |
|
115 The header is located in the top page margin and the footer in the |
|
116 bottom page margin. No more than one header or footer can exist in a document. |
|
117 |
|
118 CHeaderFooter derives from MTextFieldFactory. This allows the insertion of |
|
119 various fields, including page number, current date or time and filename. |
|
120 |
|
121 Rich text manipulation and formatting functions can be accessed through |
|
122 the rich text object which is owned by the header/footer. |
|
123 |
|
124 The header and footer are retrieved using the CPrintSetup::Header() and Footer() |
|
125 functions and they are stored and restored together with the rest of the print |
|
126 setup information. |
|
127 |
|
128 @publishedAll |
|
129 @released */ |
|
130 { |
|
131 public: |
|
132 IMPORT_C static CHeaderFooter* NewL(); |
|
133 IMPORT_C virtual ~CHeaderFooter(); |
|
134 // |
|
135 IMPORT_C void CreateTextL(); |
|
136 IMPORT_C void SetFirstPageToPrintTo(TInt aPageNum); // allows the first few pages of a doc not to have a header on them |
|
137 inline TInt FirstPageToPrintTo()const; // relative to the first page being numbered 0 |
|
138 // |
|
139 // persistence |
|
140 IMPORT_C TStreamId StoreL(CStreamStore& aStore)const; |
|
141 IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aStreamId,MPictureFactory* aFactory); |
|
142 IMPORT_C void StoreComponentsL(CStreamStore& aStore,CStoreMap& aMap)const; |
|
143 IMPORT_C void RestoreComponentsL(const CStreamStore& aStore,MPictureFactory* aFactory); |
|
144 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
145 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
146 // |
|
147 // text bits |
|
148 IMPORT_C CRichText* Text()const; |
|
149 IMPORT_C CParaFormatLayer* ParaFormat()const; |
|
150 IMPORT_C CCharFormatLayer* CharFormat()const; |
|
151 IMPORT_C void SetText(CRichText* aText); // takes ownership |
|
152 IMPORT_C void SetParaFormat(CParaFormatLayer* aParaFormat); // takes ownership |
|
153 IMPORT_C void SetCharFormat(CCharFormatLayer* aCharFormat); // takes ownership |
|
154 // |
|
155 // field bits |
|
156 IMPORT_C void SetFileNameInfo(const MFieldFileNameInfo& aFileNameInfo); // call if you want headers/footers to support filename fields |
|
157 IMPORT_C void SetNumPagesInfo(const MFieldNumPagesInfo& aNumPagesInfo); // call if you want headers/footers to support "total number of pages" fields |
|
158 inline MFieldFileNameInfo* FileNameFieldInfo()const; |
|
159 inline MFieldNumPagesInfo* NumPagesFieldInfo()const; |
|
160 // |
|
161 void SetPageNumInfo(const MFieldPageNumInfo& aPageNumInfo); // called by CPrintSetup |
|
162 private: |
|
163 CHeaderFooter(); |
|
164 void CreateFormatLayersL(); |
|
165 // from MTextFieldFactory |
|
166 CTextField* NewFieldL(TUid aFieldType); |
|
167 private: |
|
168 TInt iFirstPageToPrintTo; // relative to the first page being numbered 0 |
|
169 MFieldFileNameInfo* iFileNameInfo; |
|
170 MFieldPageNumInfo* iPageNumInfo; |
|
171 MFieldNumPagesInfo* iNumPagesInfo; |
|
172 CRichText* iText; // RichText Doc Handle |
|
173 CParaFormatLayer* iParaLayer; |
|
174 CCharFormatLayer* iCharLayer; |
|
175 private: |
|
176 enum { ETextExists = 0x0001 }; |
|
177 }; |
|
178 |
|
179 class MPrintProcessObserver |
|
180 /** Print progress and status notification interface class. |
|
181 |
|
182 The notification functions are called before, during and after a print or |
|
183 print preview operation, to give notification of its progress. |
|
184 |
|
185 The print process observer will often be the GUI's standard print progress |
|
186 or print preview dialog. |
|
187 |
|
188 An object of a class which implements this interface may be passed as a parameter |
|
189 to CPrintSetup::StartPrintL(), or to CPrintSetup::StartPreviewPrintL(). |
|
190 |
|
191 @publishedAll |
|
192 @released */ |
|
193 { |
|
194 public: |
|
195 /** Notifies that a print or print preview operation is about to begin. |
|
196 |
|
197 It may be used to display information about the document to be printed. It |
|
198 is called once, immediately before printing or print previewing begins. |
|
199 |
|
200 When subclassing, add variables to store initialisation information as required. |
|
201 |
|
202 @param aPrintParams The parameters for the print job. */ |
|
203 virtual void NotifyPrintStarted(TPrintParameters aPrintParams)=0; |
|
204 /** Notifies that a band is about to be printed. |
|
205 |
|
206 It may be used to display print progress information, including the current |
|
207 page number. It is called immediately before each band is printed. |
|
208 |
|
209 @param aPercentageOfPagePrinted The percentage of the page that has been printed. |
|
210 @param aCurrentPageNum The number of the page currently being printed. |
|
211 @param aCurrentCopyNum The number of the copy currently being printed (if multiple |
|
212 copies are being printed). */ |
|
213 virtual void NotifyBandPrinted(TInt aPercentageOfPagePrinted, TInt aCurrentPageNum, TInt aCurrentCopyNum)=0; |
|
214 /** Notifies that the print or print preview operation has completed. |
|
215 |
|
216 It may be used to display information about how the operation completed, for |
|
217 example any errors that occurred. It is called once, immediately after the |
|
218 print job terminates. |
|
219 |
|
220 @param anErrorCode KErrNone if the print job completed successfully, otherwise |
|
221 another of the system-wide error codes. */ |
|
222 virtual void NotifyPrintEnded(TInt anErrorCode)=0; |
|
223 // |
|
224 }; |
|
225 |
|
226 |
|
227 // |
|
228 // inlines |
|
229 // |
|
230 |
|
231 inline TInt CHeaderFooter::FirstPageToPrintTo()const |
|
232 /** Gets the first page on which the header or footer is to be printed. |
|
233 |
|
234 Page numbering begins at zero. |
|
235 |
|
236 @return The number of the first page on which the header or footer is to be |
|
237 printed. */ |
|
238 { return iFirstPageToPrintTo; } |
|
239 |
|
240 inline MFieldFileNameInfo* CHeaderFooter::FileNameFieldInfo()const |
|
241 /** Gets the object which implements the MFieldFileNameInfo interface, as set by |
|
242 SetFileNameInfo(). |
|
243 |
|
244 @return The object which implements the MFieldFileNameInfo interface. */ |
|
245 { return iFileNameInfo; } |
|
246 |
|
247 inline MFieldNumPagesInfo* CHeaderFooter::NumPagesFieldInfo()const |
|
248 /** Gets the object which implements the MFieldNumPagesInfo interface, as set by |
|
249 SetNumPagesInfo(). |
|
250 |
|
251 @return The object which implements the MFieldNumPagesInfo interface. */ |
|
252 { return iNumPagesInfo; } |
|
253 |
|
254 #endif |