|
1 /* |
|
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __T_RTPAR_H__ |
|
20 #define __T_RTPAR_H__ |
|
21 |
|
22 #include <E32TWIN.H> |
|
23 #include <TXTRICH.H> |
|
24 |
|
25 // classes defined in this header |
|
26 class CRichTextReader; |
|
27 class CPMLWriter; |
|
28 // |
|
29 |
|
30 enum TTagType { // Possible types of tag |
|
31 EGlobal, |
|
32 EParagraph, |
|
33 ECharacter , |
|
34 EControl |
|
35 }; |
|
36 |
|
37 enum TTagStatus { |
|
38 ETagStart, // "<" |
|
39 ETagEnd // ">" |
|
40 }; |
|
41 |
|
42 |
|
43 class CRichTextReader : public CBase |
|
44 { |
|
45 public: |
|
46 static CRichTextReader* NewL(); |
|
47 void Destruct(); |
|
48 |
|
49 // these functions convert a supplied RichText doc into PML |
|
50 // which is contained in the returned buffer. |
|
51 CBufSeg* ConvertRichText(CRichText* aRichTextDoc, RConsole aConsole); |
|
52 CBufSeg* ConvertRichText(CRichText* aRichTextDoc); |
|
53 protected: |
|
54 CRichTextReader(); |
|
55 void ConstructL(); |
|
56 private: |
|
57 void SenseGlobalFormat(); |
|
58 TInt TranslatePhrase(TInt aPos); |
|
59 void CompareParaFormats(); |
|
60 void CompareCharFormats(); |
|
61 void CompareParaToFactory(CParaFormat* aSensed); |
|
62 void CompareCharToFactory(TCharFormat aSensed); |
|
63 void CheckTabList(CParaFormat* aFormatOne, CParaFormat* aFormatTwo); |
|
64 TParaBorder* CopyBorderL(const TParaBorder* aFrom,TParaBorder* aTo); |
|
65 TBullet* CopyBulletL(const TBullet* aFrom,TBullet* aTo); |
|
66 private: |
|
67 CRichText* iRichTextDoc; |
|
68 CParaFormat* iThisParaFormat; |
|
69 CParaFormat* iPrevParaFormat; |
|
70 TCharFormat iThisCharFormat; |
|
71 TCharFormat iPrevCharFormat; |
|
72 TParaBorder* iBorder; |
|
73 |
|
74 RConsole iConsole; |
|
75 TBool iConsoleExists; |
|
76 CPMLWriter* iPMLWriter; |
|
77 TInt iParaStart; // Start pos of current paragraph |
|
78 TInt iDocLength; // length in chars of rich text doc |
|
79 }; |
|
80 |
|
81 |
|
82 class CPMLWriter : public CBase |
|
83 { |
|
84 public: |
|
85 static CPMLWriter* NewL(); |
|
86 void Destruct(); |
|
87 |
|
88 void Insert(const TDesC& aBuf); // inserts a string into PML doc |
|
89 void Delete(TUint aNumberOfCharsToDelete); // deletes chars prior to current insert pos |
|
90 void Output(RConsole aConsole); // output PML doc to screen |
|
91 inline CBufSeg* ReturnPmlDoc() {return iTextBuf;} |
|
92 inline TUint WritePos() {return iInsertPos;} |
|
93 void SetTag(TTagType, TTagStatus); // Prints tag delimiters & tag type |
|
94 void SetTab(TTabStop aTabStop); |
|
95 void SetFormat(TTextFormatAttribute aAttribute, TInt aValue); |
|
96 void SetFormat(TTextFormatAttribute aAttribute, TParaBorder* aParaBorder); |
|
97 void SetFormat(TTextFormatAttribute aAttribute, const TTypeface &aTypeface); |
|
98 void SetFormat(TTextFormatAttribute aAttribute, TBullet* aBullet); |
|
99 void SetFormat(TTextFormatAttribute aAttribute, TTabStop aTabStop); |
|
100 protected: |
|
101 CPMLWriter(); |
|
102 void ConstructL(); |
|
103 private: |
|
104 void ProcessAlignment(TInt aValue); |
|
105 void ProcessLineSpacingControl(TInt aValue); |
|
106 void ProcessFontPrintPos(TInt aValue); |
|
107 void ProcessBooleanAtt(TTextFormatAttribute aAttribute, TInt aValue); |
|
108 void ProcessBorder(TTextFormatAttribute aAttribute, TInt aValue); |
|
109 void SquashBuf(const TDesC& aBuffer, TDes8& aTarget); // squashes 16 bit buffers to 8 bit (for unicode) |
|
110 void ExpandBuf(const TDes8& aBuffer, TDes& aTarget); |
|
111 private: |
|
112 CBufSeg* iTextBuf; // Buffer for text file to be read into |
|
113 TUint iInsertPos; |
|
114 }; |
|
115 |
|
116 |
|
117 |
|
118 #endif |