xref: /aoo41x/main/l10ntools/inc/gsicheck.hxx (revision 983d4c8a)
1*983d4c8aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*983d4c8aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*983d4c8aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*983d4c8aSAndrew Rist  * distributed with this work for additional information
6*983d4c8aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*983d4c8aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*983d4c8aSAndrew Rist  * "License"); you may not use this file except in compliance
9*983d4c8aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*983d4c8aSAndrew Rist  *
11*983d4c8aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*983d4c8aSAndrew Rist  *
13*983d4c8aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*983d4c8aSAndrew Rist  * software distributed under the License is distributed on an
15*983d4c8aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*983d4c8aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*983d4c8aSAndrew Rist  * specific language governing permissions and limitations
18*983d4c8aSAndrew Rist  * under the License.
19*983d4c8aSAndrew Rist  *
20*983d4c8aSAndrew Rist  *************************************************************/
21*983d4c8aSAndrew Rist 
22*983d4c8aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _GSICHECK_HXX_
25cdf0e10cSrcweir #define _GSICHECK_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "tagtest.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir //
30cdf0e10cSrcweir // class GSILine
31cdf0e10cSrcweir //
32cdf0e10cSrcweir enum LineFormat { FORMAT_GSI, FORMAT_SDF, FORMAT_UNKNOWN };
33cdf0e10cSrcweir 
34cdf0e10cSrcweir class GSILine : public ByteString
35cdf0e10cSrcweir {
36cdf0e10cSrcweir private:
37cdf0e10cSrcweir 
38cdf0e10cSrcweir     ParserMessageList aMessages;
39cdf0e10cSrcweir     LineFormat aFormat;
40cdf0e10cSrcweir 	sal_uLong nLineNumber;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     ByteString aUniqId;
43cdf0e10cSrcweir     ByteString aLineType;
44cdf0e10cSrcweir     ByteString aLangId;
45cdf0e10cSrcweir 	ByteString aText;
46cdf0e10cSrcweir 	ByteString aQuickHelpText;
47cdf0e10cSrcweir 	ByteString aTitle;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     sal_Bool bOK;
50cdf0e10cSrcweir     sal_Bool bFixed;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     void              ReassembleLine();
53cdf0e10cSrcweir 
54cdf0e10cSrcweir public:
55cdf0e10cSrcweir     GSILine( const ByteString &rLine, sal_uLong nLine );
GetLineFormat() const56cdf0e10cSrcweir     LineFormat  GetLineFormat() const    { return aFormat; }
GetLineNumber() const57cdf0e10cSrcweir 	sal_uLong       GetLineNumber() const    { return nLineNumber; }
58cdf0e10cSrcweir 
GetUniqId() const59cdf0e10cSrcweir 	ByteString  const GetUniqId()     const    { return aUniqId; }
GetLineType() const60cdf0e10cSrcweir     ByteString  const GetLineType()   const    { return aLineType; }
GetLanguageId() const61cdf0e10cSrcweir 	ByteString  const GetLanguageId() const    { return aLangId; }
GetText() const62cdf0e10cSrcweir 	ByteString  const GetText()       const    { return aText; }
GetUText() const63cdf0e10cSrcweir 	    String  const GetUText()      const    { return String( aText, RTL_TEXTENCODING_UTF8 ); }
GetQuickHelpText() const64cdf0e10cSrcweir 	ByteString  const GetQuickHelpText() const { return aQuickHelpText; }
GetTitle() const65cdf0e10cSrcweir 	ByteString  const GetTitle()      const    { return aTitle; }
66cdf0e10cSrcweir 
SetUText(String & aNew)67cdf0e10cSrcweir 	      void        SetUText( String &aNew ) { aText = ByteString( aNew, RTL_TEXTENCODING_UTF8 ); ReassembleLine(); }
SetText(ByteString & aNew)68cdf0e10cSrcweir 	      void        SetText( ByteString &aNew ) { aText = aNew; ReassembleLine(); }
SetQuickHelpText(ByteString & aNew)69cdf0e10cSrcweir 	      void        SetQuickHelpText( ByteString &aNew ) { aQuickHelpText = aNew; ReassembleLine(); }
SetTitle(ByteString & aNew)70cdf0e10cSrcweir 	      void        SetTitle( ByteString &aNew ) { aTitle = aNew; ReassembleLine(); }
71cdf0e10cSrcweir 
GetMessageList()72cdf0e10cSrcweir     ParserMessageList* GetMessageList() { return &aMessages; };
HasMessages()73cdf0e10cSrcweir 	sal_Bool HasMessages(){ return ( aMessages.Count() > 0 ); };
74cdf0e10cSrcweir 
IsOK() const75cdf0e10cSrcweir 	sal_Bool IsOK() const { return bOK; }
76cdf0e10cSrcweir 	void NotOK();
77cdf0e10cSrcweir 
IsFixed() const78cdf0e10cSrcweir 	sal_Bool IsFixed() const { return bFixed; }
SetFixed()79cdf0e10cSrcweir     void SetFixed() { bFixed = sal_True; };
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
82cdf0e10cSrcweir //
83cdf0e10cSrcweir // class GSIBlock
84cdf0e10cSrcweir //
85cdf0e10cSrcweir 
86cdf0e10cSrcweir DECLARE_LIST( GSIBlock_Impl, GSILine * )
87cdf0e10cSrcweir 
88cdf0e10cSrcweir class LazySvFileStream;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir class GSIBlock : public GSIBlock_Impl
91cdf0e10cSrcweir {
92cdf0e10cSrcweir private:
93cdf0e10cSrcweir 	GSILine *pSourceLine;
94cdf0e10cSrcweir 	GSILine *pReferenceLine;
95cdf0e10cSrcweir 	void PrintList( ParserMessageList *pList, ByteString aPrefix, GSILine *pLine );
96cdf0e10cSrcweir 	sal_Bool bPrintContext;
97cdf0e10cSrcweir     sal_Bool bCheckSourceLang;
98cdf0e10cSrcweir     sal_Bool bCheckTranslationLang;
99cdf0e10cSrcweir     sal_Bool bReference;
100cdf0e10cSrcweir     sal_Bool bAllowKeyIDs;
101cdf0e10cSrcweir     sal_Bool bAllowSuspicious;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     sal_Bool bHasBlockError;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     sal_Bool IsUTF8( const ByteString &aTestee, sal_Bool bFixTags, sal_uInt16 &nErrorPos, ByteString &aErrorMsg, sal_Bool &bHasBeenFixed, ByteString &aFixed ) const;
106cdf0e10cSrcweir     sal_Bool TestUTF8( GSILine* pTestee, sal_Bool bFixTags );
107cdf0e10cSrcweir     sal_Bool HasSuspiciousChars( GSILine* pTestee, GSILine* pSource );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir public:
110cdf0e10cSrcweir 	GSIBlock( sal_Bool PbPrintContext, sal_Bool bSource, sal_Bool bTrans, sal_Bool bRef, sal_Bool bAllowKID, sal_Bool bAllowSusp );
111cdf0e10cSrcweir 	~GSIBlock();
112cdf0e10cSrcweir 	void PrintMessage( ByteString aType, ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() );
113cdf0e10cSrcweir 	void PrintError( ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() );
114cdf0e10cSrcweir     void InsertLine( GSILine* pLine, const ByteString aSourceLang);
115cdf0e10cSrcweir     void SetReferenceLine( GSILine* pLine );
116cdf0e10cSrcweir 	sal_Bool CheckSyntax( sal_uLong nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	void WriteError( LazySvFileStream &aErrOut, sal_Bool bRequireSourceLine );
119cdf0e10cSrcweir 	void WriteCorrect( LazySvFileStream &aOkOut, sal_Bool bRequireSourceLine );
120cdf0e10cSrcweir     void WriteFixed( LazySvFileStream &aFixOut, sal_Bool bRequireSourceLine );
121cdf0e10cSrcweir };
122cdf0e10cSrcweir 
123cdf0e10cSrcweir #endif
124cdf0e10cSrcweir 
125