|
1 // Copyright (c) 2001-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 "CHtmlToCrtConvActionProcessor.h" |
|
17 #include "CHtmlToCrtConvActionProcessorCustom.h" |
|
18 #include "CHtmlToCrtConvHash.h" |
|
19 |
|
20 CHtmlToCrtConvActionProcessor* CHtmlToCrtConvActionProcessor::NewL(CRichText& aRichText, MHtmlToCrtConvResourceFile& aResourceFile) |
|
21 { |
|
22 CHtmlToCrtConvActionProcessor* self=new(ELeave) CHtmlToCrtConvActionProcessor(aRichText, aResourceFile); |
|
23 CleanupStack::PushL(self); |
|
24 self->ConstructL(); |
|
25 CleanupStack::Pop(self); |
|
26 return self; |
|
27 } |
|
28 |
|
29 void CHtmlToCrtConvActionProcessor::ConstructL() |
|
30 { |
|
31 iParaFormat=new(ELeave) CParaFormat; |
|
32 } |
|
33 |
|
34 CHtmlToCrtConvActionProcessor::CHtmlToCrtConvActionProcessor(CRichText& aRichText, MHtmlToCrtConvResourceFile& aResourceFile) |
|
35 :iText(aRichText) |
|
36 ,iResourceFile(aResourceFile) |
|
37 { |
|
38 } |
|
39 |
|
40 CHtmlToCrtConvActionProcessor::~CHtmlToCrtConvActionProcessor() |
|
41 { |
|
42 delete iParaFormat; |
|
43 } |
|
44 |
|
45 //========================================================================== |
|
46 //utility functions |
|
47 //========================================================================== |
|
48 void CHtmlToCrtConvActionProcessor::DoBlockLevelTagActionL() |
|
49 { |
|
50 InsertParagraphDelimiterL(); |
|
51 ApplyAlignmentL(); |
|
52 } |
|
53 |
|
54 void CHtmlToCrtConvActionProcessor::ApplyAlignmentL() |
|
55 { |
|
56 if (IsFlagSet(EAlignAttribPending)) |
|
57 { |
|
58 iText.ApplyParaFormatL(iParaFormat, iParaFormatMask, iAlignmentStartPosition, (iTextPosition-iAlignmentStartPosition)); |
|
59 iParaFormatMask.ClearAttrib(EAttAlignment); |
|
60 ClearFlag(EAlignAttribPending); |
|
61 } |
|
62 } |
|
63 void CHtmlToCrtConvActionProcessor::InsertParagraphDelimiterL() |
|
64 { |
|
65 if(iTextPosition>1) |
|
66 { |
|
67 //get last 2 significant characters from the richtext object, ie ignore white space characters except for paragraph delimiter |
|
68 TBuf<2> lastTwoCharacters; |
|
69 TInt richTextPosition=iTextPosition-1;//position of last character in rich text |
|
70 |
|
71 while(lastTwoCharacters.Length()<2 && richTextPosition>=0) |
|
72 { |
|
73 //get character at position richTextPosition from rich text |
|
74 TPtrC ptrCurrentCharacter=iText.Read(richTextPosition--, 1); |
|
75 TChar currentCharacter=(ptrCurrentCharacter)[0]; |
|
76 |
|
77 if(!(currentCharacter.IsSpace() && currentCharacter!=CEditableText::EParagraphDelimiter)) |
|
78 { |
|
79 lastTwoCharacters.Append(currentCharacter); |
|
80 } |
|
81 } |
|
82 |
|
83 TBuf<2> twoParagraphDelimiters; |
|
84 twoParagraphDelimiters.Append(CEditableText::EParagraphDelimiter); |
|
85 twoParagraphDelimiters.Append(CEditableText::EParagraphDelimiter); |
|
86 if(lastTwoCharacters.Compare(twoParagraphDelimiters)) |
|
87 { |
|
88 iText.InsertL(iTextPosition, CEditableText::EParagraphDelimiter); |
|
89 iTextPosition+=1; |
|
90 } |
|
91 } |
|
92 else |
|
93 { |
|
94 iText.InsertL(iTextPosition, CEditableText::EParagraphDelimiter); |
|
95 iTextPosition+=1; |
|
96 } |
|
97 } |
|
98 //========================================================================== |
|
99 //DoWriteTextL |
|
100 //========================================================================== |
|
101 void CHtmlToCrtConvActionProcessor::DoWriteTextL(const TDesC16& aText) |
|
102 { |
|
103 if (!IsFlagSet(EIgnoreText)) |
|
104 { |
|
105 HBufC* temp=HBufC::NewLC(aText.Length()); |
|
106 TPtr tempPtr(temp->Des()); |
|
107 tempPtr.Copy(aText); |
|
108 |
|
109 //trim buffer, leaving one space at start and end of the buffer |
|
110 TrimBufferL(tempPtr); |
|
111 |
|
112 iText.InsertL(iTextPosition, *temp); |
|
113 CleanupStack::PopAndDestroy(temp); |
|
114 iTextPosition=iText.DocumentLength(); |
|
115 |
|
116 //CancelInsertCharFormat cancels the "insert pending" state set by a call to SetInsertCharFormatL() or DelSetInsertCharFormatL(). |
|
117 //This removes the restriction on the text insertion position, and has no effect if not applicable. |
|
118 iText.CancelInsertCharFormat(); |
|
119 } |
|
120 } |
|
121 //========================================================================== |
|
122 //TrimBufferL |
|
123 //========================================================================== |
|
124 void CHtmlToCrtConvActionProcessor::TrimBufferL(TPtr& aPtr) |
|
125 { |
|
126 TInt len=aPtr.Length(); |
|
127 if (!len) |
|
128 return; |
|
129 |
|
130 // Current document length - required so that we don't insert |
|
131 // any spaces until we come across a first run of text. |
|
132 const TInt documentLength=iText.DocumentLength(); |
|
133 //check if first and last characters are white space characters |
|
134 TBool spaceAtStart=EFalse; |
|
135 TBool spaceAtEnd=EFalse; |
|
136 |
|
137 TChar left=(aPtr)[0]; |
|
138 TChar right=(aPtr)[len-1]; |
|
139 if(documentLength>0 && left.IsSpace()) |
|
140 { |
|
141 spaceAtStart=ETrue; |
|
142 //if length is 1 we are seeing the same space twice, |
|
143 //if length is 2 then only one space is required |
|
144 if(len>2 && right.IsSpace()) |
|
145 { |
|
146 spaceAtEnd=ETrue; |
|
147 } |
|
148 } |
|
149 else if(right.IsSpace()) |
|
150 { |
|
151 spaceAtEnd=ETrue; |
|
152 } |
|
153 |
|
154 //remove leading and trailing space characters, and replace each contiguous set of space characters by one space character |
|
155 aPtr.TrimAll(); |
|
156 |
|
157 //add space character at start/end of buffer, if required |
|
158 _LIT(KSpace, " "); |
|
159 if(spaceAtStart) |
|
160 { |
|
161 aPtr.Insert(0, KSpace); |
|
162 } |
|
163 if(spaceAtEnd) |
|
164 { |
|
165 aPtr.Append(KSpace); |
|
166 } |
|
167 |
|
168 // Convert any remaining carriage returns or line feeds to spaces |
|
169 const TText KSpaceCharacter=0x20; |
|
170 const TText KCarriageReturn=0x0d; |
|
171 const TText KLineFeed=0x0a; |
|
172 |
|
173 TText* pText=const_cast<TText*>(aPtr.Ptr()); |
|
174 for(TInt ii=0; ii<len; ii++) |
|
175 { |
|
176 if (pText[ii]==KCarriageReturn || pText[ii]==KLineFeed) |
|
177 pText[ii]=KSpaceCharacter; |
|
178 } |
|
179 } |
|
180 //========================================================================== |
|
181 //SetFontStrokeWeightL |
|
182 //========================================================================== |
|
183 void CHtmlToCrtConvActionProcessor::SetFontStrokeWeightL(TFontStrokeWeight aStrokeWeight) |
|
184 { |
|
185 if(!(iCharFormat.iFontSpec.iFontStyle.StrokeWeight()==aStrokeWeight)) |
|
186 { |
|
187 iCharFormatMask.SetAttrib(EAttFontStrokeWeight); |
|
188 iCharFormat.iFontSpec.iFontStyle.SetStrokeWeight(aStrokeWeight); |
|
189 iText.SetInsertCharFormatL(iCharFormat, iCharFormatMask, iTextPosition); |
|
190 } |
|
191 } |
|
192 //========================================================================== |
|
193 //SetFontPostureL |
|
194 //========================================================================== |
|
195 void CHtmlToCrtConvActionProcessor::SetFontPostureL(TFontPosture aFontPosture) |
|
196 { |
|
197 if(!(iCharFormat.iFontSpec.iFontStyle.Posture()==aFontPosture)) |
|
198 { |
|
199 iCharFormatMask.SetAttrib(EAttFontPosture); |
|
200 iCharFormat.iFontSpec.iFontStyle.SetPosture(aFontPosture); |
|
201 iText.SetInsertCharFormatL(iCharFormat, iCharFormatMask, iTextPosition); |
|
202 } |
|
203 } |
|
204 //========================================================================== |
|
205 //SetFontUnderlineL |
|
206 //========================================================================== |
|
207 void CHtmlToCrtConvActionProcessor::SetFontUnderlineL(TFontUnderline aFontUnderline) |
|
208 { |
|
209 if(!(iCharFormat.iFontPresentation.iUnderline==aFontUnderline)) |
|
210 { |
|
211 iCharFormatMask.SetAttrib(EAttFontUnderline); |
|
212 iCharFormat.iFontPresentation.iUnderline=aFontUnderline; |
|
213 iText.SetInsertCharFormatL(iCharFormat, iCharFormatMask, iTextPosition); |
|
214 } |
|
215 } |
|
216 //========================================================================== |
|
217 //SetFontPrintPositionL |
|
218 //========================================================================== |
|
219 void CHtmlToCrtConvActionProcessor::SetFontPrintPositionL(TFontPrintPosition aFontPrintPosition) |
|
220 { |
|
221 if(!(iCharFormat.iFontSpec.iFontStyle.PrintPosition()==aFontPrintPosition)) |
|
222 { |
|
223 iCharFormatMask.SetAttrib(EAttFontPrintPos); |
|
224 iCharFormat.iFontSpec.iFontStyle.SetPrintPosition(aFontPrintPosition); |
|
225 iText.SetInsertCharFormatL(iCharFormat, iCharFormatMask, iTextPosition); |
|
226 } |
|
227 } |
|
228 //========================================================================== |
|
229 //SetFontStrikethroughL |
|
230 //========================================================================== |
|
231 void CHtmlToCrtConvActionProcessor::SetFontStrikethroughL(TFontStrikethrough aFontStrikethrough) |
|
232 { |
|
233 if(!(iCharFormat.iFontPresentation.iStrikethrough==aFontStrikethrough)) |
|
234 { |
|
235 iCharFormatMask.SetAttrib(EAttFontStrikethrough); |
|
236 iCharFormat.iFontPresentation.iStrikethrough=aFontStrikethrough; |
|
237 iText.SetInsertCharFormatL(iCharFormat, iCharFormatMask, iTextPosition); |
|
238 } |
|
239 } |
|
240 //========================================================================== |
|
241 //SetFontTextColorL |
|
242 //========================================================================== |
|
243 void CHtmlToCrtConvActionProcessor::SetFontTextColorL(const TRgb& aFontTextColor) |
|
244 { |
|
245 if(!(iCharFormat.iFontPresentation.iTextColor==aFontTextColor)) |
|
246 { |
|
247 iCharFormatMask.SetAttrib(EAttColor); |
|
248 iCharFormat.iFontPresentation.iTextColor=aFontTextColor; |
|
249 iText.SetInsertCharFormatL(iCharFormat, iCharFormatMask, iTextPosition); |
|
250 } |
|
251 } |
|
252 //========================================================================== |
|
253 //SetFontSizeL |
|
254 //========================================================================== |
|
255 void CHtmlToCrtConvActionProcessor::SetFontSizeL(TInt aFontSizeInTwips) |
|
256 { |
|
257 if(!(iCharFormat.iFontSpec.iHeight==aFontSizeInTwips)) |
|
258 { |
|
259 iCharFormatMask.SetAttrib(EAttFontHeight); |
|
260 iCharFormat.iFontSpec.iHeight=aFontSizeInTwips; |
|
261 iText.SetInsertCharFormatL(iCharFormat, iCharFormatMask, iTextPosition); |
|
262 } |
|
263 } |
|
264 //========================================================================== |
|
265 //DoTagActionL |
|
266 //========================================================================== |
|
267 |
|
268 void CHtmlToCrtConvActionProcessor::DoTagActionL(THtmlToCrtConvTagType aTagType, CHtmlToCrtConvParser::TTagState aTagState) |
|
269 { |
|
270 ASSERT(aTagState!=CHtmlToCrtConvParser::ENoTag); |
|
271 |
|
272 switch(aTagType) |
|
273 { |
|
274 //BLOCK LEVEL ELEMENTS |
|
275 case EHtmlTagH1: |
|
276 DoHeaderL(aTagState, KH1SizeInTwips); |
|
277 break; |
|
278 case EHtmlTagH2: |
|
279 DoHeaderL(aTagState, KH2SizeInTwips); |
|
280 break; |
|
281 case EHtmlTagH3: |
|
282 DoHeaderL(aTagState, KH3SizeInTwips); |
|
283 break; |
|
284 case EHtmlTagH4: |
|
285 DoHeaderL(aTagState, KH4SizeInTwips); |
|
286 break; |
|
287 case EHtmlTagH5: |
|
288 DoHeaderL(aTagState, KH5SizeInTwips); |
|
289 break; |
|
290 case EHtmlTagH6: |
|
291 DoHeaderL(aTagState, KH6SizeInTwips); |
|
292 break; |
|
293 case EHtmlTagCenter: |
|
294 DoCenterL(aTagState); |
|
295 break; |
|
296 case EHtmlTagBlockquote: |
|
297 DoBlockquoteL(aTagState); |
|
298 break; |
|
299 case EHtmlTagForm: |
|
300 DoFormL(aTagState); |
|
301 break; |
|
302 case EHtmlTagUnorderedList: |
|
303 DoUnorderedListL(aTagState); |
|
304 break; |
|
305 case EHtmlTagOrderedList: |
|
306 DoUnorderedListL(aTagState); |
|
307 break; |
|
308 case EHtmlTagDefinitionList: |
|
309 DoUnorderedListL(aTagState); |
|
310 break; |
|
311 case EHtmlTagParagraph: |
|
312 DoParagraphL(); |
|
313 break; |
|
314 case EHtmlTagTable: |
|
315 DoTableL(); |
|
316 break; |
|
317 case EHtmlTagDivision: |
|
318 DoDivisionL(); |
|
319 break; |
|
320 case EHtmlTagPreformatted: |
|
321 DoPreformattedL(); |
|
322 break; |
|
323 case EHtmlTagHorizontalRule: |
|
324 DoHorizontalRuleL(); |
|
325 break; |
|
326 case EHtmlTagHtml: |
|
327 DoHtmlL(aTagState); |
|
328 break; |
|
329 //TEXT LEVEL ELEMENTS |
|
330 case EHtmlTagTitle: |
|
331 DoTitleL(aTagState); |
|
332 break; |
|
333 case EHtmlTagItalic: |
|
334 DoItalicL(aTagState); |
|
335 break; |
|
336 case EHtmlTagBold: |
|
337 DoBoldL(aTagState); |
|
338 break; |
|
339 case EHtmlTagUnderline: |
|
340 DoUnderlineL(aTagState); |
|
341 break; |
|
342 case EHtmlTagEmphasis: |
|
343 DoItalicL(aTagState); |
|
344 break; |
|
345 case EHtmlTagStrong: |
|
346 DoBoldL(aTagState); |
|
347 break; |
|
348 case EHtmlTagDefinition: |
|
349 DoItalicL(aTagState); |
|
350 break; |
|
351 case EHtmlTagVariable: |
|
352 DoItalicL(aTagState); |
|
353 break; |
|
354 case EHtmlTagCitation: |
|
355 DoItalicL(aTagState); |
|
356 break; |
|
357 case EHtmlTagSubscript: |
|
358 DoSubscriptL(aTagState); |
|
359 break; |
|
360 case EHtmlTagSuperscript: |
|
361 DoSuperscriptL(aTagState); |
|
362 break; |
|
363 case EHtmlTagStrikethrough: |
|
364 DoStrikethroughL(aTagState); |
|
365 break; |
|
366 case EHtmlTagBreak: |
|
367 DoBreakL(aTagState); |
|
368 break; |
|
369 case EHtmlTagCaption: |
|
370 DoCaptionL(aTagState); |
|
371 break; |
|
372 case EHtmlTagTableData: |
|
373 DoTableDataL(aTagState); |
|
374 break; |
|
375 case EHtmlTagTableHeader: |
|
376 DoTableDataL(aTagState); |
|
377 break; |
|
378 case EHtmlTagListItem: |
|
379 DoListItemL(aTagState); |
|
380 break; |
|
381 case EHtmlTagDefinitionTerm: |
|
382 DoListItemL(aTagState); |
|
383 break; |
|
384 case EHtmlTagDefinitionDefinition: |
|
385 DoListItemL(aTagState); |
|
386 break; |
|
387 default: |
|
388 break; |
|
389 } |
|
390 } |
|
391 |
|
392 //================================================= |
|
393 //DoAttributeActionL |
|
394 //================================================= |
|
395 |
|
396 void CHtmlToCrtConvActionProcessor::DoAttributeActionL(THtmlToCrtConvTagType aTagType, CHtmlToCrtConvParser::TTagState aTagState, const THtmlToCrtConvAttributeType& aType, const TDesC8& aValue, TBool& aImgTagResourceReqd) |
|
397 { |
|
398 switch(aType) |
|
399 { |
|
400 case EHtmlAttributeAlign: |
|
401 DoAlignL(aValue, aTagState); |
|
402 break; |
|
403 case EHtmlAttributeHref: |
|
404 if (aTagType==EHtmlTagAnchor) |
|
405 { |
|
406 DoShowUrlL(aValue, aTagState, aTagType); |
|
407 } |
|
408 break; |
|
409 case EHtmlAttributeSrc: |
|
410 if (aTagType==EHtmlTagImage) |
|
411 { |
|
412 DoShowUrlL(aValue, aTagState, aTagType); |
|
413 if(IsFlagSet(ESeenAltAttribute)) |
|
414 { |
|
415 aImgTagResourceReqd=EFalse; |
|
416 ClearFlag(ESeenAltAttribute); |
|
417 } |
|
418 else |
|
419 aImgTagResourceReqd=ETrue; |
|
420 } |
|
421 break; |
|
422 case EHtmlAttributeAlt: |
|
423 if (aTagType==EHtmlTagImage) |
|
424 { |
|
425 DoAltL(aValue, aTagState); |
|
426 aImgTagResourceReqd=EFalse; |
|
427 SetFlag(ESeenAltAttribute); |
|
428 } |
|
429 break; |
|
430 default: |
|
431 break; |
|
432 } |
|
433 } |
|
434 |
|
435 //======================================================================= |
|
436 //======================================================================= |
|
437 // TAGS - implementation of |
|
438 // |
|
439 // DoHeaderL, DoTitleL, DoShowUrlL, DoAltL |
|
440 // |
|
441 // in CHtmlToCrtConvActionProcessorCustom.cpp |
|
442 //======================================================================= |
|
443 // |
|
444 //EHtmlTagCenter |
|
445 // |
|
446 void CHtmlToCrtConvActionProcessor::DoCenterL(CHtmlToCrtConvParser::TTagState aTagState) |
|
447 { |
|
448 DoBlockLevelTagActionL(); |
|
449 |
|
450 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
451 { |
|
452 iParaFormatMask.SetAttrib(EAttAlignment); |
|
453 iParaFormat->iHorizontalAlignment=CParaFormat::ECenterAlign; |
|
454 iAlignmentStartPosition=iTextPosition; |
|
455 SetFlag(EAlignAttribPending); |
|
456 } |
|
457 } |
|
458 // |
|
459 //EHtmlTagBlockquote |
|
460 // |
|
461 void CHtmlToCrtConvActionProcessor::DoBlockquoteL(CHtmlToCrtConvParser::TTagState aTagState) |
|
462 { |
|
463 DoBlockLevelTagActionL(); |
|
464 |
|
465 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
466 { |
|
467 iParaFormatMask.SetAttrib(EAttLeftMargin); |
|
468 iParaFormat->iLeftMarginInTwips=KBlockquoteIndentSizeInTwips; |
|
469 iBlockquoteStartPosition=iTextPosition; |
|
470 SetFlag(EBlockquotePending); |
|
471 } |
|
472 else if (aTagState==CHtmlToCrtConvParser::EClosingTag && IsFlagSet(EBlockquotePending)) |
|
473 { |
|
474 iText.ApplyParaFormatL(iParaFormat, iParaFormatMask, iBlockquoteStartPosition, (iTextPosition-iBlockquoteStartPosition)); |
|
475 iParaFormatMask.ClearAttrib(EAttLeftMargin); |
|
476 ClearFlag(EBlockquotePending); |
|
477 } |
|
478 } |
|
479 // |
|
480 //EHtmlTagForm |
|
481 // |
|
482 void CHtmlToCrtConvActionProcessor::DoFormL(CHtmlToCrtConvParser::TTagState aTagState) |
|
483 { |
|
484 DoBlockLevelTagActionL(); |
|
485 |
|
486 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
487 { |
|
488 SetFlag(EIgnoreText); |
|
489 } |
|
490 else if (aTagState==CHtmlToCrtConvParser::EClosingTag) |
|
491 { |
|
492 ClearFlag(EIgnoreText); |
|
493 } |
|
494 } |
|
495 // |
|
496 //EHtmlTagUnorderedList |
|
497 // |
|
498 void CHtmlToCrtConvActionProcessor::DoUnorderedListL(CHtmlToCrtConvParser::TTagState aTagState) |
|
499 { |
|
500 DoBlockLevelTagActionL(); |
|
501 |
|
502 if (aTagState==CHtmlToCrtConvParser::EClosingTag && IsFlagSet(EListPending)) |
|
503 { |
|
504 iText.ApplyParaFormatL(iParaFormat, iParaFormatMask, iListStartPosition, (iTextPosition-iListStartPosition)); |
|
505 iParaFormatMask.ClearAttrib(EAttBullet); |
|
506 ClearFlag(EListPending); |
|
507 } |
|
508 } |
|
509 // |
|
510 //EHtmlTagParagraph |
|
511 // |
|
512 void CHtmlToCrtConvActionProcessor::DoParagraphL() |
|
513 { |
|
514 DoBlockLevelTagActionL(); |
|
515 } |
|
516 // |
|
517 //EHtmlTagTable |
|
518 // |
|
519 void CHtmlToCrtConvActionProcessor::DoTableL() |
|
520 { |
|
521 DoBlockLevelTagActionL(); |
|
522 } |
|
523 // |
|
524 //EHtmlTagDivision |
|
525 // |
|
526 void CHtmlToCrtConvActionProcessor::DoDivisionL() |
|
527 { |
|
528 DoBlockLevelTagActionL(); |
|
529 } |
|
530 // |
|
531 //EHtmlTagPreformatted |
|
532 // |
|
533 void CHtmlToCrtConvActionProcessor::DoPreformattedL() |
|
534 { |
|
535 DoBlockLevelTagActionL(); |
|
536 } |
|
537 // |
|
538 //EHtmlTagHorizontalRule |
|
539 // |
|
540 void CHtmlToCrtConvActionProcessor::DoHorizontalRuleL() |
|
541 { |
|
542 DoBlockLevelTagActionL(); |
|
543 } |
|
544 // |
|
545 //EHtmlTagHtml - actions any outstanding formatting at the end of the file |
|
546 // |
|
547 void CHtmlToCrtConvActionProcessor::DoHtmlL(CHtmlToCrtConvParser::TTagState aTagState) |
|
548 { |
|
549 if (aTagState==CHtmlToCrtConvParser::EClosingTag && IsFlagSet(EAlignAttribPending)) |
|
550 { |
|
551 DoBlockLevelTagActionL(); |
|
552 } |
|
553 } |
|
554 // |
|
555 //EHtmlTagItalic |
|
556 // |
|
557 void CHtmlToCrtConvActionProcessor::DoItalicL(CHtmlToCrtConvParser::TTagState aTagState) |
|
558 { |
|
559 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
560 { |
|
561 SetFontPostureL(EPostureItalic); |
|
562 } |
|
563 else if (aTagState==CHtmlToCrtConvParser::EClosingTag) |
|
564 { |
|
565 SetFontPostureL(EPostureUpright); |
|
566 } |
|
567 } |
|
568 // |
|
569 //EHtmlTagBold |
|
570 // |
|
571 void CHtmlToCrtConvActionProcessor::DoBoldL(CHtmlToCrtConvParser::TTagState aTagState) |
|
572 { |
|
573 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
574 { |
|
575 SetFontStrokeWeightL(EStrokeWeightBold); |
|
576 } |
|
577 else if (aTagState==CHtmlToCrtConvParser::EClosingTag) |
|
578 { |
|
579 SetFontStrokeWeightL(EStrokeWeightNormal); |
|
580 } |
|
581 } |
|
582 // |
|
583 //EHtmlTagUnderline |
|
584 // |
|
585 void CHtmlToCrtConvActionProcessor::DoUnderlineL(CHtmlToCrtConvParser::TTagState aTagState) |
|
586 { |
|
587 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
588 { |
|
589 SetFontUnderlineL(EUnderlineOn); |
|
590 } |
|
591 else if (aTagState==CHtmlToCrtConvParser::EClosingTag) |
|
592 { |
|
593 SetFontUnderlineL(EUnderlineOff); |
|
594 } |
|
595 } |
|
596 // |
|
597 //EHtmlTagSubscript |
|
598 // |
|
599 void CHtmlToCrtConvActionProcessor::DoSubscriptL(CHtmlToCrtConvParser::TTagState aTagState) |
|
600 { |
|
601 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
602 { |
|
603 SetFontPrintPositionL(EPrintPosSubscript); |
|
604 } |
|
605 else if (aTagState==CHtmlToCrtConvParser::EClosingTag) |
|
606 { |
|
607 SetFontPrintPositionL(EPrintPosNormal); |
|
608 } |
|
609 } |
|
610 // |
|
611 //EHtmlTagSuperscript |
|
612 // |
|
613 void CHtmlToCrtConvActionProcessor::DoSuperscriptL(CHtmlToCrtConvParser::TTagState aTagState) |
|
614 { |
|
615 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
616 { |
|
617 SetFontPrintPositionL(EPrintPosSuperscript); |
|
618 } |
|
619 else if (aTagState==CHtmlToCrtConvParser::EClosingTag) |
|
620 { |
|
621 SetFontPrintPositionL(EPrintPosNormal); |
|
622 } |
|
623 } |
|
624 // |
|
625 //EHtmlTagStrikethrough |
|
626 // |
|
627 void CHtmlToCrtConvActionProcessor::DoStrikethroughL(CHtmlToCrtConvParser::TTagState aTagState) |
|
628 { |
|
629 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
630 { |
|
631 SetFontStrikethroughL(EStrikethroughOn); |
|
632 } |
|
633 else if (aTagState==CHtmlToCrtConvParser::EClosingTag) |
|
634 { |
|
635 SetFontStrikethroughL(EStrikethroughOff); |
|
636 } |
|
637 } |
|
638 // |
|
639 //EHtmlTagBreak |
|
640 // |
|
641 void CHtmlToCrtConvActionProcessor::DoBreakL(CHtmlToCrtConvParser::TTagState aTagState) |
|
642 { |
|
643 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
644 { |
|
645 iText.InsertL(iTextPosition, CEditableText::ELineBreak); |
|
646 iTextPosition += 1; |
|
647 } |
|
648 } |
|
649 // |
|
650 //EHtmlTagCaption |
|
651 // |
|
652 void CHtmlToCrtConvActionProcessor::DoCaptionL(CHtmlToCrtConvParser::TTagState aTagState) |
|
653 { |
|
654 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
655 InsertParagraphDelimiterL(); |
|
656 } |
|
657 // |
|
658 //EHtmlTagTableData |
|
659 // |
|
660 void CHtmlToCrtConvActionProcessor::DoTableDataL(CHtmlToCrtConvParser::TTagState aTagState) |
|
661 { |
|
662 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
663 InsertParagraphDelimiterL(); |
|
664 } |
|
665 // |
|
666 //EHtmlTagListItem |
|
667 // |
|
668 void CHtmlToCrtConvActionProcessor::DoListItemL(CHtmlToCrtConvParser::TTagState aTagState) |
|
669 { |
|
670 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
671 { |
|
672 InsertParagraphDelimiterL(); |
|
673 |
|
674 if (!IsFlagSet(EListPending)) |
|
675 { |
|
676 iParaFormatMask.SetAttrib(EAttBullet); |
|
677 if (!(iParaFormat->iBullet)) |
|
678 { |
|
679 TBullet* bullet=new(ELeave) TBullet; |
|
680 bullet->iCharacterCode=KBulletCharacterCode; |
|
681 bullet->iHeightInTwips=KBulletHeightInTwips; |
|
682 iParaFormat->iBullet=bullet; |
|
683 } |
|
684 iListStartPosition=iTextPosition; |
|
685 SetFlag(EListPending); |
|
686 } |
|
687 } |
|
688 } |
|
689 |
|
690 //================================================================================= |
|
691 // ATTRIBUTES |
|
692 //================================================================================= |
|
693 // |
|
694 //EHtmlAttributeAlign |
|
695 // |
|
696 void CHtmlToCrtConvActionProcessor::DoAlignL(const TDesC8& aValue, CHtmlToCrtConvParser::TTagState aTagState) |
|
697 { |
|
698 _LIT8(KCenter,"CENTER"); |
|
699 _LIT8(KRight,"RIGHT"); |
|
700 |
|
701 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
702 { |
|
703 if (!(aValue.CompareF(KCenter))) |
|
704 { |
|
705 iParaFormatMask.SetAttrib(EAttAlignment); |
|
706 iParaFormat->iHorizontalAlignment=CParaFormat::ECenterAlign; |
|
707 iAlignmentStartPosition=iTextPosition; |
|
708 SetFlag(EAlignAttribPending); |
|
709 } |
|
710 else if (!(aValue.CompareF(KRight))) |
|
711 { |
|
712 iParaFormatMask.SetAttrib(EAttAlignment); |
|
713 iParaFormat->iHorizontalAlignment=CParaFormat::ERightAlign; |
|
714 iAlignmentStartPosition=iTextPosition; |
|
715 SetFlag(EAlignAttribPending); |
|
716 } |
|
717 } |
|
718 } |