|
1 /* |
|
2 * Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __PARSELST_H__ |
|
20 #define __PARSELST_H__ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <mparser.h> |
|
24 #include <txtrich.h> |
|
25 //++ sort out definitive hash includes |
|
26 |
|
27 |
|
28 NONSHARABLE_CLASS(CParserList) : public CBase |
|
29 /** |
|
30 @internalComponent |
|
31 */ |
|
32 { |
|
33 enum TParserTagValues |
|
34 { |
|
35 EReformatOnRecogniseFlag = (TInt)0x80000000, |
|
36 EReformatOnRolloverFlag = 0x40000000, |
|
37 EDefaultParserFlag = 0x20000000, |
|
38 EParserTagMask = 0x3FFFFFFF, |
|
39 EMaxParserIndex = 0x1FFFFFFF |
|
40 }; |
|
41 |
|
42 enum TParserListPanic |
|
43 { |
|
44 EParserNoneActive, |
|
45 EParserNullPtr, |
|
46 EParserInstanceNotActive, |
|
47 EParserNoSuchTag, |
|
48 EParserIgnoringAllowFlag, |
|
49 EParserIndexRollover |
|
50 }; |
|
51 |
|
52 private: |
|
53 class CParserItem : public CBase |
|
54 { |
|
55 public: |
|
56 CParserItem(MParser* aParser, const TUint aTagIndex); |
|
57 ~CParserItem() {} |
|
58 |
|
59 inline MParser* Parser() const {return iParser;} |
|
60 inline TUint TagIndex() const {return iTagIndex;} |
|
61 |
|
62 private: |
|
63 MParser* iParser; |
|
64 TUint iTagIndex; |
|
65 }; |
|
66 |
|
67 public: |
|
68 CParserList(); |
|
69 ~CParserList(); |
|
70 |
|
71 void ActivateParserL(MParser* aParser); |
|
72 void DeactivateParser(MParser* aParser); |
|
73 void ActivateDefaultParserL(MParser* aParser); |
|
74 void DeactivateParserDefaults(); |
|
75 TBool ParseThisText(CRichText& aTextObj,TInt aStartScan,TInt aScanLength,TInt& aStartOfTags,TInt& aLength); |
|
76 MParser* ParserWithThisTag(const TUint aTagIndex) const; |
|
77 TUint TagForThisParser(const MParser *const aParser) const; |
|
78 |
|
79 static inline TBool ReformatOnRollover(const TUint aTagIndex) {return (aTagIndex & EReformatOnRolloverFlag);} |
|
80 |
|
81 private: |
|
82 static inline TBool ReformatOnRecognise(const TUint aTagIndex) {return (aTagIndex & static_cast<TUint>( EReformatOnRecogniseFlag ) );} |
|
83 static inline TBool DefaultParser(const TUint aTagIndex) {return (aTagIndex & EDefaultParserFlag);} |
|
84 |
|
85 static inline TUint MaskedTag(const TUint32 aTagIndex) {return (aTagIndex & EParserTagMask);} |
|
86 |
|
87 void ActivateAParserL(MParser* aParser, const TBool aDefaultParser); |
|
88 TBool LoopOneParser(MParser* aParser, const TUint aTagIndex, CRichText& aTextObj, |
|
89 const TInt aStartScan, const TInt aScanLength, |
|
90 TInt& aStartOfTags, TInt& aLength); |
|
91 void Panic(TParserListPanic aPanic) const; |
|
92 |
|
93 private: |
|
94 RPointerArray<CParserItem> iParserList; // List of active parsers (specific and default) |
|
95 TUint iHighestIndex; |
|
96 public: |
|
97 TInt iNumberInList; |
|
98 TInt iRefCount; |
|
99 }; |
|
100 |
|
101 NONSHARABLE_CLASS(CParserData) : public CBase |
|
102 /** |
|
103 @internalComponent |
|
104 */ |
|
105 { |
|
106 public: |
|
107 CParserData(TInt aEndParse); |
|
108 ~CParserData(); |
|
109 TBool HaveRange() const { return iStartParse != -1; } |
|
110 void MergeRange(TInt aStart,TInt aOldLength,TInt aNewLength); |
|
111 void KillRange() { iStartParse = -1; } |
|
112 TInt StartParse() const { return iStartParse; } |
|
113 TInt EndParse() const { return iEndParse; } |
|
114 |
|
115 CParserList* iActiveParserList; // local copy because access to Dll::Tls is slow |
|
116 MEditObserver* iEditObserver; |
|
117 TInt iLastKnownCursor; |
|
118 |
|
119 private: |
|
120 TInt iStartParse; // start of text to be parsed; -1 means none |
|
121 TInt iEndParse; // end of text to be parsed |
|
122 }; |
|
123 |
|
124 #endif |