os/textandloc/textrendering/texthandling/incp/T_RTPAR.H
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/textrendering/texthandling/incp/T_RTPAR.H	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,118 @@
     1.4 +/*
     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 "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.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 +
    1.21 +
    1.22 +#ifndef __T_RTPAR_H__
    1.23 +#define	__T_RTPAR_H__
    1.24 +
    1.25 +#include <E32TWIN.H>
    1.26 +#include <TXTRICH.H>
    1.27 +
    1.28 +// classes defined in this header
    1.29 +class CRichTextReader;
    1.30 +class CPMLWriter;
    1.31 +//
    1.32 +
    1.33 +enum TTagType {		   // Possible types of tag
    1.34 +	EGlobal, 
    1.35 +	EParagraph, 
    1.36 +	ECharacter , 
    1.37 +	EControl
    1.38 +	}; 
    1.39 +
    1.40 +enum TTagStatus {	 
    1.41 +	ETagStart,		  // "<"
    1.42 +	ETagEnd			  // ">"
    1.43 +	};
    1.44 +
    1.45 +
    1.46 +class CRichTextReader : public CBase
    1.47 +	{
    1.48 +public:
    1.49 +	static CRichTextReader* NewL();
    1.50 +	void Destruct();
    1.51 +
    1.52 +	// these functions convert a supplied RichText doc into PML 
    1.53 +	// which is contained in the returned buffer.
    1.54 +	CBufSeg* ConvertRichText(CRichText* aRichTextDoc, RConsole aConsole);
    1.55 +	CBufSeg* ConvertRichText(CRichText* aRichTextDoc);
    1.56 +protected:
    1.57 +	CRichTextReader();
    1.58 +	void ConstructL();
    1.59 +private:
    1.60 +	void SenseGlobalFormat();
    1.61 +	TInt TranslatePhrase(TInt aPos);	
    1.62 +	void CompareParaFormats();
    1.63 +	void CompareCharFormats();
    1.64 +	void CompareParaToFactory(CParaFormat* aSensed);  
    1.65 +	void CompareCharToFactory(TCharFormat aSensed);
    1.66 +	void CheckTabList(CParaFormat* aFormatOne, CParaFormat* aFormatTwo);
    1.67 +	TParaBorder* CopyBorderL(const TParaBorder* aFrom,TParaBorder* aTo);
    1.68 +	TBullet* CopyBulletL(const TBullet* aFrom,TBullet* aTo);
    1.69 +private:
    1.70 +	CRichText* iRichTextDoc;
    1.71 +	CParaFormat* iThisParaFormat;
    1.72 +	CParaFormat* iPrevParaFormat;
    1.73 +	TCharFormat iThisCharFormat;
    1.74 +	TCharFormat iPrevCharFormat;
    1.75 +	TParaBorder* iBorder;
    1.76 +				
    1.77 +	RConsole iConsole;
    1.78 +	TBool iConsoleExists;				
    1.79 +	CPMLWriter* iPMLWriter;
    1.80 +	TInt iParaStart;				// Start pos of current paragraph
    1.81 +	TInt iDocLength;				// length in chars of rich text doc
    1.82 +	};
    1.83 +
    1.84 +
    1.85 +class CPMLWriter : public CBase
    1.86 +	{
    1.87 +public:
    1.88 +	static CPMLWriter* NewL();
    1.89 +	void Destruct();
    1.90 +
    1.91 +	void Insert(const TDesC& aBuf);	// inserts a string into PML doc
    1.92 +	void Delete(TUint aNumberOfCharsToDelete);	// deletes chars prior to current insert pos
    1.93 +	void Output(RConsole aConsole); // output PML doc to screen
    1.94 +	inline CBufSeg* ReturnPmlDoc() {return iTextBuf;}
    1.95 +	inline TUint WritePos() {return iInsertPos;}
    1.96 +	void SetTag(TTagType, TTagStatus);	// Prints tag delimiters & tag type
    1.97 +	void SetTab(TTabStop aTabStop);
    1.98 +	void SetFormat(TTextFormatAttribute aAttribute, TInt aValue);
    1.99 +	void SetFormat(TTextFormatAttribute aAttribute, TParaBorder* aParaBorder);
   1.100 +	void SetFormat(TTextFormatAttribute aAttribute, const TTypeface &aTypeface);
   1.101 +	void SetFormat(TTextFormatAttribute aAttribute, TBullet* aBullet);
   1.102 +	void SetFormat(TTextFormatAttribute aAttribute, TTabStop aTabStop);
   1.103 +protected:
   1.104 +	CPMLWriter();
   1.105 +	void ConstructL();
   1.106 +private:
   1.107 +	void ProcessAlignment(TInt aValue);
   1.108 +	void ProcessLineSpacingControl(TInt aValue);
   1.109 +	void ProcessFontPrintPos(TInt aValue);
   1.110 +	void ProcessBooleanAtt(TTextFormatAttribute aAttribute, TInt aValue);
   1.111 +	void ProcessBorder(TTextFormatAttribute aAttribute, TInt aValue);
   1.112 +	void SquashBuf(const TDesC& aBuffer, TDes8& aTarget); // squashes 16 bit buffers to 8 bit (for unicode)
   1.113 +	void ExpandBuf(const TDes8& aBuffer, TDes& aTarget);
   1.114 +private:
   1.115 +	CBufSeg* iTextBuf;					// Buffer for text file to be read into
   1.116 +	TUint iInsertPos;
   1.117 +	};
   1.118 +
   1.119 +
   1.120 +
   1.121 +#endif