epoc32/include/frmpage.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/frmpage.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/frmpage.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,181 @@
     1.4 -frmpage.h
     1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// 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
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +//
    1.19 +
    1.20 +#ifndef __FRMPAGE_H__
    1.21 +#define __FRMPAGE_H__
    1.22 +
    1.23 +#include <e32std.h>
    1.24 +#include <e32base.h>
    1.25 +#include <gdi.h>
    1.26 +
    1.27 +class MLayDoc;
    1.28 +class CTextLayout;
    1.29 +class CParaFormat;
    1.30 +
    1.31 +//
    1.32 +// The following two classes are for internal use only
    1.33 +//
    1.34 +
    1.35 +/**
    1.36 +@internalComponent
    1.37 +*/
    1.38 +struct TPageLine
    1.39 +	{
    1.40 +	TInt iDocPos;
    1.41 +	TInt iLineHeight;
    1.42 +	TBool iKeepWithNext;
    1.43 +	TBool iStartNewPage;
    1.44 +	};
    1.45 +
    1.46 +/**
    1.47 +@internalComponent
    1.48 +*/
    1.49 +class TLinePaginator
    1.50 +	{
    1.51 +public:
    1.52 +	TLinePaginator();
    1.53 +	TBool AppendLineL(TPageLine aLine);
    1.54 + 	void FlushL(TInt aEndDocPos);
    1.55 +	void SetPageHeight(TInt aPageHeight);
    1.56 +	void SetArray(CArrayFix<TInt>* aCharsPerPage);
    1.57 +	void Reset();
    1.58 +private:
    1.59 +	void ResetArray();
    1.60 + 	void InsertPageBreakL();
    1.61 +	void SetPotentialBreakPoint(TInt aDocPos);
    1.62 +	void CheckTallLineL(TPageLine& aLine);
    1.63 +private:
    1.64 +	CArrayFix<TInt>* iPageList;	 // This is created and destroyed by the application running the paginator.
    1.65 +	TInt iDocPos;
    1.66 +	TBool iKeepWithPrev;
    1.67 +	TInt iPageHeight;
    1.68 +	TInt iHeightRem;
    1.69 +	TBool iBreakOnPage;
    1.70 +	TInt iPrevPageBreak;
    1.71 +	TInt iHeightLines;
    1.72 +	TBool iFirstLine;  // Used to prevent page break being inserted at top of document.
    1.73 +	};
    1.74 +
    1.75 +/** 
    1.76 +An abstract class which must be mixed with application calling the active object.
    1.77 +It specifies the protocol for a pagination observer. A
    1.78 +pagination observer may be used when paginating a document in the background
    1.79 +(using CTextPaginator::PaginateCompleteDocumentL()). It notifies the client
    1.80 +on page completion, document completion, and on errors.
    1.81 +
    1.82 +The observer is set up using the function CTextPaginator::SetObserver().
    1.83 +@publishedAll
    1.84 +@released
    1.85 +*/
    1.86 +class MPaginateObserver
    1.87 +	{
    1.88 +public:
    1.89 +
    1.90 +	/** Notifies the client on completion of document pagination. */
    1.91 +	virtual void NotifyCompletion()=0;
    1.92 +
    1.93 +	/** Notifies the client when a leave is trapped or when the pagination is cancelled.
    1.94 +	Implements error handling.
    1.95 +	@param anErrorCode Error code - indicates the type of error. */
    1.96 +	virtual void NotifyError(TInt anErrorCode)=0;
    1.97 +
    1.98 +	/** Called by the paginator when each page has been completed.
    1.99 +	@param aCurrentPageNum The number of the page. */
   1.100 +	virtual void NotifyPageCompletion(TInt aCurrentPageNum)=0;
   1.101 +	};
   1.102 +
   1.103 +
   1.104 +
   1.105 +/** 
   1.106 +Paginates a document.
   1.107 +
   1.108 +Sets the page dimensions, the printer device and the source document to paginate. 
   1.109 +Uses a page list, which is an array of characters-per-page values.
   1.110 +
   1.111 +There are two ways of paginating a document; either in the background using 
   1.112 +an active object or by incrementally adding text to the document and repeatedly 
   1.113 +notifying the CTextPaginator object to paginate the added text. If an active 
   1.114 +object is used, the client may be notified on completion of pages, on trapped 
   1.115 +leaves and on completion of the pagination by an optional pagination observer. 
   1.116 +@publishedAll
   1.117 +@released
   1.118 +*/
   1.119 +class CTextPaginator : public CActive
   1.120 +	{
   1.121 +public:
   1.122 +// 2 phase ctor: automatically adds self to active scheduler 
   1.123 +	IMPORT_C static CTextPaginator* NewL(CPrinterDevice* aPrinterDevice,CArrayFix<TInt>* aCharsPerPage,TInt aPriority);	
   1.124 +	IMPORT_C ~CTextPaginator();
   1.125 +	IMPORT_C void SetDocumentL(MLayDoc* aLayDoc); // Must call before anything else
   1.126 +	IMPORT_C void SetPrinterDevice(CPrinterDevice* aPrinterDevice);
   1.127 +	IMPORT_C void SetPageSpecInTwips(const TPageSpec& aPageSpec);  // Physical size of page.
   1.128 +	IMPORT_C void SetPageMarginsInTwips(const TMargins& aPageMargins); // Default are all zero.
   1.129 +	IMPORT_C void SetTextMarginWidthsInTwips(TInt aLabelMarginWidth,TInt aGutterMarginWidth); // label margins (if any)
   1.130 +// Called to initiate paginating a document using active object
   1.131 +	IMPORT_C void SetObserver(MPaginateObserver* aObserver);
   1.132 +	IMPORT_C void PaginateCompleteDocumentL();
   1.133 +// Called to paginate incrementally, without active object
   1.134 +	IMPORT_C TInt AppendTextL(TInt& aCumulativeDocPos);	// returns number of page breaks so far
   1.135 +	IMPORT_C TInt PaginationCompletedL();	// called at end of incremental pagination	- returns total number of page breaks
   1.136 +private:
   1.137 +	enum TPaginateMode
   1.138 +		{
   1.139 +		EFPaginateCompleteDocument,
   1.140 +		EFPaginateIncrementally
   1.141 +		};
   1.142 +	enum 
   1.143 +		{
   1.144 +		EPageLineArrayGranularity=10,
   1.145 +		EPageListArrayGranularity=5
   1.146 +		};
   1.147 +	enum
   1.148 +		{
   1.149 +		EFMaximumNumberLinesInBlock=20
   1.150 +		};
   1.151 +private:
   1.152 +	CTextPaginator(TInt aPriority);
   1.153 +	void RunL(); // Active scheduler is friend - can access 
   1.154 +	void DoCancel();  // Called by CActive::Cancel()
   1.155 +	void ConstructL(CPrinterDevice* aPrinterDevice,CArrayFix<TInt>* aCharsPerPage);
   1.156 +	void SetLayoutDimensions();
   1.157 +	void SetOrReplaceDocumentL(MLayDoc* aLayDoc);
   1.158 +	TRect TextRectInTwips() const;
   1.159 +	TSize TextSizeInPixels() const;
   1.160 +	void TrapPaginateParagraphL();
   1.161 +	void PaginateParagraphL();
   1.162 +	void PageCompleted();
   1.163 +	void Reque();
   1.164 +	void ResetPaginator();
   1.165 +	void CopyTempPageListL();  // Copies temporary page list to real one.
   1.166 +	void LeaveL(TInt aErr);
   1.167 +private:
   1.168 +	MLayDoc* iLayDoc;
   1.169 +	MPaginateObserver* iObserver;
   1.170 +	CPrinterDevice* iPrinterDevice;
   1.171 +	TLinePaginator iPaginator;
   1.172 +	CTextLayout* iLayout;
   1.173 +	CArrayFix<TInt>* iPageList;
   1.174 +	CArrayFixFlat<TInt>* iTempPageList;
   1.175 +	CArrayFixFlat<TPageLine>* iPageLineArray;
   1.176 +	TSize iPageSizeInTwips;
   1.177 +	TMargins iPageMarginsInTwips;
   1.178 +	TInt iGutterMarginWidthInTwips;   // Gap between labels and text proper - in twips
   1.179 +	TInt iLabelMarginWidthInTwips;
   1.180 +	TInt iDocPos;				// Within the laydoc
   1.181 +	TBool iPageBreakChar;
   1.182 +	TPaginateMode iMode;
   1.183 +	};
   1.184 +
   1.185 +#endif