1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _EXPORT_HXX 29*cdf0e10cSrcweir #define _EXPORT_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #ifndef L10NTOOLS_DIRECTORY_HXX 32*cdf0e10cSrcweir #define L10NTOOLS_DIRECTORY_HXX 33*cdf0e10cSrcweir #include <l10ntools/directory.hxx> 34*cdf0e10cSrcweir #endif 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir // #define MERGE_SOURCE_LANGUAGES <- To merge en-US and de resource 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <tools/string.hxx> 40*cdf0e10cSrcweir #include <tools/list.hxx> 41*cdf0e10cSrcweir #include <tools/stream.hxx> 42*cdf0e10cSrcweir #include <tools/fsys.hxx> 43*cdf0e10cSrcweir #include <osl/file.hxx> 44*cdf0e10cSrcweir #include <osl/file.h> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <hash_map> /* std::hashmap*/ 47*cdf0e10cSrcweir #include <iterator> /* std::iterator*/ 48*cdf0e10cSrcweir #include <set> /* std::set*/ 49*cdf0e10cSrcweir #include <vector> /* std::vector*/ 50*cdf0e10cSrcweir #include <queue> 51*cdf0e10cSrcweir #include <string> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir #include <unistd.h> 54*cdf0e10cSrcweir #ifdef WNT 55*cdf0e10cSrcweir #include <direct.h> 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #define NO_TRANSLATE_ISO "x-no-translate" 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #define JAPANESE_ISO "ja" 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir struct eqstr{ 64*cdf0e10cSrcweir sal_Bool operator()(const char* s1, const char* s2) const{ 65*cdf0e10cSrcweir return strcmp(s1,s2)==0; 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir }; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir struct equalByteString{ 70*cdf0e10cSrcweir bool operator()( const ByteString& rKey1, const ByteString& rKey2 ) const { 71*cdf0e10cSrcweir return rKey1.CompareTo( rKey2 )==COMPARE_EQUAL; 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir }; 74*cdf0e10cSrcweir struct lessByteString{ 75*cdf0e10cSrcweir bool operator()( const ByteString& rKey1, const ByteString& rKey2 ) const { 76*cdf0e10cSrcweir return rKey1.CompareTo( rKey2 )==COMPARE_LESS; 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir }; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir struct hashByteString{ 81*cdf0e10cSrcweir size_t operator()( const ByteString& rName ) const{ 82*cdf0e10cSrcweir std::hash< const char* > myHash; 83*cdf0e10cSrcweir return myHash( rName.GetBuffer() ); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir }; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir class PFormEntrys; 88*cdf0e10cSrcweir class MergeData; 89*cdf0e10cSrcweir typedef std::set<ByteString , lessByteString > ByteStringSet; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir typedef std::hash_map<ByteString , ByteString , hashByteString,equalByteString> 92*cdf0e10cSrcweir ByteStringHashMap; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir typedef std::hash_map<ByteString , bool , hashByteString,equalByteString> 95*cdf0e10cSrcweir ByteStringBoolHashMap; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir typedef std::hash_map<ByteString , PFormEntrys* , hashByteString,equalByteString> 98*cdf0e10cSrcweir PFormEntrysHashMap; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir typedef std::hash_map<ByteString , MergeData* , hashByteString,equalByteString> 101*cdf0e10cSrcweir MergeDataHashMap; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir #define SOURCE_LANGUAGE ByteString("en-US") 104*cdf0e10cSrcweir #define LIST_REFID "LIST_REFID" 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir typedef ByteStringHashMap ExportListEntry; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir DECLARE_LIST( ExportListBase, ExportListEntry * ) 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir // 111*cdf0e10cSrcweir // class ExportList 112*cdf0e10cSrcweir // 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir class ExportList : public ExportListBase 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir private: 117*cdf0e10cSrcweir sal_uLong nSourceLanguageListEntryCount; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir public: 120*cdf0e10cSrcweir ExportList() : ExportListBase() { nSourceLanguageListEntryCount = 0; } 121*cdf0e10cSrcweir sal_uLong GetSourceLanguageListEntryCount() { return nSourceLanguageListEntryCount; } 122*cdf0e10cSrcweir void NewSourceLanguageListEntry() { nSourceLanguageListEntryCount++; } 123*cdf0e10cSrcweir }; 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir #define REFID_NONE 0xFFFF 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir // 128*cdf0e10cSrcweir // struct ResData 129*cdf0e10cSrcweir // 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir /****************************************************************************** 132*cdf0e10cSrcweir * Purpose: holds mandatory data to export a single res (used with ResStack) 133*cdf0e10cSrcweir ******************************************************************************/ 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir #define ID_LEVEL_NULL 0x0000 136*cdf0e10cSrcweir #define ID_LEVEL_AUTOID 0x0001 137*cdf0e10cSrcweir #define ID_LEVEL_TEXT 0x0002 138*cdf0e10cSrcweir #define ID_LEVEL_FIELDNAME 0x0003 139*cdf0e10cSrcweir #define ID_LEVEL_ACCESSPATH 0x0004 140*cdf0e10cSrcweir #define ID_LEVEL_IDENTIFIER 0x0005 141*cdf0e10cSrcweir #define ID_LEVEL_LISTINDEX 0x0006 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir class ResData 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir public: 146*cdf0e10cSrcweir ~ResData(); 147*cdf0e10cSrcweir sal_Bool SetId( const ByteString &rId, sal_uInt16 nLevel ); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir sal_uInt16 nWidth; 150*cdf0e10cSrcweir sal_uInt16 nChildIndex; 151*cdf0e10cSrcweir sal_uInt16 nIdLevel; 152*cdf0e10cSrcweir sal_Bool bChild; 153*cdf0e10cSrcweir sal_Bool bChildWithText; 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir sal_Bool bText; 156*cdf0e10cSrcweir sal_Bool bHelpText; 157*cdf0e10cSrcweir sal_Bool bQuickHelpText; 158*cdf0e10cSrcweir sal_Bool bTitle; 159*cdf0e10cSrcweir sal_Bool bList; 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir sal_Bool bRestMerged; 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir ByteString sResTyp; 164*cdf0e10cSrcweir ByteString sId; 165*cdf0e10cSrcweir ByteString sGId; 166*cdf0e10cSrcweir ByteString sHelpId; 167*cdf0e10cSrcweir ByteString sFilename; 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir ByteStringHashMap sText; 170*cdf0e10cSrcweir sal_uInt16 nTextRefId; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir ByteStringHashMap sHelpText; 173*cdf0e10cSrcweir sal_uInt16 nHelpTextRefId; 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir ByteStringHashMap sQuickHelpText; 176*cdf0e10cSrcweir sal_uInt16 nQuickHelpTextRefId; 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir ByteStringHashMap sTitle; 179*cdf0e10cSrcweir sal_uInt16 nTitleRefId; 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir ByteString sTextTyp; 182*cdf0e10cSrcweir ByteStringHashMap aFallbackData; 183*cdf0e10cSrcweir ByteStringHashMap aMergedLanguages; 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir ExportList *pStringList; 186*cdf0e10cSrcweir ExportList *pUIEntries; 187*cdf0e10cSrcweir ExportList *pItemList; 188*cdf0e10cSrcweir ExportList *pFilterList; 189*cdf0e10cSrcweir ExportList *pPairedList; 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir ByteString sPForm; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir void Dump(); 194*cdf0e10cSrcweir void addFallbackData( ByteString& sId , const ByteString& sText ); 195*cdf0e10cSrcweir bool getFallbackData( ByteString& sId , ByteString& sText); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir void addMergedLanguage( ByteString& sLang ); 198*cdf0e10cSrcweir bool isMerged( ByteString& sLang ); 199*cdf0e10cSrcweir ResData( const ByteString &rPF, const ByteString &rGId ) 200*cdf0e10cSrcweir : 201*cdf0e10cSrcweir nWidth( 0 ), 202*cdf0e10cSrcweir nChildIndex( 0 ), 203*cdf0e10cSrcweir nIdLevel( ID_LEVEL_NULL ), 204*cdf0e10cSrcweir bChild( sal_False ), 205*cdf0e10cSrcweir bChildWithText( sal_False ), 206*cdf0e10cSrcweir bText( sal_False ), 207*cdf0e10cSrcweir bHelpText( sal_False ), 208*cdf0e10cSrcweir bQuickHelpText( sal_False ), 209*cdf0e10cSrcweir bTitle( sal_False ), 210*cdf0e10cSrcweir bList( sal_False ), 211*cdf0e10cSrcweir bRestMerged( sal_False ), 212*cdf0e10cSrcweir sGId( rGId ), 213*cdf0e10cSrcweir nTextRefId( REFID_NONE ), 214*cdf0e10cSrcweir nHelpTextRefId( REFID_NONE ), 215*cdf0e10cSrcweir nQuickHelpTextRefId( REFID_NONE ), 216*cdf0e10cSrcweir nTitleRefId( REFID_NONE ), 217*cdf0e10cSrcweir sTextTyp( "Text" ), 218*cdf0e10cSrcweir pStringList( NULL ), 219*cdf0e10cSrcweir pUIEntries( NULL ), 220*cdf0e10cSrcweir pItemList( NULL ), 221*cdf0e10cSrcweir pFilterList( NULL ), 222*cdf0e10cSrcweir pPairedList( NULL ), 223*cdf0e10cSrcweir sPForm( rPF ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir sGId.EraseAllChars( '\r' ); 226*cdf0e10cSrcweir sPForm.EraseAllChars( '\r' ); 227*cdf0e10cSrcweir }; 228*cdf0e10cSrcweir ResData( const ByteString &rPF, const ByteString &rGId , const ByteString &rFilename ) 229*cdf0e10cSrcweir : 230*cdf0e10cSrcweir nChildIndex( 0 ), 231*cdf0e10cSrcweir nIdLevel( ID_LEVEL_NULL ), 232*cdf0e10cSrcweir bChild( sal_False ), 233*cdf0e10cSrcweir bChildWithText( sal_False ), 234*cdf0e10cSrcweir bText( sal_False ), 235*cdf0e10cSrcweir bHelpText( sal_False ), 236*cdf0e10cSrcweir bQuickHelpText( sal_False ), 237*cdf0e10cSrcweir bTitle( sal_False ), 238*cdf0e10cSrcweir bList( sal_False ), 239*cdf0e10cSrcweir bRestMerged( sal_False ), 240*cdf0e10cSrcweir sGId( rGId ), 241*cdf0e10cSrcweir sFilename( rFilename ), 242*cdf0e10cSrcweir nTextRefId( REFID_NONE ), 243*cdf0e10cSrcweir nHelpTextRefId( REFID_NONE ), 244*cdf0e10cSrcweir nQuickHelpTextRefId( REFID_NONE ), 245*cdf0e10cSrcweir nTitleRefId( REFID_NONE ), 246*cdf0e10cSrcweir sTextTyp( "Text" ), 247*cdf0e10cSrcweir pStringList( NULL ), 248*cdf0e10cSrcweir pUIEntries( NULL ), 249*cdf0e10cSrcweir pItemList( NULL ), 250*cdf0e10cSrcweir pFilterList( NULL ), 251*cdf0e10cSrcweir pPairedList( NULL ), 252*cdf0e10cSrcweir sPForm( rPF ) 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir sGId.EraseAllChars( '\r' ); 256*cdf0e10cSrcweir sPForm.EraseAllChars( '\r' ); 257*cdf0e10cSrcweir }; 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir }; 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir // 264*cdf0e10cSrcweir // class Export 265*cdf0e10cSrcweir // 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir /****************************************************************************** 268*cdf0e10cSrcweir * Purpose: syntax check and export of *.src, called from lexer 269*cdf0e10cSrcweir ******************************************************************************/ 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir #define LIST_NON 0x0000 272*cdf0e10cSrcweir #define LIST_STRING 0x0001 273*cdf0e10cSrcweir #define LIST_FILTER 0x0002 274*cdf0e10cSrcweir #define LIST_ITEM 0x0004 275*cdf0e10cSrcweir #define LIST_PAIRED 0x0005 276*cdf0e10cSrcweir #define LIST_UIENTRIES 0x0008 277*cdf0e10cSrcweir #define STRING_TYP_TEXT 0x0010 278*cdf0e10cSrcweir #define STRING_TYP_HELPTEXT 0x0020 279*cdf0e10cSrcweir #define STRING_TYP_QUICKHELPTEXT 0x0040 280*cdf0e10cSrcweir #define STRING_TYP_TITLE 0x0080 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir #define MERGE_MODE_NORMAL 0x0000 283*cdf0e10cSrcweir #define MERGE_MODE_LIST 0x0001 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir DECLARE_LIST( ResStack, ResData * ) 286*cdf0e10cSrcweir // forwards 287*cdf0e10cSrcweir class WordTransformer; 288*cdf0e10cSrcweir class ParserQueue; 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir class Export 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir private: 293*cdf0e10cSrcweir WordTransformer *pWordTransformer; 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir CharSet aCharSet; // used charset in src 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir SvFileStream aOutput; 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir ResStack aResStack; // stack for parsing recursive 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir ByteString sActPForm; // hold cur. system 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir sal_Bool bDefine; // cur. res. in a define? 304*cdf0e10cSrcweir sal_Bool bNextMustBeDefineEOL; // define but no \ at lineend 305*cdf0e10cSrcweir sal_uLong nLevel; // res. recursiv? how deep? 306*cdf0e10cSrcweir sal_uInt16 nList; // cur. res. is String- or FilterList 307*cdf0e10cSrcweir ByteString nListLang; 308*cdf0e10cSrcweir sal_uLong nListIndex; 309*cdf0e10cSrcweir sal_uLong nListLevel; 310*cdf0e10cSrcweir bool bSkipFile; 311*cdf0e10cSrcweir ByteString sProject; 312*cdf0e10cSrcweir ByteString sRoot; 313*cdf0e10cSrcweir sal_Bool bEnableExport; 314*cdf0e10cSrcweir sal_Bool bMergeMode; 315*cdf0e10cSrcweir ByteString sMergeSrc; 316*cdf0e10cSrcweir ByteString sLastListLine; 317*cdf0e10cSrcweir sal_Bool bError; // any errors while export? 318*cdf0e10cSrcweir sal_Bool bReadOver; 319*cdf0e10cSrcweir sal_Bool bDontWriteOutput; 320*cdf0e10cSrcweir ByteString sLastTextTyp; 321*cdf0e10cSrcweir static bool isInitialized; 322*cdf0e10cSrcweir ByteString sFilename; 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir public: 326*cdf0e10cSrcweir ParserQueue* pParseQueue; // public ? 327*cdf0e10cSrcweir static ByteString sLanguages; // public ? 328*cdf0e10cSrcweir static ByteString sForcedLanguages; // public ? 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir static bool skipProject( ByteString sPrj ) ; 332*cdf0e10cSrcweir static void InitLanguages( bool bMergeMode = false ); 333*cdf0e10cSrcweir static void InitForcedLanguages( bool bMergeMode = false ); 334*cdf0e10cSrcweir static std::vector<ByteString> GetLanguages(); 335*cdf0e10cSrcweir static std::vector<ByteString> GetForcedLanguages(); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir static void SetLanguages( std::vector<ByteString> val ); 338*cdf0e10cSrcweir static void RemoveUTF8ByteOrderMarker( ByteString &rString ); 339*cdf0e10cSrcweir static bool hasUTF8ByteOrderMarker( const ByteString &rString ); 340*cdf0e10cSrcweir static void RemoveUTF8ByteOrderMarkerFromFile( const ByteString &rFilename ); 341*cdf0e10cSrcweir static bool fileHasUTF8ByteOrderMarker( const ByteString &rString ); 342*cdf0e10cSrcweir static ByteString GetIsoLangByIndex( sal_uInt16 nIndex ); 343*cdf0e10cSrcweir static void QuotHTML( ByteString &rString ); 344*cdf0e10cSrcweir static bool CopyFile( const ByteString& source , const ByteString& dest ); 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir static void QuotHTMLXRM( ByteString &rString ); 347*cdf0e10cSrcweir static void UnquotHTML( ByteString &rString ); 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir static const char* GetEnv( const char *pVar ); 350*cdf0e10cSrcweir static int getCurrentDirectory( rtl::OUString& base_fqurl , rtl::OUString& base ); 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir static bool isSourceLanguage( const ByteString &sLanguage ); 353*cdf0e10cSrcweir static bool isAllowed( const ByteString &sLanguage ); 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir static bool LanguageAllowed( const ByteString &nLanguage ); 356*cdf0e10cSrcweir static void Languages( std::vector<ByteString>::const_iterator& begin , std::vector<ByteString>::const_iterator& end ); 357*cdf0e10cSrcweir static void getRandomName( const ByteString& sPrefix , ByteString& sRandStr , const ByteString& sPostfix ); 358*cdf0e10cSrcweir static void getRandomName( ByteString& sRandStr ); 359*cdf0e10cSrcweir static void getCurrentDir( std::string& dir ); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir static void replaceEncoding( ByteString& rString ); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir static ByteString GetFallbackLanguage( const ByteString nLanguage ); 364*cdf0e10cSrcweir static void FillInFallbacks( ResData *pResData ); 365*cdf0e10cSrcweir static void FillInListFallbacks( ExportList *pList, const ByteString &nSource, const ByteString &nFallback ); 366*cdf0e10cSrcweir static ByteString GetTimeStamp(); 367*cdf0e10cSrcweir static sal_Bool ConvertLineEnds( ByteString sSource, ByteString sDestination ); 368*cdf0e10cSrcweir static ByteString GetNativeFile( ByteString sSource ); 369*cdf0e10cSrcweir static DirEntry GetTempFile(); 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir static void DumpExportList( ByteString& sListName , ExportList& aList ); 372*cdf0e10cSrcweir static ByteString DumpMap( ByteString& sMapName , ByteStringHashMap& aMap ); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir private: 375*cdf0e10cSrcweir static std::vector<ByteString> aLanguages; 376*cdf0e10cSrcweir static std::vector<ByteString> aForcedLanguages; 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir sal_Bool ListExists( ResData *pResData, sal_uInt16 nLst ); 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir sal_Bool WriteData( ResData *pResData, sal_Bool bCreateNew = sal_False );// called befor dest. cur ResData 381*cdf0e10cSrcweir sal_Bool WriteExportList( ResData *pResData, ExportList *pExportList, 382*cdf0e10cSrcweir const ByteString &rTyp, sal_Bool bCreateNew = sal_False ); 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir ByteString MergePairedList( ByteString& sLine , ByteString& sText ); 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir ByteString FullId(); // creates cur. GID 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir bool PairedListFallback( ByteString& sText , ResData& aResData ); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir ByteString GetPairedListID ( const ByteString& sText ); 391*cdf0e10cSrcweir ByteString GetPairedListString ( const ByteString& sText ); 392*cdf0e10cSrcweir ByteString StripList ( const ByteString& sText ); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir void UnmergeUTF8( ByteString& sOrig ); 395*cdf0e10cSrcweir void InsertListEntry( const ByteString &rText, const ByteString &rLine ); 396*cdf0e10cSrcweir void CleanValue( ByteString &rValue ); 397*cdf0e10cSrcweir ByteString GetText( const ByteString &rSource, int nToken ); 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir sal_Bool PrepareTextToMerge( ByteString &rText, sal_uInt16 nTyp, 400*cdf0e10cSrcweir ByteString &nLangIndex, ResData *pResData ); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir void MergeRest( ResData *pResData, sal_uInt16 nMode = MERGE_MODE_NORMAL ); 403*cdf0e10cSrcweir void ConvertMergeContent( ByteString &rText ); 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir void WriteToMerged( const ByteString &rText , bool bSDFContent ); 406*cdf0e10cSrcweir void SetChildWithText(); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir void CutComment( ByteString &rText ); 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir public: 411*cdf0e10cSrcweir Export( const ByteString &rOutput, sal_Bool bWrite, 412*cdf0e10cSrcweir const ByteString &rPrj, const ByteString &rPrjRoot , const ByteString& rFile ); 413*cdf0e10cSrcweir Export( const ByteString &rOutput, sal_Bool bWrite, 414*cdf0e10cSrcweir const ByteString &rPrj, const ByteString &rPrjRoot, 415*cdf0e10cSrcweir const ByteString &rMergeSource , const ByteString& rFile ); 416*cdf0e10cSrcweir ~Export(); 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir void Init(); 419*cdf0e10cSrcweir int Execute( int nToken, const char * pToken ); // called from lexer 420*cdf0e10cSrcweir void SetError() { bError = sal_True; } 421*cdf0e10cSrcweir sal_Bool GetError() { return bError; } 422*cdf0e10cSrcweir }; 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir // 426*cdf0e10cSrcweir // class PFormEntrys 427*cdf0e10cSrcweir // 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir /****************************************************************************** 430*cdf0e10cSrcweir * Purpose: holds information of data to merge (one pform) 431*cdf0e10cSrcweir ******************************************************************************/ 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir class PFormEntrys : public ByteString 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir friend class MergeDataFile; 436*cdf0e10cSrcweir private: 437*cdf0e10cSrcweir ByteString sHelpText; // empty string 438*cdf0e10cSrcweir ByteStringHashMap sText; 439*cdf0e10cSrcweir ByteStringBoolHashMap bTextFirst; 440*cdf0e10cSrcweir ByteStringHashMap sQuickHelpText; 441*cdf0e10cSrcweir ByteStringBoolHashMap bQuickHelpTextFirst; 442*cdf0e10cSrcweir ByteStringHashMap sTitle; 443*cdf0e10cSrcweir ByteStringBoolHashMap bTitleFirst; 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir public: 446*cdf0e10cSrcweir PFormEntrys( const ByteString &rPForm ) : ByteString( rPForm ) {}; 447*cdf0e10cSrcweir ByteString Dump(); 448*cdf0e10cSrcweir void InsertEntry( 449*cdf0e10cSrcweir const ByteString &nId , 450*cdf0e10cSrcweir const ByteString &rText, 451*cdf0e10cSrcweir const ByteString &rQuickHelpText, 452*cdf0e10cSrcweir const ByteString &rTitle 453*cdf0e10cSrcweir ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir sText[ nId ] = rText; 456*cdf0e10cSrcweir bTextFirst[ nId ] = true; 457*cdf0e10cSrcweir sQuickHelpText[ nId ] = rQuickHelpText; 458*cdf0e10cSrcweir bQuickHelpTextFirst[ nId ] = true; 459*cdf0e10cSrcweir sTitle[ nId ] = rTitle; 460*cdf0e10cSrcweir bTitleFirst[ nId ] = true; 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir sal_Bool GetText( ByteString &rReturn, sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel = sal_False ); 463*cdf0e10cSrcweir sal_Bool GetTransex3Text( ByteString &rReturn, sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel = sal_False ); 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir }; 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir // 468*cdf0e10cSrcweir // class MergeData 469*cdf0e10cSrcweir // 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir /****************************************************************************** 472*cdf0e10cSrcweir * Purpose: holds information of data to merge (one ressource) 473*cdf0e10cSrcweir ******************************************************************************/ 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir class MergeDataFile; 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir class MergeData 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir friend class MergeDataFile; 480*cdf0e10cSrcweir private: 481*cdf0e10cSrcweir ByteString sTyp; 482*cdf0e10cSrcweir ByteString sGID; 483*cdf0e10cSrcweir ByteString sLID; 484*cdf0e10cSrcweir ByteString sFilename; 485*cdf0e10cSrcweir PFormEntrysHashMap aMap; 486*cdf0e10cSrcweir public: 487*cdf0e10cSrcweir MergeData( const ByteString &rTyp, const ByteString &rGID, const ByteString &rLID , const ByteString &rFilename ) 488*cdf0e10cSrcweir : sTyp( rTyp ), sGID( rGID ), sLID( rLID ) , sFilename( rFilename ) {}; 489*cdf0e10cSrcweir ~MergeData(); 490*cdf0e10cSrcweir PFormEntrys* InsertEntry( const ByteString &rPForm ); 491*cdf0e10cSrcweir PFormEntrys* GetPFormEntrys( ResData *pResData ); 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir void Insert( const ByteString& rPFO , PFormEntrys* pfEntrys ); 494*cdf0e10cSrcweir PFormEntrys* GetPFObject( const ByteString& rPFO ); 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir ByteString Dump(); 497*cdf0e10cSrcweir sal_Bool operator==( ResData *pData ); 498*cdf0e10cSrcweir }; 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir // 501*cdf0e10cSrcweir // class MergeDataFile 502*cdf0e10cSrcweir // 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir /****************************************************************************** 505*cdf0e10cSrcweir * Purpose: holds information of data to merge 506*cdf0e10cSrcweir ******************************************************************************/ 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir class MergeDataFile 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir private: 511*cdf0e10cSrcweir sal_Bool bErrorLog; 512*cdf0e10cSrcweir ByteString sErrorLog; 513*cdf0e10cSrcweir SvFileStream aErrLog; 514*cdf0e10cSrcweir MergeDataHashMap aMap; 515*cdf0e10cSrcweir std::set<ByteString> aLanguageSet; 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir MergeData *GetMergeData( ResData *pResData , bool bCaseSensitve = false ); 518*cdf0e10cSrcweir void InsertEntry( const ByteString &rTYP, const ByteString &rGID, const ByteString &rLID, 519*cdf0e10cSrcweir const ByteString &rPFO, 520*cdf0e10cSrcweir const ByteString &nLang, const ByteString &rTEXT, 521*cdf0e10cSrcweir const ByteString &rQHTEXT, const ByteString &rTITLE, 522*cdf0e10cSrcweir const ByteString &sFilename, bool bCaseSensitive 523*cdf0e10cSrcweir ); 524*cdf0e10cSrcweir ByteString Dump(); 525*cdf0e10cSrcweir void WriteError( const ByteString &rLine ); 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir public: 528*cdf0e10cSrcweir MergeDataFile( const ByteString &rFileName, const ByteString& rFile , sal_Bool bErrLog, CharSet aCharSet, bool bCaseSensitive = false ); 529*cdf0e10cSrcweir ~MergeDataFile(); 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir std::vector<ByteString> GetLanguages(); 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir PFormEntrys *GetPFormEntrys( ResData *pResData ); 534*cdf0e10cSrcweir PFormEntrys *GetPFormEntrysCaseSensitive( ResData *pResData ); 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir static ByteString CreateKey( const ByteString& rTYP , const ByteString& rGID , const ByteString& rLID , const ByteString& rFilename , bool bCaseSensitive = false ); 537*cdf0e10cSrcweir }; 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir class QueueEntry 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir public: 543*cdf0e10cSrcweir QueueEntry( int nTypVal , ByteString sLineVal ): nTyp( nTypVal ) , sLine( sLineVal ){}; 544*cdf0e10cSrcweir int nTyp; 545*cdf0e10cSrcweir ByteString sLine; 546*cdf0e10cSrcweir }; 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir class ParserQueue 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir public: 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir ParserQueue( Export& aExportObj ); 553*cdf0e10cSrcweir ~ParserQueue(); 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir inline void Push( const QueueEntry& aEntry ); 556*cdf0e10cSrcweir bool bCurrentIsM; // public ? 557*cdf0e10cSrcweir bool bNextIsM; // public ? 558*cdf0e10cSrcweir bool bLastWasM; // public ? 559*cdf0e10cSrcweir bool bMflag; // public ? 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir void Close(); 562*cdf0e10cSrcweir private: 563*cdf0e10cSrcweir // Future / Next 564*cdf0e10cSrcweir std::queue<QueueEntry>* aQueueNext; 565*cdf0e10cSrcweir // Current 566*cdf0e10cSrcweir std::queue<QueueEntry>* aQueueCur; 567*cdf0e10cSrcweir // Ref 568*cdf0e10cSrcweir std::queue<QueueEntry>* aQref; 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir Export& aExport; 571*cdf0e10cSrcweir bool bStart; 572*cdf0e10cSrcweir bool bStartNext; 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir inline void Pop( std::queue<QueueEntry>& aQueue ); 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir }; 577*cdf0e10cSrcweir #endif 578*cdf0e10cSrcweir 579