[Libreoffice-commits] core.git: l10ntools/inc l10ntools/source solenv/gbuild
l10ntools/inc/common.hxx |2 ++ l10ntools/inc/export.hxx |4 +++- l10ntools/source/common.cxx |9 +++-- l10ntools/source/export.cxx |8 +--- solenv/gbuild/AllLangResTarget.mk |3 ++- 5 files changed, 19 insertions(+), 7 deletions(-) New commits: commit fff70bf98c7a5a63aa0db11e93a3512c6a9a9359 Author: Tomofumi Yagi Date: Sat Sep 7 10:04:30 2013 +0900 fdo#68790: fix build error on Win when system locale=="Japanese(Japan)" This patch modifies transex3. Modified transex3 outputs a file with BOM(if MergeMode is true). *.[hs]rc files with BOM avoid this problem. This problem is that MSVC interprets UTF-8 source code without BOM as local codepage when system locale is "Japanese(Japan)". Change-Id: I3e12499a91a954236f48e6d7e360d26c93d19ed6 Reviewed-on: https://gerrit.libreoffice.org/5851 Tested-by: Markus Mohrhard Tested-by: Kohei Yoshida Reviewed-by: Kohei Yoshida diff --git a/l10ntools/inc/common.hxx b/l10ntools/inc/common.hxx index 5a12bbb..047d2f4 100644 --- a/l10ntools/inc/common.hxx +++ b/l10ntools/inc/common.hxx @@ -28,12 +28,14 @@ struct HandledArgs OString m_sMergeSrc; OString m_sLanguage; bool m_bMergeMode; +bool m_bUTF8BOM; HandledArgs() : m_sInputFile( OString() ) , m_sOutputFile( OString() ) , m_sMergeSrc( OString() ) , m_sLanguage( OString() ) , m_bMergeMode( false ) +, m_bUTF8BOM( false ) {} }; diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx index 595c027..b9d2603 100644 --- a/l10ntools/inc/export.hxx +++ b/l10ntools/inc/export.hxx @@ -226,9 +226,11 @@ private: void CutComment( OString &rText ); +void WriteUTF8ByteOrderMarkToOutput() { *aOutput.mSimple << '\xEF' << '\xBB' << '\xBF'; } + public: Export( const OString &rOutput ); -Export(const OString &rMergeSource, const OString &rOutput, const OString &rLanguage); +Export(const OString &rMergeSource, const OString &rOutput, const OString &rLanguage, bool bUTF8BOM); ~Export(); void Init(); diff --git a/l10ntools/source/common.cxx b/l10ntools/source/common.cxx index db86845..78274b8 100644 --- a/l10ntools/source/common.cxx +++ b/l10ntools/source/common.cxx @@ -43,6 +43,10 @@ bool handleArguments( { nState = STATE_LANGUAGES; } +else if ( OString( argv[ i ] ).toAsciiUpperCase() == "-B" ) +{ +o_aHandledArgs.m_bUTF8BOM = true; +} else { switch ( nState ) @@ -90,12 +94,13 @@ void writeUsage(const OString& rName, const OString& rFileType) { std::cout << " Syntax: " << rName.getStr() -<< " -i FileIn -o FileOut [-m DataBase] [-l Lang]\n" +<< " -i FileIn -o FileOut [-m DataBase] [-l Lang] [-b]\n" << " FileIn: Source files (" << rFileType.getStr() << ")\n" << " FileOut: Destination file (*.*)\n" << " DataBase: Mergedata (*.po)\n" << " Lang: Restrict the handled language; one element of\n" -<< " (de, en-US, ...) or all\n"; +<< " (de, en-US, ...) or all\n" +<< " -b: Add UTF-8 Byte Order Mark to FileOut(use with -m option)\n"; } void writePoEntry( diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index b439389..864e7b2 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -69,8 +69,8 @@ FILE * init(int argc, char ** argv) { } if (aArgs.m_bMergeMode) { -global::exporter.reset( -new Export(aArgs.m_sMergeSrc, aArgs.m_sOutputFile, aArgs.m_sLanguage)); +global::exporter.reset(new Export(aArgs.m_sMergeSrc, aArgs.m_sOutputFile, + aArgs.m_sLanguage, aArgs.m_bUTF8BOM)); } else { global::exporter.reset(new Export(aArgs.m_sOutputFile)); } @@ -198,7 +198,7 @@ Export::Export(const OString &rOutput) Export::Export( const OString &rMergeSource, const OString &rOutput, -const OString &rLanguage ) +const OString &rLanguage, bool bUTF8BOM) : bDefine( sal_False ), bNextMustBeDefineEOL( sal_False ), @@ -218,6 +218,8 @@ Export::Export( { aOutput.mSimple = new std::ofstream(); aOutput.mSimple->open(rOutput.getStr(), std::ios_base::out | std::ios_base::trunc); + +if ( bUTF8BOM ) WriteUTF8ByteOrderMarkToOutput(); } void Export::Init() diff --git a/solenv/gbuild/AllLangResTarget.mk b/solenv/gbuild/AllLangResTarget.mk index 6721a98..ac7a9af 100644 --- a/solenv/gbuild/AllLangResTarget.mk +++ b/solenv/gbuild/AllLangResTarget.mk @@ -50,7 +50,8 @@ $(call gb_Helper_abbreviate_dirs,\ -i $(3) \ -o $(1) \ -m $${MERGEINPUT} \ - -l all) && \ + -l all \ + $(if $(filter MSC,$(COM)),$(if $(strip $(gb_WITH_LANG)),-b))) && \
[Libreoffice-commits] core.git: l10ntools/inc l10ntools/source solenv/gbuild
l10ntools/inc/export.hxx | 64 - l10ntools/source/cfgmerge.cxx | 15 - l10ntools/source/export.cxx| 496 ++--- l10ntools/source/helpmerge.cxx | 15 - l10ntools/source/merge.cxx | 84 +- l10ntools/source/xrmmerge.cxx | 14 - solenv/gbuild/HelpTarget.mk|2 7 files changed, 267 insertions(+), 423 deletions(-) New commits: commit c7ef2522272579a12eecddded0cbed6d222d3742 Author: Zolnai Tamás Date: Thu May 2 12:09:35 2013 +0200 Make localization a bit more effective 1. get rid of some unefficiency The "old" executables used to parse items which has other language than en-US. To this items executables search MergeEntrys(read from po) and change the content if possible. This mixed localization method not need any longer. -cfgex: cfgmerge:WorkOnText() -xrmex: xrmmerge:WorkOnText() -transex3: export:PrepareTextToMerge() 2. Change the container of MergeData to get a bit efficiency. The new MergeDataHashMap is exploit that in most case the insertion and search happen in the same order.(similar to fifo) So add an iterator-chain to define an insertion order in the original hashmap. Every call of find it is a hint that the next element, to the last found one, is the searched one. If not than search such like in a HasMap. 3. Set up some order in helpex Helpex is the only one, which was not used to merge strings in the same order as export, so change it to work effective with the new HashMap. Helpex works with all file of a specific directory and po files contain the strings of these files in lexical order so use the same order for merge.(HelpTarget.mk) 4. Make export use MergeDataHashMap a bit more effective -The same MergeData contains strings to all language, so it need to get only once. -Just text entrys have MergeData, others not need to search for it. (e.g. bitmap) Plus delete some unused code. Change-Id: I6ec80cd2323ffea8f783d0b59dc89ca7eac3c205 diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx index 7a6f911..a7f8ea1 100644 --- a/l10ntools/inc/export.hxx +++ b/l10ntools/inc/export.hxx @@ -52,9 +52,6 @@ typedef boost::unordered_map typedef boost::unordered_map OStringBoolHashMap; -typedef boost::unordered_map -MergeDataHashMap; - #define SOURCE_LANGUAGE "en-US" #define X_COMMENT "x-comment" #define LIST_REFID "LIST_REFID" @@ -193,7 +190,6 @@ private: bool bSkipFile; sal_Bool bMergeMode; OString sMergeSrc; -OString sLastListLine; sal_Bool bError;// any errors while export? sal_Bool bReadOver; sal_Bool bDontWriteOutput; @@ -219,8 +215,12 @@ private: void CleanValue( OString &rValue ); OString GetText(const OString &rSource, int nToken); -sal_Bool PrepareTextToMerge(OString &rText, sal_uInt16 nTyp, -OString &rLangIndex, ResData *pResData); +/** + Get all MergeEntrys for the ExportList identified by pResData + Check whether list can merge and load all needed MergeEntry from DataBase. +*/ +bool GetAllMergeEntrysOfList(ResData *pResData, std::vector& o_vMergeEntrys, ExportList*& o_pList); + void ResData2Output( MergeEntrys *pEntry, sal_uInt16 nType, const OString& rTextType ); void MergeRest( ResData *pResData, sal_uInt16 nMode = MERGE_MODE_NORMAL ); void ConvertMergeContent( OString &rText ); @@ -277,10 +277,56 @@ public: bTitleFirst[ rId ] = true; } sal_Bool GetText( OString &rReturn, sal_uInt16 nTyp, const OString &nLangIndex, sal_Bool bDel = sal_False ); + +/** + Generate QTZ string with ResData + For executable which works one language and without PO files. +*/ static OString GetQTZText(const ResData& rResData, const OString& rOrigText); }; +/** Container for MergeData + + This class is an HashMap with a hidden insertion + order. The class can used just like a simple + HashMap, but good to know that it's use is + more effective if the accessing(find) order + match with the insertion order. + + In the most case, this match is good. + (e.g. reading PO files of different languages, + executables merging) +*/ +class MergeDataHashMap +{ +private: +typedef boost::unordered_map HashMap_t; + +public: +MergeDataHashMap():bFirstSearch(true){}; +~MergeDataHashMap(){}; + +typedef HashMap_t::iterator iterator; +typedef HashMap_t::const_iterator const_iterator; + +std::pair insert(const OString& rKey, MergeData* pMergeData); +iterator find(const OString& rKey); + +iterator begin() {return m_aHashMap.begin();} +iterator end() {return m_aHashMap.end();} + +const_iterator begin() const {return m_aHashMap.begin();} +const_iterator end() const {return m_aHashMap.end();} + +private: +b