sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef __T_RTPAR_H__ sl@0: #define __T_RTPAR_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: // classes defined in this header sl@0: class CRichTextReader; sl@0: class CPMLWriter; sl@0: // sl@0: sl@0: enum TTagType { // Possible types of tag sl@0: EGlobal, sl@0: EParagraph, sl@0: ECharacter , sl@0: EControl sl@0: }; sl@0: sl@0: enum TTagStatus { sl@0: ETagStart, // "<" sl@0: ETagEnd // ">" sl@0: }; sl@0: sl@0: sl@0: class CRichTextReader : public CBase sl@0: { sl@0: public: sl@0: static CRichTextReader* NewL(); sl@0: void Destruct(); sl@0: sl@0: // these functions convert a supplied RichText doc into PML sl@0: // which is contained in the returned buffer. sl@0: CBufSeg* ConvertRichText(CRichText* aRichTextDoc, RConsole aConsole); sl@0: CBufSeg* ConvertRichText(CRichText* aRichTextDoc); sl@0: protected: sl@0: CRichTextReader(); sl@0: void ConstructL(); sl@0: private: sl@0: void SenseGlobalFormat(); sl@0: TInt TranslatePhrase(TInt aPos); sl@0: void CompareParaFormats(); sl@0: void CompareCharFormats(); sl@0: void CompareParaToFactory(CParaFormat* aSensed); sl@0: void CompareCharToFactory(TCharFormat aSensed); sl@0: void CheckTabList(CParaFormat* aFormatOne, CParaFormat* aFormatTwo); sl@0: TParaBorder* CopyBorderL(const TParaBorder* aFrom,TParaBorder* aTo); sl@0: TBullet* CopyBulletL(const TBullet* aFrom,TBullet* aTo); sl@0: private: sl@0: CRichText* iRichTextDoc; sl@0: CParaFormat* iThisParaFormat; sl@0: CParaFormat* iPrevParaFormat; sl@0: TCharFormat iThisCharFormat; sl@0: TCharFormat iPrevCharFormat; sl@0: TParaBorder* iBorder; sl@0: sl@0: RConsole iConsole; sl@0: TBool iConsoleExists; sl@0: CPMLWriter* iPMLWriter; sl@0: TInt iParaStart; // Start pos of current paragraph sl@0: TInt iDocLength; // length in chars of rich text doc sl@0: }; sl@0: sl@0: sl@0: class CPMLWriter : public CBase sl@0: { sl@0: public: sl@0: static CPMLWriter* NewL(); sl@0: void Destruct(); sl@0: sl@0: void Insert(const TDesC& aBuf); // inserts a string into PML doc sl@0: void Delete(TUint aNumberOfCharsToDelete); // deletes chars prior to current insert pos sl@0: void Output(RConsole aConsole); // output PML doc to screen sl@0: inline CBufSeg* ReturnPmlDoc() {return iTextBuf;} sl@0: inline TUint WritePos() {return iInsertPos;} sl@0: void SetTag(TTagType, TTagStatus); // Prints tag delimiters & tag type sl@0: void SetTab(TTabStop aTabStop); sl@0: void SetFormat(TTextFormatAttribute aAttribute, TInt aValue); sl@0: void SetFormat(TTextFormatAttribute aAttribute, TParaBorder* aParaBorder); sl@0: void SetFormat(TTextFormatAttribute aAttribute, const TTypeface &aTypeface); sl@0: void SetFormat(TTextFormatAttribute aAttribute, TBullet* aBullet); sl@0: void SetFormat(TTextFormatAttribute aAttribute, TTabStop aTabStop); sl@0: protected: sl@0: CPMLWriter(); sl@0: void ConstructL(); sl@0: private: sl@0: void ProcessAlignment(TInt aValue); sl@0: void ProcessLineSpacingControl(TInt aValue); sl@0: void ProcessFontPrintPos(TInt aValue); sl@0: void ProcessBooleanAtt(TTextFormatAttribute aAttribute, TInt aValue); sl@0: void ProcessBorder(TTextFormatAttribute aAttribute, TInt aValue); sl@0: void SquashBuf(const TDesC& aBuffer, TDes8& aTarget); // squashes 16 bit buffers to 8 bit (for unicode) sl@0: void ExpandBuf(const TDes8& aBuffer, TDes& aTarget); sl@0: private: sl@0: CBufSeg* iTextBuf; // Buffer for text file to be read into sl@0: TUint iInsertPos; sl@0: }; sl@0: sl@0: sl@0: sl@0: #endif