|
1 // Copyright (c) 1999-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 // |
|
15 |
|
16 #include <imcvcodc.h> |
|
17 |
|
18 //---------------------------------------------------------------------------------------- |
|
19 LOCAL_C inline TInt BlankLine(TDes8& rOutputLine, TInt& rPaddingCount) |
|
20 //---------------------------------------------------------------------------------------- |
|
21 { |
|
22 rOutputLine = KNullDesC8; |
|
23 rPaddingCount = KNullDesC8().Length(); |
|
24 return 1; |
|
25 } |
|
26 |
|
27 |
|
28 // function for adding 8 bit descriptor onto a 16bit descritpr. |
|
29 //---------------------------------------------------------------------------------------- |
|
30 LOCAL_C inline void Append(TDes& aBuffer, const TDesC8& aAddition) |
|
31 //---------------------------------------------------------------------------------------- |
|
32 { |
|
33 TInt addLen = aAddition.Length(); |
|
34 TInt bufLen = aBuffer.Length(); |
|
35 |
|
36 aBuffer.SetLength(bufLen+addLen); |
|
37 for(TInt i = 0; i < addLen; i++) |
|
38 aBuffer[bufLen+i] = aAddition[i]; |
|
39 } |
|
40 |
|
41 //---------------------------------------------------------------------------------------- |
|
42 LOCAL_C inline void Append(TDes& aBuffer, const TDesC16& aAddition) |
|
43 //---------------------------------------------------------------------------------------- |
|
44 { |
|
45 TInt addLen = aAddition.Length(); |
|
46 TInt bufLen = aBuffer.Length(); |
|
47 |
|
48 aBuffer.SetLength(bufLen+addLen); |
|
49 for(TInt i = 0; i < addLen; i++) |
|
50 aBuffer[bufLen+i] = aAddition[i]; |
|
51 } |
|
52 |
|
53 |
|
54 //---------------------------------------------------------------------------------------- |
|
55 inline TBool TImCodecQP::IsPlain( TChar aChar ) |
|
56 //---------------------------------------------------------------------------------------- |
|
57 { |
|
58 TLex8 lex(iEncodeCharList); |
|
59 while(!lex.Eos()) |
|
60 if ( aChar==lex.Get() ) |
|
61 return EFalse; |
|
62 |
|
63 if ( ((aChar >= 33) && (aChar <= 60)) || ((aChar >= 62) && (aChar <= 126)) ) |
|
64 return ETrue; |
|
65 |
|
66 lex = iPlainCharList; |
|
67 while(!lex.Eos()) |
|
68 if ( aChar==lex.Get() ) |
|
69 return ETrue; |
|
70 |
|
71 return EFalse; |
|
72 } |
|
73 |
|
74 //---------------------------------------------------------------------------------------- |
|
75 void TImCodecQP::AddSoftLineBreak( TDes8& aPtr, TInt& aPadding, TInt& aWritten) |
|
76 //---------------------------------------------------------------------------------------- |
|
77 { |
|
78 __ASSERT_ALWAYS( aPtr.Length()+4< aPtr.MaxLength(), gPanic(KPanicDescriptorToSmall) ); |
|
79 aPtr.Append(KImcvSP); |
|
80 aPtr.Append(iQPCharacter); |
|
81 aPtr.Append(KImcvCRLF); |
|
82 aWritten+=4; |
|
83 aPadding+=3; |
|
84 } |
|
85 |
|
86 //---------------------------------------------------------------------------------------- |
|
87 void TImCodecQP::AddSoftLineBreak(const TUint8* apEnd, TUint8* aPtr, TInt& aPadding, TInt& aWritten) |
|
88 //---------------------------------------------------------------------------------------- |
|
89 { |
|
90 __ASSERT_ALWAYS( aPtr+3<apEnd, gPanic(KPanicDescriptorToSmall) ); |
|
91 *aPtr = KImcvSP; |
|
92 *aPtr = iQPCharacter; |
|
93 *aPtr = KImcvCR; |
|
94 *aPtr = KImcvLF; |
|
95 *aPtr+=4; |
|
96 aWritten+=4; |
|
97 aPadding+=3; |
|
98 } |
|
99 |
|
100 |
|
101 //---------------------------------------------------------------------------------------- |
|
102 inline TBool TImCodec::IsDigit( TChar aChar ) |
|
103 //---------------------------------------------------------------------------------------- |
|
104 { |
|
105 return ( (aChar >= '0') && (aChar <= '9') ); |
|
106 } |
|
107 |
|
108 //---------------------------------------------------------------------------------------- |
|
109 inline TUint8 TImCodecQP::ReplacementChar( TChar aControlChar ) |
|
110 //---------------------------------------------------------------------------------------- |
|
111 { |
|
112 if (aControlChar==CEditableText::ETabCharacter) |
|
113 return KImcvTab; |
|
114 |
|
115 if (aControlChar==CEditableText::ENonBreakingHyphen) |
|
116 return KImcvHyphen; |
|
117 |
|
118 if (aControlChar==CEditableText::ENonBreakingSpace) |
|
119 return KImcvSP; |
|
120 |
|
121 return 0; |
|
122 } |
|
123 |
|
124 //---------------------------------------------------------------------------------------- |
|
125 inline void TImCodecQP::AddPlainChar( const TDesC8& aCharList ) |
|
126 //---------------------------------------------------------------------------------------- |
|
127 { |
|
128 iPlainCharList.Set(aCharList); |
|
129 } |
|
130 |
|
131 |
|
132 //---------------------------------------------------------------------------------------- |
|
133 inline void TImCodecQP::AddEncodeChar( const TDesC8& aCharList ) |
|
134 //---------------------------------------------------------------------------------------- |
|
135 { |
|
136 iEncodeCharList.Set(aCharList); |
|
137 } |
|
138 |
|
139 //---------------------------------------------------------------------------------------- |
|
140 inline void TImCodecQP::SetQPChar( TUint8 aChar ) |
|
141 //---------------------------------------------------------------------------------------- |
|
142 { |
|
143 iQPCharacter=aChar; |
|
144 } |
|
145 |
|
146 // this function rather meanly allows a line break on a non-breaking tab and non-breaking |
|
147 // space, as defined in CEditableText |
|
148 |
|
149 //---------------------------------------------------------------------------------------- |
|
150 inline TBool TImCodecQP::IsBreakable( TChar aChar) |
|
151 //---------------------------------------------------------------------------------------- |
|
152 { |
|
153 return (aChar==' '||aChar=='\t'); |
|
154 } |
|
155 |
|
156 |
|
157 //---------------------------------------------------------------------------------------- |
|
158 inline CImConvertCharconv& CImConvertHeader::CharConv() |
|
159 //---------------------------------------------------------------------------------------- |
|
160 { |
|
161 return iCharConv; |
|
162 } |
|
163 |
|
164 |
|
165 |