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