Author: jani
Date: Tue Feb 19 18:49:02 2013
New Revision: 1447867
URL: http://svn.apache.org/r1447867
Log:
.xcu is changed to new layout
Modified:
openoffice/branches/l10n/main/l10ntools/source/gCon.cxx
openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l
openoffice/branches/l10n/main/l10ntools/source/gConXcu.hxx
openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gConXculex.l
openoffice/branches/l10n/main/l10ntools/source/gHandler.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=1447867&r1=1447866&r2=1447867&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gCon.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gCon.cxx Tue Feb 19 18:49:02
2013
@@ -100,6 +100,14 @@ void convert_gen::execute()
/********************** I M P L E M E N T A T I O N **********************/
+bool convert_gen::isError()
+{
+ return convert_gen_impl::mcImpl->mbInError;
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
convert_gen_impl::convert_gen_impl(l10nMem& crMemory)
: mcMemory(crMemory),
mbInError(false),
@@ -197,6 +205,8 @@ std::string& convert_gen_impl::copySourc
if (bDoClear)
msCollector.clear();
+ else
+ msCollector += msCopyText;
// remove leading blanks
if (bSkipLeading)
@@ -224,6 +234,7 @@ std::string& convert_gen_impl::copySourc
/********************** I M P L E M E N T A T I O N **********************/
std::string convert_gen_impl::showError(char *sText)
{
+ mbInError = true;
std::cerr << "ERROR in " << msSourceFile << ":" << miLineNo << ": " <<
sText << std::endl;
return "ERROR";
}
\ No newline at end of file
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx?rev=1447867&r1=1447866&r2=1447867&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx Tue Feb 19
18:49:02 2013
@@ -92,11 +92,11 @@ void convert_src::setValue(char *syyText
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setLang(char *syyText, bool bEnUs)
{
- copySource(syyText);
+ std::string useText = copySource(syyText) + " is no en-US language";
mbEnUs = bEnUs;
if (!bEnUs)
- throw "no en-US source used";
+ showError((char *)useText.c_str());
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l?rev=1447867&r1=1447866&r2=1447867&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l Tue Feb 19
18:49:02 2013
@@ -57,11 +57,13 @@
/*********************** H E L P E R M A C R O S ***********************/
+%x CMD
PRE ^[ \t]*
SUF [ \t\r\n]
SUFT [ \t\r\n\[]
SPACE [ \t]*
-IDENT [a-zA-Z0-9_-]+
+IDENT ([a-zA-Z0-9][ a-zA-Z0-9_\-\+\*]*[a-zA-Z0-9]|[0-9])
+KEYID [a-zA-Z0-9_-]+
/******************* R U L E S D E F I N I T I O N S *******************/
%%
@@ -147,7 +149,7 @@ IDENT [a-zA-Z0-9_-]+
-"["{SPACE}{IDENT}{SPACE}"]" {
+"["{SPACE}{KEYID}{SPACE}"]" {
LOCptr->setLang(yytext, false);
}
@@ -200,6 +202,21 @@ IDENT [a-zA-Z0-9_-]+
{PRE}[wW][iI][nN][dD][oO][wW]{SUF} {
yyless(strlen(yytext)-1);
LOCptr->setCmd(yytext);
+ BEGIN(CMD);
+}
+
+<CMD>{IDENT} {
+ LOCptr->setName(yytext);
+ BEGIN(INITIAL);
+}
+
+<CMD>[ \t=]+ {
+ IMPLptr->copySource(yytext);
+}
+
+<CMD>[\\\n] {
+ yyless(1);
+ BEGIN(INITIAL);
}
@@ -250,7 +267,7 @@ IDENT [a-zA-Z0-9_-]+
-{IDENT} {
+{KEYID} {
LOCptr->setName(yytext);
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcu.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcu.hxx?rev=1447867&r1=1447866&r2=1447867&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcu.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcu.hxx Tue Feb 19
18:49:02 2013
@@ -37,20 +37,19 @@ class xcu_stack_entry;
class convert_xcu : public convert_gen_impl
{
public:
- typedef enum {TAG_COMPONENT, TAG_PROP, TAG_NODE } TAG_TYPE;
+ bool mbNoCollectingData;
+
convert_xcu(l10nMem& crMemory);
~convert_xcu();
- void pushKeyPart(TAG_TYPE eIsNode, char *syyText);
- void popKeyPart (TAG_TYPE eIsNode, char *syyText);
+ void pushKey(char *syyText);
+ void popKey(char *syyText);
void startCollectData(char *syyText);
void stopCollectData(char *syyText);
private:
std::vector<std::string> mcStack;
- std::string msObj;
- bool mbCollectingData;
void execute();
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx?rev=1447867&r1=1447866&r2=1447867&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx Tue Feb 19
18:49:02 2013
@@ -34,8 +34,8 @@
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xcu::convert_xcu(l10nMem& crMemory)
- : convert_gen_impl(crMemory),
- mbCollectingData(false)
+ : convert_gen_impl(crMemory),
+ mbNoCollectingData(true)
{
}
@@ -61,36 +61,34 @@ namespace XcuWrap
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu::execute()
{
- XcuWrap::genxcu_lex();
+ XcuWrap::yylex();
}
/********************** I M P L E M E N T A T I O N **********************/
-void convert_xcu::pushKeyPart(TAG_TYPE bIsNode, char *syyText)
+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)
- return;
-
- // find end of key
- nL += 10;
- nE = sTag.find("\"", nL);
- if (nE == (int)std::string::npos)
- return;
-
- sKey = sTag.substr(nL, nE - nL);
+ 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::popKeyPart(TAG_TYPE bIsNode, char *syyText)
+void convert_xcu::popKey(char *syyText)
{
copySource(syyText);
@@ -108,10 +106,19 @@ void convert_xcu::startCollectData(char
std::string sTag = copySource(syyText);
// locate object name
- for (nL = 1; sTag[nL] != ' '; ++nL) ;
- msObj = sTag.substr(1,nL-1);
-
- mbCollectingData = true;
+ nL = sTag.find("xml:lang=\"");
+ if (nL != (int)std::string::npos)
+ {
+ // test langauge
+ nL += 10;
+ if (sTag.substr(nL,5) != "en-US")
+ {
+ std::string sErr = sTag.substr(nL,5) + " is not en-US";
+ showError((char *)sErr.c_str());
+ }
+ else
+ mbNoCollectingData = false;
+ }
}
@@ -125,13 +132,14 @@ void convert_xcu::stopCollectData(char *
copySource(syyText);
// time to do something ?
- if (!mbCollectingData)
- return;
- mbCollectingData = false;
+ if (mbNoCollectingData)
+ return;
+
+ mbNoCollectingData = true;
// locate key and extract it
for (nL = 0; nL < (int)mcStack.size(); ++nL)
- useKey += (nL > 0 ? "." : "") + mcStack[nL];
+ useKey += (nL > 0 ? "." : "") + mcStack[nL];
if (mbMergeMode)
{
@@ -148,5 +156,5 @@ void convert_xcu::stopCollectData(char *
}
}
else
- mcMemory.setEnUsKey(useKey, msObj, useText);
+ mcMemory.setEnUsKey(useKey, "value", useText);
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConXculex.l
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXculex.l?rev=1447867&r1=1447866&r2=1447867&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXculex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXculex.l Tue Feb 19
18:49:02 2013
@@ -49,50 +49,53 @@
/* --- The following options are for future use (maybe) */
/* yyclass= --> subClass yyFlexLexer to allow own functions */
/* c++ --> generate C++ classes */
-%option 8bit noyywrap never-interactive prefix="genxcu_"
+%option 8bit noyywrap never-interactive
%p 24000
%e 1200
%n 500
+/*********************** H E L P E R M A C R O S ***********************/
+SPACE [ \t]*
+NAME {SPACE}"oor:name="\"[^\"]+\"{SPACE}
+
/******************* R U L E S D E F I N I T I O N S *******************/
%%
-"<oor:component-data "[^>]*> {
- LOCptr->pushKeyPart(convert_xcu::TAG_COMPONENT, yytext);
-}
-"</oor:component-data>" {
- LOCptr->popKeyPart(convert_xcu::TAG_COMPONENT, yytext);
+"<oor:component-data"{NAME} |
+"<prop"{NAME} |
+"<node"{NAME} {
+ LOCptr->pushKey(yytext);
}
-"<prop oor:name=\""[^\"]*\" {
- LOCptr->pushKeyPart(convert_xcu::TAG_PROP, yytext);
-}
-"</prop>" {
- LOCptr->popKeyPart(convert_xcu::TAG_PROP, yytext);
-}
-"<node oor:name=\""[^\"]*\" {
- LOCptr->pushKeyPart(convert_xcu::TAG_NODE, yytext);
+"</oor:component-data" |
+"</prop" |
+"</node" {
+ LOCptr->popKey(yytext);
}
-"</node>" {
- LOCptr->popKeyPart(convert_xcu::TAG_NODE, yytext);
-}
-
-"<value xml:lang=\""[^\"]*\"[^>]*">" {
+
+"<value xml:lang="\"[^\"]+\"[^>]*">" {
LOCptr->startCollectData(yytext);
}
+
+
"</value>" {
LOCptr->stopCollectData(yytext);
}
+
+
.|\n {
- IMPLptr->copySource(yytext);
+ IMPLptr->copySource(yytext, false, LOCptr->mbNoCollectingData);
}
+
+
+
%%
Modified: openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx?rev=1447867&r1=1447866&r2=1447867&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx Tue Feb 19
18:49:02 2013
@@ -211,26 +211,31 @@ void handler::run()
/********************** I M P L E M E N T A T I O N **********************/
void handler::runExtractMerge(bool bMerge)
{
+ bool bDoNotSave = false;
+
// prepare translation memory to module type
mcMemory.setModuleName(msModuleName);
// loop through all source files, and extract messages from each file
for (std::vector<std::string>::iterator siSource = msSourceFiles.begin();
siSource != msSourceFiles.end(); ++siSource)
{
- // tell system
- if (mbVerbose)
- std::cout << "gLang extracting text from file " << *siSource << std::endl;
+ // tell system
+ if (mbVerbose)
+ std::cout << "gLang extracting text from file " << *siSource <<
std::endl;
- // prepare translation memory
+ // prepare translation memory
mcMemory.setFileName(*siSource);
// get converter and extract files
- convert_gen convertObj(msSourceDir + *siSource, mcMemory, bMerge);
- convertObj.execute();
+ convert_gen convertObj(msSourceDir + *siSource, mcMemory, bMerge);
+ convertObj.execute();
+ if (!bDoNotSave)
+ bDoNotSave = convertObj.isError();
}
// and generate language file
- mcMemory.save(msTargetDir + msModuleName);
+ if (!bDoNotSave)
+ mcMemory.save(msTargetDir + msModuleName);
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gLang.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gLang.hxx?rev=1447867&r1=1447866&r2=1447867&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gLang.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gLang.hxx Tue Feb 19
18:49:02 2013
@@ -51,10 +51,10 @@ class l10nMem_entry
std::string msSourceFile;
std::string msModuleName;
std::string msKey;
- std::string msObjectType;
+ std::string msObjectType;
std::string msLanguage;
std::string msText;
- int miIndex;
+ int miIndex;
private:
};
@@ -69,7 +69,7 @@ class l10nMem
~l10nMem();
void save (const std::string& srTargetFile);
- void clear();
+ void clear();
void setFileName (const std::string& srSourceFile);
void setModuleName(const std::string& srModuleName);
void setEnUsKey (const std::string& srKey, const std::string&
srObjectType, const std::string& srText, int iIndex = 0);
@@ -88,11 +88,12 @@ class l10nMem
class convert_gen
{
public:
- convert_gen(const std::string& srSourceFile, l10nMem& crMemory, const bool
bMerge);
- ~convert_gen();
+ convert_gen(const std::string& srSourceFile, l10nMem& crMemory, const bool
bMerge);
+ ~convert_gen();
- // do extract/merge
+ // do extract/merge
void execute();
+ bool isError();
};