convert IDL module from String to OUString

Change-Id: Idf8e0e02ee2fde23959a281cc6ffa1a43ee7f239
This commit is contained in:
Noel Grandin
2013-09-16 07:56:50 +02:00
parent ed53efd9db
commit 73c560a63e
9 changed files with 57 additions and 63 deletions

View File

@@ -24,7 +24,7 @@
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <vector> #include <vector>
typedef ::std::vector< String* > StringList; typedef ::std::vector< OUString > StringList;
typedef ::std::vector< OString* > ByteStringList; typedef ::std::vector< OString* > ByteStringList;
class SvCommand class SvCommand
@@ -35,8 +35,8 @@ public:
OUString aListFile; OUString aListFile;
OUString aSlotMapFile; OUString aSlotMapFile;
OUString aSfxItemFile; OUString aSfxItemFile;
String aPath; OUString aPath;
String aTargetFile; OUString aTargetFile;
OUString aHelpIdFile; OUString aHelpIdFile;
OUString aCSVFile; OUString aCSVFile;
OUString aExportFile; OUString aExportFile;

View File

@@ -56,10 +56,10 @@ public:
class SvIdlDataBase class SvIdlDataBase
{ {
sal_Bool bExport; sal_Bool bExport;
String aExportFile; OUString aExportFile;
sal_uInt32 nUniqueId; sal_uInt32 nUniqueId;
sal_uInt32 nVerbosity; sal_uInt32 nVerbosity;
String aDataBaseFile; OUString aDataBaseFile;
SvPersistStream aPersStream; SvPersistStream aPersStream;
StringList aIdFileList; StringList aIdFileList;
SvStringHashTable * pIdTable; SvStringHashTable * pIdTable;
@@ -73,7 +73,7 @@ class SvIdlDataBase
protected: protected:
::std::set< OUString > m_DepFiles; ::std::set< OUString > m_DepFiles;
SvMetaObjectMemberStack aContextStack; SvMetaObjectMemberStack aContextStack;
String aPath; OUString aPath;
SvIdlError aError; SvIdlError aError;
void WriteReset() void WriteReset()
{ {
@@ -100,15 +100,15 @@ public:
OString aIFaceName; OString aIFaceName;
SvNumberIdentifier aStructSlotId; SvNumberIdentifier aStructSlotId;
void StartNewFile( const String& rName ); void StartNewFile( const OUString& rName );
void SetExportFile( const String& rName ) void SetExportFile( const OUString& rName )
{ aExportFile = rName; } { aExportFile = rName; }
void AppendAttr( SvMetaAttribute *pSlot ); void AppendAttr( SvMetaAttribute *pSlot );
const SvIdlError & GetError() const { return aError; } const SvIdlError & GetError() const { return aError; }
void SetError( const SvIdlError & r ) void SetError( const SvIdlError & r )
{ aError = r; } { aError = r; }
const String & GetPath() const { return aPath; } const OUString & GetPath() const { return aPath; }
SvMetaObjectMemberStack & GetStack() { return aContextStack; } SvMetaObjectMemberStack & GetStack() { return aContextStack; }
void Write(const OString& rText); void Write(const OString& rText);
@@ -131,7 +131,7 @@ public:
sal_uInt32 GetUniqueId() { return ++nUniqueId; } sal_uInt32 GetUniqueId() { return ++nUniqueId; }
sal_Bool FindId( const OString& rIdName, sal_uLong * pVal ); sal_Bool FindId( const OString& rIdName, sal_uLong * pVal );
sal_Bool InsertId( const OString& rIdName, sal_uLong nVal ); sal_Bool InsertId( const OString& rIdName, sal_uLong nVal );
sal_Bool ReadIdFile( const String & rFileName ); sal_Bool ReadIdFile( const OUString & rFileName );
SvMetaType * FindType( const OString& rName ); SvMetaType * FindType( const OString& rName );
static SvMetaType * FindType( const SvMetaType *, SvMetaTypeMemberList & ); static SvMetaType * FindType( const SvMetaType *, SvMetaTypeMemberList & );
@@ -141,7 +141,7 @@ public:
SvMetaType * pType = NULL ); SvMetaType * pType = NULL );
SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& ); SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& );
SvMetaClass * ReadKnownClass( SvTokenStream & rInStm ); SvMetaClass * ReadKnownClass( SvTokenStream & rInStm );
void AddDepFile(String const& rFileName); void AddDepFile(OUString const& rFileName);
bool WriteDepFile(SvFileStream & rStream, OUString const& rTarget); bool WriteDepFile(SvFileStream & rStream, OUString const& rTarget);
}; };
@@ -150,7 +150,7 @@ class SvIdlWorkingBase : public SvIdlDataBase
public: public:
explicit SvIdlWorkingBase( const SvCommand& rCmd ); explicit SvIdlWorkingBase( const SvCommand& rCmd );
sal_Bool ReadSvIdl( SvTokenStream &, sal_Bool bImported, const String & rPath ); sal_Bool ReadSvIdl( SvTokenStream &, sal_Bool bImported, const OUString & rPath );
sal_Bool WriteSvIdl( SvStream & ); sal_Bool WriteSvIdl( SvStream & );
sal_Bool WriteSfx( SvStream & ); sal_Bool WriteSfx( SvStream & );

View File

@@ -130,7 +130,7 @@ class SvTokenStream
SvFileStream * pInStream; SvFileStream * pInStream;
SvStream & rInStream; SvStream & rInStream;
String aFileName; OUString aFileName;
boost::ptr_vector<SvToken> aTokList; boost::ptr_vector<SvToken> aTokList;
boost::ptr_vector<SvToken>::iterator pCurToken; boost::ptr_vector<SvToken>::iterator pCurToken;
@@ -165,12 +165,12 @@ class SvTokenStream
} }
} }
public: public:
SvTokenStream( const String & rFileName ); SvTokenStream( const OUString & rFileName );
SvTokenStream( SvStream & rInStream, const String & rFileName ); SvTokenStream( SvStream & rInStream, const OUString & rFileName );
~SvTokenStream(); ~SvTokenStream();
const String & GetFileName() const { return aFileName; } const OUString & GetFileName() const { return aFileName; }
SvStream & GetStream() { return rInStream; } SvStream & GetStream() { return rInStream; }
void SetTabSize( sal_uInt16 nTabSizeP ) void SetTabSize( sal_uInt16 nTabSizeP )
{ nTabSize = nTabSizeP; } { nTabSize = nTabSizeP; }

View File

@@ -38,7 +38,7 @@ class SvMetaModule : public SvMetaExtern
SvMetaTypeMemberList aTypeList; SvMetaTypeMemberList aTypeList;
SvMetaAttributeMemberList aAttrList; SvMetaAttributeMemberList aAttrList;
// browser // browser
String aIdlFileName; OUString aIdlFileName;
SvString aHelpFileName; SvString aHelpFileName;
SvString aSlotIdFile; SvString aSlotIdFile;
SvString aTypeLibFile; SvString aTypeLibFile;
@@ -58,7 +58,7 @@ public:
SV_DECL_META_FACTORY1( SvMetaModule, SvMetaExtern, 13 ) SV_DECL_META_FACTORY1( SvMetaModule, SvMetaExtern, 13 )
SvMetaModule(); SvMetaModule();
const String & GetIdlFileName() const { return aIdlFileName; } const OUString & GetIdlFileName() const { return aIdlFileName; }
const OString& GetModulePrefix() const { return aModulePrefix.getString(); } const OString& GetModulePrefix() const { return aModulePrefix.getString(); }
virtual sal_Bool SetName( const OString& rName, SvIdlDataBase * = NULL ); virtual sal_Bool SetName( const OString& rName, SvIdlDataBase * = NULL );
@@ -70,7 +70,7 @@ public:
const SvMetaTypeMemberList & GetTypeList() const { return aTypeList; } const SvMetaTypeMemberList & GetTypeList() const { return aTypeList; }
const SvMetaClassMemberList & GetClassList() const { return aClassList; } const SvMetaClassMemberList & GetClassList() const { return aClassList; }
SvMetaModule( const String & rIdlFileName, SvMetaModule( const OUString & rIdlFileName,
sal_Bool bImported ); sal_Bool bImported );
sal_Bool FillNextName( SvGlobalName * ); sal_Bool FillNextName( SvGlobalName * );

View File

@@ -95,7 +95,7 @@ void SvTokenStream::InitCtor()
FillTokenList(); FillTokenList();
} }
SvTokenStream::SvTokenStream( const String & rFileName ) SvTokenStream::SvTokenStream( const OUString & rFileName )
: pInStream( new SvFileStream( rFileName, STREAM_STD_READ | STREAM_NOCREATE ) ) : pInStream( new SvFileStream( rFileName, STREAM_STD_READ | STREAM_NOCREATE ) )
, rInStream( *pInStream ) , rInStream( *pInStream )
, aFileName( rFileName ) , aFileName( rFileName )
@@ -103,7 +103,7 @@ SvTokenStream::SvTokenStream( const String & rFileName )
InitCtor(); InitCtor();
} }
SvTokenStream::SvTokenStream( SvStream & rStream, const String & rFileName ) SvTokenStream::SvTokenStream( SvStream & rStream, const OUString & rFileName )
: pInStream( NULL ) : pInStream( NULL )
, rInStream( rStream ) , rInStream( rStream )
, aFileName( rFileName ) , aFileName( rFileName )

View File

@@ -35,7 +35,7 @@ SvMetaModule::SvMetaModule()
{ {
} }
SvMetaModule::SvMetaModule( const String & rIdlFileName, sal_Bool bImp ) SvMetaModule::SvMetaModule( const OUString & rIdlFileName, sal_Bool bImp )
: aIdlFileName( rIdlFileName ) : aIdlFileName( rIdlFileName )
, bImported( bImp ), bIsModified( sal_False ) , bImported( bImp ), bIsModified( sal_False )
{ {

View File

@@ -134,7 +134,7 @@ sal_Bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand )
{ {
for( size_t n = 0; n < rCommand.aInFileList.size(); ++n ) for( size_t n = 0; n < rCommand.aInFileList.size(); ++n )
{ {
String aFileName ( *rCommand.aInFileList[ n ] ); OUString aFileName ( rCommand.aInFileList[ n ] );
pDataBase->AddDepFile(aFileName); pDataBase->AddDepFile(aFileName);
SvFileStream aStm( aFileName, STREAM_STD_READ | STREAM_NOCREATE ); SvFileStream aStm( aFileName, STREAM_STD_READ | STREAM_NOCREATE );
if( aStm.GetError() == SVSTREAM_OK ) if( aStm.GetError() == SVSTREAM_OK )
@@ -178,7 +178,7 @@ sal_Bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand )
static sal_Bool ResponseFile( StringList * pList, int argc, char ** argv ) static sal_Bool ResponseFile( StringList * pList, int argc, char ** argv )
{ {
// program name // program name
pList->push_back( new String(OUString::createFromAscii(*argv) ) ); pList->push_back( OUString::createFromAscii(*argv) );
for( int i = 1; i < argc; i++ ) for( int i = 1; i < argc; i++ )
{ {
if( '@' == **(argv +i) ) if( '@' == **(argv +i) )
@@ -200,12 +200,12 @@ static sal_Bool ResponseFile( StringList * pList, int argc, char ** argv )
while( aStr[n] && !isspace( aStr[n] ) ) while( aStr[n] && !isspace( aStr[n] ) )
n++; n++;
if( n != nPos ) if( n != nPos )
pList->push_back( new String( OStringToOUString(aStr.copy(nPos, n - nPos), RTL_TEXTENCODING_ASCII_US) ) ); pList->push_back( OStringToOUString(aStr.copy(nPos, n - nPos), RTL_TEXTENCODING_ASCII_US) );
} }
} }
} }
else if( argv[ i ] ) else if( argv[ i ] )
pList->push_back( new String( OUString::createFromAscii( argv[ i ] ) ) ); pList->push_back( OUString::createFromAscii( argv[ i ] ) );
} }
return sal_True; return sal_True;
} }
@@ -219,17 +219,17 @@ SvCommand::SvCommand( int argc, char ** argv )
{ {
for( size_t i = 1; i < aList.size(); i++ ) for( size_t i = 1; i < aList.size(); i++ )
{ {
String aParam( *aList[ i ] ); OUString aParam( aList[ i ] );
sal_Unicode aFirstChar( aParam.GetChar(0) ); sal_Unicode aFirstChar( aParam[0] );
if( '-' == aFirstChar ) if( '-' == aFirstChar )
{ {
aParam.Erase( 0, 1 ); aParam = aParam.copy( 1 );
aFirstChar = aParam.GetChar(0); aFirstChar = aParam[0];
if( aFirstChar == 'F' || aFirstChar == 'f' ) if( aFirstChar == 'F' || aFirstChar == 'f' )
{ {
aParam.Erase( 0, 1 ); aParam = aParam.copy( 1 );
aFirstChar = aParam.GetChar(0); aFirstChar = aParam[0];
String aName( aParam.Copy( 1 ) ); OUString aName( aParam.copy( 1 ) );
if( 's' == aFirstChar ) if( 's' == aFirstChar )
{ // name of slot output { // name of slot output
aSlotMapFile = aName; aSlotMapFile = aName;
@@ -298,35 +298,35 @@ SvCommand::SvCommand( int argc, char ** argv )
exit( -1 ); exit( -1 );
} }
} }
else if( aParam.EqualsIgnoreCaseAscii( "help" ) || aParam.EqualsIgnoreCaseAscii( "?" ) ) else if( aParam.equalsIgnoreAsciiCase( "help" ) || aParam.equalsIgnoreAsciiCase( "?" ) )
{ // help { // help
printf( "%s", CommandLineSyntax ); printf( "%s", CommandLineSyntax );
} }
else if( aParam.EqualsIgnoreCaseAscii( "quiet" ) ) else if( aParam.equalsIgnoreAsciiCase( "quiet" ) )
{ {
nVerbosity = 0; nVerbosity = 0;
} }
else if( aParam.EqualsIgnoreCaseAscii( "verbose" ) ) else if( aParam.equalsIgnoreAsciiCase( "verbose" ) )
{ {
nVerbosity = 2; nVerbosity = 2;
} }
else if( aParam.EqualsIgnoreCaseAscii( "syntax" ) ) else if( aParam.equalsIgnoreAsciiCase( "syntax" ) )
{ // help { // help
int j = 0; int j = 0;
while(SyntaxStrings[j]) while(SyntaxStrings[j])
printf("%s\n",SyntaxStrings[j++]); printf("%s\n",SyntaxStrings[j++]);
} }
else if( aParam.EqualsIgnoreCaseAscii( "i", 0, 1 ) ) else if( aParam.startsWithIgnoreAsciiCase( "i" ) )
{ // define include paths { // define include paths
String aName( aParam.Copy( 1 ) ); OUString aName( aParam.copy( 1 ) );
if( aPath.Len() ) if( !aPath.isEmpty() )
aPath += OUString( SAL_PATHSEPARATOR ); aPath += OUString( SAL_PATHSEPARATOR );
aPath += aName; aPath += aName;
} }
else if( aParam.EqualsIgnoreCaseAscii( "rsc", 0, 3 ) ) else if( aParam.startsWithIgnoreAsciiCase( "rsc" ) )
{ // first line in *.srs file { // first line in *.srs file
OSL_ENSURE(false, "does anything use this option, doesn't look like it belong here"); OSL_ENSURE(false, "does anything use this option, doesn't look like it belong here");
if( aList[ i + 1 ] ) if( !aList[ i + 1 ].isEmpty() )
{ {
i++; i++;
} }
@@ -343,7 +343,7 @@ SvCommand::SvCommand( int argc, char ** argv )
} }
else else
{ {
aInFileList.push_back( new String( aParam ) ); aInFileList.push_back( aParam );
} }
} }
} }
@@ -352,15 +352,13 @@ SvCommand::SvCommand( int argc, char ** argv )
printf( "%s", CommandLineSyntax ); printf( "%s", CommandLineSyntax );
} }
for ( size_t i = 0, n = aList.size(); i < n; ++i )
delete aList[ i ];
aList.clear(); aList.clear();
OString aInc(getenv("INCLUDE")); OString aInc(getenv("INCLUDE"));
// append include environment variable // append include environment variable
if( aInc.getLength() ) if( aInc.getLength() )
{ {
if( aPath.Len() ) if( !aPath.isEmpty() )
aPath += OUString( SAL_PATHSEPARATOR ); aPath += OUString( SAL_PATHSEPARATOR );
aPath += OStringToOUString(aInc, RTL_TEXTENCODING_ASCII_US); aPath += OStringToOUString(aInc, RTL_TEXTENCODING_ASCII_US);
} }
@@ -369,8 +367,6 @@ SvCommand::SvCommand( int argc, char ** argv )
SvCommand::~SvCommand() SvCommand::~SvCommand()
{ {
// release String list // release String list
for ( size_t i = 0, n = aInFileList.size(); i < n; ++i )
delete aInFileList[ i ];
aInFileList.clear(); aInFileList.clear();
} }

View File

@@ -38,8 +38,6 @@ SvIdlDataBase::SvIdlDataBase( const SvCommand& rCmd )
SvIdlDataBase::~SvIdlDataBase() SvIdlDataBase::~SvIdlDataBase()
{ {
for ( size_t i = 0, n = aIdFileList.size(); i < n; ++i )
delete aIdFileList[ i ];
aIdFileList.clear(); aIdFileList.clear();
delete pIdTable; delete pIdTable;
@@ -203,17 +201,17 @@ sal_Bool SvIdlDataBase::InsertId( const OString& rIdName, sal_uLong nVal )
return sal_False; return sal_False;
} }
sal_Bool SvIdlDataBase::ReadIdFile( const String & rFileName ) sal_Bool SvIdlDataBase::ReadIdFile( const OUString & rFileName )
{ {
OUString aFullName; OUString aFullName;
osl::File::searchFileURL( rFileName, GetPath(), aFullName); osl::File::searchFileURL( rFileName, GetPath(), aFullName);
osl::FileBase::getSystemPathFromFileURL( aFullName, aFullName ); osl::FileBase::getSystemPathFromFileURL( aFullName, aFullName );
for ( size_t i = 0, n = aIdFileList.size(); i < n; ++i ) for ( size_t i = 0, n = aIdFileList.size(); i < n; ++i )
if ( *aIdFileList[ i ] == rFileName ) if ( aIdFileList[ i ] == rFileName )
return sal_True; return sal_True;
aIdFileList.push_back( new String( rFileName ) ); aIdFileList.push_back( rFileName );
this->AddDepFile( aFullName ); this->AddDepFile( aFullName );
SvTokenStream aTokStm( aFullName ); SvTokenStream aTokStm( aFullName );
if( aTokStm.GetStream().GetError() == SVSTREAM_OK ) if( aTokStm.GetStream().GetError() == SVSTREAM_OK )
@@ -554,7 +552,7 @@ void SvIdlDataBase::WriteError( const OString& rErrWrn,
void SvIdlDataBase::WriteError( SvTokenStream & rInStm ) void SvIdlDataBase::WriteError( SvTokenStream & rInStm )
{ {
// error treatment // error treatment
String aFileName( rInStm.GetFileName() ); OUString aFileName( rInStm.GetFileName() );
OStringBuffer aErrorText; OStringBuffer aErrorText;
sal_uLong nRow = 0, nColumn = 0; sal_uLong nRow = 0, nColumn = 0;
@@ -620,7 +618,7 @@ SvIdlWorkingBase::SvIdlWorkingBase(const SvCommand& rCmd) : SvIdlDataBase(rCmd)
{ {
} }
sal_Bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, sal_Bool bImported, const String & rPath ) sal_Bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, sal_Bool bImported, const OUString & rPath )
{ {
aPath = rPath; // only valid for this iteration aPath = rPath; // only valid for this iteration
SvToken * pTok; SvToken * pTok;
@@ -783,9 +781,9 @@ sal_Bool SvIdlWorkingBase::WriteSfxItem( SvStream & )
return sal_False; return sal_False;
} }
void SvIdlDataBase::StartNewFile( const String& rName ) void SvIdlDataBase::StartNewFile( const OUString& rName )
{ {
bExport = ( aExportFile.EqualsIgnoreCaseAscii( rName ) ); bExport = ( aExportFile.equalsIgnoreAsciiCase( rName ) );
} }
void SvIdlDataBase::AppendAttr( SvMetaAttribute *pAttr ) void SvIdlDataBase::AppendAttr( SvMetaAttribute *pAttr )
@@ -827,7 +825,7 @@ sal_Bool SvIdlWorkingBase::WriteDocumentation( SvStream & rOutStm )
return sal_True; return sal_True;
} }
void SvIdlDataBase::AddDepFile(String const& rFileName) void SvIdlDataBase::AddDepFile(OUString const& rFileName)
{ {
m_DepFiles.insert(rFileName); m_DepFiles.insert(rFileName);
} }

View File

@@ -27,7 +27,7 @@
#include <osl/file.hxx> #include <osl/file.hxx>
#define BR 0x8000 #define BR 0x8000
sal_Bool FileMove_Impl( const String & rFile1, const String & rFile2, sal_Bool bImmerVerschieben ) sal_Bool FileMove_Impl( const OUString & rFile1, const OUString & rFile2, sal_Bool bImmerVerschieben )
{ {
//printf( "Move from %s to %s\n", rFile2.GetStr(), rFile1.GetStr() ); //printf( "Move from %s to %s\n", rFile2.GetStr(), rFile1.GetStr() );
sal_uLong nC1 = 0; sal_uLong nC1 = 0;
@@ -245,8 +245,8 @@ int cdecl main ( int argc, char ** argv)
if( nExit == 0 ) if( nExit == 0 )
{ {
sal_Bool bErr = sal_False; sal_Bool bErr = sal_False;
sal_Bool bDoMove = aCommand.aTargetFile.Len() == 0; sal_Bool bDoMove = aCommand.aTargetFile.isEmpty();
String aErrFile, aErrFile2; OUString aErrFile, aErrFile2;
if( !bErr && !aCommand.aListFile.isEmpty() ) if( !bErr && !aCommand.aListFile.isEmpty() )
{ {
bErr |= !FileMove_Impl( aCommand.aListFile, aTmpListFile, bDoMove ); bErr |= !FileMove_Impl( aCommand.aListFile, aTmpListFile, bDoMove );
@@ -325,7 +325,7 @@ int cdecl main ( int argc, char ** argv)
} }
else else
{ {
if( aCommand.aTargetFile.Len() ) if( !aCommand.aTargetFile.isEmpty() )
{ {
#ifdef ICC #ifdef ICC
DirEntry aT(aCommand.aTargetFile); DirEntry aT(aCommand.aTargetFile);