[Libreoffice-commits] .: Branch 'feature/killsdf' - 2 commits - helpcontent2 l10ntools/inc l10ntools/source solenv/inc
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Nov 18 10:21:49 PST 2012
helpcontent2 | 2 -
l10ntools/inc/helpmerge.hxx | 2 -
l10ntools/source/helpex.cxx | 80 +++++++++++++++++++++++++++++++++++++----
l10ntools/source/helpmerge.cxx | 45 -----------------------
l10ntools/source/merge.cxx | 13 +++---
l10ntools/source/treemerge.cxx | 5 +-
solenv/inc/tg_help.mk | 5 ++
solenv/inc/unitools.mk | 1
8 files changed, 88 insertions(+), 65 deletions(-)
New commits:
commit 06d5579c9291b6061ee89eed8f505f436375e15d
Author: Zolnai Tamás <zolnaitamas2000g at gmail.com>
Date: Sun Nov 18 18:20:38 2012 +0100
Localize tree files in help
-Treex works well when po is not exist, send a
warning but make en-US tree-s.
Change-Id: Ib2b790742c022211a8d250b66891cef045941398
diff --git a/helpcontent2 b/helpcontent2
index 23d7515..7bb6ef6 160000
--- a/helpcontent2
+++ b/helpcontent2
@@ -1 +1 @@
-Subproject commit 23d7515757534fca7d50e1201745586adde4b8f6
+Subproject commit 7bb6ef60f6486e143fda08cc1527f5eb71c86b09
diff --git a/l10ntools/source/treemerge.cxx b/l10ntools/source/treemerge.cxx
index 12e931c..8555c8f 100644
--- a/l10ntools/source/treemerge.cxx
+++ b/l10ntools/source/treemerge.cxx
@@ -279,8 +279,8 @@ void TreeParser::Merge(
{
MergeDataFile aMergeDataFile(
rMergeSrc, static_cast<OString>( m_pSource->name ), false );
-
- if( aMergeDataFile.GetLanguages()[0] != m_sLang )
+ const std::vector<OString> vLanguages = aMergeDataFile.GetLanguages();
+ if( !vLanguages.empty() && vLanguages[0] != m_sLang )
{
std::cerr
<< "Treex error: given language conflicts with "
@@ -288,7 +288,6 @@ void TreeParser::Merge(
<< m_sLang.getStr() << " - " << rMergeSrc.getStr() << std::endl;
return;
}
-
lcl_MergeLevel(
m_pSource, pRootNode, (const xmlChar *)("help_section"),
&aMergeDataFile, m_sLang, rXhpRoot );
diff --git a/solenv/inc/unitools.mk b/solenv/inc/unitools.mk
index 863c4ad..bbd51bf 100644
--- a/solenv/inc/unitools.mk
+++ b/solenv/inc/unitools.mk
@@ -33,6 +33,7 @@ CFGEX*=$(AUGMENT_LIBRARY_PATH) $(SOLARBINDIR)/cfgex
AUTODOC*=$(AUGMENT_LIBRARY_PATH) $(SOLARBINDIR)/autodoc
LOCALIZE*=$(AUGMENT_LIBRARY_PATH) $(SOLARBINDIR)/localize
GSICHECK*=$(AUGMENT_LIBRARY_PATH) $(SOLARBINDIR)/gsicheck
+TREEX*=$(AUGMENT_LIBRARY_PATH) $(SOLARBINDIR)/treex
.IF "$(XSLTPROC)"==""
.IF "$(SYSTEM_LIBXSLT)"!="YES"
commit 5d84ae59e70b8b1017959a68934ac1f455ce2b13
Author: Zolnai Tamás <zolnaitamas2000g at gmail.com>
Date: Sun Nov 18 15:24:44 2012 +0100
Localize xhp files in help
Make helpex to be able to work with more xhp files at one time
- Add new input flag "-mi" which means multiinput
- Input is a file include pathes to xhp files
(these are in the same directory so their strings
are in the same po file)
- Output is a file include pathes to dest xhp files
- Merge reads all po entry from the specified po file
if MergeDataFile ctor's second parameter is empty
Rewrite makefiles to work with new syntax
Plus Delete some unused code
Change-Id: I5eb12d7a6f5e9cda378788410d3c50052eb752b8
diff --git a/l10ntools/inc/helpmerge.hxx b/l10ntools/inc/helpmerge.hxx
index 34dfdc7..401f839 100644
--- a/l10ntools/inc/helpmerge.hxx
+++ b/l10ntools/inc/helpmerge.hxx
@@ -55,8 +55,6 @@ public:
/// point to existing files.
bool Merge( const rtl::OString &rSDFFile_in, const rtl::OString &rDestinationFile_in ,
const rtl::OString& sLanguage , MergeDataFile& aMergeDataFile );
- bool Merge( const rtl::OString &rSDFFile, const rtl::OString &rPathX , const rtl::OString &rPathY , bool bISO
- , const std::vector<rtl::OString>& aLanguages , MergeDataFile& aMergeDataFile , bool bCreateDir );
private:
rtl::OString GetOutpath( const rtl::OString& rPathX , const rtl::OString& sCur , const rtl::OString& rPathY );
diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx
index 8dca205..7ab581a 100644
--- a/l10ntools/source/helpex.cxx
+++ b/l10ntools/source/helpex.cxx
@@ -20,6 +20,9 @@
#include "sal/config.h"
#include <iostream>
+#include <fstream>
+#include <string>
+#include <cstring>
#include <stdio.h>
#include <stdlib.h>
@@ -30,24 +33,87 @@
#ifndef TESTDRIVER
+void WriteUsage()
+{
+ std::cout
+ << "Syntax: Helpex [-p Prj] [-r Root] -[m]i FileIn -o FileOut"
+ << " [-m DataBase] [-l l1,l2,...]\n"
+ << " Prj: Project\n"
+ << " Root: Path to project root (../.. etc.)\n"
+ << " FileIn + i: Source file (*.xhp)\n"
+ << " FileIn + -mi: File including pathes of source files"
+ << " (only for merge)"
+ << " FileOut: Destination file (*.*) or files (in case of -mi)\n"
+ << " DataBase: Mergedata (*.po)\n"
+ << " -l: Restrict the handled languages; l1, l2, ... are elements of"
+ << " (de, en-US, ...)\n";
+}
+
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
+
+ bool bMultiMerge = false;
+ for (int nIndex = 1; nIndex != argc; ++nIndex)
+ {
+ if (std::strcmp(argv[nIndex], "-mi") == 0)
+ {
+ argv[nIndex][1] = 'i';
+ argv[nIndex][2] = '\0';
+ bMultiMerge = true;
+ break;
+ }
+ }
+
HandledArgs aArgs;
- if ( !Export::handleArguments( argc, argv, aArgs) ) {
- Export::writeUsage("helpex","xhp");
+ if ( !Export::handleArguments( argc, argv, aArgs) )
+ {
+ WriteUsage();
return 1;
}
- //sal_uInt32 startfull = Export::startMessure();
bool hasNoError = true;
- HelpParser aParser( aArgs.m_sInputFile );
if ( aArgs.m_bMergeMode )
{
- //sal_uInt64 startreadloc = Export::startMessure();
- MergeDataFile aMergeDataFile( aArgs.m_sMergeSrc, aArgs.m_sInputFile, false );
- hasNoError = aParser.Merge( aArgs.m_sMergeSrc, aArgs.m_sOutputFile , Export::sLanguages , aMergeDataFile );
+ if( bMultiMerge )
+ {
+ std::ifstream aInput( aArgs.m_sInputFile.getStr() );
+ if( !aInput.is_open() )
+ {
+ std::cerr << "Helpex error: cannot open input file\n";
+ return 1;
+ }
+ MergeDataFile aMergeDataFile( aArgs.m_sMergeSrc, OString(), false);
+ std::string sTemp;
+ aInput >> sTemp;
+ while( !aInput.eof() )
+ {
+ const OString sXhpFile( sTemp.data(), sTemp.length() );
+ HelpParser aParser( sXhpFile );
+ const OString sOutput(
+ aArgs.m_sOutputFile +
+ sXhpFile.copy( sXhpFile.lastIndexOf("/") ));
+ if( !aParser.Merge( aArgs.m_sMergeSrc, sOutput,
+ Export::sLanguages, aMergeDataFile ))
+ {
+ hasNoError = false;
+ }
+ aInput >> sTemp;
+ }
+ aInput.close();
+ }
+ else
+ {
+ HelpParser aParser( aArgs.m_sInputFile );
+ MergeDataFile aMergeDataFile(
+ aArgs.m_sMergeSrc, aArgs.m_sInputFile, false );
+ hasNoError =
+ aParser.Merge(
+ aArgs.m_sMergeSrc, aArgs.m_sOutputFile,
+ Export::sLanguages , aMergeDataFile );
+ }
}
else
{
+ HelpParser aParser( aArgs.m_sInputFile );
hasNoError =
aParser.CreateSDF(
aArgs.m_sOutputFile, aArgs.m_sPrj, aArgs.m_sPrjRoot,
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index 8764935..68f7453 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -227,51 +227,6 @@ void HelpParser::parse_languages( std::vector<rtl::OString>& aLanguages , MergeD
}
-bool HelpParser::Merge(
- const rtl::OString &rSDFFile, const rtl::OString &rPathX , const rtl::OString &rPathY , bool bISO ,
- const std::vector<rtl::OString>& aLanguages , MergeDataFile& aMergeDataFile , bool bCreateDir )
-{
-
-
- (void) rSDFFile ;
- bool hasNoError = true;
- SimpleXMLParser aParser;
- rtl::OUString sXmlFile(
- rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US));
- //TODO: explicit BOM handling?
-
- XMLFile* xmlfile = aParser.Execute( sXmlFile, new XMLFile( rtl::OUString('0') ) );
-
- if( xmlfile == NULL)
- {
- printf("%s\n", rtl::OUStringToOString(aParser.GetError().sMessage, RTL_TEXTENCODING_UTF8).getStr());
- exit(-1);
- }
-
- xmlfile->Extract();
-
- rtl::OString sCur;
- for( unsigned int n = 0; n < aLanguages.size(); n++ ){
- sCur = aLanguages[ n ];
-
- rtl::OString sFilepath;
- if( bISO ) sFilepath = GetOutpath( rPathX , sCur , rPathY );
- else sFilepath = rPathX;
- if( bCreateDir )
- MakeDir(sFilepath);
-
- XMLFile* file = new XMLFile( *xmlfile );
- sFilepath += sHelpFile;
- hasNoError = MergeSingleFile( file , aMergeDataFile , sCur , sFilepath );
- delete file;
-
- if( !hasNoError ) return false; // Stop on error
- }
-
- delete xmlfile;
- return hasNoError;
-}
-
bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile , const rtl::OString& sLanguage ,
rtl::OString const & sPath )
{
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index 80188f5..73bd8dd 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -150,8 +150,7 @@ sal_Bool MergeData::operator==( ResData *pData )
//
MergeDataFile::MergeDataFile(
- const rtl::OString &rFileName,
- const rtl::OString &rFile,
+ const rtl::OString &rFileName, const rtl::OString &rFile,
bool bCaseSensitive)
{
std::ifstream aInputStream( rFileName.getStr() );
@@ -167,6 +166,7 @@ MergeDataFile::MergeDataFile(
{
const OString sHack("HACK");
const OString sFileName( lcl_NormalizeFilename(rFile) );
+ const bool bReadAll = sFileName.isEmpty();
PoIfstream aPoInput;
aPoInput.open( OString(sPoFileName.data(), sPoFileName.length()) );
if ( !aPoInput.isOpen() )
@@ -212,8 +212,8 @@ MergeDataFile::MergeDataFile(
{
return;
}
- } while( !aPoInput.eof() && aNextPo.getSourceFile() != sFileName );
- while( !aPoInput.eof() && aNextPo.getSourceFile() == sFileName )
+ } while( !aPoInput.eof() && aNextPo.getSourceFile() != sFileName && !bReadAll );
+ while( !aPoInput.eof() && (aNextPo.getSourceFile() == sFileName || bReadAll ))
{
PoEntry aActPo( aNextPo );
@@ -262,7 +262,7 @@ MergeDataFile::MergeDataFile(
InsertEntry(
aActPo.getResourceType(), aActPo.getGroupId(),
aActPo.getLocalId(), sHack, sLang, sText,
- sQHText, sTitle, sFileName, bCaseSensitive );
+ sQHText, sTitle, aActPo.getSourceFile(), bCaseSensitive );
if( bFirstLang )
{
@@ -271,7 +271,8 @@ MergeDataFile::MergeDataFile(
aActPo.getResourceType(), aActPo.getGroupId(),
aActPo.getLocalId(), sHack, "qtz",
sQTZText + "||" + sExText, sQTZQHText + "||" + sExQHText,
- sQTZTitle + "||" + sExTitle, sFileName, bCaseSensitive );
+ sQTZTitle + "||" + sExTitle, aActPo.getSourceFile(),
+ bCaseSensitive );
}
}
aPoInput.close();
diff --git a/solenv/inc/tg_help.mk b/solenv/inc/tg_help.mk
index c67e04a..f87953a 100644
--- a/solenv/inc/tg_help.mk
+++ b/solenv/inc/tg_help.mk
@@ -54,7 +54,10 @@ $(XHPDEST)$/{$(aux_alllangiso)}$/$(SHELL_PACKAGE)$/%.xhp :| %.xhp
$(HELP_OUT)$/$(TARGET).done : $(HLANGXHPFILES)
.IF "$(WITH_LANG)"!=""
@echo Localizing help files...
- $(COMMAND_ECHO)$(AUGMENT_LIBRARY_PATH) $(HELPEX) -p $(PRJNAME) -r $(PRJ) -i @$(mktmp $(uniq $(foreach,i,$? $(!eq,$(i:f),$(i:f:s/.xhp//) $(i:f) $(XHPFILES))))) -x $(XHPDEST) -y $(SHELL_PACKAGE) -l all -lf $(aux_alllangiso:t",") -m $(LOCALIZESDF) && $(TOUCH) $@
+ @$(foreach,xhpfile,$(XHPFILES) cp $(SRC_ROOT)/$(PRJNAME)/source/$(SHELL_PACKAGE)/$(xhpfile) $(subst,$(PRJ),$(SRC_ROOT)/$(PRJNAME) $(XHPDEST))/en-US/$(SHELL_PACKAGE)/$(xhpfile) && ) \
+ $(foreach,lang,$(subst,en-US, $(aux_alllangiso)) \
+ $(AUGMENT_LIBRARY_PATH) $(HELPEX) -mi $(mktmp $(foreach,xhpfile,$(XHPFILES) $(SRC_ROOT)/$(PRJNAME)/source/$(SHELL_PACKAGE)/$(xhpfile))) -o $(subst,$(PRJ),$(SRC_ROOT)/$(PRJNAME) $(XHPDEST))/$(lang)/$(SHELL_PACKAGE) -m $(mktmp $(SRC_ROOT)/translations/source/$(lang)/$(PRJNAME)/source/$(SHELL_PACKAGE).po) -l $(lang) && )\
+ $(TOUCH) $@
.ELSE # "$(WITH_LANG)"!=""
@echo Copying help files...
$(COMMAND_ECHO)cp $(uniq $(foreach,i,$? $(!eq,$(i:f),$(i:f:s/.xhp//) $(i:f) $(XHPFILES)))) $(XHPDEST)$/en-US$/$(SHELL_PACKAGE) && $(TOUCH) $@
More information about the Libreoffice-commits
mailing list