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