summaryrefslogtreecommitdiff
path: root/l10ntools/inc
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-05-02 12:09:35 +0200
committerZolnai Tamás <zolnaitamas2000@gmail.com>2013-05-02 12:15:22 +0200
commitc7ef2522272579a12eecddded0cbed6d222d3742 (patch)
treecaf2cdf898ce2e84eb66a5f328c08192454681c7 /l10ntools/inc
parent3ec2d26dc2017ac4a27483febfc63328632f352d (diff)
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
Diffstat (limited to 'l10ntools/inc')
-rw-r--r--l10ntools/inc/export.hxx64
1 files changed, 57 insertions, 7 deletions
diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index 7a6f91193f4b..a7f8ea126583 100644
--- a/l10ntools/inc/export.hxx
+++ b/l10ntools/inc/export.hxx
@@ -52,9 +52,6 @@ typedef boost::unordered_map<OString, OString, OStringHash>
typedef boost::unordered_map<OString, bool, OStringHash>
OStringBoolHashMap;
-typedef boost::unordered_map<OString, MergeData*, OStringHash>
- 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<MergeEntrys*>& 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<OString, MergeData*, OStringHash> HashMap_t;
+
+ public:
+ MergeDataHashMap():bFirstSearch(true){};
+ ~MergeDataHashMap(){};
+
+ typedef HashMap_t::iterator iterator;
+ typedef HashMap_t::const_iterator const_iterator;
+
+ std::pair<iterator,bool> 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:
+ bool bFirstSearch;
+ iterator aLastInsertion;
+ iterator aLastFound;
+ iterator aFirstInOrder;
+ HashMap_t m_aHashMap;
+};
+
//
// class MergeData
//
@@ -293,12 +339,16 @@ class MergeDataFile;
class MergeData
{
+ friend class MergeDataHashMap;
+
public:
OString sTyp;
OString sGID;
OString sLID;
OString sFilename;
MergeEntrys* pMergeEntrys;
+private:
+ MergeDataHashMap::iterator m_aNextData;
public:
MergeData( const OString &rTyp, const OString &rGID, const OString &rLID , const OString &rFilename );
~MergeData();
@@ -326,7 +376,7 @@ class MergeDataFile
const OString &rLID, const OString &nLang,
const OString &rTEXT, const OString &rQHTEXT,
const OString &rTITLE, const OString &sFilename,
- bool bCaseSensitive);
+ bool bFirstLang, bool bCaseSensitive);
public:
explicit MergeDataFile(
const OString &rFileName, const OString& rFile,