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/07/22 01:45:24 UTC

svn commit: r1505522 [2/3] - /openoffice/branches/l10n40/main/l10ntools/source/

Added: openoffice/branches/l10n40/main/l10ntools/source/gConUlfWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConUlfWrap.cxx?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConUlfWrap.cxx (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConUlfWrap.cxx Sun Jul 21 23:45:23 2013
@@ -0,0 +1,105 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+#include "gConUlf.hxx"
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+
+
+
+/*****************************************************************************
+ *********************   G C O N X C S W R A P . C X X   *********************
+ *****************************************************************************
+ * This includes the c code generated by flex
+ *****************************************************************************/
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+convert_ulf::convert_ulf(l10nMem& crMemory) : convert_gen_impl(crMemory) {}
+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();
+}
+
+
+
+/**********************   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);
+
+  // 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";
+
+
+  if (!bIsEnUs)
+    mcMemory.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);
+  if (mbMergeMode)
+  {
+    // prepare to read all languages
+    mcMemory.prepareMerge();
+    for (; mcMemory.getMergeLang(sLang, sText);)
+    {
+      // Prepare tag
+      sText = sLang + " = \"" + sText + "\"\n";
+      writeSourceFile(sText);
+    }
+  }
+}

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConUlfWrap.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConUlflex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConUlflex.l?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConUlflex.l (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConUlflex.l Sun Jul 21 23:45:23 2013
@@ -0,0 +1,123 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+/*****************************************************************************
+ **********************   L E X   D E F I N I T I O N   **********************
+ *****************************************************************************
+ * lex grammar for parsing ressource source files (*.ulf files)
+ * file is converted to gConUlf_yy.cxx with "flex"
+ *****************************************************************************/
+
+
+ 
+/***************   O V E R W R I T I N G   F U N C T I O N S   ***************/
+%{
+/* enlarge token buffer to tokenize whole std::strings */
+#undef  YYLMAX
+#define YYLMAX 64000
+
+/* change reader function (input) to our own version */
+#define YY_INPUT(buf,result,max_size) { IMPLptr->lexRead(buf, &result, max_size); }
+%}
+
+
+
+/*****************************   O P T I O N S   *****************************/
+/* 8bit               --> allow 8bit characters in the input stream          */
+/* noyywrap           --> yywrap is not called (single file scan)            */
+/* never-interactive  --> no check for console output                        */
+/* prefix=            --> yyFlexLexer change name                            */
+/* --- The following options are for future use (maybe)                      */
+/* yyclass=           --> subClass yyFlexLexer to allow own functions        */
+/* c++                --> generate C++ classes                               */
+%option 8bit noyywrap never-interactive
+%array
+%p 24000
+%e 1200
+%n 500
+
+/***********************   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   *******************/
+%%
+
+
+
+"/*" {
+  int i = 1;
+  for (;;)
+  {
+    while (yytext[i] != '*')
+      yytext[++i] = yyinput();
+    yytext[++i] = yyinput();
+    if (yytext[i] == '/')
+      break;
+  }
+  yytext[i+1] = '\0';
+
+  IMPLptr->copySource(yytext);
+}
+
+
+
+"\"".* {
+  LOCptr->setValue(yytext);
+}
+
+
+
+"["[^\]]+"]" {
+  LOCptr->setKey(yytext);
+}
+
+
+
+"en-US"[ \t]*"=" {
+  LOCptr->setText(yytext, true);
+}
+
+
+
+[a-zA-Z_\-]+[ \t]*"=" {
+  LOCptr->setText(yytext, false);
+}
+
+
+  
+.|\n {
+  IMPLptr->copySource(yytext);
+}
+%%
+
+
+
+void dummyJustForCompiler()
+{
+  char *txt = NULL;
+  yy_flex_strlen(txt);
+  yyunput(0, txt);
+}

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConUlflex.l
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXcs.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXcs.hxx?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXcs.hxx (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXcs.hxx Sun Jul 21 23:45:23 2013
@@ -0,0 +1,53 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+#ifndef GCONXCS_HXX
+#define GCONXCS_HXX
+#include "gCon.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_impl
+{
+  public:
+    convert_xcs(l10nMem& crMemory);
+    ~convert_xcs();
+
+    void setKey(char *syyText);
+    void unsetKey(char *syyText);
+    void startCollectData(char *syyText);
+    void stopCollectData(char *syyText);
+
+  private:
+    std::string msKey;
+    bool        mbCollectingData;
+
+    void execute();
+};
+#endif
\ No newline at end of file

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXcs.hxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXcsWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXcsWrap.cxx?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXcsWrap.cxx (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXcsWrap.cxx Sun Jul 21 23:45:23 2013
@@ -0,0 +1,159 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+#include "gConXcs.hxx"
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+
+
+
+/*****************************************************************************
+ *********************   G C O N X C S 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_xcs::convert_xcs(l10nMem& crMemory)
+                        : convert_gen_impl(crMemory),
+                          mbCollectingData(false)
+{
+}
+
+
+
+/************   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()
+{
+  // 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);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcs::unsetKey(char *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;
+}
+
+
+
+/**********************   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);
+    }
+#endif
+  }
+
+  mcMemory.setSourceKey(miLineNo, msSourceFile, sKey, sText);
+  mbCollectingData = false;
+}  

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXcsWrap.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXcslex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXcslex.l?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXcslex.l (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXcslex.l Sun Jul 21 23:45:23 2013
@@ -0,0 +1,91 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+/*****************************************************************************
+ **********************   L E X   D E F I N I T I O N   **********************
+ *****************************************************************************
+ * lex grammar for parsing ressource source files (*.xrm files)
+ * file is converted to gConXcs_yy.cxx with "flex"
+ *****************************************************************************/
+
+
+ 
+/***************   O V E R W R I T I N G   F U N C T I O N S   ***************/
+%{
+/* enlarge token buffer to tokenize whole std::strings */
+#undef  YYLMAX
+#define YYLMAX 64000
+
+/* change reader function (input) to our own version */
+#define YY_INPUT(buf,result,max_size) { IMPLptr->lexRead(buf, &result, max_size); }
+%}
+
+
+
+/*****************************   O P T I O N S   *****************************/
+/* 8bit               --> allow 8bit characters in the input stream          */
+/* noyywrap           --> yywrap is not called (single file scan)            */
+/* never-interactive  --> no check for console output                        */
+/* prefix=            --> yyFlexLexer change name                            */
+/* --- The following options are for future use (maybe)                      */
+/* yyclass=           --> subClass yyFlexLexer to allow own functions        */
+/* c++                --> generate C++ classes                               */
+%option 8bit noyywrap never-interactive
+%array
+%p 24000
+%e 1200
+%n 500
+
+
+
+/*******************   R U L E S   D E F I N I T I O N S   *******************/
+%%
+
+"<prop"[^>]*> {
+  LOCptr->setKey(yytext);
+}
+
+"</prop>" {
+  LOCptr->unsetKey(yytext);
+}
+  
+"<value"[^>]*> {
+  LOCptr->startCollectData(yytext);
+}
+
+"</value>" {
+  LOCptr->stopCollectData(yytext);
+}
+
+.|\n {
+  IMPLptr->copySource(yytext);
+}
+%%
+
+
+
+void dummyJustForCompiler()
+{
+  char *txt = NULL;
+  yy_flex_strlen(txt);
+  yyunput(0, txt);
+}

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXcslex.l
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXcu.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXcu.hxx?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXcu.hxx (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXcu.hxx Sun Jul 21 23:45:23 2013
@@ -0,0 +1,60 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+#ifndef GCONXCU_HXX
+#define GCONXCU_HXX
+#include "gCon.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_impl
+{
+  public:
+    bool mbNoCollectingData;
+
+    convert_xcu(l10nMem& crMemory);
+    ~convert_xcu();
+
+    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();
+
+  private:
+    std::vector<std::string> mcStack;
+    int                      miLevel;
+
+    void execute();
+};
+#endif
\ No newline at end of file

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXcu.hxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXcuWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXcuWrap.cxx?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXcuWrap.cxx (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXcuWrap.cxx Sun Jul 21 23:45:23 2013
@@ -0,0 +1,218 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+#include "gConXcu.hxx"
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+
+
+/*****************************************************************************
+ *********************   G C O N X C U 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_xcu::convert_xcu(l10nMem& crMemory)
+                        : convert_gen_impl(crMemory),
+                          mbNoCollectingData(true),
+                          miLevel(0)
+{
+}
+
+
+
+/************   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();
+}
+
+
+
+/**********************   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);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu::popKey(char *syyText)
+{
+  copySource(syyText);
+
+  // check for correct node/prop relations
+  if (mcStack.size())
+    mcStack.pop_back();
+}
+
+
+
+/**********************   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);
+
+  // 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")
+    {
+      std::string sErr = sTag.substr(nL,5) + " is not en-US";
+      mcMemory.showError(sErr);
+    }
+    else
+      mbNoCollectingData = false;
+  }
+}
+
+
+
+/**********************   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)
+    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);
+  }
+
+  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>";
+      writeSourceFile(sNewLine);
+    }
+  }
+}  
+
+
+
+/**********************   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::copyNL(char *syyText)
+{
+  int         nX    = msCollector.size();
+  std::string sText = copySource(syyText, mbNoCollectingData);
+
+  if (!mbNoCollectingData)
+  {
+    msCollector.erase(nX);
+    msCollector += ' ';
+  }
+}  
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu::addLevel()
+{
+  ++miLevel;
+}  

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXcuWrap.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXculex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXculex.l?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXculex.l (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXculex.l Sun Jul 21 23:45:23 2013
@@ -0,0 +1,140 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+ 
+
+/*****************************************************************************
+ **********************   L E X   D E F I N I T I O N   **********************
+ *****************************************************************************
+ * lex grammar for parsing ressource source files (*.xrm files)
+ * file is converted to gConXcu_yy.cxx with "flex"
+ *****************************************************************************/
+
+
+ 
+/***************   O V E R W R I T I N G   F U N C T I O N S   ***************/
+%{
+/* enlarge token buffer to tokenize whole std::strings */
+#undef  YYLMAX
+#define YYLMAX 64000
+
+/* change reader function (input) to our own version */
+#define YY_INPUT(buf,result,max_size) { IMPLptr->lexRead(buf, &result, max_size); }
+%}
+
+
+
+/*****************************   O P T I O N S   *****************************/
+/* 8bit               --> allow 8bit characters in the input stream          */
+/* noyywrap           --> yywrap is not called (single file scan)            */
+/* never-interactive  --> no check for console output                        */
+/* prefix=            --> yyFlexLexer change name                            */
+/* --- The following options are for future use (maybe)                      */
+/* yyclass=           --> subClass yyFlexLexer to allow own functions        */
+/* c++                --> generate C++ classes                               */
+%option 8bit noyywrap never-interactive
+%array
+%p 24000
+%e 1200
+%n 500
+
+
+
+/***********************   H E L P E R   M A C R O S   ***********************/
+SPACE [ \t]*
+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->addLevel();
+  LOCptr->pushKey(yytext);
+}
+
+
+
+"<prop"{NAME}{FIN} |
+"<node"{NAME}{FIN} {
+  LOCptr->pushKey(yytext);
+}
+
+
+
+"</oor:component-data" |
+"</prop"               |
+"</node"               {
+  LOCptr->popKey(yytext);
+}
+
+
+"<value xml:lang="\"[^\"]+\"[^>]*">" {
+  LOCptr->startCollectData(yytext);
+}
+
+
+
+"</value>" {
+  LOCptr->stopCollectData(yytext);
+}
+
+
+
+"&amp;"  |
+"&apos;" |
+"&gt;"   |
+"&lt;"   |
+"&quot;" {
+  LOCptr->copySpecial(yytext);
+}
+
+
+
+({SPACE}\n{SPACE})+ {
+  LOCptr->copyNL(yytext);
+}
+
+
+
+. {
+  IMPLptr->copySource(yytext, LOCptr->mbNoCollectingData);
+}
+
+
+
+%%
+
+
+
+void dummyJustForCompiler()
+{
+  char *txt = NULL;
+  yy_flex_strlen(txt);
+  yyunput(0, txt);
+}

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXculex.l
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXhp.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXhp.hxx?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXhp.hxx (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXhp.hxx Sun Jul 21 23:45:23 2013
@@ -0,0 +1,77 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+#ifndef GCONXHP_HXX
+#define GCONXHP_HXX
+#include "gCon.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_impl
+{
+  public:
+    convert_xhp(l10nMem& crMemory);
+    ~convert_xhp();
+
+    void setString(char *yytext);
+    void openTag(char *yytext);
+    void closeTag(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);
+
+  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();
+};
+#endif

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXhp.hxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXhpWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXhpWrap.cxx?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXhpWrap.cxx (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXhpWrap.cxx Sun Jul 21 23:45:23 2013
@@ -0,0 +1,435 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+#include "gConXhp.hxx"
+
+
+
+/*****************************************************************************
+ *********************   G C O N X H P 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_xhp::convert_xhp(l10nMem& crMemory)
+                        : convert_gen_impl(crMemory),
+                          meExpectValue(VALUE_NOT_USED),
+                          miCntLanguages(0),
+                          mcOutputFiles(NULL),
+                          msLangText(NULL)
+{
+  // xhp files are written through a local routine
+  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_xhp::~convert_xhp()
+{
+  if (mcOutputFiles)
+  {
+    for (int i = 0; i < miCntLanguages; ++i)
+      mcOutputFiles[i].close();
+    delete[] mcOutputFiles;
+  }
+  if (msLangText)
+    delete[] msLangText;
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+namespace XhpWrap
+{
+#define IMPLptr convert_gen_impl::mcImpl
+#define LOCptr ((convert_xhp *)convert_gen_impl::mcImpl)
+#include "gConXhp_yy.c"
+}
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::execute()
+{
+  std::string sLang;
+  std::string sFile, sFile2;
+
+  // prepare list with languages
+  miCntLanguages = mcMemory.prepareMerge();
+  if (mbMergeMode)
+  {
+    mcOutputFiles  = new std::ofstream[miCntLanguages];
+    msLangText     = new std::string[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");
+      }
+      msLangText[i] = "xml-lang=\"" + sLang + "\"";
+    }
+  }
+
+  // run analyzer
+  XhpWrap::yylex();
+
+  // dump last line
+  copySourceSpecial(NULL,3);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::setString(char *yytext)
+{
+  copySourceSpecial(yytext, 0);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::openTag(char *yytext)
+{
+  if (meExpectValue == VALUE_IS_VALUE)
+  {
+    meExpectValue  = VALUE_IS_VALUE_TAG;
+    msCollector   += "\\";
+  }
+  copySourceSpecial(yytext, 0);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::closeTag(char *yytext)
+{
+  STATE newState = meExpectValue;
+
+  switch (meExpectValue)
+  {
+    case VALUE_IS_VALUE_TAG:
+         newState = VALUE_IS_VALUE;
+         msCollector   += "\\";
+         break;
+
+    case VALUE_IS_TAG_TRANS:
+         if (msKey.size())
+           newState = VALUE_IS_VALUE;
+         break;
+
+    case VALUE_IS_TAG:
+         msKey.clear();
+         newState = VALUE_NOT_USED;
+         break;
+    case VALUE_NOT_USED:
+    case VALUE_IS_VALUE:
+         break;
+  }
+  copySourceSpecial(yytext, 0);
+  meExpectValue = newState;
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::setId(char *yytext)
+{
+  int          nL, nE;
+  std::string& sText = copySourceSpecial(yytext, 0);
+
+
+  nL = sText.find("\"");
+  nE = sText.find("\"", nL+1);
+  if (nL == (int)std::string::npos || nE == (int)std::string::npos)
+    return;
+
+  switch (meExpectValue)
+  {
+    case VALUE_IS_TAG:
+    case VALUE_IS_TAG_TRANS:
+         msKey = sText.substr(nL+1, nE - nL -1) + msKey;
+         break;
+
+    case VALUE_IS_VALUE_TAG:
+    case VALUE_NOT_USED:
+    case VALUE_IS_VALUE:
+         break;
+  }
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::setLang(char *yytext)
+{
+  int          nL, nE;
+  std::string  sLang;
+  std::string& sText = copySourceSpecial(yytext, 1);
+
+
+  nL = sText.find("\"");
+  nE = sText.find("\"", nL+1);
+  if (nL == (int)std::string::npos || nE == (int)std::string::npos)
+    return;
+
+  switch (meExpectValue)
+  {
+    case VALUE_IS_TAG:
+         sLang = sText.substr(nL+1, nE - nL -1);
+         if (sLang == "en-US")
+           meExpectValue = VALUE_IS_TAG_TRANS;
+         else
+          mcMemory.showError(sLang + " is no en-US language");
+         break;
+
+    case VALUE_IS_VALUE_TAG:
+         msCollector.erase(msCollector.size() - sText.size() -1);
+         break;
+
+    case VALUE_NOT_USED:
+    case VALUE_IS_TAG_TRANS:
+    case VALUE_IS_VALUE:
+         break;
+  }
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::setRef(char *yytext)
+{
+  int          nL, nE;
+  std::string& sText = copySourceSpecial(yytext, 0);
+
+
+  nL = sText.find("\"");
+  nE = sText.find("\"", nL+1);
+  if (nL == (int)std::string::npos || nE == (int)std::string::npos)
+    return;
+
+  switch (meExpectValue)
+  {
+    case VALUE_IS_TAG:
+    case VALUE_IS_TAG_TRANS:
+         msKey += "." + sText.substr(nL+1, nE - nL -1);
+         break;
+
+    case VALUE_IS_VALUE_TAG:
+    case VALUE_NOT_USED:
+    case VALUE_IS_VALUE:
+         break;
+  }
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::openTransTag(char *yytext)
+{
+  copySourceSpecial(yytext, 0);
+  msKey.clear();
+  meExpectValue = VALUE_IS_TAG;
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::closeTransTag(char *yytext)
+{
+  int iType = 0;
+
+
+  if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG)
+  {
+    if (msCollector.size() && msCollector != "-")
+      mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, msCollector);
+    msKey.clear();
+    iType = 2;
+  }
+  meExpectValue = VALUE_NOT_USED;
+  copySourceSpecial(yytext, iType);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::stopTransTag(char *yytext)
+{
+  copySourceSpecial(yytext, 0);
+  meExpectValue = VALUE_NOT_USED;
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::startComment(char *yytext)
+{
+  mePushValue   = meExpectValue;
+  msPushCollect = msCollector;
+  meExpectValue = VALUE_NOT_USED;
+  copySourceSpecial(yytext, 0);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::stopComment(char *yytext)
+{
+  copySourceSpecial(yytext, 0);
+  meExpectValue = mePushValue;
+  msCollector   = msPushCollect;
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::handleSpecial(char *yytext)
+{
+  int          nX    = msCollector.size();
+  std::string& sText = copySourceSpecial(yytext, 0);
+
+
+  if (meExpectValue != VALUE_IS_VALUE || meExpectValue != VALUE_IS_VALUE_TAG)
+  {
+    msCollector.erase(nX);
+    if      (sText == "&amp;")
+      msCollector += "&";
+    else if (sText == "&lt;")
+      msCollector += "<";
+    else if (sText == "&gt;")
+      msCollector += ">";
+    else if (sText == "&quot;")
+      msCollector += "\"";
+  }
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::handleDataEnd(char *yytext)
+{
+  int nX = msCollector.size();
+  copySourceSpecial(yytext, 0);
+
+  if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG)
+    msCollector.erase(nX);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xhp::duplicate(char *yytext)
+{
+  copySourceSpecial(yytext, 0);
+
+  if (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG)
+    msCollector += msCollector[msCollector.size()-1];
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+std::string& convert_xhp::copySourceSpecial(char *yytext, int iType)
+{
+  bool         doingValue = (meExpectValue == VALUE_IS_VALUE || meExpectValue == VALUE_IS_VALUE_TAG);
+  std::string& sText      = copySource(yytext, !doingValue);
+  std::string  sLang;
+  int          i;
+
+
+  // Do NOT write data while collecting a value (will be replaced by language text)
+  if (doingValue)
+    return sText;
+
+  // Handling depends o
+  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 language token, are to replaced with languages
+            if (mbMergeMode)
+            {
+              for (i = 0; i < miCntLanguages; ++i)
+              {
+                writeSourceFile(msLine, i);
+                writeSourceFile(msLangText[i], 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, sText);
+                writeSourceFile(sText,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_xhp::writeSourceFile(std::string& sText, int inx)
+{
+  if (sText.size() && mcOutputFiles[inx].is_open())
+    mcOutputFiles[inx].write(sText.c_str(), sText.size());
+}

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXhpWrap.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXhplex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXhplex.l?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXhplex.l (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXhplex.l Sun Jul 21 23:45:23 2013
@@ -0,0 +1,171 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+/*****************************************************************************
+ **********************   L E X   D E F I N I T I O N   **********************
+ *****************************************************************************
+ * lex grammar for parsing ressource source files (*.xrm files)
+ * file is converted to gConXrm_yy.cxx with "flex"
+ *****************************************************************************/
+
+
+ 
+/***************   O V E R W R I T I N G   F U N C T I O N S   ***************/
+%{
+/* enlarge token buffer to tokenize whole std::strings */
+#undef  YYLMAX
+#define YYLMAX 64000
+
+/* change reader function (input) to our own version */
+#define YY_INPUT(buf,result,max_size) { IMPLptr->lexRead(buf, &result, max_size); }
+%}
+
+
+
+/*****************************   O P T I O N S   *****************************/
+/* 8bit               --> allow 8bit characters in the input stream          */
+/* noyywrap           --> yywrap is not called (single file scan)            */
+/* never-interactive  --> no check for console output                        */
+/* prefix=            --> yyFlexLexer change name                            */
+/* --- The following options are for future use (maybe)                      */
+/* yyclass=           --> subClass yyFlexLexer to allow own functions        */
+/* c++                --> generate C++ classes                               */
+%option 8bit noyywrap never-interactive
+%array
+%p 24000
+%e 1200
+%n 500
+
+
+
+/***********************   H E L P E R   M A C R O S   ***********************/
+SP [ \t]*
+IDENT [\.a-zA-Z0-9_-]+
+/*******************   R U L E S   D E F I N I T I O N S   *******************/
+%%
+
+
+
+\" {
+  LOCptr->setString(yytext);
+}
+
+
+
+\< {
+  LOCptr->openTag(yytext);
+}
+
+
+
+\> {
+  LOCptr->closeTag(yytext);
+}
+
+
+
+"id="{SP}\"{SP}{IDENT}{SP}\" {
+  LOCptr->setId(yytext);
+}
+
+
+
+"xml-lang="{SP}\"{SP}{IDENT}{SP}\" {
+  LOCptr->setLang(yytext);
+}
+
+
+
+"oldref="{SP}\"{SP}{IDENT}{SP}\" {
+  LOCptr->setRef(yytext);
+}
+
+
+"<title "     |
+"<bookmark "  |
+"<paragraph " {
+  LOCptr->openTransTag(yytext);
+}
+
+
+"</title>"     |
+"</bookmark>"  |
+"</paragraph>" {
+  LOCptr->closeTransTag(yytext);
+}
+
+
+
+"<comment>" {
+  LOCptr->startComment(yytext);
+}
+
+
+
+"</comment>" {
+  LOCptr->stopComment(yytext);
+}
+
+
+
+"localize=\"false\"" {
+  LOCptr->stopTransTag(yytext);
+}
+
+
+
+"&amp;"  |
+"&gt;"   |
+"&lt;"   |
+"&quot;" {
+  LOCptr->handleSpecial(yytext);
+}
+
+
+\r*\n\t* {
+  LOCptr->handleDataEnd(yytext);
+}
+
+
+
+\\ {
+  LOCptr->duplicate(yytext);
+}
+
+
+
+.|\n {
+  LOCptr->copySourceSpecial(yytext, 0);
+}
+
+
+
+%%
+
+
+
+void dummyJustForCompiler()
+{
+  char *txt = NULL;
+  yy_flex_strlen(txt);
+  yyunput(0, txt);
+}

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXhplex.l
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXrm.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXrm.hxx?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXrm.hxx (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXrm.hxx Sun Jul 21 23:45:23 2013
@@ -0,0 +1,57 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+#ifndef GCONXRM_HXX
+#define GCONXRM_HXX
+#include "gCon.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_impl
+{
+  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();
+};
+#endif

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXrm.hxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXrmWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXrmWrap.cxx?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXrmWrap.cxx (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXrmWrap.cxx Sun Jul 21 23:45:23 2013
@@ -0,0 +1,174 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+#include "gConXrm.hxx"
+
+
+/*****************************************************************************
+ *********************   G C O N X R M 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_xrm::convert_xrm(l10nMem& crMemory)
+                        : convert_gen_impl(crMemory),
+                          mbNoCollectingData(true),
+                          mbIsTag(false),
+                          mbIsLang(false)
+{
+}
+
+
+
+/************   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()
+{
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+namespace XrmWrap
+{
+#define IMPLptr convert_gen_impl::mcImpl
+#define LOCptr ((convert_xrm *)convert_gen_impl::mcImpl)
+#include "gConXrm_yy.c"
+}
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xrm::execute()
+{
+  XrmWrap::yylex();
+
+  // write last part of file.
+  if (mbMergeMode)
+    writeSourceFile(msCollector);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xrm::setId(char *yytext)
+{
+  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;
+
+    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::setLang(char *yytext)
+{
+  std::string& sText = copySource(yytext, mbNoCollectingData);
+  std::string  sLang;
+  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;
+
+    sLang = sText.substr(nL+1, nE - nL -1);
+    if (sLang == "en-US")
+      mbIsLang = true;
+    else
+      mcMemory.showError(sLang + " is no en-US language");
+  }
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xrm::setTag(char *yytext)
+{
+  msTag = copySource(yytext);
+
+  msKey.clear();
+  mbIsLang = false;
+  mbIsTag  = true;
+}
+
+
+
+/**********************   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)
+{
+  std::string sTagText, sTagEnd, sLang, sText = msCollector;
+
+  copySource(yytext);
+  if (!mbNoCollectingData)
+  {
+    mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, sText);
+    mbNoCollectingData = true;
+  
+
+    if (mbMergeMode)
+    {
+      sTagEnd  = "</" + msTag.substr(1,msTag.size()-2) + ">\n";
+      msTag   += "id=\"" + msKey + "\" xml:lang=\"";
+
+      // prepare to read all languages
+      mcMemory.prepareMerge();
+      for (; mcMemory.getMergeLang(sLang, sText);)
+      {
+        // replace \" with "
+        for (int i = 0; (i = sText.find("\\\"", i)) != std::string::npos;)
+          sText.erase(i,1);
+
+        // Prepare tag start and end
+        sTagText = msTag + sLang + "\">" + sText + sTagEnd;
+        writeSourceFile(sTagText);
+      }
+    }
+    msKey.clear();
+  }
+  mbIsTag = false;
+}  

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXrmWrap.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gConXrmlex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gConXrmlex.l?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gConXrmlex.l (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gConXrmlex.l Sun Jul 21 23:45:23 2013
@@ -0,0 +1,111 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+/*****************************************************************************
+ **********************   L E X   D E F I N I T I O N   **********************
+ *****************************************************************************
+ * lex grammar for parsing ressource source files (*.xrm files)
+ * file is converted to gConXrm_yy.cxx with "flex"
+ *****************************************************************************/
+
+
+ 
+/***************   O V E R W R I T I N G   F U N C T I O N S   ***************/
+%{
+/* enlarge token buffer to tokenize whole std::strings */
+#undef  YYLMAX
+#define YYLMAX 64000
+
+/* change reader function (input) to our own version */
+#define YY_INPUT(buf,result,max_size) { IMPLptr->lexRead(buf, &result, max_size); }
+%}
+
+
+
+/*****************************   O P T I O N S   *****************************/
+/* 8bit               --> allow 8bit characters in the input stream          */
+/* noyywrap           --> yywrap is not called (single file scan)            */
+/* never-interactive  --> no check for console output                        */
+/* prefix=            --> yyFlexLexer change name                            */
+/* --- The following options are for future use (maybe)                      */
+/* yyclass=           --> subClass yyFlexLexer to allow own functions        */
+/* c++                --> generate C++ classes                               */
+%option 8bit noyywrap never-interactive
+%array
+%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   *******************/
+%%
+
+
+
+"id"{SP}"="{SP}{NAME} {
+  LOCptr->setId(yytext);
+}
+
+
+
+"lang"{SP}"="{SP}{NAME} {
+  LOCptr->setLang(yytext);
+}
+
+
+
+"<h"[0-9]" " |
+"<p "        {
+  LOCptr->setTag(yytext);
+}
+
+
+
+"</h"[0-9]">"[ \t\r]*[\n] |
+"</p>"[ \t\r]*[\n]        {
+  LOCptr->stopCollectData(yytext);
+}
+
+
+
+">" {
+  LOCptr->startCollectData(yytext);
+}
+
+
+
+.|\n {
+  IMPLptr->copySource(yytext, LOCptr->mbNoCollectingData);
+}
+
+
+%%
+
+void dummyJustForCompiler()
+{
+  char *txt = NULL;
+  yy_flex_strlen(txt);
+  yyunput(0, txt);
+}

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gConXrmlex.l
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx?rev=1505522&view=auto
==============================================================================
--- openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx (added)
+++ openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx Sun Jul 21 23:45:23 2013
@@ -0,0 +1,495 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+#include <iostream>
+#include "gLang.hxx"
+#include <cstdlib>
+#include <iostream>
+#include <fstream>
+
+
+
+/*****************************************************************************
+ ************************   G H A N D L E R . C X X   ************************
+ *****************************************************************************
+ * This is the control module, that interpret the command line and implement
+ * the different work types 
+ *     extract / merge / generate / convert
+ *****************************************************************************/
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+handler::handler()
+                :
+                 mbForceSave(false)
+{
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+handler::~handler()
+{
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void handler::checkCommandLine(int argc, char *argv[])
+{
+  enum {ARG_NONE, ARG_F, ARG_O, ARG_S, ARG_T} eGotArg = ARG_NONE;
+  std::string sWorkText, sLangText;
+  int         argNow, nLen;
+  bool        bKid = false;
+
+
+  // make internal throw test (to avoid if cascades
+  try
+  {
+    // check for fixed parameter: genLang <cmd> <module> <po dir> <languages>
+    if (argc <= 5)
+      throw "Not enough parameters";
+
+    // check for working mode
+    sWorkText = argv[1];
+    if      (sWorkText == "convert")  meWorkMode = DO_CONVERT;
+    else if (sWorkText == "extract")  meWorkMode = DO_EXTRACT;
+    else if (sWorkText == "merge")    meWorkMode = DO_MERGE;
+    else if (sWorkText == "generate") meWorkMode = DO_GENERATE;
+    else if (sWorkText == "help")     showManual();
+    else                              throw "<command> is mandatory";
+
+    // and set fixed parameters
+    msModuleName = argv[2];
+    msPoOutDir   = msPoDir = argv[3];
+    sLangText    = argv[4];
+    if (sLangText[0] == '\"')
+      sLangText.erase(0,1);
+    nLen = sLangText.size() -1;
+    if (nLen > 0 && sLangText[nLen] == '\"')
+      sLangText.erase(nLen);
+    
+    // decode parameters and translate to variables
+    for (argNow = 5; argNow < argc;)
+    {
+      std::string sArg(argv[argNow++]);
+
+      // all -x is followed by a directory/file name
+      if (sArg[0] == '-')
+      {
+        // Terminate collection ?
+        if (eGotArg == ARG_F)
+          eGotArg = ARG_NONE;
+
+        // Are we waiting for a directory
+        if (eGotArg != ARG_NONE)
+          throw std::string("missing argument to ") + argv[argNow-1];
+
+        // is it a known parameter
+        if      (sArg == "-d") {l10nMem::setShowDebug();               }
+        else if (sArg == "-f") {eGotArg   = ARG_F;                     }
+        else if (sArg == "-k") {bKid      = true;                      }
+        else if (sArg == "-o") {eGotArg   = ARG_O; mbForceSave = true; }      
+        else if (sArg == "-s") {eGotArg   = ARG_S;                     }
+        else if (sArg == "-t") {eGotArg   = ARG_T;                     }
+        else if (sArg == "-v") {l10nMem::setShowVerbose();             }
+        else throw std::string("unknown parameter: ") + sArg;
+      }
+      else
+      {
+        switch (eGotArg)
+        {
+          case ARG_NONE:                                       break;
+          case ARG_F: mvSourceFiles.push_back(sArg);           break;
+          case ARG_O: msPoOutDir   = sArg; eGotArg = ARG_NONE; break;
+          case ARG_S: msSourceDir  = sArg; eGotArg = ARG_NONE; break;
+          case ARG_T: msTargetDir  = sArg; eGotArg = ARG_NONE; break;
+       }
+      }
+    }
+
+    // Check parameters mandatory for all commands
+    if (!msModuleName.size())
+      throw "<module name> is mandatory";
+    if (!msPoDir.size())
+      throw "<po dir> is mandatory";
+    if (!sLangText.size())
+      throw "<languages> is mandatory";
+
+    // check parameters according to function
+    if (mvSourceFiles.size())
+    {
+      if (meWorkMode == DO_GENERATE)
+        throw "-f <files> is not valid with \"generate\"";
+    }
+    else
+    {
+      if (meWorkMode == DO_CONVERT || meWorkMode == DO_EXTRACT || meWorkMode == DO_MERGE)
+        throw "-f <files> is mandatory";
+    }
+    if (msTargetDir.size())
+    {
+      if (meWorkMode != DO_MERGE)
+        throw "-t <target dir> is only valid using \"merge\"";
+    }
+    else
+    {
+      if (meWorkMode == DO_MERGE)
+        throw "-t <target dir> is mandatory";
+    }
+    if (!convert_gen::checkAccess(msTargetDir))
+      throw "<target dir> does not exist";
+
+    if (msSourceDir.size())
+    {
+      if (meWorkMode == DO_GENERATE)
+        throw "-s <source dir> is only valid using \"extract\", \"merge\" and \"convert\"";
+    }
+    else
+    {
+      if (meWorkMode != DO_GENERATE)
+        throw "-s <source dir> is mandatory";
+    }
+    if (!convert_gen::checkAccess(msSourceDir))
+      throw "<source dir> does not exist";
+
+    // Key Identification generation
+    if (bKid)
+    {
+      if (meWorkMode != DO_MERGE)
+        throw "-k is only valid with \"merge\"";
+      else
+      {
+         meWorkMode = DO_MERGE_KID;
+         sWorkText += "(KID)";
+      }
+    }
+  }
+  catch(const char *sErr)
+  {
+    std::string myErr(sErr);
+    showUsage(myErr);
+    exit(-1);
+  }
+  catch(std::string sErr)
+  {
+    showUsage(sErr);
+    exit(-1);
+  }
+
+  // update directories to include final /
+  nLen = msSourceDir.size();
+  if (nLen && msSourceDir.at(nLen-1) != '/')
+    msSourceDir.append("/");
+  nLen = msTargetDir.size();
+  if (nLen && msTargetDir.at(nLen-1) != '/')
+    msTargetDir.append("/");
+  nLen = msPoDir.size();
+  if (nLen && msPoDir.at(nLen-1) != '/')
+    msPoDir.append("/");
+  nLen = msPoOutDir.size();
+  if (nLen && msPoOutDir.at(nLen-1) != '/')
+    msPoOutDir.append("/");
+
+  // and convert language to a vector
+  int current;
+  int next = -1;
+  do
+  {
+    current = next + 1;
+    next = sLangText.find_first_of( " ", current );
+    std::string sNewLang = sLangText.substr(current,next-current);
+    if (sNewLang != "en-US")
+      mvLanguages.push_back(sLangText.substr(current,next-current));
+  }
+  while (next != (int)std::string::npos);
+
+  // check if source files list needs to be coverted
+  if (mvSourceFiles[0] == "USEFILE:")
+    readFileWithSources();
+
+  // tell system
+  l10nMem::showVerbose("gLang starting to " + sWorkText + " from module " + msModuleName);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void handler::run()
+{
+  try
+  {
+    // prepare translation memory to module type
+    mcMemory.setModuleName(msModuleName);
+
+    // build list of languages (to be loaded and later written
+    if (msPoDir.size())
+      loadL10MEM();
+
+    // use workMode to start correct control part
+    switch (meWorkMode)
+    {
+      case DO_EXTRACT:   runExtractMerge(false, false); break;
+      case DO_MERGE:     runExtractMerge(true,  false); break;
+      case DO_MERGE_KID: runExtractMerge(true,  true);  break;
+      case DO_CONVERT:   runConvert();                  break;
+      case DO_GENERATE:  runGenerate();                 break;
+    }
+  }
+  catch(int)
+  {
+    exit(-1);
+  }
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void handler::runExtractMerge(bool bMerge, bool bKid)
+{
+  // loop through all source files, and extract messages from each file
+  for (std::vector<std::string>::iterator siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource)
+  {
+    // tell system
+    l10nMem::showDebug("gLang extracting text from file " + msSourceDir + *siSource);
+
+    // get converter and extract file
+    convert_gen convertObj(mcMemory, msSourceDir, msTargetDir, *siSource);
+    convertObj.execute(bMerge);
+  }
+
+  // and generate language file
+  mcMemory.save(msPoOutDir, bKid, mbForceSave);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void handler::runConvert()
+{
+  // loop through all languages
+  for (std::vector<std::string>::iterator siLang = mvLanguages.begin(); siLang != mvLanguages.end(); ++siLang)
+  {
+    // get converter and extract files
+    mcMemory.setLanguage(*siLang, false, true);
+
+    // loop through all source files, and extract messages from each file
+    for (std::vector<std::string>::iterator siSource = mvSourceFiles.begin(); siSource != mvSourceFiles.end(); ++siSource)
+    {
+      std::string sFilePath = msSourceDir + *siLang + "/";
+
+        // tell system
+      l10nMem::showDebug("gLang convert text from file " + sFilePath + *siSource);
+
+      // get converter and extract files
+      convert_gen convertObj(mcMemory, sFilePath, msTargetDir, *siSource);
+      convertObj.execute(true);
+    }
+  }
+
+  // and generate language file
+  mcMemory.save(msPoOutDir, false, mbForceSave);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void handler::runGenerate()
+{
+  mcMemory.dumpMem(msPoOutDir);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void handler::showUsage(std::string& sErr)
+{
+  // do we have an error text ?
+  if (sErr.size())
+    std::cerr << "commandline error:" << sErr << std::endl;
+
+  std::cout <<
+    "syntax oveview, use \"genLang help\" for full description\n"
+    "genLang <cmd> <module> <po dir> <languages> [-d] [-f <files>] [-k] [-o <dir>] [-s <dir>] [-t <dir>] [-v]\n"
+    "<cmd> is one of \"convert\", \"extract\", \"generate\", \"help\", \"merge\",\n";
+
+  exit(-1);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void handler::showManual()
+{
+  // give the correct usage
+  std::cout <<
+    "genLang (c)2013 by Apache Software Foundation\n"
+    "=============================================\n"
+    "As part of the L10N framework for Apache Open Office (AOO),\n"
+    "genLang extracts en-US texts sources of the following types:\n"
+    "  .xrm, .xhp, .xcu, .xcs, .ulf, .tree, .src, .prop and .po\n"
+    "and merges with .po files in different languages.\n"
+    "genLang merges .po files with AOO sources to add languages.\n"
+    "\n"
+    "genLang can also convert old .po files (generated from .sdf)\n"
+    "\n";
+
+  std::cout <<
+    "Syntax:\n"
+    "  genLang extract <module> <po dir> <languages> [-v] [-d]\\\n"
+    "          [-o <po outdir>]  -f <files> -s <source dir>\n"
+    "    reads <po dir>/*lang/<module>.po files and extract text\n"
+    "    from <source dir>/<files>, result is merged and\n"
+    "    written to <po outdir>/*lang/<module>.po if -o present\n"
+    "    or <po dir>/*lang/<module>.po is overwritten\n"
+    "    - Keys in .po files, not in sources files (deleted keys)\n"
+    "      are shown as warnings\n"
+    "    - Keys in .po files, with changed text in the source\n"
+    "      are marked \"fuzzy\"\n"
+    "    - Keys in source files not in .po files (new keys)\n"
+    "      are added and marked \"fuzzy\"\n"
+    "\n"
+    "  genLang merge <module> <po dir> <languages> [-v] [-d] [-k]\\\n"
+    "          [-o <po outdir>]  -f <files> -s <source dir> \\\n"
+    "          -t <target dir>\n"
+    "    works as \"extract\" and additionally merges\n"
+    "    <source dir>/<files> with all native language text\n"
+    "    from <po dir>/*lang/<module>.po\n"
+    "    The result is stored in <target dir>/<files>\n"
+    "\n"
+    "  genLang convert <module> <po dir> <languages> [-v] [-d]\\\n"
+    "          [-o <po outdir>] -s <source dir> -f <files>\n"
+    "    reads sdf generated .po <files> from\n"
+    "    <source dir>/*lang/<module>.po\n"
+    "    and merges with\n"
+    "    <po dir>/*lang/<module>.po\n"
+    "    Result is written to <po outdir>/*lang/<module>.po if\n"
+    "    present or <po dir>/*lang/<module>.po is overwritten\n"
+    "    - Keys in <source dir>, not in <module>.po\n"
+    "      are shown as warnings\n"
+    "    - Keys in <source dir>, with changed translation\n"
+    "      are marked \"fuzzy\"\n"
+    "\n"
+    "  genLang generate <module> <po dir> <languages> [-v] [-d]\\\n"
+    "          [-o <po outdir>]\n"
+    "    reads .po <files> and generates a \"bin\" file for fast loading\n"
+    "    Result is written to <po outdir>/<module>.dbpo if\n"
+    "    present or <po dir>/<module>.dbpo\n"
+    "\n"
+    "  genLang help\n"
+    "    this text\n"
+    "\n";
+
+  std::cout <<
+    "Parameters:\n"
+    "  <module>\n"
+    "     name of module (directory in main)\n"
+    "  <po dir>\n"
+    "     directory containing a directory for each language which contains\n"
+    "     a .po file for each module or a module.dbpo file for fast loading\n"
+    "  <languages>\n"
+    "     comma separated string with langauge id to be used\n"
+    "\n"   
+    "  -d\n"
+    "     extensive verbose mode, tells what gLang is doing in detail\n"
+    "  -f <files>\n"
+    "     list of files containing messages to be extracted\n"
+    "     \"convert\" expect sdf generated po files, to be converted\n"
+    "     instead of passing a list of files, it is possible to pass\n"
+    "     a file contains the list, by using:\n"
+    "     -f USEFILE: <filename>\n"
+    "  -k\n"
+    "     generate kid id (hex) for all messages in the source code,\n"
+    "     solely for QA\n"
+    "  -o <po outdir>\n"
+    "     directory to write .po files, same structure as -p\n"
+    "  -s <source dir>\n"
+    "     directory containing all source files (root path for <files>\n"
+    "  -t <target dir>\n"
+    "     <directory> used to write merged source files (root path for <files>\n"
+    "  -v\n"
+    "     verbose mode, tells what gLang is doing\n";
+
+  exit(0);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void handler::loadL10MEM()
+{
+  std::string sMod  = msModuleName + ".po";
+  std::string sLoad = msPoDir + "en-US/";
+
+
+  // load texts from en-US po file (master)
+  {
+    // tell system
+    l10nMem::showDebug("gLang loading master text from file " + sLoad + sMod);
+
+    // and load file
+    mcMemory.setLanguage("", true, false);
+    convert_gen (mcMemory, sLoad, msTargetDir, sMod).execute(false);
+  }
+
+  // loop through all languages and load text
+  for (std::vector<std::string>::iterator siLang = mvLanguages.begin(); siLang != mvLanguages.end(); ++siLang)
+  {
+    sLoad = msPoDir + *siLang + "/";
+
+    // get converter and extract files
+    mcMemory.setLanguage(*siLang, true, false);
+
+    // tell system
+    l10nMem::showDebug("gLang loading text from language file " + sLoad + sMod);
+
+    convert_gen(mcMemory, sLoad, msTargetDir, sMod).execute(false);
+  }
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void handler::readFileWithSources()
+{
+  std::ifstream fInput;
+  char          buf[256];
+
+
+  if (mvSourceFiles.size() < 2)
+    throw l10nMem::showError("missing file with sources (-f USEFILE: <filename>)");
+
+  fInput.open (mvSourceFiles[1].c_str(), std::ifstream::in);
+  if (!fInput.is_open())
+    throw l10nMem::showError("Cannot open file with sources (-f), trying to open" + mvSourceFiles[1]);
+
+  mvSourceFiles.clear();
+
+  while (fInput.good())
+  {
+    fInput.getline(buf, sizeof(buf));
+    if (!buf[0])
+      continue;
+    mvSourceFiles.push_back(buf);
+  }
+
+  fInput.close();
+}

Propchange: openoffice/branches/l10n40/main/l10ntools/source/gHandler.cxx
------------------------------------------------------------------------------
    svn:executable = *