|
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 "MHtmlToCrtConvResourceFile.h" |
|
19 #include <chtmltocrtconverter.rsg> |
|
20 |
|
21 const TInt KDefaultFontSizeInTwips = 200; |
|
22 |
|
23 // |
|
24 //Header Tags |
|
25 // |
|
26 void CHtmlToCrtConvActionProcessor::DoHeaderL(CHtmlToCrtConvParser::TTagState aTagState, TInt aFontSizeInTwips) |
|
27 { |
|
28 DoBlockLevelTagActionL(); |
|
29 |
|
30 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
31 { |
|
32 SetFontStrokeWeightL(EStrokeWeightBold); |
|
33 SetFontSizeL(aFontSizeInTwips); |
|
34 } |
|
35 else if (aTagState==CHtmlToCrtConvParser::EClosingTag) |
|
36 { |
|
37 SetFontStrokeWeightL(EStrokeWeightNormal); |
|
38 SetFontSizeL(KDefaultFontSizeInTwips); |
|
39 } |
|
40 } |
|
41 // |
|
42 //EHtmlTagTitle |
|
43 // |
|
44 void CHtmlToCrtConvActionProcessor::DoTitleL(CHtmlToCrtConvParser::TTagState aTagState) |
|
45 { |
|
46 DoHeaderL(aTagState, KH1SizeInTwips); |
|
47 InsertParagraphDelimiterL(); |
|
48 } |
|
49 // |
|
50 //EHtmlAttributeHref and EHtmlAttributeSrc - recognised for EHtmlTagAnchor and EHtmlTagImage |
|
51 // |
|
52 void CHtmlToCrtConvActionProcessor::DoShowUrlL(const TDesC8& aValue, CHtmlToCrtConvParser::TTagState aTagState, THtmlToCrtConvTagType aTagType) |
|
53 { |
|
54 TRgb urlTextColor=KDefaultTextColor; |
|
55 |
|
56 if(aTagType==EHtmlTagAnchor) |
|
57 { |
|
58 urlTextColor=iResourceFile.ReadResourceTRgbLC(R_CNV_COLOUR_ANCHOR_TAG_HREF); |
|
59 } |
|
60 else if(aTagType==EHtmlTagImage) |
|
61 { |
|
62 urlTextColor=iResourceFile.ReadResourceTRgbLC(R_CNV_COLOUR_IMAGE_TAG_SRC); |
|
63 } |
|
64 |
|
65 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
66 { |
|
67 SetFontTextColorL(urlTextColor); |
|
68 |
|
69 _LIT(KSpaceLeftBracket," ("); |
|
70 iText.InsertL(iTextPosition, KSpaceLeftBracket); |
|
71 iTextPosition += 2; |
|
72 |
|
73 HBufC* temp=HBufC::NewLC(aValue.Length()); |
|
74 TPtr pTemp(temp->Des()); |
|
75 pTemp.Copy(aValue); |
|
76 iText.InsertL(iTextPosition, pTemp); |
|
77 CleanupStack::PopAndDestroy(temp); |
|
78 iTextPosition=iText.DocumentLength(); |
|
79 |
|
80 _LIT(KRightBracketSpace,") "); |
|
81 iText.InsertL(iTextPosition, KRightBracketSpace); |
|
82 iTextPosition += 2; |
|
83 |
|
84 SetFontTextColorL(KDefaultTextColor); |
|
85 } |
|
86 } |
|
87 // |
|
88 //EHtmlAttributeAlt - recognised for EHtmlTagImage only |
|
89 // |
|
90 void CHtmlToCrtConvActionProcessor::DoAltL(const TDesC8& aValue, CHtmlToCrtConvParser::TTagState aTagState) |
|
91 { |
|
92 if (aTagState==CHtmlToCrtConvParser::EOpeningTag) |
|
93 { |
|
94 _LIT(KLeftBracket,"<"); |
|
95 iText.InsertL(iTextPosition, KLeftBracket); |
|
96 iTextPosition += 1; |
|
97 |
|
98 HBufC* temp=HBufC::NewLC(aValue.Length()); |
|
99 TPtr pTemp(temp->Des()); |
|
100 pTemp.Copy(aValue); |
|
101 iText.InsertL(iTextPosition, pTemp); |
|
102 CleanupStack::PopAndDestroy(temp); |
|
103 iTextPosition=iText.DocumentLength(); |
|
104 |
|
105 _LIT(KRightBracket,">"); |
|
106 iText.InsertL(iTextPosition, KRightBracket); |
|
107 iTextPosition += 1; |
|
108 } |
|
109 } |
|
110 void CHtmlToCrtConvActionProcessor::InsertImgTagResourceL() |
|
111 { |
|
112 //read image text from the resource file |
|
113 HBufC* resourceText=iResourceFile.ReadResourceHBufCLC(R_CNV_IMAGE_TAG_DEFAULT_TEXT); |
|
114 iText.InsertL(iTextPosition, *resourceText); |
|
115 CleanupStack::PopAndDestroy(resourceText); |
|
116 iTextPosition=iText.DocumentLength(); |
|
117 } |