merged tag ooo/OOO330_m14
[LibreOffice.git] / l10ntools / inc / gsicheck.hxx
blobfb1eecd38c825a4f4291b7613100a278a8d6d57c
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"
34 // class GSILine
36 enum LineFormat { FORMAT_GSI, FORMAT_SDF, FORMAT_UNKNOWN };
38 class GSILine : public ByteString
40 private:
42 ParserMessageList aMessages;
43 LineFormat aFormat;
44 ULONG nLineNumber;
46 ByteString aUniqId;
47 ByteString aLineType;
48 ByteString aLangId;
49 ByteString aText;
50 ByteString aQuickHelpText;
51 ByteString aTitle;
53 BOOL bOK;
54 BOOL bFixed;
56 void ReassembleLine();
58 public:
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; }
80 void NotOK();
82 BOOL IsFixed() const { return bFixed; }
83 void SetFixed() { bFixed = TRUE; };
87 // class GSIBlock
90 DECLARE_LIST( GSIBlock_Impl, GSILine * )
92 class LazySvFileStream;
94 class GSIBlock : public GSIBlock_Impl
96 private:
97 GSILine *pSourceLine;
98 GSILine *pReferenceLine;
99 void PrintList( ParserMessageList *pList, ByteString aPrefix, GSILine *pLine );
100 BOOL bPrintContext;
101 BOOL bCheckSourceLang;
102 BOOL bCheckTranslationLang;
103 BOOL bReference;
104 BOOL bAllowKeyIDs;
105 BOOL bAllowSuspicious;
107 BOOL bHasBlockError;
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 );
113 public:
114 GSIBlock( BOOL PbPrintContext, BOOL bSource, BOOL bTrans, BOOL bRef, BOOL bAllowKID, BOOL bAllowSusp );
115 ~GSIBlock();
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 );
127 #endif