xref: /AOO41X/main/l10ntools/inc/tagtest.hxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
1983d4c8aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3983d4c8aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4983d4c8aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5983d4c8aSAndrew Rist  * distributed with this work for additional information
6983d4c8aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7983d4c8aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8983d4c8aSAndrew Rist  * "License"); you may not use this file except in compliance
9983d4c8aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11983d4c8aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13983d4c8aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14983d4c8aSAndrew Rist  * software distributed under the License is distributed on an
15983d4c8aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16983d4c8aSAndrew Rist  * KIND, either express or implied.  See the License for the
17983d4c8aSAndrew Rist  * specific language governing permissions and limitations
18983d4c8aSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20983d4c8aSAndrew Rist  *************************************************************/
21983d4c8aSAndrew Rist 
22983d4c8aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _TAGTEST_HXX_
25cdf0e10cSrcweir #define _TAGTEST_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools/string.hxx>
28cdf0e10cSrcweir #include <tools/list.hxx>
29cdf0e10cSrcweir #include <hash_map> /* std::hashmap*/
30*a8f85396SHerbert Dürr #include <rtl/string.h>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir class GSILine;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir typedef sal_uInt16 TokenId;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #define TOK_INVALIDPOS  sal_uInt16( 0xFFFF )
37cdf0e10cSrcweir 
38cdf0e10cSrcweir class ParserMessage;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir DECLARE_LIST( Impl_ParserMessageList, ParserMessage* )
41cdf0e10cSrcweir class ParserMessageList;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 
44cdf0e10cSrcweir struct equalByteString{
operator ()equalByteString45cdf0e10cSrcweir         bool operator()( const ByteString& rKey1, const ByteString& rKey2 ) const {
46cdf0e10cSrcweir             return rKey1.CompareTo( rKey2 )==COMPARE_EQUAL;
47cdf0e10cSrcweir     }
48cdf0e10cSrcweir };
49cdf0e10cSrcweir struct lessByteString{
operator ()lessByteString50cdf0e10cSrcweir         bool operator()( const ByteString& rKey1, const ByteString& rKey2 ) const {
51cdf0e10cSrcweir             return rKey1.CompareTo( rKey2 )==COMPARE_LESS;
52cdf0e10cSrcweir     }
53cdf0e10cSrcweir };
54cdf0e10cSrcweir 
55cdf0e10cSrcweir struct hashByteString{
operator ()hashByteString56cdf0e10cSrcweir     size_t operator()( const ByteString& rName ) const{
57*a8f85396SHerbert Dürr         return rtl_str_hashCode_WithLength( rName.GetBuffer(), rName.Len());
58cdf0e10cSrcweir     }
59cdf0e10cSrcweir };
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir typedef std::hash_map<ByteString , String , hashByteString,equalByteString>
64cdf0e10cSrcweir                                 StringHashMap;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir class TokenInfo
67cdf0e10cSrcweir {
68cdf0e10cSrcweir private:
69cdf0e10cSrcweir     void SplitTag( ParserMessageList &rErrorList );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     String aTagName;
72cdf0e10cSrcweir     StringHashMap aProperties;
73cdf0e10cSrcweir     sal_Bool bClosed;    // tag is closed  <sdnf/>
74cdf0e10cSrcweir     sal_Bool bCloseTag;  // tag is close Tag  </sdnf>
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     sal_Bool bIsBroken;
78cdf0e10cSrcweir     sal_Bool bHasBeenFixed;
79cdf0e10cSrcweir     sal_Bool bDone;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir public:
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	String aTokenString;
84cdf0e10cSrcweir 	TokenId nId;
85cdf0e10cSrcweir     sal_uInt16 nPos;            // Position in String
86cdf0e10cSrcweir 
TokenInfo()87cdf0e10cSrcweir     TokenInfo():bClosed(sal_False),bCloseTag(sal_False),bIsBroken(sal_False),bHasBeenFixed(sal_False),bDone(sal_False),nId( 0 ){;}
TokenInfo(TokenId pnId,sal_uInt16 nP)88cdf0e10cSrcweir explicit    TokenInfo( TokenId pnId, sal_uInt16 nP ):bClosed(sal_False),bCloseTag(sal_False),bIsBroken(sal_False),bHasBeenFixed(sal_False),bDone(sal_False),nId( pnId ),nPos(nP){;}
TokenInfo(TokenId pnId,sal_uInt16 nP,String paStr)89cdf0e10cSrcweir explicit    TokenInfo( TokenId pnId, sal_uInt16 nP, String paStr ):bClosed(sal_False),bCloseTag(sal_False),bIsBroken(sal_False),bHasBeenFixed(sal_False),bDone(sal_False),aTokenString( paStr ),nId( pnId ),nPos(nP) {;}
90cdf0e10cSrcweir explicit    TokenInfo( TokenId pnId, sal_uInt16 nP, String paStr, ParserMessageList &rErrorList );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	String GetTagName() const;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     String MakeTag() const;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     /**
97cdf0e10cSrcweir         Is the property to be ignored or does it have the default value anyways
98cdf0e10cSrcweir     **/
99cdf0e10cSrcweir     sal_Bool IsPropertyRelevant( const ByteString &aName, const String &aValue ) const;
100cdf0e10cSrcweir     sal_Bool IsPropertyValueValid( const ByteString &aName, const String &aValue ) const;
101cdf0e10cSrcweir     /**
102cdf0e10cSrcweir         Does the property contain the same value for all languages
103cdf0e10cSrcweir         e.g.: the href in a link tag
104cdf0e10cSrcweir     **/
105cdf0e10cSrcweir     sal_Bool IsPropertyInvariant( const ByteString &aName, const String &aValue ) const;
106cdf0e10cSrcweir     /**
107cdf0e10cSrcweir         a subset of IsPropertyInvariant but containing only those that are fixable
108cdf0e10cSrcweir         we dont wat to fix e.g.: ahelp :: visibility
109cdf0e10cSrcweir     **/
110cdf0e10cSrcweir     sal_Bool IsPropertyFixable( const ByteString &aName ) const;
111cdf0e10cSrcweir     sal_Bool MatchesTranslation( TokenInfo& rInfo, sal_Bool bGenErrors, ParserMessageList &rErrorList, sal_Bool bFixTags = sal_False ) const;
112cdf0e10cSrcweir 
IsDone() const113cdf0e10cSrcweir     sal_Bool IsDone() const { return bDone; }
SetDone(sal_Bool bNew=sal_True)114cdf0e10cSrcweir     void SetDone( sal_Bool bNew = sal_True ) { bDone = bNew; }
115cdf0e10cSrcweir 
HasBeenFixed() const116cdf0e10cSrcweir     sal_Bool HasBeenFixed() const { return bHasBeenFixed; }
SetHasBeenFixed(sal_Bool bNew=sal_True)117cdf0e10cSrcweir     void SetHasBeenFixed( sal_Bool bNew = sal_True ) { bHasBeenFixed = bNew; }
118cdf0e10cSrcweir };
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
121cdf0e10cSrcweir class ParserMessageList : public Impl_ParserMessageList
122cdf0e10cSrcweir {
123cdf0e10cSrcweir public:
124cdf0e10cSrcweir     void AddError( sal_uInt16 nErrorNr, ByteString aErrorText, const TokenInfo &rTag );
125cdf0e10cSrcweir     void AddWarning( sal_uInt16 nErrorNr, ByteString aErrorText, const TokenInfo &rTag );
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     sal_Bool HasErrors();
128cdf0e10cSrcweir };
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 
131cdf0e10cSrcweir #define TAG_GROUPMASK				0xF000
132cdf0e10cSrcweir #define TAG_GROUPSHIFT				12
133cdf0e10cSrcweir 
134cdf0e10cSrcweir #define TAG_GROUP( nTag )			(( nTag & TAG_GROUPMASK ) >> TAG_GROUPSHIFT )
135cdf0e10cSrcweir #define TAG_NOGROUP( nTag )			( nTag & ~TAG_GROUPMASK )	// ~ = Bitweises NOT
136cdf0e10cSrcweir 
137cdf0e10cSrcweir #define TAG_NOMORETAGS				0x0
138cdf0e10cSrcweir 
139cdf0e10cSrcweir #define TAG_GROUP_FORMAT			0x1
140cdf0e10cSrcweir #define TAG_ON						0x100
141cdf0e10cSrcweir #define TAG_BOLDON					( TAG_GROUP_FORMAT << TAG_GROUPSHIFT | TAG_ON | 0x001 )
142cdf0e10cSrcweir #define TAG_BOLDOFF					( TAG_GROUP_FORMAT << TAG_GROUPSHIFT |          0x001 )
143cdf0e10cSrcweir #define TAG_ITALICON				( TAG_GROUP_FORMAT << TAG_GROUPSHIFT | TAG_ON | 0x002 )
144cdf0e10cSrcweir #define TAG_ITALICOFF				( TAG_GROUP_FORMAT << TAG_GROUPSHIFT |          0x002 )
145cdf0e10cSrcweir #define TAG_UNDERLINEON				( TAG_GROUP_FORMAT << TAG_GROUPSHIFT | TAG_ON | 0x004 )
146cdf0e10cSrcweir #define TAG_UNDERLINEOFF			( TAG_GROUP_FORMAT << TAG_GROUPSHIFT |          0x004 )
147cdf0e10cSrcweir 
148cdf0e10cSrcweir #define TAG_GROUP_NOTALLOWED		0x2
149cdf0e10cSrcweir #define TAG_HELPID					( TAG_GROUP_NOTALLOWED << TAG_GROUPSHIFT | 0x001 )
150cdf0e10cSrcweir #define TAG_MODIFY					( TAG_GROUP_NOTALLOWED << TAG_GROUPSHIFT | 0x002 )
151cdf0e10cSrcweir #define TAG_REFNR					( TAG_GROUP_NOTALLOWED << TAG_GROUPSHIFT | 0x004 )
152cdf0e10cSrcweir 
153cdf0e10cSrcweir #define TAG_GROUP_STRUCTURE			0x3
154cdf0e10cSrcweir #define TAG_NAME					( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x001 )
155cdf0e10cSrcweir #define TAG_HREF					( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x002 )
156cdf0e10cSrcweir #define TAG_AVIS					( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x004 )
157cdf0e10cSrcweir #define TAG_AHID					( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x008 )
158cdf0e10cSrcweir 
159cdf0e10cSrcweir #define TAG_TITEL					( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x020 )
160cdf0e10cSrcweir #define TAG_KEY						( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x040 )
161cdf0e10cSrcweir #define TAG_INDEX					( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x080 )
162cdf0e10cSrcweir 
163cdf0e10cSrcweir #define TAG_REFSTART				( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x100 )
164cdf0e10cSrcweir 
165cdf0e10cSrcweir #define TAG_GRAPHIC					( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x200 )
166cdf0e10cSrcweir #define TAG_NEXTVERSION				( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x400 )
167cdf0e10cSrcweir 
168cdf0e10cSrcweir #define TAG_GROUP_SYSSWITCH			0x4
169cdf0e10cSrcweir #define TAG_WIN						( TAG_GROUP_SYSSWITCH << TAG_GROUPSHIFT | 0x001 )
170cdf0e10cSrcweir #define TAG_UNIX					( TAG_GROUP_SYSSWITCH << TAG_GROUPSHIFT | 0x002 )
171cdf0e10cSrcweir #define TAG_MAC						( TAG_GROUP_SYSSWITCH << TAG_GROUPSHIFT | 0x004 )
172cdf0e10cSrcweir #define TAG_OS2						( TAG_GROUP_SYSSWITCH << TAG_GROUPSHIFT | 0x008 )
173cdf0e10cSrcweir 
174cdf0e10cSrcweir #define TAG_GROUP_PROGSWITCH		0x5
175cdf0e10cSrcweir #define TAG_WRITER					( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x001 )
176cdf0e10cSrcweir #define TAG_CALC					( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x002 )
177cdf0e10cSrcweir #define TAG_DRAW					( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x004 )
178cdf0e10cSrcweir #define TAG_IMPRESS					( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x008 )
179cdf0e10cSrcweir #define TAG_SCHEDULE				( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x010 )
180cdf0e10cSrcweir #define TAG_IMAGE					( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x020 )
181cdf0e10cSrcweir #define TAG_MATH					( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x040 )
182cdf0e10cSrcweir #define TAG_CHART					( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x080 )
183cdf0e10cSrcweir #define TAG_OFFICE					( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x100 )
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 
186cdf0e10cSrcweir #define TAG_GROUP_META				0x6
187cdf0e10cSrcweir #define TAG_OFFICEFULLNAME			( TAG_GROUP_META << TAG_GROUPSHIFT | 0x001 )
188cdf0e10cSrcweir #define TAG_OFFICENAME				( TAG_GROUP_META << TAG_GROUPSHIFT | 0x002 )
189cdf0e10cSrcweir #define TAG_OFFICEPATH				( TAG_GROUP_META << TAG_GROUPSHIFT | 0x004 )
190cdf0e10cSrcweir #define TAG_OFFICEVERSION			( TAG_GROUP_META << TAG_GROUPSHIFT | 0x008 )
191cdf0e10cSrcweir #define TAG_PORTALNAME				( TAG_GROUP_META << TAG_GROUPSHIFT | 0x010 )
192cdf0e10cSrcweir #define TAG_PORTALFULLNAME			( TAG_GROUP_META << TAG_GROUPSHIFT | 0x020 )
193cdf0e10cSrcweir #define TAG_PORTALPATH				( TAG_GROUP_META << TAG_GROUPSHIFT | 0x040 )
194cdf0e10cSrcweir #define TAG_PORTALVERSION			( TAG_GROUP_META << TAG_GROUPSHIFT | 0x080 )
195cdf0e10cSrcweir #define TAG_PORTALSHORTNAME			( TAG_GROUP_META << TAG_GROUPSHIFT | 0x100 )
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 
198cdf0e10cSrcweir #define TAG_GROUP_SINGLE            0x7
199cdf0e10cSrcweir #define TAG_REFINSERT               ( TAG_GROUP_SINGLE << TAG_GROUPSHIFT | 0x001 )
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 
202cdf0e10cSrcweir #define TAG_GROUP_MULTI				0x8
203cdf0e10cSrcweir #define TAG_END						( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x010 )
204cdf0e10cSrcweir #define TAG_ELSE					( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x020 )
205cdf0e10cSrcweir #define TAG_AEND					( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x040 )
206cdf0e10cSrcweir #define TAG_VERSIONEND				( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x080 )
207cdf0e10cSrcweir #define TAG_ENDGRAPHIC				( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x100 )
208cdf0e10cSrcweir 
209cdf0e10cSrcweir #define TAG_GROUP_MISC				0x9
210cdf0e10cSrcweir #define TAG_COMMONSTART				( TAG_GROUP_MISC << TAG_GROUPSHIFT | 0x001 )
211cdf0e10cSrcweir #define TAG_COMMONEND				( TAG_GROUP_MISC << TAG_GROUPSHIFT | 0x002 )
212cdf0e10cSrcweir 
213cdf0e10cSrcweir #define TAG_UNKNOWN_TAG				( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x800 )
214cdf0e10cSrcweir 
215cdf0e10cSrcweir DECLARE_LIST( TokenListImpl, TokenInfo* )
216cdf0e10cSrcweir 
217cdf0e10cSrcweir class TokenList : private TokenListImpl
218cdf0e10cSrcweir {
219cdf0e10cSrcweir private:
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     TokenList&   operator =( const TokenList& rList );
222cdf0e10cSrcweir //                { TokenListImpl::operator =( rList ); return *this; }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 
225cdf0e10cSrcweir public:
226cdf0e10cSrcweir 	using TokenListImpl::Count;
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 
TokenList()229cdf0e10cSrcweir     TokenList() : TokenListImpl(){};
~TokenList()230cdf0e10cSrcweir     ~TokenList(){ Clear(); };
231cdf0e10cSrcweir 
Clear()232cdf0e10cSrcweir 	void		Clear()
233cdf0e10cSrcweir 		{
234cdf0e10cSrcweir 			for ( sal_uLong i = 0 ; i < Count() ; i++ )
235cdf0e10cSrcweir 				delete TokenListImpl::GetObject( i );
236cdf0e10cSrcweir 			TokenListImpl::Clear();
237cdf0e10cSrcweir 		}
Insert(TokenInfo p,sal_uLong nIndex=LIST_APPEND)238cdf0e10cSrcweir 	void		Insert( TokenInfo p, sal_uLong nIndex = LIST_APPEND )
239cdf0e10cSrcweir 		{ TokenListImpl::Insert( new TokenInfo(p), nIndex ); }
240cdf0e10cSrcweir /*    TokenInfo		Remove( sal_uLong nIndex )
241cdf0e10cSrcweir 		{
242cdf0e10cSrcweir 			TokenInfo aT = GetObject( nIndex );
243cdf0e10cSrcweir 			delete TokenListImpl::GetObject( nIndex );
244cdf0e10cSrcweir 			TokenListImpl::Remove( nIndex );
245cdf0e10cSrcweir 			return aT;
246cdf0e10cSrcweir 		}*/
247cdf0e10cSrcweir //    TokenInfo		Remove( TokenInfo p ){ return Remove( GetPos( p ) ); }
248cdf0e10cSrcweir //    TokenInfo		GetCurObject() const { return *TokenListImpl::GetCurObject(); }
GetObject(sal_uLong nIndex) const249cdf0e10cSrcweir     TokenInfo&		GetObject( sal_uLong nIndex ) const
250cdf0e10cSrcweir 		{
251cdf0e10cSrcweir //			if ( TokenListImpl::GetObject(nIndex) )
252cdf0e10cSrcweir 				return *TokenListImpl::GetObject(nIndex);
253cdf0e10cSrcweir //			else
254cdf0e10cSrcweir //				return TokenInfo();
255cdf0e10cSrcweir 		}
256cdf0e10cSrcweir /*    sal_uLong		GetPos( const TokenInfo p ) const
257cdf0e10cSrcweir 		{
258cdf0e10cSrcweir 			for ( sal_uLong i = 0 ; i < Count() ; i++ )
259cdf0e10cSrcweir 				if ( p == GetObject( i ) )
260cdf0e10cSrcweir 					return i;
261cdf0e10cSrcweir 			return LIST_ENTRY_NOTFOUND;
262cdf0e10cSrcweir 		}*/
263cdf0e10cSrcweir 
264cdf0e10cSrcweir     TokenList( const TokenList& rList );
265cdf0e10cSrcweir /*		{
266cdf0e10cSrcweir 			for ( sal_uLong i = 0 ; i < rList.Count() ; i++ )
267cdf0e10cSrcweir 			{
268cdf0e10cSrcweir 				Insert( rList.GetObject( i ), LIST_APPEND );
269cdf0e10cSrcweir 			}
270cdf0e10cSrcweir 		}*/
271cdf0e10cSrcweir };
272cdf0e10cSrcweir 
273cdf0e10cSrcweir class ParserMessage
274cdf0e10cSrcweir {
275cdf0e10cSrcweir 	sal_uInt16 nErrorNr;
276cdf0e10cSrcweir 	ByteString aErrorText;
277cdf0e10cSrcweir 	sal_uInt16 nTagBegin,nTagLength;
278cdf0e10cSrcweir 
279cdf0e10cSrcweir protected:
280cdf0e10cSrcweir     ParserMessage( sal_uInt16 PnErrorNr, ByteString PaErrorText, const TokenInfo &rTag );
281cdf0e10cSrcweir public:
282cdf0e10cSrcweir 
GetErrorNr()283cdf0e10cSrcweir 	sal_uInt16 GetErrorNr() { return nErrorNr; }
GetErrorText()284cdf0e10cSrcweir 	ByteString GetErrorText() { return aErrorText; }
285cdf0e10cSrcweir 
GetTagBegin()286cdf0e10cSrcweir 	sal_uInt16 GetTagBegin() { return nTagBegin; }
GetTagLength()287cdf0e10cSrcweir 	sal_uInt16 GetTagLength() { return nTagLength; }
288cdf0e10cSrcweir 
~ParserMessage()289cdf0e10cSrcweir     virtual ~ParserMessage() {}
290cdf0e10cSrcweir     virtual sal_Bool IsError() =0;
291cdf0e10cSrcweir     virtual ByteString Prefix() =0;
292cdf0e10cSrcweir };
293cdf0e10cSrcweir 
294cdf0e10cSrcweir class ParserError : public ParserMessage
295cdf0e10cSrcweir {
296cdf0e10cSrcweir public:
297cdf0e10cSrcweir     ParserError( sal_uInt16 PnErrorNr, ByteString PaErrorText, const TokenInfo &rTag );
298cdf0e10cSrcweir 
IsError()299cdf0e10cSrcweir     virtual sal_Bool IsError() {return sal_True;};
Prefix()300cdf0e10cSrcweir     virtual ByteString Prefix() {return "Error:"; };
301cdf0e10cSrcweir };
302cdf0e10cSrcweir 
303cdf0e10cSrcweir class ParserWarning : public ParserMessage
304cdf0e10cSrcweir {
305cdf0e10cSrcweir public:
306cdf0e10cSrcweir     ParserWarning( sal_uInt16 PnErrorNr, ByteString PaErrorText, const TokenInfo &rTag );
307cdf0e10cSrcweir 
IsError()308cdf0e10cSrcweir     virtual sal_Bool IsError() {return sal_False;};
Prefix()309cdf0e10cSrcweir     virtual ByteString Prefix() {return "Warning:"; };
310cdf0e10cSrcweir };
311cdf0e10cSrcweir 
312cdf0e10cSrcweir class SimpleParser
313cdf0e10cSrcweir {
314cdf0e10cSrcweir private:
315cdf0e10cSrcweir 	sal_uInt16 nPos;
316cdf0e10cSrcweir 	String aSource;
317cdf0e10cSrcweir 	String aLastToken;
318cdf0e10cSrcweir 	TokenList aTokenList;
319cdf0e10cSrcweir 
320cdf0e10cSrcweir     TokenInfo aNextTag;     // to store closetag in case of combined tags like <br/>
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 	String GetNextTokenString( ParserMessageList &rErrorList, sal_uInt16 &rTokeStartPos );
323cdf0e10cSrcweir 
324cdf0e10cSrcweir public:
325cdf0e10cSrcweir 	SimpleParser();
326cdf0e10cSrcweir 	void Parse( String PaSource );
327cdf0e10cSrcweir 	TokenInfo GetNextToken( ParserMessageList &rErrorList );
328cdf0e10cSrcweir 	static String GetLexem( TokenInfo const &aToken );
GetTokenList()329cdf0e10cSrcweir 	TokenList& GetTokenList(){ return aTokenList; }
330cdf0e10cSrcweir };
331cdf0e10cSrcweir 
332cdf0e10cSrcweir class TokenParser
333cdf0e10cSrcweir {
334cdf0e10cSrcweir     sal_Bool match( const TokenInfo &aCurrentToken, const TokenId &aExpectedToken );
335cdf0e10cSrcweir 	sal_Bool match( const TokenInfo &aCurrentToken, const TokenInfo &aExpectedToken );
336cdf0e10cSrcweir 	void ParseError( sal_uInt16 nErrNr, ByteString aErrMsg, const TokenInfo &rTag );
337cdf0e10cSrcweir 	void Paragraph();
338cdf0e10cSrcweir 	void PfCase();
339cdf0e10cSrcweir 	void PfCaseBegin();
340cdf0e10cSrcweir 	void AppCase();
341cdf0e10cSrcweir 	void AppCaseBegin();
342cdf0e10cSrcweir 	void CaseEnd();
343cdf0e10cSrcweir 	void SimpleTag();
344cdf0e10cSrcweir 	void TagPair();
345cdf0e10cSrcweir 	void TagRef();
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 	SimpleParser aParser;
348cdf0e10cSrcweir 	TokenInfo aTag;
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 	TokenId nPfCaseOptions;
351cdf0e10cSrcweir 	TokenId nAppCaseOptions;
352cdf0e10cSrcweir 	sal_Bool bPfCaseActive ,bAppCaseActive;
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 	TokenId nActiveRefTypes;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	ParserMessageList *pErrorList;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir public:
359cdf0e10cSrcweir 	TokenParser();
360cdf0e10cSrcweir 	void Parse( const String &aCode, ParserMessageList* pList );
361cdf0e10cSrcweir //	ParserMessageList& GetErrors(){ return aErrorList; }
362cdf0e10cSrcweir //	sal_Bool HasErrors(){ return ( aErrorList.Count() > 0 ); }
GetTokenList()363cdf0e10cSrcweir 	TokenList& GetTokenList(){ return aParser.GetTokenList(); }
364cdf0e10cSrcweir };
365cdf0e10cSrcweir 
366cdf0e10cSrcweir class LingTest
367cdf0e10cSrcweir {
368cdf0e10cSrcweir private:
369cdf0e10cSrcweir 	TokenParser aReferenceParser;
370cdf0e10cSrcweir 	TokenParser aTesteeParser;
371cdf0e10cSrcweir 	ParserMessageList aCompareWarningList;
372cdf0e10cSrcweir 	void CheckTags( TokenList &aReference, TokenList &aTestee, sal_Bool bFixTags );
373cdf0e10cSrcweir     sal_Bool IsTagMandatory( TokenInfo const &aToken, TokenId &aMetaTokens );
374cdf0e10cSrcweir     String aFixedTestee;
375cdf0e10cSrcweir public:
376cdf0e10cSrcweir 	void CheckReference( GSILine *aReference );
377cdf0e10cSrcweir 	void CheckTestee( GSILine *aTestee, sal_Bool bHasSourceLine, sal_Bool bFixTags );
378cdf0e10cSrcweir 
379cdf0e10cSrcweir //	ParserMessageList& GetReferenceErrors(){ return aReferenceParser.GetErrors(); }
380cdf0e10cSrcweir //	sal_Bool HasReferenceErrors(){ return aReferenceParser.HasErrors(); }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir //	ParserMessageList& GetTesteeErrors(){ return aTesteeParser.GetErrors(); }
383cdf0e10cSrcweir //	sal_Bool HasTesteeErrors(){ return aTesteeParser.HasErrors(); }
384cdf0e10cSrcweir 
GetCompareWarnings()385cdf0e10cSrcweir 	ParserMessageList& GetCompareWarnings(){ return aCompareWarningList; }
HasCompareWarnings()386cdf0e10cSrcweir 	sal_Bool HasCompareWarnings(){ return ( aCompareWarningList.Count() > 0 ); }
387cdf0e10cSrcweir 
GetFixedTestee()388cdf0e10cSrcweir     String GetFixedTestee(){ return aFixedTestee; }
389cdf0e10cSrcweir };
390cdf0e10cSrcweir 
391cdf0e10cSrcweir #endif
392cdf0e10cSrcweir 
393