openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1416635 - in /openoffice/branches/l10n/main/l10ntools/source: gConPo.cxx gConPo.hxx gConPoWrap.cxx gConPolex.l
Date Mon, 03 Dec 2012 18:45:22 GMT
Author: jani
Date: Mon Dec  3 18:45:21 2012
New Revision: 1416635

URL: http://svn.apache.org/viewvc?rev=1416635&view=rev
Log:
Po file conversion

Added:
    openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/gConPolex.l   (with props)

Added: openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx?rev=1416635&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx Mon Dec  3 18:45:21 2012
@@ -0,0 +1,102 @@
+/**************************************************************
+ * 
+ * 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.
+ * 
+ *************************************************************/
+using namespace std;
+#include "gConXcu.hxx"
+
+
+
+/*****************************************************************************
+ *************************   G C O N X C U . C X X   *************************
+ *****************************************************************************
+ * This is the conversion for .xcu files
+ *****************************************************************************/
+
+
+
+/*****************************   G L O B A L S   *****************************/
+convert_xcu_impl * convert_xcu::mcpImpl;
+
+
+
+/************   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(const string& srSourceFile, l10nMem& crMemory)
+                        : convert_gen(srSourceFile, crMemory) 
+                          {mcpImpl = new convert_xcu_impl(srSourceFile, crMemory);}
+convert_xcu::~convert_xcu() {delete mcpImpl;}
+void convert_xcu::extract() {mcpImpl->extract();}
+void convert_xcu::insert()  {mcpImpl->insert();}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+xcu_stack_entry::xcu_stack_entry(TAG_TYPE sIsNode, string& sName)
+                                : mbIsNode (sIsNode),
+                                  msName   (sName)
+{
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+xcu_stack_entry::~xcu_stack_entry()
+{
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+convert_xcu_impl::convert_xcu_impl(const string& srSourceFile, l10nMem& crMemory)
+                                  : convert_gen (srSourceFile, crMemory)
+{
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+convert_xcu_impl::~convert_xcu_impl()
+{
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu_impl::extract()
+{
+  // generate l10mMem
+  mbMergeMode = false;
+
+  // run lex parser and build token tree
+  runLex();
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu_impl::insert()
+{
+  // generate source files.
+  mbMergeMode = true;
+
+  // run lex parser and build token tree
+  runLex();
+}
+
+

Propchange: openoffice/branches/l10n/main/l10ntools/source/gConPo.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx?rev=1416635&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx Mon Dec  3 18:45:21 2012
@@ -0,0 +1,78 @@
+/**************************************************************
+ * 
+ * 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 "gLang.hxx"
+#include <stack>
+
+
+
+/*****************************************************************************
+ *************************   G C O N X C U . H X X   *************************
+ *****************************************************************************
+ * This is the class header for .xcu conversion
+ *****************************************************************************/
+typedef enum {TAG_COMPONENT, TAG_PROP, TAG_NODE } TAG_TYPE;
+
+
+
+/********************   C L A S S   D E F I N I T I O N   ********************/
+class xcu_stack_entry
+{
+  public:
+    xcu_stack_entry(TAG_TYPE sIsNode, string& sName);
+    ~xcu_stack_entry();
+
+    TAG_TYPE mbIsNode;
+    string   msName;
+};
+
+
+
+
+/********************   C L A S S   D E F I N I T I O N   ********************/
+class xcu_stack_entry;
+class convert_xcu_impl : public convert_gen
+{
+  public:
+    convert_xcu_impl(const string& srSourceFile, l10nMem& crMemory);
+    ~convert_xcu_impl();
+
+    void pushKeyPart(TAG_TYPE eIsNode, string &sTag);
+    void popKeyPart (TAG_TYPE eIsNode, string &sTag);
+
+    void startCollectData(string& sCollectedText);
+    void stopCollectData(string& sCollectedText);
+    void collectData(string& sCollectedText);
+
+  private:
+    stack<xcu_stack_entry> mcStack;
+    bool                   mbMergeMode;
+    bool                   mbCollectingData;
+    string                 msCollector;
+
+    void extract();
+    void insert();
+    void runLex();
+
+    friend class convert_xcu;
+};
+#endif
\ No newline at end of file

Propchange: openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx?rev=1416635&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx Mon Dec  3 18:45:21 2012
@@ -0,0 +1,138 @@
+/**************************************************************
+ * 
+ * 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.
+ * 
+ *************************************************************/
+using namespace std;
+#include "gConXcu.hxx"
+
+
+
+/*****************************************************************************
+ *********************   G C O N X C U 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   **********************/
+#include "gConXcu_yy.c"
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu_impl::runLex()
+{
+  genxcu_lex();
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu_impl::pushKeyPart(TAG_TYPE bIsNode, string& sTag)
+{
+  // remember text for merge
+  msCollector += sTag;
+
+  xcu_stack_entry newTag(bIsNode, sTag);
+
+  mcStack.push(newTag);
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu_impl::popKeyPart(TAG_TYPE bIsNode, string &sTag)
+{
+  // remember text for merge
+  msCollector += sTag;
+
+  // check for correct node/prop relations
+  if (bIsNode != mcStack.top().mbIsNode)
+    throw "node/prob mismatch in file " + msSourceFile;
+
+  mcStack.pop();
+
+  if (mbMergeMode && msCollector.size())
+    writeSourceFile(msCollector);
+  msCollector.clear();
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu_impl::startCollectData(string& sCollectedText)
+{
+  if (mbMergeMode && msCollector.size())
+    writeSourceFile(msCollector);
+
+  mbCollectingData = true;
+  msCollector.clear();
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu_impl::stopCollectData(string& sCollectedText)
+{
+  string useKey;
+
+
+  // locate key and extract it
+  while (mcStack.size())
+  {
+    xcu_stack_entry nowEntry = mcStack.top();
+	mcStack.pop();
+	useKey = useKey + nowEntry.msName;
+  }
+
+  if (mbMergeMode)
+  {
+    // get all languages (includes en-US)
+    vector<l10nMem_entry *>& cExtraLangauges = mcMemory.getLanguagesForKey(useKey);
+    string                   sNewLine;
+    int                      nL = cExtraLangauges.size();
+
+	writeSourceFile(msCollector + sCollectedText);
+    for (int i = 0; i < nL; ++i)
+    {
+      sNewLine = "<value xml:lang=\"" + cExtraLangauges[i]->msLanguage + "\">" +
+		         cExtraLangauges[i]->msText + "</value>";
+      writeSourceFile(sNewLine);
+    }
+  }
+  else
+    mcMemory.setEnUsKey(useKey, sCollectedText);
+
+  mbCollectingData = false;
+  msCollector.clear();
+}  
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
+void convert_xcu_impl::collectData(string& sCollectedText)
+{
+  msCollector += sCollectedText;
+  if (sCollectedText == "\n")
+  {
+    if (mbMergeMode)
+      writeSourceFile(msCollector);
+    msCollector.clear();
+  }
+}

Propchange: openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n/main/l10ntools/source/gConPolex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPolex.l?rev=1416635&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPolex.l (added)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPolex.l Mon Dec  3 18:45:21 2012
@@ -0,0 +1,107 @@
+/**************************************************************
+ * 
+ * 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 strings */
+#undef  YYLMAX
+#define YYLMAX 64000
+
+/* change reader function (input) to our own version */
+#define YY_INPUT(buf,result,max_size) { convert_xcu::mcpImpl->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 prefix="genxcu_"
+%p 24000
+%e 1200
+%n 500
+
+
+
+/*******************   R U L E S   D E F I N I T I O N S   *******************/
+%%
+
+"<oor:component-data "[^>]*> {
+  string text(yytext);
+  convert_xcu::mcpImpl->pushKeyPart(TAG_COMPONENT, text);
+}
+
+
+"</oor:component-data>" {
+  string text(yytext);
+  convert_xcu::mcpImpl->popKeyPart(TAG_COMPONENT, text);
+}
+
+"<prop oor:name=\""[^\"]*\" {
+  string text(yytext);
+  convert_xcu::mcpImpl->pushKeyPart(TAG_PROP, text);
+}
+
+"</prop>" {
+  string text(yytext);
+  convert_xcu::mcpImpl->popKeyPart(TAG_PROP, text);
+}
+
+"<node oor:name=\""[^\"]*\" {
+  string text(yytext);
+  convert_xcu::mcpImpl->pushKeyPart(TAG_NODE, text);
+}
+
+"</node>" {
+  string text(yytext);
+  convert_xcu::mcpImpl->popKeyPart(TAG_NODE, text);
+}
+  
+"<value xml:lang=\""[^\"]*\"[^>]*">" {
+  string text(yytext);
+  convert_xcu::mcpImpl->startCollectData(text);
+}
+
+"</value>" {
+  string text(yytext);
+  convert_xcu::mcpImpl->stopCollectData(text);
+}
+
+.|\n {
+  string text(yytext);
+  convert_xcu::mcpImpl->collectData(text);
+}
+%%

Propchange: openoffice/branches/l10n/main/l10ntools/source/gConPolex.l
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message