1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 #ifndef _GSICHECK_HXX_ 29 #define _GSICHECK_HXX_ 30 31 #include "tagtest.hxx" 32 33 // 34 // class GSILine 35 // 36 enum LineFormat { FORMAT_GSI, FORMAT_SDF, FORMAT_UNKNOWN }; 37 38 class GSILine : public ByteString 39 { 40 private: 41 42 ParserMessageList aMessages; 43 LineFormat aFormat; 44 sal_uLong nLineNumber; 45 46 ByteString aUniqId; 47 ByteString aLineType; 48 ByteString aLangId; 49 ByteString aText; 50 ByteString aQuickHelpText; 51 ByteString aTitle; 52 53 sal_Bool bOK; 54 sal_Bool bFixed; 55 56 void ReassembleLine(); 57 58 public: 59 GSILine( const ByteString &rLine, sal_uLong nLine ); 60 LineFormat GetLineFormat() const { return aFormat; } 61 sal_uLong GetLineNumber() const { return nLineNumber; } 62 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; } 70 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(); } 75 76 ParserMessageList* GetMessageList() { return &aMessages; }; 77 sal_Bool HasMessages(){ return ( aMessages.Count() > 0 ); }; 78 79 sal_Bool IsOK() const { return bOK; } 80 void NotOK(); 81 82 sal_Bool IsFixed() const { return bFixed; } 83 void SetFixed() { bFixed = sal_True; }; 84 }; 85 86 // 87 // class GSIBlock 88 // 89 90 DECLARE_LIST( GSIBlock_Impl, GSILine * ) 91 92 class LazySvFileStream; 93 94 class GSIBlock : public GSIBlock_Impl 95 { 96 private: 97 GSILine *pSourceLine; 98 GSILine *pReferenceLine; 99 void PrintList( ParserMessageList *pList, ByteString aPrefix, GSILine *pLine ); 100 sal_Bool bPrintContext; 101 sal_Bool bCheckSourceLang; 102 sal_Bool bCheckTranslationLang; 103 sal_Bool bReference; 104 sal_Bool bAllowKeyIDs; 105 sal_Bool bAllowSuspicious; 106 107 sal_Bool bHasBlockError; 108 109 sal_Bool IsUTF8( const ByteString &aTestee, sal_Bool bFixTags, sal_uInt16 &nErrorPos, ByteString &aErrorMsg, sal_Bool &bHasBeenFixed, ByteString &aFixed ) const; 110 sal_Bool TestUTF8( GSILine* pTestee, sal_Bool bFixTags ); 111 sal_Bool HasSuspiciousChars( GSILine* pTestee, GSILine* pSource ); 112 113 public: 114 GSIBlock( sal_Bool PbPrintContext, sal_Bool bSource, sal_Bool bTrans, sal_Bool bRef, sal_Bool bAllowKID, sal_Bool bAllowSusp ); 115 ~GSIBlock(); 116 void PrintMessage( ByteString aType, ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() ); 117 void PrintError( ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() ); 118 void InsertLine( GSILine* pLine, const ByteString aSourceLang); 119 void SetReferenceLine( GSILine* pLine ); 120 sal_Bool CheckSyntax( sal_uLong nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags ); 121 122 void WriteError( LazySvFileStream &aErrOut, sal_Bool bRequireSourceLine ); 123 void WriteCorrect( LazySvFileStream &aOkOut, sal_Bool bRequireSourceLine ); 124 void WriteFixed( LazySvFileStream &aFixOut, sal_Bool bRequireSourceLine ); 125 }; 126 127 #endif 128 129