1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _GSICHECK_HXX_
29 #define _GSICHECK_HXX_
31 #include "tagtest.hxx"
36 enum LineFormat
{ FORMAT_GSI
, FORMAT_SDF
, FORMAT_UNKNOWN
};
38 class GSILine
: public ByteString
42 ParserMessageList aMessages
;
50 ByteString aQuickHelpText
;
56 void ReassembleLine();
59 GSILine( const ByteString
&rLine
, ULONG nLine
);
60 LineFormat
GetLineFormat() const { return aFormat
; }
61 ULONG
GetLineNumber() const { return nLineNumber
; }
63 ByteString
const GetUniqId() const { return aUniqId
; }
64 ByteString
const GetLineType() const { return aLineType
; }
65 ByteString
const GetLanguageId() const { return aLangId
; }
66 ByteString
const GetText() const { return aText
; }
67 String
const GetUText() const { return String( aText
, RTL_TEXTENCODING_UTF8
); }
68 ByteString
const GetQuickHelpText() const { return aQuickHelpText
; }
69 ByteString
const GetTitle() const { return aTitle
; }
71 void SetUText( String
&aNew
) { aText
= ByteString( aNew
, RTL_TEXTENCODING_UTF8
); ReassembleLine(); }
72 void SetText( ByteString
&aNew
) { aText
= aNew
; ReassembleLine(); }
73 void SetQuickHelpText( ByteString
&aNew
) { aQuickHelpText
= aNew
; ReassembleLine(); }
74 void SetTitle( ByteString
&aNew
) { aTitle
= aNew
; ReassembleLine(); }
76 ParserMessageList
* GetMessageList() { return &aMessages
; };
77 BOOL
HasMessages(){ return ( aMessages
.Count() > 0 ); };
79 BOOL
IsOK() const { return bOK
; }
82 BOOL
IsFixed() const { return bFixed
; }
83 void SetFixed() { bFixed
= TRUE
; };
90 DECLARE_LIST( GSIBlock_Impl
, GSILine
* )
92 class LazySvFileStream
;
94 class GSIBlock
: public GSIBlock_Impl
98 GSILine
*pReferenceLine
;
99 void PrintList( ParserMessageList
*pList
, ByteString aPrefix
, GSILine
*pLine
);
101 BOOL bCheckSourceLang
;
102 BOOL bCheckTranslationLang
;
105 BOOL bAllowSuspicious
;
109 BOOL
IsUTF8( const ByteString
&aTestee
, BOOL bFixTags
, USHORT
&nErrorPos
, ByteString
&aErrorMsg
, BOOL
&bHasBeenFixed
, ByteString
&aFixed
) const;
110 BOOL
TestUTF8( GSILine
* pTestee
, BOOL bFixTags
);
111 BOOL
HasSuspiciousChars( GSILine
* pTestee
, GSILine
* pSource
);
114 GSIBlock( BOOL PbPrintContext
, BOOL bSource
, BOOL bTrans
, BOOL bRef
, BOOL bAllowKID
, BOOL bAllowSusp
);
116 void PrintMessage( ByteString aType
, ByteString aMsg
, ByteString aPrefix
, ByteString aContext
, ULONG nLine
, ByteString aUniqueId
= ByteString() );
117 void PrintError( ByteString aMsg
, ByteString aPrefix
, ByteString aContext
, ULONG nLine
, ByteString aUniqueId
= ByteString() );
118 void InsertLine( GSILine
* pLine
, const ByteString aSourceLang
);
119 void SetReferenceLine( GSILine
* pLine
);
120 BOOL
CheckSyntax( ULONG nLine
, BOOL bRequireSourceLine
, BOOL bFixTags
);
122 void WriteError( LazySvFileStream
&aErrOut
, BOOL bRequireSourceLine
);
123 void WriteCorrect( LazySvFileStream
&aOkOut
, BOOL bRequireSourceLine
);
124 void WriteFixed( LazySvFileStream
&aFixOut
, BOOL bRequireSourceLine
);