williamr@2
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@2
|
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
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@2
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
//
|
williamr@2
|
15 |
|
williamr@2
|
16 |
#ifndef __FRMPAGE_H__
|
williamr@2
|
17 |
#define __FRMPAGE_H__
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#include <e32std.h>
|
williamr@2
|
20 |
#include <e32base.h>
|
williamr@2
|
21 |
#include <gdi.h>
|
williamr@2
|
22 |
|
williamr@2
|
23 |
class MLayDoc;
|
williamr@2
|
24 |
class CTextLayout;
|
williamr@2
|
25 |
class CParaFormat;
|
williamr@2
|
26 |
|
williamr@2
|
27 |
//
|
williamr@2
|
28 |
// The following two classes are for internal use only
|
williamr@2
|
29 |
//
|
williamr@2
|
30 |
|
williamr@2
|
31 |
/**
|
williamr@2
|
32 |
@internalComponent
|
williamr@2
|
33 |
*/
|
williamr@2
|
34 |
struct TPageLine
|
williamr@2
|
35 |
{
|
williamr@2
|
36 |
TInt iDocPos;
|
williamr@2
|
37 |
TInt iLineHeight;
|
williamr@2
|
38 |
TBool iKeepWithNext;
|
williamr@2
|
39 |
TBool iStartNewPage;
|
williamr@2
|
40 |
};
|
williamr@2
|
41 |
|
williamr@2
|
42 |
/**
|
williamr@2
|
43 |
@internalComponent
|
williamr@2
|
44 |
*/
|
williamr@2
|
45 |
class TLinePaginator
|
williamr@2
|
46 |
{
|
williamr@2
|
47 |
public:
|
williamr@2
|
48 |
TLinePaginator();
|
williamr@2
|
49 |
TBool AppendLineL(TPageLine aLine);
|
williamr@2
|
50 |
void FlushL(TInt aEndDocPos);
|
williamr@2
|
51 |
void SetPageHeight(TInt aPageHeight);
|
williamr@2
|
52 |
void SetArray(CArrayFix<TInt>* aCharsPerPage);
|
williamr@2
|
53 |
void Reset();
|
williamr@2
|
54 |
private:
|
williamr@2
|
55 |
void ResetArray();
|
williamr@2
|
56 |
void InsertPageBreakL();
|
williamr@2
|
57 |
void SetPotentialBreakPoint(TInt aDocPos);
|
williamr@2
|
58 |
void CheckTallLineL(TPageLine& aLine);
|
williamr@2
|
59 |
private:
|
williamr@2
|
60 |
CArrayFix<TInt>* iPageList; // This is created and destroyed by the application running the paginator.
|
williamr@2
|
61 |
TInt iDocPos;
|
williamr@2
|
62 |
TBool iKeepWithPrev;
|
williamr@2
|
63 |
TInt iPageHeight;
|
williamr@2
|
64 |
TInt iHeightRem;
|
williamr@2
|
65 |
TBool iBreakOnPage;
|
williamr@2
|
66 |
TInt iPrevPageBreak;
|
williamr@2
|
67 |
TInt iHeightLines;
|
williamr@2
|
68 |
TBool iFirstLine; // Used to prevent page break being inserted at top of document.
|
williamr@2
|
69 |
};
|
williamr@2
|
70 |
|
williamr@2
|
71 |
/**
|
williamr@2
|
72 |
An abstract class which must be mixed with application calling the active object.
|
williamr@2
|
73 |
It specifies the protocol for a pagination observer. A
|
williamr@2
|
74 |
pagination observer may be used when paginating a document in the background
|
williamr@2
|
75 |
(using CTextPaginator::PaginateCompleteDocumentL()). It notifies the client
|
williamr@2
|
76 |
on page completion, document completion, and on errors.
|
williamr@2
|
77 |
|
williamr@2
|
78 |
The observer is set up using the function CTextPaginator::SetObserver().
|
williamr@2
|
79 |
@publishedAll
|
williamr@2
|
80 |
@released
|
williamr@2
|
81 |
*/
|
williamr@2
|
82 |
class MPaginateObserver
|
williamr@2
|
83 |
{
|
williamr@2
|
84 |
public:
|
williamr@2
|
85 |
|
williamr@2
|
86 |
/** Notifies the client on completion of document pagination. */
|
williamr@2
|
87 |
virtual void NotifyCompletion()=0;
|
williamr@2
|
88 |
|
williamr@2
|
89 |
/** Notifies the client when a leave is trapped or when the pagination is cancelled.
|
williamr@2
|
90 |
Implements error handling.
|
williamr@2
|
91 |
@param anErrorCode Error code - indicates the type of error. */
|
williamr@2
|
92 |
virtual void NotifyError(TInt anErrorCode)=0;
|
williamr@2
|
93 |
|
williamr@2
|
94 |
/** Called by the paginator when each page has been completed.
|
williamr@2
|
95 |
@param aCurrentPageNum The number of the page. */
|
williamr@2
|
96 |
virtual void NotifyPageCompletion(TInt aCurrentPageNum)=0;
|
williamr@2
|
97 |
};
|
williamr@2
|
98 |
|
williamr@2
|
99 |
|
williamr@2
|
100 |
|
williamr@2
|
101 |
/**
|
williamr@2
|
102 |
Paginates a document.
|
williamr@2
|
103 |
|
williamr@2
|
104 |
Sets the page dimensions, the printer device and the source document to paginate.
|
williamr@2
|
105 |
Uses a page list, which is an array of characters-per-page values.
|
williamr@2
|
106 |
|
williamr@2
|
107 |
There are two ways of paginating a document; either in the background using
|
williamr@2
|
108 |
an active object or by incrementally adding text to the document and repeatedly
|
williamr@2
|
109 |
notifying the CTextPaginator object to paginate the added text. If an active
|
williamr@2
|
110 |
object is used, the client may be notified on completion of pages, on trapped
|
williamr@2
|
111 |
leaves and on completion of the pagination by an optional pagination observer.
|
williamr@2
|
112 |
@publishedAll
|
williamr@2
|
113 |
@released
|
williamr@2
|
114 |
*/
|
williamr@2
|
115 |
class CTextPaginator : public CActive
|
williamr@2
|
116 |
{
|
williamr@2
|
117 |
public:
|
williamr@2
|
118 |
// 2 phase ctor: automatically adds self to active scheduler
|
williamr@2
|
119 |
IMPORT_C static CTextPaginator* NewL(CPrinterDevice* aPrinterDevice,CArrayFix<TInt>* aCharsPerPage,TInt aPriority);
|
williamr@2
|
120 |
IMPORT_C ~CTextPaginator();
|
williamr@2
|
121 |
IMPORT_C void SetDocumentL(MLayDoc* aLayDoc); // Must call before anything else
|
williamr@2
|
122 |
IMPORT_C void SetPrinterDevice(CPrinterDevice* aPrinterDevice);
|
williamr@2
|
123 |
IMPORT_C void SetPageSpecInTwips(const TPageSpec& aPageSpec); // Physical size of page.
|
williamr@2
|
124 |
IMPORT_C void SetPageMarginsInTwips(const TMargins& aPageMargins); // Default are all zero.
|
williamr@2
|
125 |
IMPORT_C void SetTextMarginWidthsInTwips(TInt aLabelMarginWidth,TInt aGutterMarginWidth); // label margins (if any)
|
williamr@2
|
126 |
// Called to initiate paginating a document using active object
|
williamr@2
|
127 |
IMPORT_C void SetObserver(MPaginateObserver* aObserver);
|
williamr@2
|
128 |
IMPORT_C void PaginateCompleteDocumentL();
|
williamr@2
|
129 |
// Called to paginate incrementally, without active object
|
williamr@2
|
130 |
IMPORT_C TInt AppendTextL(TInt& aCumulativeDocPos); // returns number of page breaks so far
|
williamr@2
|
131 |
IMPORT_C TInt PaginationCompletedL(); // called at end of incremental pagination - returns total number of page breaks
|
williamr@2
|
132 |
private:
|
williamr@2
|
133 |
enum TPaginateMode
|
williamr@2
|
134 |
{
|
williamr@2
|
135 |
EFPaginateCompleteDocument,
|
williamr@2
|
136 |
EFPaginateIncrementally
|
williamr@2
|
137 |
};
|
williamr@2
|
138 |
enum
|
williamr@2
|
139 |
{
|
williamr@2
|
140 |
EPageLineArrayGranularity=10,
|
williamr@2
|
141 |
EPageListArrayGranularity=5
|
williamr@2
|
142 |
};
|
williamr@2
|
143 |
enum
|
williamr@2
|
144 |
{
|
williamr@2
|
145 |
EFMaximumNumberLinesInBlock=20
|
williamr@2
|
146 |
};
|
williamr@2
|
147 |
private:
|
williamr@2
|
148 |
CTextPaginator(TInt aPriority);
|
williamr@2
|
149 |
void RunL(); // Active scheduler is friend - can access
|
williamr@2
|
150 |
void DoCancel(); // Called by CActive::Cancel()
|
williamr@2
|
151 |
void ConstructL(CPrinterDevice* aPrinterDevice,CArrayFix<TInt>* aCharsPerPage);
|
williamr@2
|
152 |
void SetLayoutDimensions();
|
williamr@2
|
153 |
void SetOrReplaceDocumentL(MLayDoc* aLayDoc);
|
williamr@2
|
154 |
TRect TextRectInTwips() const;
|
williamr@2
|
155 |
TSize TextSizeInPixels() const;
|
williamr@2
|
156 |
void TrapPaginateParagraphL();
|
williamr@2
|
157 |
void PaginateParagraphL();
|
williamr@2
|
158 |
void PageCompleted();
|
williamr@2
|
159 |
void Reque();
|
williamr@2
|
160 |
void ResetPaginator();
|
williamr@2
|
161 |
void CopyTempPageListL(); // Copies temporary page list to real one.
|
williamr@2
|
162 |
void LeaveL(TInt aErr);
|
williamr@2
|
163 |
private:
|
williamr@2
|
164 |
MLayDoc* iLayDoc;
|
williamr@2
|
165 |
MPaginateObserver* iObserver;
|
williamr@2
|
166 |
CPrinterDevice* iPrinterDevice;
|
williamr@2
|
167 |
TLinePaginator iPaginator;
|
williamr@2
|
168 |
CTextLayout* iLayout;
|
williamr@2
|
169 |
CArrayFix<TInt>* iPageList;
|
williamr@2
|
170 |
CArrayFixFlat<TInt>* iTempPageList;
|
williamr@2
|
171 |
CArrayFixFlat<TPageLine>* iPageLineArray;
|
williamr@2
|
172 |
TSize iPageSizeInTwips;
|
williamr@2
|
173 |
TMargins iPageMarginsInTwips;
|
williamr@2
|
174 |
TInt iGutterMarginWidthInTwips; // Gap between labels and text proper - in twips
|
williamr@2
|
175 |
TInt iLabelMarginWidthInTwips;
|
williamr@2
|
176 |
TInt iDocPos; // Within the laydoc
|
williamr@2
|
177 |
TBool iPageBreakChar;
|
williamr@2
|
178 |
TPaginateMode iMode;
|
williamr@2
|
179 |
};
|
williamr@2
|
180 |
|
williamr@2
|
181 |
#endif
|