xref: /aoo41x/main/l10ntools/inc/helpmerge.hxx (revision 983d4c8a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 // local includes
24 #include "export.hxx"
25 #include "xmlparse.hxx"
26 #include <rtl/ustring.hxx>
27 #include <rtl/ustrbuf.hxx>
28 #include <rtl/strbuf.hxx>
29 #include <memory> /* auto_ptr */
30 #include "tools/isofallback.hxx"
31 
32 #define MOVEFILE_REPLACE_EXISTING 0x01
33 
34 /// This Class is responsible for extracting/merging OpenOffice XML Helpfiles
35 class HelpParser
36 {
37 private:
38 	ByteString sHelpFile;
39     bool       bUTF8;
40     bool       bHasInputList;
41 
42 /// Copy fallback language String (ENUS,DE) into position of the numeric language iso code
43 /// @PRECOND 0 < langIdx_in < MAX_IDX
44     static void FillInFallbacks( LangHashMap& rElem_out, ByteString sLangIdx_in );
45 
46 /// Debugmethod, prints the content of the map to stdout
47     static  void Dump(  LangHashMap* rElem_in , const ByteString sKey_in );
48 
49 /// Debugmethod, prints the content of the map to stdout
50     static  void Dump(  XMLHashMap* rElem_in ) ;
51 
52 
53 
54 public:
55 	HelpParser( const ByteString &rHelpFile, bool bUTF8 , bool bHasInputList );
~HelpParser()56     ~HelpParser(){};
57 
58 /// Method creates/append a SDF file with the content of a parsed XML file
59 /// @PRECOND rHelpFile is valid
60     static bool CreateSDF( const ByteString &rSDFFile_in, const ByteString &rPrj_in, const ByteString &rRoot_in,
61                            const ByteString &sHelpFile, XMLFile *pXmlFile, const ByteString &rGsi1 );
62 
63 	static  void parse_languages( std::vector<ByteString>& aLanguages , MergeDataFile& aMergeDataFile );
64 
65 /// Method merges the String from the SDFfile into XMLfile. Both Strings must
66 /// point to existing files.
67 	bool Merge( const ByteString &rSDFFile_in, const ByteString &rDestinationFile_in , ByteString& sLanguage , MergeDataFile& aMergeDataFile );
68     bool Merge( const ByteString &rSDFFile, const ByteString &rPathX , const ByteString &rPathY , bool bISO
69 		, const std::vector<ByteString>& aLanguages , MergeDataFile& aMergeDataFile , bool bCreateDir );
70 
71 private:
72     static ByteString makeAbsolutePath( const ByteString& sHelpFile , const ByteString& rRoot_in );
73 
74     ByteString GetOutpath( const ByteString& rPathX , const ByteString& sCur , const ByteString& rPathY );
75     bool MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile , const ByteString& sLanguage , ByteString sPath );
76 
77     void Process( LangHashMap* aLangHM , const ByteString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile );
78     void ProcessHelp( LangHashMap* aLangHM , const ByteString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile );
79     void MakeDir( const ByteString& sPath );
80 };
81