[Libreoffice-commits] core.git: l10ntools/Executable_genlang.mk l10ntools/inc l10ntools/Module_l10ntools.mk l10ntools/source Repository.mk
Jan Iversen
jani at documentfoundation.org
Thu Mar 3 07:47:21 UTC 2016
Repository.mk | 1
l10ntools/Executable_genlang.mk | 73 +++
l10ntools/Module_l10ntools.mk | 1
l10ntools/inc/gConv.hxx | 92 ++++
l10ntools/inc/gConvDB.hxx | 49 ++
l10ntools/inc/gConvPo.hxx | 71 +++
l10ntools/inc/gConvProp.hxx | 45 ++
l10ntools/inc/gConvSrc.hxx | 75 ++++
l10ntools/inc/gConvTree.hxx | 75 ++++
l10ntools/inc/gConvUlf.hxx | 52 ++
l10ntools/inc/gConvXcs.hxx | 52 ++
l10ntools/inc/gConvXcu.hxx | 60 +++
l10ntools/inc/gConvXhp.hxx | 77 ++++
l10ntools/inc/gConvXrm.hxx | 56 +++
l10ntools/inc/gL10nMem.hxx | 217 +++++++++++
l10ntools/inc/gLang.hxx | 164 ++++++++
l10ntools/source/gConv.cxx | 363 +++++++++++++++++++
l10ntools/source/gConvDB.cxx | 97 +++++
l10ntools/source/gConvPo.cxx | 243 +++++++++++++
l10ntools/source/gConvProp.cxx | 51 ++
l10ntools/source/gConvSrc.cxx | 353 +++++++++++++++++++
l10ntools/source/gConvTree.cxx | 234 ++++++++++++
l10ntools/source/gConvUlf.cxx | 105 +++++
l10ntools/source/gConvXcs.cxx | 161 ++++++++
l10ntools/source/gConvXcu.cxx | 218 +++++++++++
l10ntools/source/gConvXhp.cxx | 438 +++++++++++++++++++++++
l10ntools/source/gConvXrm.cxx | 171 +++++++++
l10ntools/source/gHandler.cxx | 531 ++++++++++++++++++++++++++++
l10ntools/source/gL10nMem.cxx | 739 ++++++++++++++++++++++++++++++++++++++++
l10ntools/source/gL10nMemDB.cxx | 463 +++++++++++++++++++++++++
l10ntools/source/gLang.cxx | 48 ++
l10ntools/source/gLexPo.l | 174 +++++++++
l10ntools/source/gLexSrc.l | 337 ++++++++++++++++++
l10ntools/source/gLexTree.l | 165 ++++++++
l10ntools/source/gLexUlf.l | 144 +++++++
l10ntools/source/gLexXcs.l | 111 ++++++
l10ntools/source/gLexXcu.l | 161 ++++++++
l10ntools/source/gLexXhp.l | 197 ++++++++++
l10ntools/source/gLexXrm.l | 132 +++++++
39 files changed, 6796 insertions(+)
New commits:
commit 999c68f12f1d95b16a97294949a0e6ba6d3ba259
Author: Jan Iversen <jani at documentfoundation.org>
Date: Tue Mar 1 18:07:54 2016 +0100
genLang project (awareness)
the genLang project aims at replacing all l10ntools with more
modern versions, based on C++ and lex.
The current extract works basically as a standalone "find" over the
source tree. genLang can use that, but also a more efficient way, by
having translation-worthy files declared in the makefile stubs.
genLang itself is a C++ framework, where each file type is defined as
a class, making it easy to add new file types.
genLang can easily be adopted to transform the help files into e.g.
mediawiki format, and later merge a url back into the code.
The project was first developed (solely by the author) in a non
published branch of OO. This branch was never merged but deleted
and therefore never published.
The files have been adapted to the LO build system and setup.
The primary commit is just to raise awareness, that this is being
developed. The following commit, will update the source code to LO
standard. Before replacing the old modules a dedicated review will
be asked for.
Change-Id: I4504992474333c476c179903f822bfaf1441cca9
Reviewed-on: https://gerrit.libreoffice.org/22819
Reviewed-by: jan iversen <jani at documentfoundation.org>
Tested-by: jan iversen <jani at documentfoundation.org>
diff --git a/Repository.mk b/Repository.mk
index 61173d3..36416ce 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -33,6 +33,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
genconv_dict \
gendict \
genindex_data \
+ genlang \
helpex \
idxdict \
langsupport \
diff --git a/l10ntools/Executable_genlang.mk b/l10ntools/Executable_genlang.mk
new file mode 100644
index 0000000..b6656c2
--- /dev/null
+++ b/l10ntools/Executable_genlang.mk
@@ -0,0 +1,73 @@
+# -*- 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,genlang))
+
+$(eval $(call gb_Executable_set_include,genlang,\
+ -I$(SRCDIR)/l10ntools/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Executable_add_scanners,genlang,\
+ l10ntools/source/gLexPo \
+ l10ntools/source/gLexSrc \
+ l10ntools/source/gLexXcu \
+ l10ntools/source/gLexXcs \
+ l10ntools/source/gLexXrm \
+ l10ntools/source/gLexXhp \
+ l10ntools/source/gLexUlf \
+ l10ntools/source/gLexTree \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,genlang,\
+ l10ntools/source/gLang \
+ l10ntools/source/gL10nMem \
+ l10ntools/source/gL10nMemDB \
+ l10ntools/source/gHandler \
+ l10ntools/source/gConvProp \
+ l10ntools/source/gConv \
+ l10ntools/source/gConvDB \
+ l10ntools/source/gConvPo \
+ l10ntools/source/gConvSrc \
+ l10ntools/source/gConvXrm \
+ l10ntools/source/gConvXhp \
+ l10ntools/source/gConvXcs \
+ l10ntools/source/gConvXcu \
+ l10ntools/source/gConvUlf \
+ l10ntools/source/gConvTree \
+))
+
+# vim:set noet sw=4 ts=4:
+
+
+
+
+# localizer for new l10n framework
+APP1TARGET= genLang
+APP1OBJS= $(OBJFILES)
+APP1RPATH= NONE
+APP1LINKTYPE= STATIC
+
+APP1LIBS=
+APP1STDLIBS=
+APP1LIBSALCPPRT=
+
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk
+
+$(MISC)$/%_yy.c : %lex.l
+ flex -l -w -8 -o$@ $<
+
+# --- Files --------------------------------------------------------
+
+
+genPO: ALLTAR
+ +$(PERL) $(SOLARENV)/bin/deliver.pl
+
diff --git a/l10ntools/Module_l10ntools.mk b/l10ntools/Module_l10ntools.mk
index d391ed7..0c2e18e 100644
--- a/l10ntools/Module_l10ntools.mk
+++ b/l10ntools/Module_l10ntools.mk
@@ -10,6 +10,7 @@
$(eval $(call gb_Module_Module,l10ntools))
$(eval $(call gb_Module_add_targets_for_build,l10ntools,\
+ Executable_genlang \
Executable_helpex \
Executable_idxdict \
Executable_ulfex \
diff --git a/l10ntools/inc/gConv.hxx b/l10ntools/inc/gConv.hxx
new file mode 100644
index 0000000..5b79e4a
--- /dev/null
+++ b/l10ntools/inc/gConv.hxx
@@ -0,0 +1,92 @@
+/* -*- 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 GCON_HXX
+#define GCON_HXX
+#include "gLang.hxx"
+
+#include <iostream>
+#include <fstream>
+
+
+
+/*****************************************************************************
+ **************************** G C O N . H X X ****************************
+ *****************************************************************************
+ * This is the class definition header for all converter classes,
+ * all classes and their interrelations is defined here
+ *****************************************************************************/
+
+
+
+/******************* G L O B A L D E F I N I T I O N *******************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_gen_impl
+{
+ public:
+ static convert_gen_impl *mcImpl;
+
+
+ convert_gen_impl(l10nMem& crMemory);
+ virtual ~convert_gen_impl();
+
+ // all converters MUST implement this function
+ virtual void execute() = 0;
+
+ // ONLY po should implement these functions
+ virtual void startSave(const std::string& sLanguage,
+ const std::string& sFile);
+ virtual void save(const std::string& sFileName,
+ const std::string& sKey,
+ const std::string& sENUStext,
+ const std::string& sText,
+ bool bFuzzy);
+ virtual void endSave();
+
+ // generic variables
+ bool mbMergeMode;
+ bool mbLoadMode;
+ std::string msSourcePath;
+ std::string msTargetPath;
+ std::string msSourceFile;
+ l10nMem& mcMemory;
+ std::string msCollector;
+ int miLineNo;
+
+
+ // utility functions for converters
+ void lexRead (char *sBuf, int *nResult, int nMax_size);
+ void writeSourceFile(const std::string& line);
+ std::string& copySource (char *yyText, bool bDoClear = true);
+
+ protected:
+ std::string msSourceBuffer, msCopyText;
+ int miSourceReadIndex;
+
+ bool prepareFile();
+
+ private:
+ std::ofstream mcOutputFile;
+
+ friend class convert_gen;
+};
+#endif
diff --git a/l10ntools/inc/gConvDB.hxx b/l10ntools/inc/gConvDB.hxx
new file mode 100644
index 0000000..54dba4e
--- /dev/null
+++ b/l10ntools/inc/gConvDB.hxx
@@ -0,0 +1,49 @@
+/* -*- 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 GCONDN_HXX
+#define GCONDN_HXX
+#include "gConv.hxx"
+
+
+
+/*****************************************************************************
+ ************************** G C O N D B . H X X **************************
+ *****************************************************************************
+ * This is the class header for loading/writing internal "object" files
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_db : public convert_gen_impl
+{
+ public:
+ convert_db(l10nMem& crMemory);
+ ~convert_db();
+
+ private:
+ static const int NUMFIELD = 16;
+ std::string msFields[NUMFIELD];
+ int miSize;
+
+ void execute();
+ bool collectLine();
+};
+#endif
diff --git a/l10ntools/inc/gConvPo.hxx b/l10ntools/inc/gConvPo.hxx
new file mode 100644
index 0000000..7d2d8f2
--- /dev/null
+++ b/l10ntools/inc/gConvPo.hxx
@@ -0,0 +1,71 @@
+/* -*- 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 GCONPO_HXX
+#define GCONPO_HXX
+#include "gConv.hxx"
+
+
+
+/*****************************************************************************
+ ************************** G C O N P O . H X X **************************
+ *****************************************************************************
+ * This is the class header for .po conversion
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_po : public convert_gen_impl
+{
+ public:
+ bool mbExpectId;
+ bool mbExpectStr;
+
+
+ convert_po(l10nMem& crMemory);
+ ~convert_po();
+
+ void startLook ();
+ void setValue (char *syyText, int iLineCnt);
+ void setFuzzy ();
+ void setKey (char *syyText);
+ void setMsgId ();
+ void setMsgStr ();
+ void handleNL ();
+
+ private:
+ std::string msId;
+ std::string msStr;
+ std::string msKey;
+ bool mbFuzzy;
+ std::filebuf outBuffer;
+
+ void execute();
+
+ void startSave(const std::string& sLanguage,
+ const std::string& sFile);
+ void save(const std::string& sFileName,
+ const std::string& sKey,
+ const std::string& sENUStext,
+ const std::string& sText,
+ bool bFuzzy);
+ void endSave();
+};
+#endif
diff --git a/l10ntools/inc/gConvProp.hxx b/l10ntools/inc/gConvProp.hxx
new file mode 100644
index 0000000..ce2ee38
--- /dev/null
+++ b/l10ntools/inc/gConvProp.hxx
@@ -0,0 +1,45 @@
+/* -*- 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 GCONPROP_HXX
+#define GCONPROP_HXX
+#include "gConv.hxx"
+
+
+
+/*****************************************************************************
+ ************************ G C O N P R O P . H X X ************************
+ *****************************************************************************
+ * This is the class header for .proporties conversion
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_prop : public convert_gen_impl
+{
+ public:
+ convert_prop(l10nMem& crMemory);
+ ~convert_prop();
+
+
+ private:
+ void execute();
+};
+#endif
diff --git a/l10ntools/inc/gConvSrc.hxx b/l10ntools/inc/gConvSrc.hxx
new file mode 100644
index 0000000..e8de370
--- /dev/null
+++ b/l10ntools/inc/gConvSrc.hxx
@@ -0,0 +1,75 @@
+/* -*- 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 GCONSRCHXX
+#define GCONSRCHXX
+#include "gConv.hxx"
+
+
+/*****************************************************************************
+ ************************* G C O N S R C . H X X *************************
+ *****************************************************************************
+ * This is the class header for .src conversion
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_src : public convert_gen_impl
+{
+ public:
+ bool mbExpectValue;
+
+ convert_src(l10nMem& crMemory);
+ ~convert_src();
+
+ void setValue (char *syyText, char *sbuildValue);
+ void setLang (char *syyText, bool bEnUs);
+ void setId (char *syyText, bool bIde);
+ void setText (char *syyText);
+ void setName (char *syyText);
+ void setCmd (char *syyText);
+ void setMacro (char *syyText);
+ void setList (char *syyText);
+ void setListItem (char *syyText, bool bIsStart);
+ void setNL (char *syyText, bool bMacro);
+ void startBlock (char *syyText);
+ void stopBlock (char *syyText);
+
+ private:
+ std::vector<std::string> mcStack;
+ std::string msValue;
+ std::string msName;
+ std::string msTextName;
+ std::string msCmd;
+ bool mbEnUs;
+ bool mbExpectName;
+ bool mbExpectMacro;
+ bool mbAutoPush;
+ bool mbValuePresent;
+ bool mbInList;
+ bool mbInListItem;
+ int miListCount;
+ int miMacroLevel;
+ void execute();
+ void trim(std::string& sText);
+ void buildKey(std::string& sKey);
+ void insertLanguagePart(std::string& sKey, std::string& sTextType);
+};
+#endif
diff --git a/l10ntools/inc/gConvTree.hxx b/l10ntools/inc/gConvTree.hxx
new file mode 100644
index 0000000..0ec25ad
--- /dev/null
+++ b/l10ntools/inc/gConvTree.hxx
@@ -0,0 +1,75 @@
+/* -*- 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 GCONTREE_HXX
+#define GCONTREE_HXX
+#include "gConv.hxx"
+
+
+
+/*****************************************************************************
+ ************************ G C O N T R E E . H X X ************************
+ *****************************************************************************
+ * This is the class header for .tree conversion
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_tree : public convert_gen_impl
+{
+ public:
+ typedef enum
+ {
+ STATE_TAG_NONE,
+ STATE_TAG_HELPSEC,
+ STATE_TAG_NODE,
+ STATE_TAG_TOPIC,
+ STATE_TAG_VALUE
+ } STATE_TAG;
+ typedef enum
+ {
+ STATE_VAL_NONE,
+ STATE_VAL_APPL,
+ STATE_VAL_ID,
+ STATE_VAL_TITLE
+ } STATE_VAL;
+
+ convert_tree(l10nMem& crMemory);
+ ~convert_tree();
+
+ void setString (char *yytext);
+ void setState (char *yytext, STATE_TAG eNewStateTag, STATE_VAL eNewStateVAL);
+ void setValue (char *yytext);
+ std::string& copySourceSpecial (char *yytext, int iType);
+ void writeSourceFile (std::string& sText, int inx);
+
+
+ private:
+ std::string msLine;
+ std::string msId;
+ std::string msAppl;
+ std::ofstream *mcOutputFiles;
+ STATE_TAG meStateTag;
+ STATE_VAL meStateVal;
+ int miCntLanguages;
+
+ void execute();
+};
+#endif
diff --git a/l10ntools/inc/gConvUlf.hxx b/l10ntools/inc/gConvUlf.hxx
new file mode 100644
index 0000000..30e79ad
--- /dev/null
+++ b/l10ntools/inc/gConvUlf.hxx
@@ -0,0 +1,52 @@
+/* -*- 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 GCONULF_HXX
+#define GCONULF_HXX
+#include "gConv.hxx"
+
+
+
+/*****************************************************************************
+ ************************* G C O N U L F . H X X *************************
+ *****************************************************************************
+ * This is the class header for .ulf conversion
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_ulf : public convert_gen_impl
+{
+ public:
+ convert_ulf(l10nMem& crMemory);
+ ~convert_ulf();
+
+ void setKey(char *syyText);
+ void setText(char *syyText, bool bIsEnUs);
+ void setValue(char *syyText);
+
+ private:
+ std::string msKey;
+
+
+ void execute();
+ void handleLines();
+};
+#endif
diff --git a/l10ntools/inc/gConvXcs.hxx b/l10ntools/inc/gConvXcs.hxx
new file mode 100644
index 0000000..d1b241e
--- /dev/null
+++ b/l10ntools/inc/gConvXcs.hxx
@@ -0,0 +1,52 @@
+/* -*- 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 GCONXCS_HXX
+#define GCONXCS_HXX
+#include "gConv.hxx"
+
+
+
+/*****************************************************************************
+ ************************* G C O N X C S . H X X *************************
+ *****************************************************************************
+ * This is the class header for .xcs conversion
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_xcs : public convert_gen_impl
+{
+ public:
+ convert_xcs(l10nMem& crMemory);
+ ~convert_xcs();
+
+ void setKey(char *syyText);
+ void unsetKey(char *syyText);
+ void startCollectData(char *syyText);
+ void stopCollectData(char *syyText);
+
+ private:
+ std::string msKey;
+ bool mbCollectingData;
+
+ void execute();
+};
+#endif
diff --git a/l10ntools/inc/gConvXcu.hxx b/l10ntools/inc/gConvXcu.hxx
new file mode 100644
index 0000000..db10627
--- /dev/null
+++ b/l10ntools/inc/gConvXcu.hxx
@@ -0,0 +1,60 @@
+/* -*- 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 GCONXCU_HXX
+#define GCONXCU_HXX
+#include "gConv.hxx"
+
+
+
+/*****************************************************************************
+ ************************* G C O N X C U . H X X *************************
+ *****************************************************************************
+ * This is the class header for .xcu conversion
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class xcu_stack_entry;
+class convert_xcu : public convert_gen_impl
+{
+ public:
+ bool mbNoCollectingData;
+
+ convert_xcu(l10nMem& crMemory);
+ ~convert_xcu();
+
+ void pushKey(char *syyText);
+ void popKey(char *syyText);
+
+ void startCollectData(char *syyText);
+ void stopCollectData(char *syyText);
+ void copySpecial(char *syyText);
+ void copyNL(char *syyText);
+ void addLevel();
+
+ private:
+ std::vector<std::string> mcStack;
+ int miLevel;
+ bool mbNoTranslate;
+
+ void execute();
+};
+#endif
diff --git a/l10ntools/inc/gConvXhp.hxx b/l10ntools/inc/gConvXhp.hxx
new file mode 100644
index 0000000..857966f
--- /dev/null
+++ b/l10ntools/inc/gConvXhp.hxx
@@ -0,0 +1,77 @@
+/* -*- 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 GCONXHP_HXX
+#define GCONXHP_HXX
+#include "gConv.hxx"
+
+
+
+/*****************************************************************************
+ ************************* G C O N X H P . H X X *************************
+ *****************************************************************************
+ * This is the class definition header xhp converter
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_xhp : public convert_gen_impl
+{
+ public:
+ convert_xhp(l10nMem& crMemory);
+ ~convert_xhp();
+
+ void setString(char *yytext);
+ void openTag(char *yytext);
+ void closeTag(char *yytext);
+ void closeTagNOvalue(char *yytext);
+ void setId(char *yytext);
+ void setLang(char *yytext);
+ void setRef(char *yytext);
+ void openTransTag(char *yytext);
+ void closeTransTag(char *yytext);
+ void stopTransTag(char *yytext);
+ void startComment(char *yytext);
+ void stopComment(char *yytext);
+ void handleSpecial(char *yytext);
+ void handleDataEnd(char *yytext);
+ void duplicate(char *yytext);
+ std::string& copySourceSpecial(char *yytext, int iType);
+ void writeSourceFile(std::string& sText, int inx);
+
+ private:
+ typedef enum
+ {
+ VALUE_NOT_USED,
+ VALUE_IS_TAG,
+ VALUE_IS_TAG_TRANS,
+ VALUE_IS_VALUE,
+ VALUE_IS_VALUE_TAG
+ } STATE;
+ STATE meExpectValue, mePushValue;
+ std::string msKey, msPushCollect;
+ std::string msLine;
+
+ std::string *msLangText;
+ std::ofstream *mcOutputFiles;
+ int miCntLanguages;
+ void execute();
+};
+#endif
diff --git a/l10ntools/inc/gConvXrm.hxx b/l10ntools/inc/gConvXrm.hxx
new file mode 100644
index 0000000..e10d999
--- /dev/null
+++ b/l10ntools/inc/gConvXrm.hxx
@@ -0,0 +1,56 @@
+/* -*- 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 GCONXRM_HXX
+#define GCONXRM_HXX
+#include "gConv.hxx"
+
+
+
+/*****************************************************************************
+ ************************* G C O N X R M . H X X *************************
+ *****************************************************************************
+ * This is the class definition header xrm converter
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_xrm : public convert_gen_impl
+{
+ public:
+ bool mbNoCollectingData;
+ convert_xrm(l10nMem& crMemory);
+ ~convert_xrm();
+
+ void setId(char *yytext);
+ void setLang(char *yytext);
+ void setTag(char *yytext);
+ void startCollectData(char *yytext);
+ void stopCollectData(char *yytext);
+
+ private:
+ std::string msKey;
+ bool mbIsTag;
+ bool mbIsLang;
+ std::string msTag;
+
+ void execute();
+};
+#endif
diff --git a/l10ntools/inc/gL10nMem.hxx b/l10ntools/inc/gL10nMem.hxx
new file mode 100644
index 0000000..1da50af
--- /dev/null
+++ b/l10ntools/inc/gL10nMem.hxx
@@ -0,0 +1,217 @@
+/* -*- 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 GL10NMEM_HXX
+#define GL10NMEM_HXX
+#include "gLang.hxx"
+
+
+
+/*****************************************************************************
+ ************************ G L 1 0 N M E M . H X X ************************
+ *****************************************************************************
+ * This is the class definition header of the l10n localizer program,
+ * all global classes and their interrelations is defined here
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class l10nMem_lang_entry
+{
+ public:
+ l10nMem_lang_entry(const std::string& sMsgStr, bool bFuzzy);
+ ~l10nMem_lang_entry();
+
+ std::string msMsgStr; // translated text from po file
+ bool mbFuzzy; // fuzzy flag
+};
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class l10nMem_enus_entry
+{
+ public:
+ l10nMem_enus_entry(const std::string& sKey,
+ const std::string& sMsgId,
+ int iLineNo,
+ int iFileInx,
+ int iLangSize,
+ l10nMem::ENTRY_STATE eState);
+ ~l10nMem_enus_entry();
+
+ std::string msKey; // key in po file and source file
+ std::string msMsgId; // en-US text from source file
+ l10nMem::ENTRY_STATE meState; // status information
+ int miFileInx; // index of file name
+ int miLineNo; // line number
+ std::vector<l10nMem_lang_entry> mcLangText; // language texts (index is languageId)
+};
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class l10nMem_file_entry
+{
+ public:
+ l10nMem_file_entry(const std::string& sFileName, int iStart);
+ ~l10nMem_file_entry();
+
+ std::string msFileName; // file Name with relative path
+ std::string msPureName; // just filename
+ int miStart; // start index of entries in mcMasterEntries (l10Mem_db::mcENUS)
+ int miEnd; // last index of entries in mcMasterEntries (l10Mem_db::mcENUS)
+};
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class l10nMem_lang_list_entry
+{
+ public:
+ l10nMem_lang_list_entry(const std::string& sName);
+ ~l10nMem_lang_list_entry();
+
+ std::string msName; // language Name
+ bool mbChanged; // used for "convert", true if language is modified
+};
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class l10nMem_db
+{
+ public:
+ l10nMem_db();
+ ~l10nMem_db();
+
+ int miCurFileInx;
+ int miCurLangInx;
+ int miCurENUSinx;
+ bool mbNeedWrite;
+ bool mbConvertMode;
+ bool mbStrictMode;
+ std::vector<l10nMem_enus_entry> mcENUSlist;
+ std::vector<l10nMem_file_entry> mcFileList;
+ std::vector<l10nMem_lang_list_entry> mcLangList;
+
+
+ void loadENUSkey (int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId);
+ void setLanguage (const std::string& sLanguage,
+ bool bCreate);
+ void setConvert (bool bConvert,
+ bool bStrict);
+ bool findFileName (const std::string& sSourceFile);
+ void loadLangKey (int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
+ bool bFuzzy);
+
+
+ bool locateKey (int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ bool bThrow);
+ void reorganize (bool bConvert);
+ void addKey (int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ l10nMem::ENTRY_STATE eStat);
+
+ int prepareMerge ();
+ bool getMergeLang (std::string& sLang,
+ std::string& sText);
+ bool getLangList (std::string& sLang);
+
+static void keyToUpper(std::string& sKey);
+};
+
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class l10nMem_impl
+{
+ public:
+ l10nMem_impl();
+ ~l10nMem_impl();
+
+ int showError (const std::string& sText, int iLineNo);
+ int showWarning (const std::string& sText, int iLineNo);
+ void showDebug (const std::string& sText, int iLineNo);
+ void showVerbose (const std::string& sText, int iLineNo);
+
+ void setModuleName (const std::string& sModuleName);
+ const std::string& getModuleName (void);
+ void loadEntryKey (int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
+ bool bIsFuzzy);
+ void setSourceKey (int iLineNo,
+ const std::string& sFilename,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ bool bMustExist);
+
+ void saveTemplates (l10nMem& cMem,
+ const std::string& sTargetDir,
+ bool bKid,
+ bool bForce);
+ void saveLanguages (l10nMem& cMem,
+ const std::string& sTargetDir,
+ bool bForce);
+ void dumpMem (const std::string& sTargetDir);
+ void showNOconvert();
+
+ void convertToInetString(std::string& sText);
+ void convertFromInetString(std::string& sText);
+
+ private:
+ static bool mbVerbose;
+ static bool mbDebug;
+ static l10nMem_impl *mcImpl;
+ l10nMem_db mcDb;
+ std::string msModuleName;
+ bool mbInError;
+
+ void formatAndShowText(const std::string& sType, int iLineNo, const std::string& sText);
+ bool needWrite (const std::string sFileName, bool bForce);
+ bool convFilterWarning(const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId);
+ void convEntryKey (int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
+ bool bIsFuzzy);
+
+ friend class l10nMem;
+};
+#endif
diff --git a/l10ntools/inc/gLang.hxx b/l10ntools/inc/gLang.hxx
new file mode 100644
index 0000000..be1422b
--- /dev/null
+++ b/l10ntools/inc/gLang.hxx
@@ -0,0 +1,164 @@
+/* -*- 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 GLANG_HXX
+#define GLANG_HXX
+#include <string>
+#include <vector>
+
+
+
+/*****************************************************************************
+ *************************** G L A N G . H X X ***************************
+ *****************************************************************************
+ * This is the class definition header of the l10n localizer program,
+ * all global classes and their interrelations is defined here
+ *****************************************************************************/
+
+
+
+/******************* G L O B A L D E F I N I T I O N *******************/
+
+
+
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class l10nMem_impl;
+class l10nMem
+{
+ public:
+ l10nMem();
+ ~l10nMem();
+
+ typedef enum
+ {
+ ENTRY_DELETED,
+ ENTRY_ADDED,
+ ENTRY_CHANGED,
+ ENTRY_NORMAL
+ } ENTRY_STATE;
+
+ static void setShowVerbose ();
+ static void setShowDebug ();
+
+ static int showError (const std::string& sText, int iLineNo = 0);
+ static int showWarning (const std::string& sText, int iLineNo = 0);
+ static void showDebug (const std::string& sText, int iLineNo = 0);
+ static void showVerbose (const std::string& sText, int iLineNo = 0);
+ bool isError ();
+
+ void setModuleName (const std::string& sModuleName);
+ const std::string& getModuleName (void);
+ void setLanguage (const std::string& sLanguage,
+ bool bCreate);
+ void setConvert (bool bConvert,
+ bool bStrict);
+ void loadEntryKey (int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sOrgText,
+ const std::string& sText,
+ bool bIsFuzzy);
+
+ void setSourceKey (int iLineNo,
+ const std::string& sFilename,
+ const std::string& sKey,
+ const std::string& sText,
+ bool bMustExist);
+
+ void saveTemplates (const std::string& sTargetDir,
+ bool bKid,
+ bool bForce);
+ void saveLanguages (const std::string& sTargetDir,
+ bool bForce);
+ void dumpMem (const std::string& sTargetDir);
+
+ int prepareMerge ();
+ bool getMergeLang (std::string& sLang,
+ std::string& sText);
+ void showNOconvert ();
+
+ void convertToInetString(std::string& sText);
+ void convertFromInetString(std::string& sText);
+};
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_gen
+{
+ public:
+ convert_gen(l10nMem& cMemory,
+ const std::string& sSourceDir,
+ const std::string& sTargetDir,
+ const std::string& sSourceFile);
+ ~convert_gen();
+
+ // do extract/merge
+ bool execute(const bool bMerge);
+
+ // ONLY po should implement these functions
+ void startSave(const std::string& sLanguage,
+ const std::string& sFile);
+ void save(const std::string& sFileName,
+ const std::string& sKey,
+ const std::string& sENUStext,
+ const std::string& sText,
+ bool bFuzzy);
+ void endSave();
+ static bool checkAccess(std::string& sFile);
+ static bool createDir(std::string& sDir, std::string& sFile);
+};
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class handler
+{
+ public:
+ handler();
+ ~handler();
+
+ void checkCommandLine(int argc, char *argv[]);
+ void run();
+
+ private:
+ enum {DO_CONVERT, DO_CONVERT_POT, DO_EXTRACT, DO_EXTRACT_KID, DO_MERGE} meWorkMode;
+ l10nMem mcMemory;
+ std::string msModuleName;
+ std::string msPoOutDir;
+ std::string msPoDir;
+ std::string msSourceDir;
+ std::string msTargetDir;
+ bool mbForceSave;
+ std::vector<std::string> mvSourceFiles;
+ std::vector<std::string> mvLanguages;
+
+ void runConvert(bool bPot);
+ void runExtract(bool bKid);
+ void runMerge();
+
+ void showUsage(std::string& sErr);
+ void showManual();
+ void loadL10MEM(bool onlyTemplates);
+ void readFileWithSources();
+};
+#endif
diff --git a/l10ntools/source/gConv.cxx b/l10ntools/source/gConv.cxx
new file mode 100644
index 0000000..562d87a
--- /dev/null
+++ b/l10ntools/source/gConv.cxx
@@ -0,0 +1,363 @@
+/* -*- 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 .
+ */
+
+#include "gConv.hxx"
+#include "gConvDB.hxx"
+#include "gConvPo.hxx"
+#include "gConvProp.hxx"
+#include "gConvSrc.hxx"
+#include "gConvTree.hxx"
+#include "gConvUlf.hxx"
+#include "gConvXcs.hxx"
+#include "gConvXcu.hxx"
+#include "gConvXhp.hxx"
+#include "gConvXrm.hxx"
+#ifdef _WIN32
+#include <io.h>
+#include <direct.h>
+#define OS_ACCESS(x,y) _access(x,y)
+#define OS_MKDIR(x) _mkdir(x)
+#else
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#define OS_ACCESS(x,y) access(x,y)
+#define OS_MKDIR(x) mkdir(x,0777)
+#endif
+
+
+
+/*****************************************************************************
+ **************************** G C O N . C X X ****************************
+ *****************************************************************************
+ * This is the generic conversion module, it handles all generic work of the
+ * conversion, and offer utility functions to the specific conversion classes
+ *****************************************************************************/
+
+
+
+/******************* G L O B A L D E F I N I T I O N *******************/
+convert_gen_impl * convert_gen_impl::mcImpl = NULL;
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+convert_gen::convert_gen(l10nMem& cMemory,
+ const std::string& sSourceDir,
+ const std::string& sTargetDir,
+ const std::string& sSourceFile)
+{
+ // do we have an old object
+ if (convert_gen_impl::mcImpl)
+ delete convert_gen_impl::mcImpl;
+
+ // did the user give a .xxx with the source file ?
+ int nInx = sSourceFile.rfind(".");
+ if (nInx == (int)std::string::npos)
+ throw l10nMem::showError("source file: "+sSourceFile+" missing extension");
+
+ // find correct conversion class and create correct object
+ std::string sExtension = sSourceFile.substr(nInx+1);
+ if (sExtension == "hrc") convert_gen_impl::mcImpl = new convert_src(cMemory);
+ else if (sExtension == "src") convert_gen_impl::mcImpl = new convert_src(cMemory);
+ else if (sExtension == "po") convert_gen_impl::mcImpl = new convert_po(cMemory);
+ else if (sExtension == "pot") convert_gen_impl::mcImpl = new convert_po(cMemory);
+ else if (sExtension == "tree") convert_gen_impl::mcImpl = new convert_tree(cMemory);
+ else if (sExtension == "ulf") convert_gen_impl::mcImpl = new convert_ulf(cMemory);
+ else if (sExtension == "xcu") convert_gen_impl::mcImpl = new convert_xcu(cMemory);
+ else if (sExtension == "xhp") convert_gen_impl::mcImpl = new convert_xhp(cMemory);
+ else if (sExtension == "xrm") convert_gen_impl::mcImpl = new convert_xrm(cMemory);
+ else if (sExtension == "properties") convert_gen_impl::mcImpl = new convert_prop(cMemory);
+ else throw l10nMem::showError("unknown extension on source file: "+sSourceFile);
+
+ // and set environment
+ convert_gen_impl::mcImpl->msSourceFile = sSourceFile;
+ convert_gen_impl::mcImpl->msTargetPath = sTargetDir;
+ convert_gen_impl::mcImpl->msSourcePath = sSourceDir + sSourceFile;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+convert_gen::~convert_gen()
+{
+ delete convert_gen_impl::mcImpl;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+bool convert_gen::execute(const bool bMerge)
+{
+ convert_gen_impl::mcImpl->mbMergeMode = bMerge;
+
+ // and load file
+ if (!convert_gen_impl::mcImpl->prepareFile())
+ return false;
+
+ // and execute conversion
+ convert_gen_impl::mcImpl->execute();
+
+ return true;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_gen::startSave(const std::string& sLanguage,
+ const std::string& sFile)
+{
+ convert_gen_impl::mcImpl->startSave(sLanguage, sFile);
+}
+void convert_gen_impl::startSave(const std::string& sLanguage,
+ const std::string& sFile)
+{
+ std::string x;
+
+ x = sLanguage;
+ x = sFile;
+ throw l10nMem::showError("startSave called with non .po file");
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_gen::save(const std::string& sFileName,
+ const std::string& sKey,
+ const std::string& sENUStext,
+ const std::string& sText,
+ bool bFuzzy)
+{
+ convert_gen_impl::mcImpl->save(sFileName, sKey, sENUStext, sText, bFuzzy);
+}
+void convert_gen_impl::save(const std::string& sFileName,
+ const std::string& sKey,
+ const std::string& sENUStext,
+ const std::string& sText,
+ bool bFuzzy)
+{
+ std::string x;
+
+ if (bFuzzy)
+ x = sFileName + sKey + sENUStext + sText;
+ throw l10nMem::showError("save called with non .po file");
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_gen::endSave()
+{
+ convert_gen_impl::mcImpl->endSave();
+}
+void convert_gen_impl::endSave()
+{
+ throw l10nMem::showError("endSave called with non .po file");
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+bool convert_gen::checkAccess(std::string& sFile)
+{
+ return (OS_ACCESS(sFile.c_str(), 0) == 0);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+bool convert_gen::createDir(std::string& sDir, std::string& sFile)
+{
+ std::string sNewDir(sDir);
+ int newPos, oldPos;
+
+
+ for (oldPos = 0;; oldPos = newPos +1)
+ {
+ newPos = sFile.find_first_of("/\\", oldPos);
+ if (newPos == (int)std::string::npos)
+ break;
+
+ sNewDir += sFile.substr(oldPos, newPos-oldPos) + "/";
+
+ if (!checkAccess(sNewDir))
+ {
+ OS_MKDIR((char *)sNewDir.c_str());
+ }
+
+ }
+
+
+ return true;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+convert_gen_impl::convert_gen_impl(l10nMem& crMemory)
+ : mbMergeMode(false),
+ mbLoadMode(false),
+ mcMemory(crMemory),
+ miLineNo(1)
+{
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+convert_gen_impl::~convert_gen_impl()
+{
+ mcImpl = NULL;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+bool convert_gen_impl::prepareFile()
+{
+ std::ifstream inputFile(msSourcePath.c_str(), std::ios::binary);
+
+
+ if (!inputFile.is_open())
+ {
+ if (mbLoadMode)
+ {
+ l10nMem::showWarning("Cannot open file (" + msSourcePath + ")");
+ return false;
+ }
+ else
+ throw l10nMem::showError("Cannot open file (" + msSourcePath + ") for reading");
+ }
+
+ // get length of file:
+ miSourceReadIndex = 0;
+ inputFile.seekg (0, std::ios::end);
+ msSourceBuffer.resize((unsigned int)inputFile.tellg());
+ inputFile.seekg (0, std::ios::beg);
+
+ // get size, prepare std::string and read whole file
+ inputFile.read((char *)msSourceBuffer.c_str(), msSourceBuffer.size());
+ if ((unsigned int)inputFile.gcount() != msSourceBuffer.size())
+ throw l10nMem::showError("cannot read whole file");
+ inputFile.close();
+
+ if (mbMergeMode && !mbLoadMode)
+ {
+ // close previous file
+ if (mcOutputFile.is_open())
+ mcOutputFile.close();
+
+ // open output file
+ mcOutputFile.open((msTargetPath+msSourceFile).c_str(), std::ios::binary);
+ if (mcOutputFile.is_open())
+ return true;
+
+ if (convert_gen::createDir(msTargetPath, msSourceFile))
+ {
+ mcOutputFile.open((msTargetPath+msSourceFile).c_str(), std::ios::binary);
+ if (mcOutputFile.is_open())
+ return true;
+ }
+ throw l10nMem::showError("Cannot open file (" + msTargetPath+msSourceFile + ") for writing");
+ }
+
+ return true;
+}
+
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_gen_impl::lexRead(char *sBuf, int *nResult, int nMax_size)
+{
+ // did we hit eof
+ if (miSourceReadIndex == -1)
+ {
+ *nResult = 0;
+ return;
+ }
+
+ // assume we can copy all that are left.
+ *nResult = msSourceBuffer.size() - miSourceReadIndex;
+
+ // space enough for the whole line ?
+ if (*nResult <= nMax_size)
+ {
+ msSourceBuffer.copy(sBuf, *nResult, miSourceReadIndex);
+ miSourceReadIndex = -1;
+ }
+ else
+ {
+ msSourceBuffer.copy(sBuf, nMax_size, miSourceReadIndex);
+ *nResult = nMax_size;
+ miSourceReadIndex += nMax_size;
+ }
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_gen_impl::writeSourceFile(const std::string& line)
+{
+ if (!line.size())
+ return;
+
+ if (mcOutputFile.is_open())
+ mcOutputFile.write(line.c_str(), line.size());
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+std::string& convert_gen_impl::copySource(char *yyText, bool bDoClear)
+{
+ int nL;
+
+
+ if (!yyText)
+ {
+ msCopyText.clear();
+ return msCopyText;
+ }
+ msCopyText = yyText;
+
+ // write text for merge
+ if (mbMergeMode)
+ writeSourceFile(msCopyText);
+
+ if (bDoClear)
+ msCollector.clear();
+ else
+ msCollector += msCopyText;
+
+ // remove any CR
+ for (nL = 0; nL < (int)msCopyText.size(); ++nL)
+ {
+ if (msCopyText[nL] == '\r')
+ {
+ msCopyText.erase(nL, 1);
+ --nL;
+ continue;
+ }
+ if (msCopyText[nL] == '\n')
+ ++miLineNo;
+ }
+
+ return msCopyText;
+}
diff --git a/l10ntools/source/gConvDB.cxx b/l10ntools/source/gConvDB.cxx
new file mode 100644
index 0000000..8822414
--- /dev/null
+++ b/l10ntools/source/gConvDB.cxx
@@ -0,0 +1,97 @@
+/* -*- 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 .
+ */
+
+#include "gConvDB.hxx"
+
+
+
+/*****************************************************************************
+ ************************** G C O N D B . C X X **************************
+ *****************************************************************************
+ * This includes the c code generated by flex
+ *****************************************************************************/
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+convert_db::convert_db(l10nMem& crMemory) : convert_gen_impl(crMemory) {}
+convert_db::~convert_db() {}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_db::execute()
+{
+ std::string newKey;
+ int i;
+
+
+ msSourceBuffer += '\n';
+ miSize = msSourceBuffer.size() -1;
+ miLineNo = 0;
+
+ while (collectLine())
+ {
+ newKey = msFields[4];
+ if (msFields[5].size())
+ newKey += "." + msFields[5];
+ if (msFields[3].size())
+ newKey += "." + msFields[3];
+
+ for (; (i = msFields[1].find('\\')) != (int)std::string::npos;)
+ msFields[1][i] = '/';
+
+ // handle en-US or lang
+ mcMemory.loadEntryKey(miLineNo, msFields[1], newKey, msFields[10], msFields[10], false);
+ }
+}
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+bool convert_db::collectLine()
+{
+ int i, iStart;
+ bool bLineEnd;
+
+ ++miLineNo;
+
+ for (i = 0; i < NUMFIELD; ++i)
+ msFields[i].clear();
+
+ if (miSourceReadIndex >= miSize)
+ return false;
+
+ for (i = 0, bLineEnd = false, iStart = miSourceReadIndex; !bLineEnd; ++miSourceReadIndex)
+ {
+ if (msSourceBuffer[miSourceReadIndex] == '\r' ||
+ msSourceBuffer[miSourceReadIndex] == '\n' ||
+ miSourceReadIndex == miSize)
+ bLineEnd = true;
+ if (msSourceBuffer[miSourceReadIndex] == '\t' || bLineEnd)
+ {
+ if (i >= NUMFIELD)
+ {
+ l10nMem::showError((char*)"TOO many fields", miLineNo);
+ }
+ msFields[i++] = msSourceBuffer.substr(iStart, miSourceReadIndex - iStart);
+ iStart = miSourceReadIndex +1;
+ }
+ }
+ return true;
+}
diff --git a/l10ntools/source/gConvPo.cxx b/l10ntools/source/gConvPo.cxx
new file mode 100644
index 0000000..8bbedc7
--- /dev/null
+++ b/l10ntools/source/gConvPo.cxx
@@ -0,0 +1,243 @@
+/* -*- 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 .
+ */
+
+#include "gConvPo.hxx"
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+
+
+
+/*****************************************************************************
+ ********************** G C O N P O W R A P . C X X **********************
+ *****************************************************************************
+ * This includes the c code generated by flex
+ *****************************************************************************/
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+convert_po::convert_po(l10nMem& crMemory)
+ : convert_gen_impl(crMemory),
+ mbExpectId(false),
+ mbExpectStr(false),
+ mbFuzzy(false)
+{
+ // Po files are handled special
+ mbLoadMode = true;
+}
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+convert_po::~convert_po()
+{
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+//namespace PoWrap
+//{
+//#define IMPLptr convert_gen_impl::mcImpl
+//#define LOCptr ((convert_po *)convert_gen_impl::mcImpl)
+//#include "gConPo_yy.c"
+//}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::startLook()
+{
+ std::string sFileName, sNewKey;
+ int i;
+
+
+ if (!msKey.size() || !msId.size())
+ return;
+
+ // split key into filename and real key
+ i = msKey.find("#");
+ sFileName = msKey.substr(0, i);
+ sNewKey = msKey.substr(i+1);
+
+ // load in db
+ if (msId.size())
+ mcMemory.loadEntryKey(miLineNo, sFileName, sNewKey, msId, msStr, mbFuzzy);
+
+ // and prepare for new entry
+ msKey.clear();
+ msId.clear();
+ msStr.clear();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::setValue(char *syyText, int iLineCnt)
+{
+ if (mbExpectId)
+ msId = syyText;
+ if (mbExpectStr)
+ msStr = syyText;
+ mbExpectId =
+ mbExpectStr = false;
+ miLineNo += iLineCnt;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::setFuzzy()
+{
+ mbFuzzy = true;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::setKey(char *syyText)
+{
+ int i;
+
+
+ // Activate "look for msg" mode.
+ startLook();
+
+ // skip "#:" and any blanks
+ for (syyText += 2; *syyText == ' ' || *syyText == '\t'; ++syyText) ;
+ msKey = syyText;
+
+ // remove trailing blanks
+ for (i = msKey.size() -1; msKey[i] == '\r' || msKey[i] == ' ' || msKey[i] == '\t'; --i) ;
+ msKey.erase(i+1);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::setMsgId()
+{
+ mbExpectId = true;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::setMsgStr()
+{
+ mbExpectStr = true;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::handleNL()
+{
+ ++miLineNo;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::execute()
+{
+ if (mbMergeMode)
+ throw l10nMem::showError("Merge not implemented");
+
+// PoWrap::yylex();
+ startLook();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::startSave(const std::string& sLanguage,
+ const std::string& sFile)
+{
+ std::string sFilePath = msTargetPath + sLanguage + sFile;
+ outBuffer.open(sFilePath.c_str(), std::ios::out);
+
+ if (!outBuffer.is_open())
+ throw l10nMem::showError("Cannot open " + sFilePath + " for writing");
+
+ l10nMem::showDebug("writing file (" + sFilePath + ")");
+
+ std::ostream outFile(&outBuffer);
+
+ // Set license header
+ outFile << "#*************************************************************" << std::endl
+ << "#*" << std::endl
+ << "#* Licensed to the Apache Software Foundation (ASF) under one" << std::endl
+ << "#* or more contributor license agreements. See the NOTICE file" << std::endl
+ << "#* distributed with this work for additional information" << std::endl
+ << "#* regarding copyright ownership. The ASF licenses this file" << std::endl
+ << "#* to you under the Apache License, Version 2.0 (the" << std::endl
+ << "#* \"License\"); you may not use this file except in compliance" << std::endl
+ << "#* with the License. You may obtain a copy of the License at" << std::endl
+ << "#*" << std::endl
+ << "#* http://www.apache.org/licenses/LICENSE-2.0" << std::endl
+ << "#*" << std::endl
+ << "#* Unless required by applicable law or agreed to in writing," << std::endl
+ << "#* software distributed under the License is distributed on an" << std::endl
+ << "#* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY" << std::endl
+ << "#* KIND, either express or implied. See the License for the" << std::endl
+ << "#* specific language governing permissions and limitations" << std::endl
+ << "#* under the License." << std::endl
+ << "#*" << std::endl
+ << "#************************************************************" << std::endl
+ << "msgid \"\"" << std::endl
+ << "msgstr \"\"" << std::endl
+ << "\"Project-Id-Version: AOO-4-xx\\n\"" << std::endl
+ << "\"POT-Creation-Date: \\n\"" << std::endl
+ << "\"PO-Revision-Date: \\n\"" << std::endl
+ << "\"Last-Translator: genLang (build process)\\n\"" << std::endl
+ << "\"Language-Team: \\n\"" << std::endl
+ << "\"MIME-Version: 1.0\\n\"" << std::endl
+ << "\"Content-Type: text/plain; charset=UTF-8\\n\"" << std::endl
+ << "\"Content-Transfer-Encoding: 8bit\\n\"" << std::endl
+ << "\"X-Generator: genLang\\n\"" << std::endl
+ << std::endl;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::save(const std::string& sFileName,
+ const std::string& sKey,
+ const std::string& sENUStext,
+ const std::string& sText,
+ bool bFuzzy)
+{
+ std::ostream outFile(&outBuffer);
+
+ outFile << std::endl << "#: " << sFileName << "#" << sKey << std::endl;
+ if (bFuzzy)
+ outFile << "#, fuzzy" << std::endl;
+ outFile << "msgid \"" << sENUStext << "\"" << std::endl
+ << "msgstr \"" << sText << "\"" << std::endl;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_po::endSave()
+{
+ outBuffer.close();
+}
diff --git a/l10ntools/source/gConvProp.cxx b/l10ntools/source/gConvProp.cxx
new file mode 100644
index 0000000..d03455c
--- /dev/null
+++ b/l10ntools/source/gConvProp.cxx
@@ -0,0 +1,51 @@
+/* -*- 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 .
+ */
+
+#include "gConvProp.hxx"
+
+
+
+/*****************************************************************************
+ ************************ G C O N P R O P . C X X ************************
+ *****************************************************************************
+ * This is the conversion for .properties files
+ *****************************************************************************/
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+convert_prop::convert_prop(l10nMem& crMemory) : convert_gen_impl(crMemory)
+{
+ throw mcMemory.showError(std::string("convert_prop not implemented"));
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+convert_prop::~convert_prop()
+{
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_prop::execute()
+{
+ throw mcMemory.showError(std::string("convert_prop::execute not implemented"));
+}
diff --git a/l10ntools/source/gConvSrc.cxx b/l10ntools/source/gConvSrc.cxx
new file mode 100644
index 0000000..b65f2d2
--- /dev/null
+++ b/l10ntools/source/gConvSrc.cxx
@@ -0,0 +1,353 @@
+/* -*- 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 .
+ */
+
+#include "gConvSrc.hxx"
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+#include <sstream>
+#include <string.h>
+
+
+/*****************************************************************************
+ ********************* G C O N S R C W R A P . C X X *********************
+ *****************************************************************************
+ * This includes the c code generated by flex
+ *****************************************************************************/
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+convert_src::convert_src(l10nMem& crMemory)
+ : convert_gen_impl(crMemory),
+ mbExpectValue(false),
+ mbEnUs(false),
+ mbExpectName(false),
+ mbExpectMacro(false),
+ mbAutoPush(false),
+ mbValuePresent(false),
+ mbInList(false),
+ mbInListItem(false)
+{}
+convert_src::~convert_src()
+{}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+//namespace SrcWrap
+//{
+//#define IMPLptr convert_gen_impl::mcImpl
+//#define LOCptr ((convert_src *)convert_gen_impl::mcImpl)
+//#include "gConSrc_yy.c"
+//}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::execute()
+{
+// SrcWrap::yylex();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::setValue(char *syyText, char *sbuildValue)
+{
+ copySource(syyText);
+
+ if (mbInList && !mbInListItem)
+ {
+ setListItem((char *)"", true);
+ setListItem((char *)"", false);
+ }
+ msValue = sbuildValue;
+ mbValuePresent = true;
+ mbExpectValue = false;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::setLang(char *syyText, bool bEnUs)
+{
+ std::string useText = copySource(syyText) + " is no en-US language";
+
+ mbEnUs = bEnUs;
+ if (!bEnUs && mbExpectValue)
+ mcMemory.showError(useText);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::setId(char *syyText, bool bId)
+{
+ copySource(syyText);
+ if (bId || !mcStack.back().size())
+ mbExpectName = mbAutoPush = true;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::setText(char *syyText)
+{
+ msTextName = copySource(syyText);
+ mbExpectValue = true;
+ mbEnUs = false;
+ trim(msTextName);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::setName(char *syyText)
+{
+ std::string useText = copySource(syyText);
+
+ trim(useText);
+ if (mbExpectName)
+ {
+ mbExpectName = false;
+ if (!mbAutoPush)
+ msName = useText;
+ else
+ {
+ mbAutoPush = false;
+ if (mcStack.size())
+ mcStack.pop_back();
+ mcStack.push_back(useText);
+ }
+ }
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::setCmd(char *syyText)
+{
+ msCmd = copySource(syyText);
+ mbExpectName = true;
+ mbInList = false;
+ trim(msCmd);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::setMacro(char *syyText)
+{
+ msCmd = copySource(syyText);
+ mbExpectName =
+ mbExpectMacro =
+ mbAutoPush = true;
+ miMacroLevel = mcStack.size();
+ mcStack.push_back("");
+ trim(msCmd);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::setList(char *syyText)
+{
+ msCmd = copySource(syyText);
+ miListCount = 0;
+ mbInList = true;
+ trim(msCmd);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::setNL(char *syyText, bool bMacro)
+{
+ int nL;
+ std::string sKey;
+
+ copySource(syyText);
+
+ if (msTextName.size() && mbValuePresent && mbEnUs)
+ {
+ // locate key and extract it
+ buildKey(sKey);
+
+ for (nL = -1;;)
+ {
+ nL = msValue.find("\\\"", nL+1);
+ if (nL == (int)std::string::npos)
+ break;
+ msValue.erase(nL,1);
+ }
+ for (nL = -1;;)
+ {
+ nL = msValue.find("\\\\", nL+1);
+ if (nL == (int)std::string::npos)
+ break;
+ msValue.erase(nL,1);
+ }
+
+ sKey += "." + msCmd + "." + msTextName;
+ if (msValue.size() && msValue != "-")
+ {
+ mcMemory.setSourceKey(miLineNo, msSourceFile, sKey, msValue, mbMergeMode);
+ if (mbMergeMode)
+ insertLanguagePart(sKey, msTextName);
+ }
+ }
+
+ if (!bMacro && mbExpectMacro)
+ {
+ while ((int)mcStack.size() > miMacroLevel)
+ mcStack.pop_back();
+ mbEnUs =
+ mbExpectMacro = false;
+ }
+
+ mbValuePresent =
+ mbExpectName =
+ mbAutoPush = false;
+ msValue.clear();
+ msTextName.clear();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::startBlock(char *syyText)
+{
+ copySource(syyText);
+
+ mcStack.push_back(msName);
+ msName.clear();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::stopBlock(char *syyText)
+{
+ copySource(syyText);
+
+ // check for correct node/prop relations
+ if (mcStack.size())
+ mcStack.pop_back();
+
+ mbInList =
+ mbEnUs = false;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::setListItem(char *syyText, bool bIsStart)
+{
+ copySource(syyText);
+
+ if (bIsStart)
+ {
+ if (!miListCount)
+ {
+ mcStack.pop_back();
+ msName = "dummy";
+ mcStack.push_back(msName);
+ }
+ msTextName = "item";
+ mbExpectValue =
+ mbExpectName =
+ mbInListItem = true;
+ msName.clear();
+ }
+ else
+ {
+ if (mbInListItem)
+ {
+ std::stringstream ssBuf;
+ std::string myKey;
+
+
+ ++miListCount;
+ mcStack.pop_back();
+ if (mbExpectName)
+ {
+ ssBuf << miListCount;
+ msName = "item" + ssBuf.str();
+ }
+ mcStack.push_back(msName);
+ mbInListItem =
+ mbExpectName = false;
+
+ // check key or add seq.
+ buildKey(myKey);
+ }
+ }
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::trim(std::string& sText)
+{
+ int nL;
+
+
+ while (sText[0] == ' ' || sText[0] == '\t')
+ sText.erase(0,1);
+ for (nL = sText.size(); sText[nL-1] == ' ' || sText[nL-1] == '\t'; --nL);
+ if (nL != (int)sText.size())
+ sText.erase(nL);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::buildKey(std::string& sKey)
+{
+ int nL;
+
+
+ sKey.clear();
+ for (nL = 0; nL < (int)mcStack.size(); ++nL)
+ if (mcStack[nL].size())
+ sKey += (sKey.size() ? "." : "") + mcStack[nL];
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src::insertLanguagePart(std::string& sKey, std::string& sTextType)
+{
+ std::string sLang, sText, sTagText;
+
+
+ // just to please compiler
+ sKey = sKey;
+
+ // prepare to read all languages
+ mcMemory.prepareMerge();
+ for (; mcMemory.getMergeLang(sLang, sText);)
+ {
+ // Prepare tag start and end
+ sTagText = sTextType + "[ " + sLang + " ] = \"" + sText + "\" ;" +
+ (mbExpectMacro ? "\\" : "") + "\n";
+ writeSourceFile(sTagText);
+ }
+}
diff --git a/l10ntools/source/gConvTree.cxx b/l10ntools/source/gConvTree.cxx
new file mode 100644
index 0000000..06f577d
--- /dev/null
+++ b/l10ntools/source/gConvTree.cxx
@@ -0,0 +1,234 @@
+/* -*- 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 .
+ */
+
+#include "gConvTree.hxx"
+
+
+
+/*****************************************************************************
+ ******************** G C O N T R E E W R A P . C X X ********************
+ *****************************************************************************
+ * This includes the c code generated by flex
+ *****************************************************************************/
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+convert_tree::convert_tree(l10nMem& crMemory)
+ : convert_gen_impl(crMemory),
+ mcOutputFiles(NULL),
+ meStateTag(STATE_TAG_NONE),
+ meStateVal(STATE_VAL_NONE),
+ miCntLanguages(0)
+
+{
+ // tree files are written through a local routine
+ mbLoadMode = true;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+convert_tree::~convert_tree()
+{
+ if (mcOutputFiles)
+ {
+ for (int i = 0; i < miCntLanguages; ++i)
+ mcOutputFiles[i].close();
+ delete[] mcOutputFiles;
+ }
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+//namespace TreeWrap
+//{
+//#define IMPLptr convert_gen_impl::mcImpl
+//#define LOCptr ((convert_tree *)convert_gen_impl::mcImpl)
+//#include "gConTree_yy.c"
+//}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_tree::execute()
+{
+ std::string sLang;
+ std::string sFile, sFile2;
+
+ if (mbMergeMode)
+ throw l10nMem::showError("Merge not implemented");
+
+ // prepare list with languages
+ if (mbMergeMode)
+ {
+ miCntLanguages = mcMemory.prepareMerge();
+ mcOutputFiles = new std::ofstream[miCntLanguages];
+
+ for (int i = 0; mcMemory.getMergeLang(sLang, sFile); ++i)
+ {
+ sFile2 = sLang + "/" + msSourceFile;
+ sFile = msTargetPath + sFile2;
+ mcOutputFiles[i].open(sFile.c_str(), std::ios::binary);
+ if (!mcOutputFiles[i].is_open())
+ {
+ if (!convert_gen::createDir(msTargetPath, sFile2))
+ throw l10nMem::showError("Cannot create missing directories (" + sFile + ") for writing");
+
+ mcOutputFiles[i].open(sFile.c_str(), std::ios::binary);
+ if (!mcOutputFiles[i].is_open())
+ throw l10nMem::showError("Cannot open file (" + sFile + ") for writing");
+ }
+ }
+ }
+
+ // run analyzer
+// TreeWrap::yylex();
+
+ // dump last line
+ copySourceSpecial(NULL,3);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_tree::setString(char *yytext)
+{
+ switch (meStateVal)
+ {
+ case STATE_VAL_NONE:
+ copySourceSpecial(yytext, 0);
+ break;
+
+ case STATE_VAL_APPL:
+ msAppl = copySourceSpecial(yytext, 0);
+ break;
+
+ case STATE_VAL_ID:
+ msId = copySourceSpecial(yytext, 0);
+ msId.erase(msId.size()-1);
+ break;
+
+ case STATE_VAL_TITLE:
+ std::string sText = copySourceSpecial(yytext, 1);
+ sText.erase(sText.size()-1);
+ mcMemory.setSourceKey(miLineNo, msSourceFile, msId, sText, mbMergeMode);
+ break;
+ }
+ meStateVal = STATE_VAL_NONE;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_tree::setState(char *yytext, STATE_TAG eNewStateTag, STATE_VAL eNewStateVAL)
+{
+ copySourceSpecial(yytext, 0);
+ msCollector.clear();
+ meStateTag = eNewStateTag;
+ meStateVal = eNewStateVAL;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_tree::setValue(char *yytext)
+{
+ mcMemory.setSourceKey(miLineNo, msSourceFile, msId, msCollector, mbMergeMode);
+ copySourceSpecial(yytext, 2);
+
+ meStateTag = STATE_TAG_NONE;
+ meStateVal = STATE_VAL_NONE;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+std::string& convert_tree::copySourceSpecial(char *yytext, int iType)
+{
+ std::string& sText = copySource(yytext, false);
+ std::string sLang, sTemp;
+ int i;
+
+ // Handling depends on iType
+ switch (iType)
+ {
+ case 0: // Used for tokens that are to be copied 1-1,
+ if (mbMergeMode)
+ {
+ msLine += yytext;
+ if (*yytext == '\n')
+ {
+ for (i = 0; i < miCntLanguages; ++i)
+ writeSourceFile(msLine, i);
+ msLine.clear();
+ }
+ }
+ break;
+
+ case 1: // Used for title token, are to replaced with languages
+ if (mbMergeMode)
+ {
+ mcMemory.prepareMerge();
+ for (i = 0; i < miCntLanguages; ++i)
+ {
+ writeSourceFile(msLine, i);
+ mcMemory.getMergeLang(sLang, sTemp);
+ writeSourceFile(sTemp,i);
+ }
+ msLine.clear();
+ }
+ break;
+
+ case 2: // Used for token at end of value, language text are to be inserted and then token written
+ if (mbMergeMode)
+ {
+ mcMemory.prepareMerge();
+ for (i = 0; i < miCntLanguages; ++i)
+ {
+ writeSourceFile(msLine, i);
+ mcMemory.getMergeLang(sLang, sTemp);
+ writeSourceFile(sTemp,i);
+ std::string sYY(yytext);
+ writeSourceFile(sYY, i);
+ }
+ msLine.clear();
+ }
+ break;
+
+ case 3: // Used for EOF
+ if (mbMergeMode)
+ {
+ for (i = 0; i < miCntLanguages; ++i)
+ writeSourceFile(msLine, i);
+ }
+ break;
+ }
+ return sText;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_tree::writeSourceFile(std::string& sText, int inx)
+{
+ if (sText.size() && mcOutputFiles[inx].is_open())
+ mcOutputFiles[inx].write(sText.c_str(), sText.size());
+}
diff --git a/l10ntools/source/gConvUlf.cxx b/l10ntools/source/gConvUlf.cxx
new file mode 100644
index 0000000..7f220b1
--- /dev/null
+++ b/l10ntools/source/gConvUlf.cxx
@@ -0,0 +1,105 @@
+/* -*- 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 .
+ */
+
+#include "gConvUlf.hxx"
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+
+
+
+/*****************************************************************************
+ ********************* G C O N X C S W R A P . C X X *********************
+ *****************************************************************************
+ * This includes the c code generated by flex
+ *****************************************************************************/
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+convert_ulf::convert_ulf(l10nMem& crMemory) : convert_gen_impl(crMemory) {}
+convert_ulf::~convert_ulf() {}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+//namespace UlfWrap
+//{
+//#define IMPLptr convert_gen_impl::mcImpl
+//#define LOCptr ((convert_ulf *)convert_gen_impl::mcImpl)
+//#include "gConUlf_yy.c"
+//}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_ulf::execute()
+{
+// UlfWrap::yylex();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_ulf::setKey(char *syyText)
+{
+ std::string sText = copySource(syyText);
+
+ // locate key (is any)
+ msKey = sText.substr(1,sText.size()-2);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_ulf::setText(char *syyText, bool bIsEnUs)
+{
+ std::string sText = copySource(syyText) + " is not en-US";
+
+
+ if (!bIsEnUs)
+ mcMemory.showError(sText);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_ulf::setValue(char *syyText)
+{
+ std::string sLang, sText = copySource(syyText);
+ int nL;
+
+ sText.erase(0,1);
+ nL = sText.rfind("\"");
+ sText.erase(nL);
+
+ mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, sText, mbMergeMode);
+
+ if (mbMergeMode)
+ {
+ // prepare to read all languages
+ mcMemory.prepareMerge();
+ for (; mcMemory.getMergeLang(sLang, sText);)
+ {
+ // Prepare tag
+ sText = "\n" + sLang + " = \"" + sText + "\"";
+ writeSourceFile(sText);
+ }
+ }
+}
diff --git a/l10ntools/source/gConvXcs.cxx b/l10ntools/source/gConvXcs.cxx
new file mode 100644
index 0000000..6133bbb
--- /dev/null
+++ b/l10ntools/source/gConvXcs.cxx
@@ -0,0 +1,161 @@
+/* -*- 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 .
+ */
+
+#include "gConvXcs.hxx"
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+
+
+
+/*****************************************************************************
+ ********************* G C O N X C S W R A P . C X X *********************
+ *****************************************************************************
+ * This includes the c code generated by flex
+ *****************************************************************************/
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+convert_xcs::convert_xcs(l10nMem& crMemory)
+ : convert_gen_impl(crMemory),
+ mbCollectingData(false)
+{
+}
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+convert_xcs::~convert_xcs()
+{
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+//namespace XcsWrap
+//{
+//#define IMPLptr convert_gen_impl::mcImpl
+//#define LOCptr ((convert_xcs *)convert_gen_impl::mcImpl)
+//#include "gConXcs_yy.c"
+//}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcs::execute()
+{
+ if (mbMergeMode)
+ throw l10nMem::showError("Merge not implemented");
+
+ // currently no .xcs files generate en-US translation, so stop trying
+// XcsWrap::yylex();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcs::setKey(char *syyText)
+{
+ int nL;
+ std::string sHead, sText = copySource(syyText);
+
+ // is it to be translated
+ if (sText.find("oor:localized=") == std::string::npos)
+ return;
+
+ // locate key (is any)
+ nL = sText.find("oor:name=\"");
+ if (nL == (int)std::string::npos)
+ return;
+ sHead = sText.substr(nL+10);
+ nL = sHead.find("\"");
+ msKey = sHead.substr(0,nL);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcs::unsetKey(char *syyText)
+{
+ copySource(syyText);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcs::startCollectData(char *syyText)
+{
+ copySource(syyText);
+ if (!msKey.size())
+ return;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcs::stopCollectData(char *syyText)
+{
+ std::string sHead, sKey, sLang, sText, sCollectedText = copySource(syyText, false);
+ int nL;
+
+
+ // get type of tag
+ msCollector += sCollectedText;
+ nL = msCollector.find("<p");
+ if (nL != (int)std::string::npos)
+ sHead = msCollector.substr(nL+1, 1);
+ else
+ {
+ nL = msCollector.find("<h");
+ sHead = msCollector.substr(nL+1, 2);
+ }
+
+ // locate key and extract it
+ nL = msCollector.find("id=") +4;
+ sKey = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL);
+ nL = msCollector.find("xml:lang=\"") + 10;
+ sLang = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL);
+ nL = msCollector.find(">") +1;
+ sText = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL);
+ msCollector.clear();
+
+ if (mbMergeMode)
+ {
+#if 0
+ // get all languages (includes en-US)
+ std::vector<l10nMem_entry *>& cExtraLangauges = mcMemory.getLanguagesForKey(sKey);
+ std::string sNewLine;
+ nL = cExtraLangauges.size();
+
+ for (int i = 0; i < nL; ++i)
+ {
+ sNewLine = "\n<" + sHead + " id=\"" + sKey + "\"" + " xml:lang=\"" +
+ cExtraLangauges[i]->msLanguage + "\">" +
+ cExtraLangauges[i]->msText +
+ "</" + sHead + ">";
+
+ writeSourceFile(sNewLine);
+ }
+#endif
+ }
+
+ mcMemory.setSourceKey(miLineNo, msSourceFile, sKey, sText, mbMergeMode);
+ mbCollectingData = false;
+}
diff --git a/l10ntools/source/gConvXcu.cxx b/l10ntools/source/gConvXcu.cxx
new file mode 100644
index 0000000..972e546
--- /dev/null
+++ b/l10ntools/source/gConvXcu.cxx
@@ -0,0 +1,218 @@
+/* -*- 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 .
+ */
+
+#include "gConvXcu.hxx"
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+
+
+/*****************************************************************************
+ ********************* G C O N X C U W R A P . C X X *********************
+ *****************************************************************************
+ * This includes the c code generated by flex
+ *****************************************************************************/
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+convert_xcu::convert_xcu(l10nMem& crMemory)
+ : convert_gen_impl(crMemory),
+ mbNoCollectingData(true),
+ miLevel(0),
+ mbNoTranslate(false)
+{
+}
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+convert_xcu::~convert_xcu()
+{
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+//namespace XcuWrap
+//{
+//#define IMPLptr convert_gen_impl::mcImpl
+//#define LOCptr ((convert_xcu *)convert_gen_impl::mcImpl)
+//#include "gConXcu_yy.c"
+//}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcu::execute()
+{
+// XcuWrap::yylex();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcu::pushKey(char *syyText)
+{
+ std::string sKey, sTag = copySource(syyText);
+ int nL, nE;
+
+ // find key in tag
+ nL = sTag.find("oor:name=\"");
+ if (nL != (int)std::string::npos)
+ {
+ // find end of key
+ nL += 10;
+ nE = sTag.find("\"", nL);
+ if (nE != (int)std::string::npos)
+ sKey = sTag.substr(nL, nE - nL);
+ }
+ mcStack.push_back(sKey);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcu::popKey(char *syyText)
+{
+ copySource(syyText);
+
+ // check for correct node/prop relations
+ if (mcStack.size())
+ mcStack.pop_back();
+
+ mbNoTranslate = false;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcu::startCollectData(char *syyText)
+{
+ int nL;
+ std::string sTag = copySource(syyText);
+
+ if (mbNoTranslate)
+ return;
+
+ // locate object name
+ nL = sTag.find("xml:lang=\"");
+ if (nL != (int)std::string::npos)
+ {
+ // test langauge
+ nL += 10;
+ if (sTag.substr(nL,5) == "en-US")
+ mbNoCollectingData = false;
+ else if (sTag.substr(nL,14) == "x-no-translate")
+ mbNoTranslate = true;
+ else
+ {
+ std::string sErr = sTag.substr(nL,5) + " is not en-US";
+ mcMemory.showError(sErr);
+ }
+ }
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcu::stopCollectData(char *syyText)
+{
+ int nL;
+ std::string useKey, useText = msCollector;
+
+ copySource(syyText);
+
+ // time to do something ?
+ if (mbNoCollectingData || mbNoTranslate)
+ return;
+
+ // remove any newline
+ for (nL = 0;;)
+ {
+ nL = useText.find("\n");
+ if (nL == (int)std::string::npos)
+ break;
+ useText.erase(nL,1);
+ }
+
+ mbNoCollectingData = true;
+
+ if (useText.size())
+ {
+ // locate key and extract it
+ for (nL = 0; nL < (int)mcStack.size(); ++nL)
+ useKey += (useKey.size() ? "." : "" ) + mcStack[nL];
+ mcMemory.setSourceKey(miLineNo, msSourceFile, useKey, useText, mbMergeMode);
+ }
+
+ if (mbMergeMode)
+ {
+ std::string sLang, sText, sNewLine;
+
+
+ // prepare to read all languages
+ mcMemory.prepareMerge();
+ for (; mcMemory.getMergeLang(sLang, sText);)
+ {
+ sNewLine = "\n<value xml:lang=\"" + sLang + "\">" + sText + "</value>";
+ mcMemory.convertToInetString(sNewLine);
+ writeSourceFile(sNewLine);
+ }
+ }
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_xcu::copySpecial(char *syyText)
+{
+ int nx = msCollector.size();
+ std::string sText = copySource(syyText, mbNoCollectingData);
+
+ if (!mbNoCollectingData)
+ {
+ msCollector.erase(nx);
+ mcMemory.convertFromInetString(sText);
+ msCollector += sText;
+ }
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list