sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "T_RTPAR.H"
|
sl@0
|
20 |
|
sl@0
|
21 |
////////////////////////////////////////////
|
sl@0
|
22 |
// CRichTextReader
|
sl@0
|
23 |
////////////////////////////////////////////
|
sl@0
|
24 |
|
sl@0
|
25 |
CRichTextReader* CRichTextReader::NewL()
|
sl@0
|
26 |
{
|
sl@0
|
27 |
CRichTextReader* self=new(ELeave) CRichTextReader;
|
sl@0
|
28 |
CleanupStack::PushL(self);
|
sl@0
|
29 |
self->ConstructL();
|
sl@0
|
30 |
CleanupStack::Pop();
|
sl@0
|
31 |
return self;
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
|
sl@0
|
35 |
CRichTextReader::CRichTextReader()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
// init variables
|
sl@0
|
38 |
iParaStart = 0;
|
sl@0
|
39 |
iConsoleExists = EFalse;
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
|
sl@0
|
43 |
void CRichTextReader::ConstructL()
|
sl@0
|
44 |
{
|
sl@0
|
45 |
// construct PML writer
|
sl@0
|
46 |
iPMLWriter = CPMLWriter::NewL();
|
sl@0
|
47 |
|
sl@0
|
48 |
// construct RichText bits
|
sl@0
|
49 |
iThisParaFormat = CParaFormat::NewL();
|
sl@0
|
50 |
iPrevParaFormat = CParaFormat::NewL();
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
|
sl@0
|
54 |
void CRichTextReader::Destruct()
|
sl@0
|
55 |
{
|
sl@0
|
56 |
// iConsole.Destroy();
|
sl@0
|
57 |
Adt::Destroy(iPMLWriter);
|
sl@0
|
58 |
Adt::Destroy(iThisParaFormat);
|
sl@0
|
59 |
Adt::Destroy(iPrevParaFormat);
|
sl@0
|
60 |
if (iBorder)
|
sl@0
|
61 |
delete(iBorder); // only delete if it hasn't been used (if it has RT destroys it automatically)
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
|
sl@0
|
65 |
CBufSeg* CRichTextReader::ConvertRichText(CRichText* aRichTextDoc)
|
sl@0
|
66 |
// Quiet version of the RichText->PML parser
|
sl@0
|
67 |
// Takes RT doc passed in, reads its global format,
|
sl@0
|
68 |
// then reads the character and paragraph formats phrase by phrase
|
sl@0
|
69 |
{
|
sl@0
|
70 |
iRichTextDoc = aRichTextDoc;
|
sl@0
|
71 |
iDocLength = iRichTextDoc->DocumentLength();
|
sl@0
|
72 |
SenseGlobalFormat();
|
sl@0
|
73 |
|
sl@0
|
74 |
TInt nextPhrase;
|
sl@0
|
75 |
TInt readPos = 0;
|
sl@0
|
76 |
while (readPos < iDocLength)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
nextPhrase = TranslatePhrase(readPos);
|
sl@0
|
79 |
readPos += nextPhrase;
|
sl@0
|
80 |
}
|
sl@0
|
81 |
iPMLWriter->Delete(1); // remove end-of-document paragraph delimiter
|
sl@0
|
82 |
return iPMLWriter->ReturnPmlDoc();
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
|
sl@0
|
86 |
CBufSeg* CRichTextReader::ConvertRichText(CRichText* aRichTextDoc, RConsole aConsole)
|
sl@0
|
87 |
// Version of the RichText->PML parser with console output (primarily for debugging)
|
sl@0
|
88 |
// Takes RT doc passed in, reads its global format,
|
sl@0
|
89 |
// then reads the character and paragraph formats phrase by phrase
|
sl@0
|
90 |
{
|
sl@0
|
91 |
iConsoleExists = ETrue;
|
sl@0
|
92 |
iRichTextDoc = aRichTextDoc;
|
sl@0
|
93 |
iConsole = aConsole;
|
sl@0
|
94 |
iDocLength = iRichTextDoc->DocumentLength();
|
sl@0
|
95 |
SenseGlobalFormat();
|
sl@0
|
96 |
|
sl@0
|
97 |
TInt nextPhrase;
|
sl@0
|
98 |
TInt readPos = 0;
|
sl@0
|
99 |
while (readPos <= iDocLength)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
nextPhrase = TranslatePhrase(readPos);
|
sl@0
|
102 |
readPos += nextPhrase;
|
sl@0
|
103 |
}
|
sl@0
|
104 |
iPMLWriter->Delete(1);
|
sl@0
|
105 |
iPMLWriter->Output(iConsole); // output PML doc to screen
|
sl@0
|
106 |
return iPMLWriter->ReturnPmlDoc();
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
|
sl@0
|
110 |
void CRichTextReader::SenseGlobalFormat()
|
sl@0
|
111 |
// Senses global format & writes it to PML
|
sl@0
|
112 |
{
|
sl@0
|
113 |
// construct rich text bits
|
sl@0
|
114 |
const CParaFormatLayer* globalParaFormatLayer; // initialised with factory settings
|
sl@0
|
115 |
const CCharFormatLayer* globalCharFormatLayer;
|
sl@0
|
116 |
CParaFormat* globalParaFormat = CParaFormat::NewL();
|
sl@0
|
117 |
TCharFormat globalCharFormat;
|
sl@0
|
118 |
|
sl@0
|
119 |
// Sense global format
|
sl@0
|
120 |
globalParaFormatLayer = iRichTextDoc->SenseGlobalParaFormatLayer();
|
sl@0
|
121 |
globalParaFormatLayer->SenseEffectiveL(globalParaFormat);
|
sl@0
|
122 |
globalCharFormatLayer = iRichTextDoc->SenseGlobalCharFormatLayer();
|
sl@0
|
123 |
globalCharFormatLayer->SenseEffective(globalCharFormat);
|
sl@0
|
124 |
|
sl@0
|
125 |
// now set it
|
sl@0
|
126 |
iPMLWriter->SetTag(EGlobal, ETagStart); // output <G
|
sl@0
|
127 |
CompareParaToFactory(globalParaFormat); // step through format, adding all != factory settings
|
sl@0
|
128 |
CompareCharToFactory(globalCharFormat); // ...
|
sl@0
|
129 |
iPMLWriter->SetTag(EGlobal, ETagEnd); // output >\n
|
sl@0
|
130 |
|
sl@0
|
131 |
// initialise iPrevXxxxFormat
|
sl@0
|
132 |
globalParaFormatLayer->SenseEffectiveL(iPrevParaFormat);
|
sl@0
|
133 |
globalCharFormatLayer->SenseEffective(iPrevCharFormat);
|
sl@0
|
134 |
|
sl@0
|
135 |
// destroy rich text bits
|
sl@0
|
136 |
Adt::Destroy(globalParaFormat);
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
|
sl@0
|
140 |
TInt CRichTextReader::TranslatePhrase(TInt aReadPos)
|
sl@0
|
141 |
// Output any new formatting being applied to this phrase
|
sl@0
|
142 |
// First check whether this phrase is the start of a new paragraph
|
sl@0
|
143 |
// If so check the paragraph format
|
sl@0
|
144 |
// Next check the character formatting of the phrase
|
sl@0
|
145 |
{
|
sl@0
|
146 |
CPicture* pic; // dummy pointer for senseChars
|
sl@0
|
147 |
TPtrC currentPhrase;
|
sl@0
|
148 |
TUint pmlWritePos;
|
sl@0
|
149 |
|
sl@0
|
150 |
TInt currentParaStart = aReadPos;
|
sl@0
|
151 |
|
sl@0
|
152 |
// paragraph formatting
|
sl@0
|
153 |
if (currentParaStart != 0) // doesn't work for position=0 -- Duncan!!
|
sl@0
|
154 |
iRichTextDoc->ParagraphStart(currentParaStart);
|
sl@0
|
155 |
if ((currentParaStart > iParaStart)||(aReadPos == 0)) // is it a new paragraph?
|
sl@0
|
156 |
{
|
sl@0
|
157 |
iParaStart = currentParaStart;
|
sl@0
|
158 |
// delete para delimiter
|
sl@0
|
159 |
if (aReadPos > 0)
|
sl@0
|
160 |
iPMLWriter->Delete(1); // deletes 1 chars previous to the current insert pos
|
sl@0
|
161 |
// add para tag
|
sl@0
|
162 |
iPMLWriter->SetTag(EParagraph, ETagStart);
|
sl@0
|
163 |
iRichTextDoc->SenseParagraphFormatL(aReadPos,iThisParaFormat); // get para format
|
sl@0
|
164 |
CompareParaFormats(); // compare to previous paragraph to get changes
|
sl@0
|
165 |
iRichTextDoc->SenseParagraphFormatL(aReadPos,iPrevParaFormat); // set prevParaFormat to current & copy compound attributes
|
sl@0
|
166 |
iPrevParaFormat->iTopBorder=CopyBorderL(iThisParaFormat->iTopBorder,iPrevParaFormat->iTopBorder);
|
sl@0
|
167 |
iPrevParaFormat->iBottomBorder=CopyBorderL(iThisParaFormat->iBottomBorder,iPrevParaFormat->iBottomBorder);
|
sl@0
|
168 |
iPrevParaFormat->iLeftBorder=CopyBorderL(iThisParaFormat->iLeftBorder,iPrevParaFormat->iLeftBorder);
|
sl@0
|
169 |
iPrevParaFormat->iRightBorder=CopyBorderL(iThisParaFormat->iRightBorder,iPrevParaFormat->iRightBorder);
|
sl@0
|
170 |
iPrevParaFormat->iBullet=CopyBulletL(iThisParaFormat->iBullet,iPrevParaFormat->iBullet);
|
sl@0
|
171 |
iPMLWriter->SetTag(EParagraph, ETagEnd);
|
sl@0
|
172 |
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
// character formatting
|
sl@0
|
176 |
iPMLWriter->SetTag(ECharacter, ETagStart);
|
sl@0
|
177 |
pmlWritePos = iPMLWriter->WritePos();
|
sl@0
|
178 |
iRichTextDoc->SenseChars(aReadPos,currentPhrase,iThisCharFormat,pic); // get char format
|
sl@0
|
179 |
CompareCharFormats(); // compare to previous
|
sl@0
|
180 |
iRichTextDoc->SenseChars(aReadPos,currentPhrase,iPrevCharFormat,pic); // get char format
|
sl@0
|
181 |
if (pmlWritePos == iPMLWriter->WritePos())
|
sl@0
|
182 |
iPMLWriter->Delete(3); // delete tag start if tag is empty
|
sl@0
|
183 |
else
|
sl@0
|
184 |
iPMLWriter->SetTag(ECharacter, ETagEnd); // else close tag
|
sl@0
|
185 |
|
sl@0
|
186 |
iPMLWriter->Insert(currentPhrase); // output text of phrase to PML
|
sl@0
|
187 |
return currentPhrase.Length(); // return relative pos of start of next phrase
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
|
sl@0
|
191 |
TParaBorder* CRichTextReader::CopyBorderL(const TParaBorder* aFrom,TParaBorder* aTo)
|
sl@0
|
192 |
// copies one paragraph border to another, creating or destroying where necessary
|
sl@0
|
193 |
{
|
sl@0
|
194 |
if (!aFrom)
|
sl@0
|
195 |
{
|
sl@0
|
196 |
if (aTo)
|
sl@0
|
197 |
delete(aTo);
|
sl@0
|
198 |
return NULL; // No border cell in the original
|
sl@0
|
199 |
}
|
sl@0
|
200 |
else
|
sl@0
|
201 |
{
|
sl@0
|
202 |
if (!aTo)
|
sl@0
|
203 |
aTo = new(ELeave) TParaBorder;
|
sl@0
|
204 |
*aTo = *aFrom;
|
sl@0
|
205 |
return aTo;
|
sl@0
|
206 |
}
|
sl@0
|
207 |
}
|
sl@0
|
208 |
|
sl@0
|
209 |
|
sl@0
|
210 |
TBullet* CRichTextReader::CopyBulletL(const TBullet* aFrom,TBullet* aTo)
|
sl@0
|
211 |
// copies one bullet to another, creating or destroying where necessary
|
sl@0
|
212 |
{
|
sl@0
|
213 |
if (!aFrom)
|
sl@0
|
214 |
{
|
sl@0
|
215 |
if (aTo)
|
sl@0
|
216 |
delete(aTo);
|
sl@0
|
217 |
return NULL; // No bullet cell in the original
|
sl@0
|
218 |
}
|
sl@0
|
219 |
else
|
sl@0
|
220 |
{
|
sl@0
|
221 |
if (!aTo)
|
sl@0
|
222 |
aTo = new(ELeave) TBullet;
|
sl@0
|
223 |
*aTo = *aFrom;
|
sl@0
|
224 |
return aTo;
|
sl@0
|
225 |
}
|
sl@0
|
226 |
}
|
sl@0
|
227 |
|
sl@0
|
228 |
|
sl@0
|
229 |
void CRichTextReader::CompareParaToFactory(CParaFormat* aSensedParaFormat)
|
sl@0
|
230 |
// Compares the supplied paragraph format to the factory defaults and acts on any differences
|
sl@0
|
231 |
{
|
sl@0
|
232 |
// create a new reference format with factory settings
|
sl@0
|
233 |
CParaFormat* refParaFormat = CParaFormat::NewL();
|
sl@0
|
234 |
// step through, comparing aSensedParaFormat to the reference
|
sl@0
|
235 |
// if any attributes differ, set the differences in the PML doc
|
sl@0
|
236 |
if (aSensedParaFormat->iLanguage != refParaFormat->iLanguage)
|
sl@0
|
237 |
iPMLWriter->SetFormat(EAttParaLanguage, aSensedParaFormat->iLanguage);
|
sl@0
|
238 |
if (aSensedParaFormat->iLeftMargin != refParaFormat->iLeftMargin)
|
sl@0
|
239 |
iPMLWriter->SetFormat(EAttLeftMargin, aSensedParaFormat->iLeftMargin);
|
sl@0
|
240 |
if (aSensedParaFormat->iRightMargin != refParaFormat->iRightMargin)
|
sl@0
|
241 |
iPMLWriter->SetFormat(EAttRightMargin, aSensedParaFormat->iRightMargin);
|
sl@0
|
242 |
if (aSensedParaFormat->iIndent != refParaFormat->iIndent)
|
sl@0
|
243 |
iPMLWriter->SetFormat(EAttIndent, aSensedParaFormat->iIndent);
|
sl@0
|
244 |
if (aSensedParaFormat->iAlignment != refParaFormat->iAlignment)
|
sl@0
|
245 |
iPMLWriter->SetFormat(EAttAlignment, aSensedParaFormat->iAlignment);
|
sl@0
|
246 |
if (aSensedParaFormat->iLineSpacing != refParaFormat->iLineSpacing)
|
sl@0
|
247 |
iPMLWriter->SetFormat(EAttLineSpacing, aSensedParaFormat->iLineSpacing);
|
sl@0
|
248 |
if (aSensedParaFormat->iLineSpacingControl != refParaFormat->iLineSpacingControl)
|
sl@0
|
249 |
iPMLWriter->SetFormat(EAttLineSpacingControl, aSensedParaFormat->iLineSpacingControl);
|
sl@0
|
250 |
if (aSensedParaFormat->iSpaceBefore != refParaFormat->iSpaceBefore)
|
sl@0
|
251 |
iPMLWriter->SetFormat(EAttSpaceBefore, aSensedParaFormat->iSpaceBefore);
|
sl@0
|
252 |
if (aSensedParaFormat->iSpaceAfter != refParaFormat->iSpaceAfter)
|
sl@0
|
253 |
iPMLWriter->SetFormat(EAttSpaceAfter, aSensedParaFormat->iSpaceAfter);
|
sl@0
|
254 |
if (aSensedParaFormat->iKeepTogether != refParaFormat->iKeepTogether)
|
sl@0
|
255 |
iPMLWriter->SetFormat(EAttKeepTogether, aSensedParaFormat->iKeepTogether);
|
sl@0
|
256 |
if (aSensedParaFormat->iKeepWithNext != refParaFormat->iKeepWithNext)
|
sl@0
|
257 |
iPMLWriter->SetFormat(EAttKeepWithNext, aSensedParaFormat->iKeepWithNext);
|
sl@0
|
258 |
if (aSensedParaFormat->iStartNewPage != refParaFormat->iStartNewPage)
|
sl@0
|
259 |
iPMLWriter->SetFormat(EAttStartNewPage, aSensedParaFormat->iStartNewPage);
|
sl@0
|
260 |
if (aSensedParaFormat->iWidowOrphan != refParaFormat->iWidowOrphan)
|
sl@0
|
261 |
iPMLWriter->SetFormat(EAttWidowOrphan, aSensedParaFormat->iWidowOrphan);
|
sl@0
|
262 |
if (aSensedParaFormat->iBorderMargin != refParaFormat->iBorderMargin)
|
sl@0
|
263 |
iPMLWriter->SetFormat(EAttBorderMargin, aSensedParaFormat->iBorderMargin);
|
sl@0
|
264 |
if (aSensedParaFormat->iTopBorder)
|
sl@0
|
265 |
{
|
sl@0
|
266 |
if (refParaFormat->iTopBorder == NULL)
|
sl@0
|
267 |
iPMLWriter->SetFormat(EAttTopBorder, aSensedParaFormat->iTopBorder);
|
sl@0
|
268 |
else if ((aSensedParaFormat->iTopBorder->iLineStyle != refParaFormat->iTopBorder->iLineStyle)
|
sl@0
|
269 |
||(aSensedParaFormat->iTopBorder->iAutoColor != refParaFormat->iTopBorder->iAutoColor)
|
sl@0
|
270 |
||(aSensedParaFormat->iTopBorder->iColor != refParaFormat->iTopBorder->iColor))
|
sl@0
|
271 |
{
|
sl@0
|
272 |
iPMLWriter->SetFormat(EAttTopBorder, aSensedParaFormat->iTopBorder);
|
sl@0
|
273 |
}
|
sl@0
|
274 |
}
|
sl@0
|
275 |
if (aSensedParaFormat->iBottomBorder)
|
sl@0
|
276 |
{
|
sl@0
|
277 |
if (refParaFormat->iTopBorder == NULL)
|
sl@0
|
278 |
iPMLWriter->SetFormat(EAttBottomBorder, aSensedParaFormat->iBottomBorder);
|
sl@0
|
279 |
else if ((aSensedParaFormat->iBottomBorder->iLineStyle != refParaFormat->iBottomBorder->iLineStyle)
|
sl@0
|
280 |
||(aSensedParaFormat->iBottomBorder->iAutoColor != refParaFormat->iBottomBorder->iAutoColor)
|
sl@0
|
281 |
||(aSensedParaFormat->iBottomBorder->iColor != refParaFormat->iBottomBorder->iColor))
|
sl@0
|
282 |
{
|
sl@0
|
283 |
iPMLWriter->SetFormat(EAttBottomBorder, aSensedParaFormat->iBottomBorder);
|
sl@0
|
284 |
}
|
sl@0
|
285 |
}
|
sl@0
|
286 |
if (aSensedParaFormat->iLeftBorder)
|
sl@0
|
287 |
{
|
sl@0
|
288 |
if (refParaFormat->iTopBorder == NULL)
|
sl@0
|
289 |
iPMLWriter->SetFormat(EAttLeftBorder, aSensedParaFormat->iLeftBorder);
|
sl@0
|
290 |
else if ((aSensedParaFormat->iLeftBorder->iLineStyle != refParaFormat->iLeftBorder->iLineStyle)
|
sl@0
|
291 |
||(aSensedParaFormat->iLeftBorder->iAutoColor != refParaFormat->iLeftBorder->iAutoColor)
|
sl@0
|
292 |
||(aSensedParaFormat->iLeftBorder->iColor != refParaFormat->iLeftBorder->iColor))
|
sl@0
|
293 |
{
|
sl@0
|
294 |
iPMLWriter->SetFormat(EAttLeftBorder, aSensedParaFormat->iLeftBorder);
|
sl@0
|
295 |
}
|
sl@0
|
296 |
}
|
sl@0
|
297 |
if (aSensedParaFormat->iRightBorder)
|
sl@0
|
298 |
{
|
sl@0
|
299 |
if (refParaFormat->iTopBorder == NULL)
|
sl@0
|
300 |
iPMLWriter->SetFormat(EAttRightBorder, aSensedParaFormat->iRightBorder);
|
sl@0
|
301 |
else if ((aSensedParaFormat->iRightBorder->iLineStyle != refParaFormat->iRightBorder->iLineStyle)
|
sl@0
|
302 |
||(aSensedParaFormat->iRightBorder->iAutoColor != refParaFormat->iRightBorder->iAutoColor)
|
sl@0
|
303 |
||(aSensedParaFormat->iRightBorder->iColor != refParaFormat->iRightBorder->iColor))
|
sl@0
|
304 |
{
|
sl@0
|
305 |
iPMLWriter->SetFormat(EAttRightBorder, aSensedParaFormat->iRightBorder);
|
sl@0
|
306 |
}
|
sl@0
|
307 |
}
|
sl@0
|
308 |
if (aSensedParaFormat->iBullet)
|
sl@0
|
309 |
{
|
sl@0
|
310 |
if (refParaFormat->iBullet == NULL)
|
sl@0
|
311 |
iPMLWriter->SetFormat(EAttBullet, aSensedParaFormat->iBullet);
|
sl@0
|
312 |
if ((aSensedParaFormat->iBullet->iCharacterCode != refParaFormat->iBullet->iCharacterCode)
|
sl@0
|
313 |
||(aSensedParaFormat->iBullet->iHeight != refParaFormat->iBullet->iHeight)
|
sl@0
|
314 |
||(aSensedParaFormat->iBullet->iTypeface.iName != refParaFormat->iBullet->iTypeface.iName)
|
sl@0
|
315 |
||(aSensedParaFormat->iBullet->iTypeface.iFlags != refParaFormat->iBullet->iTypeface.iFlags))
|
sl@0
|
316 |
{
|
sl@0
|
317 |
iPMLWriter->SetFormat(EAttBullet, aSensedParaFormat->iBullet);
|
sl@0
|
318 |
}
|
sl@0
|
319 |
}
|
sl@0
|
320 |
if (aSensedParaFormat->iDefaultTabWidth != refParaFormat->iDefaultTabWidth)
|
sl@0
|
321 |
iPMLWriter->SetFormat(EAttDefaultTabWidth, aSensedParaFormat->iDefaultTabWidth);
|
sl@0
|
322 |
CheckTabList(aSensedParaFormat, refParaFormat); // tabs are sensed separately
|
sl@0
|
323 |
|
sl@0
|
324 |
// Destroy ref format
|
sl@0
|
325 |
Adt::Destroy(refParaFormat);
|
sl@0
|
326 |
}
|
sl@0
|
327 |
|
sl@0
|
328 |
void CRichTextReader::CompareCharToFactory(TCharFormat aSensedCharFormat)
|
sl@0
|
329 |
// Compares the supplied character format to the factory defaults and acts on any differences
|
sl@0
|
330 |
{
|
sl@0
|
331 |
// create a new reference format with factory settings
|
sl@0
|
332 |
TCharFormat refCharFormat;
|
sl@0
|
333 |
// step through, comparing aSensedCharFormat to the reference
|
sl@0
|
334 |
// if any attributes differ, set the differences in the PML doc
|
sl@0
|
335 |
if (aSensedCharFormat.iLanguage != refCharFormat.iLanguage)
|
sl@0
|
336 |
iPMLWriter->SetFormat(EAttCharLanguage, aSensedCharFormat.iLanguage);
|
sl@0
|
337 |
if (aSensedCharFormat.iColor != refCharFormat.iColor)
|
sl@0
|
338 |
iPMLWriter->SetFormat(EAttColor, aSensedCharFormat.iColor.RgbToUint());
|
sl@0
|
339 |
if (aSensedCharFormat.iFontSpec.iTypeface.iName != refCharFormat.iFontSpec.iTypeface.iName)
|
sl@0
|
340 |
iPMLWriter->SetFormat(EAttFontTypefaceName, aSensedCharFormat.iFontSpec.iTypeface);
|
sl@0
|
341 |
if (aSensedCharFormat.iFontSpec.iTypeface.iFlags != refCharFormat.iFontSpec.iTypeface.iFlags)
|
sl@0
|
342 |
iPMLWriter->SetFormat(EAttFontTypefaceFlags, aSensedCharFormat.iFontSpec.iTypeface);
|
sl@0
|
343 |
if (aSensedCharFormat.iFontSpec.iHeight != refCharFormat.iFontSpec.iHeight)
|
sl@0
|
344 |
iPMLWriter->SetFormat(EAttFontHeight, aSensedCharFormat.iFontSpec.iHeight);
|
sl@0
|
345 |
if (aSensedCharFormat.iFontSpec.iPosture != refCharFormat.iFontSpec.iPosture)
|
sl@0
|
346 |
iPMLWriter->SetFormat(EAttFontPosture, aSensedCharFormat.iFontSpec.iPosture);
|
sl@0
|
347 |
if (aSensedCharFormat.iFontSpec.iStrokeWeight != refCharFormat.iFontSpec.iStrokeWeight)
|
sl@0
|
348 |
iPMLWriter->SetFormat(EAttFontStrokeWeight, aSensedCharFormat.iFontSpec.iStrokeWeight);
|
sl@0
|
349 |
if (aSensedCharFormat.iFontSpec.iPos != refCharFormat.iFontSpec.iPos)
|
sl@0
|
350 |
iPMLWriter->SetFormat(EAttFontPrintPos, aSensedCharFormat.iFontSpec.iPos);
|
sl@0
|
351 |
if (aSensedCharFormat.iFontSpec.iUnderline != refCharFormat.iFontSpec.iUnderline)
|
sl@0
|
352 |
iPMLWriter->SetFormat((TTextFormatAttribute)EAttFontUnderline, aSensedCharFormat.iFontSpec.iUnderline);
|
sl@0
|
353 |
if (aSensedCharFormat.iFontSpec.iStrikethrough != refCharFormat.iFontSpec.iStrikethrough)
|
sl@0
|
354 |
iPMLWriter->SetFormat(EAttFontStrikethrough, aSensedCharFormat.iFontSpec.iStrikethrough);
|
sl@0
|
355 |
}
|
sl@0
|
356 |
|
sl@0
|
357 |
|
sl@0
|
358 |
void CRichTextReader::CompareParaFormats()
|
sl@0
|
359 |
// compares the current para format with the format of the previous para
|
sl@0
|
360 |
// any differences are output to PML
|
sl@0
|
361 |
{
|
sl@0
|
362 |
if (iThisParaFormat->iLanguage != iPrevParaFormat->iLanguage)
|
sl@0
|
363 |
iPMLWriter->SetFormat(EAttParaLanguage, iThisParaFormat->iLanguage);
|
sl@0
|
364 |
if (iThisParaFormat->iLeftMargin != iPrevParaFormat->iLeftMargin)
|
sl@0
|
365 |
iPMLWriter->SetFormat(EAttLeftMargin, iThisParaFormat->iLeftMargin);
|
sl@0
|
366 |
if (iThisParaFormat->iRightMargin != iPrevParaFormat->iRightMargin)
|
sl@0
|
367 |
iPMLWriter->SetFormat(EAttRightMargin, iThisParaFormat->iRightMargin);
|
sl@0
|
368 |
if (iThisParaFormat->iIndent != iPrevParaFormat->iIndent)
|
sl@0
|
369 |
iPMLWriter->SetFormat(EAttIndent, iThisParaFormat->iIndent);
|
sl@0
|
370 |
if (iThisParaFormat->iAlignment != iPrevParaFormat->iAlignment)
|
sl@0
|
371 |
iPMLWriter->SetFormat(EAttAlignment, iThisParaFormat->iAlignment);
|
sl@0
|
372 |
if (iThisParaFormat->iLineSpacing != iPrevParaFormat->iLineSpacing)
|
sl@0
|
373 |
iPMLWriter->SetFormat(EAttLineSpacing, iThisParaFormat->iLineSpacing);
|
sl@0
|
374 |
if (iThisParaFormat->iLineSpacingControl != iPrevParaFormat->iLineSpacingControl)
|
sl@0
|
375 |
iPMLWriter->SetFormat(EAttLineSpacingControl, iThisParaFormat->iLineSpacingControl);
|
sl@0
|
376 |
if (iThisParaFormat->iSpaceBefore != iPrevParaFormat->iSpaceBefore)
|
sl@0
|
377 |
iPMLWriter->SetFormat(EAttSpaceBefore, iThisParaFormat->iSpaceBefore);
|
sl@0
|
378 |
if (iThisParaFormat->iSpaceAfter != iPrevParaFormat->iSpaceAfter)
|
sl@0
|
379 |
iPMLWriter->SetFormat(EAttSpaceAfter, iThisParaFormat->iSpaceAfter);
|
sl@0
|
380 |
if (iThisParaFormat->iKeepTogether != iPrevParaFormat->iKeepTogether)
|
sl@0
|
381 |
iPMLWriter->SetFormat(EAttKeepTogether, iThisParaFormat->iKeepTogether);
|
sl@0
|
382 |
if (iThisParaFormat->iKeepWithNext != iPrevParaFormat->iKeepWithNext)
|
sl@0
|
383 |
iPMLWriter->SetFormat(EAttKeepWithNext, iThisParaFormat->iKeepWithNext);
|
sl@0
|
384 |
if (iThisParaFormat->iStartNewPage != iPrevParaFormat->iStartNewPage)
|
sl@0
|
385 |
iPMLWriter->SetFormat(EAttStartNewPage, iThisParaFormat->iStartNewPage);
|
sl@0
|
386 |
if (iThisParaFormat->iWidowOrphan != iPrevParaFormat->iWidowOrphan)
|
sl@0
|
387 |
iPMLWriter->SetFormat(EAttWidowOrphan, iThisParaFormat->iWidowOrphan);
|
sl@0
|
388 |
if (iThisParaFormat->iBorderMargin != iPrevParaFormat->iBorderMargin)
|
sl@0
|
389 |
iPMLWriter->SetFormat(EAttBorderMargin, iThisParaFormat->iBorderMargin);
|
sl@0
|
390 |
if (iThisParaFormat->iTopBorder)
|
sl@0
|
391 |
{
|
sl@0
|
392 |
if (iPrevParaFormat->iTopBorder == NULL)
|
sl@0
|
393 |
iPMLWriter->SetFormat(EAttTopBorder, iThisParaFormat->iTopBorder);
|
sl@0
|
394 |
else if ((iThisParaFormat->iTopBorder->iLineStyle != iPrevParaFormat->iTopBorder->iLineStyle)
|
sl@0
|
395 |
||(iThisParaFormat->iTopBorder->iAutoColor != iPrevParaFormat->iTopBorder->iAutoColor)
|
sl@0
|
396 |
||(iThisParaFormat->iTopBorder->iColor != iPrevParaFormat->iTopBorder->iColor))
|
sl@0
|
397 |
{
|
sl@0
|
398 |
iPMLWriter->SetFormat(EAttTopBorder, iThisParaFormat->iTopBorder);
|
sl@0
|
399 |
}
|
sl@0
|
400 |
}
|
sl@0
|
401 |
if (iThisParaFormat->iBottomBorder)
|
sl@0
|
402 |
{
|
sl@0
|
403 |
if (iPrevParaFormat->iBottomBorder == NULL)
|
sl@0
|
404 |
iPMLWriter->SetFormat(EAttBottomBorder, iThisParaFormat->iBottomBorder);
|
sl@0
|
405 |
else if ((iThisParaFormat->iBottomBorder->iLineStyle != iPrevParaFormat->iBottomBorder->iLineStyle)
|
sl@0
|
406 |
||(iThisParaFormat->iBottomBorder->iAutoColor != iPrevParaFormat->iBottomBorder->iAutoColor)
|
sl@0
|
407 |
||(iThisParaFormat->iBottomBorder->iColor != iPrevParaFormat->iBottomBorder->iColor))
|
sl@0
|
408 |
{
|
sl@0
|
409 |
iPMLWriter->SetFormat(EAttBottomBorder, iThisParaFormat->iBottomBorder);
|
sl@0
|
410 |
}
|
sl@0
|
411 |
}
|
sl@0
|
412 |
if (iThisParaFormat->iLeftBorder)
|
sl@0
|
413 |
{
|
sl@0
|
414 |
if (iPrevParaFormat->iLeftBorder == NULL)
|
sl@0
|
415 |
iPMLWriter->SetFormat(EAttLeftBorder, iThisParaFormat->iLeftBorder);
|
sl@0
|
416 |
if ((iThisParaFormat->iLeftBorder->iLineStyle != iPrevParaFormat->iLeftBorder->iLineStyle)
|
sl@0
|
417 |
||(iThisParaFormat->iLeftBorder->iAutoColor != iPrevParaFormat->iLeftBorder->iAutoColor)
|
sl@0
|
418 |
||(iThisParaFormat->iLeftBorder->iColor != iPrevParaFormat->iLeftBorder->iColor))
|
sl@0
|
419 |
{
|
sl@0
|
420 |
iPMLWriter->SetFormat(EAttLeftBorder, iThisParaFormat->iLeftBorder);
|
sl@0
|
421 |
}
|
sl@0
|
422 |
}
|
sl@0
|
423 |
if (iThisParaFormat->iRightBorder)
|
sl@0
|
424 |
{
|
sl@0
|
425 |
if (iPrevParaFormat->iRightBorder == NULL)
|
sl@0
|
426 |
iPMLWriter->SetFormat(EAttRightBorder, iThisParaFormat->iRightBorder);
|
sl@0
|
427 |
if ((iThisParaFormat->iRightBorder->iLineStyle != iPrevParaFormat->iRightBorder->iLineStyle)
|
sl@0
|
428 |
||(iThisParaFormat->iRightBorder->iAutoColor != iPrevParaFormat->iRightBorder->iAutoColor)
|
sl@0
|
429 |
||(iThisParaFormat->iRightBorder->iColor != iPrevParaFormat->iRightBorder->iColor))
|
sl@0
|
430 |
{
|
sl@0
|
431 |
iPMLWriter->SetFormat(EAttRightBorder, iThisParaFormat->iRightBorder);
|
sl@0
|
432 |
}
|
sl@0
|
433 |
}
|
sl@0
|
434 |
if (iThisParaFormat->iBullet)
|
sl@0
|
435 |
{
|
sl@0
|
436 |
if (iPrevParaFormat->iBullet == NULL)
|
sl@0
|
437 |
iPMLWriter->SetFormat(EAttBullet, iThisParaFormat->iBullet);
|
sl@0
|
438 |
else if ((iThisParaFormat->iBullet->iCharacterCode != iPrevParaFormat->iBullet->iCharacterCode)
|
sl@0
|
439 |
||(iThisParaFormat->iBullet->iHeight != iPrevParaFormat->iBullet->iHeight)
|
sl@0
|
440 |
||(iThisParaFormat->iBullet->iTypeface.iName != iPrevParaFormat->iBullet->iTypeface.iName)
|
sl@0
|
441 |
||(iThisParaFormat->iBullet->iTypeface.iFlags != iPrevParaFormat->iBullet->iTypeface.iFlags))
|
sl@0
|
442 |
{
|
sl@0
|
443 |
iPMLWriter->SetFormat(EAttBullet, iThisParaFormat->iBullet);
|
sl@0
|
444 |
}
|
sl@0
|
445 |
}
|
sl@0
|
446 |
if (iThisParaFormat->iDefaultTabWidth != iPrevParaFormat->iDefaultTabWidth)
|
sl@0
|
447 |
iPMLWriter->SetFormat(EAttDefaultTabWidth, iThisParaFormat->iDefaultTabWidth);
|
sl@0
|
448 |
CheckTabList(iThisParaFormat, iPrevParaFormat); // tabs are sensed separately
|
sl@0
|
449 |
}
|
sl@0
|
450 |
|
sl@0
|
451 |
|
sl@0
|
452 |
void CRichTextReader::CheckTabList(CParaFormat* aFormatOne, CParaFormat* aFormatTwo)
|
sl@0
|
453 |
// Check whether the first (current) and second formats' tablists differ
|
sl@0
|
454 |
// If they do, output whole of first list to PML
|
sl@0
|
455 |
{
|
sl@0
|
456 |
TBool output = EFalse;
|
sl@0
|
457 |
if (aFormatOne->TabCount() != aFormatTwo->TabCount())
|
sl@0
|
458 |
output = ETrue; // output to PML
|
sl@0
|
459 |
else
|
sl@0
|
460 |
{
|
sl@0
|
461 |
// lists are same length: check that all members are the same
|
sl@0
|
462 |
TInt index = 0;
|
sl@0
|
463 |
TBool dif = EFalse;
|
sl@0
|
464 |
while ((index < aFormatOne->TabCount())&&(!dif))
|
sl@0
|
465 |
{
|
sl@0
|
466 |
if (aFormatOne->TabStop(index) != aFormatTwo->TabStop(index))
|
sl@0
|
467 |
output = ETrue; // output to PML
|
sl@0
|
468 |
index++;
|
sl@0
|
469 |
}
|
sl@0
|
470 |
}
|
sl@0
|
471 |
if (output)
|
sl@0
|
472 |
{
|
sl@0
|
473 |
for (TInt i=0; i < aFormatOne->TabCount(); i++)
|
sl@0
|
474 |
iPMLWriter->SetFormat(EAttTabStop, aFormatOne->TabStop(i));
|
sl@0
|
475 |
}
|
sl@0
|
476 |
}
|
sl@0
|
477 |
|
sl@0
|
478 |
|
sl@0
|
479 |
void CRichTextReader::CompareCharFormats()
|
sl@0
|
480 |
{
|
sl@0
|
481 |
if (iThisCharFormat.iLanguage != iPrevCharFormat.iLanguage)
|
sl@0
|
482 |
iPMLWriter->SetFormat(EAttCharLanguage, iThisCharFormat.iLanguage);
|
sl@0
|
483 |
if (iThisCharFormat.iColor != iPrevCharFormat.iColor)
|
sl@0
|
484 |
iPMLWriter->SetFormat(EAttColor, iThisCharFormat.iColor.RgbToUint());
|
sl@0
|
485 |
if (iThisCharFormat.iFontSpec.iTypeface.iName != iPrevCharFormat.iFontSpec.iTypeface.iName)
|
sl@0
|
486 |
iPMLWriter->SetFormat(EAttFontTypefaceName, iThisCharFormat.iFontSpec.iTypeface);
|
sl@0
|
487 |
if (iThisCharFormat.iFontSpec.iTypeface.iFlags != iPrevCharFormat.iFontSpec.iTypeface.iFlags)
|
sl@0
|
488 |
iPMLWriter->SetFormat(EAttFontTypefaceFlags, iThisCharFormat.iFontSpec.iTypeface);
|
sl@0
|
489 |
if (iThisCharFormat.iFontSpec.iHeight != iPrevCharFormat.iFontSpec.iHeight)
|
sl@0
|
490 |
iPMLWriter->SetFormat(EAttFontHeight, iThisCharFormat.iFontSpec.iHeight);
|
sl@0
|
491 |
if (iThisCharFormat.iFontSpec.iPosture != iPrevCharFormat.iFontSpec.iPosture)
|
sl@0
|
492 |
iPMLWriter->SetFormat(EAttFontPosture, iThisCharFormat.iFontSpec.iPosture);
|
sl@0
|
493 |
if (iThisCharFormat.iFontSpec.iStrokeWeight != iPrevCharFormat.iFontSpec.iStrokeWeight)
|
sl@0
|
494 |
iPMLWriter->SetFormat(EAttFontStrokeWeight, iThisCharFormat.iFontSpec.iStrokeWeight);
|
sl@0
|
495 |
if (iThisCharFormat.iFontSpec.iPos != iPrevCharFormat.iFontSpec.iPos)
|
sl@0
|
496 |
iPMLWriter->SetFormat(EAttFontPrintPos, iThisCharFormat.iFontSpec.iPos);
|
sl@0
|
497 |
if (iThisCharFormat.iFontSpec.iUnderline != iPrevCharFormat.iFontSpec.iUnderline)
|
sl@0
|
498 |
iPMLWriter->SetFormat(EAttFontUnderline, iThisCharFormat.iFontSpec.iUnderline);
|
sl@0
|
499 |
if (iThisCharFormat.iFontSpec.iStrikethrough != iPrevCharFormat.iFontSpec.iStrikethrough)
|
sl@0
|
500 |
iPMLWriter->SetFormat(EAttFontStrikethrough, iThisCharFormat.iFontSpec.iStrikethrough);
|
sl@0
|
501 |
}
|
sl@0
|
502 |
|
sl@0
|
503 |
|
sl@0
|
504 |
|
sl@0
|
505 |
|
sl@0
|
506 |
//////////////////////////////////////////////////////
|
sl@0
|
507 |
// CPMLWriter
|
sl@0
|
508 |
//////////////////////////////////////////////////////
|
sl@0
|
509 |
|
sl@0
|
510 |
CPMLWriter* CPMLWriter::NewL()
|
sl@0
|
511 |
{
|
sl@0
|
512 |
CPMLWriter* self=new(ELeave) CPMLWriter;
|
sl@0
|
513 |
self->Construct();
|
sl@0
|
514 |
return self;
|
sl@0
|
515 |
}
|
sl@0
|
516 |
|
sl@0
|
517 |
|
sl@0
|
518 |
CPMLWriter::CPMLWriter()
|
sl@0
|
519 |
{
|
sl@0
|
520 |
// init variables
|
sl@0
|
521 |
}
|
sl@0
|
522 |
|
sl@0
|
523 |
|
sl@0
|
524 |
void CPMLWriter::Construct()
|
sl@0
|
525 |
{
|
sl@0
|
526 |
iTextBuf = CBufSeg::New(64); // create buffer with granularity 64
|
sl@0
|
527 |
}
|
sl@0
|
528 |
|
sl@0
|
529 |
|
sl@0
|
530 |
void CPMLWriter::Destruct()
|
sl@0
|
531 |
{
|
sl@0
|
532 |
Adt::Destroy(iTextBuf);
|
sl@0
|
533 |
}
|
sl@0
|
534 |
|
sl@0
|
535 |
|
sl@0
|
536 |
void CPMLWriter::ExpandBuf(const TDes8& aBuffer, TDes& aTarget)
|
sl@0
|
537 |
//
|
sl@0
|
538 |
// Input 8 bit buffer to be returned by ref. as an 8/16-bit version
|
sl@0
|
539 |
// Used for unicode compatability
|
sl@0
|
540 |
//
|
sl@0
|
541 |
{
|
sl@0
|
542 |
TText textPointer;
|
sl@0
|
543 |
for (TInt pos=0 ; pos<aBuffer.Length() ; pos++ )
|
sl@0
|
544 |
{
|
sl@0
|
545 |
textPointer = aBuffer[pos];
|
sl@0
|
546 |
aTarget.Append(textPointer);
|
sl@0
|
547 |
}
|
sl@0
|
548 |
}
|
sl@0
|
549 |
|
sl@0
|
550 |
|
sl@0
|
551 |
void CPMLWriter::SquashBuf(const TDesC& aBuffer, TDes8& aTarget)
|
sl@0
|
552 |
//
|
sl@0
|
553 |
// Input 8/16 bit buffer and an 8-bit target to be copied into.
|
sl@0
|
554 |
// Used for unicode compatability
|
sl@0
|
555 |
//
|
sl@0
|
556 |
{
|
sl@0
|
557 |
TText textPointer;
|
sl@0
|
558 |
for (TInt pos=0; pos<aBuffer.Length(); pos++)
|
sl@0
|
559 |
{
|
sl@0
|
560 |
textPointer = aBuffer[pos];
|
sl@0
|
561 |
aTarget.Append(textPointer);
|
sl@0
|
562 |
}
|
sl@0
|
563 |
}
|
sl@0
|
564 |
|
sl@0
|
565 |
|
sl@0
|
566 |
void CPMLWriter::Insert(const TDesC& aBuf)
|
sl@0
|
567 |
// insert aBuf into PML doc
|
sl@0
|
568 |
{
|
sl@0
|
569 |
TUint bufLength = aBuf.Length();
|
sl@0
|
570 |
TBuf8<128> temp;
|
sl@0
|
571 |
SquashBuf(aBuf,temp);
|
sl@0
|
572 |
iTextBuf->InsertL(iInsertPos, temp, bufLength);
|
sl@0
|
573 |
iInsertPos += bufLength;
|
sl@0
|
574 |
}
|
sl@0
|
575 |
|
sl@0
|
576 |
|
sl@0
|
577 |
void CPMLWriter::Delete(TUint aLength)
|
sl@0
|
578 |
// delete back from current insert pos aLength (characters)
|
sl@0
|
579 |
{
|
sl@0
|
580 |
iTextBuf->Delete(iInsertPos-aLength, aLength);
|
sl@0
|
581 |
iInsertPos -= aLength;
|
sl@0
|
582 |
}
|
sl@0
|
583 |
|
sl@0
|
584 |
|
sl@0
|
585 |
void CPMLWriter::Output(RConsole aConsole)
|
sl@0
|
586 |
// output buffer to screen
|
sl@0
|
587 |
{
|
sl@0
|
588 |
TBuf8<1> tempBuf;
|
sl@0
|
589 |
TInt readPos = 0;
|
sl@0
|
590 |
while (readPos < iTextBuf->Size())
|
sl@0
|
591 |
{
|
sl@0
|
592 |
iTextBuf->Read(readPos, tempBuf, 1);
|
sl@0
|
593 |
TBuf<1> wideTemp;
|
sl@0
|
594 |
ExpandBuf(tempBuf,wideTemp);
|
sl@0
|
595 |
aConsole.Write(wideTemp);
|
sl@0
|
596 |
readPos++;
|
sl@0
|
597 |
}
|
sl@0
|
598 |
}
|
sl@0
|
599 |
|
sl@0
|
600 |
|
sl@0
|
601 |
void CPMLWriter::SetTag(TTagType aTagType, TTagStatus aStatus)
|
sl@0
|
602 |
// insert a tag-open or tag-close into the PML doc
|
sl@0
|
603 |
{
|
sl@0
|
604 |
if (aStatus == ETagStart)
|
sl@0
|
605 |
{
|
sl@0
|
606 |
switch (aTagType)
|
sl@0
|
607 |
{
|
sl@0
|
608 |
case EGlobal:
|
sl@0
|
609 |
Insert(_L("\n<G "));
|
sl@0
|
610 |
break;
|
sl@0
|
611 |
case EParagraph:
|
sl@0
|
612 |
Insert(_L("\n<P "));
|
sl@0
|
613 |
break;
|
sl@0
|
614 |
case ECharacter:
|
sl@0
|
615 |
Insert(_L("<C "));
|
sl@0
|
616 |
break;
|
sl@0
|
617 |
case EControl:
|
sl@0
|
618 |
Insert(_L("<X "));
|
sl@0
|
619 |
break;
|
sl@0
|
620 |
}
|
sl@0
|
621 |
}
|
sl@0
|
622 |
if (aStatus == ETagEnd)
|
sl@0
|
623 |
{
|
sl@0
|
624 |
switch (aTagType)
|
sl@0
|
625 |
{
|
sl@0
|
626 |
case EGlobal:
|
sl@0
|
627 |
Insert(_L(">\n"));
|
sl@0
|
628 |
break;
|
sl@0
|
629 |
case EParagraph:
|
sl@0
|
630 |
Insert(_L(">\n"));
|
sl@0
|
631 |
break;
|
sl@0
|
632 |
case ECharacter:
|
sl@0
|
633 |
Insert(_L(">"));
|
sl@0
|
634 |
break;
|
sl@0
|
635 |
case EControl:
|
sl@0
|
636 |
Insert(_L(">"));
|
sl@0
|
637 |
break;
|
sl@0
|
638 |
}
|
sl@0
|
639 |
}
|
sl@0
|
640 |
}
|
sl@0
|
641 |
|
sl@0
|
642 |
|
sl@0
|
643 |
void CPMLWriter::SetTab(TTabStop aTabStop)
|
sl@0
|
644 |
// insert a tab into the PML doc
|
sl@0
|
645 |
{
|
sl@0
|
646 |
TBuf<80> tagBuf;
|
sl@0
|
647 |
tagBuf.Format(_L("Tab=,%d"),aTabStop.iPosition); // put 2nd paramater in first
|
sl@0
|
648 |
switch (aTabStop.iType) // insert 1st paramater after "="
|
sl@0
|
649 |
{
|
sl@0
|
650 |
case ENullTab:
|
sl@0
|
651 |
tagBuf.Insert(4,_L("Null"));
|
sl@0
|
652 |
break;
|
sl@0
|
653 |
case ELeftTab:
|
sl@0
|
654 |
tagBuf.Insert(4,_L("Left"));
|
sl@0
|
655 |
break;
|
sl@0
|
656 |
case ECenteredTab:
|
sl@0
|
657 |
tagBuf.Insert(4,_L("Centered"));
|
sl@0
|
658 |
break;
|
sl@0
|
659 |
case ERightTab:
|
sl@0
|
660 |
tagBuf.Insert(4,_L("Right"));
|
sl@0
|
661 |
break;
|
sl@0
|
662 |
}
|
sl@0
|
663 |
Insert(tagBuf);
|
sl@0
|
664 |
}
|
sl@0
|
665 |
|
sl@0
|
666 |
/* The setFormat functions add the stipulated formatting to the PML doc */
|
sl@0
|
667 |
|
sl@0
|
668 |
void CPMLWriter::SetFormat(TTextFormatAttribute aAttribute, TInt aValue)
|
sl@0
|
669 |
{
|
sl@0
|
670 |
TBuf<80> outputBuf;
|
sl@0
|
671 |
switch (aAttribute)
|
sl@0
|
672 |
{
|
sl@0
|
673 |
// Para Formats
|
sl@0
|
674 |
case EAttParaLanguage:
|
sl@0
|
675 |
outputBuf.Format(_L("ParaLanguage=%d "),aValue);
|
sl@0
|
676 |
Insert(outputBuf);
|
sl@0
|
677 |
break;
|
sl@0
|
678 |
case EAttLeftMargin:
|
sl@0
|
679 |
outputBuf.Format(_L("LeftMargin=%d "),aValue);
|
sl@0
|
680 |
Insert(outputBuf);
|
sl@0
|
681 |
break;
|
sl@0
|
682 |
case EAttRightMargin:
|
sl@0
|
683 |
outputBuf.Format(_L("RightMargin=%d "),aValue);
|
sl@0
|
684 |
Insert(outputBuf);
|
sl@0
|
685 |
break;
|
sl@0
|
686 |
case EAttIndent:
|
sl@0
|
687 |
outputBuf.Format(_L("Indent=%d "),aValue);
|
sl@0
|
688 |
Insert(outputBuf);
|
sl@0
|
689 |
break;
|
sl@0
|
690 |
case EAttAlignment:
|
sl@0
|
691 |
ProcessAlignment(aValue);
|
sl@0
|
692 |
break;
|
sl@0
|
693 |
case EAttLineSpacing:
|
sl@0
|
694 |
outputBuf.Format(_L("LineSpacing=%d "),aValue);
|
sl@0
|
695 |
Insert(outputBuf);
|
sl@0
|
696 |
break;
|
sl@0
|
697 |
case EAttLineSpacingControl:
|
sl@0
|
698 |
ProcessLineSpacingControl(aValue);
|
sl@0
|
699 |
break;
|
sl@0
|
700 |
case EAttSpaceBefore:
|
sl@0
|
701 |
outputBuf.Format(_L("SpaceBefore=%d "),aValue);
|
sl@0
|
702 |
Insert(outputBuf);
|
sl@0
|
703 |
break;
|
sl@0
|
704 |
case EAttSpaceAfter:
|
sl@0
|
705 |
outputBuf.Format(_L("SpaceAfter=%d "),aValue);
|
sl@0
|
706 |
Insert(outputBuf);
|
sl@0
|
707 |
break;
|
sl@0
|
708 |
case EAttKeepTogether:
|
sl@0
|
709 |
ProcessBooleanAtt(aAttribute, aValue);
|
sl@0
|
710 |
break;
|
sl@0
|
711 |
case EAttKeepWithNext:
|
sl@0
|
712 |
ProcessBooleanAtt(aAttribute, aValue);
|
sl@0
|
713 |
break;
|
sl@0
|
714 |
case EAttStartNewPage:
|
sl@0
|
715 |
ProcessBooleanAtt(aAttribute, aValue);
|
sl@0
|
716 |
break;
|
sl@0
|
717 |
case EAttWidowOrphan:
|
sl@0
|
718 |
ProcessBooleanAtt(aAttribute, aValue);
|
sl@0
|
719 |
break;
|
sl@0
|
720 |
case EAttBorderMargin:
|
sl@0
|
721 |
outputBuf.Format(_L("BorderMargin=%d "),aValue);
|
sl@0
|
722 |
Insert(outputBuf);
|
sl@0
|
723 |
break;
|
sl@0
|
724 |
case EAttDefaultTabWidth:
|
sl@0
|
725 |
outputBuf.Format(_L("DefaultTabWidth=%d "),aValue);
|
sl@0
|
726 |
Insert(outputBuf);
|
sl@0
|
727 |
break;
|
sl@0
|
728 |
|
sl@0
|
729 |
// Char formats
|
sl@0
|
730 |
case EAttCharLanguage:
|
sl@0
|
731 |
outputBuf.Format(_L("Language=%d "),aValue);
|
sl@0
|
732 |
Insert(outputBuf);
|
sl@0
|
733 |
break;
|
sl@0
|
734 |
case EAttColor:
|
sl@0
|
735 |
outputBuf.Format(_L("Color=%d "),aValue);
|
sl@0
|
736 |
Insert(outputBuf);
|
sl@0
|
737 |
break;
|
sl@0
|
738 |
case EAttFontHeight:
|
sl@0
|
739 |
outputBuf.Format(_L("FontHeight=%d "),aValue);
|
sl@0
|
740 |
Insert(outputBuf);
|
sl@0
|
741 |
break;
|
sl@0
|
742 |
case EAttFontPosture:
|
sl@0
|
743 |
ProcessBooleanAtt(aAttribute, aValue);
|
sl@0
|
744 |
break;
|
sl@0
|
745 |
case EAttFontStrokeWeight:
|
sl@0
|
746 |
ProcessBooleanAtt(aAttribute, aValue);
|
sl@0
|
747 |
break;
|
sl@0
|
748 |
case EAttFontPrintPos:
|
sl@0
|
749 |
ProcessFontPrintPos(aValue);
|
sl@0
|
750 |
break;
|
sl@0
|
751 |
case EAttFontUnderline:
|
sl@0
|
752 |
ProcessBooleanAtt(aAttribute, aValue);
|
sl@0
|
753 |
break;
|
sl@0
|
754 |
case EAttFontStrikethrough:
|
sl@0
|
755 |
ProcessBooleanAtt(aAttribute, aValue);
|
sl@0
|
756 |
break;
|
sl@0
|
757 |
case EAttFontTypefaceFlags:
|
sl@0
|
758 |
outputBuf.Format(_L("TypefaceFlags=%d "),aValue);
|
sl@0
|
759 |
Insert(outputBuf);
|
sl@0
|
760 |
break;
|
sl@0
|
761 |
}
|
sl@0
|
762 |
}
|
sl@0
|
763 |
|
sl@0
|
764 |
|
sl@0
|
765 |
void CPMLWriter::SetFormat(TTextFormatAttribute aAttribute, const TTypeface &aTypeface)
|
sl@0
|
766 |
{
|
sl@0
|
767 |
TBuf<80> outputBuf;
|
sl@0
|
768 |
switch (aAttribute)
|
sl@0
|
769 |
{
|
sl@0
|
770 |
case EAttFontTypefaceName:
|
sl@0
|
771 |
outputBuf.Format(_L("TypefaceName=%S "),&aTypeface.iName);
|
sl@0
|
772 |
break;
|
sl@0
|
773 |
case EAttFontTypefaceFlags:
|
sl@0
|
774 |
outputBuf.Format(_L("TypefaceFlags=%u "),aTypeface.iFlags);
|
sl@0
|
775 |
break;
|
sl@0
|
776 |
}
|
sl@0
|
777 |
Insert(outputBuf);
|
sl@0
|
778 |
}
|
sl@0
|
779 |
|
sl@0
|
780 |
void CPMLWriter::SetFormat(TTextFormatAttribute aAttribute, TParaBorder* aParaBorder)
|
sl@0
|
781 |
{
|
sl@0
|
782 |
TBuf<80> outputBuf;
|
sl@0
|
783 |
TBuf<80> values;
|
sl@0
|
784 |
values.Format(_L("%d,%d,%d"),aParaBorder->iLineStyle,aParaBorder->iAutoColor,aParaBorder->iColor.RgbToUint());
|
sl@0
|
785 |
outputBuf.Insert(0,values);
|
sl@0
|
786 |
switch (aAttribute)
|
sl@0
|
787 |
{
|
sl@0
|
788 |
case EAttTopBorder:
|
sl@0
|
789 |
outputBuf.Insert(0,_L("TopBorder="));
|
sl@0
|
790 |
break;
|
sl@0
|
791 |
case EAttBottomBorder:
|
sl@0
|
792 |
outputBuf.Insert(0,_L("BottomBorder="));
|
sl@0
|
793 |
break;
|
sl@0
|
794 |
case EAttLeftBorder:
|
sl@0
|
795 |
outputBuf.Insert(0,_L("LeftBorder="));
|
sl@0
|
796 |
break;
|
sl@0
|
797 |
case EAttRightBorder:
|
sl@0
|
798 |
outputBuf.Insert(0,_L("RightBorder="));
|
sl@0
|
799 |
break;
|
sl@0
|
800 |
}
|
sl@0
|
801 |
Insert(outputBuf);
|
sl@0
|
802 |
}
|
sl@0
|
803 |
|
sl@0
|
804 |
|
sl@0
|
805 |
void CPMLWriter::SetFormat(TTextFormatAttribute /*aAttribute*/, TBullet* aBullet)
|
sl@0
|
806 |
{
|
sl@0
|
807 |
TBuf<80> outputBuf;
|
sl@0
|
808 |
outputBuf.Format(_L("%d,%u,%u,"),aBullet->iCharacterCode,aBullet->iHeight,
|
sl@0
|
809 |
aBullet->iTypeface.iFlags);
|
sl@0
|
810 |
TBuf<128> wideTemp; // long enough??
|
sl@0
|
811 |
ExpandBuf(aBullet->iTypeface.iName,wideTemp);
|
sl@0
|
812 |
outputBuf.Append(wideTemp);
|
sl@0
|
813 |
outputBuf.Append(_L(" "));
|
sl@0
|
814 |
outputBuf.Insert(0,_L("Bullet="));
|
sl@0
|
815 |
Insert(outputBuf);
|
sl@0
|
816 |
}
|
sl@0
|
817 |
|
sl@0
|
818 |
|
sl@0
|
819 |
void CPMLWriter::SetFormat(TTextFormatAttribute /*aAttribute*/, TTabStop aTabStop)
|
sl@0
|
820 |
{
|
sl@0
|
821 |
TBuf<80> outputBuf;
|
sl@0
|
822 |
outputBuf.Format(_L("Tabstop=%u,"),aTabStop.iPosition);
|
sl@0
|
823 |
switch (aTabStop.iType)
|
sl@0
|
824 |
{
|
sl@0
|
825 |
case ENullTab:
|
sl@0
|
826 |
outputBuf.Append(_L("Null "));
|
sl@0
|
827 |
break;
|
sl@0
|
828 |
case ELeftTab:
|
sl@0
|
829 |
outputBuf.Append(_L("Left "));
|
sl@0
|
830 |
break;
|
sl@0
|
831 |
case ERightTab:
|
sl@0
|
832 |
outputBuf.Append(_L("Right "));
|
sl@0
|
833 |
break;
|
sl@0
|
834 |
case ECenteredTab:
|
sl@0
|
835 |
outputBuf.Append(_L("Centered "));
|
sl@0
|
836 |
break;
|
sl@0
|
837 |
}
|
sl@0
|
838 |
Insert(outputBuf);
|
sl@0
|
839 |
}
|
sl@0
|
840 |
|
sl@0
|
841 |
|
sl@0
|
842 |
void CPMLWriter::ProcessAlignment(TInt aValue)
|
sl@0
|
843 |
{
|
sl@0
|
844 |
TBuf<80> outputBuf;
|
sl@0
|
845 |
switch (aValue)
|
sl@0
|
846 |
{
|
sl@0
|
847 |
case 0:
|
sl@0
|
848 |
outputBuf.Insert(0,_L("Alignment=Left "));
|
sl@0
|
849 |
break;
|
sl@0
|
850 |
case 1:
|
sl@0
|
851 |
outputBuf.Insert(0,_L("Alignment=Center "));
|
sl@0
|
852 |
break;
|
sl@0
|
853 |
case 2:
|
sl@0
|
854 |
outputBuf.Insert(0,_L("Alignment=Right "));
|
sl@0
|
855 |
break;
|
sl@0
|
856 |
case 3:
|
sl@0
|
857 |
outputBuf.Insert(0,_L("Alignment=Justified "));
|
sl@0
|
858 |
break;
|
sl@0
|
859 |
}
|
sl@0
|
860 |
Insert(outputBuf);
|
sl@0
|
861 |
}
|
sl@0
|
862 |
|
sl@0
|
863 |
|
sl@0
|
864 |
void CPMLWriter::ProcessLineSpacingControl(TInt aValue)
|
sl@0
|
865 |
{
|
sl@0
|
866 |
TBuf<80> outputBuf;
|
sl@0
|
867 |
switch (aValue)
|
sl@0
|
868 |
{
|
sl@0
|
869 |
case 0:
|
sl@0
|
870 |
outputBuf.Insert(0,_L("LineSpacingControl=Atleast "));
|
sl@0
|
871 |
break;
|
sl@0
|
872 |
case 1:
|
sl@0
|
873 |
outputBuf.Insert(0,_L("LineSpacingControl=Exactly "));
|
sl@0
|
874 |
break;
|
sl@0
|
875 |
}
|
sl@0
|
876 |
Insert(outputBuf);
|
sl@0
|
877 |
}
|
sl@0
|
878 |
|
sl@0
|
879 |
|
sl@0
|
880 |
void CPMLWriter::ProcessFontPrintPos(TInt aValue)
|
sl@0
|
881 |
{
|
sl@0
|
882 |
TBuf<80> outputBuf;
|
sl@0
|
883 |
switch (aValue)
|
sl@0
|
884 |
{
|
sl@0
|
885 |
case 0:
|
sl@0
|
886 |
outputBuf.Insert(0,_L("PrintPos=Normal "));
|
sl@0
|
887 |
break;
|
sl@0
|
888 |
case 1:
|
sl@0
|
889 |
outputBuf.Insert(0,_L("PrintPos=SuperScript "));
|
sl@0
|
890 |
break;
|
sl@0
|
891 |
case 2:
|
sl@0
|
892 |
outputBuf.Insert(0,_L("PrintPos=SubScript "));
|
sl@0
|
893 |
break;
|
sl@0
|
894 |
}
|
sl@0
|
895 |
Insert(outputBuf);
|
sl@0
|
896 |
}
|
sl@0
|
897 |
|
sl@0
|
898 |
|
sl@0
|
899 |
void CPMLWriter::ProcessBooleanAtt(TTextFormatAttribute aAttribute, TInt aValue)
|
sl@0
|
900 |
{
|
sl@0
|
901 |
TBuf<80> outputBuf;
|
sl@0
|
902 |
switch (aAttribute)
|
sl@0
|
903 |
{
|
sl@0
|
904 |
case EAttKeepTogether:
|
sl@0
|
905 |
outputBuf.Insert(0,_L("KeepTogether "));
|
sl@0
|
906 |
break;
|
sl@0
|
907 |
case EAttKeepWithNext:
|
sl@0
|
908 |
outputBuf.Insert(0,_L("KeepWithNext "));
|
sl@0
|
909 |
break;
|
sl@0
|
910 |
case EAttStartNewPage:
|
sl@0
|
911 |
outputBuf.Insert(0,_L("StartNewPage "));
|
sl@0
|
912 |
break;
|
sl@0
|
913 |
case EAttWidowOrphan:
|
sl@0
|
914 |
outputBuf.Insert(0,_L("WidowOrphan "));
|
sl@0
|
915 |
break;
|
sl@0
|
916 |
case EAttFontPosture:
|
sl@0
|
917 |
outputBuf.Insert(0,_L("Italic "));
|
sl@0
|
918 |
break;
|
sl@0
|
919 |
case EAttFontStrokeWeight:
|
sl@0
|
920 |
outputBuf.Insert(0,_L("Bold "));
|
sl@0
|
921 |
break;
|
sl@0
|
922 |
case EAttFontUnderline:
|
sl@0
|
923 |
outputBuf.Insert(0,_L("Underline "));
|
sl@0
|
924 |
break;
|
sl@0
|
925 |
case EAttFontStrikethrough:
|
sl@0
|
926 |
outputBuf.Insert(0,_L("Strikethrough "));
|
sl@0
|
927 |
break;
|
sl@0
|
928 |
}
|
sl@0
|
929 |
if (aValue == 0) // Boolean NOT
|
sl@0
|
930 |
outputBuf.Insert(0,_L("!"));
|
sl@0
|
931 |
Insert(outputBuf);
|
sl@0
|
932 |
}
|