[Libreoffice-commits] .: l10ntools/inc l10ntools/source
Joseph Powers
jpowers at kemper.freedesktop.org
Sat Jan 22 21:21:57 PST 2011
l10ntools/inc/export.hxx | 96 +++++++-------
l10ntools/source/export.cxx | 294 ++++++++++++++-----------------------------
l10ntools/source/export2.cxx | 117 ++++++-----------
3 files changed, 196 insertions(+), 311 deletions(-)
New commits:
commit 0b7cad0b7357909e1761b957f4b96b096c47d010
Author: Joseph Powers <jpowers27 at cox.net>
Date: Sat Jan 22 21:21:53 2011 -0800
Remove DECLARE_LIST( ExportListBase, ExportListEntry* )
diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index 6e402bc..a5749df 100644
--- a/l10ntools/inc/export.hxx
+++ b/l10ntools/inc/export.hxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -25,7 +25,7 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
+
#ifndef _EXPORT_HXX
#define _EXPORT_HXX
@@ -34,9 +34,6 @@
#include <l10ntools/directory.hxx>
#endif
-
-// #define MERGE_SOURCE_LANGUAGES <- To merge en-US and de resource
-
#include <tools/string.hxx>
#include <tools/list.hxx>
#include <tools/stream.hxx>
@@ -48,7 +45,7 @@
#include <iterator> /* std::iterator*/
#include <set> /* std::set*/
#include <vector> /* std::vector*/
-#include <queue>
+#include <queue>
#include <string>
#include <unistd.h>
@@ -104,22 +101,29 @@ typedef std::hash_map<ByteString , MergeData* , hashByteString,equalByteString>
#define LIST_REFID "LIST_REFID"
typedef ByteStringHashMap ExportListEntry;
-
-DECLARE_LIST( ExportListBase, ExportListEntry * )
+typedef ::std::vector< ExportListEntry* > ExportListBase;
//
// class ExportList
//
-class ExportList : public ExportListBase
+class ExportList
{
private:
+ ExportListBase maList;
ULONG nSourceLanguageListEntryCount;
public:
- ExportList() : ExportListBase() { nSourceLanguageListEntryCount = 0; }
+ ExportList() { nSourceLanguageListEntryCount = 0; }
ULONG GetSourceLanguageListEntryCount() { return nSourceLanguageListEntryCount; }
void NewSourceLanguageListEntry() { nSourceLanguageListEntryCount++; }
+ size_t size() const { return maList.size(); }
+ void push_back( ExportListEntry* item ) { maList.push_back( item ); }
+
+ ExportListEntry* operator [] ( size_t i )
+ {
+ return ( i < maList.size() ) ? maList[ i ] : NULL;
+ }
};
#define REFID_NONE 0xFFFF
@@ -145,7 +149,7 @@ class ResData
public:
~ResData();
BOOL SetId( const ByteString &rId, USHORT nLevel );
-
+
USHORT nWidth;
USHORT nChildIndex;
USHORT nIdLevel;
@@ -187,17 +191,17 @@ public:
ExportList *pItemList;
ExportList *pFilterList;
ExportList *pPairedList;
-
+
ByteString sPForm;
void Dump();
void addFallbackData( ByteString& sId , const ByteString& sText );
bool getFallbackData( ByteString& sId , ByteString& sText);
-
+
void addMergedLanguage( ByteString& sLang );
bool isMerged( ByteString& sLang );
ResData( const ByteString &rPF, const ByteString &rGId )
- :
+ :
nWidth( 0 ),
nChildIndex( 0 ),
nIdLevel( ID_LEVEL_NULL ),
@@ -217,7 +221,7 @@ public:
sTextTyp( "Text" ),
pStringList( NULL ),
pUIEntries( NULL ),
- pItemList( NULL ),
+ pItemList( NULL ),
pFilterList( NULL ),
pPairedList( NULL ),
sPForm( rPF )
@@ -226,7 +230,7 @@ public:
sPForm.EraseAllChars( '\r' );
};
ResData( const ByteString &rPF, const ByteString &rGId , const ByteString &rFilename )
- :
+ :
nChildIndex( 0 ),
nIdLevel( ID_LEVEL_NULL ),
bChild( FALSE ),
@@ -246,7 +250,7 @@ public:
sTextTyp( "Text" ),
pStringList( NULL ),
pUIEntries( NULL ),
- pItemList( NULL ),
+ pItemList( NULL ),
pFilterList( NULL ),
pPairedList( NULL ),
sPForm( rPF )
@@ -295,7 +299,7 @@ private:
CharSet aCharSet; // used charset in src
SvFileStream aOutput;
-
+
ResStack aResStack; // stack for parsing recursive
ByteString sActPForm; // hold cur. system
@@ -320,14 +324,14 @@ private:
ByteString sLastTextTyp;
static bool isInitialized;
ByteString sFilename;
-
+
public:
ParserQueue* pParseQueue; // public ?
static ByteString sLanguages; // public ?
static ByteString sForcedLanguages; // public ?
-
-
+
+
static bool skipProject( ByteString sPrj ) ;
static void InitLanguages( bool bMergeMode = false );
static void InitForcedLanguages( bool bMergeMode = false );
@@ -338,19 +342,19 @@ public:
static void RemoveUTF8ByteOrderMarker( ByteString &rString );
static bool hasUTF8ByteOrderMarker( const ByteString &rString );
static void RemoveUTF8ByteOrderMarkerFromFile( const ByteString &rFilename );
- static bool fileHasUTF8ByteOrderMarker( const ByteString &rString );
+ static bool fileHasUTF8ByteOrderMarker( const ByteString &rString );
static ByteString GetIsoLangByIndex( USHORT nIndex );
static void QuotHTML( ByteString &rString );
static bool CopyFile( const ByteString& source , const ByteString& dest );
static void QuotHTMLXRM( ByteString &rString );
static void UnquotHTML( ByteString &rString );
-
+
static const char* GetEnv( const char *pVar );
static int getCurrentDirectory( rtl::OUString& base_fqurl , rtl::OUString& base );
static bool isSourceLanguage( const ByteString &sLanguage );
- static bool isAllowed( const ByteString &sLanguage );
+ static bool isAllowed( const ByteString &sLanguage );
static bool LanguageAllowed( const ByteString &nLanguage );
static void Languages( std::vector<ByteString>::const_iterator& begin , std::vector<ByteString>::const_iterator& end );
@@ -359,7 +363,7 @@ public:
static void getCurrentDir( std::string& dir );
static void replaceEncoding( ByteString& rString );
-
+
static ByteString GetFallbackLanguage( const ByteString nLanguage );
static void FillInFallbacks( ResData *pResData );
static void FillInListFallbacks( ExportList *pList, const ByteString &nSource, const ByteString &nFallback );
@@ -367,7 +371,7 @@ public:
static BOOL ConvertLineEnds( ByteString sSource, ByteString sDestination );
static ByteString GetNativeFile( ByteString sSource );
static DirEntry GetTempFile();
-
+
static void DumpExportList( ByteString& sListName , ExportList& aList );
static ByteString DumpMap( ByteString& sMapName , ByteStringHashMap& aMap );
@@ -380,13 +384,13 @@ private:
BOOL WriteData( ResData *pResData, BOOL bCreateNew = FALSE );// called befor dest. cur ResData
BOOL WriteExportList( ResData *pResData, ExportList *pExportList,
const ByteString &rTyp, BOOL bCreateNew = FALSE );
-
+
ByteString MergePairedList( ByteString& sLine , ByteString& sText );
ByteString FullId(); // creates cur. GID
-
+
bool PairedListFallback( ByteString& sText , ResData& aResData );
-
+
ByteString GetPairedListID ( const ByteString& sText );
ByteString GetPairedListString ( const ByteString& sText );
ByteString StripList ( const ByteString& sText );
@@ -397,7 +401,7 @@ private:
ByteString GetText( const ByteString &rSource, int nToken );
BOOL PrepareTextToMerge( ByteString &rText, USHORT nTyp,
- ByteString &nLangIndex, ResData *pResData );
+ ByteString &nLangIndex, ResData *pResData );
void MergeRest( ResData *pResData, USHORT nMode = MERGE_MODE_NORMAL );
void ConvertMergeContent( ByteString &rText );
@@ -445,14 +449,14 @@ private:
public:
PFormEntrys( const ByteString &rPForm ) : ByteString( rPForm ) {};
ByteString Dump();
- void InsertEntry(
+ void InsertEntry(
const ByteString &nId ,
const ByteString &rText,
const ByteString &rQuickHelpText,
- const ByteString &rTitle
+ const ByteString &rTitle
)
{
-
+
sText[ nId ] = rText;
bTextFirst[ nId ] = true;
sQuickHelpText[ nId ] = rQuickHelpText;
@@ -475,7 +479,7 @@ public:
class MergeDataFile;
-class MergeData
+class MergeData
{
friend class MergeDataFile;
private:
@@ -490,7 +494,7 @@ public:
~MergeData();
PFormEntrys* InsertEntry( const ByteString &rPForm );
PFormEntrys* GetPFormEntrys( ResData *pResData );
-
+
void Insert( const ByteString& rPFO , PFormEntrys* pfEntrys );
PFormEntrys* GetPFObject( const ByteString& rPFO );
@@ -513,28 +517,28 @@ private:
ByteString sErrorLog;
SvFileStream aErrLog;
ByteStringSet aLanguageSet;
- MergeDataHashMap aMap;
+ MergeDataHashMap aMap;
ByteStringHashMap aLanguageMap;
std::vector<ByteString> aLanguageList;
ByteStringHashMap aFilenames;
-
+
public:
MergeDataFile( const ByteString &rFileName, const ByteString& rFile , BOOL bErrLog, CharSet aCharSet, bool bCaseSensitive = false );
~MergeDataFile();
-
-
+
+
std::vector<ByteString> GetLanguages();
MergeData *GetMergeData( ResData *pResData , bool bCaseSensitve = false );
-
+
PFormEntrys *GetPFormEntrys( ResData *pResData );
PFormEntrys *GetPFormEntrysCaseSensitive( ResData *pResData );
void InsertEntry( const ByteString &rTYP, const ByteString &rGID, const ByteString &rLID,
- const ByteString &rPFO,
+ const ByteString &rPFO,
const ByteString &nLang , const ByteString &rTEXT,
- const ByteString &rQHTEXT, const ByteString &rTITLE ,
- const ByteString &sFilename , bool bCaseSensitive
+ const ByteString &rQHTEXT, const ByteString &rTITLE ,
+ const ByteString &sFilename , bool bCaseSensitive
);
static USHORT GetLangIndex( USHORT nId );
static ByteString CreateKey( const ByteString& rTYP , const ByteString& rGID , const ByteString& rLID , const ByteString& rFilename , bool bCaseSensitive = false );
@@ -555,7 +559,7 @@ public:
class ParserQueue
{
public:
-
+
ParserQueue( Export& aExportObj );
~ParserQueue();
@@ -564,12 +568,12 @@ public:
bool bNextIsM; // public ?
bool bLastWasM; // public ?
bool bMflag; // public ?
-
+
void Close();
private:
// Future / Next
std::queue<QueueEntry>* aQueueNext;
- // Current
+ // Current
std::queue<QueueEntry>* aQueueCur;
// Ref
std::queue<QueueEntry>* aQref;
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index 3f20370..85864b7 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -104,7 +104,7 @@ extern char *GetOutputFile( int argc, char* argv[])
// parse command line
for( int i = 1; i < argc; i++ ) {
ByteString sSwitch( argv[ i ] );
-
+
if (sSwitch == "-i" || sSwitch == "-I" ) {
nState = STATE_INPUT; // next tokens specifies source files
}
@@ -250,7 +250,7 @@ extern FILE *GetNextFile()
sTempFile = sFileName;
Export::RemoveUTF8ByteOrderMarkerFromFile( sFileName );
-
+
// able to open file?
FILE *pFile = fopen( sFileName.GetBuffer(), "r" );
if ( !pFile )
@@ -275,7 +275,7 @@ extern FILE *GetNextFile()
sActFileName.SearchAndReplaceAll( "/", "\\" );
sFile = sActFileName;
-
+
if ( pExport ) {
// create instance of class export
pExport->Init();
@@ -289,7 +289,7 @@ extern FILE *GetNextFile()
}
int Parse( int nTyp, const char *pTokenText ){
- pExport->Execute( nTyp , pTokenText );
+ pExport->Execute( nTyp , pTokenText );
return 1;
}
void Close(){
@@ -346,7 +346,7 @@ void ResData::Dump(){
ByteString f("sText");
Export::DumpMap( f , sText );
-
+
if( pStringList ) Export::DumpExportList( a , *pStringList );
if( pUIEntries ) Export::DumpExportList( b , *pUIEntries );
if( pFilterList ) Export::DumpExportList( c , *pFilterList );
@@ -356,12 +356,10 @@ void ResData::Dump(){
}
void ResData::addFallbackData( ByteString& sId_in , const ByteString& sText_in ){
- //printf(" ResData::addFallbackData ( sId = %s , sText = %s )\n", sId_in.GetBuffer() , sText_in.GetBuffer() );
aFallbackData[ sId_in ] = sText_in;
}
bool ResData::getFallbackData( ByteString& sId_in , ByteString& sText_inout ){
sText_inout = aFallbackData[ sId_in ];
- //printf("ResData::getFallbackData( sId = %s , return sText = %s \n" , sId_in.GetBuffer(), sText_inout.GetBuffer());
return sText_inout.Len() > 0;
}
@@ -434,7 +432,7 @@ Export::Export( const ByteString &rOutput, BOOL bWrite,
(void) rPrj;
(void) rPrjRoot;
(void) rFile;
-
+
if( !isInitialized ) InitLanguages();
// used when export is enabled
@@ -514,7 +512,7 @@ void Export::Init()
Export::~Export()
/*****************************************************************************/
{
- if( pParseQueue )
+ if( pParseQueue )
delete pParseQueue;
// close output stream
if ( bEnableExport )
@@ -528,7 +526,6 @@ Export::~Export()
if ( !pMergeDataFile )
pMergeDataFile = new MergeDataFile( sMergeSrc,sFile , bErrorLog, aCharSet);//, bUTF8 );
- //pMergeDataFile->WriteErrorLog( sActFileName );
delete pMergeDataFile;
}
}
@@ -537,13 +534,9 @@ Export::~Export()
int Export::Execute( int nToken, const char * pToken )
/*****************************************************************************/
{
-
+
ByteString sToken( pToken );
ByteString sOrig( sToken );
-/* printf("+---------------\n");
- printf("sToken = %s\n",sToken.GetBuffer());
- printf("nToken = %d\n",nToken);
- printf("+---------------\n"); */
BOOL bWriteToMerged = bMergeMode;
if ( nToken == CONDITION ) {
@@ -579,11 +572,11 @@ int Export::Execute( int nToken, const char * pToken )
{
// no res. exists at cur. level so return
if ( bMergeMode )
- WriteToMerged( sOrig , false );
+ WriteToMerged( sOrig , false );
return 0;
}
// #define NO_LOCALIZE_EXPORT
- if( bSkipFile ){
+ if( bSkipFile ){
if ( bMergeMode ) {
WriteToMerged( sOrig , false );
}
@@ -599,11 +592,6 @@ int Export::Execute( int nToken, const char * pToken )
// end of macro found, so destroy res.
bDefine = FALSE;
if ( bMergeMode ) {
- /*if ( bDontWriteOutput && bUnmerge ) {
- bDontWriteOutput = FALSE;
- bNextMustBeDefineEOL = FALSE;
- bDefine = TRUE;
- }*/
MergeRest( pResData );
}
bNextMustBeDefineEOL = FALSE;
@@ -630,7 +618,7 @@ int Export::Execute( int nToken, const char * pToken )
USHORT nOpen = 0;
USHORT nClose = 0;
BOOL bReadOver1 = FALSE;
- USHORT i = 0;
+ USHORT i = 0;
for ( i = 0; i < sToken.Len(); i++ ) {
if ( sToken.GetChar( i ) == '\"' )
bReadOver1 = !bReadOver1;
@@ -650,9 +638,8 @@ int Export::Execute( int nToken, const char * pToken )
bExecuteDown = TRUE;
}
switch ( nToken ) {
-
+
case NORMDEFINE:
- //printf("sToken = '%s'",sToken.GetBuffer());
while( sToken.SearchAndReplace( "\r", " " ) != STRING_NOTFOUND ) {};
while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
while( sToken.SearchAndReplace( " ", " " ) != STRING_NOTFOUND ) {};
@@ -661,11 +648,11 @@ int Export::Execute( int nToken, const char * pToken )
return 0;
}
if ( bMergeMode )
- WriteToMerged( sOrig , false );
-
+ WriteToMerged( sOrig , false );
+
return 0;
-
-
+
+
case RSCDEFINE:
bDefine = TRUE; // res. defined in macro
@@ -782,7 +769,7 @@ int Export::Execute( int nToken, const char * pToken )
else
nListLevel--;
}
- }
+ }
break;
case ASSIGNMENT: {
bDontWriteOutput = FALSE;
@@ -800,34 +787,22 @@ int Export::Execute( int nToken, const char * pToken )
pResData->sHelpId = sValue;
}
else if ( sKey == "STRINGLIST" ) {
- //if ( bUnmerge ){
- // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
- //}
-
pResData->bList = TRUE;
nList = LIST_STRING;
- //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
nListLang = SOURCE_LANGUAGE;
nListIndex = 0;
nListLevel = 0;
}
else if ( sKey == "FILTERLIST" ) {
- //if ( bUnmerge ){
- // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
- //}
pResData->bList = TRUE;
nList = LIST_FILTER;
- //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
nListLang = SOURCE_LANGUAGE;
nListIndex = 0;
nListLevel = 0;
}
else if ( sKey == "UIENTRIES" ) {
- //if ( bUnmerge ){
- // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));}
pResData->bList = TRUE;
nList = LIST_UIENTRIES;
- //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
nListLang = SOURCE_LANGUAGE;
nListIndex = 0;
nListLevel = 0;
@@ -835,11 +810,8 @@ int Export::Execute( int nToken, const char * pToken )
if (( sToken.Search( "{" ) != STRING_NOTFOUND ) &&
( sToken.GetTokenCount( '{' ) > sToken.GetTokenCount( '}' )))
{
- //WorkOnTokenSet( LEVELUP, pTkn );
Parse( LEVELUP, "" );
}
- //if ( bUnmerge && ( nListLang.EqualsIgnoreCaseAscii("de") || nListLang.EqualsIgnoreCaseAscii("en-US") ) && ListExists( pResData, nList ))
- // bDontWriteOutput = TRUE;
}
break;
case UIENTRIES:
@@ -848,12 +820,8 @@ int Export::Execute( int nToken, const char * pToken )
ByteString sTmpToken( sToken);
sTmpToken.EraseAllChars(' ');
USHORT nPos = 0;
- //nPos = sTmpToken.ToLowerAscii().Search("[de]=");
nPos = sTmpToken.ToLowerAscii().Search("[en-us]=");
if( nPos != STRING_NOTFOUND ) {
- //if ( bUnmerge ){
- // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
- //}
ByteString sKey = sTmpToken.Copy( 0 , nPos );
sKey.EraseAllChars( ' ' );
sKey.EraseAllChars( '\t' );
@@ -862,7 +830,6 @@ int Export::Execute( int nToken, const char * pToken )
if ( sKey.ToUpperAscii() == "STRINGLIST" ) {
pResData->bList = TRUE;
nList = LIST_STRING;
- //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
nListLang = SOURCE_LANGUAGE;
nListIndex = 0;
nListLevel = 0;
@@ -870,7 +837,6 @@ int Export::Execute( int nToken, const char * pToken )
else if ( sKey == "FILTERLIST" ) {
pResData->bList = TRUE;
nList = LIST_FILTER;
- //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
nListLang = SOURCE_LANGUAGE;
nListIndex = 0;
nListLevel = 0;
@@ -879,7 +845,6 @@ int Export::Execute( int nToken, const char * pToken )
else if ( sKey == "PAIREDLIST" ) {
pResData->bList = TRUE;
nList = LIST_PAIRED;
- //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
nListLang = SOURCE_LANGUAGE;
nListIndex = 0;
nListLevel = 0;
@@ -888,7 +853,6 @@ int Export::Execute( int nToken, const char * pToken )
else if ( sKey == "ITEMLIST" ) {
pResData->bList = TRUE;
nList = LIST_ITEM;
- //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
nListLang = SOURCE_LANGUAGE;
nListIndex = 0;
nListLevel = 0;
@@ -896,15 +860,10 @@ int Export::Execute( int nToken, const char * pToken )
else if ( sKey == "UIENTRIES" ) {
pResData->bList = TRUE;
nList = LIST_UIENTRIES;
- //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
nListLang = SOURCE_LANGUAGE;
nListIndex = 0;
nListLevel = 0;
}
- /*if ( bUnmerge && ( nListLang.EqualsIgnoreCaseAscii( "de" )
- || nListLang.EqualsIgnoreCaseAscii("en-US" ) )
- && ListExists( pResData, nList ))
- bDontWriteOutput = TRUE;*/
}
else {
// new res. is a String- or FilterList
@@ -925,12 +884,8 @@ int Export::Execute( int nToken, const char * pToken )
ByteString sLang=sToken.GetToken( 1, '[' ).GetToken( 0, ']' );
CleanValue( sLang );
nListLang = sLang;
- /*if (( bUnmerge ) && ( !nListLang.EqualsIgnoreCaseAscii("de")) && ( !nListLang.EqualsIgnoreCaseAscii("en-US")))
- bDontWriteOutput = TRUE;*/
nListIndex = 0;
nListLevel = 0;
- /*if ( bUnmerge && nListLang.EqualsIgnoreCaseAscii("de") && ListExists( pResData, nList ) )
- bDontWriteOutput = TRUE;*/
}
}
}
@@ -946,8 +901,6 @@ int Export::Execute( int nToken, const char * pToken )
sEntry += "\"";
if ( sEntry == "\\\"" )
sEntry = "\"";
- //sEntry = sEntry.Convert( aCharSet, RTL_TEXTENCODING_MS_1252 );
- //sEntry = sEntry.Convert( RTL_TEXTENCODING_MS_1252, RTL_TEXTENCODING_UTF8 );
InsertListEntry( sEntry, sOrig );
if ( bMergeMode && ( sEntry != "\"" )) {
PrepareTextToMerge( sOrig, nList, nListLang, pResData );
@@ -982,20 +935,14 @@ int Export::Execute( int nToken, const char * pToken )
( sKey == "SLOTNAME" ) ||
( sKey == "UINAME" ))
{
- //if ( bUnmerge && sToken.GetToken( 0, '=' ).Search( "[" ) == STRING_NOTFOUND )
- // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
-
SetChildWithText();
- //if ( nLangIndex.EqualsIgnoreCaseAscii("en-US") )
- if ( Export::isSourceLanguage( nLangIndex ) )
+ if ( Export::isSourceLanguage( nLangIndex ) )
pResData->SetId( sText, ID_LEVEL_TEXT );
pResData->bText = TRUE;
pResData->sTextTyp = sOrigKey;
if ( bMergeMode ) {
PrepareTextToMerge( sOrig, STRING_TYP_TEXT, nLangIndex, pResData );
- //if ( bUnmerge )
- // pResData->sText[ nLangIndex ] = sText;
}
else {
if ( pResData->sText[ nLangIndex ].Len()) {
@@ -1007,9 +954,6 @@ int Export::Execute( int nToken, const char * pToken )
}
}
else if ( sKey == "HELPTEXT" ) {
- //if ( bUnmerge && sToken.GetToken( 0, '=' ).Search( "[" ) == STRING_NOTFOUND ){
- // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
- // }
SetChildWithText();
pResData->bHelpText = TRUE;
if ( bBreakWhenHelpText ) {
@@ -1020,8 +964,6 @@ int Export::Execute( int nToken, const char * pToken )
}
if ( bMergeMode )
PrepareTextToMerge( sOrig, STRING_TYP_HELPTEXT, nLangIndex, pResData );
- //if ( bUnmerge )
- // pResData->sHelpText[ nLangIndex ] = sText;
else {
if ( pResData->sHelpText[ nLangIndex ].Len()) {
ByteString sError( "Language " );
@@ -1032,15 +974,10 @@ int Export::Execute( int nToken, const char * pToken )
}
}
else if ( sKey == "QUICKHELPTEXT" ) {
- //if ( bUnmerge && sToken.GetToken( 0, '=' ).Search( "[" ) == STRING_NOTFOUND ){
- // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
- // }
SetChildWithText();
pResData->bQuickHelpText = TRUE;
if ( bMergeMode )
PrepareTextToMerge( sOrig, STRING_TYP_QUICKHELPTEXT, nLangIndex, pResData );
- //if ( bUnmerge )
- // pResData->sQuickHelpText[ nLangIndex ] = sText;
else {
if ( pResData->sQuickHelpText[ nLangIndex ].Len()) {
ByteString sError( "Language " );
@@ -1051,15 +988,10 @@ int Export::Execute( int nToken, const char * pToken )
}
}
else if ( sKey == "TITLE" ) {
- //if ( bUnmerge && sToken.GetToken( 0, '=' ).Search( "[" ) == STRING_NOTFOUND ){
- // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
- // }
SetChildWithText();
pResData->bTitle = TRUE;
if ( bMergeMode )
PrepareTextToMerge( sOrig, STRING_TYP_TITLE, nLangIndex, pResData );
- //if ( bUnmerge )
- // pResData->sTitle[ nLangIndex ] = sText;
else {
if ( pResData->sTitle[ nLangIndex ].Len()) {
ByteString sError( "Language " );
@@ -1080,12 +1012,6 @@ int Export::Execute( int nToken, const char * pToken )
break;
case NEWTEXTINRES: {
bDontWriteOutput = TRUE;
- // this means something like // ### Achtung : Neuer Text ...
- /*ByteString sLang( "GERMAN" );
- ByteString sText = sToken.GetToken( 2, ':' ).GetToken( 0, '*' );
- CleanValue( sText );
- if ( sText.Len())
- pResData->sText[ sLang ] = sText;*/
}
break;
case APPFONTMAPPING: {
@@ -1153,7 +1079,6 @@ int Export::Execute( int nToken, const char * pToken )
bDefine = FALSE;
while ( nLevel )
Parse( LEVELDOWN, "" );
- //WorkOnTokenSet( LEVELDOWN, pTkn );
}
}
break;
@@ -1182,30 +1107,14 @@ int Export::Execute( int nToken, const char * pToken )
break;
case TEXTREFID : {
bDontWriteOutput = TRUE;
- /*ByteString sK = sToken.GetToken( 0, '=' );
- ByteString sKey = sK.EraseAllChars( '\t' ).EraseAllChars( ' ' );
- ByteString sT = sToken.GetToken( 1, '=' ).GetToken( 0, ';' );
- USHORT nRefId = ( USHORT ) sT.EraseAllChars( '\t' ).EraseAllChars( ' ' ).ToInt32();
- if (( sKey.ToUpperAscii() == "TEXT" ) ||
- ( sKey == "MESSAGE" ) ||
- ( sKey == "CUSTOMUNITTEXT" ) ||
- ( sKey == "SLOTNAME" ) ||
- ( sKey == "UINAME" ))
- pResData->nTextRefId = nRefId;
- else if ( sKey == "HELPTEXT" )
- pResData->nHelpTextRefId = nRefId;
- else if ( sKey == "QUICKHELPTEXT" )
- pResData->nQuickHelpTextRefId = nRefId;
- else if ( sKey == "TITLE" )
- pResData->nTitleRefId = nRefId;*/
}
}
if ( bWriteToMerged ) {
// the current token must be written to dest. without merging
-
+
if( bDefine && sOrig.Len() > 2 ){
for( USHORT n = 0 ; n < sOrig.Len() ; n++ ){
- if( sOrig.GetChar( n ) == '\n' && sOrig.GetChar( n-1 ) != '\\'){
+ if( sOrig.GetChar( n ) == '\n' && sOrig.GetChar( n-1 ) != '\\'){
sOrig.Insert('\\' , n++ );
}
}
@@ -1215,7 +1124,6 @@ int Export::Execute( int nToken, const char * pToken )
if ( bExecuteDown ) {
Parse( LEVELDOWN, "" );
- //WorkOnTokenSet( LEVELDOWN, pTkn );
}
return 1;
@@ -1263,11 +1171,11 @@ BOOL Export::ListExists( ResData *pResData, USHORT nLst )
/*****************************************************************************/
{
switch ( nLst ) {
- case LIST_STRING: return pResData->pStringList != NULL;
+ case LIST_STRING: return pResData->pStringList != NULL;
case LIST_FILTER: return pResData->pFilterList != NULL;
- case LIST_ITEM: return pResData->pItemList != NULL;
- case LIST_PAIRED: return pResData->pPairedList != NULL;
- case LIST_UIENTRIES: return pResData->pUIEntries != NULL;
+ case LIST_ITEM: return pResData->pItemList != NULL;
+ case LIST_PAIRED: return pResData->pPairedList != NULL;
+ case LIST_UIENTRIES: return pResData->pUIEntries != NULL;
}
return FALSE;
}
@@ -1287,23 +1195,23 @@ BOOL Export::WriteData( ResData *pResData, BOOL bCreateNew )
/* ByteStringHashMap::iterator pos3 = pResData->sText.begin();
ByteStringHashMap::iterator end3 = pResData->sText.end();
for(;pos3!=end3;++pos3){
-
+
printf("[%s]=%s\n", pos3->first.GetBuffer(), pos3->second.GetBuffer() );
}*/
- // mandatory to export: en-US
-
+ // mandatory to export: en-US
+
if (( //pResData->sText[ ByteString("de") ].Len() &&
( pResData->sText[ SOURCE_LANGUAGE ].Len()))
||
( //pResData->sHelpText[ ByteString("de") ].Len() &&
- ( pResData->sHelpText[ SOURCE_LANGUAGE ].Len()))
+ ( pResData->sHelpText[ SOURCE_LANGUAGE ].Len()))
||
( //pResData->sQuickHelpText[ ByteString("de") ].Len() &&
( pResData->sQuickHelpText[ SOURCE_LANGUAGE ].Len()))
||
( //pResData->sTitle[ ByteString("de") ].Len() &&
( pResData->sTitle[ SOURCE_LANGUAGE ].Len())))
-
+
{
FillInFallbacks( pResData );
@@ -1392,15 +1300,15 @@ BOOL Export::WriteData( ResData *pResData, BOOL bCreateNew )
sOutput += pResData->sPForm; sOutput += "\t";
sOutput += ByteString::CreateFromInt64( pResData->nWidth ); sOutput += "\t";
sOutput += sCur; sOutput += "\t";
-
+
sOutput += sXText; sOutput += "\t";
sOutput += sXHText; sOutput += "\t";
sOutput += sXQHText; sOutput+= "\t";
sOutput += sXTitle; sOutput += "\t";
sOutput += sTimeStamp;
-
- // if( !sCur.EqualsIgnoreCaseAscii("de") ||( sCur.EqualsIgnoreCaseAscii("de") && !Export::isMergingGermanAllowed( sProject ) ) )
+
+ // if( !sCur.EqualsIgnoreCaseAscii("de") ||( sCur.EqualsIgnoreCaseAscii("de") && !Export::isMergingGermanAllowed( sProject ) ) )
aOutput.WriteLine( sOutput );
}
@@ -1486,11 +1394,11 @@ BOOL Export::WriteExportList( ResData *pResData, ExportList *pExportList,
ByteString sTimeStamp( Export::GetTimeStamp());
ByteString sCur;
- for ( ULONG i = 0; pExportList != NULL && i < pExportList->Count(); i++ ) {
- ExportListEntry *pEntry = pExportList->GetObject( i );
- // mandatory for export: german and eng. and/or enus
- //ByteString a("Export::WriteExportList::pEntry");
- //Export::DumpMap( a, *pEntry );
+ for ( size_t i = 0; pExportList != NULL && i < pExportList->size(); i++ ) {
+ ExportListEntry *pEntry = (*pExportList)[ i ];
+ // mandatory for export: german and eng. and/or enus
+ // ByteString a("Export::WriteExportList::pEntry");
+ // Export::DumpMap( a, *pEntry );
ByteString sLID( ByteString::CreateFromInt64( i + 1 ));
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
@@ -1504,13 +1412,13 @@ BOOL Export::WriteExportList( ResData *pResData, ExportList *pExportList,
if ( bEnableExport )
{
ByteString sText((*pEntry)[ SOURCE_LANGUAGE ] );
-
+
// Strip PairList Line String
if( rTyp.EqualsIgnoreCaseAscii("pairedlist") ){
sLID = GetPairedListID( sText );
if ((*pEntry)[ sCur ].Len())
sText = (*pEntry)[ sCur ];
- sText = GetPairedListString( sText );
+ sText = GetPairedListString( sText );
}
else{
//if ((*pEntry)[ sCur ].Len()){
@@ -1536,7 +1444,7 @@ BOOL Export::WriteExportList( ResData *pResData, ExportList *pExportList,
sOutput += sText; sOutput += "\t\t\t\t";
sOutput += sTimeStamp;
-
+
//if( !sCur.EqualsIgnoreCaseAscii("de") ||( sCur.EqualsIgnoreCaseAscii("de") && !Export::isMergingGermanAllowed( sProject ) ) )
aOutput.WriteLine( sOutput );
@@ -1620,26 +1528,26 @@ void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine )
pList = pResData->pUIEntries;
if ( !pList ) {
pResData->pUIEntries = new ExportList();
- pList = pResData->pUIEntries;
+ pList = pResData->pUIEntries;
nListIndex = 0;
}
}
else
return;
- if ( nListIndex + 1 > pList->Count()) {
+ if ( nListIndex + 1 > pList->size()) {
ExportListEntry *pNew = new ExportListEntry();
(*pNew)[ LIST_REFID ] = ByteString::CreateFromInt32( REFID_NONE );
- pList->Insert( pNew, LIST_APPEND );
+ pList->push_back( pNew );
}
- ExportListEntry *pCurEntry = pList->GetObject( nListIndex );
-
+ ExportListEntry *pCurEntry = (*pList)[ nListIndex ];
+
// For paired list use the line to set proper lid
if( nList == LIST_PAIRED ){
(*pCurEntry)[ nListLang ] = rLine;
}else
(*pCurEntry)[ nListLang ] = rText;
-
+
// Remember en-US fallback string, so each list has the same amount of elements
//if ( nListLang.EqualsIgnoreCaseAscii("en-US") ) {
if ( Export::isSourceLanguage( nListLang ) ) {
@@ -1661,7 +1569,7 @@ void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine )
}
// new fallback
}
-
+
//if ( nListLang.EqualsIgnoreCaseAscii("en-US") ) {
if ( Export::isSourceLanguage( nListLang ) ) {
if( nList == LIST_PAIRED ){
@@ -1669,7 +1577,7 @@ void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine )
}
else
(*pCurEntry)[ SOURCE_LANGUAGE ] = rLine;
-
+
pList->NewSourceLanguageListEntry();
}
@@ -1790,31 +1698,31 @@ void Export::WriteToMerged( const ByteString &rText , bool bSDFContent )
while ( sText.SearchAndReplace( " \n", "\n" ) != STRING_NOTFOUND ) {};
if( pParseQueue->bNextIsM && bSDFContent && sText.Len() > 2 ){
for( USHORT n = 0 ; n < sText.Len() ; n++ ){
- if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
+ if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
sText.Insert('\\' , n++ );
-
+
}
}
}
- else if( pParseQueue->bLastWasM && sText.Len() > 2 ){
+ else if( pParseQueue->bLastWasM && sText.Len() > 2 ){
for( USHORT n = 0 ; n < sText.Len() ; n++ ){
- if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
+ if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
sText.Insert('\\' , n++ );
}
if( sText.GetChar( n ) == '\n' )pParseQueue->bMflag=true;
}
}
- else if( pParseQueue->bCurrentIsM && bSDFContent && sText.Len() > 2 ){
+ else if( pParseQueue->bCurrentIsM && bSDFContent && sText.Len() > 2 ){
for( USHORT n = 0 ; n < sText.Len() ; n++ ){
- if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
+ if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
sText.Insert('\\' , n++ );
pParseQueue->bMflag=true;
}
}
}
- else if( pParseQueue->bMflag ){
+ else if( pParseQueue->bMflag ){
for( USHORT n = 1 ; n < sText.Len() ; n++ ){
- if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
+ if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
sText.Insert('\\' , n++ );
}
}
@@ -1822,12 +1730,12 @@ void Export::WriteToMerged( const ByteString &rText , bool bSDFContent )
for ( USHORT i = 0; i < sText.Len(); i++ ) {
if ( sText.GetChar( i ) != '\n' ){
aOutput.Write( ByteString( sText.GetChar( i )).GetBuffer(), 1 );
-
+
}
else{
aOutput.WriteLine( ByteString());
}
-
+
}
}
}
@@ -1942,14 +1850,14 @@ BOOL Export::PrepareTextToMerge( ByteString &rText, USHORT nTyp,
}
if ( pList ) {
- ExportListEntry *pCurEntry = pList->GetObject( nListIndex - 1 );
+ ExportListEntry *pCurEntry = (*pList)[ nListIndex - 1 ];
if ( pCurEntry ) {
//printf("%s\n",Export::DumpMap( "pCurEntry", *pCurEntry ).GetBuffer() );
//ByteString a("pCurEntry");
//Export::DumpMap( a , *pCurEntry );
rText = (*pCurEntry)[ SOURCE_LANGUAGE ];
- if( nTyp == LIST_PAIRED ){
- pResData->addMergedLanguage( nLangIndex );
+ if( nTyp == LIST_PAIRED ){
+ pResData->addMergedLanguage( nLangIndex );
}
}
}
@@ -1980,10 +1888,10 @@ BOOL Export::PrepareTextToMerge( ByteString &rText, USHORT nTyp,
sLastListLine += sTmp;
}
if ( pResData->sResTyp.EqualsIgnoreCaseAscii( "pairedlist" ) ){
- pResData->sId = GetPairedListID( sLastListLine );
+ pResData->sId = GetPairedListID( sLastListLine );
}
else pResData->sId = ByteString::CreateFromInt32( nListIndex );
-
+
if ( pResData->sGId.Len())
pResData->sGId += ".";
pResData->sGId += sOldId;
@@ -2046,7 +1954,7 @@ BOOL Export::PrepareTextToMerge( ByteString &rText, USHORT nTyp,
// search for merge data
if ( !pMergeDataFile ){
pMergeDataFile = new MergeDataFile( sMergeSrc, sFile , bErrorLog, aCharSet);//, bUTF8 );
-
+
// Init Languages
ByteString sTmp = Export::sLanguages;
if( sTmp.ToUpperAscii().Equals("ALL") )
@@ -2057,7 +1965,7 @@ BOOL Export::PrepareTextToMerge( ByteString &rText, USHORT nTyp,
// printf("*************DUMPING****************\n");
// printf("%s\n",pMergeDataFile->Dump().GetBuffer());
// printf("*************DUMPING****************\n");
-
+
// printf("Dumping ResData\n");
// pResData->Dump();
PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrys( pResData );
@@ -2077,7 +1985,7 @@ BOOL Export::PrepareTextToMerge( ByteString &rText, USHORT nTyp,
//if ( !sContent.Len() && ( ! nLangIndex.EqualsIgnoreCaseAscii("en-US") )) {
if ( !sContent.Len() && ( ! Export::isSourceLanguage( nLangIndex ) )) {
rText = sOrigText;
- return FALSE; // no data found
+ return FALSE; // no data found
}
//if ( nLangIndex.EqualsIgnoreCaseAscii("en-US") ) {
@@ -2111,7 +2019,7 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
if ( !pMergeDataFile ){
pMergeDataFile = new MergeDataFile( sMergeSrc, sFile ,bErrorLog, aCharSet);//, bUTF8 );
-
+
// Init Languages
ByteString sTmp = Export::sLanguages;
if( sTmp.ToUpperAscii().Equals("ALL") )
@@ -2122,10 +2030,10 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
switch ( nMode ) {
case MERGE_MODE_NORMAL : {
PFormEntrys *pEntry = pMergeDataFile->GetPFormEntrys( pResData );
-
+
bool bWriteNoSlash = false;
if ( pEntry && pResData->bText ) {
-
+
BOOL bAddSemikolon = FALSE;
BOOL bFirst = TRUE;
ByteString sCur;
@@ -2171,7 +2079,7 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
WriteToMerged( sOutput , true );
}
}
-
+
if ( bAddSemikolon ) {
ByteString sOutput( ";" );
@@ -2277,7 +2185,7 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
if ( pResData->bList ) {
//printf("Dumping ResData\n");
//pResData->Dump();
-
+
bool bPairedList = false;
ByteString sOldId = pResData->sId;
ByteString sOldGId = pResData->sGId;
@@ -2299,17 +2207,17 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
}
ByteString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
- sCur = aLanguages[ n ];
+ sCur = aLanguages[ n ];
USHORT nIdx = 1;
-
- // Set matching pairedlist identifier
+
+ // Set matching pairedlist identifier
if( bPairedList && pResData->pPairedList && ( nIdx == 1 ) ){
- ExportListEntry* pListE = ( ExportListEntry* ) pResData->pPairedList->GetObject( nIdx-1 );
+ ExportListEntry* pListE = ( ExportListEntry* ) (*pResData->pPairedList)[ nIdx-1 ];
pResData->sId = GetPairedListID ( (*pListE)[ SOURCE_LANGUAGE ] );
- }
+ }
else
pResData->sId = ByteString("1");
-
+
PFormEntrys *pEntrys;
ULONG nLIndex = 0;
ULONG nMaxIndex = 0;
@@ -2325,24 +2233,24 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
bText = pEntrys->GetTransex3Text( sText , STRING_TYP_TEXT, SOURCE_LANGUAGE , FALSE );
// Use fallback, if data is missing in sdf file
- //if( !bText && pResData->sResTyp.Equals( "pairedlist" ) ){
- if( !bText && bPairedList ){
- if( pResData->isMerged( sCur ) ) break;
+ //if( !bText && pResData->sResTyp.Equals( "pairedlist" ) ){
+ if( !bText && bPairedList ){
+ if( pResData->isMerged( sCur ) ) break;
const ByteString sPlist("pairedlist");
ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sGId , pResData->sId , sFilename );
bText = pResData->getFallbackData( sKey , sText );
}else if ( !bText ){// new fallback
- if( pResData->isMerged( sCur ) ) break;
+ if( pResData->isMerged( sCur ) ) break;
const ByteString sPlist("list");
ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sGId , pResData->sId , sFilename );
bText = pResData->getFallbackData( sKey , sText );
} // new fallback
if ( bText && sText.Len()) {
- //if( pEntrys ) pEntrys->Dump();
+ //if( pEntrys ) pEntrys->Dump();
if ( nIdx == 1 ) {
ByteString sHead;
- if ( bNextMustBeDefineEOL )
+ if ( bNextMustBeDefineEOL )
sHead = "\\\n\t";
sHead += sSpace;
switch ( nT ) {
@@ -2369,8 +2277,8 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
WriteToMerged( sHead , true);
}
ByteString sLine;
- if ( pList && pList->GetObject( nLIndex ))
- sLine = ( *pList->GetObject( nLIndex ))[ SOURCE_LANGUAGE ];
+ if ( pList && (*pList)[ nLIndex ] )
+ sLine = ( *(*pList)[ nLIndex ])[ SOURCE_LANGUAGE ];
if ( !sLine.Len())
sLine = sLastListLine;
@@ -2387,7 +2295,7 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
USHORT nStart, nEnd;
nStart = sLine.Search( "\"" );
-
+
ByteString sPostFix;
if( !bPairedList ){
nEnd = sLine.SearchBackward( '\"' );
@@ -2417,11 +2325,11 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
sText1 += "\t";
//printf("Writing '%s'\n",sText1.GetBuffer());
WriteToMerged( sText1 ,true );
-
- // Set matching pairedlist identifier
+
+ // Set matching pairedlist identifier
if ( bPairedList ){
nIdx++;
- ExportListEntry* pListE = ( ExportListEntry* ) pResData->pPairedList->GetObject( ( nIdx ) -1 );
+ ExportListEntry* pListE = ( ExportListEntry* )(*pResData->pPairedList)[ ( nIdx ) -1 ];
if( pListE ){
pResData->sId = GetPairedListID ( (*pListE)[ SOURCE_LANGUAGE ] );
}
@@ -2473,8 +2381,8 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
if ( pList )
nMaxIndex = pList->GetSourceLanguageListEntryCount();
ByteString sLine;
- if ( pList && pList->GetObject( nListIndex ))
- sLine = ( *pList->GetObject( nListIndex ))[ SOURCE_LANGUAGE ];
+ if ( pList && (*pList)[ nListIndex ] )
+ sLine = ( *(*pList)[ nListIndex ])[ SOURCE_LANGUAGE ];
if ( !sLine.Len())
sLine = sLastListLine;
@@ -2489,7 +2397,7 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
}
}
- while( PrepareTextToMerge( sLine, nList, nListLang, pResData ) && ( nListIndex <= nMaxIndex )) {
+ while( PrepareTextToMerge( sLine, nList, nListLang, pResData ) && ( nListIndex <= nMaxIndex )) {
ByteString sText( "\t" );
sText += sLine;
sText += " ;";
@@ -2498,8 +2406,8 @@ void Export::MergeRest( ResData *pResData, USHORT nMode )
sText += "\t";
WriteToMerged( sText ,false );
nListIndex++;
- if ( pList && pList->GetObject( nListIndex ))
- sLine = ( *pList->GetObject( nListIndex ))[ SOURCE_LANGUAGE ];
+ if ( pList && (*pList)[ nListIndex ])
+ sLine = ( *(*pList)[ nListIndex ])[ SOURCE_LANGUAGE ];
if ( !sLine.Len())
sLine = sLastListLine;
sLine += " ;";
@@ -2590,7 +2498,7 @@ void ParserQueue::Push( const QueueEntry& aEntry ){
aQref = aQueueCur;
aQueueCur = aQueueNext;
aQueueNext = aQref;
- }
+ }
}
}
@@ -2608,19 +2516,19 @@ void ParserQueue::Close(){
};
void ParserQueue::Pop( std::queue<QueueEntry>& aQueue ){
while( !aQueue.empty() ){
- QueueEntry aEntry = aQueue.front();
+ QueueEntry aEntry = aQueue.front();
aQueue.pop();
aExport.Execute( aEntry.nTyp , (char*) aEntry.sLine.GetBuffer() );
}
}
ParserQueue::ParserQueue( Export& aExportObj )
- :
- bCurrentIsM( false ),
- bNextIsM( false ) ,
+ :
+ bCurrentIsM( false ),
+ bNextIsM( false ) ,
bLastWasM( false ),
bMflag( false ) ,
aExport( aExportObj ) ,
- bStart( false ) ,
+ bStart( false ) ,
bStartNext( false )
{
aQueueNext = new std::queue<QueueEntry>;
diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx
index ae80731..36280e2 100644
--- a/l10ntools/source/export2.cxx
+++ b/l10ntools/source/export2.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -54,32 +54,32 @@ ResData::~ResData()
{
if ( pStringList ) {
// delete existing res. of type StringList
- for ( ULONG i = 0; i < pStringList->Count(); i++ ) {
- ExportListEntry* test = pStringList->GetObject( i );
+ for ( size_t i = 0; i < pStringList->size(); i++ ) {
+ ExportListEntry* test = (*pStringList)[ i ];
if( test != NULL ) delete test;
}
delete pStringList;
}
if ( pFilterList ) {
// delete existing res. of type FilterList
- for ( ULONG i = 0; i < pFilterList->Count(); i++ ) {
- ExportListEntry* test = pFilterList->GetObject( i );
+ for ( size_t i = 0; i < pFilterList->size(); i++ ) {
+ ExportListEntry* test = (*pFilterList)[ i ];
delete test;
}
delete pFilterList;
}
if ( pItemList ) {
// delete existing res. of type ItemList
- for ( ULONG i = 0; i < pItemList->Count(); i++ ) {
- ExportListEntry* test = pItemList->GetObject( i );
+ for ( size_t i = 0; i < pItemList->size(); i++ ) {
+ ExportListEntry* test = (*pItemList)[ i ];
delete test;
}
delete pItemList;
}
if ( pUIEntries ) {
// delete existing res. of type UIEntries
- for ( ULONG i = 0; i < pUIEntries->Count(); i++ ) {
- ExportListEntry* test = pUIEntries->GetObject( i );
+ for ( size_t i = 0; i < pUIEntries->size(); i++ ) {
+ ExportListEntry* test = (*pUIEntries)[ i ];
delete test;
}
delete pUIEntries;
@@ -100,8 +100,8 @@ void Export::DumpExportList( ByteString& sListName , ExportList& aList ){
printf( "%s\n", sListName.GetBuffer() );
ByteString l("");
ExportListEntry* aEntry;
- for( unsigned int x = 0; x < aList.Count() ; x++ ){
- aEntry = (ExportListEntry*) aList.GetObject( x );
+ for( unsigned int x = 0; x < aList.size() ; x++ ){
+ aEntry = (ExportListEntry*) aList[ x ];
Export::DumpMap( l , *aEntry );
}
printf("\n");
@@ -109,7 +109,7 @@ void Export::DumpExportList( ByteString& sListName , ExportList& aList ){
ByteString Export::DumpMap( ByteString& sMapName , ByteStringHashMap& aMap ){
ByteStringHashMap::const_iterator idbg;
ByteString sReturn;
-
+
if( sMapName.Len() )
printf("MapName %s\n", sMapName.GetBuffer());
if( aMap.size() < 1 ) return ByteString();
@@ -129,14 +129,14 @@ void Export::SetLanguages( std::vector<ByteString> val ){
isInitialized = true;
}
/*****************************************************************************/
-std::vector<ByteString> Export::GetLanguages(){
+std::vector<ByteString> Export::GetLanguages(){
/*****************************************************************************/
- return aLanguages;
+ return aLanguages;
}
/*****************************************************************************/
-std::vector<ByteString> Export::GetForcedLanguages(){
+std::vector<ByteString> Export::GetForcedLanguages(){
/*****************************************************************************/
- return aForcedLanguages;
+ return aForcedLanguages;
}
std::vector<ByteString> Export::aLanguages = std::vector<ByteString>();
std::vector<ByteString> Export::aForcedLanguages = std::vector<ByteString>();
@@ -160,7 +160,7 @@ void Export::QuotHTMLXRM( ByteString &rString )
i++;
}
}
-
+
if ( i < rString.Len()) {
switch ( rString.GetChar( i )) {
case '<':
@@ -270,13 +270,13 @@ void Export::RemoveUTF8ByteOrderMarker( ByteString &rString ){
bool Export::hasUTF8ByteOrderMarker( const ByteString &rString ){
// Byte order marker signature
-
+
const unsigned char c1 = 0xEF;
const unsigned char c2 = 0xBB;
const unsigned char c3 = 0xBF;
const char bom[ 3 ] = { c1 , c2 , c3 };
-
+
return rString.Len() >= 3 &&
rString.GetChar( 0 ) == bom[ 0 ] &&
rString.GetChar( 1 ) == bom[ 1 ] &&
@@ -300,13 +300,11 @@ void Export::RemoveUTF8ByteOrderMarkerFromFile( const ByteString &rFilename ){
aFileIn.ReadLine( sLine );
// Test header
if( hasUTF8ByteOrderMarker( sLine ) ){
- //cout << "UTF8 Header found!\n";
DirEntry aTempFile = Export::GetTempFile();
ByteString sTempFile = ByteString( aTempFile.GetFull() , RTL_TEXTENCODING_ASCII_US );
SvFileStream aNewFile( String( sTempFile , RTL_TEXTENCODING_ASCII_US ) , STREAM_WRITE );
// Remove header
RemoveUTF8ByteOrderMarker( sLine );
- //cout << "Copy stripped stuff to " << sTempFile.GetBuffer() << endl;
aNewFile.WriteLine( sLine );
// Copy the rest
while( !aFileIn.IsEof() ){
@@ -316,40 +314,15 @@ void Export::RemoveUTF8ByteOrderMarkerFromFile( const ByteString &rFilename ){
if( aFileIn.IsOpen() ) aFileIn.Close();
if( aNewFile.IsOpen() ) aNewFile.Close();
DirEntry aEntry( rFilename.GetBuffer() );
- //cout << "Removing file " << rFilename.GetBuffer() << "\n";
aEntry.Kill();
- //cout << "Renaming file " << sTempFile.GetBuffer() << " to " << rFilename.GetBuffer() << "\n";
DirEntry( sTempFile ).MoveTo( DirEntry( rFilename.GetBuffer() ) );
}
}
if( aFileIn.IsOpen() ) aFileIn.Close();
}
-// Merge it into source code!
-//bool Export::isMergingGermanAllowed( const ByteString& rPrj ){
-// (void) rPrj;
-// return true;
-/* static ByteStringBoolHashMap aHash;
-
- if( aHash.find( rPrj ) != aHash.end() ){
- return aHash[ rPrj ];
- }
-
- ByteString sFile = Export::GetEnv( "SRC_ROOT" ) ;
- sFile.Append("/");
- sFile.Append( rPrj );
- sFile.Append("/prj/l10n");
-#if defined(WNT) || defined(OS2)
- sFile.SearchAndReplaceAll('/','\\');
-#endif
- DirEntry aFlagfile( sFile );
-
- aHash[ rPrj ] = !aFlagfile.Exists();
- return aHash[ rPrj ];*/
-//}
bool Export::CopyFile( const ByteString& source , const ByteString& dest )
{
-// cout << "CopyFile( " << source.GetBuffer() << " , " << dest.GetBuffer() << " )\n";
const int BUFFERSIZE = 8192;
char buf[ BUFFERSIZE ];
@@ -367,7 +340,7 @@ bool Export::CopyFile( const ByteString& source , const ByteString& dest )
fclose( IN_FILE );
return false;
}
-
+
while( fgets( buf , BUFFERSIZE , IN_FILE ) != NULL )
{
if( fputs( buf , OUT_FILE ) == EOF )
@@ -387,7 +360,7 @@ bool Export::CopyFile( const ByteString& source , const ByteString& dest )
}
fclose ( IN_FILE );
fclose ( OUT_FILE );
-
+
return true;
}
@@ -466,7 +439,7 @@ void Export::InitForcedLanguages( bool bMergeMode ){
for ( USHORT x = 0; x < sForcedLanguages.GetTokenCount( ',' ); x++ ){
sTmp = sForcedLanguages.GetToken( x, ',' ).GetToken( 0, '=' );
sTmp.EraseLeadingAndTrailingChars();
- if( bMergeMode && isAllowed( sTmp ) ){}
+ if( bMergeMode && isAllowed( sTmp ) ){}
else if( !( (sTmp.GetChar(0)=='x' || sTmp.GetChar(0)=='X') && sTmp.GetChar(1)=='-' ) )
aForcedLanguages.push_back( sTmp );
}
@@ -487,8 +460,8 @@ void Export::replaceEncoding( ByteString& rString )
for( xub_StrLen idx = 0; idx <= rString.Len()-8 ; idx++ )
{
- if( rString.GetChar( idx ) == '&' &&
- rString.GetChar( idx+1 ) == '#' &&
+ if( rString.GetChar( idx ) == '&' &&
+ rString.GetChar( idx+1 ) == '#' &&
rString.GetChar( idx+2 ) == 'x' &&
rString.GetChar( idx+7 ) == ';' )
{
@@ -502,7 +475,7 @@ void Export::replaceEncoding( ByteString& rString )
rString = sTmp;
}
}
-}
+}
/*****************************************************************************/
void Export::FillInFallbacks( ResData *pResData )
@@ -512,18 +485,18 @@ void Export::FillInFallbacks( ResData *pResData )
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
if( isAllowed( sCur ) ){
- ByteString nFallbackIndex = GetFallbackLanguage( sCur );
+ ByteString nFallbackIndex = GetFallbackLanguage( sCur );
if( nFallbackIndex.Len() ){
if ( !pResData->sText[ sCur ].Len())
- pResData->sText[ sCur ] =
+ pResData->sText[ sCur ] =
pResData->sText[ nFallbackIndex ];
if ( !pResData->sHelpText[ sCur ].Len())
- pResData->sHelpText[ sCur ] =
+ pResData->sHelpText[ sCur ] =
pResData->sHelpText[ nFallbackIndex ];
if ( !pResData->sQuickHelpText[ sCur ].Len())
- pResData->sQuickHelpText[ sCur ] =
+ pResData->sQuickHelpText[ sCur ] =
pResData->sQuickHelpText[ nFallbackIndex ];
if ( !pResData->sTitle[ sCur ].Len())
@@ -533,11 +506,11 @@ void Export::FillInFallbacks( ResData *pResData )
if ( pResData->pStringList )
FillInListFallbacks(
pResData->pStringList, sCur, nFallbackIndex );
-
+
if ( pResData->pPairedList )
FillInListFallbacks(
pResData->pPairedList, sCur, nFallbackIndex );
-
+
if ( pResData->pFilterList )
FillInListFallbacks(
pResData->pFilterList, sCur, nFallbackIndex );
@@ -552,16 +525,16 @@ void Export::FillInFallbacks( ResData *pResData )
}
}
}
-}
+}
/*****************************************************************************/
void Export::FillInListFallbacks(
ExportList *pList, const ByteString &nSource, const ByteString &nFallback )
/*****************************************************************************/
-{
+{
- for ( ULONG i = 0; i < pList->Count(); i++ ) {
- ExportListEntry *pEntry = pList->GetObject( i );
+ for ( size_t i = 0; i < pList->size(); i++ ) {
+ ExportListEntry *pEntry = (*pList)[ i ];
if ( !( *pEntry )[ nSource ].Len()){
( *pEntry )[ nSource ] = ( *pEntry )[ nFallback ];
ByteString x = ( *pEntry )[ nSource ];
@@ -577,7 +550,7 @@ ByteString Export::GetTimeStamp()
// return "xx.xx.xx";
char buf[20];
Time aTime;
-
+
snprintf(buf, sizeof(buf), "%8d %02d:%02d:%02d", int(Date().GetDate()),
int(aTime.GetHour()), int(aTime.GetMin()), int(aTime.GetSec()));
return ByteString(buf);
@@ -672,7 +645,7 @@ void Export::getRandomName( const ByteString& sPrefix , ByteString& sRandStr , c
static sal_uInt64 value;
char buffer[RAND_NAME_LENGTH];
-
+
TimeValue tv;
sal_uInt64 v;
int i;
@@ -681,7 +654,7 @@ void Export::getRandomName( const ByteString& sPrefix , ByteString& sRandStr , c
oslProcessInfo proInfo;
proInfo.Size = sizeof(oslProcessInfo);
osl_getProcessInfo( 0 , osl_Process_IDENTIFIER , &proInfo );
-
+
value += ((sal_uInt64) ( tv.Nanosec / 1000 ) << 16) ^ ( tv.Nanosec / 1000 ) ^ proInfo.Ident;
v = value;
@@ -691,7 +664,7 @@ void Export::getRandomName( const ByteString& sPrefix , ByteString& sRandStr , c
buffer[i] = LETTERS[v % COUNT_OF_LETTERS];
v /= COUNT_OF_LETTERS;
}
-
+
sRandStr.Append( buffer , RAND_NAME_LENGTH );
sRandStr.Append( sPostfix );
}
@@ -707,23 +680,23 @@ DirEntry Export::GetTempFile()
/*****************************************************************************/
{
rtl::OUString* sTempFilename = new rtl::OUString();
-
+
// Create a temp file
int nRC = osl::FileBase::createTempFile( 0 , 0 , sTempFilename );
if( nRC ) printf(" osl::FileBase::createTempFile RC = %d",nRC);
-
+
String strTmp( *sTempFilename );
-
+
INetURLObject::DecodeMechanism eMechanism = INetURLObject::DECODE_TO_IURI;
- String sDecodedStr = INetURLObject::decode( strTmp , '%' , eMechanism );
+ String sDecodedStr = INetURLObject::decode( strTmp , '%' , eMechanism );
ByteString sTmp( sDecodedStr , RTL_TEXTENCODING_UTF8 );
-
+
#if defined(WNT) || defined(OS2)
sTmp.SearchAndReplace("file:///","");
sTmp.SearchAndReplaceAll('/','\\');
#else
// Set file permission to 644
- const sal_uInt64 nPerm = osl_File_Attribute_OwnRead | osl_File_Attribute_OwnWrite |
+ const sal_uInt64 nPerm = osl_File_Attribute_OwnRead | osl_File_Attribute_OwnWrite |
osl_File_Attribute_GrpRead | osl_File_Attribute_OthRead ;
nRC = osl::File::setAttributes( *sTempFilename , nPerm );
More information about the Libreoffice-commits
mailing list