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/19 20:27:05 UTC

svn commit: r1458465 - in /openoffice/branches/l10n/main/l10ntools/source: gConUlfWrap.cxx gConUlflex.l gConXrm.hxx gConXrmWrap.cxx gConXrmlex.l gL10nMem.cxx gL10nMem.hxx gL10nMemDB.cxx gLang.hxx

Author: jani
Date: Tue Mar 19 19:27:05 2013
New Revision: 1458465

URL: http://svn.apache.org/r1458465
Log:
merge implemented for xrm files, and Ulf convert problem repaired

Modified:
    openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx
    openoffice/branches/l10n/main/l10ntools/source/gConUlflex.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
    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/gConUlfWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx?rev=1458465&r1=1458464&r2=1458465&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx Tue Mar 19 19:27:05 2013
@@ -86,6 +86,7 @@ void convert_ulf::setValue(char *syyText
   std::string sText = copySource(syyText);
   int         nL;
 
+  sText.erase(0,1);
   nL = sText.rfind("\"");
   sText.erase(nL);
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l?rev=1458465&r1=1458464&r2=1458465&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l Tue Mar 19 19:27:05 2013
@@ -85,7 +85,7 @@ KEYID [a-zA-Z0-9_-]+
 
 
 "\"".* {
-  LOCptr->setValue(&yytext[1]);
+  LOCptr->setValue(yytext);
 }
 
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx?rev=1458465&r1=1458464&r2=1458465&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx Tue Mar 19 19:27:05 2013
@@ -48,8 +48,10 @@ class convert_xrm : public convert_gen_i
 
   private:
     std::string msKey;
-    bool        mbIsTag;
+    bool        mbIsTagHeader;
+    bool        mbIsTagPara;
     bool        mbIsLang;
+    int         miHeaderLevel;
 
     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=1458465&r1=1458464&r2=1458465&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx Tue Mar 19 19:27:05 2013
@@ -21,6 +21,7 @@
 #include "gConXrm.hxx"
 #include <iostream>
 #include <fstream>
+#include <sstream>
 #include <cstdlib>
 
 
@@ -36,7 +37,8 @@
 convert_xrm::convert_xrm(l10nMem& crMemory)
                         : convert_gen_impl(crMemory),
                           mbNoCollectingData(true),
-                          mbIsTag(false),
+                          mbIsTagHeader(false),
+                          mbIsTagPara(false),
                           mbIsLang(false)
 {
 }
@@ -78,7 +80,7 @@ void convert_xrm::setId(char *yytext)
   int          nL, nE;
 
 
-  if (mbIsTag)
+  if (mbIsTagHeader || mbIsTagPara)
   {
     nL = sText.find("\"");
     nE = sText.find("\"", nL+1);
@@ -99,7 +101,7 @@ void convert_xrm::setLang(char *yytext)
   int          nL, nE;
 
 
-  if (mbIsTag)
+  if (mbIsTagHeader || mbIsTagPara)
   {
     nL = sText.find("\"");
     nE = sText.find("\"", nL+1);
@@ -123,7 +125,15 @@ void convert_xrm::setTag(char *yytext)
 
   msKey.clear();
   mbIsLang = false;
-  mbIsTag  = true;
+
+  // set correct tag
+  if (yytext[1] == 'p')
+    mbIsTagPara = true;
+  else
+  {
+    mbIsTagHeader = true;
+    miHeaderLevel = yytext[2] - '0';
+  }
 }
 
 
@@ -133,10 +143,10 @@ void convert_xrm::startCollectData(char 
 {
   copySource(yytext, mbNoCollectingData);
 
-  if (mbIsTag && mbIsLang && msKey.size())
+  if ((mbIsTagHeader || mbIsTagPara) && mbIsLang && msKey.size())
     mbNoCollectingData = false;
 
-  mbIsTag = mbIsLang = false;
+  mbIsTagHeader = mbIsTagPara = mbIsLang = false;
 }
 
 
@@ -144,12 +154,43 @@ void convert_xrm::startCollectData(char 
 /**********************   I M P L E M E N T A T I O N   **********************/
 void convert_xrm::stopCollectData(char *yytext)
 {
+  std::string       sTagStart, sTagText, sTagEnd, sLang, sText = msCollector;
+
+  copySource(yytext);
   if (!mbNoCollectingData)
   {
-    msKey = msKey + "." + msKey;
-    mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, msCollector);
+    mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, sText);
     mbNoCollectingData = true;
+  
+    if (mbMergeMode)
+    {
+      if (mbIsTagPara)
+      {
+        sTagStart = "<p ";
+        sTagEnd   = "</p>";
+      }
+      else
+      {
+        std::stringstream ss;
+        ss << miHeaderLevel;
+        sTagStart = "<h"  + ss.str()  + " ";
+        sTagEnd   = "</h" + ss.str()  + ">";
+      }
+
+      // prepare to read all languages
+      mcMemory.prepareMerge();
+      for (; mcMemory.getMergeLang(sLang, sText);)
+      {
+        // Prepare tag start and end
+        sTagText =                    sTagStart +
+                   "id=\""          + msKey     +
+                   "\" xml:lang=\"" + sLang     +
+                   "\">"            + sText     +
+                                      sTagEnd   +
+                   "\n";
+        writeSourceFile(sTagText);
+      }
+    }
     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=1458465&r1=1458464&r2=1458465&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l Tue Mar 19 19:27:05 2013
@@ -83,8 +83,8 @@ SP    [ \t]*
 
 
 
-"</h"[0-9] |
-"</p"      {
+"</h"[0-9]">"[ \t\r]*[\n] |
+"</p>"[ \t\r]*[\n]        {
   LOCptr->stopCollectData(yytext);
 }
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx?rev=1458465&r1=1458464&r2=1458465&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx Tue Mar 19 19:27:05 2013
@@ -95,8 +95,12 @@ void l10nMem::setSourceKey(int iL, const
      { l10nMem_impl::mcImpl->setSourceKey(iL, sF, sK, sT); }
 void l10nMem::save(const std::string& sT, bool bK, bool bF)
      { l10nMem_impl::mcImpl->save(*this, sT, bK, bF); }
+void l10nMem::prepareMerge()
+     { l10nMem_impl::mcImpl->mcDb.prepareMerge(); }
 void l10nMem::dumpMem(const std::string& sT)
      { l10nMem_impl::mcImpl->dumpMem(sT); }
+bool l10nMem::getMergeLang(std::string& sL, std::string& sT)
+     { return l10nMem_impl::mcImpl->mcDb.getMergeLang(sL, sT); }
 
 
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx?rev=1458465&r1=1458464&r2=1458465&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx Tue Mar 19 19:27:05 2013
@@ -128,6 +128,11 @@ class l10nMem_db
                          const std::string&   sKey,
                          const std::string&   sText,
                          l10nMem::ENTRY_STATE eStat);
+
+    void prepareMerge   ();
+    bool getMergeLang   (std::string& sLang,
+                         std::string& sText);
+
 };
 
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx?rev=1458465&r1=1458464&r2=1458465&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx Tue Mar 19 19:27:05 2013
@@ -385,3 +385,27 @@ void l10nMem_db::addKey(int             
     }
   }
 }
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void l10nMem_db::prepareMerge()
+{
+  miCurLangInx = 0;
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+bool l10nMem_db::getMergeLang(std::string& sLang,
+                                std::string& sText)
+{
+  miCurLangInx++;
+  if (miCurLangInx >= mcLangList.size())
+    return false;
+
+  // update pointers
+  sLang = mcLangList[miCurLangInx];
+  sText = mcENUSlist[miCurENUSinx].mcLangList[miCurLangInx].msText;
+  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=1458465&r1=1458464&r2=1458465&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gLang.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gLang.hxx Tue Mar 19 19:27:05 2013
@@ -87,6 +87,9 @@ class l10nMem
                        bool               bForce);
     void dumpMem      (const std::string& sTargetDir);
 
+    void prepareMerge ();
+    bool getMergeLang (std::string& sLang,
+                       std::string& sText);
 };