You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ja...@apache.org on 2013/03/23 12:24:37 UTC
svn commit: r1460128 - in /openoffice/branches/l10n/main/l10ntools/source:
gCon.cxx gCon.hxx gConPoWrap.cxx gConXhp.hxx gConXhpWrap.cxx gConXhplex.l
gHandler.cxx gL10nMem.cxx gL10nMem.hxx gL10nMemDB.cxx gLang.hxx
Author: jani
Date: Sat Mar 23 11:24:37 2013
New Revision: 1460128
URL: http://svn.apache.org/r1460128
Log:
prepare for merging of xhp files (needs to write a file pr language)
Modified:
openoffice/branches/l10n/main/l10ntools/source/gCon.cxx
openoffice/branches/l10n/main/l10ntools/source/gCon.hxx
openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gConXhp.hxx
openoffice/branches/l10n/main/l10ntools/source/gConXhpWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gConXhplex.l
openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx
openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx
openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx
openoffice/branches/l10n/main/l10ntools/source/gLang.hxx
Modified: openoffice/branches/l10n/main/l10ntools/source/gCon.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gCon.cxx?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gCon.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gCon.cxx Sat Mar 23 11:24:37 2013
@@ -92,12 +92,12 @@ convert_gen::~convert_gen()
/********************** I M P L E M E N T A T I O N **********************/
-bool convert_gen::execute(const bool bMerge, const bool bLoadMode, const bool bAllowNoFile)
+bool convert_gen::execute(const bool bMerge)
{
convert_gen_impl::mcImpl->mbMergeMode = bMerge;
// and load file
- if (!convert_gen_impl::mcImpl->prepareFile(bLoadMode, bAllowNoFile))
+ if (!convert_gen_impl::mcImpl->prepareFile())
return false;
// and execute conversion
@@ -143,6 +143,7 @@ void convert_gen_impl::save(const std::s
{
std::string x;
+ x = sFileName;
x = sKey;
x = sENUStext;
x = sText;
@@ -166,7 +167,9 @@ void convert_gen_impl::endSave()
/********************** I M P L E M E N T A T I O N **********************/
convert_gen_impl::convert_gen_impl(l10nMem& crMemory)
- : mcMemory(crMemory),
+ : mbMergeMode(false),
+ mbLoadMode(false),
+ mcMemory(crMemory),
miLineNo(1)
{
}
@@ -182,14 +185,14 @@ convert_gen_impl::~convert_gen_impl()
/********************** I M P L E M E N T A T I O N **********************/
-bool convert_gen_impl::prepareFile(bool bLoadMode, bool bAllowNoFile)
+bool convert_gen_impl::prepareFile()
{
std::ifstream inputFile(msSourcePath.c_str(), std::ios::binary);
if (!inputFile.is_open())
{
- if (bAllowNoFile)
+ if (mbLoadMode)
{
l10nMem::showWarning("Cannot open file (" + msSourcePath + ")");
return false;
@@ -210,7 +213,7 @@ bool convert_gen_impl::prepareFile(bool
throw l10nMem::showError("cannot read whole file");
inputFile.close();
- if (mbMergeMode && !bLoadMode)
+ if (mbMergeMode && !mbLoadMode)
{
// close previous file
if (outputFile.is_open())
@@ -263,7 +266,8 @@ void convert_gen_impl::writeSourceFile(c
if (!line.size())
return;
- outputFile.write(line.c_str(), line.size());
+ if (outputFile.is_open())
+ outputFile.write(line.c_str(), line.size());
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gCon.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gCon.hxx?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gCon.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gCon.hxx Sat Mar 23 11:24:37 2013
@@ -65,6 +65,7 @@ class convert_gen_impl
// generic variables
bool mbMergeMode;
+ bool mbLoadMode;
std::string msSourcePath;
std::string msTargetPath;
std::string msSourceFile;
@@ -74,15 +75,15 @@ class convert_gen_impl
// utility functions for converters
- void lexRead (char *sBuf, int *nResult, int nMax_size);
+ void lexRead (char *sBuf, int *nResult, int nMax_size);
void writeSourceFile(const std::string& line);
- std::string& copySource(char *yyText, bool bDoClear = true);
+ std::string& copySource (char *yyText, bool bDoClear = true);
protected:
std::string msSourceBuffer, msCopyText;
int miSourceReadIndex;
- bool prepareFile(bool bLoadMode, bool bAllowNoFile);
+ bool prepareFile();
private:
std::ofstream outputFile;
Modified: openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx Sat Mar 23 11:24:37 2013
@@ -40,6 +40,8 @@ convert_po::convert_po(l10nMem& crMemory
mbExpectStr(false),
mbFuzzy(false)
{
+ // Po files are handled special
+ mbLoadMode = true;
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXhp.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXhp.hxx?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXhp.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXhp.hxx Sat Mar 23 11:24:37 2013
@@ -33,6 +33,20 @@
/******************** C L A S S D E F I N I T I O N ********************/
+class lang_container
+{
+ public:
+ lang_container(const std::string& sLang, const std::string& sFileName);
+ lang_container();
+ ~lang_container();
+
+ std::string msLang;
+// std::ofstream msOutFile;
+};
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
class convert_xhp : public convert_gen_impl
{
public:
@@ -53,19 +67,21 @@ class convert_xhp : public convert_gen_i
void handleSpecial(char *yytext);
void handleDataEnd(char *yytext);
void duplicate(char *yytext);
- std::string& copySourceWithCollector(char *yytext);
+ std::string& copySourceSpecial(char *yytext, int iType = 0);
private:
- enum
+ typedef enum
{
VALUE_NOT_USED,
VALUE_IS_TAG,
VALUE_IS_TAG_TRANS,
VALUE_IS_VALUE,
VALUE_IS_VALUE_TAG
- } meExpectValue, mePushValue;
+ } STATE;
+ STATE meExpectValue, mePushValue;
std::string msKey, msPushCollect;
- void execute();
+ std::vector<lang_container> mbLanguages;
+ void execute();
};
#endif
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXhpWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXhpWrap.cxx?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXhpWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXhpWrap.cxx Sat Mar 23 11:24:37 2013
@@ -35,10 +35,40 @@
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+lang_container::lang_container(const std::string& sLang, const std::string& sFileName)
+{
+ std::string x;
+
+ x= sLang;
+ x= sFileName;
+ // JIX: implement file open
+ // JIX: implement lang tag
+}
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+lang_container::lang_container()
+{
+}
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
+lang_container::~lang_container()
+{
+ // JIX: implement close file
+}
+
+
+
+/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xhp::convert_xhp(l10nMem& crMemory)
: convert_gen_impl(crMemory),
meExpectValue(VALUE_NOT_USED)
{
+ // xhp files are written through a local routine
+ mbLoadMode = true;
}
@@ -62,10 +92,15 @@ namespace XhpWrap
/********************** I M P L E M E N T A T I O N **********************/
void convert_xhp::execute()
{
- XhpWrap::yylex();
+ std::string sLang;
+ std::string sFile = msTargetPath+msSourceFile;
+
+ // prepare list with languages
+ mcMemory.prepareMerge();
+ for (; mcMemory.getLangList(sLang); )
+ mbLanguages.push_back(lang_container(sLang, sFile));
- if (mbMergeMode)
- writeSourceFile(msCollector);
+ XhpWrap::yylex();
}
@@ -73,7 +108,7 @@ void convert_xhp::execute()
/********************** I M P L E M E N T A T I O N **********************/
void convert_xhp::setString(char *yytext)
{
- copySourceWithCollector(yytext);
+ copySourceSpecial(yytext);
}
@@ -86,7 +121,7 @@ void convert_xhp::openTag(char *yytext)
meExpectValue = VALUE_IS_VALUE_TAG;
msCollector += "\\";
}
- copySourceWithCollector(yytext);
+ copySourceSpecial(yytext);
}
@@ -94,27 +129,30 @@ void convert_xhp::openTag(char *yytext)
/********************** I M P L E M E N T A T I O N **********************/
void convert_xhp::closeTag(char *yytext)
{
- copySourceWithCollector(yytext);
+ STATE newState = meExpectValue;
+
switch (meExpectValue)
{
case VALUE_IS_VALUE_TAG:
- meExpectValue = VALUE_IS_VALUE;
- msCollector.insert(msCollector.size()-1, "\\");
+ newState = VALUE_IS_VALUE;
+ msCollector += "\\";
break;
case VALUE_IS_TAG_TRANS:
if (msKey.size())
- meExpectValue = VALUE_IS_VALUE;
+ newState = VALUE_IS_VALUE;
break;
case VALUE_IS_TAG:
msKey.clear();
- meExpectValue = VALUE_NOT_USED;
+ newState = VALUE_NOT_USED;
break;
case VALUE_NOT_USED:
case VALUE_IS_VALUE:
break;
}
+ copySourceSpecial(yytext);
+ meExpectValue = newState;
}
@@ -122,8 +160,8 @@ void convert_xhp::closeTag(char *yytext)
/********************** I M P L E M E N T A T I O N **********************/
void convert_xhp::setId(char *yytext)
{
- int nL, nE, nX = msCollector.size();
- std::string& sText = copySourceWithCollector(yytext);
+ int nL, nE;
+ std::string& sText = copySourceSpecial(yytext);
nL = sText.find("\"");
@@ -152,7 +190,7 @@ void convert_xhp::setLang(char *yytext)
{
int nL, nE;
std::string sLang;
- std::string& sText = copySourceWithCollector(yytext);
+ std::string& sText = copySourceSpecial(yytext, 1);
nL = sText.find("\"");
@@ -186,8 +224,8 @@ void convert_xhp::setLang(char *yytext)
/********************** I M P L E M E N T A T I O N **********************/
void convert_xhp::setRef(char *yytext)
{
- int nL, nE, nX = msCollector.size();
- std::string& sText = copySourceWithCollector(yytext);
+ int nL, nE;
+ std::string& sText = copySourceSpecial(yytext);
nL = sText.find("\"");
@@ -214,7 +252,7 @@ void convert_xhp::setRef(char *yytext)
/********************** I M P L E M E N T A T I O N **********************/
void convert_xhp::openTransTag(char *yytext)
{
- copySource(yytext);
+ copySourceSpecial(yytext);
msKey.clear();
meExpectValue = VALUE_IS_TAG;
}
@@ -230,8 +268,8 @@ void convert_xhp::closeTransTag(char *yy
mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, msCollector);
msKey.clear();
}
- copySource(yytext);
meExpectValue = VALUE_NOT_USED;
+ copySourceSpecial(yytext, 2);
}
@@ -239,7 +277,7 @@ void convert_xhp::closeTransTag(char *yy
/********************** I M P L E M E N T A T I O N **********************/
void convert_xhp::stopTransTag(char *yytext)
{
- copySource(yytext);
+ copySourceSpecial(yytext);
meExpectValue = VALUE_NOT_USED;
}
@@ -251,7 +289,7 @@ void convert_xhp::startComment(char *yyt
mePushValue = meExpectValue;
msPushCollect = msCollector;
meExpectValue = VALUE_NOT_USED;
- copySource(yytext);
+ copySourceSpecial(yytext);
}
@@ -259,7 +297,7 @@ void convert_xhp::startComment(char *yyt
/********************** I M P L E M E N T A T I O N **********************/
void convert_xhp::stopComment(char *yytext)
{
- copySource(yytext);
+ copySourceSpecial(yytext);
meExpectValue = mePushValue;
msCollector = msPushCollect;
}
@@ -270,7 +308,7 @@ void convert_xhp::stopComment(char *yyte
void convert_xhp::handleSpecial(char *yytext)
{
int nX = msCollector.size();
- std::string& sText = copySourceWithCollector(yytext);
+ std::string& sText = copySourceSpecial(yytext);
if (meExpectValue != VALUE_IS_VALUE || meExpectValue != VALUE_IS_VALUE_TAG)
@@ -293,7 +331,7 @@ void convert_xhp::handleSpecial(char *yy
void convert_xhp::handleDataEnd(char *yytext)
{
int nX = msCollector.size();
- copySourceWithCollector(yytext);
+ copySourceSpecial(yytext);
if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG)
msCollector.erase(nX);
@@ -304,7 +342,7 @@ void convert_xhp::handleDataEnd(char *yy
/********************** I M P L E M E N T A T I O N **********************/
void convert_xhp::duplicate(char *yytext)
{
- copySourceWithCollector(yytext);
+ copySourceSpecial(yytext);
if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG)
msCollector += msCollector[msCollector.size()-1];
@@ -313,7 +351,12 @@ void convert_xhp::duplicate(char *yytext
/********************** I M P L E M E N T A T I O N **********************/
-std::string& convert_xhp::copySourceWithCollector(char *yytext)
+std::string& convert_xhp::copySourceSpecial(char *yytext, int iType)
{
- return copySource(yytext, (meExpectValue == VALUE_NOT_USED || meExpectValue == VALUE_IS_TAG_TRANS));
+ iType = 0;
+ return copySource(yytext, (meExpectValue != VALUE_IS_VALUE && meExpectValue != VALUE_IS_VALUE_TAG));
+
+
+ // JIX tell copy source not to use outputfile
+ // JIX write all languages sources.
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXhplex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXhplex.l?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXhplex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXhplex.l Sat Mar 23 11:24:37 2013
@@ -154,7 +154,7 @@ IDENT [\.a-zA-Z0-9_-]+
.|\n {
- LOCptr->copySourceWithCollector(yytext);
+ LOCptr->copySourceSpecial(yytext);
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx Sat Mar 23 11:24:37 2013
@@ -278,9 +278,7 @@ void handler::runExtractMerge(bool bMerg
// get converter and extract file
convert_gen convertObj(mcMemory, msSourceDir, msTargetDir, *siSource);
- convertObj.execute(bMerge, false, false);
-
- //JIX runExtractMerge, handle merge
+ convertObj.execute(bMerge);
}
// and generate language file
@@ -308,7 +306,7 @@ void handler::runConvert()
// get converter and extract files
convert_gen convertObj(mcMemory, sFilePath, msTargetDir, *siSource);
- convertObj.execute(true, true, true);
+ convertObj.execute(true);
}
}
@@ -454,7 +452,7 @@ void handler::loadL10MEM()
// and load file
mcMemory.setLanguage("", true, false);
- convert_gen (mcMemory, sLoad, msTargetDir, sMod).execute(false, true, true);
+ convert_gen (mcMemory, sLoad, msTargetDir, sMod).execute(false);
}
// loop through all languages and load text
@@ -468,7 +466,7 @@ void handler::loadL10MEM()
// tell system
l10nMem::showDebug("gLang loading text from language file " + sLoad + sMod);
- convert_gen(mcMemory, sLoad, msTargetDir, sMod).execute(false, true, true);
+ convert_gen(mcMemory, sLoad, msTargetDir, sMod).execute(false);
}
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx Sat Mar 23 11:24:37 2013
@@ -101,6 +101,8 @@ void l10nMem::dumpMem(const std::string&
{ l10nMem_impl::mcImpl->dumpMem(sT); }
bool l10nMem::getMergeLang(std::string& sL, std::string& sT)
{ return l10nMem_impl::mcImpl->mcDb.getMergeLang(sL, sT); }
+bool l10nMem::getLangList(std::string& sL)
+ { return l10nMem_impl::mcImpl->mcDb.getLangList(sL); }
Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx Sat Mar 23 11:24:37 2013
@@ -132,7 +132,7 @@ class l10nMem_db
void prepareMerge ();
bool getMergeLang (std::string& sLang,
std::string& sText);
-
+ bool getLangList (std::string& sLang);
};
Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx Sat Mar 23 11:24:37 2013
@@ -398,10 +398,10 @@ void l10nMem_db::prepareMerge()
/********************** I M P L E M E N T A T I O N **********************/
bool l10nMem_db::getMergeLang(std::string& sLang,
- std::string& sText)
+ std::string& sText)
{
miCurLangInx++;
- if (miCurLangInx >= mcLangList.size())
+ if (miCurLangInx >= (int)mcLangList.size())
return false;
// update pointers
@@ -409,3 +409,17 @@ bool l10nMem_db::getMergeLang(std::strin
sText = mcENUSlist[miCurENUSinx].mcLangList[miCurLangInx].msText;
return true;
}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+bool l10nMem_db::getLangList(std::string& sLang)
+{
+ miCurLangInx++;
+ if (miCurLangInx >= (int)mcLangList.size())
+ return false;
+
+ // update pointers
+ sLang = mcLangList[miCurLangInx];
+ return true;
+}
Modified: openoffice/branches/l10n/main/l10ntools/source/gLang.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gLang.hxx?rev=1460128&r1=1460127&r2=1460128&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gLang.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gLang.hxx Sat Mar 23 11:24:37 2013
@@ -90,6 +90,7 @@ class l10nMem
void prepareMerge ();
bool getMergeLang (std::string& sLang,
std::string& sText);
+ bool getLangList (std::string& sLang);
};
@@ -105,9 +106,7 @@ class convert_gen
~convert_gen();
// do extract/merge
- bool execute(const bool bMerge,
- const bool bLoadMode,
- const bool bAllowNoFile);
+ bool execute(const bool bMerge);
// ONLY po should implement these functions
void startSave(const std::string& sLanguage,