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