1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
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"
36 #define MOVEFILE_REPLACE_EXISTING 0x01
38 /// This Class is responsible for extracting/merging OpenOffice XML Helpfiles
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
);
50 /// Debugmethod, prints the content of the map to stdout
51 static void Dump( LangHashMap
* rElem_in
, const ByteString sKey_in
);
53 /// Debugmethod, prints the content of the map to stdout
54 static void Dump( XMLHashMap
* rElem_in
) ;
59 HelpParser( const ByteString
&rHelpFile
, bool bUTF8
, bool bHasInputList
);
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
);
67 static void parse_languages( std::vector
<ByteString
>& aLanguages
, MergeDataFile
& aMergeDataFile
);
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
);
76 static ByteString
makeAbsolutePath( const ByteString
& sHelpFile
, const ByteString
& rRoot_in
);
78 ByteString
GetOutpath( const ByteString
& rPathX
, const ByteString
& sCur
, const ByteString
& rPathY
);
79 bool MergeSingleFile( XMLFile
* file
, MergeDataFile
& aMergeDataFile
, const ByteString
& sLanguage
, ByteString sPath
);
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
);