xref: /trunk/main/l10ntools/inc/helpmerge.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 // local includes
28 #include "export.hxx"
29 #include "xmlparse.hxx"
30 #include <rtl/ustring.hxx>
31 #include <rtl/ustrbuf.hxx>
32 #include <rtl/strbuf.hxx>
33 #include <memory> /* auto_ptr */
34 #include "tools/isofallback.hxx"
35 
36 #define MOVEFILE_REPLACE_EXISTING 0x01
37 
38 /// This Class is responsible for extracting/merging OpenOffice XML Helpfiles
39 class HelpParser
40 {
41 private:
42 	ByteString sHelpFile;
43     bool       bUTF8;
44     bool       bHasInputList;
45 
46 /// Copy fallback language String (ENUS,DE) into position of the numeric language iso code
47 /// @PRECOND 0 < langIdx_in < MAX_IDX
48     static void FillInFallbacks( LangHashMap& rElem_out, ByteString sLangIdx_in );
49 
50 /// Debugmethod, prints the content of the map to stdout
51     static  void Dump(  LangHashMap* rElem_in , const ByteString sKey_in );
52 
53 /// Debugmethod, prints the content of the map to stdout
54     static  void Dump(  XMLHashMap* rElem_in ) ;
55 
56 
57 
58 public:
59 	HelpParser( const ByteString &rHelpFile, bool bUTF8 , bool bHasInputList );
60     ~HelpParser(){};
61 
62 /// Method creates/append a SDF file with the content of a parsed XML file
63 /// @PRECOND rHelpFile is valid
64     static bool CreateSDF( const ByteString &rSDFFile_in, const ByteString &rPrj_in, const ByteString &rRoot_in,
65                            const ByteString &sHelpFile, XMLFile *pXmlFile, const ByteString &rGsi1 );
66 
67 	static  void parse_languages( std::vector<ByteString>& aLanguages , MergeDataFile& aMergeDataFile );
68 
69 /// Method merges the String from the SDFfile into XMLfile. Both Strings must
70 /// point to existing files.
71 	bool Merge( const ByteString &rSDFFile_in, const ByteString &rDestinationFile_in , ByteString& sLanguage , MergeDataFile& aMergeDataFile );
72     bool Merge( const ByteString &rSDFFile, const ByteString &rPathX , const ByteString &rPathY , bool bISO
73 		, const std::vector<ByteString>& aLanguages , MergeDataFile& aMergeDataFile , bool bCreateDir );
74 
75 private:
76     static ByteString makeAbsolutePath( const ByteString& sHelpFile , const ByteString& rRoot_in );
77 
78     ByteString GetOutpath( const ByteString& rPathX , const ByteString& sCur , const ByteString& rPathY );
79     bool MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile , const ByteString& sLanguage , ByteString sPath );
80 
81     void Process( LangHashMap* aLangHM , const ByteString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile );
82     void ProcessHelp( LangHashMap* aLangHM , const ByteString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile );
83     void MakeDir( const ByteString& sPath );
84 };
85