1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _GSICHECK_HXX_ 25 #define _GSICHECK_HXX_ 26 27 #include "tagtest.hxx" 28 29 // 30 // class GSILine 31 // 32 enum LineFormat { FORMAT_GSI, FORMAT_SDF, FORMAT_UNKNOWN }; 33 34 class GSILine : public ByteString 35 { 36 private: 37 38 ParserMessageList aMessages; 39 LineFormat aFormat; 40 sal_uLong nLineNumber; 41 42 ByteString aUniqId; 43 ByteString aLineType; 44 ByteString aLangId; 45 ByteString aText; 46 ByteString aQuickHelpText; 47 ByteString aTitle; 48 49 sal_Bool bOK; 50 sal_Bool bFixed; 51 52 void ReassembleLine(); 53 54 public: 55 GSILine( const ByteString &rLine, sal_uLong nLine ); GetLineFormat() const56 LineFormat GetLineFormat() const { return aFormat; } GetLineNumber() const57 sal_uLong GetLineNumber() const { return nLineNumber; } 58 GetUniqId() const59 ByteString const GetUniqId() const { return aUniqId; } GetLineType() const60 ByteString const GetLineType() const { return aLineType; } GetLanguageId() const61 ByteString const GetLanguageId() const { return aLangId; } GetText() const62 ByteString const GetText() const { return aText; } GetUText() const63 String const GetUText() const { return String( aText, RTL_TEXTENCODING_UTF8 ); } GetQuickHelpText() const64 ByteString const GetQuickHelpText() const { return aQuickHelpText; } GetTitle() const65 ByteString const GetTitle() const { return aTitle; } 66 SetUText(String & aNew)67 void SetUText( String &aNew ) { aText = ByteString( aNew, RTL_TEXTENCODING_UTF8 ); ReassembleLine(); } SetText(ByteString & aNew)68 void SetText( ByteString &aNew ) { aText = aNew; ReassembleLine(); } SetQuickHelpText(ByteString & aNew)69 void SetQuickHelpText( ByteString &aNew ) { aQuickHelpText = aNew; ReassembleLine(); } SetTitle(ByteString & aNew)70 void SetTitle( ByteString &aNew ) { aTitle = aNew; ReassembleLine(); } 71 GetMessageList()72 ParserMessageList* GetMessageList() { return &aMessages; }; HasMessages()73 sal_Bool HasMessages(){ return ( aMessages.Count() > 0 ); }; 74 IsOK() const75 sal_Bool IsOK() const { return bOK; } 76 void NotOK(); 77 IsFixed() const78 sal_Bool IsFixed() const { return bFixed; } SetFixed()79 void SetFixed() { bFixed = sal_True; }; 80 }; 81 82 // 83 // class GSIBlock 84 // 85 86 DECLARE_LIST( GSIBlock_Impl, GSILine * ) 87 88 class LazySvFileStream; 89 90 class GSIBlock : public GSIBlock_Impl 91 { 92 private: 93 GSILine *pSourceLine; 94 GSILine *pReferenceLine; 95 void PrintList( ParserMessageList *pList, ByteString aPrefix, GSILine *pLine ); 96 sal_Bool bPrintContext; 97 sal_Bool bCheckSourceLang; 98 sal_Bool bCheckTranslationLang; 99 sal_Bool bReference; 100 sal_Bool bAllowKeyIDs; 101 sal_Bool bAllowSuspicious; 102 103 sal_Bool bHasBlockError; 104 105 sal_Bool IsUTF8( const ByteString &aTestee, sal_Bool bFixTags, sal_uInt16 &nErrorPos, ByteString &aErrorMsg, sal_Bool &bHasBeenFixed, ByteString &aFixed ) const; 106 sal_Bool TestUTF8( GSILine* pTestee, sal_Bool bFixTags ); 107 sal_Bool HasSuspiciousChars( GSILine* pTestee, GSILine* pSource ); 108 109 public: 110 GSIBlock( sal_Bool PbPrintContext, sal_Bool bSource, sal_Bool bTrans, sal_Bool bRef, sal_Bool bAllowKID, sal_Bool bAllowSusp ); 111 ~GSIBlock(); 112 void PrintMessage( ByteString aType, ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() ); 113 void PrintError( ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() ); 114 void InsertLine( GSILine* pLine, const ByteString aSourceLang); 115 void SetReferenceLine( GSILine* pLine ); 116 sal_Bool CheckSyntax( sal_uLong nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags ); 117 118 void WriteError( LazySvFileStream &aErrOut, sal_Bool bRequireSourceLine ); 119 void WriteCorrect( LazySvFileStream &aOkOut, sal_Bool bRequireSourceLine ); 120 void WriteFixed( LazySvFileStream &aFixOut, sal_Bool bRequireSourceLine ); 121 }; 122 123 #endif 124 125