[Libreoffice-commits] .: l10ntools/inc l10ntools/source
Joseph Powers
jpowers at kemper.freedesktop.org
Sat Jan 22 19:50:33 PST 2011
l10ntools/inc/cfgmerge.hxx | 54 +++++++++++++++++++++-------------
l10ntools/source/cfgmerge.cxx | 65 +++++++++++++++++++++---------------------
2 files changed, 66 insertions(+), 53 deletions(-)
New commits:
commit ac5f4d49e1876e35db16e4b97c4b1bca0eb9c33a
Author: Joseph Powers <jpowers27 at cox.net>
Date: Sat Jan 22 19:50:28 2011 -0800
Remove DECLARE_LIST( CfgStackList, CfgStackData* )
diff --git a/l10ntools/inc/cfgmerge.hxx b/l10ntools/inc/cfgmerge.hxx
index f0138e7..62dd70c 100644
--- a/l10ntools/inc/cfgmerge.hxx
+++ b/l10ntools/inc/cfgmerge.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
@@ -32,6 +32,7 @@
#include <tools/string.hxx>
#include <tools/list.hxx>
#include <hash_map>
+#include <vector>
typedef std::hash_map<ByteString , ByteString , hashByteString,equalByteString>
ByteStringHashMap;
@@ -57,7 +58,7 @@ private:
ByteStringHashMap sText;
public:
- CfgStackData( const ByteString &rTag, const ByteString &rId )
+ CfgStackData( const ByteString &rTag, const ByteString &rId )
: sTagType( rTag ), sIdentifier( rId ) {};
ByteString &GetTagType() { return sTagType; }
@@ -69,28 +70,39 @@ public:
// class CfgStack
//
-DECLARE_LIST( CfgStackList, CfgStackData * )
+typedef ::std::vector< CfgStackData* > CfgStackList;
-class CfgStack : public CfgStackList
+class CfgStack
{
+private:
+ CfgStackList maList;
+
public:
- CfgStack() : CfgStackList( 10, 10 ) {}
+ CfgStack() {}
~CfgStack();
- ULONG Push( CfgStackData *pStackData );
+ size_t Push( CfgStackData *pStackData );
CfgStackData *Push( const ByteString &rTag, const ByteString &rId );
- CfgStackData *Pop() { return Remove( Count() - 1 ); }
+ CfgStackData *Pop()
+ {
+ if ( maList.empty() ) return NULL;
+ CfgStackData* temp = maList.back();
+ maList.pop_back();
+ return temp;
+ }
+
+ CfgStackData *GetStackData( size_t nPos = LIST_APPEND );
- CfgStackData *GetStackData( ULONG nPos = LIST_APPEND );
+ ByteString GetAccessPath( size_t nPos = LIST_APPEND );
- ByteString GetAccessPath( ULONG nPos = LIST_APPEND );
+ size_t size() const { return maList.size(); }
};
//
// class CfgParser
//
-class CfgParser
+class CfgParser
{
protected:
ByteString sCurrentResTyp;
@@ -104,8 +116,8 @@ protected:
BOOL bLocalize;
- virtual void WorkOnText(
- ByteString &rText,
+ virtual void WorkOnText(
+ ByteString &rText,
const ByteString &nLangIndex )=0;
virtual void WorkOnRessourceEnd()=0;
@@ -117,11 +129,11 @@ protected:
private:
int ExecuteAnalyzedToken( int nToken, char *pToken );
std::vector<ByteString> aLanguages;
- void AddText(
- ByteString &rText,
+ void AddText(
+ ByteString &rText,
const ByteString &rIsoLang,
const ByteString &rResTyp );
-
+
BOOL IsTokenClosed( const ByteString &rToken );
public:
@@ -155,14 +167,14 @@ private:
ByteString sPath;
std::vector<ByteString> aLanguages;
protected:
- void WorkOnText(
- ByteString &rText,
+ void WorkOnText(
+ ByteString &rText,
const ByteString &rIsoLang
);
void WorkOnRessourceEnd();
void Output( const ByteString& rOutput );
-public:
+public:
CfgExport(
const ByteString &rOutputFile,
const ByteString &rProject,
@@ -181,14 +193,14 @@ private:
MergeDataFile *pMergeDataFile;
std::vector<ByteString> aLanguages;
ResData *pResData;
-
+
BOOL bGerman;
ByteString sFilename;
BOOL bEnglish;
protected:
- void WorkOnText(
- ByteString &rText,
+ void WorkOnText(
+ ByteString &rText,
const ByteString &nLangIndex );
void WorkOnRessourceEnd();
diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx
index e992cf4..02874eb 100644
--- a/l10ntools/source/cfgmerge.cxx
+++ b/l10ntools/source/cfgmerge.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
@@ -95,7 +95,7 @@ extern char *GetOutputFile( int argc, char* argv[])
for( int i = 1; i < argc; i++ ) {
ByteString sSwitch( argv[ i ] );
sSwitch.ToUpperAscii();
-
+
if ( sSwitch == "-I" ) {
nState = STATE_INPUT; // next token specifies source file
}
@@ -191,9 +191,9 @@ int InitCfgExport( char *pOutput , char* pFilename )
if ( bMergeMode )
pParser = new CfgMerge( sMergeSrc, sOutputFile, sFilename );
- else if ( sOutputFile.Len())
+ else if ( sOutputFile.Len())
pParser = new CfgExport( sOutputFile, sPrj, sActFileName );
-
+
return 1;
}
@@ -214,7 +214,7 @@ void removeTempFile(){
}
extern const char* getFilename()
{
- return sInputFileName.GetBuffer();
+ return sInputFileName.GetBuffer();
}
/*****************************************************************************/
extern FILE *GetCfgFile()
@@ -255,7 +255,7 @@ extern FILE *GetCfgFile()
// (e.g.: source\ui\src\menue.src)
// printf("sFullEntry = %s\n",sFullEntry.GetBuffer());
sActFileName = sFullEntry.Copy( sPrjEntry.Len() + 1 );
-// printf("sActFileName = %s\n",sActFileName.GetBuffer());
+// printf("sActFileName = %s\n",sActFileName.GetBuffer());
sActFileName.SearchAndReplaceAll( "/", "\\" );
@@ -296,12 +296,12 @@ int GetError()
//
CfgStackData* CfgStack::Push( const ByteString &rTag, const ByteString &rId )
-{
- CfgStackData *pD = new CfgStackData( rTag, rId );
- Insert( pD, LIST_APPEND );
- return pD;
+{
+ CfgStackData *pD = new CfgStackData( rTag, rId );
+ maList.push_back( pD );
+ return pD;
}
-
+
//
// class CfgStack
//
@@ -310,19 +310,20 @@ CfgStackData* CfgStack::Push( const ByteString &rTag, const ByteString &rId )
CfgStack::~CfgStack()
/*****************************************************************************/
{
- for ( ULONG i = 0; i < Count(); i++ )
- delete GetObject( i );
+ for ( size_t i = 0, n = maList.size(); i < n; i++ )
+ delete maList[ i ];
+ maList.clear();
}
/*****************************************************************************/
-ByteString CfgStack::GetAccessPath( ULONG nPos )
+ByteString CfgStack::GetAccessPath( size_t nPos )
/*****************************************************************************/
{
if ( nPos == LIST_APPEND )
- nPos = Count() - 1;
+ nPos = maList.size() - 1;
ByteString sReturn;
- for ( ULONG i = 0; i <= nPos; i++ ) {
+ for ( size_t i = 0; i <= nPos; i++ ) {
if ( i )
sReturn += ".";
sReturn += GetStackData( i )->GetIdentifier();
@@ -332,13 +333,13 @@ ByteString CfgStack::GetAccessPath( ULONG nPos )
}
/*****************************************************************************/
-CfgStackData *CfgStack::GetStackData( ULONG nPos )
+CfgStackData *CfgStack::GetStackData( size_t nPos )
/*****************************************************************************/
{
if ( nPos == LIST_APPEND )
- nPos = Count() - 1;
+ nPos = maList.size() - 1;
- return GetObject( nPos );
+ return maList[ nPos ];
}
//
@@ -662,12 +663,12 @@ void CfgExport::WorkOnRessourceEnd()
ByteString sLocalId = pStackData->sIdentifier;
ByteString sGroupId;
- if ( aStack.Count() == 1 ) {
+ if ( aStack.size() == 1 ) {
sGroupId = sLocalId;
sLocalId = "";
}
else {
- sGroupId = aStack.GetAccessPath( aStack.Count() - 2 );
+ sGroupId = aStack.GetAccessPath( aStack.size() - 2 );
}
ByteString sTimeStamp( Export::GetTimeStamp());
@@ -730,7 +731,7 @@ CfgMerge::CfgMerge(
{
if ( rMergeSource.Len()){
pMergeDataFile = new MergeDataFile(
- rMergeSource, sInputFileName , bErrorLog, RTL_TEXTENCODING_MS_1252, true );
+ rMergeSource, sInputFileName , bErrorLog, RTL_TEXTENCODING_MS_1252, true );
if( Export::sLanguages.EqualsIgnoreCaseAscii("ALL") ){
Export::SetLanguages( pMergeDataFile->GetLanguages() );
aLanguages = pMergeDataFile->GetLanguages();
@@ -760,12 +761,12 @@ void CfgMerge::WorkOnText(
if ( !pResData ) {
ByteString sLocalId = pStackData->sIdentifier;
ByteString sGroupId;
- if ( aStack.Count() == 1 ) {
+ if ( aStack.size() == 1 ) {
sGroupId = sLocalId;
sLocalId = "";
}
else {
- sGroupId = aStack.GetAccessPath( aStack.Count() - 2 );
+ sGroupId = aStack.GetAccessPath( aStack.size() - 2 );
}
ByteString sPlatform( "" );
@@ -784,11 +785,11 @@ void CfgMerge::WorkOnText(
if ( pEntrys ) {
ByteString sContent;
pEntrys->GetText( sContent, STRING_TYP_TEXT, nLangIndex );
-
+
if ( Export::isAllowed( nLangIndex ) &&
( sContent != "-" ) && ( sContent.Len()))
{
-#ifdef MERGE_SOURCE_LANGUAGES
+#ifdef MERGE_SOURCE_LANGUAGES
if( nLangIndex.EqualsIgnoreCaseAscii("de") || nLangIndex.EqualsIgnoreCaseAscii("en-US") )
rText = sContent;
#endif
@@ -806,10 +807,10 @@ void CfgMerge::Output( const ByteString& rOutput )
pOutputStream->Write( rOutput.GetBuffer(), rOutput.Len());
}
-ULONG CfgStack::Push( CfgStackData *pStackData )
-{
- Insert( pStackData, LIST_APPEND );
- return Count() - 1;
+size_t CfgStack::Push( CfgStackData *pStackData )
+{
+ maList.push_back( pStackData );
+ return maList.size() - 1;
}
/*****************************************************************************/
@@ -827,13 +828,13 @@ void CfgMerge::WorkOnRessourceEnd()
ByteString sContent;
pEntrys->GetText( sContent, STRING_TYP_TEXT, sCur , TRUE );
- if (
+ if (
// (!sCur.EqualsIgnoreCaseAscii("de") ) &&
( !sCur.EqualsIgnoreCaseAscii("en-US") ) &&
( sContent != "-" ) && ( sContent.Len()))
{
-
+
ByteString sText = sContent;
Export::QuotHTML( sText );
More information about the Libreoffice-commits
mailing list