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/02/25 01:05:09 UTC

svn commit: r1449567 - in /openoffice/branches/l10n/main/l10ntools/source: gCon.cxx gConSrcWrap.cxx gConUlfWrap.cxx gConUlflex.l gConXcsWrap.cxx gConXcslex.l gConXcu.hxx gConXcuWrap.cxx gConXculex.l gConXrm.hxx gConXrmWrap.cxx gConXrmlex.l

Author: jani
Date: Mon Feb 25 00:05:09 2013
New Revision: 1449567

URL: http://svn.apache.org/r1449567
Log:
xrm works

Modified:
    openoffice/branches/l10n/main/l10ntools/source/gCon.cxx
    openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx
    openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx
    openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l
    openoffice/branches/l10n/main/l10ntools/source/gConXcsWrap.cxx
    openoffice/branches/l10n/main/l10ntools/source/gConXcslex.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/gConXrm.hxx
    openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx
    openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l

Modified: openoffice/branches/l10n/main/l10ntools/source/gCon.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gCon.cxx?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gCon.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gCon.cxx Mon Feb 25 00:05:09 2013
@@ -69,6 +69,7 @@ convert_gen::convert_gen(const std::stri
   else if (sExtension == "ulf")        convert_gen_impl::mcImpl = new convert_ulf(crMemory);
   else if (sExtension == "xcu")        convert_gen_impl::mcImpl = new convert_xcu(crMemory);
   else if (sExtension == "xhp")        convert_gen_impl::mcImpl = new convert_xhp(crMemory);
+  else if (sExtension == "xrm")        convert_gen_impl::mcImpl = new convert_xrm(crMemory);
   else if (sExtension == "properties") convert_gen_impl::mcImpl = new convert_prop(crMemory);
   else throw std::string("unknown extension on source file: ")+srSourceFile;
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx Mon Feb 25 00:05:09 2013
@@ -119,6 +119,7 @@ void convert_src::setText(char *syyText)
 {
   msTextName    = copySource(syyText);
   mbExpectValue = true;
+  mbEnUs        = false;
 }
 
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx Mon Feb 25 00:05:09 2013
@@ -84,7 +84,10 @@ void convert_ulf::setText(char *syyText,
 void convert_ulf::setValue(char *syyText)
 {
   std::string sText = copySource(syyText);
+  int         nL;
 
+  nL = sText.rfind("\"");
+  sText.erase(nL);
 
   mcMemory.setEnUsKey(msKey, std::string("LngText"), sText);
 }

Modified: openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l Mon Feb 25 00:05:09 2013
@@ -56,14 +56,11 @@
 
 /***********************   H E L P E R   M A C R O S   ***********************/
 PRE   ^[ \t]*
-
-
 SUF   [ \t\r\n]
 SUFT  [ \t\r\n\[]
 SPACE [ \t]*
 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   *******************/
 %%
 
@@ -84,13 +81,7 @@ KEYID [a-zA-Z0-9_-]+
 
 
 
-"\"" {
-  int i = 0;
-  for (; (yytext[++i] = yyinput()) != '\"';)
-    if (yytext[i] == '\\')
-      yytext[++i] = yyinput();
-  yytext[i] = '\0';
-
+"\"".* {
   LOCptr->setValue(&yytext[1]);
 }
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcsWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcsWrap.cxx?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcsWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcsWrap.cxx Mon Feb 25 00:05:09 2013
@@ -35,7 +35,7 @@
 
 /************   I N T E R F A C E   I M P L E M E N T A T I O N   ************/
 convert_xcs::convert_xcs(l10nMem& crMemory)
-                      : convert_gen_impl(crMemory),
+                        : convert_gen_impl(crMemory),
                           mbCollectingData(false)
 {
 }
@@ -63,7 +63,7 @@ namespace XcsWrap
 void convert_xcs::execute()
 {
   // currently no .xcs files generate en-US translation, so stop trying
-  XcsWrap::genxcs_lex();
+  XcsWrap::yylex();
 }
 
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcslex.l Mon Feb 25 00:05:09 2013
@@ -49,7 +49,7 @@
 /* --- 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="genxcs_"
+%option 8bit noyywrap never-interactive
 %p 24000
 %e 1200
 %n 500

Modified: openoffice/branches/l10n/main/l10ntools/source/gConXcu.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXcu.hxx?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcu.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcu.hxx Mon Feb 25 00:05:09 2013
@@ -42,15 +42,17 @@ class convert_xcu : public convert_gen_i
     convert_xcu(l10nMem& crMemory);
     ~convert_xcu();
 
-    void pushKey(char *syyText, bool bIsComponent);
+    void pushKey(char *syyText);
     void popKey(char *syyText);
 
     void startCollectData(char *syyText);
     void stopCollectData(char *syyText);
+    void copySpecial(char *syyText);
+    void addLevel();
 
   private:
     std::vector<std::string> mcStack;
-
+    int                      miLevel;
 
     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=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXcuWrap.cxx Mon Feb 25 00:05:09 2013
@@ -35,7 +35,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),
-                          mbNoCollectingData(true)
+                          mbNoCollectingData(true),
+                          miLevel(0)
 {
 }
 
@@ -67,7 +68,7 @@ void convert_xcu::execute()
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
-void convert_xcu::pushKey(char *syyText, bool bIsComponent)
+void convert_xcu::pushKey(char *syyText)
 {
   std::string sKey, sTag = copySource(syyText);
   int    nL, nE;
@@ -80,7 +81,7 @@ void convert_xcu::pushKey(char *syyText,
     nL += 10;
     nE  = sTag.find("\"", nL);
     if (nE != (int)std::string::npos)
-      sKey = (bIsComponent ? "." : "") + sTag.substr(nL, nE - nL);
+      sKey = sTag.substr(nL, nE - nL);
   }
   mcStack.push_back(sKey);
 }
@@ -140,6 +141,7 @@ void convert_xcu::stopCollectData(char *
   // locate key and extract it
   for (nL = 0; nL < (int)mcStack.size(); ++nL)
     useKey += (useKey.size() ? "." : "" ) + mcStack[nL];
+  useKey.insert(0, miLevel, '.');
   
   if (mbMergeMode)
   {
@@ -158,3 +160,35 @@ void convert_xcu::stopCollectData(char *
   else
     mcMemory.setEnUsKey(useKey, "value", useText);
 }  
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu::copySpecial(char *syyText)
+{
+  int         nX    = msCollector.size();
+  std::string sText = copySource(syyText, mbNoCollectingData);
+
+  if (!mbNoCollectingData)
+  {
+    msCollector.erase(nX);
+    if (sText == "&amp;")
+      msCollector += "&";
+    else if (sText == "&apos;")
+      msCollector += "\'";
+    else if (sText == "&gt;")
+      msCollector += ">";
+    else if (sText == "&lt;")
+      msCollector += "<";
+    else if (sText == "&quot;")
+      msCollector += "\"";
+  }
+}  
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu::addLevel()
+{
+  ++miLevel;
+}  

Modified: openoffice/branches/l10n/main/l10ntools/source/gConXculex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXculex.l?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXculex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXculex.l Mon Feb 25 00:05:09 2013
@@ -58,22 +58,30 @@
 
 /***********************   H E L P E R   M A C R O S   ***********************/
 SPACE [ \t]*
-NAME  {SPACE}"oor:name="\"[^\"]+\"{SPACE}
+NAME  .*"oor:name="\"[^\"]+\"{SPACE}
 FIN   [^/>]*">"
 /*******************   R U L E S   D E F I N I T I O N S   *******************/
 %%
 
 
 
+"component-data" {
+  LOCptr->addLevel();
+  IMPLptr->copySource(yytext, false);
+}
+
+
+
 "<oor:component-data"{NAME} {
-  LOCptr->pushKey(yytext, true);
+  LOCptr->addLevel();
+  LOCptr->pushKey(yytext);
 }
 
 
 
 "<prop"{NAME}{FIN} |
 "<node"{NAME}{FIN} {
-  LOCptr->pushKey(yytext, false);
+  LOCptr->pushKey(yytext);
 }
 
 
@@ -97,6 +105,16 @@ FIN   [^/>]*">"
 
 
 
+"&amp;"  |
+"&apos;" |
+"&gt;"   |
+"&lt;"   |
+"&quot;" {
+  LOCptr->copySpecial(yytext);
+}
+
+
+
 .|\n {
   IMPLptr->copySource(yytext, LOCptr->mbNoCollectingData);
 }

Modified: openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx Mon Feb 25 00:05:09 2013
@@ -36,16 +36,20 @@
 class convert_xrm : public convert_gen_impl
 {
   public:
+    bool mbNoCollectingData;
     convert_xrm(l10nMem& crMemory);
     ~convert_xrm();
 
-    void startCollectData(std::string sType, std::string& sCollectedText);
-    void stopCollectData(std::string sType, std::string& sCollectedText);
+    void setId(char *yytext);
+    void setLang(char *yytext);
+    void setTag(char *yytext);
+    void startCollectData(char *yytext);
+    void stopCollectData(char *yytext);
 
   private:
-  std::string msTag;
-  std::string msMergeType;
-  bool        mbCollectingData;
+    std::string msKey;
+    bool        mbIsTag;
+    bool        mbIsLang;
 
     void execute();
 };

Modified: openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx Mon Feb 25 00:05:09 2013
@@ -34,8 +34,10 @@
 
 /************   I N T E R F A C E   I M P L E M E N T A T I O N   ************/
 convert_xrm::convert_xrm(l10nMem& crMemory)
-                      : convert_gen_impl(crMemory),
-                          mbCollectingData(false)
+                        : convert_gen_impl(crMemory),
+                          mbNoCollectingData(true),
+                          mbIsTag(false),
+                          mbIsLang(false)
 {
 }
 
@@ -60,7 +62,7 @@ namespace XrmWrap
 /**********************   I M P L E M E N T A T I O N   **********************/
 void convert_xrm::execute()
 {
-  XrmWrap::genXrm_lex();
+  XrmWrap::yylex();
 
   // write last part of file.
   if (mbMergeMode)
@@ -70,58 +72,84 @@ void convert_xrm::execute()
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
-void convert_xrm::startCollectData(std::string sType, std::string& sCollectedText)
+void convert_xrm::setId(char *yytext)
 {
-  if (mbMergeMode)
-    writeSourceFile(msCollector+sCollectedText);
-  msCollector.clear();
+  std::string& sText = copySource(yytext, mbNoCollectingData);
+  int          nL, nE;
+
+
+  if (mbIsTag)
+  {
+    nL = sText.find("\"");
+    nE = sText.find("\"", nL+1);
+    if (nL == (int)std::string::npos || nE == (int)std::string::npos)
+      return;
 
-  mbCollectingData = true;
-  msMergeType      = sType;
-  msTag            = sCollectedText;
+    msKey = sText.substr(nL+1, nE - nL -1);
+  }
 }
 
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
-void convert_xrm::stopCollectData(std::string sType, std::string& sCollectedText)
+void convert_xrm::setLang(char *yytext)
 {
-  std::string sKey;
-  int    nL;
+  std::string& sText = copySource(yytext, mbNoCollectingData);
+  std::string  sLang;
+  int          nL, nE;
 
 
-  // check tag match
-  if (sType != msMergeType)
-  throw "Conflicting tags: " + msTag + msCollector + sCollectedText;
+  if (mbIsTag)
+  {
+    nL = sText.find("\"");
+    nE = sText.find("\"", nL+1);
+    if (nL == (int)std::string::npos || nE == (int)std::string::npos)
+      return;
+
+    sLang = sText.substr(nL+1, nE - nL -1);
+    if (sLang == "en-US")
+      mbIsLang = true;
+    else
+      showError((char *)(sLang + " is no en-US language").c_str());
+  }
+}
 
-  // locate key and extract it
-  nL    = msTag.find("id=") +4;
-  sKey  = msTag.substr(nL, msTag.find("\"", nL+1) - nL);
 
-  if (mbMergeMode)
-  {
-    // get all languages (includes en-US)
-    std::vector<l10nMem_entry *>& cExtraLangauges = mcMemory.getLanguagesForKey(sKey);
-    std::string                   sNewLine;
-    nL = cExtraLangauges.size();
-
-  // write en-US entry
-    writeSourceFile(msCollector+sCollectedText);
-
-  // and all other languages for that key
-  for (int i = 0; i < nL; ++i)
-    {
-      sNewLine = "\n<" + sType + " id=\"" + sKey + "\"" + " xml:lang=\"" +
-                 cExtraLangauges[i]->msLanguage + "\">" +
-                 cExtraLangauges[i]->msText +
-                 "</" + sType + ">";
 
-      writeSourceFile(sNewLine);
-    }
-  }
-  else
-    mcMemory.setEnUsKey(sKey, std::string("dummy"), msCollector);
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xrm::setTag(char *yytext)
+{
+  copySource(yytext);
+
+  msKey.clear();
+  mbIsLang = false;
+  mbIsTag  = true;
+}
 
-  mbCollectingData = false;
-  msCollector.clear();
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xrm::startCollectData(char *yytext)
+{
+  copySource(yytext, mbNoCollectingData);
+
+  if (mbIsTag && mbIsLang && msKey.size())
+    mbNoCollectingData = false;
+
+  mbIsTag = mbIsLang = false;
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xrm::stopCollectData(char *yytext)
+{
+  if (!mbNoCollectingData)
+  {
+    msKey = msKey + "." + msKey;
+    mcMemory.setEnUsKey(msKey, std::string("text"), msCollector);
+    mbNoCollectingData = true;
+    msKey.clear();
+  }
+  copySource(yytext);
 }  

Modified: openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l?rev=1449567&r1=1449566&r2=1449567&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l Mon Feb 25 00:05:09 2013
@@ -49,38 +49,54 @@
 /* --- 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="genXrm_"
+%option 8bit noyywrap never-interactive
 %p 24000
 %e 1200
 %n 500
 
-
-
+/***********************   H E L P E R   M A C R O S   ***********************/
+IDENT [a-zA-Z0-9_-]*
+NAME  \"{IDENT}\"
+SP    [ \t]*
 /*******************   R U L E S   D E F I N I T I O N S   *******************/
 %%
 
-"<p"[^>]*> {
-  std::string text(yytext);
-  LOCptr->startCollectData(text.substr(1,1), text);
+
+
+"id"{SP}"="{SP}{NAME} {
+  LOCptr->setId(yytext);
+}
+
+
+
+"lang"{SP}"="{SP}{NAME} {
+  LOCptr->setLang(yytext);
 }
 
-"<h"[0-9][^>]*> {
-  std::string text(yytext);
-  LOCptr->startCollectData(text.substr(1,2), text);
+
+
+"<h"[0-9]" " |
+"<p "        {
+  LOCptr->setTag(yytext);
 }
 
-"</p>" {
-  std::string text(yytext);
-  LOCptr->stopCollectData(text.substr(2,1), text);
+
+
+"</h"[0-9] |
+"</p"      {
+  LOCptr->stopCollectData(yytext);
 }
 
-"</h"[0-9]> {
-  std::string text(yytext);
-  LOCptr->stopCollectData(text.substr(2,2), text);
+
+
+">" {
+  LOCptr->startCollectData(yytext);
 }
 
+
+
 .|\n {
-  IMPLptr->copySource(yytext);
+  IMPLptr->copySource(yytext, LOCptr->mbNoCollectingData);
 }