Added: openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx?rev=1416218&view=auto ============================================================================== --- openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx (added) +++ openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx Sun Dec 2 18:06:44 2012 @@ -0,0 +1,58 @@ +/************************************************************** + * + * 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 "gLang.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_impl : public convert_gen +{ + public: + convert_xrm_impl(const string& srSourceFile, l10nMem& crMemory); + ~convert_xrm_impl(); + + void startCollectData(string& sCollectedText); + void stopCollectData(string& sCollectedText); + void collectData(string& sCollectedText); + + private: + bool mbMergeMode; + + bool mbCollectingData; + string msCollector; + + void extract(); + void insert(); + void runLex(); + + friend class convert_xrm; +}; +#endif \ No newline at end of file
Propchange: openoffice/branches/l10n/main/l10ntools/source/gConXrm.hxx ------------------------------------------------------------------------------ svn:executable = * Added: openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx?rev=1416218&view=auto ============================================================================== --- openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx (added) +++ openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx Sun Dec 2 18:06:44 2012 @@ -0,0 +1,129 @@ +/************************************************************** + * + * 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 "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 M P L E M E N T A T I O N **********************/ +#include "gConXrm_yy.c" + + + +/********************** I M P L E M E N T A T I O N **********************/ +void convert_xrm_impl::runLex() +{ + genXrm_lex(); + + // write last part of file. + if (mbMergeMode && msCollector.size()) + writeSourceFile(msCollector); +} + + + +/********************** I M P L E M E N T A T I O N **********************/ +void convert_xrm_impl::startCollectData(string& sCollectedText) +{ + if (mbMergeMode && msCollector.size()) + writeSourceFile(msCollector); + + mbCollectingData = true; + msCollector = sCollectedText; +} + + + +/********************** I M P L E M E N T A T I O N **********************/ +void convert_xrm_impl::stopCollectData(string& sCollectedText) +{ +static const char TEXT_P[] = "<p"; +static const char TEXT_H[] = "<h"; +static const char TEXT_ID[] = "id="; + string sHead, sKey, sLang, sText; + int nL; + + + // get type of tag + msCollector += sCollectedText; + nL = msCollector.find(TEXT_P); + if (nL != string::npos) + sHead = msCollector.substr(nL+1, 1); + else + { + nL = msCollector.find(TEXT_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); + + if (mbMergeMode) + { + // get all languages (includes en-US) + vector<l10nMem_entry *>& cExtraLangauges = mcMemory.getLanguagesForKey(sKey); + string sNewLine; + int nL = cExtraLangauges.size(); + + writeSourceFile(msCollector); + msCollector.clear(); + for (int i = 0; i < nL; ++i) + { + sNewLine = "\n<" + sHead + " id=\"" + sKey + "\"" + " xml:lang=\"" + + cExtraLangauges[i]->msLanguage + "\">" + + cExtraLangauges[i]->msText + + "</" + sHead + ">"; + + writeSourceFile(sNewLine); + } + } + else + mcMemory.setEnUsKey(sKey, sText); + + mbCollectingData = false; + msCollector.clear(); +} + + +/********************** I M P L E M E N T A T I O N **********************/ +void convert_xrm_impl::collectData(string& sCollectedText) +{ + msCollector += sCollectedText; + if (sCollectedText == "\n") + { + if (mbMergeMode) + writeSourceFile(msCollector); + msCollector.clear(); + } +} Propchange: openoffice/branches/l10n/main/l10ntools/source/gConXrmWrap.cxx ------------------------------------------------------------------------------ svn:executable = * Added: openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l?rev=1416218&view=auto ============================================================================== --- openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l (added) +++ openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l Sun Dec 2 18:06:44 2012 @@ -0,0 +1,80 @@ +/************************************************************** + * + * 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 strings */ +#undef YYLMAX +#define YYLMAX 64000 + +/* change reader function (input) to our own version */ +#define YY_INPUT(buf,result,max_size) { convert_xrm::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="genXrm_" +%p 24000 +%e 1200 +%n 500 + + + +/******************* R U L E S D E F I N I T I O N S *******************/ +%% + +"<p"[^>]*> | +"<h"[0-9][^>]*> { + string text(yytext); + convert_xrm::mcpImpl->startCollectData(text); +} + +"</p>" | +"</h"[0-9]> { + string text(yytext); + convert_xrm::mcpImpl->stopCollectData(text); +} + +.|\n { + string text(yytext); + convert_xrm::mcpImpl->collectData(text); +} + + +%% Propchange: openoffice/branches/l10n/main/l10ntools/source/gConXrmlex.l ------------------------------------------------------------------------------ svn:executable = *