summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorAndras Timar <atimar@suse.com>2012-09-28 16:57:02 +0200
committerAndras Timar <atimar@suse.com>2012-09-28 16:57:02 +0200
commitdbac379f77a034f10e62e607258fcbafad41b7ab (patch)
tree38c9db63bb991d8ff0ca8060274f8c6aaf92e3c9 /l10ntools
parent822ac662c758916af546a293a408ee6fbb9cfe7e (diff)
parent8b97644bab0e9106b798a5b8969aa796e558ef3f (diff)
Merge branch 'master' into feature/killsdf
Conflicts: l10ntools/Module_l10ntools.mk l10ntools/source/merge.cxx solenv/gbuild/AllLangResTarget.mk solenv/gbuild/ExtensionTarget.mk solenv/gbuild/InstallModuleTarget.mk solenv/gbuild/TargetLocations.mk
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/Executable_helpindexer.mk50
-rw-r--r--l10ntools/Executable_helplinker.mk50
-rw-r--r--l10ntools/Executable_uiex.mk35
-rw-r--r--l10ntools/Library_helplinker.mk68
-rw-r--r--l10ntools/Module_l10ntools.mk4
-rw-r--r--l10ntools/Package_inc.mk5
-rw-r--r--l10ntools/inc/export.hxx6
-rw-r--r--l10ntools/inc/l10ntools/HelpIndexer.hxx109
-rw-r--r--l10ntools/inc/l10ntools/HelpLinker.hxx104
-rw-r--r--l10ntools/inc/l10ntools/HelpSearch.hxx64
-rw-r--r--l10ntools/inc/l10ntools/dllapi.h49
-rw-r--r--l10ntools/inc/tokens.h2
-rw-r--r--l10ntools/prj/build.lst2
-rw-r--r--l10ntools/scripts/update_tree.pl394
-rw-r--r--l10ntools/source/cfglex.l8
-rw-r--r--l10ntools/source/gsicheck.cxx13
-rw-r--r--l10ntools/source/help/HelpCompiler.cxx461
-rw-r--r--l10ntools/source/help/HelpCompiler.hxx275
-rw-r--r--l10ntools/source/help/HelpIndexer.cxx172
-rw-r--r--l10ntools/source/help/HelpIndexer_main.cxx109
-rw-r--r--l10ntools/source/help/HelpLinker.cxx1087
-rw-r--r--l10ntools/source/help/HelpLinker_main.cxx51
-rw-r--r--l10ntools/source/help/HelpSearch.cxx79
-rw-r--r--l10ntools/source/help/LuceneHelper.cxx59
-rw-r--r--l10ntools/source/help/LuceneHelper.hxx61
-rw-r--r--l10ntools/source/help/compilehelp.hxx71
-rw-r--r--l10ntools/source/helpmerge.cxx17
-rw-r--r--l10ntools/source/localize.cxx3
-rw-r--r--l10ntools/source/merge.cxx2
-rw-r--r--l10ntools/source/srclex.l6
-rw-r--r--l10ntools/source/uimerge.cxx311
-rw-r--r--l10ntools/source/ulfconv/msi-encodinglist.txt140
-rw-r--r--l10ntools/source/xrmlex.l6
33 files changed, 857 insertions, 3016 deletions
diff --git a/l10ntools/Executable_helpindexer.mk b/l10ntools/Executable_helpindexer.mk
deleted file mode 100644
index c9ce8bae4790..000000000000
--- a/l10ntools/Executable_helpindexer.mk
+++ /dev/null
@@ -1,50 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-# Version: MPL 1.1 / GPLv3+ / LGPLv3+
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License or as specified alternatively below. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# Major Contributor(s):
-# Copyright (C) 2012 David Ostrovsky <d.ostrovsky@gmx.de> (initial developer)
-#
-# All Rights Reserved.
-#
-# For minor contributions see the git repository.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
-# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
-# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
-# instead of those above.
-
-$(eval $(call gb_Executable_Executable,HelpIndexer))
-
-$(eval $(call gb_Executable_use_package,HelpIndexer,\
- l10ntools_inc \
-))
-
-$(eval $(call gb_Executable_use_libraries,HelpIndexer,\
- sal \
- helplinker \
-))
-
-$(eval $(call gb_Executable_use_externals,HelpIndexer,\
- expat_utf8 \
- libxslt \
- libxml2 \
- berkeleydb \
- clucene \
-))
-
-$(eval $(call gb_Executable_add_exception_objects,HelpIndexer,\
- l10ntools/source/help/HelpIndexer_main \
-))
-
-# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/l10ntools/Executable_helplinker.mk b/l10ntools/Executable_helplinker.mk
deleted file mode 100644
index 534c10a62a61..000000000000
--- a/l10ntools/Executable_helplinker.mk
+++ /dev/null
@@ -1,50 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-# Version: MPL 1.1 / GPLv3+ / LGPLv3+
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License or as specified alternatively below. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# Major Contributor(s):
-# Copyright (C) 2012 David Ostrovsky <d.ostrovsky@gmx.de> (initial developer)
-#
-# All Rights Reserved.
-#
-# For minor contributions see the git repository.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
-# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
-# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
-# instead of those above.
-
-$(eval $(call gb_Executable_Executable,HelpLinker))
-
-$(eval $(call gb_Executable_use_package,HelpLinker,\
- l10ntools_inc \
-))
-
-$(eval $(call gb_Executable_use_libraries,HelpLinker,\
- sal \
- helplinker \
-))
-
-$(eval $(call gb_Executable_use_externals,HelpLinker,\
- expat_utf8 \
- libxslt \
- libxml2 \
- berkeleydb \
- clucene \
-))
-
-$(eval $(call gb_Executable_add_exception_objects,HelpLinker,\
- l10ntools/source/help/HelpLinker_main \
-))
-
-# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/l10ntools/Executable_uiex.mk b/l10ntools/Executable_uiex.mk
new file mode 100644
index 000000000000..ca4d7266423a
--- /dev/null
+++ b/l10ntools/Executable_uiex.mk
@@ -0,0 +1,35 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Executable_Executable,uiex))
+
+$(eval $(call gb_Executable_set_include,uiex,\
+ -I$(SRCDIR)/l10ntools/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Executable_use_libraries,uiex,\
+ sal \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,uiex,\
+ transex \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,uiex,\
+ l10ntools/source/uimerge \
+))
+
+$(eval $(call gb_Executable_use_externals,uiex,\
+ libexslt \
+ libxml2 \
+ libxslt \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/l10ntools/Library_helplinker.mk b/l10ntools/Library_helplinker.mk
deleted file mode 100644
index 8cabe50768aa..000000000000
--- a/l10ntools/Library_helplinker.mk
+++ /dev/null
@@ -1,68 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-# Version: MPL 1.1 / GPLv3+ / LGPLv3+
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License or as specified alternatively below. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# Major Contributor(s):
-# Copyright (C) 2012 David Ostrovsky <d.ostrovsky@gmx.de> (initial developer)
-#
-# All Rights Reserved.
-#
-# For minor contributions see the git repository.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
-# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
-# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
-# instead of those above.
-
-$(eval $(call gb_Library_Library,helplinker))
-
-$(eval $(call gb_Library_use_package,helplinker,\
- l10ntools_inc\
-))
-
-$(eval $(call gb_Library_add_defs,helplinker,\
- -DL10N_DLLIMPLEMENTATION \
- -DHELPLINKER_DLLIMPLEMENTATION \
-))
-
-$(eval $(call gb_Library_use_libraries,helplinker,\
- sal \
-))
-
-$(eval $(call gb_Library_use_externals,helplinker,\
- berkeleydb \
- expat_utf8 \
- libxslt \
- libxml2 \
- clucene \
-))
-
-$(eval $(call gb_Library_add_exception_objects,helplinker,\
- l10ntools/source/help/HelpCompiler \
- l10ntools/source/help/LuceneHelper \
- l10ntools/source/help/HelpIndexer \
- l10ntools/source/help/HelpSearch \
-))
-
-ifeq ($(strip $(OS)$(CPU)$(COM)),MACOSXPGCC)
-$(eval $(call gb_Library_add_cxxobjects,helplinker,\
- l10ntools/source/help/HelpLinker \
- , $(gb_COMPILERNOOPTFLAGS) $(gb_LinkTarget_EXCEPTIONFLAGS) \
-))
-else
-$(eval $(call gb_Library_add_exception_objects,helplinker,\
- l10ntools/source/help/HelpLinker \
-))
-endif
-
-# vim: set noet sw=4 ts=4:
diff --git a/l10ntools/Module_l10ntools.mk b/l10ntools/Module_l10ntools.mk
index fb2a3b3289e5..4b1d64d80e12 100644
--- a/l10ntools/Module_l10ntools.mk
+++ b/l10ntools/Module_l10ntools.mk
@@ -33,14 +33,12 @@ $(eval $(call gb_Module_add_targets,l10ntools,\
Executable_ulfex \
Executable_gsicheck \
Executable_cfgex \
+ Executable_uiex \
Executable_xrmex \
Executable_localize \
Executable_transex3 \
- Executable_helpindexer \
- Executable_helplinker \
Executable_renewpo \
StaticLibrary_transex \
- Library_helplinker \
Package_inc \
Package_scripts \
Package_ulfconv \
diff --git a/l10ntools/Package_inc.mk b/l10ntools/Package_inc.mk
index 025a6767d6cc..c990c154f502 100644
--- a/l10ntools/Package_inc.mk
+++ b/l10ntools/Package_inc.mk
@@ -27,14 +27,9 @@
$(eval $(call gb_Package_Package,l10ntools_inc,$(SRCDIR)/l10ntools))
$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/export.hxx,inc/export.hxx))
-$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/dllapi.h,inc/l10ntools/dllapi.h))
$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/directory.hxx,inc/l10ntools/directory.hxx))
$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/file.hxx,inc/l10ntools/file.hxx))
-$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/HelpIndexer.hxx,inc/l10ntools/HelpIndexer.hxx))
-$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/HelpLinker.hxx,inc/l10ntools/HelpLinker.hxx))
-$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/HelpSearch.hxx,inc/l10ntools/HelpSearch.hxx))
$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/FCFGMerge.cfg,source/filter/merge/FCFGMerge.cfg))
-$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/compilehelp.hxx,source/help/compilehelp.hxx))
# vim: set noet sw=4 ts=4:
diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index a1c66e3808a1..be243600d6a6 100644
--- a/l10ntools/inc/export.hxx
+++ b/l10ntools/inc/export.hxx
@@ -405,8 +405,7 @@ class MergeDataFile;
class MergeData
{
-friend class MergeDataFile;
-private:
+public:
rtl::OString sTyp;
rtl::OString sGID;
rtl::OString sLID;
@@ -451,7 +450,8 @@ class MergeDataFile
~MergeDataFile();
- std::vector<rtl::OString> GetLanguages();
+ std::vector<rtl::OString> GetLanguages() const;
+ const MergeDataHashMap& getMap() const { return aMap; }
PFormEntrys *GetPFormEntrys( ResData *pResData );
PFormEntrys *GetPFormEntrysCaseSensitive( ResData *pResData );
diff --git a/l10ntools/inc/l10ntools/HelpIndexer.hxx b/l10ntools/inc/l10ntools/HelpIndexer.hxx
deleted file mode 100644
index f81bca3fe393..000000000000
--- a/l10ntools/inc/l10ntools/HelpIndexer.hxx
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
- * (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#ifndef HELPINDEXER_HXX
-#define HELPINDEXER_HXX
-
-#include <l10ntools/dllapi.h>
-
-#include <rtl/ustring.hxx>
-#include <set>
-
-// I assume that TCHAR is defined as wchar_t throughout
-
-namespace lucene
-{
-namespace document
-{
-class Document;
-}
-namespace util
-{
-class Reader;
-}
-}
-
-class L10N_DLLPUBLIC HelpIndexer {
- private:
- rtl::OUString d_lang;
- rtl::OUString d_module;
- rtl::OUString d_captionDir;
- rtl::OUString d_contentDir;
- rtl::OUString d_indexDir;
- rtl::OUString d_error;
- std::set<rtl::OUString> d_files;
-
- public:
-
- /**
- * @param lang Help files language.
- * @param module The module of the helpfiles.
- * @param srcDir The help directory to index
- * @param outDir The directory to write the "module".idxl directory to
- */
- HelpIndexer(rtl::OUString const &lang, rtl::OUString const &module,
- rtl::OUString const &srcDir, rtl::OUString const &outDir);
-
- /**
- * Run the indexer.
- * @return true if index successfully generated.
- */
- bool indexDocuments();
-
- /**
- * Get the error string (empty if no error occurred).
- */
- rtl::OUString const & getErrorMessage();
-
- private:
-
- /**
- * Scan the caption & contents directories for help files.
- */
- bool scanForFiles();
-
- /**
- * Scan for files in the given directory.
- */
- bool scanForFiles(rtl::OUString const &path);
-
- /**
- * Fill the Document with information on the given help file.
- */
- bool helpDocument(rtl::OUString const & fileName, lucene::document::Document *doc);
-
- /**
- * Create a reader for the given file, and create an "empty" reader in case the file doesn't exist.
- */
- lucene::util::Reader *helpFileReader(rtl::OUString const & path);
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/inc/l10ntools/HelpLinker.hxx b/l10ntools/inc/l10ntools/HelpLinker.hxx
deleted file mode 100644
index 4befcd4669a1..000000000000
--- a/l10ntools/inc/l10ntools/HelpLinker.hxx
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef HELPLINKER_HXX
-#define HELPLINKER_HXX
-
-#include <l10ntools/dllapi.h>
-#include <libxslt/transform.h>
-
-#ifdef AIX
-# undef _THREAD_SAFE
-#endif
-
-#define DBHELP_ONLY
-
-class L10N_DLLPUBLIC IndexerPreProcessor
-{
-private:
- std::string m_aModuleName;
- fs::path m_fsIndexBaseDir;
- fs::path m_fsCaptionFilesDirName;
- fs::path m_fsContentFilesDirName;
-
- xsltStylesheetPtr m_xsltStylesheetPtrCaption;
- xsltStylesheetPtr m_xsltStylesheetPtrContent;
-
-public:
- IndexerPreProcessor( const std::string& aModuleName, const fs::path& fsIndexBaseDir,
- const fs::path& idxCaptionStylesheet, const fs::path& idxContentStylesheet );
- ~IndexerPreProcessor();
-
- void processDocument( xmlDocPtr doc, const std::string& EncodedDocPath );
-};
-
-class L10N_DLLPUBLIC HelpLinker
-{
-public:
- void main(std::vector<std::string> &args,
- std::string* pExtensionPath = NULL,
- std::string* pDestination = NULL,
- const rtl::OUString* pOfficeHelpPath = NULL )
-
- throw( HelpProcessingException );
-
- HelpLinker()
- : m_pIndexerPreProcessor(NULL)
- {}
- ~HelpLinker()
- { delete m_pIndexerPreProcessor; }
-
-private:
- Stringtable additionalFiles;
- HashSet helpFiles;
- fs::path sourceRoot;
- fs::path embeddStylesheet;
- fs::path idxCaptionStylesheet;
- fs::path idxContentStylesheet;
- fs::path zipdir;
- fs::path outputFile;
- std::string extsource;
- std::string extdestination;
- std::string module;
- std::string lang;
- std::string extensionPath;
- std::string extensionDestination;
- bool bExtensionMode;
- fs::path indexDirName;
- fs::path indexDirParentName;
- IndexerPreProcessor* m_pIndexerPreProcessor;
- void initIndexerPreProcessor();
- void link() throw( HelpProcessingException );
- void addBookmark( DB* dbBase, FILE* pFile_DBHelp, std::string thishid,
- const std::string& fileB, const std::string& anchorB,
- const std::string& jarfileB, const std::string& titleB );
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/inc/l10ntools/HelpSearch.hxx b/l10ntools/inc/l10ntools/HelpSearch.hxx
deleted file mode 100644
index e4a846a926dd..000000000000
--- a/l10ntools/inc/l10ntools/HelpSearch.hxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
- * (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#ifndef HELPSEARCH_HXX
-#define HELPSEARCH_HXX
-
-#include <l10ntools/dllapi.h>
-
-#include <rtl/ustring.hxx>
-#include <vector>
-
-class L10N_DLLPUBLIC HelpSearch{
- private:
- rtl::OUString d_lang;
- rtl::OString d_indexDir;
-
- public:
-
- /**
- * @param lang Help files language.
- * @param indexDir The directory where the index files are stored.
- */
- HelpSearch(rtl::OUString const &lang, rtl::OUString const &indexDir);
-
- /**
- * Query the index for a certain query string.
- * @param queryStr The query.
- * @param captionOnly Set to true to search in the caption, not the content.
- * @param rDocuments Vector to write the paths of the found documents.
- * @param rScores Vector to write the scores to.
- */
- bool query(rtl::OUString const &queryStr, bool captionOnly,
- std::vector<rtl::OUString> &rDocuments, std::vector<float> &rScores);
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/inc/l10ntools/dllapi.h b/l10ntools/inc/l10ntools/dllapi.h
deleted file mode 100644
index 184a590944ed..000000000000
--- a/l10ntools/inc/l10ntools/dllapi.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _L10N_DLLAPI_H
-#define _L10N_DLLAPI_H
-
-#include "sal/config.h"
-#include "sal/types.h"
-
-#if defined L10N_DLLIMPLEMENTATION
-#define L10N_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
-#else
-#define L10N_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
-#endif
-
-#if defined UNX && ! defined MACOS
-#define L10N_PLUGIN_PUBLIC L10N_DLLPUBLIC
-#else
-#define L10N_PLUGIN_PUBLIC SAL_DLLPRIVATE
-#endif
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/inc/tokens.h b/l10ntools/inc/tokens.h
index 1d035a7ddef7..694bead2dd10 100644
--- a/l10ntools/inc/tokens.h
+++ b/l10ntools/inc/tokens.h
@@ -26,7 +26,7 @@
/*------------------------------------------------------ */
/*------------------------------------------------------ */
#define IGNOREDTOKENS 400 /* #include | #pragma | //... | ... */
-#define COMMEND 401 /*... */
+#define COMMENT 401 /*... */
#define DEFINEDRES 402 /* Text = { */
#define ANYTOKEN 404 /* XYZ */
#define UNKNOWNTOKEN 405 /* XYZ[ \t]$ */
diff --git a/l10ntools/prj/build.lst b/l10ntools/prj/build.lst
index c1e47969eddb..5f7fca144415 100644
--- a/l10ntools/prj/build.lst
+++ b/l10ntools/prj/build.lst
@@ -1,3 +1,3 @@
-tr l10ntools : BERKELEYDB:berkeleydb EXPAT:expat LIBXSLT:libxslt CLUCENE:clucene sal NULL
+tr l10ntools : EXPAT:expat LIBXSLT:libxslt sal NULL
tr l10ntools usr1 - all tr_mkout NULL
tr l10ntools\prj nmake - all tr_prj NULL
diff --git a/l10ntools/scripts/update_tree.pl b/l10ntools/scripts/update_tree.pl
new file mode 100644
index 000000000000..02faf6a37c72
--- /dev/null
+++ b/l10ntools/scripts/update_tree.pl
@@ -0,0 +1,394 @@
+:
+eval 'exec perl -wS $0 ${1+"$@"}'
+ if 0;
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+use Cwd 'abs_path';
+use File::Find;
+use File::Copy qw/cp mv/;
+use File::Basename;
+
+# update the tree files in <platform>/misc/*
+
+$| = 1;
+
+my $prj = $ENV{PWD};
+
+my $inpath = $ENV{WORKDIR};
+terminate() if ( ! defined $inpath );
+
+my $destpath = $inpath;
+my $with_lang = $ARGV[1];
+my $xmllint = $ENV{XMLLINT} || "$ENV{OUTDIR_FOR_BUILD}/bin/xmllint";
+
+$tree_target_prefix = $ARGV[4];
+
+# Always use / directory separators
+$prj =~ s/\\/\//g if defined($prj);
+$inpath =~ s/\\/\//g;
+$destpath =~ s/\\/\//g;
+
+if ( ! defined $prj ) {
+# do someting that works for manual call
+ ($scriptname = `pwd`) =~ s/\n/\/$0/;
+ ($tree_src = $scriptname) =~ s/\/update_tree.pl/\/..\/source\/auxiliary/;
+ ($tree_dest = $scriptname) =~ s/\/update_tree.pl/\/..\/$destpath\/misc/;
+ ($source_dir = $scriptname) =~ s/\/update_tree.pl/\/..\/source/;
+ ($source_dir_xhp = $scriptname) =~ s/\/update_tree.pl/\/..\/source/;
+
+ if ( defined $ENV{TRYSDF} || defined $ENV{LOCALIZESDF} )
+ {
+ if( defined $ENV{LOCALIZATION_FOUND} && $ENV{LOCALIZATION_FOUND} eq "YES" )
+ {
+ $source_dir = $ENV{TRYSDF};
+ }
+ elsif( defined $ENV{LOCALIZESDF} && $ENV{LOCALIZESDF} ne "" )
+ {
+ $source_dir = $ENV{LOCALIZESDF};
+ }
+ $source_dir =~ s/\/auxiliary\/localize.sdf$// ;
+ }
+ $treestrings = "$ARGV[0]";
+ $treestrings=~ s/\/*.tree//g;
+} else {
+ $source_dir_xhp = "$prj/source/presenter/help";
+ $tree_src = "$ARGV[0]";
+ $tree_src =~ s/\/help.tree//g;
+ $tree_dest = "$ARGV[3]";
+ $tree_dest =~ s/\/help.tree//g;
+ $source_dir = "$ARGV[2]";
+ $source_dir =~ s/\/localize.sdf//g;
+ $treestrings = "$ARGV[0]";
+ $treestrings=~ s/\/help.tree/\/tree_strings.xhp/g;
+
+ if( defined $ENV{LOCALIZATION_FOUND} && $ENV{LOCALIZATION_FOUND} eq "YES" )
+ {
+ $source_dir = $ENV{TRYSDF};
+ }
+ elsif ( defined $ENV{LOCALIZESDF} && $ENV{LOCALIZESDF} ne "" )
+ {
+ $source_dir = $ENV{LOCALIZESDF};
+ }
+ $source_dir =~ s/\/auxiliary\/localize.sdf$// ;
+}
+
+# Get the English tree files as master
+#-------------------------------
+# Update English from xhp
+#-------------------------------
+&do_english;
+#-------------------------------
+# Update localizations from sdf
+#-------------------------------
+
+if( defined $with_lang && $with_lang ne "" )
+{
+ @langs = split /\s+/, $with_lang;
+ &read_loc;
+ for $l(@langs)
+ {
+ #if ($l ne "en-US") {
+ &do_lang($l);
+ #}
+ }
+}
+else
+{
+ print "\nNo WITH_LANG set, skipping l10n\n";
+}
+#-------------------------------
+#
+
+####################
+# SUBS
+####################
+sub terminate {
+ $err = shift;
+ print "$err\n\n";
+ $msg = <<"MSG";
+
+update_tree.pl
+ all languages in WITH_LANG are processed. WITH_LANG=ALL is
+ not supported in manual calls.
+
+ Updates the *.tree files.
+ At first, the English file is updated based on the English
+ help topic titles as read from the help files. Then, the
+ localized tree files are written based on the English tree
+ file and the localized help topic titles.
+
+ Requires a valid LibreOffice build environment.
+MSG
+ print "$msg\n";
+ exit( -1 );
+ # die "$msg\n";
+}
+
+#---------------------------------------------------
+
+sub do_english {
+ undef %helpsection; undef %node;
+ &readtreestrings;
+ &gettreefiles;
+}
+
+#---------------------------------------------------
+sub do_lang {
+ $lng = shift;
+ print "Processing $lng\n";
+ &processtreefiles($lng);
+}
+
+#---------------------------------------------------
+sub readtreestrings {
+ if (open TREE, $treestrings) {
+ print "Processing readtreestrings\n";
+ while (<TREE>) {
+ chomp;
+ s/<\/*help:productname>//gis;
+ if (/help_section/) {
+ s/^\s*<.*help_section//;
+ s/<\/.*$//;
+ ($id = $_) =~ s/^.*id=&quot;(\d+)&quot;.*$/$1/;
+ ($title = $_) =~ s/^.*title=&quot;(.*)&quot;.*$/$1/;
+ $helpsection{$id} = $title;
+ }
+
+ if (/node id=/) {
+ s/^\s*<.*node //;
+ s/<\/.*$//;
+ ($id = $_) =~ s/^.*id=&quot;(\d+)&quot;.*$/$1/;
+ ($title = $_) =~ s/^.*title=&quot;(.*)&quot;.*$/$1/;
+ $node{$id} = $title;
+ }
+ }
+ close TREE;
+ } else {
+ &terminate("Error opening $treestrings");
+ }
+}
+
+#------------------------------------
+sub gettreefiles {
+ # Read the tree files from the directory
+ # this list is also used for all foreign languages
+ if (opendir ENUS, "$tree_src") {
+ @treeviews = grep /\.tree/, readdir ENUS;
+ closedir ENUS;
+ } else {
+ &terminate("Cannot open directory $tree_src");
+ }
+}
+
+#------------------------------------
+sub processtreefiles {
+ $lng = shift;
+ use File::Temp qw/ tempfile /;
+ use File::Spec;
+
+ for $tv(@treeviews) {
+ @lines = &readtv("$tree_src/$tv");
+ for $l(@lines) {
+ if ($l =~ /topic/) {
+ ($id = $l) =~ s/^.*id="([^"]*)".*$/$1/gis;
+ ($module = $id) =~ s/^([^\/]*).*$/$1/;
+ $id =~ s/^.*?\///;
+ $file = "$source_dir_xhp/$lng/$id";
+
+ if ($lng eq 'en-US') { # english comes from the file
+ $temp = $l;
+ $temp =~ s/^.*<topic[^>]+id=".*"[^>]*>([^<]*)<\/topic>.*$/$1/gis;
+ $temp =~ s/&apos;/\'/gis; $temp=~ s/&amp;/+/gis;
+ $temp =~ s/&quot;/\'/gis; $temp =~ s/&/+/gis;
+
+ $id =~s/^.*\/(.*.xhp)/$1/;
+ $l = "<topic id=\"$module/$tree_target_prefix/$id\">$temp</topic>\n";
+ } else { # localized comes from the localize sdf
+ if (defined($loc_title{$lng}->{$id})) {
+ $xhpname = $id;
+ $xhpname =~s/^.*\/(.*.xhp)/$1/;
+ $l = "<topic id=\"$module/$tree_target_prefix/$xhpname\">$loc_title{$lng}->{$id}</topic>\n";
+ } else {
+ }
+ }
+ }
+
+ if ($l =~/<node/) {
+ ($id = $l) =~ s/^.*id="(\d+)".*$/$1/gis;
+ if ($lng eq 'en-US') {
+ if (defined($node{$id})) {
+ $l =~ s/title="(.*)"/title="$node{$id}"/;
+ } else {
+ $l =~ s/title="(.*)"/title="NOTFOUND:$id"/;
+ }
+ } else {
+ if (defined($node{$lng}->{$id})) {
+ $l =~ s/title="(.*)"/title="$node{$lng}->{$id}"/;
+ }
+ }
+ }
+
+ if ($l =~/<help_section/) {
+ ($id = $l) =~ s/^.*id="(\d+)".*$/$1/gis;
+ if ($lng eq 'en-US') {
+ if (defined($helpsection{$id})) {
+ $l =~ s/title="(.*)"/title="$helpsection{$id}"/;
+ } else {
+ $l =~ s/title="(.*)"/title="NOTFOUND:$id"/;
+ }
+ } else {
+ if (defined($helpsection{$lng}->{$id})) {
+ $l =~ s/title="(.*)"/title="$helpsection{$lng}->{$id}"/;
+ }
+ }
+ }
+ }
+
+
+ my $treeoutdir = "$tree_dest";
+ my $tmpname_template=$tv."_XXXXX";
+ my ( $treetmpfilehandle, $treetmpfile ) = tempfile($tmpname_template , DIR => File::Spec->tmpdir() );
+ close $treetmpfilehandle ;
+
+ if (open TV, ">$treetmpfile") {
+ for $line(@lines) {
+ $line =~ s/\$\[officename\]/%PRODUCTNAME/g;
+ $line =~ s/\$\[officeversion\]/%PRODUCTVERSION/g;
+ print TV $line;
+ }
+ close TV;
+ chmod 0664, $treetmpfile or &terminate("Cannot change rights on $treetmpfile");
+ if( $^O eq 'MSWin32' )
+ {
+ $tree_dest =~ s/\//\\/g ;
+ unlink "$tree_dest\\$tv" ;
+ mv $treetmpfile , "$tree_dest\\$tv" or &terminate("Cannot mv $treetmpfile to $tree_dest\\$tv" );
+ }
+ else
+ {
+ unlink "$tree_dest/$tv" ;
+ my $ret=mv $treetmpfile , "$tree_dest/$tv" or &terminate("Cannot write to $tree_dest/$tv - Error $!");
+ my $ret=mv "$tree_dest/$tv" , "$tree_dest/$tv" or &terminate("Cannot write to $tree_dest/$tv - Error $!");
+ #xmllint is crashing on windows, fixme
+ if( $^O ne 'cygwin' )
+ {
+ system("$xmllint --noout --noent $tree_dest/$tv") == 0 or &terminate("$tree_dest/$tv is illformed xml ($xmllint on $^O)" );
+ }
+ }
+ } else {
+ &terminate("Cannot write to $tvout");
+ }
+ }
+}
+
+#------------------------------------
+sub readtv {
+ my $f = shift;
+ if (open TV, $f) {
+ $/ = "\n";
+ my @l = <TV>;
+ close TV;
+ return @l;
+ } else {
+ &terminate("Error opening $f");
+ }
+}
+
+#-------------------------------------
+# read entries from localize.sdf files
+#-------------------------------------
+sub read_loc {
+ $/ = "\n";
+ my $path = "$source_dir";
+ @files = `find $source_dir -name localize.sdf`;
+ for my $fname (@files) {
+ $FS = '\t';
+ open(LOCALIZE_SDF, $fname) || die 'Cannot open "localize.sdf".'."$fname";
+ while (<LOCALIZE_SDF>) {
+ my $sdf_line = $_;
+ my ($Fld1,$file,$Fld3,$Fld4,$id,$Fld6,$Fld7,$Fld8,$Fld9,$lang,$text) = split($FS, $sdf_line , 12);
+ next if ( $Fld1 =~ /^#/);
+ if ($id eq 'tit') {
+ #strip filename
+ $file =~ s/.*text\\/text\\/g;
+ #convert \ to / in filename
+ $file =~ s/\\/\//g;
+ $file =~ s/^.*\/(.*)\/(.*)$/$1\/$2/;
+ #fpe: i46823 - need to encode &s, added encoding
+ $text =~ s/&(?!amp;)/&amp;/g;
+ #help xml tags are not allowed in .tree files
+ $text =~ s/\\<.*?\\>//g;
+ # add entry to the hash
+
+ $loc_title{$lang}->{$file} = $text;
+ }
+ if ($file =~ /tree_strings.xhp/) {
+ #strip filename
+ $file =~ s/.*text/text/g;
+ #convert \ to / in filename
+ $file =~ s/\\/\//g;
+ if ($text =~ /^<help_section/) {
+ #example: <help_section application="scalc" id="08" title="表計算ドキュメント">
+ my ($fld1,$app,$fld3,$id,$fld5,$sec_title) = split('"', $text, 7);
+ #fpe: i46823 - need to encode &s, added encoding
+ if( defined $sec_title )
+ {
+ $sec_title =~ s/&(?!amp;)/&amp;/g;
+ #help xml tags are not allowed in .tree files
+ $sec_title =~ s/\\<.*?\\>//g;
+ #unquot \<item ... /\>
+ terminate( "\n\nERROR: Bad string in file '$fname' will cause invalid xml tree file \n---\n'$sdf_line'\n---\nPlease remove or replace < = '&lt;' and > = '&gt;' within the title attribute '$sec_title'\n") , if( $sec_title =~ /[\<\>]/ );
+ $helpsection{$lang}->{$id} = $sec_title;
+ }
+ } elsif ($text =~/<node id=/) {
+ # example: <node id="0205" title="Tabelas em documentos de texto">
+ # BEWARE: title may contain escaped '"' so only match " not preceded by \
+ # using a zero‐width negative look‐behind assertion.
+ my ($fld1,$id,$fld3,$node_title,$Fld5) = split(/(?<!\\)"/, $text, 5);
+ #fpe: i46823 - need to encode &s, added encoding
+ if( defined $node_title )
+ {
+ $node_title =~ s/&(?!amp;)/&amp;/g;
+ #help xml tags are not allowed in .tree files
+ $node_title =~ s/\\<.*?\\>//g;
+ terminate( "\n\nERROR: Bad string in '$fname' will cause invalid xml tree file \n---\n'$sdf_line'\n---\nPlease remove or replace < = '&lt;' and > = '&gt;' within the title attribute '$node_title'\n") , if( $node_title =~ /[\<\>]/ );
+ }
+ $node{$lang}->{$id} = $node_title;
+ }
+ }
+ }
+ close LOCALIZE_SDF;
+ }
+ # statistics
+ $total_elements=0;
+ foreach $lang (keys %loc_title) {
+ $no_elements = scalar(keys(%{$loc_title{$lang}}));
+ push(@langstat, "$lang:\t ".$no_elements." matches\n");
+ $total_elements += $no_elements;
+ }
+}
diff --git a/l10ntools/source/cfglex.l b/l10ntools/source/cfglex.l
index 7476cbff0eb7..16ddf289fda3 100644
--- a/l10ntools/source/cfglex.l
+++ b/l10ntools/source/cfglex.l
@@ -89,8 +89,8 @@ int bText=0;
pChar[1] = 0x00;
pChar[0] = c3;
- workOnTokenSet( COMMEND, yytext );
- workOnTokenSet( COMMEND, pChar );
+ workOnTokenSet( COMMENT, yytext );
+ workOnTokenSet( COMMENT, pChar );
for(;;) {
if ( c3 == EOF )
@@ -102,7 +102,7 @@ int bText=0;
c3 = yyinput();
pChar[0] = c3;
- workOnTokenSet( COMMEND, pChar );
+ workOnTokenSet( COMMENT, pChar );
}
}
@@ -114,7 +114,7 @@ int bText=0;
\<[^\>\!]*\> {
bText = 0;
if ( yytext[ 1 ] == '!' && yytext[ 2 ] == '-' && yytext[ 3 ] == '-' )
- workOnTokenSet( COMMEND, yytext );
+ workOnTokenSet( COMMENT, yytext );
else
workOnTokenSet( CFG_UNKNOWNTAG, yytext );
}
diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx
index af662d009b46..1abc00d17ac9 100644
--- a/l10ntools/source/gsicheck.cxx
+++ b/l10ntools/source/gsicheck.cxx
@@ -42,10 +42,10 @@
#include "tagtest.hxx"
#include "gsicheck.hxx"
-namespace {
-
sal_Int32 const MAX_GID_LID_LEN = 250;
+namespace {
+
rtl::OString copyUpTo(
rtl::OString const & text, sal_Int32 start, sal_Int32 maximumLength)
{
@@ -641,6 +641,15 @@ void GSIBlock::WriteFixed( LazyStream &aFixOut )
}
}
+
+/*****************************************************************************/
+/*****************************************************************************/
+/*****************************************************************************/
+/*****************************************************************************/
+/*****************************************************************************/
+/*****************************************************************************/
+/*****************************************************************************/
+
/*****************************************************************************/
void Help()
/*****************************************************************************/
diff --git a/l10ntools/source/help/HelpCompiler.cxx b/l10ntools/source/help/HelpCompiler.cxx
deleted file mode 100644
index 2a5fda5a79ce..000000000000
--- a/l10ntools/source/help/HelpCompiler.cxx
+++ /dev/null
@@ -1,461 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-#include "HelpCompiler.hxx"
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libxslt/xslt.h>
-#include <libxslt/xsltInternals.h>
-#include <libxslt/transform.h>
-#include <libxslt/xsltutils.h>
-#include <osl/thread.hxx>
-
-static void impl_sleep( sal_uInt32 nSec )
-{
- TimeValue aTime;
- aTime.Seconds = nSec;
- aTime.Nanosec = 0;
-
- osl::Thread::wait( aTime );
-}
-
-HelpCompiler::HelpCompiler(StreamTable &in_streamTable, const fs::path &in_inputFile,
- const fs::path &in_src, const fs::path &in_resEmbStylesheet,
- const std::string &in_module, const std::string &in_lang, bool in_bExtensionMode)
- : streamTable(in_streamTable), inputFile(in_inputFile),
- src(in_src), module(in_module), lang(in_lang), resEmbStylesheet(in_resEmbStylesheet),
- bExtensionMode( in_bExtensionMode )
-{
- xmlKeepBlanksDefaultValue = 0;
- char* guitmp = getenv("GUI");
- if (guitmp)
- {
- gui = (strcmp(guitmp, "UNX") ? gui : "UNIX");
- gui = (strcmp(guitmp, "MAC") ? gui : "MAC");
- gui = (strcmp(guitmp, "WNT") ? gui : "WIN");
- }
-}
-
-xmlDocPtr HelpCompiler::getSourceDocument(const fs::path &filePath)
-{
- static const char *params[4 + 1];
- static xsltStylesheetPtr cur = NULL;
-
- xmlDocPtr res;
- if( bExtensionMode )
- {
- res = xmlParseFile(filePath.native_file_string().c_str());
- if( !res ){
- impl_sleep( 3 );
- res = xmlParseFile(filePath.native_file_string().c_str());
- }
- }
- else
- {
- if (!cur)
- {
- static std::string fsroot('\'' + src.toUTF8() + '\'');
- static std::string esclang('\'' + lang + '\'');
-
- xmlSubstituteEntitiesDefault(1);
- xmlLoadExtDtdDefaultValue = 1;
- cur = xsltParseStylesheetFile((const xmlChar *)resEmbStylesheet.native_file_string().c_str());
-
- int nbparams = 0;
- params[nbparams++] = "Language";
- params[nbparams++] = esclang.c_str();
- params[nbparams++] = "fsroot";
- params[nbparams++] = fsroot.c_str();
- params[nbparams] = NULL;
- }
- xmlDocPtr doc = xmlParseFile(filePath.native_file_string().c_str());
- if( !doc )
- {
- impl_sleep( 3 );
- doc = xmlParseFile(filePath.native_file_string().c_str());
- }
-
- //???res = xmlParseFile(filePath.native_file_string().c_str());
-
- res = xsltApplyStylesheet(cur, doc, params);
- xmlFreeDoc(doc);
- }
- return res;
-}
-
-// returns a node representing the whole stuff compiled for the current
-// application.
-xmlNodePtr HelpCompiler::clone(xmlNodePtr node, const std::string& appl)
-{
- xmlNodePtr root = xmlCopyNode(node, 2);
- if (node->xmlChildrenNode)
- {
- xmlNodePtr list = node->xmlChildrenNode;
- while (list)
- {
- if (strcmp((const char*)list->name, "switchinline") == 0 || strcmp((const char*)list->name, "switch") == 0)
- {
- std::string tmp="";
- if (strcmp((const char*)xmlGetProp(list, (xmlChar*)"select"), "sys"))
- {
- tmp = gui;
- }
- if (strcmp((const char*)xmlGetProp(list, (xmlChar*)"select"), "appl"))
- {
- tmp = appl;
- }
- if (tmp.compare("") != 0)
- {
- bool isCase=false;
- xmlNodePtr caseList=list->xmlChildrenNode;
- while (caseList)
- {
- xmlChar *select = xmlGetProp(caseList, (xmlChar*)"select");
- if (select)
- {
- if (!strcmp((const char*)select, tmp.c_str()) && !isCase)
- {
- isCase=true;
- xmlNodePtr clp = caseList->xmlChildrenNode;
- while (clp)
- {
- xmlAddChild(root, clone(clp, appl));
- clp = clp->next;
- }
- }
- xmlFree(select);
- }
- else
- {
- if ((strcmp((const char*)caseList->name, "defaultinline") != 0) && (strcmp((const char*)caseList->name, "default") != 0))
- {
- xmlAddChild(root, clone(caseList, appl));
- }
- else
- {
- if (!isCase)
- {
- xmlNodePtr clp = caseList->xmlChildrenNode;
- while (clp)
- {
- xmlAddChild(root, clone(clp, appl));
- clp = clp->next;
- }
- }
- }
- }
- caseList = caseList->next;
- }
- }
- }
- else
- {
- xmlAddChild(root, clone(list, appl));
- }
- list = list->next;
- }
- }
- return root;
-}
-
-class myparser
-{
-public:
- std::string documentId;
- std::string fileName;
- std::string title;
- HashSet *hidlist;
- Hashtable *keywords;
- Stringtable *helptexts;
-private:
- HashSet extendedHelpText;
-public:
- myparser(const std::string &indocumentId, const std::string &infileName,
- const std::string &intitle) : documentId(indocumentId), fileName(infileName),
- title(intitle)
- {
- hidlist = new HashSet;
- keywords = new Hashtable;
- helptexts = new Stringtable;
- }
- void traverse( xmlNodePtr parentNode );
-private:
- std::string module;
- std::string dump(xmlNodePtr node);
-};
-
-std::string myparser::dump(xmlNodePtr node)
-{
- std::string app;
- if (node->xmlChildrenNode)
- {
- xmlNodePtr list = node->xmlChildrenNode;
- while (list)
- {
- app += dump(list);
- list = list->next;
- }
- }
- if (xmlNodeIsText(node))
- {
- xmlChar *pContent = xmlNodeGetContent(node);
- app += std::string((const char*)pContent);
- xmlFree(pContent);
- }
- return app;
-}
-
-void trim(std::string& str)
-{
- std::string::size_type pos = str.find_last_not_of(' ');
- if(pos != std::string::npos)
- {
- str.erase(pos + 1);
- pos = str.find_first_not_of(' ');
- if(pos != std::string::npos)
- str.erase(0, pos);
- }
- else
- str.erase(str.begin(), str.end());
-}
-
-void myparser::traverse( xmlNodePtr parentNode )
-{
- // traverse all nodes that belong to the parent
- xmlNodePtr test ;
- for (test = parentNode->xmlChildrenNode; test; test = test->next)
- {
- if (fileName.empty() && !strcmp((const char*)test->name, "filename"))
- {
- xmlNodePtr node = test->xmlChildrenNode;
- if (xmlNodeIsText(node))
- {
- xmlChar *pContent = xmlNodeGetContent(node);
- fileName = std::string((const char*)pContent);
- xmlFree(pContent);
- }
- }
- else if (title.empty() && !strcmp((const char*)test->name, "title"))
- {
- title = dump(test);
- if (title.empty())
- title = "<notitle>";
- }
- else if (!strcmp((const char*)test->name, "bookmark"))
- {
- xmlChar *branchxml = xmlGetProp(test, (const xmlChar*)"branch");
- xmlChar *idxml = xmlGetProp(test, (const xmlChar*)"id");
- std::string branch((const char*)branchxml);
- std::string anchor((const char*)idxml);
- xmlFree (branchxml);
- xmlFree (idxml);
-
- std::string hid;
-
- if (branch.find("hid") == 0)
- {
- size_t index = branch.find('/');
- if (index != std::string::npos)
- {
- hid = branch.substr(1 + index);
- // one shall serve as a documentId
- if (documentId.empty())
- documentId = hid;
- extendedHelpText.push_back(hid);
- std::string foo = anchor.empty() ? hid : hid + "#" + anchor;
- HCDBG(std::cerr << "hid pushback" << foo << std::endl);
- hidlist->push_back( anchor.empty() ? hid : hid + "#" + anchor);
- }
- else
- continue;
- }
- else if (branch.compare("index") == 0)
- {
- LinkedList ll;
-
- for (xmlNodePtr nd = test->xmlChildrenNode; nd; nd = nd->next)
- {
- if (strcmp((const char*)nd->name, "bookmark_value"))
- continue;
-
- std::string embedded;
- xmlChar *embeddedxml = xmlGetProp(nd, (const xmlChar*)"embedded");
- if (embeddedxml)
- {
- embedded = std::string((const char*)embeddedxml);
- xmlFree (embeddedxml);
- std::transform (embedded.begin(), embedded.end(),
- embedded.begin(), tocharlower);
- }
-
- bool isEmbedded = !embedded.empty() && embedded.compare("true") == 0;
- if (isEmbedded)
- continue;
-
- std::string keyword = dump(nd);
- size_t keywordSem = keyword.find(';');
- if (keywordSem != std::string::npos)
- {
- std::string tmppre =
- keyword.substr(0,keywordSem);
- trim(tmppre);
- std::string tmppos =
- keyword.substr(1+keywordSem);
- trim(tmppos);
- keyword = tmppre + ";" + tmppos;
- }
- ll.push_back(keyword);
- }
- if (!ll.empty())
- (*keywords)[anchor] = ll;
- }
- else if (branch.compare("contents") == 0)
- {
- // currently not used
- }
- }
- else if (!strcmp((const char*)test->name, "ahelp"))
- {
- std::string text = dump(test);
- trim(text);
- std::string name;
-
- HashSet::const_iterator aEnd = extendedHelpText.end();
- for (HashSet::const_iterator iter = extendedHelpText.begin(); iter != aEnd; ++iter)
- {
- name = *iter;
- (*helptexts)[name] = text;
- }
- extendedHelpText.clear();
- }
- // traverse children
- traverse(test);
- }
-}
-
-bool HelpCompiler::compile( void ) throw( HelpProcessingException )
-{
- // we now have the jaroutputstream, which will contain the document.
- // now determine the document as a dom tree in variable docResolved
-
- xmlDocPtr docResolvedOrg = getSourceDocument(inputFile);
-
- // now add path to the document
- // resolve the dom
-
- if (!docResolvedOrg)
- {
- impl_sleep( 3 );
- docResolvedOrg = getSourceDocument(inputFile);
- if( !docResolvedOrg )
- {
- std::stringstream aStrStream;
- aStrStream << "ERROR: file not existing: " << inputFile.native_file_string().c_str() << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- }
-
- std::string documentId;
- std::string fileName;
- std::string title;
- // returns a clone of the document with switch-cases resolved
- std::string appl = module.substr(1);
- for (unsigned int i = 0; i < appl.length(); ++i)
- {
- appl[i]=toupper(appl[i]);
- }
- xmlNodePtr docResolved = clone(xmlDocGetRootElement(docResolvedOrg), appl);
- myparser aparser(documentId, fileName, title);
- aparser.traverse(docResolved);
- documentId = aparser.documentId;
- fileName = aparser.fileName;
- title = aparser.title;
-
- HCDBG(std::cerr << documentId << " : " << fileName << " : " << title << std::endl);
-
- xmlDocPtr docResolvedDoc = xmlCopyDoc(docResolvedOrg, false);
- xmlDocSetRootElement(docResolvedDoc, docResolved);
-
- streamTable.dropappl();
- streamTable.appl_doc = docResolvedDoc;
- streamTable.appl_hidlist = aparser.hidlist;
- streamTable.appl_helptexts = aparser.helptexts;
- streamTable.appl_keywords = aparser.keywords;
-
- streamTable.document_id = documentId;
- streamTable.document_path = fileName;
- streamTable.document_title = title;
- std::string actMod = module;
-
- if ( !bExtensionMode && !fileName.empty())
- {
- if (fileName.find("/text/") == 0)
- {
- int len = strlen("/text/");
- actMod = fileName.substr(len);
- actMod = actMod.substr(0, actMod.find('/'));
- }
- }
- streamTable.document_module = actMod;
- xmlFreeDoc(docResolvedOrg);
- return true;
-}
-
-namespace fs
-{
- rtl_TextEncoding getThreadTextEncoding( void )
- {
- static bool bNeedsInit = true;
- static rtl_TextEncoding nThreadTextEncoding;
- if( bNeedsInit )
- {
- bNeedsInit = false;
- nThreadTextEncoding = osl_getThreadTextEncoding();
- }
- return nThreadTextEncoding;
- }
-
- void create_directory(const fs::path indexDirName)
- {
- HCDBG(
- std::cerr << "creating " <<
- rtl::OUStringToOString(indexDirName.data, RTL_TEXTENCODING_UTF8).getStr()
- << std::endl
- );
- osl::Directory::createPath(indexDirName.data);
- }
-
- void copy(const fs::path &src, const fs::path &dest)
- {
- osl::File::copy(src.data, dest.data);
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/HelpCompiler.hxx b/l10ntools/source/help/HelpCompiler.hxx
deleted file mode 100644
index 49ebd602501d..000000000000
--- a/l10ntools/source/help/HelpCompiler.hxx
+++ /dev/null
@@ -1,275 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef HELPCOMPILER_HXX
-#define HELPCOMPILER_HXX
-
-#include <string>
-#include <boost/unordered_map.hpp>
-#include <vector>
-#include <list>
-#include <fstream>
-#include <sstream>
-#include <algorithm>
-#include <ctype.h>
-#ifdef SYSTEM_DB_HEADER
-#include SYSTEM_DB_HEADER
-#else
-#include <berkeleydb/db.h>
-#endif
-
-#include <boost/shared_ptr.hpp>
-
-#include <libxml/xmlmemory.h>
-#include <libxml/debugXML.h>
-#include <libxml/HTMLtree.h>
-#include <libxml/xmlIO.h>
-#include <libxml/xinclude.h>
-#include <libxml/catalog.h>
-
-#include <rtl/ustring.hxx>
-#include <osl/thread.h>
-#include <osl/process.h>
-#include <osl/file.hxx>
-
-#include <compilehelp.hxx>
-
-#if OSL_DEBUG_LEVEL > 2
- #include <iostream>
- #define HCDBG(foo) do { if (1) foo; } while(0)
-#else
- #define HCDBG(foo) do { } while(0)
-#endif
-
-namespace fs
-{
- rtl_TextEncoding getThreadTextEncoding( void );
-
- enum convert { native };
- class path
- {
- public:
- ::rtl::OUString data;
- public:
- path() {}
- path(const path &rOther) : data(rOther.data) {}
- path(const std::string &in, convert)
- {
- rtl::OUString sWorkingDir;
- osl_getProcessWorkingDir(&sWorkingDir.pData);
-
- rtl::OString tmp(in.c_str());
- rtl::OUString ustrSystemPath(rtl::OStringToOUString(tmp, getThreadTextEncoding()));
- osl::File::getFileURLFromSystemPath(ustrSystemPath, data);
- osl::File::getAbsoluteFileURL(sWorkingDir, data, data);
- }
- path(const std::string &FileURL)
- {
- rtl::OString tmp(FileURL.c_str());
- data = rtl::OStringToOUString(tmp, getThreadTextEncoding());
- }
- std::string native_file_string() const
- {
- ::rtl::OUString ustrSystemPath;
- osl::File::getSystemPathFromFileURL(data, ustrSystemPath);
- rtl::OString tmp(rtl::OUStringToOString(ustrSystemPath, getThreadTextEncoding()));
- HCDBG(std::cerr << "native_file_string is " << tmp.getStr() << std::endl);
- return std::string(tmp.getStr());
- }
-#ifdef WNT
- wchar_t const * native_file_string_w() const
- {
- ::rtl::OUString ustrSystemPath;
- osl::File::getSystemPathFromFileURL(data, ustrSystemPath);
- return (wchar_t const *) ustrSystemPath.getStr();
- }
-#endif
- std::string native_directory_string() const { return native_file_string(); }
- std::string toUTF8() const
- {
- rtl::OString tmp(rtl::OUStringToOString(data, RTL_TEXTENCODING_UTF8));
- return std::string(tmp.getStr());
- }
- bool empty() const { return data.isEmpty(); }
- path operator/(const std::string &in) const
- {
- path ret(*this);
- HCDBG(std::cerr << "orig was " <<
- rtl::OUStringToOString(ret.data, RTL_TEXTENCODING_UTF8).getStr() << std::endl);
- rtl::OString tmp(in.c_str());
- rtl::OUString ustrSystemPath(rtl::OStringToOUString(tmp, getThreadTextEncoding()));
- ret.data += rtl::OUString(sal_Unicode('/'));
- ret.data += ustrSystemPath;
- HCDBG(std::cerr << "final is " <<
- rtl::OUStringToOString(ret.data, RTL_TEXTENCODING_UTF8).getStr() << std::endl);
- return ret;
- }
- void append(const char *in)
- {
- rtl::OString tmp(in);
- rtl::OUString ustrSystemPath(rtl::OStringToOUString(tmp, getThreadTextEncoding()));
- data = data + ustrSystemPath;
- }
- void append(const std::string &in) { append(in.c_str()); }
- };
-
- void create_directory(const fs::path indexDirName);
- void copy(const fs::path &src, const fs::path &dest);
-}
-
-struct joaat_hash
-{
- size_t operator()(const std::string &str) const
- {
- size_t hash = 0;
- const char *key = str.data();
- for (size_t i = 0; i < str.size(); i++)
- {
- hash += key[i];
- hash += (hash << 10);
- hash ^= (hash >> 6);
- }
- hash += (hash << 3);
- hash ^= (hash >> 11);
- hash += (hash << 15);
- return hash;
- }
-};
-
-#define get16bits(d) ((((sal_uInt32)(((const sal_uInt8 *)(d))[1])) << 8)\
- +(sal_uInt32)(((const sal_uInt8 *)(d))[0]) )
-
-#define pref_hash joaat_hash
-
-typedef boost::unordered_map<std::string, std::string, pref_hash> Stringtable;
-typedef std::list<std::string> LinkedList;
-typedef std::vector<std::string> HashSet;
-
-typedef boost::unordered_map<std::string, LinkedList, pref_hash> Hashtable;
-
-class StreamTable
-{
-public:
- std::string document_id;
- std::string document_path;
- std::string document_module;
- std::string document_title;
-
- HashSet *appl_hidlist;
- Hashtable *appl_keywords;
- Stringtable *appl_helptexts;
- xmlDocPtr appl_doc;
-
- HashSet *default_hidlist;
- Hashtable *default_keywords;
- Stringtable *default_helptexts;
- xmlDocPtr default_doc;
-
- StreamTable() :
- appl_hidlist(NULL), appl_keywords(NULL), appl_helptexts(NULL), appl_doc(NULL),
- default_hidlist(NULL), default_keywords(NULL), default_helptexts(NULL), default_doc(NULL)
- {}
- void dropdefault()
- {
- delete default_hidlist;
- delete default_keywords;
- delete default_helptexts;
- if (default_doc) xmlFreeDoc(default_doc);
- }
- void dropappl()
- {
- delete appl_hidlist;
- delete appl_keywords;
- delete appl_helptexts;
- if (appl_doc) xmlFreeDoc(appl_doc);
- }
- ~StreamTable()
- {
- dropappl();
- dropdefault();
- }
-};
-
-struct HelpProcessingException
-{
- HelpProcessingErrorClass m_eErrorClass;
- std::string m_aErrorMsg;
- std::string m_aXMLParsingFile;
- int m_nXMLParsingLine;
-
- HelpProcessingException( HelpProcessingErrorClass eErrorClass, const std::string& aErrorMsg )
- : m_eErrorClass( eErrorClass )
- , m_aErrorMsg( aErrorMsg )
- , m_nXMLParsingLine( 0 )
- {}
- HelpProcessingException( const std::string& aErrorMsg, const std::string& aXMLParsingFile, int nXMLParsingLine )
- : m_eErrorClass( HELPPROCESSING_XMLPARSING_ERROR )
- , m_aErrorMsg( aErrorMsg )
- , m_aXMLParsingFile( aXMLParsingFile )
- , m_nXMLParsingLine( nXMLParsingLine )
- {}
-};
-
-class HelpCompiler
-{
-public:
- HelpCompiler(StreamTable &streamTable,
- const fs::path &in_inputFile,
- const fs::path &in_src,
- const fs::path &in_resEmbStylesheet,
- const std::string &in_module,
- const std::string &in_lang,
- bool in_bExtensionMode);
- bool compile( void ) throw (HelpProcessingException);
- void addEntryToJarFile(const std::string &prefix,
- const std::string &entryName, const std::string &bytesToAdd);
- void addEntryToJarFile(const std::string &prefix,
- const std::string &entryName, const HashSet &bytesToAdd);
- void addEntryToJarFile(const std::string &prefix,
- const std::string &entryName, const Stringtable &bytesToAdd);
- void addEntryToJarFile(const std::string &prefix,
- const std::string &entryName, const Hashtable &bytesToAdd);
-private:
- xmlDocPtr getSourceDocument(const fs::path &filePath);
- xmlNodePtr clone(xmlNodePtr node, const std::string& appl);
- StreamTable &streamTable;
- const fs::path inputFile, src;
- const std::string module, lang;
- const fs::path resEmbStylesheet;
- bool bExtensionMode;
- std::string gui;
-};
-
-inline char tocharlower(char c)
-{
- return static_cast<char>(tolower(c));
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/HelpIndexer.cxx b/l10ntools/source/help/HelpIndexer.cxx
deleted file mode 100644
index 72a0d045229e..000000000000
--- a/l10ntools/source/help/HelpIndexer.cxx
+++ /dev/null
@@ -1,172 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
- * (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <l10ntools/HelpIndexer.hxx>
-
-#include <rtl/string.hxx>
-#include <rtl/uri.hxx>
-#include <rtl/ustrbuf.hxx>
-#include <osl/file.hxx>
-#include <osl/thread.h>
-#include <boost/scoped_ptr.hpp>
-#include <algorithm>
-
-#include "LuceneHelper.hxx"
-
-using namespace lucene::document;
-
-HelpIndexer::HelpIndexer(rtl::OUString const &lang, rtl::OUString const &module,
- rtl::OUString const &srcDir, rtl::OUString const &outDir)
- : d_lang(lang), d_module(module)
-{
- d_indexDir = rtl::OUStringBuffer(outDir).append('/').
- append(module).appendAscii(RTL_CONSTASCII_STRINGPARAM(".idxl")).toString();
- d_captionDir = srcDir + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/caption"));
- d_contentDir = srcDir + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/content"));
-}
-
-bool HelpIndexer::indexDocuments()
-{
- if (!scanForFiles())
- return false;
-
- try
- {
- rtl::OUString sLang = d_lang.getToken(0, '-');
- bool bUseCJK = sLang == "ja" || sLang == "ko" || sLang == "zh";
-
- // Construct the analyzer appropriate for the given language
- boost::scoped_ptr<lucene::analysis::Analyzer> analyzer;
- if (bUseCJK)
- analyzer.reset(new lucene::analysis::LanguageBasedAnalyzer(L"cjk"));
- else
- analyzer.reset(new lucene::analysis::standard::StandardAnalyzer());
-
- rtl::OUString ustrSystemPath;
- osl::File::getSystemPathFromFileURL(d_indexDir, ustrSystemPath);
-
- rtl::OString indexDirStr = rtl::OUStringToOString(ustrSystemPath, osl_getThreadTextEncoding());
- lucene::index::IndexWriter writer(indexDirStr.getStr(), analyzer.get(), true);
- //Double limit of tokens allowed, otherwise we'll get a too-many-tokens
- //exception for ja help. Could alternative ignore the exception and get
- //truncated results as per java-Lucene apparently
- writer.setMaxFieldLength(lucene::index::IndexWriter::DEFAULT_MAX_FIELD_LENGTH*2);
-
- // Index the identified help files
- Document doc;
- for (std::set<rtl::OUString>::iterator i = d_files.begin(); i != d_files.end(); ++i) {
- helpDocument(*i, &doc);
- writer.addDocument(&doc);
- doc.clear();
- }
- writer.optimize();
-
- // Optimize the index
- writer.optimize();
- }
- catch (CLuceneError &e)
- {
- d_error = rtl::OUString::createFromAscii(e.what());
- return false;
- }
-
- return true;
-}
-
-rtl::OUString const & HelpIndexer::getErrorMessage() {
- return d_error;
-}
-
-bool HelpIndexer::scanForFiles() {
- if (!scanForFiles(d_contentDir)) {
- return false;
- }
- if (!scanForFiles(d_captionDir)) {
- return false;
- }
- return true;
-}
-
-bool HelpIndexer::scanForFiles(rtl::OUString const & path) {
-
- osl::Directory dir(path);
- if (osl::FileBase::E_None != dir.open()) {
- d_error = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Error reading directory ")) + path;
- return true;
- }
-
- osl::DirectoryItem item;
- osl::FileStatus fileStatus(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Type);
- while (dir.getNextItem(item) == osl::FileBase::E_None) {
- item.getFileStatus(fileStatus);
- if (fileStatus.getFileType() == osl::FileStatus::Regular) {
- d_files.insert(fileStatus.getFileName());
- }
- }
-
- return true;
-}
-
-bool HelpIndexer::helpDocument(rtl::OUString const & fileName, Document *doc) {
- // Add the help path as an indexed, untokenized field.
-
- rtl::OUString path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("#HLP#")) +
- d_module + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + fileName;
- std::vector<TCHAR> aPath(OUStringToTCHARVec(path));
- doc->add(*_CLNEW Field(_T("path"), &aPath[0], Field::STORE_YES | Field::INDEX_UNTOKENIZED));
-
- rtl::OUString sEscapedFileName =
- rtl::Uri::encode(fileName,
- rtl_UriCharClassUric, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8);
-
- // Add the caption as a field.
- rtl::OUString captionPath = d_captionDir + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sEscapedFileName;
- doc->add(*_CLNEW Field(_T("caption"), helpFileReader(captionPath), Field::STORE_NO | Field::INDEX_TOKENIZED));
-
- // Add the content as a field.
- rtl::OUString contentPath = d_contentDir + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sEscapedFileName;
- doc->add(*_CLNEW Field(_T("content"), helpFileReader(contentPath), Field::STORE_NO | Field::INDEX_TOKENIZED));
-
- return true;
-}
-
-lucene::util::Reader *HelpIndexer::helpFileReader(rtl::OUString const & path) {
- osl::File file(path);
- if (osl::FileBase::E_None == file.open(osl_File_OpenFlag_Read)) {
- file.close();
- rtl::OUString ustrSystemPath;
- osl::File::getSystemPathFromFileURL(path, ustrSystemPath);
- rtl::OString pathStr = rtl::OUStringToOString(ustrSystemPath, osl_getThreadTextEncoding());
- return _CLNEW lucene::util::FileReader(pathStr.getStr(), "UTF-8");
- } else {
- return _CLNEW lucene::util::StringReader(L"");
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/HelpIndexer_main.cxx b/l10ntools/source/help/HelpIndexer_main.cxx
deleted file mode 100644
index 48e0f3eecdda..000000000000
--- a/l10ntools/source/help/HelpIndexer_main.cxx
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
- * (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <l10ntools/HelpIndexer.hxx>
-#include <osl/file.hxx>
-#include <osl/process.h>
-#include <osl/thread.h>
-#include <string>
-#include <iostream>
-
-#include "LuceneHelper.hxx"
-
-int main(int argc, char **argv) {
- const std::string pLang("-lang");
- const std::string pModule("-mod");
- const std::string pDir("-dir");
-
- std::string lang;
- std::string module;
- std::string dir;
-
- bool error = false;
- for (int i = 1; i < argc; ++i) {
- if (pLang.compare(argv[i]) == 0) {
- if (i + 1 < argc) {
- lang = argv[++i];
- } else {
- error = true;
- }
- } else if (pModule.compare(argv[i]) == 0) {
- if (i + 1 < argc) {
- module = argv[++i];
- } else {
- error = true;
- }
- } else if (pDir.compare(argv[i]) == 0) {
- if (i + 1 < argc) {
- dir = argv[++i];
- } else {
- error = true;
- }
- } else {
- error = true;
- }
- }
-
- if (error) {
- std::cerr << "Error parsing command-line arguments" << std::endl;
- }
-
- if (error || lang.empty() || module.empty() || dir.empty()) {
- std::cerr << "Usage: HelpIndexer -lang ISOLangCode -mod HelpModule -dir Dir" << std::endl;
- return 1;
- }
-
- std::string captionDir(dir + SAL_PATHDELIMITER + "caption");
- std::string contentDir(dir + SAL_PATHDELIMITER + "content");
- std::string indexDir(dir + SAL_PATHDELIMITER + module + ".idxl");
-
- rtl::OUString sDir;
-
- osl::File::getFileURLFromSystemPath(
- rtl::OUString(dir.c_str(), dir.size(), osl_getThreadTextEncoding()),
- sDir);
-
- rtl::OUString cwd;
- osl_getProcessWorkingDir(&cwd.pData);
-
- osl::File::getAbsoluteFileURL(cwd, sDir, sDir);
-
- HelpIndexer indexer(
- rtl::OUString(lang.c_str(), lang.size(), osl_getThreadTextEncoding()),
- rtl::OUString(module.c_str(), module.size(), osl_getThreadTextEncoding()),
- sDir, sDir);
-
- if (!indexer.indexDocuments()) {
- std::cerr << rtl::OUStringToOString(indexer.getErrorMessage(), osl_getThreadTextEncoding()).getStr() << std::endl;
- return 2;
- }
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/HelpLinker.cxx b/l10ntools/source/help/HelpLinker.cxx
deleted file mode 100644
index dd1057a3d25b..000000000000
--- a/l10ntools/source/help/HelpLinker.cxx
+++ /dev/null
@@ -1,1087 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "HelpCompiler.hxx"
-#include "l10ntools/HelpLinker.hxx"
-
-#include <map>
-
-#include <string.h>
-#include <limits.h>
-
-#include <libxslt/xslt.h>
-#include <libxslt/xsltutils.h>
-#include <libxslt/functions.h>
-#include <libxslt/extensions.h>
-
-#include <sal/main.h>
-#include <sal/types.h>
-#include <osl/time.h>
-#include <rtl/bootstrap.hxx>
-
-#include <expat.h>
-
-IndexerPreProcessor::IndexerPreProcessor
- ( const std::string& aModuleName, const fs::path& fsIndexBaseDir,
- const fs::path& idxCaptionStylesheet, const fs::path& idxContentStylesheet )
- : m_aModuleName( aModuleName )
- , m_fsIndexBaseDir( fsIndexBaseDir )
-{
- m_fsCaptionFilesDirName = fsIndexBaseDir / "caption";
- fs::create_directory( m_fsCaptionFilesDirName );
-
- m_fsContentFilesDirName = fsIndexBaseDir / "content";
- fs::create_directory( m_fsContentFilesDirName );
-
- m_xsltStylesheetPtrCaption = xsltParseStylesheetFile
- ((const xmlChar *)idxCaptionStylesheet.native_file_string().c_str());
- m_xsltStylesheetPtrContent = xsltParseStylesheetFile
- ((const xmlChar *)idxContentStylesheet.native_file_string().c_str());
-}
-
-IndexerPreProcessor::~IndexerPreProcessor()
-{
- if( m_xsltStylesheetPtrCaption )
- xsltFreeStylesheet( m_xsltStylesheetPtrCaption );
- if( m_xsltStylesheetPtrContent )
- xsltFreeStylesheet( m_xsltStylesheetPtrContent );
-}
-
-std::string getEncodedPath( const std::string& Path )
-{
- rtl::OString aOStr_Path( Path.c_str() );
- rtl::OUString aOUStr_Path( rtl::OStringToOUString
- ( aOStr_Path, fs::getThreadTextEncoding() ) );
- rtl::OUString aPathURL;
- osl::File::getFileURLFromSystemPath( aOUStr_Path, aPathURL );
- rtl::OString aOStr_PathURL( rtl::OUStringToOString
- ( aPathURL, fs::getThreadTextEncoding() ) );
- std::string aStdStr_PathURL( aOStr_PathURL.getStr() );
- return aStdStr_PathURL;
-}
-
-void IndexerPreProcessor::processDocument
- ( xmlDocPtr doc, const std::string &EncodedDocPath )
-{
- std::string aStdStr_EncodedDocPathURL = getEncodedPath( EncodedDocPath );
-
- if( m_xsltStylesheetPtrCaption )
- {
- xmlDocPtr resCaption = xsltApplyStylesheet( m_xsltStylesheetPtrCaption, doc, NULL );
- xmlNodePtr pResNodeCaption = resCaption->xmlChildrenNode;
- if( pResNodeCaption )
- {
- fs::path fsCaptionPureTextFile_docURL = m_fsCaptionFilesDirName / aStdStr_EncodedDocPathURL;
-#ifdef WNT //We need _wfopen to support long file paths on Windows XP
- FILE* pFile_docURL = _wfopen(
- fsCaptionPureTextFile_docURL.native_file_string_w(), L"w" );
-#else
- FILE* pFile_docURL = fopen(
- fsCaptionPureTextFile_docURL.native_file_string().c_str(), "w" );
-#endif
- if( pFile_docURL )
- {
- fprintf( pFile_docURL, "%s\n", pResNodeCaption->content );
- fclose( pFile_docURL );
- }
- }
- xmlFreeDoc(resCaption);
- }
-
- if( m_xsltStylesheetPtrContent )
- {
- xmlDocPtr resContent = xsltApplyStylesheet( m_xsltStylesheetPtrContent, doc, NULL );
- xmlNodePtr pResNodeContent = resContent->xmlChildrenNode;
- if( pResNodeContent )
- {
- fs::path fsContentPureTextFile_docURL = m_fsContentFilesDirName / aStdStr_EncodedDocPathURL;
-#ifdef WNT //We need _wfopen to support long file paths on Windows XP
- FILE* pFile_docURL = _wfopen(
- fsContentPureTextFile_docURL.native_file_string_w(), L"w" );
-#else
- FILE* pFile_docURL = fopen(
- fsContentPureTextFile_docURL.native_file_string().c_str(), "w" );
-#endif
- if( pFile_docURL )
- {
- fprintf( pFile_docURL, "%s\n", pResNodeContent->content );
- fclose( pFile_docURL );
- }
- }
- xmlFreeDoc(resContent);
- }
-}
-
-struct Data
-{
- std::vector<std::string> _idList;
- typedef std::vector<std::string>::const_iterator cIter;
-
- void append(const std::string &id)
- {
- _idList.push_back(id);
- }
-
- std::string getString() const
- {
- std::string ret;
- cIter aEnd = _idList.end();
- for (cIter aIter = _idList.begin(); aIter != aEnd; ++aIter)
- ret += *aIter + ";";
- return ret;
- }
-};
-
-void writeKeyValue_DBHelp( FILE* pFile, const std::string& aKeyStr, const std::string& aValueStr )
-{
- if( pFile == NULL )
- return;
- char cLF = 10;
- unsigned int nKeyLen = aKeyStr.length();
- unsigned int nValueLen = aValueStr.length();
- fprintf( pFile, "%x ", nKeyLen );
- if( nKeyLen > 0 )
- {
- if (fwrite( aKeyStr.c_str(), 1, nKeyLen, pFile ) != nKeyLen)
- fprintf(stderr, "fwrite to db failed\n");
- }
- if (fprintf( pFile, " %x ", nValueLen ) < 0)
- fprintf(stderr, "fwrite to db failed\n");
- if( nValueLen > 0 )
- {
- if (fwrite( aValueStr.c_str(), 1, nValueLen, pFile ) != nValueLen)
- fprintf(stderr, "fwrite to db failed\n");
- }
- if (fprintf( pFile, "%c", cLF ) < 0)
- fprintf(stderr, "fwrite to db failed\n");
-}
-
-class HelpKeyword
-{
-private:
- typedef boost::unordered_map<std::string, Data, pref_hash> DataHashtable;
- DataHashtable _hash;
-
-public:
- void insert(const std::string &key, const std::string &id)
- {
- Data &data = _hash[key];
- data.append(id);
- }
-
- void dump(DB* table)
- {
- DataHashtable::const_iterator aEnd = _hash.end();
- for (DataHashtable::const_iterator aIter = _hash.begin(); aIter != aEnd; ++aIter)
- {
- const std::string &keystr = aIter->first;
- DBT key;
- memset(&key, 0, sizeof(key));
- key.data = const_cast<char*>(keystr.c_str());
- key.size = keystr.length();
-
- const Data &data = aIter->second;
- std::string str = data.getString();
- DBT value;
- memset(&value, 0, sizeof(value));
- value.data = const_cast<char*>(str.c_str());
- value.size = str.length();
-
- table->put(table, NULL, &key, &value, 0);
- }
- }
-
- void dump_DBHelp( const fs::path& rFileName )
- {
-#ifdef WNT //We need _wfopen to support long file paths on Windows XP
- FILE* pFile = _wfopen( rFileName.native_file_string_w(), L"wb" );
-#else
- FILE* pFile = fopen( rFileName.native_file_string().c_str(), "wb" );
-#endif
- if( pFile == NULL )
- return;
-
- DataHashtable::const_iterator aEnd = _hash.end();
- for (DataHashtable::const_iterator aIter = _hash.begin(); aIter != aEnd; ++aIter)
- writeKeyValue_DBHelp( pFile, aIter->first, aIter->second.getString() );
-
- fclose( pFile );
- }
-};
-
-namespace URLEncoder
-{
- static std::string encode(const std::string &rIn)
- {
- const char *good = "!$&'()*+,-.=@_";
- static const char hex[17] = "0123456789ABCDEF";
-
- std::string result;
- for (size_t i=0; i < rIn.length(); ++i)
- {
- unsigned char c = rIn[i];
- if (isalnum (c) || strchr (good, c))
- result += c;
- else {
- result += '%';
- result += hex[c >> 4];
- result += hex[c & 0xf];
- }
- }
- return result;
- }
-}
-
-void HelpLinker::addBookmark( DB* dbBase, FILE* pFile_DBHelp, std::string thishid,
- const std::string& fileB, const std::string& anchorB,
- const std::string& jarfileB, const std::string& titleB)
-{
- HCDBG(std::cerr << "HelpLinker::addBookmark " << thishid << " " <<
- fileB << " " << anchorB << " " << jarfileB << " " << titleB << std::endl);
-
- thishid = URLEncoder::encode(thishid);
-
- DBT key;
- memset(&key, 0, sizeof(key));
- key.data = const_cast<char*>(thishid.c_str());
- key.size = thishid.length();
-
- int fileLen = fileB.length();
- if (!anchorB.empty())
- fileLen += (1 + anchorB.length());
- int dataLen = 1 + fileLen + 1 + jarfileB.length() + 1 + titleB.length();
-
- std::vector<unsigned char> dataB(dataLen);
- size_t i = 0;
- dataB[i++] = static_cast<unsigned char>(fileLen);
- for (size_t j = 0; j < fileB.length(); ++j)
- dataB[i++] = static_cast<unsigned char>(fileB[j]);
- if (!anchorB.empty())
- {
- dataB[i++] = '#';
- for (size_t j = 0; j < anchorB.length(); ++j)
- dataB[i++] = anchorB[j];
- }
- dataB[i++] = static_cast<unsigned char>(jarfileB.length());
- for (size_t j = 0; j < jarfileB.length(); ++j)
- dataB[i++] = jarfileB[j];
-
- dataB[i++] = static_cast<unsigned char>(titleB.length());
- for (size_t j = 0; j < titleB.length(); ++j)
- dataB[i++] = titleB[j];
-
- DBT data;
- memset(&data, 0, sizeof(data));
- data.data = &dataB[0];
- data.size = dataB.size();
-
- if( dbBase != NULL )
- dbBase->put(dbBase, NULL, &key, &data, 0);
-
- if( pFile_DBHelp != NULL )
- {
- std::string aValueStr( dataB.begin(), dataB.end() );
- writeKeyValue_DBHelp( pFile_DBHelp, thishid, aValueStr );
- }
-}
-
-void HelpLinker::initIndexerPreProcessor()
-{
- if( m_pIndexerPreProcessor )
- delete m_pIndexerPreProcessor;
- std::string mod = module;
- std::transform (mod.begin(), mod.end(), mod.begin(), tocharlower);
- m_pIndexerPreProcessor = new IndexerPreProcessor( mod, indexDirParentName,
- idxCaptionStylesheet, idxContentStylesheet );
-}
-
-/**
-*
-*/
-void HelpLinker::link() throw( HelpProcessingException )
-{
- bool bIndexForExtension = true;
-
- if( bExtensionMode )
- {
- indexDirParentName = extensionDestination;
- }
- else
- {
- indexDirParentName = zipdir;
- fs::create_directory(indexDirParentName);
- }
-
-#ifdef CMC_DEBUG
- std::cerr << "will not delete tmpdir of " << indexDirParentName.native_file_string().c_str() << std::endl;
-#endif
-
- std::string mod = module;
- std::transform (mod.begin(), mod.end(), mod.begin(), tocharlower);
-
- // do the work here
- // continue with introduction of the overall process thing into the
- // here all hzip files will be worked on
- std::string appl = mod;
- if (appl[0] == 's')
- appl = appl.substr(1);
-
- bool bUse_ = true;
-#ifdef DBHELP_ONLY
- if( !bExtensionMode )
- bUse_ = false;
-#endif
-
- DB* helpText(0);
-#ifndef DBHELP_ONLY
- fs::path helpTextFileName(indexDirParentName / (mod + ".ht"));
- db_create(&helpText,0,0);
- helpText->open(helpText, NULL, helpTextFileName.native_file_string().c_str(), NULL, DB_BTREE,
- DB_CREATE | DB_TRUNCATE, 0644);
-#endif
-
- fs::path helpTextFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".ht_" : ".ht")));
-#ifdef WNT
- //We need _wfopen to support long file paths on Windows XP
- FILE* pFileHelpText_DBHelp = _wfopen
- ( helpTextFileName_DBHelp.native_file_string_w(), L"wb" );
-#else
-
- FILE* pFileHelpText_DBHelp = fopen
- ( helpTextFileName_DBHelp.native_file_string().c_str(), "wb" );
-#endif
- DB* dbBase(0);
-#ifndef DBHELP_ONLY
- fs::path dbBaseFileName(indexDirParentName / (mod + ".db"));
- db_create(&dbBase,0,0);
- dbBase->open(dbBase, NULL, dbBaseFileName.native_file_string().c_str(), NULL, DB_BTREE,
- DB_CREATE | DB_TRUNCATE, 0644);
-#endif
-
- fs::path dbBaseFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".db_" : ".db")));
-#ifdef WNT
- //We need _wfopen to support long file paths on Windows XP
- FILE* pFileDbBase_DBHelp = _wfopen
- ( dbBaseFileName_DBHelp.native_file_string_w(), L"wb" );
-#else
- FILE* pFileDbBase_DBHelp = fopen
- ( dbBaseFileName_DBHelp.native_file_string().c_str(), "wb" );
-#endif
-
-#ifndef DBHELP_ONLY
- DB* keyWord(0);
- fs::path keyWordFileName(indexDirParentName / (mod + ".key"));
- db_create(&keyWord,0,0);
- keyWord->open(keyWord, NULL, keyWordFileName.native_file_string().c_str(), NULL, DB_BTREE,
- DB_CREATE | DB_TRUNCATE, 0644);
-#endif
-
- fs::path keyWordFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".key_" : ".key")));
-
- HelpKeyword helpKeyword;
-
- // catch HelpProcessingException to avoid locking data bases
- try
- {
-
- // lastly, initialize the indexBuilder
- if ( (!bExtensionMode || bIndexForExtension) && !helpFiles.empty())
- initIndexerPreProcessor();
-
- // here we start our loop over the hzip files.
- HashSet::iterator end = helpFiles.end();
- for (HashSet::iterator iter = helpFiles.begin(); iter != end; ++iter)
- {
- // process one file
- // streamTable contains the streams in the hzip file
- StreamTable streamTable;
- const std::string &xhpFileName = *iter;
-
- if (!bExtensionMode && xhpFileName.rfind(".xhp") != xhpFileName.length()-4)
- {
- // only work on .xhp - files
- SAL_WARN("l10ntools",
- "ERROR: input list entry '"
- << xhpFileName
- << "' has the wrong extension (only files with extension .xhp "
- << "are accepted)");
-
- continue;
- }
-
- fs::path langsourceRoot(sourceRoot);
- fs::path xhpFile;
-
- if( bExtensionMode )
- {
- // langsourceRoot == sourceRoot for extensions
- std::string xhpFileNameComplete( extensionPath );
- xhpFileNameComplete.append( '/' + xhpFileName );
- xhpFile = fs::path( xhpFileNameComplete );
- }
- else
- {
- langsourceRoot.append('/' + lang + '/');
- xhpFile = fs::path(xhpFileName, fs::native);
- }
-
- HelpCompiler hc( streamTable, xhpFile, langsourceRoot,
- embeddStylesheet, module, lang, bExtensionMode );
-
- HCDBG(std::cerr << "before compile of " << xhpFileName << std::endl);
- bool success = hc.compile();
- HCDBG(std::cerr << "after compile of " << xhpFileName << std::endl);
-
- if (!success && !bExtensionMode)
- {
- std::stringstream aStrStream;
- aStrStream <<
- "\nERROR: compiling help particle '"
- << xhpFileName
- << "' for language '"
- << lang
- << "' failed!";
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- std::string documentPath = streamTable.document_path;
- if (documentPath.find("/") == 0)
- documentPath = documentPath.substr(1);
-
- std::string documentJarfile = streamTable.document_module + ".jar";
-
- std::string documentTitle = streamTable.document_title;
- if (documentTitle.empty())
- documentTitle = "<notitle>";
-
- const std::string& fileB = documentPath;
- const std::string& jarfileB = documentJarfile;
- std::string& titleB = documentTitle;
-
- // add once this as its own id.
- addBookmark(dbBase, pFileDbBase_DBHelp, documentPath, fileB, std::string(), jarfileB, titleB);
-
- // first the database *.db
- // ByteArrayInputStream bais = null;
- // ObjectInputStream ois = null;
-
- const HashSet *hidlist = streamTable.appl_hidlist;
- if (!hidlist)
- hidlist = streamTable.default_hidlist;
- if (hidlist && !hidlist->empty())
- {
- // now iterate over all elements of the hidlist
- HashSet::const_iterator aEnd = hidlist->end();
- for (HashSet::const_iterator hidListIter = hidlist->begin();
- hidListIter != aEnd; ++hidListIter)
- {
- std::string thishid = *hidListIter;
-
- std::string anchorB;
- size_t index = thishid.rfind('#');
- if (index != std::string::npos)
- {
- anchorB = thishid.substr(1 + index);
- thishid = thishid.substr(0, index);
- }
- addBookmark(dbBase, pFileDbBase_DBHelp, thishid, fileB, anchorB, jarfileB, titleB);
- }
- }
-
- // now the keywords
- const Hashtable *anchorToLL = streamTable.appl_keywords;
- if (!anchorToLL)
- anchorToLL = streamTable.default_keywords;
- if (anchorToLL && !anchorToLL->empty())
- {
- std::string fakedHid = URLEncoder::encode(documentPath);
- Hashtable::const_iterator aEnd = anchorToLL->end();
- for (Hashtable::const_iterator enumer = anchorToLL->begin();
- enumer != aEnd; ++enumer)
- {
- const std::string &anchor = enumer->first;
- addBookmark(dbBase, pFileDbBase_DBHelp, documentPath, fileB,
- anchor, jarfileB, titleB);
- std::string totalId = fakedHid + "#" + anchor;
- // std::cerr << hzipFileName << std::endl;
- const LinkedList& ll = enumer->second;
- LinkedList::const_iterator aOtherEnd = ll.end();
- for (LinkedList::const_iterator llIter = ll.begin();
- llIter != aOtherEnd; ++llIter)
- {
- helpKeyword.insert(*llIter, totalId);
- }
- }
-
- }
-
- // and last the helptexts
- const Stringtable *helpTextHash = streamTable.appl_helptexts;
- if (!helpTextHash)
- helpTextHash = streamTable.default_helptexts;
- if (helpTextHash && !helpTextHash->empty())
- {
- Stringtable::const_iterator aEnd = helpTextHash->end();
- for (Stringtable::const_iterator helpTextIter = helpTextHash->begin();
- helpTextIter != aEnd; ++helpTextIter)
- {
- std::string helpTextId = helpTextIter->first;
- const std::string& helpTextText = helpTextIter->second;
-
- helpTextId = URLEncoder::encode(helpTextId);
-
- DBT keyDbt;
- memset(&keyDbt, 0, sizeof(keyDbt));
- keyDbt.data = const_cast<char*>(helpTextId.c_str());
- keyDbt.size = helpTextId.length();
-
- DBT textDbt;
- memset(&textDbt, 0, sizeof(textDbt));
- textDbt.data = const_cast<char*>(helpTextText.c_str());
- textDbt.size = helpTextText.length();
-
- if( helpText != NULL )
- helpText->put(helpText, NULL, &keyDbt, &textDbt, 0);
-
- if( pFileHelpText_DBHelp != NULL )
- writeKeyValue_DBHelp( pFileHelpText_DBHelp, helpTextId, helpTextText );
- }
- }
-
- //IndexerPreProcessor
- if( !bExtensionMode || bIndexForExtension )
- {
- // now the indexing
- xmlDocPtr document = streamTable.appl_doc;
- if (!document)
- document = streamTable.default_doc;
- if (document)
- {
- std::string temp = module;
- std::transform (temp.begin(), temp.end(), temp.begin(), tocharlower);
- m_pIndexerPreProcessor->processDocument(document, URLEncoder::encode(documentPath) );
- }
- }
-
- } // while loop over hzip files ending
-
- } // try
- catch( const HelpProcessingException& )
- {
- // catch HelpProcessingException to avoid locking data bases
-#ifndef DBHELP_ONLY
- helpText->close(helpText, 0);
- dbBase->close(dbBase, 0);
- keyWord->close(keyWord, 0);
-#endif
- if( pFileHelpText_DBHelp != NULL )
- fclose( pFileHelpText_DBHelp );
- if( pFileDbBase_DBHelp != NULL )
- fclose( pFileDbBase_DBHelp );
- throw;
- }
-
-#ifndef DBHELP_ONLY
- helpText->close(helpText, 0);
- dbBase->close(dbBase, 0);
- helpKeyword.dump(keyWord);
- keyWord->close(keyWord, 0);
-#endif
- if( pFileHelpText_DBHelp != NULL )
- fclose( pFileHelpText_DBHelp );
- if( pFileDbBase_DBHelp != NULL )
- fclose( pFileDbBase_DBHelp );
-
- helpKeyword.dump_DBHelp( keyWordFileName_DBHelp);
-
- if( !bExtensionMode )
- {
- // New index
- Stringtable::iterator aEnd = additionalFiles.end();
- for (Stringtable::iterator enumer = additionalFiles.begin(); enumer != aEnd;
- ++enumer)
- {
- const std::string &additionalFileName = enumer->second;
- const std::string &additionalFileKey = enumer->first;
-
- fs::path fsAdditionalFileName( additionalFileName, fs::native );
- HCDBG({
- std::string aNativeStr = fsAdditionalFileName.native_file_string();
- const char* pStr = aNativeStr.c_str();
- std::cerr << pStr << std::endl;
- });
-
- fs::path fsTargetName( indexDirParentName / additionalFileKey );
-
- fs::copy( fsAdditionalFileName, fsTargetName );
- }
- }
-}
-
-
-void HelpLinker::main( std::vector<std::string> &args,
- std::string* pExtensionPath, std::string* pDestination,
- const rtl::OUString* pOfficeHelpPath )
- throw( HelpProcessingException )
-{
- bExtensionMode = false;
- helpFiles.clear();
-
- if ((!args.empty()) && args[0][0] == '@')
- {
- std::vector<std::string> stringList;
- std::ifstream fileReader(args[0].substr(1).c_str());
-
- while (fileReader)
- {
- std::string token;
- fileReader >> token;
- if (!token.empty())
- stringList.push_back(token);
- }
- fileReader.close();
-
- args = stringList;
- }
-
- size_t i = 0;
- bool bSrcOption = false;
- while (i < args.size())
- {
- if (args[i].compare("-extlangsrc") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "extension source missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- extsource = args[i];
- }
- else if (args[i].compare("-extlangdest") == 0)
- {
- //If this argument is not provided then the location provided in -extsource will
- //also be the destination
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "extension destination missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- extdestination = args[i];
- }
- else if (args[i].compare("-src") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "sourceroot missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- bSrcOption = true;
- sourceRoot = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-sty") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "embeddingStylesheet missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- embeddStylesheet = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-zipdir") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "idxtemp missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- zipdir = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-idxcaption") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "idxcaption stylesheet missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- idxCaptionStylesheet = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-idxcontent") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "idxcontent stylesheet missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- idxContentStylesheet = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-o") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "outputfilename missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- outputFile = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-mod") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "module name missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- module = args[i];
- }
- else if (args[i].compare("-lang") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "language name missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- lang = args[i];
- }
- else if (args[i].compare("-hid") == 0)
- {
- ++i;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, "obsolete -hid argument used" );
- }
- else if (args[i].compare("-add") == 0)
- {
- std::string addFile, addFileUnderPath;
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "pathname missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- addFileUnderPath = args[i];
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "pathname missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- addFile = args[i];
- if (!addFileUnderPath.empty() && !addFile.empty())
- additionalFiles[addFileUnderPath] = addFile;
- }
- else
- helpFiles.push_back(args[i]);
- ++i;
- }
-
- //We can be called from the helplinker executable or the extension manager
- //In the latter case extsource is not used.
- if( (pExtensionPath && pExtensionPath->length() > 0 && pOfficeHelpPath)
- || !extsource.empty())
- {
- bExtensionMode = true;
- if (!extsource.empty())
- {
- //called from helplinker.exe, pExtensionPath and pOfficeHelpPath
- //should be NULL
- sourceRoot = fs::path(extsource, fs::native);
- extensionPath = sourceRoot.toUTF8();
-
- if (extdestination.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "-extlangdest is missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- else
- {
- //Convert from system path to file URL!!!
- fs::path p(extdestination, fs::native);
- extensionDestination = p.toUTF8();
- }
- }
- else
- { //called from extension manager
- extensionPath = *pExtensionPath;
- sourceRoot = fs::path(extensionPath);
- extensionDestination = *pDestination;
- }
- //check if -src option was used. This option must not be used
- //when extension help is compiled.
- if (bSrcOption)
- {
- std::stringstream aStrStream;
- aStrStream << "-src must not be used together with -extsource missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- }
-
- if (!bExtensionMode && zipdir.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "no index dir given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- if ( (!bExtensionMode && idxCaptionStylesheet.empty())
- || (!extsource.empty() && idxCaptionStylesheet.empty()) )
- {
- //No extension mode and extension mode using commandline
- //!extsource.empty indicates extension mode using commandline
- // -idxcaption paramter is required
- std::stringstream aStrStream;
- aStrStream << "no index caption stylesheet given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- else if ( bExtensionMode && extsource.empty())
- {
- //This part is used when compileExtensionHelp is called from the extensions manager.
- //If extension help is compiled using helplinker in the build process
- rtl::OUString aIdxCaptionPathFileURL( *pOfficeHelpPath );
- aIdxCaptionPathFileURL += rtl::OUString("/idxcaption.xsl");
-
- rtl::OString aOStr_IdxCaptionPathFileURL( rtl::OUStringToOString
- ( aIdxCaptionPathFileURL, fs::getThreadTextEncoding() ) );
- std::string aStdStr_IdxCaptionPathFileURL( aOStr_IdxCaptionPathFileURL.getStr() );
-
- idxCaptionStylesheet = fs::path( aStdStr_IdxCaptionPathFileURL );
- }
-
- if ( (!bExtensionMode && idxContentStylesheet.empty())
- || (!extsource.empty() && idxContentStylesheet.empty()) )
- {
- //No extension mode and extension mode using commandline
- //!extsource.empty indicates extension mode using commandline
- // -idxcontent paramter is required
- std::stringstream aStrStream;
- aStrStream << "no index content stylesheet given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- else if ( bExtensionMode && extsource.empty())
- {
- //If extension help is compiled using helplinker in the build process
- //then -idxcontent must be supplied
- //This part is used when compileExtensionHelp is called from the extensions manager.
- rtl::OUString aIdxContentPathFileURL( *pOfficeHelpPath );
- aIdxContentPathFileURL += rtl::OUString("/idxcontent.xsl");
-
- rtl::OString aOStr_IdxContentPathFileURL( rtl::OUStringToOString
- ( aIdxContentPathFileURL, fs::getThreadTextEncoding() ) );
- std::string aStdStr_IdxContentPathFileURL( aOStr_IdxContentPathFileURL.getStr() );
-
- idxContentStylesheet = fs::path( aStdStr_IdxContentPathFileURL );
- }
- if (!bExtensionMode && embeddStylesheet.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "no embedding resolving file given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- if (sourceRoot.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "no sourceroot given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- if (!bExtensionMode && outputFile.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "no output file given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- if (module.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "module missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- if (!bExtensionMode && lang.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "language missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- link();
-}
-
-// Variable to set an exception in "C" StructuredXMLErrorFunction
-static const HelpProcessingException* GpXMLParsingException = NULL;
-
-extern "C" void StructuredXMLErrorFunction(void *userData, xmlErrorPtr error)
-{
- (void)userData;
- (void)error;
-
- std::string aErrorMsg = error->message;
- std::string aXMLParsingFile;
- if( error->file != NULL )
- aXMLParsingFile = error->file;
- int nXMLParsingLine = error->line;
- HelpProcessingException* pException = new HelpProcessingException( aErrorMsg, aXMLParsingFile, nXMLParsingLine );
- GpXMLParsingException = pException;
-
- // Reset error handler
- xmlSetStructuredErrorFunc( NULL, NULL );
-}
-
-HelpProcessingErrorInfo& HelpProcessingErrorInfo::operator=( const struct HelpProcessingException& e )
-{
- m_eErrorClass = e.m_eErrorClass;
- rtl::OString tmpErrorMsg( e.m_aErrorMsg.c_str() );
- m_aErrorMsg = rtl::OStringToOUString( tmpErrorMsg, fs::getThreadTextEncoding() );
- rtl::OString tmpXMLParsingFile( e.m_aXMLParsingFile.c_str() );
- m_aXMLParsingFile = rtl::OStringToOUString( tmpXMLParsingFile, fs::getThreadTextEncoding() );
- m_nXMLParsingLine = e.m_nXMLParsingLine;
- return *this;
-}
-
-
-// Returns true in case of success, false in case of error
-HELPLINKER_DLLPUBLIC bool compileExtensionHelp
-(
- const rtl::OUString& aOfficeHelpPath,
- const rtl::OUString& aExtensionName,
- const rtl::OUString& aExtensionLanguageRoot,
- sal_Int32 nXhpFileCount, const rtl::OUString* pXhpFiles,
- const rtl::OUString& aDestination,
- HelpProcessingErrorInfo& o_rHelpProcessingErrorInfo
-)
-{
- bool bSuccess = true;
-
- std::vector<std::string> args;
- args.reserve(nXhpFileCount + 2);
- args.push_back(std::string("-mod"));
- rtl::OString aOExtensionName = rtl::OUStringToOString( aExtensionName, fs::getThreadTextEncoding() );
- args.push_back(std::string(aOExtensionName.getStr()));
-
- for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp )
- {
- rtl::OUString aXhpFile = pXhpFiles[iXhp];
-
- rtl::OString aOXhpFile = rtl::OUStringToOString( aXhpFile, fs::getThreadTextEncoding() );
- args.push_back(std::string(aOXhpFile.getStr()));
- }
-
- rtl::OString aOExtensionLanguageRoot = rtl::OUStringToOString( aExtensionLanguageRoot, fs::getThreadTextEncoding() );
- const char* pExtensionPath = aOExtensionLanguageRoot.getStr();
- std::string aStdStrExtensionPath = pExtensionPath;
- rtl::OString aODestination = rtl::OUStringToOString(aDestination, fs::getThreadTextEncoding());
- const char* pDestination = aODestination.getStr();
- std::string aStdStrDestination = pDestination;
-
- // Set error handler
- xmlSetStructuredErrorFunc( NULL, (xmlStructuredErrorFunc)StructuredXMLErrorFunction );
- try
- {
- HelpLinker* pHelpLinker = new HelpLinker();
- pHelpLinker->main( args, &aStdStrExtensionPath, &aStdStrDestination, &aOfficeHelpPath );
- delete pHelpLinker;
- }
- catch( const HelpProcessingException& e )
- {
- if( GpXMLParsingException != NULL )
- {
- o_rHelpProcessingErrorInfo = *GpXMLParsingException;
- delete GpXMLParsingException;
- GpXMLParsingException = NULL;
- }
- else
- {
- o_rHelpProcessingErrorInfo = e;
- }
- bSuccess = false;
- }
- // Reset error handler
- xmlSetStructuredErrorFunc( NULL, NULL );
-
- // i83624: Tree files
- ::rtl::OUString aTreeFileURL = aExtensionLanguageRoot;
- aTreeFileURL += rtl::OUString("/help.tree");
- osl::DirectoryItem aTreeFileItem;
- osl::FileBase::RC rcGet = osl::DirectoryItem::get( aTreeFileURL, aTreeFileItem );
- osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileSize );
- if( rcGet == osl::FileBase::E_None &&
- aTreeFileItem.getFileStatus( aFileStatus ) == osl::FileBase::E_None &&
- aFileStatus.isValid( osl_FileStatus_Mask_FileSize ) )
- {
- sal_uInt64 ret, len = aFileStatus.getFileSize();
- char* s = new char[ int(len) ]; // the buffer to hold the installed files
- osl::File aFile( aTreeFileURL );
- aFile.open( osl_File_OpenFlag_Read );
- aFile.read( s, len, ret );
- aFile.close();
-
- XML_Parser parser = XML_ParserCreate( 0 );
- XML_Status parsed = XML_Parse( parser, s, int( len ), true );
-
- if (XML_STATUS_ERROR == parsed)
- {
- XML_Error nError = XML_GetErrorCode( parser );
- o_rHelpProcessingErrorInfo.m_eErrorClass = HELPPROCESSING_XMLPARSING_ERROR;
- o_rHelpProcessingErrorInfo.m_aErrorMsg = rtl::OUString::createFromAscii( XML_ErrorString( nError ) );;
- o_rHelpProcessingErrorInfo.m_aXMLParsingFile = aTreeFileURL;
- // CRAHSES!!! o_rHelpProcessingErrorInfo.m_nXMLParsingLine = XML_GetCurrentLineNumber( parser );
- bSuccess = false;
- }
-
- XML_ParserFree( parser );
- delete[] s;
- }
-
- return bSuccess;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/HelpLinker_main.cxx b/l10ntools/source/help/HelpLinker_main.cxx
deleted file mode 100644
index 54ce8916d1b9..000000000000
--- a/l10ntools/source/help/HelpLinker_main.cxx
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "HelpCompiler.hxx"
-#include "l10ntools/HelpLinker.hxx"
-#include <iostream>
-#include <sal/main.h>
-
-SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
- std::vector<std::string> args;
- for (int i = 1; i < argc; ++i)
- args.push_back(std::string(argv[i]));
- try
- {
- HelpLinker* pHelpLinker = new HelpLinker();
- pHelpLinker->main( args );
- delete pHelpLinker;
- }
- catch( const HelpProcessingException& e )
- {
- std::cerr << e.m_aErrorMsg;
- exit(1);
- }
- return 0;
-}
-
diff --git a/l10ntools/source/help/HelpSearch.cxx b/l10ntools/source/help/HelpSearch.cxx
deleted file mode 100644
index 64c0ed16aca7..000000000000
--- a/l10ntools/source/help/HelpSearch.cxx
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
- * (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <l10ntools/HelpSearch.hxx>
-#include <osl/file.hxx>
-#include <osl/thread.hxx>
-
-#include "LuceneHelper.hxx"
-
-HelpSearch::HelpSearch(rtl::OUString const &lang, rtl::OUString const &indexDir)
- : d_lang(lang)
-{
- rtl::OUString ustrSystemPath;
- osl::File::getSystemPathFromFileURL(indexDir, ustrSystemPath);
- d_indexDir = rtl::OUStringToOString(ustrSystemPath, osl_getThreadTextEncoding());
-}
-
-bool HelpSearch::query(rtl::OUString const &queryStr, bool captionOnly,
- std::vector<rtl::OUString> &rDocuments, std::vector<float> &rScores) {
-
- lucene::index::IndexReader *reader = lucene::index::IndexReader::open(d_indexDir.getStr());
- lucene::search::IndexSearcher searcher(reader);
-
- TCHAR captionField[] = L"caption";
- TCHAR contentField[] = L"content";
- TCHAR *field = captionOnly ? captionField : contentField;
-
- bool isWildcard = queryStr[queryStr.getLength() - 1] == L'*';
- std::vector<TCHAR> aQueryStr(OUStringToTCHARVec(queryStr));
- lucene::search::Query *pQuery;
- if (isWildcard)
- pQuery = _CLNEW lucene::search::WildcardQuery(_CLNEW lucene::index::Term(field, &aQueryStr[0]));
- else
- pQuery = _CLNEW lucene::search::TermQuery(_CLNEW lucene::index::Term(field, &aQueryStr[0]));
-
- lucene::search::Hits *hits = searcher.search(pQuery);
- for (unsigned i = 0; i < hits->length(); ++i) {
- lucene::document::Document &doc = hits->doc(i); // Document* belongs to Hits.
- wchar_t const *path = doc.get(L"path");
- rDocuments.push_back(TCHARArrayToOUString(path != 0 ? path : L""));
- rScores.push_back(hits->score(i));
- }
-
- _CLDELETE(hits);
- _CLDELETE(pQuery);
-
- reader->close();
- _CLDELETE(reader);
-
- return true;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/LuceneHelper.cxx b/l10ntools/source/help/LuceneHelper.cxx
deleted file mode 100644
index bee9090cc2b7..000000000000
--- a/l10ntools/source/help/LuceneHelper.cxx
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
- * (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include "LuceneHelper.hxx"
-
-std::vector<TCHAR> OUStringToTCHARVec(rtl::OUString const &rStr)
-{
- //UTF-16
- if (sizeof(TCHAR) == sizeof(sal_Unicode))
- return std::vector<TCHAR>(rStr.getStr(), rStr.getStr() + rStr.getLength() + 1);
-
- //UTF-32
- std::vector<TCHAR> aRet;
- for (sal_Int32 nStrIndex = 0; nStrIndex < rStr.getLength(); )
- {
- const sal_uInt32 nCode = rStr.iterateCodePoints(&nStrIndex);
- aRet.push_back(nCode);
- }
- aRet.push_back(0);
- return aRet;
-}
-
-rtl::OUString TCHARArrayToOUString(TCHAR const *str)
-{
- // UTF-16
- if (sizeof(TCHAR) == sizeof(sal_Unicode))
- return rtl::OUString((const sal_Unicode*)(str));
-
- // UTF-32
- return rtl::OUString((const sal_uInt32*)str, wcslen(str));
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/LuceneHelper.hxx b/l10ntools/source/help/LuceneHelper.hxx
deleted file mode 100644
index a0248f836a1f..000000000000
--- a/l10ntools/source/help/LuceneHelper.hxx
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
- * (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#ifndef LUCENEHELPER_HXX
-#define LUCENEHELPER_HXX
-
-#if defined _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4068 4263 4264 4266)
-#endif
-
-#if defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE)
-# pragma GCC visibility push (default)
-#endif
-
-#include <CLucene.h>
-#include <CLucene/analysis/LanguageBasedAnalyzer.h>
-
-#if defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE)
-# pragma GCC visibility pop
-#endif
-
-#if defined _MSC_VER
-#pragma warning(pop)
-#endif
-
-#include <rtl/ustring.hxx>
-#include <vector>
-
-std::vector<TCHAR> OUStringToTCHARVec(rtl::OUString const &rStr);
-rtl::OUString TCHARArrayToOUString(TCHAR const *str);
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/help/compilehelp.hxx b/l10ntools/source/help/compilehelp.hxx
deleted file mode 100644
index cbac6e6c87b9..000000000000
--- a/l10ntools/source/help/compilehelp.hxx
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef COMPILE_HXX
-#define COMPILE_HXX
-
-#include "sal/types.h"
-
-#if defined(HELPLINKER_DLLIMPLEMENTATION)
-#define HELPLINKER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
-#else
-#define HELPLINKER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
-#endif
-#define HELPLINKER_DLLPRIVATE SAL_DLLPRIVATE
-
-#include <rtl/ustring.hxx>
-
-enum HelpProcessingErrorClass
-{
- HELPPROCESSING_NO_ERROR,
- HELPPROCESSING_GENERAL_ERROR, // Missing files, options etc.
- HELPPROCESSING_INTERNAL_ERROR, // Unexpected problems
- HELPPROCESSING_XMLPARSING_ERROR // Errors thrown by libxml
-};
-
-struct HelpProcessingErrorInfo
-{
- HelpProcessingErrorClass m_eErrorClass;
- rtl::OUString m_aErrorMsg;
- rtl::OUString m_aXMLParsingFile;
- sal_Int32 m_nXMLParsingLine;
-
- HelpProcessingErrorInfo( void )
- : m_eErrorClass( HELPPROCESSING_NO_ERROR )
- , m_nXMLParsingLine( -1 )
- {}
-
- HelpProcessingErrorInfo& operator=( const struct HelpProcessingException& e );
-};
-
-
-// Returns true in case of success, false in case of error
-HELPLINKER_DLLPUBLIC bool compileExtensionHelp
-(
- const rtl::OUString& aOfficeHelpPath,
- const rtl::OUString& aExtensionName,
- const rtl::OUString& aExtensionLanguageRoot,
- sal_Int32 nXhpFileCount, const rtl::OUString* pXhpFiles,
- const rtl::OUString& aDestination,
- HelpProcessingErrorInfo& o_rHelpProcessingErrorInfo
-);
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index 6f4071e32053..2d4435c5e74c 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -154,7 +154,7 @@ bool HelpParser::CreateSDF(
rtl::OUString()).
replaceAll(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t")),
- rtl::OUString()));
+ rtl::OUString()).trim());
sBuffer.append( sOUPrj );
sBuffer.append('\t');
if ( !rRoot_in.isEmpty())
@@ -373,8 +373,23 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const rtl::OString& sCur ,
if( pEntrys != NULL)
{
rtl::OString sNewText;
+ rtl::OUString sSourceText(
+ pXMLElement->ToOUString().
+ replaceAll(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n")),
+ rtl::OUString()).
+ replaceAll(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t")),
+ rtl::OUString()));
+ // re-add spaces to the beginning of translated string,
+ // important for indentation of Basic code examples
+ sal_Int32 nPreSpaces = 0;
+ sal_Int32 nLen = sSourceText.getLength();
+ while ( (nPreSpaces < nLen) && (*(sSourceText.getStr()+nPreSpaces) == ' ') )
+ nPreSpaces++;
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sCur , true );
rtl::OUString sNewdata(
+ sSourceText.copy(0,nPreSpaces) +
rtl::OStringToOUString(sNewText, RTL_TEXTENCODING_UTF8));
if (!sNewdata.isEmpty())
{
diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx
index 7c1ad3f0590f..a9a20c8b13da 100644
--- a/l10ntools/source/localize.cxx
+++ b/l10ntools/source/localize.cxx
@@ -312,7 +312,8 @@ void handleFile(
{ RTL_CONSTASCII_STRINGPARAM(".xrm"), "xrmex", false },
{ RTL_CONSTASCII_STRINGPARAM(".xml"), "xrmex", true },
{ RTL_CONSTASCII_STRINGPARAM(".xhp"), "helpex", false },
- { RTL_CONSTASCII_STRINGPARAM(".properties"), "propex", false } };
+ { RTL_CONSTASCII_STRINGPARAM(".properties"), "propex", false },
+ { RTL_CONSTASCII_STRINGPARAM(".ui"), "uiex", false } };
for (std::size_t i = 0; i != SAL_N_ELEMENTS(commands); ++i) {
if (url.endsWithAsciiL(
commands[i].extension, commands[i].extensionLength))
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index a1c4570056e6..b87024a22dec 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -242,7 +242,7 @@ MergeDataFile::~MergeDataFile()
delete aI->second;
}
-std::vector<rtl::OString> MergeDataFile::GetLanguages()
+std::vector<rtl::OString> MergeDataFile::GetLanguages() const
{
return std::vector<rtl::OString>(aLanguageSet.begin(),aLanguageSet.end());
}
diff --git a/l10ntools/source/srclex.l b/l10ntools/source/srclex.l
index e99eea42ac44..01be0df7ea3b 100644
--- a/l10ntools/source/srclex.l
+++ b/l10ntools/source/srclex.l
@@ -82,8 +82,8 @@ void YYWarning();
pChar[1] = 0x00;
pChar[0] = c2;
- WorkOnTokenSet( COMMEND, yytext );
- WorkOnTokenSet( COMMEND, pChar );
+ WorkOnTokenSet( COMMENT, yytext );
+ WorkOnTokenSet( COMMENT, pChar );
for(;;) {
if ( c2 == EOF )
break;
@@ -92,7 +92,7 @@ void YYWarning();
c1 = c2;
c2 = yyinput();
pChar[0] = c2;
- WorkOnTokenSet( COMMEND, pChar );
+ WorkOnTokenSet( COMMENT, pChar );
}
}
diff --git a/l10ntools/source/uimerge.cxx b/l10ntools/source/uimerge.cxx
new file mode 100644
index 000000000000..bdf536a238dc
--- /dev/null
+++ b/l10ntools/source/uimerge.cxx
@@ -0,0 +1,311 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/main.h>
+
+#include <rtl/strbuf.hxx>
+
+#include <libexslt/exslt.h>
+#include <libxslt/transform.h>
+#include <libxslt/xslt.h>
+#include <libxslt/xsltutils.h>
+
+#include <stdio.h>
+
+#include "common.hxx"
+#include "export.hxx"
+#include "xrmmerge.hxx"
+#include "tokens.h"
+#include <iostream>
+#include <fstream>
+#include <vector>
+
+#define STATE_NON 0x0001
+#define STATE_INPUT 0x0002
+#define STATE_OUTPUT 0x0003
+#define STATE_PRJ 0x0004
+#define STATE_ROOT 0x0005
+#define STATE_MERGESRC 0x0006
+#define STATE_ERRORLOG 0x0007
+#define STATE_LANGUAGES 0x000C
+
+sal_Bool bMergeMode;
+sal_Bool bErrorLog;
+sal_Bool bUTF8;
+sal_Bool bDisplayName;
+sal_Bool bExtensionDescription;
+rtl::OString sPrj;
+rtl::OString sPrjRoot;
+rtl::OString sInputFileName;
+rtl::OString sOutputFile;
+rtl::OString sMergeSrc;
+rtl::OString sLangAttribute;
+rtl::OString sResourceType;
+XRMResParser *pParser = NULL;
+
+void GetOutputFile( int argc, char* argv[])
+{
+ bMergeMode = sal_False;
+ bErrorLog = sal_True;
+ bUTF8 = sal_True;
+ bDisplayName = sal_False;
+ bExtensionDescription = sal_False;
+ sPrj = "";
+ sPrjRoot = "";
+ sInputFileName = "";
+ Export::sLanguages = "";
+ sal_uInt16 nState = STATE_NON;
+
+ // parse command line
+ for( int i = 1; i < argc; i++ ) {
+ if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-I" ) {
+ nState = STATE_INPUT; // next token specifies source file
+ }
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-O" ) {
+ nState = STATE_OUTPUT; // next token specifies the dest file
+ }
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-P" ) {
+ nState = STATE_PRJ; // next token specifies the cur. project
+ }
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-R" ) {
+ nState = STATE_ROOT; // next token specifies path to project root
+ }
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-M" ) {
+ nState = STATE_MERGESRC; // next token specifies the merge database
+ }
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-E" ) {
+ nState = STATE_ERRORLOG;
+ bErrorLog = sal_False;
+ }
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-L" ) {
+ nState = STATE_LANGUAGES;
+ }
+ else {
+ switch ( nState ) {
+ case STATE_NON: {
+ return; // no valid command line
+ }
+ case STATE_INPUT: {
+ sInputFileName = argv[ i ];
+ }
+ break;
+ case STATE_OUTPUT: {
+ sOutputFile = argv[ i ]; // the dest. file
+ }
+ break;
+ case STATE_PRJ: {
+ sPrj = rtl::OString( argv[ i ]);
+ }
+ break;
+ case STATE_ROOT: {
+ sPrjRoot = rtl::OString( argv[ i ]); // path to project root
+ }
+ break;
+ case STATE_MERGESRC: {
+ sMergeSrc = rtl::OString( argv[ i ]);
+ bMergeMode = sal_True; // activate merge mode, cause merge database found
+ }
+ break;
+ case STATE_LANGUAGES: {
+ Export::sLanguages = rtl::OString( argv[ i ]);
+ }
+ break;
+ }
+ }
+ }
+}
+
+int extractTranslations()
+{
+ FILE *pOutFile = fopen(sOutputFile.getStr(), "w");
+ if (!pOutFile)
+ {
+ fprintf(stderr, "cannot open %s\n", sOutputFile.getStr());
+ return 1;
+ }
+
+ exsltRegisterAll();
+
+ rtl::OString sActFileName = common::pathnameToken(sInputFileName.getStr(), sPrjRoot.getStr());
+
+ rtl::OString sStyleSheet = rtl::OString(getenv("SRC_ROOT")) + rtl::OString("/solenv/bin/uilangfilter.xslt");
+
+ xsltStylesheetPtr stylesheet = xsltParseStylesheetFile ((const xmlChar *)sStyleSheet.getStr());
+
+ xmlDocPtr doc = xmlParseFile(sInputFileName.getStr());
+
+ xmlDocPtr res = xsltApplyStylesheet(stylesheet, doc, NULL);
+
+ for( xmlNodePtr nodeLevel1 = res->children; nodeLevel1 != NULL; nodeLevel1 = nodeLevel1->next)
+ {
+ for( xmlNodePtr nodeLevel2 = nodeLevel1->children; nodeLevel2 != NULL; nodeLevel2 = nodeLevel2->next)
+ {
+ if (nodeLevel2->type == XML_ELEMENT_NODE)
+ {
+ fprintf(pOutFile, "%s\t%s\t0\t",sPrj.getStr(), sActFileName.getStr());
+ for(xmlAttrPtr attribute = nodeLevel2->properties; attribute != NULL; attribute = attribute->next)
+ {
+ xmlChar *content = xmlNodeListGetString(res, attribute->children, 1);
+ fprintf(pOutFile, "%s\t", content);
+ xmlFree(content);
+ }
+ fprintf(pOutFile, "\t\t0\ten-US\t%s\t\t\t\t\n", xmlNodeGetContent(nodeLevel2));
+ }
+ }
+ }
+
+ xmlFreeDoc(res);
+
+ xmlFreeDoc(doc);
+
+ xsltFreeStylesheet(stylesheet);
+
+ fclose(pOutFile);
+
+ return 0;
+}
+
+namespace
+{
+ rtl::OString QuotHTML(const rtl::OString &rString)
+ {
+ rtl::OStringBuffer sReturn;
+ for (sal_Int32 i = 0; i < rString.getLength(); ++i) {
+ switch (rString[i]) {
+ case '\\':
+ if (i < rString.getLength()) {
+ switch (rString[i + 1]) {
+ case '"':
+ case '<':
+ case '>':
+ case '\\':
+ ++i;
+ break;
+ }
+ }
+ // fall through
+ default:
+ sReturn.append(rString[i]);
+ break;
+
+ case '<':
+ sReturn.append("&lt;");
+ break;
+
+ case '>':
+ sReturn.append("&gt;");
+ break;
+
+ case '"':
+ sReturn.append("&quot;");
+ break;
+
+ case '&':
+ if (rString.matchL(RTL_CONSTASCII_STRINGPARAM("&amp;"), i))
+ sReturn.append('&');
+ else
+ sReturn.append(RTL_CONSTASCII_STRINGPARAM("&amp;"));
+ break;
+ }
+ }
+ return sReturn.makeStringAndClear();
+ }
+}
+
+bool Merge(
+ const rtl::OString &rSDFFile,
+ const rtl::OString &rSourceFile,
+ const rtl::OString &rDestinationFile)
+{
+ Export::InitLanguages( true );
+ std::ofstream aDestination(
+ rDestinationFile.getStr(), std::ios_base::out | std::ios_base::trunc);
+ if (!aDestination.is_open()) {
+ return false;
+ }
+
+ aDestination << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ aDestination << "<t>\n";
+
+ MergeDataFile aMergeDataFile( rSDFFile, rSourceFile, sal_False );
+ rtl::OString sTmp( Export::sLanguages );
+ if( sTmp.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("ALL")) )
+ Export::SetLanguages( aMergeDataFile.GetLanguages() );
+
+ std::vector<rtl::OString> aLanguages = Export::GetLanguages();
+
+ const MergeDataHashMap& rMap = aMergeDataFile.getMap();
+
+ for(size_t n = 0; n < aLanguages.size(); ++n)
+ {
+ rtl::OString sCur = aLanguages[ n ];
+ if (sCur.isEmpty() || sCur.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")))
+ continue;
+ for (MergeDataHashMap::const_iterator aI = rMap.begin(), aEnd = rMap.end(); aI != aEnd; ++aI)
+ {
+ if (aI->second->sGID.isEmpty())
+ continue;
+
+ PFormEntrys* pFoo = aI->second->GetPFormEntries();
+ rtl::OString sOut;
+ pFoo->GetText( sOut, STRING_TYP_TEXT, sCur);
+
+ if (sOut.isEmpty())
+ continue;
+
+ aDestination << " <e "
+ << "g=\"" << aI->second->sGID.getStr() << "\" "
+ << "i=\"" << aI->second->sLID.getStr() << "\">"
+ << QuotHTML(sOut).getStr() << "</e>\n";
+ }
+ }
+
+ aDestination << "</t>";
+ aDestination.close();
+ return sal_True;
+}
+
+SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
+{
+ int nRetValue = 0;
+
+ GetOutputFile( argc, argv );
+
+ if (sOutputFile.isEmpty())
+ {
+ fprintf( stdout, "Syntax: UIEX[-p Prj][-r PrjRoot]-i FileIn [-o FileOut][-m DataBase][-e][-L l1,l2,...]\n" );
+ fprintf( stdout, " Prj: Project\n" );
+ fprintf( stdout, " PrjRoot: Path to project root (..\\.. etc.)\n" );
+ fprintf( stdout, " FileIn: Source files (*.src)\n" );
+ fprintf( stdout, " FileOut: Destination file (*.*)\n" );
+ fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
+ fprintf( stdout, " -e: Disable writing errorlog\n" );
+ fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US,es...)\n" );
+ return 1;
+ }
+
+ if (!bMergeMode)
+ {
+ if (Export::sLanguages != "en-US")
+ {
+ fprintf(stderr, "only en-US can exist in source .ui files\n");
+ nRetValue = 1;
+ }
+ else
+ nRetValue = extractTranslations();
+ }
+ else
+ {
+ Merge(sMergeSrc, sInputFileName, sOutputFile);
+ }
+
+ return nRetValue;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/ulfconv/msi-encodinglist.txt b/l10ntools/source/ulfconv/msi-encodinglist.txt
index 9b93d55ff16e..113f4a40f84a 100644
--- a/l10ntools/source/ulfconv/msi-encodinglist.txt
+++ b/l10ntools/source/ulfconv/msi-encodinglist.txt
@@ -16,62 +16,64 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
-# Syntax: language ANSI-Codepage LCID
+# Syntax: language 0 LCID
+# 2nd field used to be the ANSI codepage,
+# but now we are using UTF-8 everywhere.
# comment lines begin with hash
-af 1252 1078 # Afrikaans
+af 0 1078 # Afrikaans
am 0 1118 # Amharic
-ar 1256 1025
-ar-SA 1256 1025
+ar 0 1025
+ar-SA 0 1025
as 0 1101 # Assamese
as-IN 0 1101 # Assamese
-ast 1252 1610
-be 1251 1059 # Belarusian
-be-BY 1251 1059
-bg 1251 1026 # Bulgarian
+ast 0 1610
+be 0 1059 # Belarusian
+be-BY 0 1059
+bg 0 1026 # Bulgarian
bn 0 2117 # Bengali
bn-BD 0 2117 # Bengali Bangladesh
bn-IN 0 1093 # Bengali India
bo 0 2121
-br 1252 1150 # Breton
+br 0 1150 # Breton
brx 0 1603 # Bodo (India)
bs 0 5146 # bosnian
-ca 1252 1027 # Catalan
-ca-XV 1252 32771 # Catalan Valencian
-cs 1250 1029 # Czech
-cy 1252 1106 # Welsh
-da 1252 1030
-de 1252 1031
+ca 0 1027 # Catalan
+ca-XV 0 32771 # Catalan Valencian
+cs 0 1029 # Czech
+cy 0 1106 # Welsh
+da 0 1030
+de 0 1031
dgo 0 1604 # Dogri (India)
dz 0 2129 # Dzongkha (same ID as tibetan bhutan (s. i40713))
-el 1253 1032
-en-GB 1252 2057
-en-US 1252 1033
-en-ZA 1252 7177
+el 0 1032
+en-GB 0 2057
+en-US 0 1033
+en-ZA 0 7177
eo 0 1553 # Esperanto
-es 1252 1034
-et 1257 1061
-eu 1252 1069 # Basque
+es 0 1034
+et 0 1061
+eu 0 1069 # Basque
fa 0 1065 # Farsi
-fi 1252 1035
-fo 1252 1080 # Faroese
-fr 1252 1036
-fr-CA 1252 3084
+fi 0 1035
+fo 0 1080 # Faroese
+fr 0 1036
+fr-CA 0 3084
fur 0 1585
ga 0 2108 # Irish
gd 0 1084 # Gaelic (Scotland)
-gl 1252 1110 # Galician
+gl 0 1110 # Galician
gu 0 1095 # Gujarati
gu-IN 0 1095 # Gujarati
-he 1255 1037
+he 0 1037
hi 0 1081
-hr 1250 1050 # Croatian
-ht 1252 1626 # Haitian
-hu 1250 1038
+hr 0 1050 # Croatian
+ht 0 1626 # Haitian
+hu 0 1038
hy 0 1067 # Armenian
-id 1252 1057 # Indonesian
-is 1252 1039 # Icelandic
-it 1252 1040
-ja 932 1041
+id 0 1057 # Indonesian
+is 0 1039 # Icelandic
+it 0 1040
+ja 0 1041
jbo 0 1624
ka 0 1079 # Georgian
kab 0 1625
@@ -79,18 +81,18 @@ kk 0 1087
km 0 1107 # Khmer
kn 0 1099 # Kannada
kn-IN 0 1099 # Kannada
-ko 949 1042
+ko 0 1042
kok 0 1111 # Konkani
ks 0 1120 # Kashmiri
ku 0 1574
ky 0 1088 # Kyrgyz
ky-CN 0 1640 # Kyrgyz (China)
-lb 1252 1134
+lb 0 1134
lo 0 1108 # Lao
-lt 1257 1063 # Lithuanian
-lv 1257 1062 # Latvian
+lt 0 1063 # Lithuanian
+lv 0 1062 # Latvian
mai 0 1605 # Maithili (India)
-mk 1251 1071 # Macedonian
+mk 0 1071 # Macedonian
ml 0 1100
ml-IN 0 1100
mn 0 1104 # Mongolian
@@ -101,70 +103,70 @@ mr-IN 0 1102
ms 0 1086 # Malay (Malaysian)
mt 0 1082 # Maltese
my 0 1109 # Burmese
-nb 1252 1044
+nb 0 1044
ne 0 1121 # Nepali
-nl 1252 1043
-nn 1252 2068
-no 1252 1044
+nl 0 1043
+nn 0 2068
+no 0 1044
nr 0 1580 # Ndebele South
nso 0 1132
ny 0 1598
-oc 1252 1154 # Occitan-lengadocian
+oc 0 1154 # Occitan-lengadocian
om 0 2162
or 0 1096 # Oriya
or-IN 0 1096
pa-IN 0 1094 # Punjabi
pap 0 2171
-pl 1250 1045
+pl 0 1045
ps 0 2171
-pt 1252 2070
-pt-BR 1252 1046
-pt-PT 1252 2070
-qtz 1252 1033 # key id pseudo language
+pt 0 2070
+pt-BR 0 1046
+pt-PT 0 2070
+qtz 0 1033 # key id pseudo language
rm 0 1047 # Raeto-Romance
-ro 1250 1048 # Romanian
-ru 1251 1049
+ro 0 1048 # Romanian
+ru 0 1049
rw 0 1569 # Kinyarwanda
sa-IN 0 1103 # Sanskrit
sat 0 1606 # Santali
sb 0 1070 # Sorbian
sc 0 3047
sd 0 1113 # Sindhi
-sh 1250 2074 # Serbian Latin
+sh 0 2074 # Serbian Latin
si 0 2133
-sk 1250 1051 # Slovak
-sl 1250 1060 # Slovenian
-sq 1250 1052 # Albanian
-sr 1251 3098 # Serbian Cyrillic
-sr-SP 1251 3098 # Serbian Cyrillic
+sk 0 1051 # Slovak
+sl 0 1060 # Slovenian
+sq 0 1052 # Albanian
+sr 0 3098 # Serbian Cyrillic
+sr-SP 0 3098 # Serbian Cyrillic
ss 0 1579 # Swazi
st 0 1072 # Southern Sotho, Sutu
-sv 1252 1053
-sw 1252 1089 # Swahili
-sw-TZ 1252 1089 # Swahili
+sv 0 1053
+sw 0 1089 # Swahili
+sw-TZ 0 1089 # Swahili
so 0 1143
ta 0 1097 # Tamil
ta-IN 0 1097 # Tamil
te 0 1098
te-IN 0 1098
tg 0 1064 # Tajik
-th 874 1054
+th 0 1054
ti 0 1139 # Tigrinya
ti-ER 0 1139 # Tigrinya
tn 0 1074 # Setsuana
-tr 1254 1055 # Turkish
+tr 0 1055 # Turkish
ts 0 1073 # Tsonga
tk 0 1090
-tt 1251 1092 # Tatar
+tt 0 1092 # Tatar
ug 0 1152
-uk 1251 1058 # Ukrainian
-ur 1256 1056 # Urdu
+uk 0 1058 # Ukrainian
+ur 0 1056 # Urdu
ur-IN 0 2080
uz 0 1091 # Uzbek (Latin)
ve 0 1075 # Venda
-vi 1258 1066 # Vietnamese
+vi 0 1066 # Vietnamese
xh 0 1076 # Xhosa
yi 0 1085 # Yiddish
-zh-CN 936 2052
-zh-TW 950 1028
+zh-CN 0 2052
+zh-TW 0 1028
zu 0 1077 # Zulu
diff --git a/l10ntools/source/xrmlex.l b/l10ntools/source/xrmlex.l
index 9e9aa5cb93ba..eadb19f3fbfb 100644
--- a/l10ntools/source/xrmlex.l
+++ b/l10ntools/source/xrmlex.l
@@ -144,8 +144,8 @@ int bText=0;
pChar[1] = 0x00;
pChar[0] = c3;
- WorkOnTokenSet( COMMEND, yytext );
- WorkOnTokenSet( COMMEND, pChar );
+ WorkOnTokenSet( COMMENT, yytext );
+ WorkOnTokenSet( COMMENT, pChar );
for(;;) {
if ( c3 == EOF )
@@ -156,7 +156,7 @@ int bText=0;
c2 = c3;
c3 = yyinput();
pChar[0] = c3;
- WorkOnTokenSet( COMMEND, pChar );
+ WorkOnTokenSet( COMMENT, pChar );
}
}