[Libreoffice-commits] core.git: l10ntools/inc l10ntools/source
jan iversen
jani at documentfoundation.org
Tue Mar 15 01:07:25 UTC 2016
l10ntools/inc/gConv.hxx | 90 +++----
l10ntools/inc/gConvDB.hxx | 28 --
l10ntools/inc/gConvPo.hxx | 75 ++----
l10ntools/inc/gConvProp.hxx | 21 -
l10ntools/inc/gConvSrc.hxx | 79 ++----
l10ntools/inc/gConvTree.hxx | 81 ++----
l10ntools/inc/gConvUlf.hxx | 31 --
l10ntools/inc/gConvXcs.hxx | 32 --
l10ntools/inc/gConvXcu.hxx | 42 +--
l10ntools/inc/gConvXhp.hxx | 82 ++----
l10ntools/inc/gConvXrm.hxx | 46 +--
l10ntools/inc/gL10nMem.hxx | 202 +++++++---------
l10ntools/source/gConv.cxx | 322 ++++++++++++--------------
l10ntools/source/gConvDB.cxx | 89 +++----
l10ntools/source/gConvPo.cxx | 216 +++++++----------
l10ntools/source/gConvProp.cxx | 6
l10ntools/source/gConvSrc.cxx | 340 ++++++++++++---------------
l10ntools/source/gConvTree.cxx | 264 +++++++++------------
l10ntools/source/gConvUlf.cxx | 64 +----
l10ntools/source/gConvXcs.cxx | 143 +++++------
l10ntools/source/gConvXcu.cxx | 209 +++++++---------
l10ntools/source/gConvXhp.cxx | 506 ++++++++++++++++++-----------------------
l10ntools/source/gConvXrm.cxx | 145 +++++------
l10ntools/source/gL10nMem.cxx | 254 +++++++++-----------
l10ntools/source/gLang.cxx | 12
l10ntools/source/gLexPo.l | 94 +++----
l10ntools/source/gLexSrc.l | 156 ++++++------
l10ntools/source/gLexTree.l | 56 ++--
l10ntools/source/gLexUlf.l | 57 ++--
l10ntools/source/gLexXcs.l | 33 +-
l10ntools/source/gLexXcu.l | 46 +--
l10ntools/source/gLexXhp.l | 54 ++--
l10ntools/source/gLexXrm.l | 34 +-
33 files changed, 1747 insertions(+), 2162 deletions(-)
New commits:
commit 885eb42469f9191f7df270dfd1c8bda5dcec0e2f
Author: jan iversen <jani at documentfoundation.org>
Date: Tue Mar 15 01:54:42 2016 +0100
genLang update
Decoration removed
Indent etc. updated to LO standard
License in generate pot files changed to LO standard.
this commit is a pure text edit, NO functional changes.
Change-Id: Ie0a26d3cff470dd5f91241ca6b962b17851c9d5b
diff --git a/l10ntools/inc/gConv.hxx b/l10ntools/inc/gConv.hxx
index b9507ac..710d0ff 100644
--- a/l10ntools/inc/gConv.hxx
+++ b/l10ntools/inc/gConv.hxx
@@ -16,7 +16,6 @@
* 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 <iostream>
@@ -24,58 +23,59 @@
class convert_gen
{
-public:
- static convert_gen *mcImpl;
+ public:
+ static convert_gen *mcImpl;
+
+ convert_gen(l10nMem& cMemory);
+ virtual ~convert_gen();
- convert_gen(l10nMem& cMemory);
- virtual ~convert_gen();
+ // Create instance
+ static convert_gen& createInstance(l10nMem& cMemory,
+ const std::string& sSourceDir,
+ const std::string& sTargetDir,
+ const std::string& sSourceFile);
- // Create instance
- static convert_gen& createInstance(l10nMem& cMemory,
- const std::string& sSourceDir,
- const std::string& sTargetDir,
- const std::string& sSourceFile);
+ // do extract/merge
+ bool execute(const bool bMerge, const bool bKid);
- // do extract/merge
- bool execute(const bool bMerge, const bool bKid);
+ // all converters MUST implement this function
+ virtual void execute() = 0;
- // 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();
+ static bool checkAccess(std::string& sFile);
+ static bool createDir(std::string& sDir, std::string& sFile);
- // 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();
- static bool checkAccess(std::string& sFile);
- static bool createDir(std::string& sDir, std::string& sFile);
+ // utility functions for converters
+ void lexRead(char *sBuf, int *nResult, int nMax_size);
+ std::string& copySource(char const *yyText, bool bDoClear = true);
- // utility functions for converters
- void lexRead(char *sBuf, int *nResult, int nMax_size);
- std::string& copySource(char const *yyText, bool bDoClear = true);
+ protected:
+ // generic variables
+ bool mbMergeMode;
+ bool mbLoadMode;
+ std::string msSourcePath;
+ std::string msTargetPath;
+ std::string msSourceFile;
+ l10nMem& mcMemory;
+ std::string msCollector;
+ int miLineNo;
+ std::string msSourceBuffer, msCopyText;
+ int miSourceReadIndex;
-protected:
- // generic variables
- bool mbMergeMode;
- bool mbLoadMode;
- std::string msSourcePath;
- std::string msTargetPath;
- std::string msSourceFile;
- l10nMem& mcMemory;
- std::string msCollector;
- int miLineNo;
- std::string msSourceBuffer, msCopyText;
- int miSourceReadIndex;
+ bool prepareFile();
- bool prepareFile();
+ // utility functions for converters
+ void writeSourceFile(const std::string& line);
- // utility functions for converters
- void writeSourceFile(const std::string& line);
-private:
- std::ofstream mcOutputFile;
+ private:
+ std::ofstream mcOutputFile;
};
#endif
diff --git a/l10ntools/inc/gConvDB.hxx b/l10ntools/inc/gConvDB.hxx
index 51c8377..2315183 100644
--- a/l10ntools/inc/gConvDB.hxx
+++ b/l10ntools/inc/gConvDB.hxx
@@ -16,34 +16,24 @@
* 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
{
- public:
- convert_db(l10nMem& crMemory);
- virtual ~convert_db();
+ public:
+ convert_db(l10nMem& crMemory);
+ ~convert_db();
- private:
- static const int NUMFIELD = 16;
- std::string msFields[NUMFIELD];
- int miSize;
+ private:
+ static const int NUMFIELD = 16;
+ std::string msFields[NUMFIELD];
+ int miSize;
- void execute() override;
- bool collectLine();
+ void execute() override;
+ bool collectLine();
};
#endif
diff --git a/l10ntools/inc/gConvPo.hxx b/l10ntools/inc/gConvPo.hxx
index 33fc4ef..ab120d9 100644
--- a/l10ntools/inc/gConvPo.hxx
+++ b/l10ntools/inc/gConvPo.hxx
@@ -23,49 +23,40 @@
-/*****************************************************************************
- ************************** 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
{
- public:
- bool mbExpectId;
- bool mbExpectStr;
-
-
- convert_po(l10nMem& crMemory);
- virtual ~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() override;
-
- void startSave(const std::string& sLanguage,
- const std::string& sFile) override;
- void save(const std::string& sFileName,
- const std::string& sKey,
- const std::string& sENUStext,
- const std::string& sText,
- bool bFuzzy) override;
- void endSave() override;
+ 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() override;
+
+ void startSave(const std::string& sLanguage,
+ const std::string& sFile) override;
+ void save(const std::string& sFileName,
+ const std::string& sKey,
+ const std::string& sENUStext,
+ const std::string& sText,
+ bool bFuzzy) override;
+ void endSave() override;
};
#endif
diff --git a/l10ntools/inc/gConvProp.hxx b/l10ntools/inc/gConvProp.hxx
index b2b9bd1..9e7f6e7 100644
--- a/l10ntools/inc/gConvProp.hxx
+++ b/l10ntools/inc/gConvProp.hxx
@@ -16,30 +16,19 @@
* 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
{
- public:
- convert_prop(l10nMem& crMemory);
- virtual ~convert_prop();
-
+ public:
+ convert_prop(l10nMem& crMemory);
+ ~convert_prop();
- private:
- void execute() override;
+ private:
+ void execute() override;
};
#endif
diff --git a/l10ntools/inc/gConvSrc.hxx b/l10ntools/inc/gConvSrc.hxx
index 669430f..8df5d6c 100644
--- a/l10ntools/inc/gConvSrc.hxx
+++ b/l10ntools/inc/gConvSrc.hxx
@@ -16,60 +16,51 @@
* 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
{
- public:
- bool mbExpectValue;
+ public:
+ bool mbExpectValue;
- convert_src(l10nMem& crMemory);
- virtual ~convert_src();
+ 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 const *syyText, bool bIsStart);
- void setNL (char *syyText, bool bMacro);
- void startBlock (char *syyText);
- void stopBlock (char *syyText);
+ 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 const *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() override;
- void trim(std::string& sText);
- void buildKey(std::string& sKey);
- void insertLanguagePart(std::string& sKey, std::string& sTextType);
+ 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() override;
+ 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
index a0ecb20..0807069 100644
--- a/l10ntools/inc/gConvTree.hxx
+++ b/l10ntools/inc/gConvTree.hxx
@@ -16,60 +16,47 @@
* 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
{
- 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);
- virtual ~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() override;
+ 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() override;
};
#endif
diff --git a/l10ntools/inc/gConvUlf.hxx b/l10ntools/inc/gConvUlf.hxx
index dc7c75f..234c60e 100644
--- a/l10ntools/inc/gConvUlf.hxx
+++ b/l10ntools/inc/gConvUlf.hxx
@@ -16,37 +16,26 @@
* 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
{
- public:
- convert_ulf(l10nMem& crMemory);
- virtual ~convert_ulf();
-
- void setKey(char *syyText);
- void setText(char *syyText, bool bIsEnUs);
- void setValue(char *syyText);
+ public:
+ convert_ulf(l10nMem& crMemory);
+ ~convert_ulf();
- private:
- std::string msKey;
+ void setKey(char *syyText);
+ void setText(char *syyText, bool bIsEnUs);
+ void setValue(char *syyText);
+ private:
+ std::string msKey;
- void execute() override;
- void handleLines();
+ void execute() override;
+ void handleLines();
};
#endif
diff --git a/l10ntools/inc/gConvXcs.hxx b/l10ntools/inc/gConvXcs.hxx
index 40cb2ca..3444907 100644
--- a/l10ntools/inc/gConvXcs.hxx
+++ b/l10ntools/inc/gConvXcs.hxx
@@ -16,37 +16,27 @@
* 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
{
- public:
- convert_xcs(l10nMem& crMemory);
- virtual ~convert_xcs();
+ public:
+ convert_xcs(l10nMem& crMemory);
+ ~convert_xcs();
- void setKey(char *syyText);
- void unsetKey(char *syyText);
- void startCollectData(char *syyText);
- void stopCollectData(char *syyText);
+ void setKey(char *syyText);
+ void unsetKey(char *syyText);
+ void startCollectData(char *syyText);
+ void stopCollectData(char *syyText);
- private:
- std::string msKey;
- bool mbCollectingData;
+ private:
+ std::string msKey;
+ bool mbCollectingData;
- void execute() override;
+ void execute() override;
};
#endif
diff --git a/l10ntools/inc/gConvXcu.hxx b/l10ntools/inc/gConvXcu.hxx
index c19f9901..3e49f52 100644
--- a/l10ntools/inc/gConvXcu.hxx
+++ b/l10ntools/inc/gConvXcu.hxx
@@ -16,45 +16,35 @@
* 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
{
- public:
- bool mbNoCollectingData;
+ public:
+ bool mbNoCollectingData;
- convert_xcu(l10nMem& crMemory);
- virtual ~convert_xcu();
+ convert_xcu(l10nMem& crMemory);
+ ~convert_xcu();
- void pushKey(char *syyText);
- void popKey(char *syyText);
+ 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();
+ 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;
+ private:
+ std::vector<std::string> mcStack;
+ int miLevel;
+ bool mbNoTranslate;
- void execute() override;
+ void execute() override;
};
#endif
diff --git a/l10ntools/inc/gConvXhp.hxx b/l10ntools/inc/gConvXhp.hxx
index d59a00b..c33e3b7 100644
--- a/l10ntools/inc/gConvXhp.hxx
+++ b/l10ntools/inc/gConvXhp.hxx
@@ -16,62 +16,50 @@
* 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
{
- public:
- convert_xhp(l10nMem& crMemory);
- virtual ~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);
+ public:
+ convert_xhp(l10nMem& crMemory);
+ ~convert_xhp();
- 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;
+ 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);
- std::string *msLangText;
- std::ofstream *mcOutputFiles;
- int miCntLanguages;
- void execute() override;
+ 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() override;
};
#endif
diff --git a/l10ntools/inc/gConvXrm.hxx b/l10ntools/inc/gConvXrm.hxx
index 4928bac..cb6e4a7 100644
--- a/l10ntools/inc/gConvXrm.hxx
+++ b/l10ntools/inc/gConvXrm.hxx
@@ -16,41 +16,31 @@
* 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
{
- public:
- bool mbNoCollectingData;
- convert_xrm(l10nMem& crMemory);
- virtual ~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() override;
+ 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() override;
};
#endif
diff --git a/l10ntools/inc/gL10nMem.hxx b/l10ntools/inc/gL10nMem.hxx
index 94e76c9..3cfd9f0 100644
--- a/l10ntools/inc/gL10nMem.hxx
+++ b/l10ntools/inc/gL10nMem.hxx
@@ -24,116 +24,110 @@ class l10nMem_file_entry;
class l10nMem_lang_list_entry;
class l10nMem
{
-public:
- l10nMem();
- ~l10nMem();
+ public:
+ l10nMem();
+ ~l10nMem();
- typedef enum
- {
- ENTRY_DELETED,
- ENTRY_ADDED,
- ENTRY_CHANGED,
- ENTRY_NORMAL
- } ENTRY_STATE;
+ typedef enum {
+ ENTRY_DELETED,
+ ENTRY_ADDED,
+ ENTRY_CHANGED,
+ ENTRY_NORMAL
+ } ENTRY_STATE;
- static int showError(const std::string& sText, int iLineNo = 0);
- static void 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);
- static void keyToUpper(std::string& sKey);
+ static int showError(const std::string& sText, int iLineNo = 0);
+ static void 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);
+ static void keyToUpper(std::string& sKey);
- 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 setVerbose(const bool doVerbose);
- void setDebug(const bool doDebug);
+ 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 setVerbose(const bool doVerbose);
+ void setDebug(const bool doDebug);
+ 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 loadEntryKey(int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sOrgText,
- const std::string& sText,
- bool bIsFuzzy);
+ void saveTemplates(const std::string& sTargetDir,
+ bool bKid,
+ bool bForce);
+ void saveLanguages(l10nMem& cMem,
+ const std::string& sTargetDir,
+ bool bForce);
+ void dumpMem(const std::string& sTargetDir);
+ int prepareMerge();
+ bool getMergeLang(std::string& sLang,
+ std::string& sText);
+ void showNOconvert();
+ bool isError();
+ void convertToInetString(std::string& sText);
+ void convertFromInetString(std::string& sText);
- void setSourceKey(int iLineNo,
- const std::string& sFilename,
- const std::string& sKey,
- const std::string& sText,
- bool bMustExist);
+ private:
+ bool mbVerbose;
+ bool mbDebug;
+ bool mbInError;
+ std::string msModuleName;
+ 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 saveTemplates(const std::string& sTargetDir,
- bool bKid,
- bool bForce);
- void saveLanguages(l10nMem& cMem,
- const std::string& sTargetDir,
- bool bForce);
- void dumpMem(const std::string& sTargetDir);
-
- int prepareMerge();
- bool getMergeLang(std::string& sLang,
- std::string& sText);
- void showNOconvert();
- bool isError();
-
- void convertToInetString(std::string& sText);
- void convertFromInetString(std::string& sText);
-
-private:
- bool mbVerbose;
- bool mbDebug;
- bool mbInError;
- std::string msModuleName;
- 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 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);
- void saveTemplates(l10nMem& cMem,
- const std::string& sTargetDir,
- bool bKid,
- bool bForce);
-
- void loadENUSkey(int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId);
- void loadLangKey(int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId,
- const std::string& sMsgStr,
- bool bFuzzy);
- void reorganize(bool bConvert);
- bool locateKey(int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId,
- bool bThrow);
- void addKey(int iLineNo,
- const std::string& sSourceFile,
- const std::string& sKey,
- const std::string& sMsgId,
- l10nMem::ENTRY_STATE eStat);
- bool findFileName(const std::string& sSourceFile);
+ 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);
+ void saveTemplates(l10nMem& cMem,
+ const std::string& sTargetDir,
+ bool bKid,
+ bool bForce);
+ void loadENUSkey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId);
+ void loadLangKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ const std::string& sMsgStr,
+ bool bFuzzy);
+ void reorganize(bool bConvert);
+ bool locateKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ bool bThrow);
+ void addKey(int iLineNo,
+ const std::string& sSourceFile,
+ const std::string& sKey,
+ const std::string& sMsgId,
+ l10nMem::ENTRY_STATE eStat);
+ bool findFileName(const std::string& sSourceFile);
};
#endif
diff --git a/l10ntools/source/gConv.cxx b/l10ntools/source/gConv.cxx
index d9bb973..74f05ba 100644
--- a/l10ntools/source/gConv.cxx
+++ b/l10ntools/source/gConv.cxx
@@ -45,12 +45,13 @@
#endif
+
convert_gen * convert_gen::mcImpl = NULL;
-/********************** I M P L E M E N T A T I O N **********************/
-convert_gen::convert_gen(l10nMem& cMemory)
- : mcMemory(cMemory)
+
+convert_gen::convert_gen(l10nMem& cMemory)
+ : mcMemory(cMemory)
{
mcImpl = this;
}
@@ -60,68 +61,66 @@ convert_gen::~convert_gen()
convert_gen& convert_gen::createInstance(l10nMem& cMemory,
- const std::string& sSourceDir,
- const std::string& sTargetDir,
- const std::string& sSourceFile)
+ const std::string& sSourceDir,
+ const std::string& sTargetDir,
+ const std::string& sSourceFile)
{
- // 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);
- convert_gen *x;
- if (sExtension == "hrc") x = new convert_src(cMemory);
- else if (sExtension == "src") x = new convert_src(cMemory);
- else if (sExtension == "po") x = new convert_po(cMemory);
- else if (sExtension == "pot") x = new convert_po(cMemory);
- else if (sExtension == "tree") x = new convert_tree(cMemory);
- else if (sExtension == "ulf") x = new convert_ulf(cMemory);
- else if (sExtension == "xcu") x = new convert_xcu(cMemory);
- else if (sExtension == "xhp") x = new convert_xhp(cMemory);
- else if (sExtension == "xrm") x = new convert_xrm(cMemory);
- else if (sExtension == "properties") x = new convert_prop(cMemory);
- else throw l10nMem::showError("unknown extension on source file: "+sSourceFile);
-
- // and set environment
- x->msSourceFile = sSourceFile;
- x->msTargetPath = sTargetDir;
- x->msSourcePath = sSourceDir + sSourceFile;
- return *x;
+ // 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);
+ convert_gen *x;
+ if (sExtension == "hrc") x = new convert_src(cMemory);
+ else if (sExtension == "src") x = new convert_src(cMemory);
+ else if (sExtension == "po") x = new convert_po(cMemory);
+ else if (sExtension == "pot") x = new convert_po(cMemory);
+ else if (sExtension == "tree") x = new convert_tree(cMemory);
+ else if (sExtension == "ulf") x = new convert_ulf(cMemory);
+ else if (sExtension == "xcu") x = new convert_xcu(cMemory);
+ else if (sExtension == "xhp") x = new convert_xhp(cMemory);
+ else if (sExtension == "xrm") x = new convert_xrm(cMemory);
+ else if (sExtension == "properties") x = new convert_prop(cMemory);
+ else throw l10nMem::showError("unknown extension on source file: "+sSourceFile);
+
+ // and set environment
+ x->msSourceFile = sSourceFile;
+ x->msTargetPath = sTargetDir;
+ x->msSourcePath = sSourceDir + sSourceFile;
+ return *x;
}
-/********************** I M P L E M E N T A T I O N **********************/
bool convert_gen::execute(const bool bMerge, const bool bKid)
{
- mbMergeMode = bMerge;
+ mbMergeMode = bMerge;
- if (bKid)
- throw l10nMem::showError("not implemented");
+ if (bKid)
+ throw l10nMem::showError("not implemented");
- // and load file
- if (!prepareFile())
- return false;
+ // and load file
+ if (!prepareFile())
+ return false;
- // and execute conversion
- execute();
+ // and execute conversion
+ execute();
- return true;
+ 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)
{
- std::string x;
+ std::string x;
- x = sLanguage;
- x = sFile;
- throw l10nMem::showError("startSave called with non .po file");
+ x = sLanguage;
+ x = sFile;
+ throw l10nMem::showError("startSave called with non .po file");
}
@@ -132,189 +131,166 @@ void convert_gen::save(const std::string& sFileName,
const std::string& sText,
bool bFuzzy)
{
- std::string x;
+ std::string x;
- if (bFuzzy)
- x = sFileName + sKey + sENUStext + sText;
- throw l10nMem::showError("save called with non .po file");
+ if (bFuzzy)
+ x = sFileName + sKey + sENUStext + sText;
+ throw l10nMem::showError("save called with non .po file");
}
void convert_gen::endSave()
{
- throw l10nMem::showError("endSave called with non .po file");
+ 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);
+ 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;
-
+ 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;
+ 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) + "/";
+ sNewDir += sFile.substr(oldPos, newPos-oldPos) + "/";
- if (!checkAccess(sNewDir))
- {
- OS_MKDIR(sNewDir.c_str());
+ if (!checkAccess(sNewDir)) {
+ OS_MKDIR(sNewDir.c_str());
+ }
}
-
- }
-
-
- return true;
+ return true;
}
-/********************** I M P L E M E N T A T I O N **********************/
bool convert_gen::prepareFile()
{
- std::ifstream inputFile(msSourcePath.c_str(), std::ios::binary);
+ std::ifstream inputFile(msSourcePath.c_str(), std::ios::binary);
- if (!inputFile.is_open())
- {
- if (mbLoadMode)
- {
- l10nMem::showWarning("Cannot open file (" + msSourcePath + ")");
- return false;
+ if (!inputFile.is_open()) {
+ if (mbLoadMode) {
+ l10nMem::showWarning("Cannot open file (" + msSourcePath + ")");
+ return false;
+ }
+ else
+ throw l10nMem::showError("Cannot open file (" + msSourcePath + ") for reading");
}
- 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(const_cast<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;
+ // 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(const_cast<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");
}
- throw l10nMem::showError("Cannot open file (" + msTargetPath+msSourceFile + ") for writing");
- }
-
- return true;
+ return true;
}
-/********************** I M P L E M E N T A T I O N **********************/
void convert_gen::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);
- l10nMem::showDebug(sBuf);
- miSourceReadIndex = -1;
- }
- else
- {
-// msSourceBuffer.copy(sBuf, nMax_size, miSourceReadIndex);
- *nResult = nMax_size;
- miSourceReadIndex += 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);
+ l10nMem::showDebug(sBuf);
+ 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::writeSourceFile(const std::string& line)
{
- if (!line.size())
- return;
+ if (!line.size())
+ return;
- if (mcOutputFile.is_open())
- mcOutputFile.write(line.c_str(), line.size());
+ 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::copySource(char const *yyText, bool bDoClear)
{
- int nL;
+ 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 (!yyText) {
+ msCopyText.clear();
+ return msCopyText;
}
- if (msCopyText[nL] == '\n')
- ++miLineNo;
- }
+ msCopyText = yyText;
- return msCopyText;
+ // 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
index c0931eb..80940ad 100644
--- a/l10ntools/source/gConvDB.cxx
+++ b/l10ntools/source/gConvDB.cxx
@@ -29,63 +29,58 @@ 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;
+ std::string newKey;
+ int i;
- msSourceBuffer += '\n';
- miSize = msSourceBuffer.size() -1;
- miLineNo = 0;
+ 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];
+ 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] = '/';
+ 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);
- }
+ // 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("TOO many fields", miLineNo);
- }
- msFields[i++] = msSourceBuffer.substr(iStart, miSourceReadIndex - iStart);
- iStart = miSourceReadIndex +1;
- }
- }
- return true;
+ 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("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
index e540d70..e43d1bf 100644
--- a/l10ntools/source/gConvPo.cxx
+++ b/l10ntools/source/gConvPo.cxx
@@ -27,220 +27,192 @@
-/*****************************************************************************
- ********************** 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(crMemory),
mbExpectId(false),
mbExpectStr(false),
mbFuzzy(false)
{
- // Po files are handled special
- mbLoadMode = true;
+ // 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;
+ std::string sFileName, sNewKey;
+ int i;
- if (!msKey.size() || !msId.size())
- return;
+ 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);
+ // 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);
+ // 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();
+ // 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;
+ 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;
+ mbFuzzy = true;
}
-/********************** I M P L E M E N T A T I O N **********************/
void convert_po::setKey(char *syyText)
{
- int i;
+ int i;
- // Activate "look for msg" mode.
- startLook();
+ // Activate "look for msg" mode.
+ startLook();
- // skip "#:" and any blanks
- for (syyText += 2; *syyText == ' ' || *syyText == '\t'; ++syyText) ;
- msKey = syyText;
+ // 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);
+ // 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;
+ mbExpectId = true;
}
-/********************** I M P L E M E N T A T I O N **********************/
void convert_po::setMsgStr()
{
- mbExpectStr = true;
+ mbExpectStr = true;
}
-/********************** I M P L E M E N T A T I O N **********************/
void convert_po::handleNL()
{
- ++miLineNo;
+ ++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");
+ if (mbMergeMode)
+ throw l10nMem::showError("Merge not implemented");
-// PoWrap::yylex();
- startLook();
+ // 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;
+ 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
+ << "#* This file is part of the LibreOffice project. " << std::endl
+ << "#*" << std::endl
+ << "#* This Source Code Form is subject to the terms of the " << std::endl
+ << "#* Mozilla Public License, v. 2.0. If a copy of the MPL was " << std::endl
+ << "#* not distributed with this file, You can obtain one at " << std::endl
+ << "#* http://mozilla.org/MPL/2.0/." << std::endl
+ << "#*" << std::endl
+ << "#* This file incorporates work covered by the following " << std::endl
+ << "#* license notice :" << 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 " << std::endl
+ << "#* (the \"License\"); you may not use this file except in " << std::endl
+ << "#* compliance with the License.You may obtain a copy of the " << std::endl
+ << "#* License at http ://www.apache.org/licenses/LICENSE-2.0 . " << 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);
+ 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;
+ 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();
+ outBuffer.close();
}
diff --git a/l10ntools/source/gConvProp.cxx b/l10ntools/source/gConvProp.cxx
index e751737..c1f6bfa 100644
--- a/l10ntools/source/gConvProp.cxx
+++ b/l10ntools/source/gConvProp.cxx
@@ -26,20 +26,18 @@
convert_prop::convert_prop(l10nMem& crMemory) : convert_gen(crMemory)
{
-// throw l10nMem::showError(std::string("convert_prop not implemented"));
+ // throw l10nMem::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 l10nMem::showError(std::string("convert_prop::execute not implemented"));
+ throw l10nMem::showError(std::string("convert_prop::execute not implemented"));
}
diff --git a/l10ntools/source/gConvSrc.cxx b/l10ntools/source/gConvSrc.cxx
index 08fe485..6b49cc5 100644
--- a/l10ntools/source/gConvSrc.cxx
+++ b/l10ntools/source/gConvSrc.cxx
@@ -44,304 +44,264 @@ 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();
+ // 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("", true);
- setListItem("", false);
- }
- msValue = sbuildValue;
- mbValuePresent = true;
- mbExpectValue = false;
+ copySource(syyText);
+
+ if (mbInList && !mbInListItem) {
+ setListItem("", true);
+ setListItem("", 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";
+ std::string useText = copySource(syyText) + " is no en-US language";
- mbEnUs = bEnUs;
- if (!bEnUs && mbExpectValue)
- l10nMem::showError(useText);
+ mbEnUs = bEnUs;
+ if (!bEnUs && mbExpectValue)
+ l10nMem::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;
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ }
}
- 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;
}
- }
-
- if (!bMacro && mbExpectMacro)
- {
- while ((int)mcStack.size() > miMacroLevel)
- mcStack.pop_back();
- mbEnUs =
- mbExpectMacro = false;
- }
-
- mbValuePresent =
- mbExpectName =
- mbAutoPush = false;
- msValue.clear();
- msTextName.clear();
+
+ 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);
+ copySource(syyText);
- mcStack.push_back(msName);
- msName.clear();
+ 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);
+ copySource(syyText);
- // check for correct node/prop relations
- if (mcStack.size())
- mcStack.pop_back();
+ // check for correct node/prop relations
+ if (mcStack.size())
+ mcStack.pop_back();
- mbInList =
- mbEnUs = false;
+ mbInList =
+ mbEnUs = false;
}
-/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setListItem(char const *syyText, bool bIsStart)
{
- copySource(syyText);
-
- if (bIsStart)
- {
- if (!miListCount)
- {
- mcStack.pop_back();
- msName = "dummy";
- mcStack.push_back(msName);
+ copySource(syyText);
+
+ if (bIsStart) {
+ if (!miListCount) {
+ mcStack.pop_back();
+ msName = "dummy";
+ mcStack.push_back(msName);
+ }
+ msTextName = "item";
+ mbExpectValue =
+ mbExpectName =
+ mbInListItem = true;
+ msName.clear();
}
- msTextName = "item";
- mbExpectValue =
- mbExpectName =
- mbInListItem = true;
- msName.clear();
- }
- else
- {
- if (mbInListItem)
+ else
{
- 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);
+ 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;
+ 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);
+ 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;
+ int nL;
- sKey.clear();
- for (nL = 0; nL < (int)mcStack.size(); ++nL)
- if (mcStack[nL].size())
- sKey += (sKey.size() ? "." : "") + mcStack[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;
+ std::string sLang, sText, sTagText;
- // just to please compiler
- sKey = sKey;
+ // 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);
- }
+ // 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
index cac25a4..a452240 100644
--- a/l10ntools/source/gConvTree.cxx
+++ b/l10ntools/source/gConvTree.cxx
@@ -31,197 +31,167 @@ convert_tree::convert_tree(l10nMem& crMemory)
miCntLanguages(0)
{
- // tree files are written through a local routine
- mbLoadMode = true;
+ // 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;
- }
+ 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");
- }
+ 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();
+ // run analyzer
+ // TreeWrap::yylex();
- // dump last line
- copySourceSpecial(nullptr,3);
+ // dump last line
+ copySourceSpecial(nullptr,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;
+ 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;
+ 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);
+ mcMemory.setSourceKey(miLineNo, msSourceFile, msId, msCollector, mbMergeMode);
+ copySourceSpecial(yytext, 2);
- meStateTag = STATE_TAG_NONE;
- meStateVal = STATE_VAL_NONE;
+ 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;
+ 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());
+ 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
index d8d5651..2e13ee4 100644
--- a/l10ntools/source/gConvUlf.cxx
+++ b/l10ntools/source/gConvUlf.cxx
@@ -29,68 +29,52 @@ 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();
+ // 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);
+ std::string sText = copySource(syyText);
- // locate key (is any)
- msKey = sText.substr(1,sText.size()-2);
+ // 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";
+ std::string sText = copySource(syyText) + " is not en-US";
- if (!bIsEnUs)
- l10nMem::showError(sText);
+ if (!bIsEnUs)
+ l10nMem::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);
+ 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
index 45b41e2..5067fbf 100644
--- a/l10ntools/source/gConvXcs.cxx
+++ b/l10ntools/source/gConvXcs.cxx
@@ -32,121 +32,102 @@ convert_xcs::convert_xcs(l10nMem& crMemory)
-/************ 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");
+ if (mbMergeMode)
+ throw l10nMem::showError("Merge not implemented");
- // currently no .xcs files generate en-US translation, so stop trying
-// XcsWrap::yylex();
+ // 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);
+ 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);
+ 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;
+ 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);
+ 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;
+ mcMemory.setSourceKey(miLineNo, msSourceFile, sKey, sText, mbMergeMode);
+ mbCollectingData = false;
}
diff --git a/l10ntools/source/gConvXcu.cxx b/l10ntools/source/gConvXcu.cxx
index ff7e7f6..ccf1a95 100644
--- a/l10ntools/source/gConvXcu.cxx
+++ b/l10ntools/source/gConvXcu.cxx
@@ -31,177 +31,148 @@ convert_xcu::convert_xcu(l10nMem& crMemory)
-/************ 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();
+ // 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);
+ 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);
+ copySource(syyText);
- // check for correct node/prop relations
- if (mcStack.size())
- mcStack.pop_back();
+ // check for correct node/prop relations
+ if (mcStack.size())
+ mcStack.pop_back();
- mbNoTranslate = false;
+ 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";
- l10nMem::showError(sErr);
+ 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";
+ l10nMem::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);
+ int nL;
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list