summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--l10ntools/inc/export.hxx64
-rw-r--r--l10ntools/source/cfgmerge.cxx15
-rw-r--r--l10ntools/source/export.cxx496
-rw-r--r--l10ntools/source/helpmerge.cxx15
-rw-r--r--l10ntools/source/merge.cxx84
-rw-r--r--l10ntools/source/xrmmerge.cxx14
-rw-r--r--solenv/gbuild/HelpTarget.mk2
7 files changed, 267 insertions, 423 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,
diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx
index b2f47b27274c..6a8d2d719bdc 100644
--- a/l10ntools/source/cfgmerge.cxx
+++ b/l10ntools/source/cfgmerge.cxx
@@ -450,7 +450,7 @@ CfgMerge::~CfgMerge()
delete pResData;
}
-void CfgMerge::WorkOnText(OString &rText, const OString& rLangIndex)
+void CfgMerge::WorkOnText(OString &, const OString& rLangIndex)
{
if ( pMergeDataFile && bLocalize ) {
@@ -470,19 +470,8 @@ void CfgMerge::WorkOnText(OString &rText, const OString& rLangIndex)
pResData->sResTyp = pStackData->sResTyp;
}
- if (rLangIndex.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")))
+ if (rLangIndex.equalsIgnoreAsciiCase("en-US"))
bEnglish = sal_True;
-
- MergeEntrys *pEntrys = pMergeDataFile->GetMergeEntrysCaseSensitive( pResData );
- if ( pEntrys ) {
- OString sContent;
- pEntrys->GetText( sContent, STRING_TYP_TEXT, rLangIndex );
-
- if ( !rLangIndex.equalsIgnoreAsciiCase("en-US") && !sContent.isEmpty())
- {
- rText = helper::QuotHTML( rText );
- }
- }
}
}
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index af97a4b6d8f7..a27be62a1b94 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -497,8 +497,6 @@ int Export::Execute( int nToken, const char * pToken )
if ( bDefine )
bNextMustBeDefineEOL = sal_True;
if ( !nListLevel ) {
- if ( bMergeMode )
- MergeRest( pResData, MERGE_MODE_LIST );
nList = LIST_NON;
}
else
@@ -616,31 +614,6 @@ int Export::Execute( int nToken, const char * pToken )
nListLevel = 0;
}
}
- else
- {
- // new res. is a String- or FilterList
- sal_Int32 n = 0;
- OString sKey(
- sToken.getToken(0, '[', n).replaceAll(" ", OString()).
- replaceAll("\t", OString()).toAsciiUpperCase());
- if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("STRINGLIST")))
- nList = LIST_STRING;
- else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("FILTERLIST")))
- nList = LIST_FILTER;
- else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("PAIREDLIST")))
- nList = LIST_PAIRED; // abcd
- else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("ITEMLIST")))
- nList = LIST_ITEM;
- else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("UIENTRIES")))
- nList = LIST_UIENTRIES;
- if ( nList ) {
- OString sLang = sToken.getToken(0, ']', n);
- CleanValue( sLang );
- m_sListLang = sLang;
- nListIndex = 0;
- nListLevel = 0;
- }
- }
}
break;
case TEXT:
@@ -656,10 +629,6 @@ int Export::Execute( int nToken, const char * pToken )
if ( sEntry == "\\\"" )
sEntry = "\"";
InsertListEntry( sEntry, sOrig );
- if ( bMergeMode && ( sEntry != "\"" ))
- {
- PrepareTextToMerge( sOrig, nList, m_sListLang, pResData );
- }
}
}
break;
@@ -700,10 +669,7 @@ int Export::Execute( int nToken, const char * pToken )
pResData->bText = sal_True;
pResData->sTextTyp = sOrigKey;
- if ( bMergeMode ) {
- PrepareTextToMerge( sOrig, STRING_TYP_TEXT, sLangIndex, pResData );
- }
- else
+ if ( !bMergeMode )
{
if (!pResData->sText[ sLangIndex ].isEmpty())
{
@@ -718,9 +684,7 @@ int Export::Execute( int nToken, const char * pToken )
else if ( sKey == "HELPTEXT" ) {
SetChildWithText();
pResData->bHelpText = sal_True;
- if ( bMergeMode )
- PrepareTextToMerge( sOrig, STRING_TYP_HELPTEXT, sLangIndex, pResData );
- else
+ if ( !bMergeMode )
{
if (!pResData->sHelpText[ sLangIndex ].isEmpty())
{
@@ -735,9 +699,7 @@ int Export::Execute( int nToken, const char * pToken )
else if ( sKey == "QUICKHELPTEXT" ) {
SetChildWithText();
pResData->bQuickHelpText = sal_True;
- if ( bMergeMode )
- PrepareTextToMerge( sOrig, STRING_TYP_QUICKHELPTEXT, sLangIndex, pResData );
- else
+ if ( !bMergeMode )
{
if (!pResData->sQuickHelpText[ sLangIndex ].isEmpty())
{
@@ -752,9 +714,7 @@ int Export::Execute( int nToken, const char * pToken )
else if ( sKey == "TITLE" ) {
SetChildWithText();
pResData->bTitle = sal_True;
- if ( bMergeMode )
- PrepareTextToMerge( sOrig, STRING_TYP_TITLE, sLangIndex, pResData );
- else
+ if ( !bMergeMode )
{
if ( !pResData->sTitle[ sLangIndex ].isEmpty())
{
@@ -1279,182 +1239,102 @@ void Export::ConvertExportContent( OString& rText )
rText = helper::unEscapeAll(rText,"\\n""\\t""\\\\""\\\"","\n""\t""\\""\"");
}
-sal_Bool Export::PrepareTextToMerge(OString &rText, sal_uInt16 nTyp,
- OString &rLangIndex, ResData *pResData)
+bool Export::GetAllMergeEntrysOfList(ResData *pResData, std::vector<MergeEntrys*>& o_vMergeEntrys, ExportList*& o_pList )
{
- // position to merge in:
- sal_Int32 nStart = 0;
- sal_Int32 nEnd = 0;
- OString sOldId = pResData->sId;
- OString sOldGId = pResData->sGId;
- OString sOldTyp = pResData->sResTyp;
-
- OString sOrigText( rText );
-
- switch ( nTyp ) {
- case LIST_STRING :
- case LIST_UIENTRIES :
- case LIST_FILTER :
- case LIST_PAIRED:
- case LIST_ITEM :
+ o_vMergeEntrys.clear();
+ o_pList = 0;
+
+ if (!pResData->sGId.isEmpty())
+ pResData->sGId = pResData->sGId + OString('.');
+ pResData->sGId = pResData->sGId + pResData->sId;
+
+ ///Find out the type of List
+ MergeEntrys* pEntrysOfFirstItem = 0;
+ sal_uInt16 nType = LIST_STRING;
+ bool bPairedList = false;
+ while( !pEntrysOfFirstItem && nType <= LIST_UIENTRIES )
+ {
+ switch ( nType )
{
- ExportList *pList = NULL;
- switch ( nTyp ) {
- case LIST_STRING : {
- pResData->sResTyp = "stringlist";
- pList = pResData->pStringList;
- }
- break;
- case LIST_UIENTRIES : {
- pResData->sResTyp = "uientries";
- pList = pResData->pUIEntries;
- }
- break;
- case LIST_FILTER : {
- pResData->sResTyp = "filterlist";
- pList = pResData->pFilterList;
- }
- break;
- case LIST_ITEM : {
- pResData->sResTyp = "itemlist";
- pList = pResData->pItemList;
- }
- break;
- case LIST_PAIRED : {
- pResData->sResTyp = "pairedlist";
- pList = pResData->pPairedList;
- }
- break;
-
- }
- if (pList)
- {
- ExportListEntry *pCurEntry = (*pList)[ nListIndex - 1 ];
- if ( pCurEntry )
- rText = (*pCurEntry)[ SOURCE_LANGUAGE ];
- }
-
- nStart = rText.indexOf( '"' );
- if ( nStart == -1 ) {
- rText = sOrigText;
- return sal_False;
- }
-
- sal_Bool bFound = sal_False;
- for ( nEnd = nStart + 1; nEnd < rText.getLength() && !bFound; nEnd++ ) {
- if ( rText[nEnd] == '\"' )
- bFound = sal_True;
- }
- if ( !bFound ) {
- rText = sOrigText;
- return sal_False;
- }
-
- nEnd --;
- sLastListLine = rText;
- if (( sLastListLine.indexOf( '>' ) != -1 ) &&
- ( sLastListLine.indexOf( '<' ) == -1 ))
- {
- OString sTmp = sLastListLine;
- sLastListLine = "<";
- sLastListLine += sTmp;
- }
- if ( pResData->sResTyp.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("pairedlist")) )
- {
- pResData->sId = GetPairedListID( sLastListLine );
- }
- else pResData->sId = OString::number(nListIndex);
-
- if (!pResData->sGId.isEmpty())
- pResData->sGId = pResData->sGId + OString('.');
- pResData->sGId = pResData->sGId + sOldId;
- nTyp = STRING_TYP_TEXT;
+ case LIST_STRING : pResData->sResTyp = "stringlist"; o_pList = pResData->pStringList; bPairedList = false; break;
+ case LIST_FILTER : pResData->sResTyp = "filterlist"; o_pList = pResData->pFilterList; bPairedList = false; break;
+ case LIST_UIENTRIES : pResData->sResTyp = "uientries"; o_pList = pResData->pUIEntries;bPairedList = false; break;
+ case LIST_ITEM : pResData->sResTyp = "itemlist"; o_pList = pResData->pItemList; bPairedList = false; break;
+ case LIST_PAIRED : pResData->sResTyp = "pairedlist"; o_pList = pResData->pPairedList; bPairedList = true; break;
}
- break;
- case STRING_TYP_TEXT :
- case STRING_TYP_HELPTEXT :
- case STRING_TYP_QUICKHELPTEXT :
- case STRING_TYP_TITLE :
- {
- nStart = rText.indexOf( '=' );
- if ( nStart == -1 ) {
- rText = sOrigText;
- return sal_False;
- }
-
- nStart++;
- sal_Bool bFound = sal_False;
- while(( nStart < rText.getLength()) && !bFound ) {
- if (( rText[nStart] != ' ' ) && ( rText[nStart] != '\t' ))
- bFound = sal_True;
- else
- nStart ++;
- }
-
- // no start position found
- if ( !bFound ) {
- rText = sOrigText;
- return sal_False;
- }
-
- // position to end mergeing in
- nEnd = rText.getLength() - 1;
- bFound = sal_False;
- while (( nEnd > nStart ) && !bFound ) {
- if (( rText[nEnd] != ' ' ) && ( rText[nEnd] != '\t' ) &&
- ( rText[nEnd] != '\n' ) && ( rText[nEnd] != ';' ) &&
- ( rText[nEnd] != '{' ) && ( rText[nEnd] != '\\' ))
- {
- bFound = sal_True;
- }
- else
- nEnd --;
- }
+ // Set matching pairedlist identifier
+ if( bPairedList && pResData->pPairedList )
+ {
+ ExportListEntry* pListE = ( ExportListEntry* ) (*pResData->pPairedList)[ 0 ];
+ pResData->sId = GetPairedListID ( (*pListE)[ SOURCE_LANGUAGE ] );
}
- break;
- }
+ else
+ pResData->sId = "1";
- // search for merge data
- if ( !pMergeDataFile ){
- pMergeDataFile = new MergeDataFile( sMergeSrc, global::inputPathname, false );
- aLanguages = pMergeDataFile->GetLanguages();
+ pEntrysOfFirstItem = pMergeDataFile->GetMergeEntrys( pResData );
+ ++nType;
}
- MergeEntrys *pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
- pResData->sId = sOldId;
- pResData->sGId = sOldGId;
- pResData->sResTyp = sOldTyp;
-
- if ( !pEntrys ) {
- rText = sOrigText;
- return sal_False; // no data found
+ if( !pEntrysOfFirstItem )
+ {
+ o_pList = 0;
+ return false;
}
+ else
+ nList = nType-1;
- OString sContent;
- pEntrys->GetText(sContent, nTyp, rLangIndex);
- if (sContent.isEmpty() && !rLangIndex.equalsIgnoreAsciiCase("en-US"))
+ sal_uInt16 nMaxIndex = 0;
+ if ( o_pList )
{
- rText = sOrigText;
- return sal_False; // no data found
+ nMaxIndex = o_pList->GetSourceLanguageListEntryCount();
+ }
+ /**
+ * Check whether count of listentries match with count
+ * of translated items. If not than write origin items
+ * to the list to avoid mixed translations
+ * (exclude pairedlist)
+ */
+ if( !bPairedList )
+ {
+ MergeEntrys* pEntrys;
+ ///MergeData contains longer list
+ pResData->sId = OString::number(nMaxIndex+1);
+ pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
+ if ( pEntrys )
+ return false;
+ ///MergeData contains shorter list
+ pResData->sId = OString::number(nMaxIndex);
+ pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
+ if ( !pEntrys )
+ return false;
+ pResData->sId = "1";
}
- if (rLangIndex.equalsIgnoreAsciiCase("en-US"))
- return sal_False;
-
- OString sPostFix( rText.copy( ++nEnd ));
- rText = rText.copy(0, nStart);
-
- ConvertMergeContent( sContent );
-
-
+ o_vMergeEntrys.push_back(pEntrysOfFirstItem);
- // merge new res. in text line
- rText += sContent;
- rText += sPostFix;
+ for( sal_uInt16 nLIndex = 2; nLIndex <= nMaxIndex; ++nLIndex )
+ {
+ // Set matching pairedlist identifier
+ if ( bPairedList )
+ {
+ ExportListEntry* pListE = ( ExportListEntry* )(*pResData->pPairedList)[ ( nLIndex ) -1 ];
+ if( pListE )
+ {
+ pResData->sId = GetPairedListID ( (*pListE)[ SOURCE_LANGUAGE ] );
+ }
+ }
+ else
+ pResData->sId = OString::number(nLIndex);
- return sal_True;
-}
+ MergeEntrys* pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
+ if( pEntrys )
+ {
+ o_vMergeEntrys.push_back(pEntrys);
+ }
+ }
+ return true;
+ }
void Export::ResData2Output( MergeEntrys *pEntry, sal_uInt16 nType, const OString& rTextType )
{
@@ -1519,7 +1399,9 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
}
switch ( nMode ) {
case MERGE_MODE_NORMAL : {
- MergeEntrys *pEntry = pMergeDataFile->GetMergeEntrys( pResData );
+ MergeEntrys *pEntry = 0;
+ if( pResData->bText || pResData->bQuickHelpText || pResData->bTitle )
+ pEntry = pMergeDataFile->GetMergeEntrys( pResData );
if ( pEntry ) {
if ( pResData->bText )
@@ -1535,115 +1417,77 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
// Merge Lists
if ( pResData->bList ) {
- bool bPairedList = false;
OString sOldId = pResData->sId;
OString sOldGId = pResData->sGId;
OString sOldTyp = pResData->sResTyp;
- if (!pResData->sGId.isEmpty())
- pResData->sGId = pResData->sGId + OString('.');
- pResData->sGId = pResData->sGId + sOldId;
+ sal_uInt16 nOldListTyp = nList;
+
OString sSpace;
for ( sal_uInt16 i = 1; i < nLevel-1; i++ )
sSpace += "\t";
- for ( sal_uInt16 nT = LIST_STRING; nT <= LIST_UIENTRIES; nT++ ) {
- ExportList *pList = NULL;
- switch ( nT ) {
- case LIST_STRING : pResData->sResTyp = "stringlist"; pList = pResData->pStringList; bPairedList = false; break;
- case LIST_FILTER : pResData->sResTyp = "filterlist"; pList = pResData->pFilterList; bPairedList = false; break;
- case LIST_UIENTRIES : pResData->sResTyp = "uientries"; pList = pResData->pUIEntries;bPairedList = false; break;
- case LIST_ITEM : pResData->sResTyp = "itemlist"; pList = pResData->pItemList; bPairedList = false; break;
- case LIST_PAIRED : pResData->sResTyp = "pairedlist"; pList = pResData->pPairedList; bPairedList = true; break;
- }
+
+ std::vector<MergeEntrys*> vMergeEntryVector;
+ ExportList* pList = 0;
+ bool bTranslateList = GetAllMergeEntrysOfList(pResData, vMergeEntryVector, pList);
+
+ if( pList )
+ {
OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ )
{
sCur = aLanguages[ n ];
- sal_uInt16 nIdx = 1;
- // Set matching pairedlist identifier
- if( bPairedList && pResData->pPairedList && ( nIdx == 1 ) ){
- ExportListEntry* pListE = ( ExportListEntry* ) (*pResData->pPairedList)[ nIdx-1 ];
- pResData->sId = GetPairedListID ( (*pListE)[ SOURCE_LANGUAGE ] );
- }
- else
- pResData->sId = "1";
-
- MergeEntrys *pEntrys;
- std::size_t nLIndex = 0;
- std::size_t nMaxIndex = 0;
- if ( pList )
- nMaxIndex = pList->GetSourceLanguageListEntryCount();
-
- /**
- * Check whether count of listentries match with count
- * of translated items. If not than write origin items
- * to the list to avoid mixed translations
- * (exclude pairedlist)
- */
- sal_Bool bTranslateList = true;
- if( !bPairedList ){
- pResData->sId = OString::number(nMaxIndex);
- pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
- if ( !pEntrys )
- bTranslateList = false;
- pResData->sId = OString::valueOf(static_cast<sal_Int32>(nMaxIndex+1));
- pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
- if ( pEntrys )
- bTranslateList = false;
- pResData->sId = "1";
- }
-
- pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
- while(( nLIndex < nMaxIndex )) {
- if ( nIdx == 1 )
+ sal_uInt16 nLIndex = 0;
+ sal_uInt16 nMaxIndex = pList->GetSourceLanguageListEntryCount();
+ while( nLIndex < nMaxIndex )
+ {
+ if ( nLIndex == 0 )
{
OStringBuffer sHead;
if ( bNextMustBeDefineEOL )
- sHead.append(RTL_CONSTASCII_STRINGPARAM("\\\n\t"));
+ sHead.append("\\\n\t");
sHead.append(sSpace);
- switch ( nT )
+ switch ( nList )
{
case LIST_STRING:
- sHead.append(RTL_CONSTASCII_STRINGPARAM("StringList "));
+ sHead.append("StringList ");
break;
case LIST_FILTER:
- sHead.append(RTL_CONSTASCII_STRINGPARAM("FilterList "));
+ sHead.append("FilterList ");
break;
case LIST_ITEM:
- sHead.append(RTL_CONSTASCII_STRINGPARAM("ItemList "));
+ sHead.append("ItemList ");
break;
case LIST_PAIRED:
- sHead.append(RTL_CONSTASCII_STRINGPARAM("PairedList "));
+ sHead.append("PairedList ");
break;
case LIST_UIENTRIES:
- sHead.append(RTL_CONSTASCII_STRINGPARAM("UIEntries "));
+ sHead.append("UIEntries ");
break;
}
- sHead.append(RTL_CONSTASCII_STRINGPARAM("[ "));
+ sHead.append("[ ");
sHead.append(sCur);
- sHead.append(RTL_CONSTASCII_STRINGPARAM(" ] "));
+ sHead.append(" ] ");
if ( bDefine || bNextMustBeDefineEOL )
{
- sHead.append(RTL_CONSTASCII_STRINGPARAM("= \\\n"));
+ sHead.append("= \\\n");
sHead.append(sSpace);
- sHead.append(RTL_CONSTASCII_STRINGPARAM("\t{\\\n\t"));
+ sHead.append("\t{\\\n\t");
}
else
{
- sHead.append(RTL_CONSTASCII_STRINGPARAM("= \n"));
+ sHead.append("= \n");
sHead.append(sSpace);
- sHead.append(RTL_CONSTASCII_STRINGPARAM("\t{\n\t"));
+ sHead.append("\t{\n\t");
}
WriteToMerged(sHead.makeStringAndClear() , true);
}
OString sLine;
if ( pList && (*pList)[ nLIndex ] )
sLine = ( *(*pList)[ nLIndex ])[ SOURCE_LANGUAGE ];
- if ( sLine.isEmpty())
- sLine = sLastListLine;
- if ( sLastListLine.indexOf( '<' ) != -1 ) {
- if (( nT != LIST_UIENTRIES ) &&
+ if ( sLine.indexOf( '>' ) != -1 ) {
+ if (( nList != LIST_UIENTRIES ) &&
(( sLine.indexOf( '{' ) == -1 ) ||
( sLine.indexOf( '{' ) >= sLine.indexOf( '"' ))) &&
(( sLine.indexOf( '<' ) == -1 ) ||
@@ -1656,32 +1500,14 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
if( bTranslateList )
{
OString sText;
- sal_Bool bText = false;
- if ( pEntrys )
- bText = pEntrys->GetText( sText, STRING_TYP_TEXT, sCur, sal_True );
+ sal_Bool bText;
+ bText = vMergeEntryVector[nLIndex]->GetText( sText, STRING_TYP_TEXT, sCur, sal_True );
if ( bText && !sText.isEmpty() )
{
- sal_Int32 nStart, nEnd;
- nStart = sLine.indexOf( '"' );
-
- OString sPostFix;
- if( !bPairedList ){
- nEnd = sLine.lastIndexOf( '"' );
- sPostFix = sLine.copy( ++nEnd );
- sLine = sLine.copy(0, nStart);
- }
-
-
ConvertMergeContent( sText );
-
- // merge new res. in text line
- if( bPairedList ){
- sLine = MergePairedList( sLine , sText );
- }
- else{
- sLine += sText;
- sLine += sPostFix;
- }
+ OString sPre = sLine.copy( 0 , sLine.indexOf('"') );
+ OString sPost = sLine.copy( sLine.lastIndexOf('"') + 1 );
+ sLine = sPre + sText + sPost;
}
}
@@ -1694,26 +1520,9 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
sText1 += sSpace;
sText1 += "\t";
WriteToMerged( sText1 ,true );
- nIdx++;
- if ( bTranslateList )
- {
- // Set matching pairedlist identifier
- if ( bPairedList ){
- ExportListEntry* pListE = ( ExportListEntry* )(*pResData->pPairedList)[ ( nIdx ) -1 ];
- if( pListE ){
- pResData->sId = GetPairedListID ( (*pListE)[ SOURCE_LANGUAGE ] );
- }
- }
- else
- pResData->sId = OString::number(nIdx);
- MergeEntrys *oldEntry = pEntrys;
- pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
- if( !pEntrys )
- pEntrys = oldEntry;
- }
- nLIndex++;
+ ++nLIndex;
}
- if ( nIdx > 1 ) {
+ if ( nLIndex > 0 ) {
OString sFooter;
if (!sSpace.isEmpty()) {
sFooter = sSpace.copy(1);
@@ -1732,72 +1541,17 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
pResData->sId = sOldId;
pResData->sGId = sOldGId;
pResData->sResTyp = sOldTyp;
+ nList = nOldListTyp;
}
}
break;
case MERGE_MODE_LIST : {
- ExportList *pList = NULL;
- switch ( nList ) {
- // PairedList
- case LIST_STRING : pList = pResData->pStringList; break;
- case LIST_FILTER : pList = pResData->pFilterList; break;
- case LIST_UIENTRIES : pList = pResData->pUIEntries; break;
- case LIST_ITEM : pList = pResData->pItemList; break;
- case LIST_PAIRED : pList = pResData->pPairedList; break;
-
- }
-
- nListIndex++;
- std::size_t nMaxIndex = 0;
- if ( pList )
- nMaxIndex = pList->GetSourceLanguageListEntryCount();
- OString sLine;
- if ( pList && (*pList)[ nListIndex ] )
- sLine = ( *(*pList)[ nListIndex ])[ SOURCE_LANGUAGE ];
- if ( sLine.isEmpty())
- sLine = sLastListLine;
-
- if ( sLastListLine.indexOf( '<' ) != -1 ) {
- if (( nList != LIST_UIENTRIES ) &&
- (( sLine.indexOf( '{' ) == -1 ) ||
- ( sLine.indexOf( '{' ) >= sLine.indexOf( '"' ))) &&
- (( sLine.indexOf( '<' ) == -1 ) ||
- ( sLine.indexOf( '<' ) >= sLine.indexOf( '"' ))))
- {
- sLine = sLine.replaceFirst("\"", "< \"");
- }
- }
-
- while( PrepareTextToMerge( sLine, nList, m_sListLang, pResData ) && ( nListIndex <= nMaxIndex )) {
- OString sText( "\t" );
- sText += sLine;
- sText += " ;";
- sText += "\n";
- for ( sal_uInt16 i = 0; i < nLevel; i++ )
- sText += "\t";
- WriteToMerged( sText ,false );
- nListIndex++;
- if ( pList && (*pList)[ nListIndex ])
- sLine = ( *(*pList)[ nListIndex ])[ SOURCE_LANGUAGE ];
- if ( sLine.isEmpty())
- sLine = sLastListLine;
- sLine += " ;";
- }
}
break;
}
pParseQueue->bMflag = false;
}
-OString Export::MergePairedList( OString const & sLine , OString const & sText ){
-// < "xy" ; IDENTIFIER ; >
- OString sPre = sLine.copy( 0 , sLine.indexOf('"') );
- OString sPost = sLine.copy( sLine.lastIndexOf('"') + 1 );
- sPre += sText;
- sPre += sPost;
- return sPre;
-}
-
/*****************************************************************************/
void Export::SetChildWithText()
/*****************************************************************************/
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index 69bde372f75d..d79dfaea7fa2 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -119,7 +119,6 @@ bool HelpParser::CreatePO(
{
posm = aXMLStrHM->find( *pos );
pElem = posm->second;
- OString sCur;
pXMLElement = (*pElem)[ "en-US" ];
@@ -138,7 +137,7 @@ bool HelpParser::CreatePO(
}
else
{
- fprintf(stdout,"\nDBG: NullPointer in HelpParser::CreatePO, Language %s, File %s\n", sCur.getStr(), sHelpFile.getStr());
+ fprintf(stdout,"\nDBG: NullPointer in HelpParser::CreatePO, File %s\n", sHelpFile.getStr());
}
}
aPoOutput.close();
@@ -174,17 +173,21 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile* pMergeDataFile
static ResData pResData("","");
pResData.sResTyp = "help";
- for(XMLHashMap::iterator pos=aXMLStrHM->begin();pos!=aXMLStrHM->end();++pos) // Merge every l10n related string
- {
+ std::vector<OString> order = file->getOrder();
+ std::vector<OString>::iterator pos;
+ XMLHashMap::iterator posm;
- aLangHM = pos->second;
+ for( pos = order.begin(); pos != order.end() ; ++pos ) // Merge every l10n related string in the same order as export
+ {
+ posm = aXMLStrHM->find( *pos );
+ aLangHM = posm->second;
#if OSL_DEBUG_LEVEL > 2
printf("*********************DUMPING HASHMAP***************************************");
Dump(aXMLStrHM);
printf("DBG: sHelpFile = %s\n",sHelpFile.getStr() );
#endif
- pResData.sGId = pos->first;
+ pResData.sGId = posm->first;
pResData.sFilename = sHelpFile;
ProcessHelp( aLangHM , sLanguage, &pResData , pMergeDataFile );
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index 498962f34d59..ce2864a8a7eb 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -188,6 +188,60 @@ OString MergeEntrys::GetQTZText(const ResData& rResData, const OString& rOrigTex
}
//
+// class MergeDataHashMap
+//
+
+std::pair<MergeDataHashMap::iterator,bool> MergeDataHashMap::insert(const OString& rKey, MergeData* pMergeData)
+{
+ std::pair<iterator,bool> aTemp = m_aHashMap.insert(HashMap_t::value_type( rKey, pMergeData ));
+ if( m_aHashMap.size() == 1 )
+ {
+ ///When first insert, set an iterator to the first element
+ aFirstInOrder = aTemp.first;
+ }
+ else
+ {
+ ///Define insertion order by setting an iterator to the next element.
+ aLastInsertion->second->m_aNextData = aTemp.first;
+ }
+ aLastInsertion = aTemp.first;
+ return aTemp;
+}
+
+MergeDataHashMap::iterator MergeDataHashMap::find(const OString& rKey)
+{
+ iterator aHint = m_aHashMap.end();
+
+ ///Add a hint
+ if( bFirstSearch && !m_aHashMap.empty() )
+ {
+ aHint = aFirstInOrder;
+ }
+ else if( aLastFound == aLastInsertion )
+ {
+ /// Next to the last element is the first element
+ aHint = aFirstInOrder;
+ }
+ else if( aLastFound != m_aHashMap.end() && aLastFound != aLastInsertion )
+ {
+ aHint = aLastFound->second->m_aNextData;
+ }
+
+ ///If hint works than no need for search
+ if( aHint != m_aHashMap.end() && aHint->first == rKey )
+ {
+ aLastFound = aHint;
+ }
+ else
+ {
+ aLastFound = m_aHashMap.find(rKey);
+ }
+
+ bFirstSearch = false;
+ return aLastFound;
+}
+
+//
// class MergeData
//
@@ -310,7 +364,8 @@ MergeDataFile::MergeDataFile(
InsertEntry(
aActPo.getResourceType(), aActPo.getGroupId(),
aActPo.getLocalId(), sLang, sText,
- sQHText, sTitle, aActPo.getSourceFile(), bCaseSensitive );
+ sQHText, sTitle, aActPo.getSourceFile(),
+ bFirstLang, bCaseSensitive );
if( bFirstLang && bWithQtz &&
( strcmp(getenv("ENABLE_RELEASE_BUILD"),"TRUE") ) )
@@ -321,7 +376,7 @@ MergeDataFile::MergeDataFile(
aActPo.getLocalId(), "qtz",
sExText, sExQHText,
sExTitle, aActPo.getSourceFile(),
- bCaseSensitive );
+ false, bCaseSensitive );
}
}
aPoInput.close();
@@ -357,11 +412,12 @@ MergeData *MergeDataFile::GetMergeData( ResData *pResData , bool bCaseSensitive
OString sKey = CreateKey( pResData->sResTyp , pResData->sGId , pResData->sId , pResData->sFilename , bCaseSensitive );
- if(aMap.find( sKey ) != aMap.end())
+ MergeDataHashMap::const_iterator mit = aMap.find( sKey );
+ if(mit != aMap.end())
{
pResData->sGId = sOldG;
pResData->sId = sOldL;
- return aMap[ sKey ];
+ return mit->second;
}
pResData->sGId = sOldG;
pResData->sId = sOldL;
@@ -391,24 +447,28 @@ void MergeDataFile::InsertEntry(
const OString &rLID, const OString &nLANG,
const OString &rTEXT, const OString &rQHTEXT,
const OString &rTITLE, const OString &rInFilename,
- bool bCaseSensitive )
+ bool bFirstLang, bool bCaseSensitive )
{
- MergeData *pData;
+ MergeData *pData = 0;
// search for MergeData
OString sKey = CreateKey(rTYP , rGID , rLID , rInFilename , bCaseSensitive);
- MergeDataHashMap::const_iterator mit;
- mit = aMap.find( sKey );
- if( mit != aMap.end() )
+
+ if( !bFirstLang )
{
- pData = mit->second;
+ MergeDataHashMap::const_iterator mit = aMap.find( sKey );
+ if(mit != aMap.end())
+ pData = mit->second;
+
}
- else
+
+ if( !pData )
{
pData = new MergeData( rTYP, rGID, rLID, rInFilename );
- aMap.insert( MergeDataHashMap::value_type( sKey, pData ) );
+ aMap.insert( sKey, pData );
}
+
// insert the cur string
MergeEntrys *pMergeEntrys = pData->GetMergeEntries();
if( nLANG =="qtz" )
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index 7fd0797f8da3..46bcd2e6da41 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -523,7 +523,7 @@ void XRMResMerge::WorkOnDesc(
/*****************************************************************************/
void XRMResMerge::WorkOnText(
const OString &rOpenTag,
- OString &rText
+ OString &
)
/*****************************************************************************/
{
@@ -534,18 +534,6 @@ void XRMResMerge::WorkOnText(
pResData = new ResData( GetGID(), sFilename );
pResData->sResTyp = sResourceType;
}
-
- MergeEntrys *pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
- if ( pEntrys ) {
- OString sContent;
- if ( !sLang.equalsIgnoreAsciiCase("en-US") &&
- ( pEntrys->GetText(
- sContent, STRING_TYP_TEXT, sLang )) && !sContent.isEmpty() &&
- helper::isWellFormedXML( sContent ))
- {
- rText = sContent;
- }
- }
}
}
diff --git a/solenv/gbuild/HelpTarget.mk b/solenv/gbuild/HelpTarget.mk
index 9aa622e8fdd9..f1c1d5845e00 100644
--- a/solenv/gbuild/HelpTarget.mk
+++ b/solenv/gbuild/HelpTarget.mk
@@ -38,7 +38,7 @@ gb_HelpTranslatePartTarget_COMMAND := $(call gb_Executable_get_command,helpex)
define gb_HelpTranslatePartTarget__command
$(call gb_Output_announce,$(2),$(true),HPX,1)
-HELPFILES=$(call var2file,$(shell $(gb_MKTEMP)),100,$(filter %.xhp,$(3))) && \
+HELPFILES=$(call var2file,$(shell $(gb_MKTEMP)),100,$(sort $(filter %.xhp,$(3)))) && \
$(call gb_Helper_abbreviate_dirs, \
$(if $(filter-out qtz,$(HELP_LANG)), \
POFILES=$(call var2file,$(shell $(gb_MKTEMP)),100,$(sort $(POFILES))) && \