|
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 #ifndef __CHTMLTOCRTCONVPARSER_H__ |
|
17 #define __CHTMLTOCRTCONVPARSER_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <txtfrmat.h> |
|
21 #include "CHtmlToCrtConvHash.h" |
|
22 |
|
23 class CRichText; |
|
24 class CHtmlToCrtConvBuffer; |
|
25 class CHtmlToCrtConvHashTable; |
|
26 class CHtmlToCrtConvActionProcessor; |
|
27 class MHtmlToCrtConvResourceFile; |
|
28 |
|
29 const TInt KCharsProcessedInOneStep = 100; |
|
30 const TInt KTagBufferLength = 10; |
|
31 const TInt KAttributeBufferLength = 10; |
|
32 const TInt KEntityBufferLength = 10; |
|
33 |
|
34 //======================================================================== |
|
35 |
|
36 class CHtmlToCrtConvAttribute : public CBase |
|
37 { |
|
38 public: |
|
39 static CHtmlToCrtConvAttribute* NewLC(THtmlToCrtConvAttributeType aType, TDesC8& aValue); |
|
40 ~CHtmlToCrtConvAttribute(); |
|
41 |
|
42 inline const THtmlToCrtConvAttributeType Type() const {return iType;} |
|
43 inline const TDesC8& Value() const {return *iValue;} |
|
44 |
|
45 private: |
|
46 CHtmlToCrtConvAttribute(THtmlToCrtConvAttributeType aType); |
|
47 void ConstructL(TDesC8& aValue); |
|
48 |
|
49 private: |
|
50 THtmlToCrtConvAttributeType iType; |
|
51 HBufC8* iValue; |
|
52 }; |
|
53 |
|
54 //========================================================================= |
|
55 |
|
56 class CHtmlToCrtConvParser : public CBase |
|
57 { |
|
58 public: |
|
59 enum TTagState |
|
60 { |
|
61 ENoTag, |
|
62 EOpeningTag, |
|
63 EClosingTag |
|
64 }; |
|
65 |
|
66 public: |
|
67 static CHtmlToCrtConvParser* NewL(CRichText& aRichText, CHtmlToCrtConvBuffer& aBuffer, MHtmlToCrtConvResourceFile& aResourceFile); |
|
68 ~CHtmlToCrtConvParser(); |
|
69 TBool DoOneStepL(); |
|
70 |
|
71 private: |
|
72 CHtmlToCrtConvParser(CHtmlToCrtConvBuffer& aBuffer); |
|
73 void ConstructL(CRichText& aRichText, MHtmlToCrtConvResourceFile& aResourceFile); |
|
74 |
|
75 TBool InspectCurrentCharacter(TChar aChar); |
|
76 void DoActionL(TChar aChar); |
|
77 |
|
78 void SeeWhiteSpaceCharacterInTag(TBool& aBool); |
|
79 void SeeSpecialCharactersInTag(TChar aChar, TBool& aBool); |
|
80 void SeeOtherCharactersInTag(); |
|
81 void SeeOtherCharactersNotInTag(TBool& aBool); |
|
82 |
|
83 void DoTagOperationL(); |
|
84 void DoEntityOperationL(); |
|
85 void WriteToRichTextL(); |
|
86 void WriteToTagBufferL(TChar aChar); |
|
87 void WriteToEntityBufferL(TChar aChar); |
|
88 void WriteToAttributeBufferL(TChar aChar); |
|
89 void WriteToAttributeValueBufferL(TChar aChar); |
|
90 void WriteToAttributeArrayL(); |
|
91 |
|
92 private: |
|
93 enum TParserState |
|
94 { |
|
95 EInitialState, |
|
96 ESeeStartOfTag, |
|
97 ESeeEndOfTag, |
|
98 ESeeClosingTagIndicator, |
|
99 ESeeEquals, |
|
100 ESeeExclamationMark, |
|
101 ESeeEndOfTagWhileReadingJavascript, |
|
102 EReadingOpeningTag, |
|
103 EReadingClosingTag, |
|
104 EReadingAttribute, |
|
105 EReadingAttributeValue, |
|
106 EReadingAttributeValueWithinInvCommas, |
|
107 EReadingText, |
|
108 EReadingJavascript, |
|
109 EFinishedReadingTag, |
|
110 EFinishedReadingAttribute, |
|
111 EFinishedReadingAttributeValue, |
|
112 EStartOfCharacterEntity, |
|
113 EEndOfCharacterEntity, |
|
114 EReadingCharacterEntity |
|
115 }; |
|
116 |
|
117 private: |
|
118 TPtrC16 iTextBuffer; |
|
119 TBuf16<KTagBufferLength> iTagBuffer; |
|
120 TBuf16<KEntityBufferLength> iEntityBuffer; |
|
121 TBuf16<KAttributeBufferLength> iAttributeBuffer; |
|
122 CBufBase* iAttributeValueBuffer; |
|
123 RPointerArray<CHtmlToCrtConvAttribute> iAttributes; |
|
124 TBuf16<2> iLastTwoCharacters; |
|
125 |
|
126 TParserState iParserState; |
|
127 TTagState iTagState; |
|
128 TBool iInTag; |
|
129 TBool iInCharacterEntity; |
|
130 |
|
131 TInt iBufferPosition; |
|
132 TInt iStartOfTextPosition; |
|
133 TInt iEndOfTextPosition; |
|
134 TBool iEndOfBufferReached; |
|
135 |
|
136 CHtmlToCrtConvBuffer& iBuffer; |
|
137 CHtmlToCrtConvHashTable* iHashTable; |
|
138 CHtmlToCrtConvActionProcessor* iActionProcessor; |
|
139 }; |
|
140 |
|
141 #endif |