|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // concrete conversion for a Plain Text to Quoted Printable |
|
15 // |
|
16 // |
|
17 |
|
18 #if !defined(__TXCONV_H__) |
|
19 #define __TXCONV_H__ |
|
20 #if !defined(__E32BASE_H__) |
|
21 #include <e32base.h> |
|
22 #endif |
|
23 #if !defined(__TXTETEXT_H__) |
|
24 #include <txtetext.h> |
|
25 #endif |
|
26 |
|
27 |
|
28 const TInt KEtextToText=0x100040C8; |
|
29 const TUid KUidEtextToText={KEtextToText}; |
|
30 const TInt KTextToEtext=0x100040C7; |
|
31 const TUid KUidTextToEtext={KTextToEtext}; |
|
32 const TInt KTextToEtextNoTrim=0x10281B4C; |
|
33 const TUid KUidTextToEtextNoTrim={KTextToEtextNoTrim}; |
|
34 |
|
35 class CFileStore; |
|
36 class CStreamDictionary; |
|
37 // |
|
38 // Classes declared in this file |
|
39 class TTextTran; |
|
40 class TTextTranToEra; |
|
41 class TTextTranFromEra; |
|
42 |
|
43 |
|
44 NONSHARABLE_CLASS(CEtToTxtCnv) : public CConverterBase2 |
|
45 { |
|
46 public: |
|
47 CEtToTxtCnv(); |
|
48 ~CEtToTxtCnv(); |
|
49 public: // from CConverterBase2 |
|
50 void ConvertObjectAL(RReadStream& aReadStream, RWriteStream& aWriteStream,MConverterUiObserver* aObserver=NULL); |
|
51 TBool DoConvertL(); |
|
52 TInt Capabilities(); |
|
53 TUid Uid(); |
|
54 private: |
|
55 RReadStream* iReadStream; |
|
56 TTextTranFromEra* iTextTranFromEra; |
|
57 TInt iPos; |
|
58 TInt iLength; |
|
59 }; |
|
60 |
|
61 NONSHARABLE_CLASS(CTxtToEtCnv) : public CConverterBase2 |
|
62 { |
|
63 public: |
|
64 CTxtToEtCnv(); |
|
65 CTxtToEtCnv(TBool aNoTrim); |
|
66 ~CTxtToEtCnv(); |
|
67 public: // from CConverterBase2 |
|
68 void ConvertObjectAL(RReadStream& aReadStream, RWriteStream& aWriteStream, MConverterUiObserver* aObserver=NULL); |
|
69 TBool DoConvertL(); |
|
70 TInt Capabilities(); |
|
71 TUid Uid(); |
|
72 private: |
|
73 RReadStream* iReadStream; |
|
74 RWriteStream* iWriteStream; |
|
75 TTextTranToEra* iTextTranToEra; |
|
76 TInt iLength; |
|
77 TInt iPos; |
|
78 TBool iNoTrim; |
|
79 }; |
|
80 |
|
81 |
|
82 class TTextTran |
|
83 { |
|
84 // Text converter |
|
85 // |
|
86 public: |
|
87 // virtual void Translate(TDes& aBuf)=0; |
|
88 void SetTranslationMode(CPlainText::TTextOrganisation aTextOrganisation); |
|
89 CPlainText::TTextOrganisation TranslationMode()const; |
|
90 protected: |
|
91 TTextTran(CPlainText::TTextOrganisation aTextOrganisation); |
|
92 protected: |
|
93 CPlainText::TTextOrganisation iTransMode; // Paragraph or Line |
|
94 TText* iReadPtr; |
|
95 TText* iWritePtr; |
|
96 }; |
|
97 |
|
98 |
|
99 class TTextTranToEra : public TTextTran |
|
100 { |
|
101 // Converts plain text to ERA Editable Text format. |
|
102 // |
|
103 public: |
|
104 TTextTranToEra(CPlainText::TTextOrganisation aTextOrganisation, TBool aNoTrim=EFalse); |
|
105 // Text organisation is the one to read from. |
|
106 void Translate(TDes& aBuf); |
|
107 private: |
|
108 void MapControlCode(); |
|
109 void Trim(); |
|
110 private: |
|
111 enum {EBlobCharacter=0x000000b9}; |
|
112 TBool iNoTrim; |
|
113 }; |
|
114 |
|
115 |
|
116 const TInt KMaxExportBuffer=0x100; |
|
117 const TInt KLineDelimiterLength=2; // CR/LF protocol |
|
118 // |
|
119 const TText KCharacterCR=0x0d; |
|
120 const TText KCharacterLF=0x0a; |
|
121 const TText KCharacterTab=0x09; |
|
122 const TText KCharacterHyphen=0x2d; |
|
123 const TText KCharacterSpace=0x20; |
|
124 |
|
125 |
|
126 class TTextTranFromEra : public TTextTran |
|
127 { |
|
128 // Converts from ERA Editable Text format to plain text. |
|
129 // |
|
130 public: |
|
131 static TTextTranFromEra* NewL(CPlainText::TTextOrganisation aTextOrganisation,RWriteStream& aOutStream,TInt aLineWrap); |
|
132 TInt DoTranslateL(); |
|
133 void NotifyEndOfSourceL(); |
|
134 void Initialise(const TDesC& aBuf); |
|
135 private: |
|
136 TTextTranFromEra(CPlainText::TTextOrganisation aTextOrganisation,RWriteStream& aOutStream,TInt aLineWrap); |
|
137 void ConstructL(); |
|
138 void ResetExportBuffer(); |
|
139 void CommitExportBufferToFileL(); |
|
140 void DoTranslateSourceBufferL(); |
|
141 void MapEraCodeL(); |
|
142 void WriteCRLF(TInt aCharacters); |
|
143 private: |
|
144 TBuf<KMaxExportBuffer> iExportBuffer; |
|
145 TText* iSBase; |
|
146 TInt iSLen; |
|
147 TText* iTBase; |
|
148 RWriteStream& iOutStream; |
|
149 TInt iLineWrap; |
|
150 }; |
|
151 #endif |