diff options
Diffstat (limited to 'l10ntools/inc')
-rw-r--r-- | l10ntools/inc/cfgmerge.hxx | 217 | ||||
-rw-r--r-- | l10ntools/inc/export.hxx | 570 | ||||
-rw-r--r-- | l10ntools/inc/gsicheck.hxx | 132 | ||||
-rw-r--r-- | l10ntools/inc/helpmerge.hxx | 86 | ||||
-rw-r--r-- | l10ntools/inc/l10ntools/directory.hxx | 56 | ||||
-rw-r--r-- | l10ntools/inc/l10ntools/file.hxx | 25 | ||||
-rw-r--r-- | l10ntools/inc/l10ntools/vosapp.hxx | 33 | ||||
-rw-r--r-- | l10ntools/inc/lngmerge.hxx | 70 | ||||
-rw-r--r-- | l10ntools/inc/makefile.mk | 47 | ||||
-rw-r--r-- | l10ntools/inc/pch/precompiled_l10ntools.cxx | 31 | ||||
-rw-r--r-- | l10ntools/inc/pch/precompiled_l10ntools.hxx | 34 | ||||
-rw-r--r-- | l10ntools/inc/srciter.hxx | 60 | ||||
-rw-r--r-- | l10ntools/inc/tagtest.hxx | 374 | ||||
-rw-r--r-- | l10ntools/inc/tokens.h | 112 | ||||
-rw-r--r-- | l10ntools/inc/wtranode.hxx | 120 | ||||
-rw-r--r-- | l10ntools/inc/wtratree.hxx | 161 | ||||
-rw-r--r-- | l10ntools/inc/xmlparse.hxx | 527 | ||||
-rw-r--r-- | l10ntools/inc/xmlutil.hxx | 11 | ||||
-rw-r--r-- | l10ntools/inc/xrmmerge.hxx | 160 |
19 files changed, 2826 insertions, 0 deletions
diff --git a/l10ntools/inc/cfgmerge.hxx b/l10ntools/inc/cfgmerge.hxx new file mode 100644 index 000000000000..c8f3d99a7b14 --- /dev/null +++ b/l10ntools/inc/cfgmerge.hxx @@ -0,0 +1,217 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CFG_MERGE_HXX +#define _CFG_MERGE_HXX + +#include <tools/string.hxx> +#include <boost/unordered_map.hpp> +#include <vector> + +typedef boost::unordered_map<rtl::OString, rtl::OString, rtl::OStringHash> ByteStringHashMap; + + +// +// class CfgStackData +// + +class CfgStackData +{ +friend class CfgParser; +friend class CfgExport; +friend class CfgMerge; +private: + ByteString sTagType; + ByteString sIdentifier; + + ByteString sResTyp; + + ByteString sTextTag; + ByteString sEndTextTag; + + ByteStringHashMap sText; +public: + CfgStackData( const ByteString &rTag, const ByteString &rId ) + : sTagType( rTag ), sIdentifier( rId ) {}; + + ByteString &GetTagType() { return sTagType; } + ByteString &GetIdentifier() { return sIdentifier; } + +}; + +// +// class CfgStack +// + +typedef ::std::vector< CfgStackData* > CfgStackList; + +class CfgStack +{ +private: + CfgStackList maList; + +public: + CfgStack() {} + ~CfgStack(); + + size_t Push( CfgStackData *pStackData ); + CfgStackData *Push( const ByteString &rTag, const ByteString &rId ); + CfgStackData *Pop() + { + if ( maList.empty() ) return NULL; + CfgStackData* temp = maList.back(); + maList.pop_back(); + return temp; + } + + CfgStackData *GetStackData( size_t nPos = LIST_APPEND ); + + ByteString GetAccessPath( size_t nPos = LIST_APPEND ); + + size_t size() const { return maList.size(); } +}; + +// +// class CfgParser +// + +class CfgParser +{ +protected: + ByteString sCurrentResTyp; + ByteString sCurrentIsoLang; + ByteString sCurrentText; + + ByteString sLastWhitespace; + + CfgStack aStack; + CfgStackData *pStackData; + + sal_Bool bLocalize; + + virtual void WorkOnText( + ByteString &rText, + const ByteString &nLangIndex )=0; + + virtual void WorkOnRessourceEnd()=0; + + virtual void Output( const ByteString& rOutput )=0; + + void Error( const ByteString &rError ); + +private: + int ExecuteAnalyzedToken( int nToken, char *pToken ); + std::vector<ByteString> aLanguages; + void AddText( + ByteString &rText, + const ByteString &rIsoLang, + const ByteString &rResTyp ); + +sal_Bool IsTokenClosed( const ByteString &rToken ); + +public: + CfgParser(); + virtual ~CfgParser(); + + int Execute( int nToken, char * pToken ); +}; + +// +// class CfgOutputParser +// + +class CfgOutputParser : public CfgParser +{ +protected: + SvFileStream *pOutputStream; +public: + CfgOutputParser ( const ByteString &rOutputFile ); + virtual ~CfgOutputParser(); +}; + +// +// class CfgExport +// + +class CfgExport : public CfgOutputParser +{ +private: + ByteString sPrj; + ByteString sPath; + std::vector<ByteString> aLanguages; +protected: + void WorkOnText( + ByteString &rText, + const ByteString &rIsoLang + ); + + void WorkOnRessourceEnd(); + void Output( const ByteString& rOutput ); +public: + CfgExport( + const ByteString &rOutputFile, + const ByteString &rProject, + const ByteString &rFilePath + ); + ~CfgExport(); +}; + +// +// class CfgMerge +// + +class CfgMerge : public CfgOutputParser +{ +private: + MergeDataFile *pMergeDataFile; + std::vector<ByteString> aLanguages; + ResData *pResData; + + ByteString sFilename; + sal_Bool bEnglish; + +protected: + void WorkOnText( + ByteString &rText, + const ByteString &nLangIndex ); + + void WorkOnRessourceEnd(); + + void Output( const ByteString& rOutput ); +public: + CfgMerge( + const ByteString &rMergeSource, + const ByteString &rOutputFile, + ByteString &rFilename + ); + ~CfgMerge(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx new file mode 100644 index 000000000000..c33960fa8468 --- /dev/null +++ b/l10ntools/inc/export.hxx @@ -0,0 +1,570 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _EXPORT_HXX +#define _EXPORT_HXX + +#ifndef L10NTOOLS_DIRECTORY_HXX +#define L10NTOOLS_DIRECTORY_HXX +#include <l10ntools/directory.hxx> +#endif + +#include <tools/string.hxx> +#include <tools/stream.hxx> +#include <tools/fsys.hxx> +#include <osl/file.hxx> +#include <osl/file.h> + +#include <boost/unordered_map.hpp> +#include <iterator> /* std::iterator*/ +#include <set> /* std::set*/ +#include <vector> /* std::vector*/ +#include <queue> +#include <string> + +#include <unistd.h> +#ifdef WNT +#include <direct.h> +#endif + +#define NO_TRANSLATE_ISO "x-no-translate" + +#define JAPANESE_ISO "ja" + + +struct eqstr{ + sal_Bool operator()(const char* s1, const char* s2) const{ + return strcmp(s1,s2)==0; + } +}; + +struct equalByteString{ + bool operator()( const ByteString& rKey1, const ByteString& rKey2 ) const { + return rKey1.CompareTo( rKey2 )==COMPARE_EQUAL; + } +}; +struct lessByteString{ + bool operator()( const ByteString& rKey1, const ByteString& rKey2 ) const { + return rKey1.CompareTo( rKey2 )==COMPARE_LESS; + } +}; + +struct hashByteString{ + size_t operator()( const ByteString& rName ) const{ + return rtl_str_hashCode_WithLength(rName.GetBuffer(), rName.Len() ); + } +}; + +class PFormEntrys; +class MergeData; +typedef std::set<ByteString , lessByteString > ByteStringSet; + +typedef boost::unordered_map<rtl::OString, rtl::OString, rtl::OStringHash> ByteStringHashMap; + +typedef boost::unordered_map<ByteString , bool , hashByteString,equalByteString> + ByteStringBoolHashMap; + +typedef boost::unordered_map<ByteString , PFormEntrys* , hashByteString,equalByteString> + PFormEntrysHashMap; + +typedef boost::unordered_map<ByteString , MergeData* , hashByteString,equalByteString> + MergeDataHashMap; + +#define SOURCE_LANGUAGE ByteString("en-US") +#define LIST_REFID "LIST_REFID" + +typedef ByteStringHashMap ExportListEntry; +typedef ::std::vector< ExportListEntry* > ExportListBase; + +// +// class ExportList +// + +class ExportList +{ +private: + ExportListBase maList; + sal_uLong nSourceLanguageListEntryCount; + +public: + ExportList() { nSourceLanguageListEntryCount = 0; } + sal_uLong GetSourceLanguageListEntryCount() { return nSourceLanguageListEntryCount; } + void NewSourceLanguageListEntry() { nSourceLanguageListEntryCount++; } + size_t size() const { return maList.size(); } + void push_back( ExportListEntry* item ) { maList.push_back( item ); } + + ExportListEntry* operator [] ( size_t i ) + { + return ( i < maList.size() ) ? maList[ i ] : NULL; + } +}; + +#define REFID_NONE 0xFFFF + +// +// struct ResData +// + +/****************************************************************************** +* Purpose: holds mandatory data to export a single res (used with ResStack) +******************************************************************************/ + +#define ID_LEVEL_NULL 0x0000 +#define ID_LEVEL_AUTOID 0x0001 +#define ID_LEVEL_TEXT 0x0002 +#define ID_LEVEL_FIELDNAME 0x0003 +#define ID_LEVEL_ACCESSPATH 0x0004 +#define ID_LEVEL_IDENTIFIER 0x0005 +#define ID_LEVEL_LISTINDEX 0x0006 + +class ResData +{ +public: + ~ResData(); + sal_Bool SetId( const ByteString &rId, sal_uInt16 nLevel ); + + sal_uInt16 nWidth; + sal_uInt16 nChildIndex; + sal_uInt16 nIdLevel; + sal_Bool bChild; + sal_Bool bChildWithText; + + sal_Bool bText; + sal_Bool bHelpText; + sal_Bool bQuickHelpText; + sal_Bool bTitle; + sal_Bool bList; + + sal_Bool bRestMerged; + + ByteString sResTyp; + ByteString sId; + ByteString sGId; + ByteString sHelpId; + ByteString sFilename; + + ByteStringHashMap sText; + sal_uInt16 nTextRefId; + + ByteStringHashMap sHelpText; + sal_uInt16 nHelpTextRefId; + + ByteStringHashMap sQuickHelpText; + sal_uInt16 nQuickHelpTextRefId; + + ByteStringHashMap sTitle; + sal_uInt16 nTitleRefId; + + ByteString sTextTyp; + ByteStringHashMap aFallbackData; + ByteStringHashMap aMergedLanguages; + + ExportList *pStringList; + ExportList *pUIEntries; + ExportList *pItemList; + ExportList *pFilterList; + ExportList *pPairedList; + + ByteString sPForm; + + void Dump(); + void addFallbackData( ByteString& sId , const ByteString& sText ); + bool getFallbackData( ByteString& sId , ByteString& sText); + + void addMergedLanguage(rtl::OString& rLang); + bool isMerged(rtl::OString& rLang); + ResData( const ByteString &rPF, const ByteString &rGId ) + : + nWidth( 0 ), + nChildIndex( 0 ), + nIdLevel( ID_LEVEL_NULL ), + bChild( sal_False ), + bChildWithText( sal_False ), + bText( sal_False ), + bHelpText( sal_False ), + bQuickHelpText( sal_False ), + bTitle( sal_False ), + bList( sal_False ), + bRestMerged( sal_False ), + sGId( rGId ), + nTextRefId( REFID_NONE ), + nHelpTextRefId( REFID_NONE ), + nQuickHelpTextRefId( REFID_NONE ), + nTitleRefId( REFID_NONE ), + sTextTyp( "Text" ), + pStringList( NULL ), + pUIEntries( NULL ), + pItemList( NULL ), + pFilterList( NULL ), + pPairedList( NULL ), + sPForm( rPF ) + { + sGId.EraseAllChars( '\r' ); + sPForm.EraseAllChars( '\r' ); + }; + ResData( const ByteString &rPF, const ByteString &rGId , const ByteString &rFilename ) + : + nChildIndex( 0 ), + nIdLevel( ID_LEVEL_NULL ), + bChild( sal_False ), + bChildWithText( sal_False ), + bText( sal_False ), + bHelpText( sal_False ), + bQuickHelpText( sal_False ), + bTitle( sal_False ), + bList( sal_False ), + bRestMerged( sal_False ), + sGId( rGId ), + sFilename( rFilename ), + nTextRefId( REFID_NONE ), + nHelpTextRefId( REFID_NONE ), + nQuickHelpTextRefId( REFID_NONE ), + nTitleRefId( REFID_NONE ), + sTextTyp( "Text" ), + pStringList( NULL ), + pUIEntries( NULL ), + pItemList( NULL ), + pFilterList( NULL ), + pPairedList( NULL ), + sPForm( rPF ) + + { + sGId.EraseAllChars( '\r' ); + sPForm.EraseAllChars( '\r' ); + }; + + +}; + + +// +// class Export +// + +/****************************************************************************** +* Purpose: syntax check and export of *.src, called from lexer +******************************************************************************/ + +#define LIST_NON 0x0000 +#define LIST_STRING 0x0001 +#define LIST_FILTER 0x0002 +#define LIST_ITEM 0x0004 +#define LIST_PAIRED 0x0005 +#define LIST_UIENTRIES 0x0008 +#define STRING_TYP_TEXT 0x0010 +#define STRING_TYP_HELPTEXT 0x0020 +#define STRING_TYP_QUICKHELPTEXT 0x0040 +#define STRING_TYP_TITLE 0x0080 + +#define MERGE_MODE_NORMAL 0x0000 +#define MERGE_MODE_LIST 0x0001 + +typedef ::std::vector< ResData* > ResStack; +// forwards +class WordTransformer; +class ParserQueue; + +class Export +{ +private: + WordTransformer *pWordTransformer; + + CharSet aCharSet; // used charset in src + + SvFileStream aOutput; + + ResStack aResStack; // stack for parsing recursive + + ByteString sActPForm; // hold cur. system + + sal_Bool bDefine; // cur. res. in a define? + sal_Bool bNextMustBeDefineEOL; // define but no \ at lineend + sal_uLong nLevel; // res. recursiv? how deep? + sal_uInt16 nList; // cur. res. is String- or FilterList + rtl::OString m_sListLang; + sal_uLong nListIndex; + sal_uLong nListLevel; + bool bSkipFile; + ByteString sProject; + ByteString sRoot; + sal_Bool bEnableExport; + sal_Bool bMergeMode; + ByteString sMergeSrc; + ByteString sLastListLine; + sal_Bool bError; // any errors while export? + sal_Bool bReadOver; + sal_Bool bDontWriteOutput; + ByteString sLastTextTyp; + static bool isInitialized; + ByteString sFilename; + + +public: + ParserQueue* pParseQueue; // public ? + static ByteString sLanguages; // public ? + static ByteString sForcedLanguages; // public ? + + + static bool skipProject( ByteString sPrj ) ; + static void InitLanguages( bool bMergeMode = false ); + static void InitForcedLanguages( bool bMergeMode = false ); + static std::vector<ByteString> GetLanguages(); + static std::vector<ByteString> GetForcedLanguages(); + + static void SetLanguages( std::vector<ByteString> val ); + static void RemoveUTF8ByteOrderMarker( ByteString &rString ); + static bool hasUTF8ByteOrderMarker( const ByteString &rString ); + static void RemoveUTF8ByteOrderMarkerFromFile( const ByteString &rFilename ); + static bool fileHasUTF8ByteOrderMarker( const ByteString &rString ); + static void QuotHTML( ByteString &rString ); + static bool CopyFile( const ByteString& source , const ByteString& dest ); + + static void UnquotHTML( ByteString &rString ); + + static const char* GetEnv( const char *pVar ); + + static bool isSourceLanguage( const ByteString &sLanguage ); + static bool isAllowed( const ByteString &sLanguage ); + + static void Languages( std::vector<ByteString>::const_iterator& begin , std::vector<ByteString>::const_iterator& end ); + static void getRandomName( const ByteString& sPrefix , ByteString& sRandStr , const ByteString& sPostfix ); + static void getCurrentDir( std::string& dir ); + + static ByteString GetFallbackLanguage( const ByteString nLanguage ); + static void FillInFallbacks( ResData *pResData ); + static void FillInListFallbacks( ExportList *pList, const ByteString &nSource, const ByteString &nFallback ); + static ByteString GetTimeStamp(); + static sal_Bool ConvertLineEnds( ByteString sSource, ByteString sDestination ); + static ByteString GetNativeFile( ByteString sSource ); + static DirEntry GetTempFile(); + + static void DumpExportList( ByteString& sListName , ExportList& aList ); + static ByteString DumpMap( ByteString& sMapName , ByteStringHashMap& aMap ); + +private: + static std::vector<ByteString> aLanguages; + static std::vector<ByteString> aForcedLanguages; + + sal_Bool WriteData( ResData *pResData, sal_Bool bCreateNew = sal_False );// called befor dest. cur ResData + sal_Bool WriteExportList( ResData *pResData, ExportList *pExportList, + const ByteString &rTyp, sal_Bool bCreateNew = sal_False ); + + ByteString MergePairedList( ByteString& sLine , ByteString& sText ); + + ByteString FullId(); // creates cur. GID + + bool PairedListFallback( ByteString& sText , ResData& aResData ); + + ByteString GetPairedListID ( const ByteString& sText ); + ByteString GetPairedListString ( const ByteString& sText ); + ByteString StripList ( const ByteString& sText ); + + void InsertListEntry( const ByteString &rText, const ByteString &rLine ); + void CleanValue( ByteString &rValue ); + ByteString GetText( const ByteString &rSource, int nToken ); + + sal_Bool PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp, + rtl::OString &rLangIndex, ResData *pResData); + + void MergeRest( ResData *pResData, sal_uInt16 nMode = MERGE_MODE_NORMAL ); + void ConvertMergeContent( ByteString &rText ); + + void WriteToMerged( const ByteString &rText , bool bSDFContent ); + void SetChildWithText(); + + void CutComment( ByteString &rText ); + +public: + Export( const ByteString &rOutput, sal_Bool bWrite, + const ByteString &rPrj, const ByteString &rPrjRoot , const ByteString& rFile ); + Export( const ByteString &rOutput, sal_Bool bWrite, + const ByteString &rPrj, const ByteString &rPrjRoot, + const ByteString &rMergeSource , const ByteString& rFile ); + ~Export(); + + void Init(); + int Execute( int nToken, const char * pToken ); // called from lexer + void SetError() { bError = sal_True; } + sal_Bool GetError() { return bError; } +}; + + +// +// class PFormEntrys +// + +/****************************************************************************** +* Purpose: holds information of data to merge (one pform) +******************************************************************************/ + +class PFormEntrys : public ByteString +{ +friend class MergeDataFile; +private: + ByteString sHelpText; // empty string + ByteStringHashMap sText; + ByteStringBoolHashMap bTextFirst; + ByteStringHashMap sQuickHelpText; + ByteStringBoolHashMap bQuickHelpTextFirst; + ByteStringHashMap sTitle; + ByteStringBoolHashMap bTitleFirst; + +public: + PFormEntrys( const ByteString &rPForm ) : ByteString( rPForm ) {}; + ByteString Dump(); + void InsertEntry( + const ByteString &nId , + const ByteString &rText, + const ByteString &rQuickHelpText, + const ByteString &rTitle + ) + { + + sText[ nId ] = rText; + bTextFirst[ nId ] = true; + sQuickHelpText[ nId ] = rQuickHelpText; + bQuickHelpTextFirst[ nId ] = true; + sTitle[ nId ] = rTitle; + bTitleFirst[ nId ] = true; + } + sal_Bool GetText( ByteString &rReturn, sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel = sal_False ); + sal_Bool GetTransex3Text( ByteString &rReturn, sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel = sal_False ); + +}; + +// +// class MergeData +// + +/****************************************************************************** +* Purpose: holds information of data to merge (one ressource) +******************************************************************************/ + +class MergeDataFile; + +class MergeData +{ +friend class MergeDataFile; +private: + ByteString sTyp; + ByteString sGID; + ByteString sLID; + ByteString sFilename; + PFormEntrysHashMap aMap; +public: + MergeData( const ByteString &rTyp, const ByteString &rGID, const ByteString &rLID , const ByteString &rFilename ) + : sTyp( rTyp ), sGID( rGID ), sLID( rLID ) , sFilename( rFilename ) {}; + ~MergeData(); + PFormEntrys* GetPFormEntrys( ResData *pResData ); + + void Insert( const ByteString& rPFO , PFormEntrys* pfEntrys ); + PFormEntrys* GetPFObject( const ByteString& rPFO ); + + ByteString Dump(); + sal_Bool operator==( ResData *pData ); +}; + +// +// class MergeDataFile +// + +/****************************************************************************** +* Purpose: holds information of data to merge +******************************************************************************/ + +class MergeDataFile +{ + private: + sal_Bool bErrorLog; + ByteString sErrorLog; + SvFileStream aErrLog; + MergeDataHashMap aMap; + std::set<ByteString> aLanguageSet; + + MergeData *GetMergeData( ResData *pResData , bool bCaseSensitve = false ); + void InsertEntry( const ByteString &rTYP, const ByteString &rGID, const ByteString &rLID, + const ByteString &rPFO, + const ByteString &nLang, const ByteString &rTEXT, + const ByteString &rQHTEXT, const ByteString &rTITLE, + const ByteString &sFilename, bool bCaseSensitive + ); + ByteString Dump(); + public: + MergeDataFile( const ByteString &rFileName, const ByteString& rFile , sal_Bool bErrLog, CharSet aCharSet, bool bCaseSensitive = false ); + ~MergeDataFile(); + + + std::vector<ByteString> GetLanguages(); + + PFormEntrys *GetPFormEntrys( ResData *pResData ); + PFormEntrys *GetPFormEntrysCaseSensitive( ResData *pResData ); + + static ByteString CreateKey( const ByteString& rTYP , const ByteString& rGID , const ByteString& rLID , const ByteString& rFilename , bool bCaseSensitive = false ); +}; + + +class QueueEntry +{ +public: + QueueEntry( int nTypVal , ByteString sLineVal ): nTyp( nTypVal ) , sLine( sLineVal ){}; + int nTyp; + ByteString sLine; +}; + +class ParserQueue +{ +public: + + ParserQueue( Export& aExportObj ); + ~ParserQueue(); + + inline void Push( const QueueEntry& aEntry ); + bool bCurrentIsM; // public ? + bool bNextIsM; // public ? + bool bLastWasM; // public ? + bool bMflag; // public ? + + void Close(); +private: + // Future / Next + std::queue<QueueEntry>* aQueueNext; + // Current + std::queue<QueueEntry>* aQueueCur; + // Ref + std::queue<QueueEntry>* aQref; + + Export& aExport; + bool bStart; + bool bStartNext; + + inline void Pop( std::queue<QueueEntry>& aQueue ); + +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/gsicheck.hxx b/l10ntools/inc/gsicheck.hxx new file mode 100644 index 000000000000..971f85016fbd --- /dev/null +++ b/l10ntools/inc/gsicheck.hxx @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _GSICHECK_HXX_ +#define _GSICHECK_HXX_ + +#include "tagtest.hxx" +#include <vector> + +// +// class GSILine +// +enum LineFormat { FORMAT_GSI, FORMAT_SDF, FORMAT_UNKNOWN }; + +class GSILine : public ByteString +{ +private: + + ParserMessageList aMessages; + LineFormat aFormat; + sal_uLong nLineNumber; + + ByteString aUniqId; + ByteString aLineType; + ByteString aLangId; + ByteString aText; + ByteString aQuickHelpText; + ByteString aTitle; + + sal_Bool bOK; + sal_Bool bFixed; + + void ReassembleLine(); + +public: + GSILine( const ByteString &rLine, sal_uLong nLine ); + LineFormat GetLineFormat() const { return aFormat; } + sal_uLong GetLineNumber() const { return nLineNumber; } + + ByteString const GetUniqId() const { return aUniqId; } + ByteString const GetLineType() const { return aLineType; } + ByteString const GetLanguageId() const { return aLangId; } + ByteString const GetText() const { return aText; } + String const GetUText() const { return String( aText, RTL_TEXTENCODING_UTF8 ); } + ByteString const GetQuickHelpText() const { return aQuickHelpText; } + ByteString const GetTitle() const { return aTitle; } + + void SetUText( String &aNew ) { aText = ByteString( aNew, RTL_TEXTENCODING_UTF8 ); ReassembleLine(); } + void SetText( ByteString &aNew ) { aText = aNew; ReassembleLine(); } + void SetQuickHelpText( ByteString &aNew ) { aQuickHelpText = aNew; ReassembleLine(); } + void SetTitle( ByteString &aNew ) { aTitle = aNew; ReassembleLine(); } + + ParserMessageList* GetMessageList() { return &aMessages; }; + sal_Bool HasMessages(){ return ( aMessages.size() > 0 ); }; + + sal_Bool IsOK() const { return bOK; } + void NotOK(); + + sal_Bool IsFixed() const { return bFixed; } + void SetFixed() { bFixed = sal_True; }; +}; + +// +// class GSIBlock +// + +typedef ::std::vector< GSILine* > GSIBlock_Impl; + +class LazySvFileStream; + +class GSIBlock +{ +private: + GSIBlock_Impl maList; + GSILine *pSourceLine; + GSILine *pReferenceLine; + void PrintList( ParserMessageList *pList, ByteString aPrefix, GSILine *pLine ); + sal_Bool bPrintContext; + sal_Bool bCheckSourceLang; + sal_Bool bCheckTranslationLang; + sal_Bool bReference; + sal_Bool bAllowKeyIDs; + sal_Bool bAllowSuspicious; + + sal_Bool bHasBlockError; + + sal_Bool IsUTF8( const ByteString &aTestee, sal_Bool bFixTags, sal_uInt16 &nErrorPos, ByteString &aErrorMsg, sal_Bool &bHasBeenFixed, ByteString &aFixed ) const; + sal_Bool TestUTF8( GSILine* pTestee, sal_Bool bFixTags ); + sal_Bool HasSuspiciousChars( GSILine* pTestee, GSILine* pSource ); + +public: + GSIBlock( sal_Bool PbPrintContext, sal_Bool bSource, sal_Bool bTrans, sal_Bool bRef, sal_Bool bAllowKID, sal_Bool bAllowSusp ); + ~GSIBlock(); + void PrintMessage( ByteString aType, ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() ); + void PrintError( ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() ); + void InsertLine( GSILine* pLine, const ByteString aSourceLang); + void SetReferenceLine( GSILine* pLine ); + sal_Bool CheckSyntax( sal_uLong nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags ); + + void WriteError( LazySvFileStream &aErrOut, sal_Bool bRequireSourceLine ); + void WriteCorrect( LazySvFileStream &aOkOut, sal_Bool bRequireSourceLine ); + void WriteFixed( LazySvFileStream &aFixOut, sal_Bool bRequireSourceLine ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/helpmerge.hxx b/l10ntools/inc/helpmerge.hxx new file mode 100644 index 000000000000..25536244e357 --- /dev/null +++ b/l10ntools/inc/helpmerge.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// local includes +#include "export.hxx" +#include "xmlparse.hxx" +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> +#include <rtl/strbuf.hxx> +#include <memory> /* auto_ptr */ +#include "tools/isofallback.hxx" + +#define MOVEFILE_REPLACE_EXISTING 0x01 + +/// This Class is responsible for extracting/merging OpenOffice XML Helpfiles +class HelpParser +{ +private: + ByteString sHelpFile; + bool bUTF8; + bool bHasInputList; + +/// Copy fallback language String (ENUS,DE) into position of the numeric language iso code +/// @PRECOND 0 < langIdx_in < MAX_IDX + static void FillInFallbacks( LangHashMap& rElem_out, ByteString sLangIdx_in ); + +#if OSL_DEBUG_LEVEL > 2 + /// Debugmethod, prints the content of the map to stdout + static void Dump(LangHashMap* rElem_in , const ByteString sKey_in); + + /// Debugmethod, prints the content of the map to stdout + static void Dump(XMLHashMap* rElem_in); +#endif + +public: + HelpParser( const ByteString &rHelpFile, bool bUTF8 , bool bHasInputList ); + ~HelpParser(){}; + +/// Method creates/append a SDF file with the content of a parsed XML file +/// @PRECOND rHelpFile is valid + static bool CreateSDF( const ByteString &rSDFFile_in, const ByteString &rPrj_in, const ByteString &rRoot_in, + const ByteString &sHelpFile, XMLFile *pXmlFile, const ByteString &rGsi1 ); + + static void parse_languages( std::vector<ByteString>& aLanguages , MergeDataFile& aMergeDataFile ); + +/// Method merges the String from the SDFfile into XMLfile. Both Strings must +/// point to existing files. + bool Merge( const ByteString &rSDFFile_in, const ByteString &rDestinationFile_in , ByteString& sLanguage , MergeDataFile& aMergeDataFile ); + bool Merge( const ByteString &rSDFFile, const ByteString &rPathX , const ByteString &rPathY , bool bISO + , const std::vector<ByteString>& aLanguages , MergeDataFile& aMergeDataFile , bool bCreateDir ); + +private: + static ByteString makeAbsolutePath( const ByteString& sHelpFile , const ByteString& rRoot_in ); + + ByteString GetOutpath( const ByteString& rPathX , const ByteString& sCur , const ByteString& rPathY ); + bool MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile , const ByteString& sLanguage , ByteString sPath ); + + void ProcessHelp( LangHashMap* aLangHM , const ByteString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile ); + void MakeDir( const ByteString& sPath ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/l10ntools/directory.hxx b/l10ntools/inc/l10ntools/directory.hxx new file mode 100644 index 000000000000..34e4a3a0cc65 --- /dev/null +++ b/l10ntools/inc/l10ntools/directory.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#include <vector> +#include <algorithm> +#include <rtl/ustring.hxx> +#include <tools/string.hxx> + +#ifdef WNT +#else +#include <dirent.h> +#include <unistd.h> +#include <sys/stat.h> +#endif + +#include <stdio.h> + +#ifndef L10NTOOLS_FILE_HXX +#define L10NTOOLS_FILE_HXX +#include <l10ntools/file.hxx> +#endif + +namespace transex{ + +class Directory +{ + private: + rtl::OUString sDirectoryName; + rtl::OUString sFullName; + bool bSkipLinks; + + std::vector<Directory> aDirVec; + std::vector<File> aFileVec; + + public: + std::vector<Directory> getSubDirectories() { return aDirVec; } + std::vector<File> getFiles() { return aFileVec; } + + void readDirectory(); + void readDirectory( const rtl::OUString& sFullpath ); + void scanSubDir( int nLevels = 0 ); + + rtl::OUString getDirectoryName() { return sDirectoryName; } + rtl::OUString getFullName() { return sFullName ; } + void setSkipLinks( bool is_skipped ); + + void dump(); + Directory(){}; + + Directory( const rtl::OUString sFullPath ); + Directory( const rtl::OUString sFullPath , const rtl::OUString sEntry ) ; + + static bool lessDir ( const Directory& rKey1, const Directory& rKey2 ) ; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/l10ntools/file.hxx b/l10ntools/inc/l10ntools/file.hxx new file mode 100644 index 000000000000..fae252e5f926 --- /dev/null +++ b/l10ntools/inc/l10ntools/file.hxx @@ -0,0 +1,25 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#include "rtl/ustring.hxx" + +namespace transex +{ + +class File +{ + private: + rtl::OUString sFileName; + rtl::OUString sFullName; + + public: + rtl::OUString getFileName(){ return sFileName; } + rtl::OUString getFullName(){ return sFullName; } + + File( const rtl::OUString sFullName , const rtl::OUString sFile ); + + static bool lessFile ( const File& rKey1, const File& rKey2 ); + +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/l10ntools/vosapp.hxx b/l10ntools/inc/l10ntools/vosapp.hxx new file mode 100644 index 000000000000..e8e97fb71fef --- /dev/null +++ b/l10ntools/inc/l10ntools/vosapp.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#ifndef VOSAPP_HXX +#define VOSAPP_HXX + +#include <sal/main.h> +#include <tools/solar.h> +#include <tools/string.hxx> + +// Mininmal vcl/svapp compatibility without vcl dependence +class Application +{ +public: + sal_uInt16 GetCommandLineParamCount(); + XubString GetCommandLineParam( sal_uInt16 nParam ); + virtual void Main() = 0; +}; + +// Urg: Cut & Paste from svapp.cxx: we don't want to depend on vcl +sal_uInt16 Application::GetCommandLineParamCount() +{ + return osl_getCommandArgCount(); +} + +XubString Application::GetCommandLineParam( sal_uInt16 nParam ) +{ + rtl::OUString aParam; + osl_getCommandArg( nParam, &aParam.pData ); + return XubString( aParam ); +} + +#endif /* VOSAPP_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/lngmerge.hxx b/l10ntools/inc/lngmerge.hxx new file mode 100644 index 000000000000..8aaf98d3d782 --- /dev/null +++ b/l10ntools/inc/lngmerge.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// local includes +#include "export.hxx" +#include <vector> + +typedef ::std::vector< ByteString* > LngLineList; + +#define LNG_OK 0x0000 +#define LNG_FILE_NOTFOUND 0x0001 +#define LNG_COULD_NOT_OPEN 0x0002 +#define SDF_OK 0x0003 +#define SDF_FILE_NOTFOUND 0x0004 +#define SDF_COULD_NOT_OPEN 0x0005 + +// +// class LngParser +// + +class LngParser +{ +private: + sal_uInt16 nError; + LngLineList *pLines; + ByteString sSource; + sal_Bool bDBIsUTF8; + sal_Bool bULF; + bool bQuiet; + std::vector<ByteString> aLanguages; + + void FillInFallbacks( ByteStringHashMap Text ); + bool isNextGroup( ByteString &sGroup_out , ByteString &sLine_in); + void ReadLine( const ByteString &sLine_in , ByteStringHashMap &rText_inout ); + void WriteSDF( SvFileStream &aSDFStream , ByteStringHashMap &rText_inout , + const ByteString &rPrj , + const ByteString &rRoot , const ByteString &sActFileName , const ByteString &sID ); +public: + LngParser( const ByteString &rLngFile, sal_Bool bUTF8, sal_Bool bULFFormat ); + ~LngParser(); + + sal_Bool CreateSDF( const ByteString &rSDFFile, const ByteString &rPrj, const ByteString &rRoot ); + sal_Bool Merge( const ByteString &rSDFFile, const ByteString &rDestinationFile , const ByteString &rPrj ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/makefile.mk b/l10ntools/inc/makefile.mk new file mode 100644 index 000000000000..ce0925c51b26 --- /dev/null +++ b/l10ntools/inc/makefile.mk @@ -0,0 +1,47 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=.. + +PRJNAME=l10ntools +TARGET=inc + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + +.IF "$(ENABLE_PCH)"!="" +ALLTAR : \ + $(SLO)$/precompiled.pch \ + $(SLO)$/precompiled_ex.pch + +.ENDIF # "$(ENABLE_PCH)"!="" + diff --git a/l10ntools/inc/pch/precompiled_l10ntools.cxx b/l10ntools/inc/pch/precompiled_l10ntools.cxx new file mode 100644 index 000000000000..227eec55ca55 --- /dev/null +++ b/l10ntools/inc/pch/precompiled_l10ntools.cxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_l10ntools.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/pch/precompiled_l10ntools.hxx b/l10ntools/inc/pch/precompiled_l10ntools.hxx new file mode 100644 index 000000000000..876028762f2e --- /dev/null +++ b/l10ntools/inc/pch/precompiled_l10ntools.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): Generated on 2006-09-01 17:50:15.326479 + +#ifdef PRECOMPILED_HEADERS +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/srciter.hxx b/l10ntools/inc/srciter.hxx new file mode 100644 index 000000000000..c859d2356c1a --- /dev/null +++ b/l10ntools/inc/srciter.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef L10NTOOLS_DIRECTORY_HXX +#define L10NTOOLS_DIRECTORY_HXX +#include <l10ntools/directory.hxx> +#endif + +// class SourceTreeIterator +// + +class SourceTreeIterator +{ +private: + transex::Directory aRootDirectory; + bool bInExecute; + + void ExecuteDirectory( transex::Directory& pDirectory ); + +protected: + bool bLocal; + bool bSkipLinks; + +public: + SourceTreeIterator( const ByteString &rRootDirectory, const ByteString &rVersion , bool bLocal_in = false); + virtual ~SourceTreeIterator(); + + sal_Bool StartExecute(); + void EndExecute(); + + virtual void OnExecuteDirectory( const rtl::OUString &rDirectory ); +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/tagtest.hxx b/l10ntools/inc/tagtest.hxx new file mode 100644 index 000000000000..1a41f508533f --- /dev/null +++ b/l10ntools/inc/tagtest.hxx @@ -0,0 +1,374 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _TAGTEST_HXX_ +#define _TAGTEST_HXX_ + +#include <tools/string.hxx> +#include <boost/unordered_map.hpp> +#include <vector> + +class GSILine; + +typedef sal_uInt16 TokenId; + +#define TOK_INVALIDPOS sal_uInt16( 0xFFFF ) + +class ParserMessage; +typedef ::std::vector< ParserMessage* > Impl_ParserMessageList; + +class ParserMessageList; + +struct equalByteString{ + bool operator()( const ByteString& rKey1, const ByteString& rKey2 ) const { + return rKey1.CompareTo( rKey2 )==COMPARE_EQUAL; + } +}; +struct lessByteString{ + bool operator()( const ByteString& rKey1, const ByteString& rKey2 ) const { + return rKey1.CompareTo( rKey2 )==COMPARE_LESS; + } +}; + +struct hashByteString{ + size_t operator()( const ByteString& rName ) const{ + return rtl_str_hashCode(rName.GetBuffer()); + } +}; + +typedef boost::unordered_map<ByteString , String , hashByteString,equalByteString> + StringHashMap; + +class TokenInfo +{ +private: + void SplitTag( ParserMessageList &rErrorList ); + + String aTagName; + StringHashMap aProperties; + sal_Bool bClosed; // tag is closed <sdnf/> + sal_Bool bCloseTag; // tag is close Tag </sdnf> + + + sal_Bool bIsBroken; + sal_Bool bHasBeenFixed; + sal_Bool bDone; + +public: + + String aTokenString; + TokenId nId; + sal_uInt16 nPos; // Position in String + + TokenInfo():bClosed(sal_False),bCloseTag(sal_False),bIsBroken(sal_False),bHasBeenFixed(sal_False),bDone(sal_False),nId( 0 ){;} +explicit TokenInfo( TokenId pnId, sal_uInt16 nP ):bClosed(sal_False),bCloseTag(sal_False),bIsBroken(sal_False),bHasBeenFixed(sal_False),bDone(sal_False),nId( pnId ),nPos(nP){;} +explicit TokenInfo( TokenId pnId, sal_uInt16 nP, String paStr ):bClosed(sal_False),bCloseTag(sal_False),bIsBroken(sal_False),bHasBeenFixed(sal_False),bDone(sal_False),aTokenString( paStr ),nId( pnId ),nPos(nP) {;} +explicit TokenInfo( TokenId pnId, sal_uInt16 nP, String paStr, ParserMessageList &rErrorList ); + + String GetTagName() const; + + String MakeTag() const; + + /** + Is the property to be ignored or does it have the default value anyways + **/ + sal_Bool IsPropertyRelevant( const ByteString &aName, const String &aValue ) const; + sal_Bool IsPropertyValueValid( const ByteString &aName, const String &aValue ) const; + /** + Does the property contain the same value for all languages + e.g.: the href in a link tag + **/ + sal_Bool IsPropertyInvariant( const ByteString &aName, const String &aValue ) const; + /** + a subset of IsPropertyInvariant but containing only those that are fixable + we dont wat to fix e.g.: ahelp :: visibility + **/ + sal_Bool IsPropertyFixable( const ByteString &aName ) const; + sal_Bool MatchesTranslation( TokenInfo& rInfo, sal_Bool bGenErrors, ParserMessageList &rErrorList, sal_Bool bFixTags = sal_False ) const; + + sal_Bool IsDone() const { return bDone; } + void SetDone( sal_Bool bNew = sal_True ) { bDone = bNew; } + + sal_Bool HasBeenFixed() const { return bHasBeenFixed; } + void SetHasBeenFixed( sal_Bool bNew = sal_True ) { bHasBeenFixed = bNew; } +}; + + +class ParserMessageList +{ +private: + Impl_ParserMessageList maList; + +public: + ~ParserMessageList() { clear(); } + void AddError( sal_uInt16 nErrorNr, ByteString aErrorText, const TokenInfo &rTag ); + void AddWarning( sal_uInt16 nErrorNr, ByteString aErrorText, const TokenInfo &rTag ); + + sal_Bool HasErrors(); + bool empty() const { return maList.empty(); } + size_t size() const { return maList.size(); } + ParserMessage* operator [] ( size_t i ) { return ( i < maList.size() ) ? maList[ i ] : NULL; } + void clear(); +}; + + +#define TAG_GROUPMASK 0xF000 +#define TAG_GROUPSHIFT 12 + +#define TAG_GROUP( nTag ) (( nTag & TAG_GROUPMASK ) >> TAG_GROUPSHIFT ) +#define TAG_NOGROUP( nTag ) ( nTag & ~TAG_GROUPMASK ) // ~ = Bitweises NOT + +#define TAG_NOMORETAGS 0x0 + +#define TAG_GROUP_FORMAT 0x1 +#define TAG_ON 0x100 +#define TAG_BOLDON ( TAG_GROUP_FORMAT << TAG_GROUPSHIFT | TAG_ON | 0x001 ) +#define TAG_BOLDOFF ( TAG_GROUP_FORMAT << TAG_GROUPSHIFT | 0x001 ) +#define TAG_ITALICON ( TAG_GROUP_FORMAT << TAG_GROUPSHIFT | TAG_ON | 0x002 ) +#define TAG_ITALICOFF ( TAG_GROUP_FORMAT << TAG_GROUPSHIFT | 0x002 ) +#define TAG_UNDERLINEON ( TAG_GROUP_FORMAT << TAG_GROUPSHIFT | TAG_ON | 0x004 ) +#define TAG_UNDERLINEOFF ( TAG_GROUP_FORMAT << TAG_GROUPSHIFT | 0x004 ) + +#define TAG_GROUP_NOTALLOWED 0x2 +#define TAG_HELPID ( TAG_GROUP_NOTALLOWED << TAG_GROUPSHIFT | 0x001 ) +#define TAG_MODIFY ( TAG_GROUP_NOTALLOWED << TAG_GROUPSHIFT | 0x002 ) +#define TAG_REFNR ( TAG_GROUP_NOTALLOWED << TAG_GROUPSHIFT | 0x004 ) + +#define TAG_GROUP_STRUCTURE 0x3 +#define TAG_NAME ( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x001 ) +#define TAG_HREF ( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x002 ) +#define TAG_AVIS ( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x004 ) +#define TAG_AHID ( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x008 ) + +#define TAG_TITEL ( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x020 ) +#define TAG_KEY ( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x040 ) +#define TAG_INDEX ( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x080 ) + +#define TAG_REFSTART ( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x100 ) + +#define TAG_GRAPHIC ( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x200 ) +#define TAG_NEXTVERSION ( TAG_GROUP_STRUCTURE << TAG_GROUPSHIFT | 0x400 ) + +#define TAG_GROUP_SYSSWITCH 0x4 +#define TAG_WIN ( TAG_GROUP_SYSSWITCH << TAG_GROUPSHIFT | 0x001 ) +#define TAG_UNIX ( TAG_GROUP_SYSSWITCH << TAG_GROUPSHIFT | 0x002 ) +#define TAG_MAC ( TAG_GROUP_SYSSWITCH << TAG_GROUPSHIFT | 0x004 ) +#define TAG_OS2 ( TAG_GROUP_SYSSWITCH << TAG_GROUPSHIFT | 0x008 ) + +#define TAG_GROUP_PROGSWITCH 0x5 +#define TAG_WRITER ( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x001 ) +#define TAG_CALC ( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x002 ) +#define TAG_DRAW ( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x004 ) +#define TAG_IMPRESS ( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x008 ) +#define TAG_SCHEDULE ( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x010 ) +#define TAG_IMAGE ( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x020 ) +#define TAG_MATH ( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x040 ) +#define TAG_CHART ( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x080 ) +#define TAG_OFFICE ( TAG_GROUP_PROGSWITCH << TAG_GROUPSHIFT | 0x100 ) + + +#define TAG_GROUP_META 0x6 +#define TAG_OFFICEFULLNAME ( TAG_GROUP_META << TAG_GROUPSHIFT | 0x001 ) +#define TAG_OFFICENAME ( TAG_GROUP_META << TAG_GROUPSHIFT | 0x002 ) +#define TAG_OFFICEPATH ( TAG_GROUP_META << TAG_GROUPSHIFT | 0x004 ) +#define TAG_OFFICEVERSION ( TAG_GROUP_META << TAG_GROUPSHIFT | 0x008 ) +#define TAG_PORTALNAME ( TAG_GROUP_META << TAG_GROUPSHIFT | 0x010 ) +#define TAG_PORTALFULLNAME ( TAG_GROUP_META << TAG_GROUPSHIFT | 0x020 ) +#define TAG_PORTALPATH ( TAG_GROUP_META << TAG_GROUPSHIFT | 0x040 ) +#define TAG_PORTALVERSION ( TAG_GROUP_META << TAG_GROUPSHIFT | 0x080 ) +#define TAG_PORTALSHORTNAME ( TAG_GROUP_META << TAG_GROUPSHIFT | 0x100 ) + + +#define TAG_GROUP_SINGLE 0x7 +#define TAG_REFINSERT ( TAG_GROUP_SINGLE << TAG_GROUPSHIFT | 0x001 ) + + +#define TAG_GROUP_MULTI 0x8 +#define TAG_END ( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x010 ) +#define TAG_ELSE ( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x020 ) +#define TAG_AEND ( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x040 ) +#define TAG_VERSIONEND ( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x080 ) +#define TAG_ENDGRAPHIC ( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x100 ) + +#define TAG_GROUP_MISC 0x9 +#define TAG_COMMONSTART ( TAG_GROUP_MISC << TAG_GROUPSHIFT | 0x001 ) +#define TAG_COMMONEND ( TAG_GROUP_MISC << TAG_GROUPSHIFT | 0x002 ) + +#define TAG_UNKNOWN_TAG ( TAG_GROUP_MULTI << TAG_GROUPSHIFT | 0x800 ) + +typedef ::std::vector< TokenInfo* > TokenListImpl; + +class TokenList +{ +private: + TokenListImpl maList; + TokenList& operator =( const TokenList& rList ); + +public: + TokenList() {}; + ~TokenList(){ clear(); }; + + size_t size() const { return maList.size(); } + void clear() + { + for ( size_t i = 0 ; i < maList.size() ; i++ ) + delete maList[ i ]; + maList.clear(); + } + + void insert( TokenInfo p, size_t nIndex = size_t(-1) ) + { + if ( nIndex < maList.size() ) { + TokenListImpl::iterator it = maList.begin(); + ::std::advance( it, nIndex ); + maList.insert( it, new TokenInfo(p) ); + } else { + maList.push_back( new TokenInfo(p) ); + } + } + TokenInfo& operator [] ( size_t nIndex ) const + { + return *maList[ nIndex ]; + } + + TokenList( const TokenList& rList ); +}; + +class ParserMessage +{ + sal_uInt16 nErrorNr; + ByteString aErrorText; + sal_uInt16 nTagBegin,nTagLength; + +protected: + ParserMessage( sal_uInt16 PnErrorNr, ByteString PaErrorText, const TokenInfo &rTag ); +public: + + sal_uInt16 GetErrorNr() { return nErrorNr; } + ByteString GetErrorText() { return aErrorText; } + + sal_uInt16 GetTagBegin() { return nTagBegin; } + sal_uInt16 GetTagLength() { return nTagLength; } + + virtual ~ParserMessage() {} + virtual sal_Bool IsError() =0; + virtual ByteString Prefix() =0; +}; + +class ParserError : public ParserMessage +{ +public: + ParserError( sal_uInt16 PnErrorNr, ByteString PaErrorText, const TokenInfo &rTag ); + + virtual sal_Bool IsError() {return sal_True;}; + virtual ByteString Prefix() {return "Error:"; }; +}; + +class ParserWarning : public ParserMessage +{ +public: + ParserWarning( sal_uInt16 PnErrorNr, ByteString PaErrorText, const TokenInfo &rTag ); + + virtual sal_Bool IsError() {return sal_False;}; + virtual ByteString Prefix() {return "Warning:"; }; +}; + +class SimpleParser +{ +private: + sal_uInt16 nPos; + String aSource; + String aLastToken; + TokenList aTokenList; + + TokenInfo aNextTag; // to store closetag in case of combined tags like <br/> + + String GetNextTokenString( ParserMessageList &rErrorList, sal_uInt16 &rTokeStartPos ); + +public: + SimpleParser(); + void Parse( String PaSource ); + TokenInfo GetNextToken( ParserMessageList &rErrorList ); + static String GetLexem( TokenInfo const &aToken ); + TokenList& GetTokenList(){ return aTokenList; } +}; + +class TokenParser +{ + sal_Bool match( const TokenInfo &aCurrentToken, const TokenId &aExpectedToken ); + sal_Bool match( const TokenInfo &aCurrentToken, const TokenInfo &aExpectedToken ); + void ParseError( sal_uInt16 nErrNr, ByteString aErrMsg, const TokenInfo &rTag ); + void Paragraph(); + void PfCase(); + void PfCaseBegin(); + void AppCase(); + void AppCaseBegin(); + void CaseEnd(); + void SimpleTag(); + void TagPair(); + void TagRef(); + + SimpleParser aParser; + TokenInfo aTag; + + TokenId nPfCaseOptions; + TokenId nAppCaseOptions; + sal_Bool bPfCaseActive ,bAppCaseActive; + + TokenId nActiveRefTypes; + + ParserMessageList *pErrorList; + +public: + TokenParser(); + void Parse( const String &aCode, ParserMessageList* pList ); + TokenList& GetTokenList(){ return aParser.GetTokenList(); } +}; + +class LingTest +{ +private: + TokenParser aReferenceParser; + TokenParser aTesteeParser; + ParserMessageList aCompareWarningList; + void CheckTags( TokenList &aReference, TokenList &aTestee, sal_Bool bFixTags ); + sal_Bool IsTagMandatory( TokenInfo const &aToken, TokenId &aMetaTokens ); + String aFixedTestee; +public: + void CheckReference( GSILine *aReference ); + void CheckTestee( GSILine *aTestee, sal_Bool bHasSourceLine, sal_Bool bFixTags ); + + ParserMessageList& GetCompareWarnings(){ return aCompareWarningList; } + sal_Bool HasCompareWarnings(){ return ( !aCompareWarningList.empty() ); } + + String GetFixedTestee(){ return aFixedTestee; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/tokens.h b/l10ntools/inc/tokens.h new file mode 100644 index 000000000000..b8c658ee0c14 --- /dev/null +++ b/l10ntools/inc/tokens.h @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _TOKENS_H +#define _TOKENS_H + +/*------------------------------------------------------ */ +/*------------------------------------------------------ */ +/* Tokens for parsing src files */ +/*------------------------------------------------------ */ +/*------------------------------------------------------ */ +#define IGNOREDTOKENS 400 /* #include | #pragma | //... | ... */ +#define COMMEND 401 /*... */ +#define DEFINEDRES 402 /* Text = { */ +#define ANYTOKEN 404 /* XYZ */ +#define UNKNOWNTOKEN 405 /* XYZ[ \t]$ */ +#define UNKNOWNCONSTRUCTION 406 /* XYZ ( xxx, yyy, zzz ) */ +#define UNKNOWNCHAR 407 /* . */ +/*------------------------------------------------------ */ +/* prev. tokens will not be executed */ +#define FILTER_LEVEL 500 +/* following tokens will be executed */ +/*------------------------------------------------------ */ +#define CONDITION 501 /* #if... | #endif ... | ... */ +#define EMPTYLINE 502 /* */ +#define RESSOURCE 503 /* Menu MID_TEST */ +#define RESSOURCEEXPR 504 /* Menu ( MID_TEST + .. ) */ +#define SMALRESSOURCE 505 /* PageItem { */ +#define TEXTLINE 506 /* TEXT = "hhh" */ +#define LONGTEXTLINE 507 /* TEXT = "hhh" TEST "HHH" ... */ +#define TEXT 508 /* "Something like this" */ +#define LEVELUP 509 /* { */ +#define LEVELDOWN 510 /* }; */ +#define APPFONTMAPPING 511 /* MAP_APPFONT(10,10) */ +#define ASSIGNMENT 512 /* Somathing = Anything */ +#define LISTASSIGNMENT 513 /* ...List [xyz]=... */ +#define LISTTEXT 514 /* < "Text" ... > */ +#define RSCDEFINE 515 /* #define MY_TEXT */ +#define RSCDEFINELEND 516 /* */ +#define NEWTEXTINRES 517 /* ### Achtung : Ne... */ +#define UIENTRIES 518 /* UIEntries = { */ +#define PRAGMA 519 /* #pragma ... */ +#define _LISTTEXT 521 /* { "Text" ... } */ +#define TEXTREFID 522 /* Text = 12345 */ +#define LISTRESID 523 /* < 12345; ... > */ +#define _LISTRESID 523 /* { 12345; ... } */ +#define NORMDEFINE 524 /* #define ... */ +/*------------------------------------------------------ */ +/*------------------------------------------------------ */ +/* Tokens for parsing cfg files */ +/*------------------------------------------------------ */ +/*------------------------------------------------------ */ +#define CFG_TAG 501 +#define CFG_TEXT_START 505 +#define CFG_TEXT_END 506 +#define CFG_TEXTCHAR 507 +#define CFG_CLOSETAG 508 +#define CFG_UNKNOWNTAG 509 +#define CFG_TOKEN_PACKAGE 600 +#define CFG_TOKEN_COMPONENT 601 +#define CFG_TOKEN_CONFIGNAME 602 +#define CFG_TOKEN_TEMPLATE 603 +#define CFG_TOKEN_OORNAME 604 +#define CFG_TOKEN_OORVALUE 605 +#define CFG_TOKEN_NO_TRANSLATE 606 + +/*------------------------------------------------------ */ +/*------------------------------------------------------ */ +/* Tokens for parsing xrm files */ +/*------------------------------------------------------ */ +/*------------------------------------------------------ */ +#define XRM_README_START 501 +#define XRM_README_END 502 +#define XRM_SECTION_START 503 +#define XRM_SECTION_END 504 +#define XRM_PARAGRAPH_START 505 +#define XRM_PARAGRAPH_END 506 +#define XRM_TEXT_START 507 +#define XRM_TEXT_END 508 +#define XRM_LIST_START 509 +#define XRM_LIST_END 510 +#define XML_TEXTCHAR 600 + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/wtranode.hxx b/l10ntools/inc/wtranode.hxx new file mode 100644 index 000000000000..b2c10e07d2d2 --- /dev/null +++ b/l10ntools/inc/wtranode.hxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifndef TX3_WTRANODE_HXX +#define TX3_WTRANODE_HXX + +// USED + // Base Classes + // Components + // Parameters +#include <tools/string.hxx> + + +typedef UINT8 BRANCH_T; + + + +const BRANCH_T C_BR_ALPHABASE = 4; +const BRANCH_T C_NR_OF_BRANCHES = 34; + + + + +/** @task + This is a node of the parsing-tree which implements the fuctionality of + class WordTransTree. + WordTransTree is dependant of this class, but NOT the other way! +**/ +class WTT_Node // WordTransTree-Node +{ + public: + enum E_TokenType + { +// no_token = 0, + token_to_keep, + token_to_replace + }; + + // LIFECYCLE + WTT_Node( + UINT8 i_nValue, // Own branch-value. + WTT_Node * i_pDefaultBranch, + WTT_Node * i_pDefaultBranchForAlphas ); + void SetBranch( + UINT8 i_cBranch, + WTT_Node * i_pNode ); + void SetAsTokenToReplace( + const ByteString & i_sReplaceString ); + ~WTT_Node(); + + // OPERATIONS + WTT_Node * GetNextNode( + UINT8 i_cBranch ); /// [0 .. C_NR_OF_BRANCHES-1], sonst GPF !!! + + // INQUIRY + E_TokenType TokenType() const; + UINT8 Value() const; + sal_Bool IsOnDeleting() const; + const ByteString & ReplaceString() const; + + private: + // DATA + UINT8 nValue; + E_TokenType eType; + ByteString sReplaceString; + WTT_Node * aBranches[C_NR_OF_BRANCHES]; // Mostly DYN pointers. + char bIsOnDeleting; +}; + + +inline WTT_Node * +WTT_Node::GetNextNode(UINT8 i_cBranch) + { return aBranches[i_cBranch]; } +inline WTT_Node::E_TokenType +WTT_Node::TokenType() const + { return eType; } +inline UINT8 +WTT_Node::Value() const + { return nValue; } +inline sal_Bool +WTT_Node::IsOnDeleting() const + { return bIsOnDeleting; } +inline const ByteString & +WTT_Node::ReplaceString() const + { return sReplaceString; } + + + + +#endif + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/wtratree.hxx b/l10ntools/inc/wtratree.hxx new file mode 100644 index 000000000000..c06be49b183c --- /dev/null +++ b/l10ntools/inc/wtratree.hxx @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifndef TX3_WTRATREE_HXX +#define TX3_WTRATREE_HXX + +// USED + // Base Classes + // Components + // Parameters +#include <tools/string.hxx> + +const INT16 C_NR_OF_WTT_RESULTS = 5; +const INT16 C_NR_OF_POSSIBLE_CHARS = 256; + + +typedef unsigned char u_char; +typedef const char * constr; + + +class WTT_Node; + + +/** @task + This class implements the functionality, that class WordTransformer + offers. + WordTransformer is dependant of this class, but NOT the other way! +**/ +class WordTransTree +{ + public: + enum E_Result + { + OK = 0, + HOTKEY_LOST, + OUTPUT_OVERFLOW + }; + + + // LIFECYCLE + WordTransTree( + CharSet i_nWorkingCharSet = RTL_TEXTENCODING_MS_1252); + void SetCharSet( + CharSet i_nWorkingCharSet); + ~WordTransTree(); + + void AddWordPair( + const ByteString & i_sOldString, + const ByteString & i_sReplaceString ); + + // OPERATIONS + void InitTransformation( + const char * i_sInput, /// [!=0], a range of i_nInputLength must be valid memory for read. + UINT32 i_nInputLength, + UINT32 i_nOutputMaxLength = STRING_MAXLEN - 12 ); + E_Result TransformNextToken(); + + // INQUIRY + sal_Bool TextEndReached() const; + const char * Output() const; + + // These 3 functions are valid between two calls of + // TransformNextToken(): + E_Result CurResult() const; + ByteString CurReplacedString() const; + ByteString CurReplacingString() const; + char CurHotkey() const; + + private: + // SERVICE FUNCTONS + UINT8 CalculateBranch( + u_char i_cInputChar ) const; + + void Handle_Hotkey(); + void Handle_TokenToKeep(); + void Handle_TokenToTransform(); + + // DATA + // Fixed data + const u_char * sInput; + UINT32 nInputLength; + const u_char * pInputEnd; + + u_char * sOutput; // DYN + UINT32 nOutputMaxLength; + + WTT_Node * dpParsingTreeTop; // DYN + WTT_Node * pUnknownAlpha; + u_char cChar2Branch[C_NR_OF_POSSIBLE_CHARS]; + u_char c_AE, c_OE, c_UE, c_ae, c_oe, c_ue; + + // Working data + const u_char * pInputCurTokenStart; + const u_char * pInputPosition; + u_char * pOutputPosition; + WTT_Node * pCurParseNode; + + // Data which are valid only after a completed call to TransformNextToken() + E_Result eCurResult; + u_char cCurHotkey; // Letter wich is used as hotkey + u_char cCurHotkeySign; // Letter which is used to assign hotkey ('~'or '&') . +}; + + + + + + + +inline sal_Bool +WordTransTree::TextEndReached() const + { return pInputPosition == pInputEnd; } +inline const char * +WordTransTree::Output() const + { return TextEndReached() ? (constr) sOutput : ""; } +inline WordTransTree::E_Result +WordTransTree::CurResult() const + { return eCurResult; } +inline ByteString +WordTransTree::CurReplacedString() const + { return ByteString((constr) pInputCurTokenStart,pInputPosition-pInputCurTokenStart); } +inline char +WordTransTree::CurHotkey() const + { return cCurHotkey; } +inline UINT8 +WordTransTree::CalculateBranch(u_char i_cInputChar) const + { return cChar2Branch[i_cInputChar]; } + + + +#endif + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/xmlparse.hxx b/l10ntools/inc/xmlparse.hxx new file mode 100644 index 000000000000..97e56df59253 --- /dev/null +++ b/l10ntools/inc/xmlparse.hxx @@ -0,0 +1,527 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef BOOTSTRP_XMLPARSE_HXX +#define BOOTSTRP_XMLPARSE_HXX + +#include <signal.h> +#include <expat.h> +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> +#include "tools/string.hxx" +#define ENABLE_BYTESTRING_STREAM_OPERATORS +#include "tools/stream.hxx" +#include "tools/isofallback.hxx" +#include "export.hxx" +#include "xmlutil.hxx" + +#include <fstream> +#include <iostream> + +class XMLParentNode; +class XMLElement; + + +using namespace ::rtl; +using namespace std; + +#include <boost/unordered_map.hpp> +#include <deque> /* std::deque*/ +#include <iterator> /* std::iterator*/ +#include <list> /* std::list*/ +#include <vector> /* std::vector*/ +#define XML_NODE_TYPE_FILE 0x001 +#define XML_NODE_TYPE_ELEMENT 0x002 +#define XML_NODE_TYPE_DATA 0x003 +#define XML_NODE_TYPE_COMMENT 0x004 +#define XML_NODE_TYPE_DEFAULT 0x005 +#define MAX_LANGUAGES 99 + + +//------------------------------------------------------------------------- + +/** Holds data of Attributes + */ +class XMLAttribute : public String +{ +private: + String sValue; + +public: + /// creates an attribute + XMLAttribute( + const String &rName, // attributes name + const String &rValue // attributes data + ) + : String( rName ), sValue( rValue ) {} + + /// getting value of an attribue + const String &GetValue() { return sValue; } + + void setValue(const String &rValue){sValue=rValue;} + + /// returns true if two attributes are equal and have the same value + sal_Bool IsEqual( + const XMLAttribute &rAttribute // the attribute which has to be equal + ) + { + return (( rAttribute == *this ) && ( rAttribute.sValue == sValue )); + } +}; + +typedef ::std::vector< XMLAttribute* > XMLAttributeList; + +//------------------------------------------------------------------------- + +/** Virtual base to handle different kinds of XML nodes + */ +class XMLNode +{ +protected: + XMLNode() {} + +public: + virtual sal_uInt16 GetNodeType() = 0; + virtual ~XMLNode() {} +}; + +//------------------------------------------------------------------------- + +/** Virtual base to handle different kinds of child nodes + */ +class XMLChildNode : public XMLNode +{ +private: + XMLParentNode *pParent; + +protected: + XMLChildNode( XMLParentNode *pPar ); + XMLChildNode():pParent( NULL ){}; + XMLChildNode( const XMLChildNode& obj); + XMLChildNode& operator=(const XMLChildNode& obj); +public: + virtual sal_uInt16 GetNodeType() = 0; + + /// returns the parent of this node + XMLParentNode *GetParent() { return pParent; } + virtual ~XMLChildNode(){}; +}; + +typedef ::std::vector< XMLChildNode* > XMLChildNodeList; + +//------------------------------------------------------------------------- + +/** Virtual base to handle different kinds of parent nodes + */ +class XMLData; + +class XMLParentNode : public XMLChildNode +{ +private: + XMLChildNodeList* pChildList; + static int dbgcnt; + +protected: + XMLParentNode( XMLParentNode *pPar ) + : XMLChildNode( pPar ), pChildList( NULL ) + { + } + XMLParentNode(): pChildList(NULL){ + } + /// Copyconstructor + XMLParentNode( const XMLParentNode& ); + + XMLParentNode& operator=(const XMLParentNode& obj); + virtual ~XMLParentNode(); + + +public: + virtual sal_uInt16 GetNodeType() = 0; + + /// returns child list of this node + XMLChildNodeList *GetChildList() { return pChildList; } + + /// adds a new child + void AddChild( + XMLChildNode *pChild /// the new child + ); + + void AddChild( + XMLChildNode *pChild , size_t pos /// the new child + ); + + virtual int GetPosition( ByteString id ); + int RemoveChild( XMLElement *pRefElement ); + void RemoveAndDeleteAllChilds(); + + /// returns a child element which matches the given one + XMLElement *GetChildElement( + XMLElement *pRefElement // the reference elelement + ); +}; + +//------------------------------------------------------------------------- + +/// Mapping numeric Language code <-> XML Element +typedef boost::unordered_map< ByteString ,XMLElement* , hashByteString,equalByteString > LangHashMap; + +/// Mapping XML Element string identifier <-> Language Map +typedef boost::unordered_map<ByteString , LangHashMap* , + hashByteString,equalByteString> XMLHashMap; + +/// Mapping iso alpha string code <-> iso numeric code +typedef boost::unordered_map<ByteString, int, hashByteString,equalByteString> HashMap; + +/// Mapping XML tag names <-> have localizable strings +typedef boost::unordered_map<ByteString , sal_Bool , + hashByteString,equalByteString> TagMap; + +/** Holds information of a XML file, is root node of tree + */ + + +class XMLFile : public XMLParentNode +{ +public: + XMLFile() ; + XMLFile( + const String &rFileName // the file name, empty if created from memory stream + ); + XMLFile( const XMLFile& obj ) ; + ~XMLFile(); + + ByteString* GetGroupID(std::deque<ByteString> &groupid); + void Print( XMLNode *pCur = NULL, sal_uInt16 nLevel = 0 ); + virtual void SearchL10NElements( XMLParentNode *pCur, int pos = 0 ); + void Extract( XMLFile *pCur = NULL ); + void View(); +// void static Signal_handler(int signo);//void*,oslSignalInfo * pInfo); + void showType(XMLParentNode* node); + + XMLHashMap* GetStrings(){return XMLStrings;} + sal_Bool Write( ByteString &rFilename ); + sal_Bool Write( ofstream &rStream , XMLNode *pCur = NULL ); + + bool CheckExportStatus( XMLParentNode *pCur = NULL );// , int pos = 0 ); + + XMLFile& operator=(const XMLFile& obj); + + virtual sal_uInt16 GetNodeType(); + + /// returns file name + const String &GetName() { return sFileName; } + void SetName( const String &rFilename ) { sFileName = rFilename; } + void SetFullName( const String &rFullFilename ) { sFullName = rFullFilename; } + const std::vector<ByteString> getOrder(){ return order; } + +protected: + // writes a string as UTF8 with dos line ends to a given stream + void WriteString( ofstream &rStream, const String &sString ); + + // quotes the given text for writing to a file + void QuotHTML( String &rString ); + + void InsertL10NElement( XMLElement* pElement); + + // DATA + String sFileName; + String sFullName; + + const ByteString ID,OLDREF,XML_LANG; + + TagMap nodes_localize; + XMLHashMap* XMLStrings; + + std::vector <ByteString> order; +}; + +/// An Utility class for XML +/// See RFC 3066 / #i8252# for ISO codes +class XMLUtil{ + +public: + /// Quot the XML characters and replace \n \t + static void QuotHTML( String &rString ); + + /// UnQuot the XML characters and restore \n \t + static void UnQuotHTML ( String &rString ); +private: + static void UnQuotData( String &rString ); + static void UnQuotTags( String &rString ); +}; + + + +//------------------------------------------------------------------------- + +/** Hold information of an element node + */ +class XMLElement : public XMLParentNode +{ +private: + String sElementName; + XMLAttributeList *pAttributes; + ByteString project, + filename, + id, + sOldRef, + resourceType, + languageId; + int nPos; + +protected: + void Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement); +public: + /// create a element node + XMLElement(){} + XMLElement( + const String &rName, // the element name + XMLParentNode *Parent // parent node of this element + ): XMLParentNode( Parent ), + sElementName( rName ), + pAttributes( NULL ), + project(""), + filename(""), + id(""), + sOldRef(""), + resourceType(""), + languageId(""), + nPos(0) + { + } + ~XMLElement(); + XMLElement(const XMLElement&); + + XMLElement& operator=(const XMLElement& obj); + /// returns node type XML_NODE_ELEMENT + virtual sal_uInt16 GetNodeType(); + + /// returns element name + const String &GetName() { return sElementName; } + + /// returns list of attributes of this element + XMLAttributeList *GetAttributeList() { return pAttributes; } + + /// adds a new attribute to this element, typically used by parser + void AddAttribute( const String &rAttribute, const String &rValue ); + + void ChangeLanguageTag( const String &rValue ); + // Return a ASCII String representation of this object + OString ToOString(); + + // Return a Unicode String representation of this object + OUString ToOUString(); + + bool Equals(OUString refStr); + + /// returns a attribute + XMLAttribute *GetAttribute( + const String &rName // the attribute name + ); + void SetProject ( ByteString prj ){ project = prj; } + void SetFileName ( ByteString fn ){ filename = fn; } + void SetId ( ByteString theId ){ id = theId; } + void SetResourceType ( ByteString rt ){ resourceType = rt; } + void SetLanguageId ( ByteString lid ){ languageId = lid; } + void SetPos ( int nPos_in ){ nPos = nPos_in; } + void SetOldRef ( ByteString sOldRef_in ){ sOldRef = sOldRef_in; } + + virtual int GetPos() { return nPos; } + ByteString GetProject() { return project; } + ByteString GetFileName() { return filename; } + ByteString GetId() { return id; } + ByteString GetOldref() { return sOldRef; } + ByteString GetResourceType(){ return resourceType; } + ByteString GetLanguageId() { return languageId; } + + +}; +//------------------------------------------------------------------------- + + +/** Holds character data + */ +class XMLData : public XMLChildNode +{ +private: + String sData; + bool isNewCreated; + +public: + /// create a data node + XMLData( + const String &rData, // the initial data + XMLParentNode *Parent // the parent node of this data, typically a element node + ) + : XMLChildNode( Parent ), sData( rData ) , isNewCreated ( false ){} + XMLData( + const String &rData, // the initial data + XMLParentNode *Parent, // the parent node of this data, typically a element node + bool newCreated + ) + : XMLChildNode( Parent ), sData( rData ) , isNewCreated ( newCreated ){} + + XMLData(const XMLData& obj); + + XMLData& operator=(const XMLData& obj); + virtual sal_uInt16 GetNodeType(); + + /// returns the data + const String &GetData() { return sData; } + + bool isNew() { return isNewCreated; } + /// adds new character data to the existing one + void AddData( + const String &rData // the new data + ); + + + +}; + +//------------------------------------------------------------------------- + +/** Holds comments + */ +class XMLComment : public XMLChildNode +{ +private: + String sComment; + +public: + /// create a comment node + XMLComment( + const String &rComment, // the comment + XMLParentNode *Parent // the parent node of this comemnt, typically a element node + ) + : XMLChildNode( Parent ), sComment( rComment ) {} + + virtual sal_uInt16 GetNodeType(); + + XMLComment( const XMLComment& obj ); + + XMLComment& operator=(const XMLComment& obj); + + /// returns the comment + const String &GetComment() { return sComment; } +}; + +//------------------------------------------------------------------------- + +/** Holds additional file content like those for which no handler exists + */ +class XMLDefault : public XMLChildNode +{ +private: + String sDefault; + +public: + /// create a comment node + XMLDefault( + const String &rDefault, // the comment + XMLParentNode *Parent // the parent node of this comemnt, typically a element node + ) + : XMLChildNode( Parent ), sDefault( rDefault ) {} + + XMLDefault(const XMLDefault& obj); + + XMLDefault& operator=(const XMLDefault& obj); + + /// returns node type XML_NODE_TYPE_COMMENT + virtual sal_uInt16 GetNodeType(); + + /// returns the comment + const String &GetDefault() { return sDefault; } +}; + +//------------------------------------------------------------------------- + +/** struct for error information, used by class SimpleXMLParser + */ +struct XMLError { + XML_Error eCode; // the error code + sal_uLong nLine; // error line number + sal_uLong nColumn; // error column number + String sMessage; // readable error message +}; + +//------------------------------------------------------------------------- + +/** validating xml parser, creates a document tree with xml nodes + */ + + +class SimpleXMLParser +{ +private: + XML_Parser aParser; + XMLError aErrorInformation; + + XMLFile *pXMLFile; + XMLParentNode *pCurNode; + XMLData *pCurData; + + + static void StartElementHandler( void *userData, const XML_Char *name, const XML_Char **atts ); + static void EndElementHandler( void *userData, const XML_Char *name ); + static void CharacterDataHandler( void *userData, const XML_Char *s, int len ); + static void CommentHandler( void *userData, const XML_Char *data ); + static void DefaultHandler( void *userData, const XML_Char *s, int len ); + + + void StartElement( const XML_Char *name, const XML_Char **atts ); + void EndElement( const XML_Char *name ); + void CharacterData( const XML_Char *s, int len ); + void Comment( const XML_Char *data ); + void Default( const XML_Char *s, int len ); + + +public: + /// creates a new parser + SimpleXMLParser(); + ~SimpleXMLParser(); + + /// parse a file, returns NULL on criticall errors + XMLFile *Execute( + const String &rFullFileName, + const String &rFileName, // the file name + XMLFile *pXMLFileIn // the XMLFile + ); + + /// parse a memory stream, returns NULL on criticall errors + XMLFile *Execute( + SvMemoryStream *pStream // the stream + ); + + /// returns an error struct + const XMLError &GetError() { return aErrorInformation; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/xmlutil.hxx b/l10ntools/inc/xmlutil.hxx new file mode 100644 index 000000000000..2c131a987edf --- /dev/null +++ b/l10ntools/inc/xmlutil.hxx @@ -0,0 +1,11 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#define ENGLISH_US 1 +#define ENGLISH_US_ISO "en-US" +#define ENGLISH_US_PROPERTY "en_US" +#define ENGLISH_US_INDEX 1 +#define GERMAN_DE 4 +#define GERMAN_DE_ISO "x-german" +#define GERMAN_DE_INDEX 3 +#define GERMAN_ISO2 "de-DE" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/xrmmerge.hxx b/l10ntools/inc/xrmmerge.hxx new file mode 100644 index 000000000000..f0b213a54ce3 --- /dev/null +++ b/l10ntools/inc/xrmmerge.hxx @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// global includes +#include <tools/string.hxx> + +// +// XRMResParser +// + +class XRMResParser +{ +private: + ByteString sGID; + ByteString sLID; + + sal_Bool bError; + sal_Bool bText; + + bool sLocalized; + + ByteString sCurrentOpenTag; + ByteString sCurrentCloseTag; + ByteString sCurrentText; + std::vector<ByteString> aLanguages; + +protected: + ByteString GetAttribute( const ByteString &rToken, const ByteString &rAttribute ); + void Error( const ByteString &rError ); + + virtual void Output( const ByteString& rOutput )=0; + virtual void WorkOnText( + const ByteString &rOpenTag, + ByteString &rText + )=0; + virtual void EndOfText( + const ByteString &rOpenTag, + const ByteString &rCloseTag + )=0; + + ByteString GetGID() { return sGID; } + ByteString GetLID() { return sLID; } + + void ConvertStringToDBFormat( ByteString &rString ); + void ConvertStringToXMLFormat( ByteString &rString ); + +public: + XRMResParser(); + virtual ~XRMResParser(); + + int Execute( int nToken, char * pToken ); + + void SetError( sal_Bool bErr = sal_True ) { bError = bErr; } + sal_Bool GetError() { return bError; } +}; + +// +// class XRMResOutputParser +// + +class XRMResOutputParser : public XRMResParser +{ +private: + std::vector<ByteString> aLanguages; +protected: + SvFileStream *pOutputStream; +public: + XRMResOutputParser ( const ByteString &rOutputFile ); + virtual ~XRMResOutputParser(); +}; + +// +// XRMResExport +// + +class XRMResExport : public XRMResOutputParser +{ +private: + ResData *pResData; + ByteString sPrj; + ByteString sPath; + std::vector<ByteString> aLanguages; + +protected: + void WorkOnText( + const ByteString &rOpenTag, + ByteString &rText + ); + void EndOfText( + const ByteString &rOpenTag, + const ByteString &rCloseTag + ); + void Output( const ByteString& rOutput ); + +public: + XRMResExport( + const ByteString &rOutputFile, + const ByteString &rProject, + const ByteString &rFilePath + ); + virtual ~XRMResExport(); +}; + +// +// class XRMResMerge +// + +class XRMResMerge : public XRMResOutputParser +{ +private: + MergeDataFile *pMergeDataFile; + ByteString sFilename; + ResData *pResData; + std::vector<ByteString> aLanguages; + +protected: + void WorkOnText( + const ByteString &rOpenTag, + ByteString &rText + ); + void EndOfText( + const ByteString &rOpenTag, + const ByteString &rCloseTag + ); + void Output( const ByteString& rOutput ); +public: + XRMResMerge( + const ByteString &rMergeSource, + const ByteString &rOutputFile, + ByteString &rFilename + ); + virtual ~XRMResMerge(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |