1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: gsicheck.hxx,v $
10 * $Revision: 1.8.22.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _GSICHECK_HXX_
32 #define _GSICHECK_HXX_
34 #include "tagtest.hxx"
39 enum LineFormat
{ FORMAT_GSI
, FORMAT_SDF
, FORMAT_UNKNOWN
};
41 class GSILine
: public ByteString
45 ParserMessageList aMessages
;
53 ByteString aQuickHelpText
;
59 void ReassembleLine();
62 GSILine( const ByteString
&rLine
, ULONG nLine
);
63 LineFormat
GetLineFormat() const { return aFormat
; }
64 ULONG
GetLineNumber() const { return nLineNumber
; }
66 ByteString
const GetUniqId() const { return aUniqId
; }
67 ByteString
const GetLineType() const { return aLineType
; }
68 ByteString
const GetLanguageId() const { return aLangId
; }
69 ByteString
const GetText() const { return aText
; }
70 String
const GetUText() const { return String( aText
, RTL_TEXTENCODING_UTF8
); }
71 ByteString
const GetQuickHelpText() const { return aQuickHelpText
; }
72 ByteString
const GetTitle() const { return aTitle
; }
74 void SetUText( String
&aNew
) { aText
= ByteString( aNew
, RTL_TEXTENCODING_UTF8
); ReassembleLine(); }
75 void SetText( ByteString
&aNew
) { aText
= aNew
; ReassembleLine(); }
76 void SetQuickHelpText( ByteString
&aNew
) { aQuickHelpText
= aNew
; ReassembleLine(); }
77 void SetTitle( ByteString
&aNew
) { aTitle
= aNew
; ReassembleLine(); }
79 ParserMessageList
* GetMessageList() { return &aMessages
; };
80 BOOL
HasMessages(){ return ( aMessages
.Count() > 0 ); };
82 BOOL
IsOK() const { return bOK
; }
85 BOOL
IsFixed() const { return bFixed
; }
86 void SetFixed() { bFixed
= TRUE
; };
93 DECLARE_LIST( GSIBlock_Impl
, GSILine
* )
95 class LazySvFileStream
;
97 class GSIBlock
: public GSIBlock_Impl
100 GSILine
*pSourceLine
;
101 GSILine
*pReferenceLine
;
102 void PrintList( ParserMessageList
*pList
, ByteString aPrefix
, GSILine
*pLine
);
104 BOOL bCheckSourceLang
;
105 BOOL bCheckTranslationLang
;
108 BOOL bAllowSuspicious
;
112 BOOL
IsUTF8( const ByteString
&aTestee
, BOOL bFixTags
, USHORT
&nErrorPos
, ByteString
&aErrorMsg
, BOOL
&bHasBeenFixed
, ByteString
&aFixed
) const;
113 BOOL
TestUTF8( GSILine
* pTestee
, BOOL bFixTags
);
114 BOOL
HasSuspiciousChars( GSILine
* pTestee
, GSILine
* pSource
);
117 GSIBlock( BOOL PbPrintContext
, BOOL bSource
, BOOL bTrans
, BOOL bRef
, BOOL bAllowKID
, BOOL bAllowSusp
);
119 void PrintMessage( ByteString aType
, ByteString aMsg
, ByteString aPrefix
, ByteString aContext
, ULONG nLine
, ByteString aUniqueId
= ByteString() );
120 void PrintError( ByteString aMsg
, ByteString aPrefix
, ByteString aContext
, ULONG nLine
, ByteString aUniqueId
= ByteString() );
121 void InsertLine( GSILine
* pLine
, const ByteString aSourceLang
);
122 void SetReferenceLine( GSILine
* pLine
);
123 BOOL
CheckSyntax( ULONG nLine
, BOOL bRequireSourceLine
, BOOL bFixTags
);
125 void WriteError( LazySvFileStream
&aErrOut
, BOOL bRequireSourceLine
);
126 void WriteCorrect( LazySvFileStream
&aOkOut
, BOOL bRequireSourceLine
);
127 void WriteFixed( LazySvFileStream
&aFixOut
, BOOL bRequireSourceLine
);