xref: /aoo41x/main/l10ntools/inc/gsicheck.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _GSICHECK_HXX_
29*cdf0e10cSrcweir #define _GSICHECK_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "tagtest.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir //
34*cdf0e10cSrcweir // class GSILine
35*cdf0e10cSrcweir //
36*cdf0e10cSrcweir enum LineFormat { FORMAT_GSI, FORMAT_SDF, FORMAT_UNKNOWN };
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir class GSILine : public ByteString
39*cdf0e10cSrcweir {
40*cdf0e10cSrcweir private:
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir     ParserMessageList aMessages;
43*cdf0e10cSrcweir     LineFormat aFormat;
44*cdf0e10cSrcweir 	sal_uLong nLineNumber;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir     ByteString aUniqId;
47*cdf0e10cSrcweir     ByteString aLineType;
48*cdf0e10cSrcweir     ByteString aLangId;
49*cdf0e10cSrcweir 	ByteString aText;
50*cdf0e10cSrcweir 	ByteString aQuickHelpText;
51*cdf0e10cSrcweir 	ByteString aTitle;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir     sal_Bool bOK;
54*cdf0e10cSrcweir     sal_Bool bFixed;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir     void              ReassembleLine();
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir public:
59*cdf0e10cSrcweir     GSILine( const ByteString &rLine, sal_uLong nLine );
60*cdf0e10cSrcweir     LineFormat  GetLineFormat() const    { return aFormat; }
61*cdf0e10cSrcweir 	sal_uLong       GetLineNumber() const    { return nLineNumber; }
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	ByteString  const GetUniqId()     const    { return aUniqId; }
64*cdf0e10cSrcweir     ByteString  const GetLineType()   const    { return aLineType; }
65*cdf0e10cSrcweir 	ByteString  const GetLanguageId() const    { return aLangId; }
66*cdf0e10cSrcweir 	ByteString  const GetText()       const    { return aText; }
67*cdf0e10cSrcweir 	    String  const GetUText()      const    { return String( aText, RTL_TEXTENCODING_UTF8 ); }
68*cdf0e10cSrcweir 	ByteString  const GetQuickHelpText() const { return aQuickHelpText; }
69*cdf0e10cSrcweir 	ByteString  const GetTitle()      const    { return aTitle; }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	      void        SetUText( String &aNew ) { aText = ByteString( aNew, RTL_TEXTENCODING_UTF8 ); ReassembleLine(); }
72*cdf0e10cSrcweir 	      void        SetText( ByteString &aNew ) { aText = aNew; ReassembleLine(); }
73*cdf0e10cSrcweir 	      void        SetQuickHelpText( ByteString &aNew ) { aQuickHelpText = aNew; ReassembleLine(); }
74*cdf0e10cSrcweir 	      void        SetTitle( ByteString &aNew ) { aTitle = aNew; ReassembleLine(); }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     ParserMessageList* GetMessageList() { return &aMessages; };
77*cdf0e10cSrcweir 	sal_Bool HasMessages(){ return ( aMessages.Count() > 0 ); };
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 	sal_Bool IsOK() const { return bOK; }
80*cdf0e10cSrcweir 	void NotOK();
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	sal_Bool IsFixed() const { return bFixed; }
83*cdf0e10cSrcweir     void SetFixed() { bFixed = sal_True; };
84*cdf0e10cSrcweir };
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir //
87*cdf0e10cSrcweir // class GSIBlock
88*cdf0e10cSrcweir //
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir DECLARE_LIST( GSIBlock_Impl, GSILine * )
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir class LazySvFileStream;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir class GSIBlock : public GSIBlock_Impl
95*cdf0e10cSrcweir {
96*cdf0e10cSrcweir private:
97*cdf0e10cSrcweir 	GSILine *pSourceLine;
98*cdf0e10cSrcweir 	GSILine *pReferenceLine;
99*cdf0e10cSrcweir 	void PrintList( ParserMessageList *pList, ByteString aPrefix, GSILine *pLine );
100*cdf0e10cSrcweir 	sal_Bool bPrintContext;
101*cdf0e10cSrcweir     sal_Bool bCheckSourceLang;
102*cdf0e10cSrcweir     sal_Bool bCheckTranslationLang;
103*cdf0e10cSrcweir     sal_Bool bReference;
104*cdf0e10cSrcweir     sal_Bool bAllowKeyIDs;
105*cdf0e10cSrcweir     sal_Bool bAllowSuspicious;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     sal_Bool bHasBlockError;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     sal_Bool IsUTF8( const ByteString &aTestee, sal_Bool bFixTags, sal_uInt16 &nErrorPos, ByteString &aErrorMsg, sal_Bool &bHasBeenFixed, ByteString &aFixed ) const;
110*cdf0e10cSrcweir     sal_Bool TestUTF8( GSILine* pTestee, sal_Bool bFixTags );
111*cdf0e10cSrcweir     sal_Bool HasSuspiciousChars( GSILine* pTestee, GSILine* pSource );
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir public:
114*cdf0e10cSrcweir 	GSIBlock( sal_Bool PbPrintContext, sal_Bool bSource, sal_Bool bTrans, sal_Bool bRef, sal_Bool bAllowKID, sal_Bool bAllowSusp );
115*cdf0e10cSrcweir 	~GSIBlock();
116*cdf0e10cSrcweir 	void PrintMessage( ByteString aType, ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() );
117*cdf0e10cSrcweir 	void PrintError( ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() );
118*cdf0e10cSrcweir     void InsertLine( GSILine* pLine, const ByteString aSourceLang);
119*cdf0e10cSrcweir     void SetReferenceLine( GSILine* pLine );
120*cdf0e10cSrcweir 	sal_Bool CheckSyntax( sal_uLong nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags );
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	void WriteError( LazySvFileStream &aErrOut, sal_Bool bRequireSourceLine );
123*cdf0e10cSrcweir 	void WriteCorrect( LazySvFileStream &aOkOut, sal_Bool bRequireSourceLine );
124*cdf0e10cSrcweir     void WriteFixed( LazySvFileStream &aFixOut, sal_Bool bRequireSourceLine );
125*cdf0e10cSrcweir };
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir #endif
128*cdf0e10cSrcweir 
129