[Libreoffice-commits] .: rsc/inc rsc/source

Joseph Powers jpowers at kemper.freedesktop.org
Mon Jan 24 21:37:04 PST 2011


 rsc/inc/rscdef.hxx          |    8 +-
 rsc/source/parser/rscdb.cxx |    5 -
 rsc/source/rsc/rsc.cxx      |  151 +++++++++++++++++++++-----------------------
 rsc/source/tools/rscdef.cxx |   65 +++++++++---------
 4 files changed, 112 insertions(+), 117 deletions(-)

New commits:
commit 1f06c584bcdb5373748eedd992c08cde2d68c8c0
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Mon Jan 24 21:36:59 2011 -0800

    Remove DECLARE_LIST( RscDependList, RscDepend* )

diff --git a/rsc/inc/rscdef.hxx b/rsc/inc/rscdef.hxx
index bbde75e..cfe43e1 100644
--- a/rsc/inc/rscdef.hxx
+++ b/rsc/inc/rscdef.hxx
@@ -200,10 +200,11 @@ public:
             RscDepend( ULONG lIncKey ){ lKey = lIncKey; };
     ULONG	GetFileKey(){ return lKey; }
 };
-DECLARE_LIST( RscDependList, RscDepend * )
+
+typedef ::std::vector< RscDepend* > RscDependList;
 
 // Tabelle die alle Dateinamen enthaelt
-class RscFile : public RscDependList
+class RscFile
 {
 friend class RscFileTab;
     BOOL			bIncFile;	// Ist es eine Include-Datei
@@ -214,10 +215,11 @@ public:
     ByteString		aFileName;	// Name der Datei
     ByteString		aPathName;	// Pfad und Name der Datei
     RscDefineList	aDefLst;	// Liste der Defines
+    RscDependList   aDepLst;    // List of Depend
 
                     RscFile();
                     ~RscFile();
-    BOOL			InsertDependFile( ULONG lDepFile, ULONG lPos );
+    BOOL			InsertDependFile( ULONG lDepFile, size_t lPos );
     void			RemoveDependFile( ULONG lDepFile );
     BOOL			Depend( ULONG lDepend, ULONG lFree );
     void			SetIncFlag(){ bIncFile = TRUE; };
diff --git a/rsc/source/parser/rscdb.cxx b/rsc/source/parser/rscdb.cxx
index 22f5a30..6c4ec25 100644
--- a/rsc/source/parser/rscdb.cxx
+++ b/rsc/source/parser/rscdb.cxx
@@ -436,9 +436,9 @@ void RscTypCont :: WriteInc( FILE * fOutput, ULONG lFileKey )
         pFName = aFileTab.Get( lFileKey );
         if( pFName )
         {
-            pDep = pFName->First();
-            while( pDep )
+            for ( size_t i = 0, n = pFName->aDepLst.size(); i < n; ++i )
             {
+                pDep = pFName->aDepLst[ i ];
                 if( pDep->GetFileKey() != lFileKey )
                 {
                     pFile = aFileTab.GetFile( pDep->GetFileKey() );
@@ -449,7 +449,6 @@ void RscTypCont :: WriteInc( FILE * fOutput, ULONG lFileKey )
                                  pFile->aFileName.GetBuffer() );
                     }
                 }
-                pDep = pFName->Next();
             };
         };
     };
diff --git a/rsc/source/rsc/rsc.cxx b/rsc/source/rsc/rsc.cxx
index c411f14..506c5dc 100644
--- a/rsc/source/rsc/rsc.cxx
+++ b/rsc/source/rsc/rsc.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
@@ -72,7 +72,7 @@
 #include <rtl/tencinfo.h>
 #include <rtl/textenc.h>
 
-#include <vector> 
+#include <vector>
 
 
 using namespace rtl;
@@ -192,8 +192,8 @@ RscCmdLine::RscCmdLine( int argc, char ** argv, RscError * pEH )
                 {
                     const ByteString 	aSPath( pEqual + 1 );
                     DirEntry			aSDir( String( aSPath, RTL_TEXTENCODING_ASCII_US ) );
-                
-                    m_aReplacements.push_back( std::pair< OString, OString >( OString( (*ppStr)+4, pEqual - *ppStr - 4 ), 
+
+                    m_aReplacements.push_back( std::pair< OString, OString >( OString( (*ppStr)+4, pEqual - *ppStr - 4 ),
                                                                               ByteString( aSDir.GetFull(), RTL_TEXTENCODING_ASCII_US ) ) );
                 }
             }
@@ -235,12 +235,12 @@ RscCmdLine::RscCmdLine( int argc, char ** argv, RscError * pEH )
             {  // additional language specific include for system dependent files
                 const ByteString 	aSysSearchDir( (*ppStr)+5 );
                 DirEntry			aSysDir( String( aSysSearchDir, RTL_TEXTENCODING_ASCII_US ) );
-                
+
                 m_aOutputFiles.back().aSysSearchDirs.push_back( ByteString( aSysDir.GetFull(), RTL_TEXTENCODING_ASCII_US ) );
-                
+
                 if( m_aOutputFiles.back().aLangSearchPath.Len() )
                     m_aOutputFiles.back().aLangSearchPath.Append( ByteString( DirEntry::GetSearchDelimiter(), RTL_TEXTENCODING_ASCII_US ) );
-                
+
                 m_aOutputFiles.back().aLangSearchPath.Append( aSysSearchDir );
             }
             else if( !rsc_strnicmp( (*ppStr) + 1, "fp=", 3 ) )
@@ -667,16 +667,15 @@ ERRTYPE RscCompiler :: IncludeParser( ULONG lFileKey )
             fclose( finput );
 
             // Include-Pfad durchsuchen
-            pDep = pFName->First();
-            while( pDep )
+            for ( size_t i = 0, n = pFName->aDepLst.size(); i < n; ++i )
             {
+                pDep = pFName->aDepLst[ i ];
                 pFNTmp = pTC->aFileTab.GetFile( pDep->GetFileKey() );
-                pDep = pFName->Next();
             }
 
-            pDep = pFName->First();
-            while( pDep )
+            for ( size_t i = 0, n = pFName->aDepLst.size(); i < n; ++i )
             {
+                pDep = pFName->aDepLst[ i ];
                 pFNTmp = pTC->aFileTab.GetFile( pDep->GetFileKey() );
                 // Kein Pfad und Include Datei
                 if( pFNTmp && !pFNTmp->bLoaded )
@@ -688,7 +687,6 @@ ERRTYPE RscCompiler :: IncludeParser( ULONG lFileKey )
                     else
                         aError = ERR_OPENFILE;
                 }
-                pDep = pFName->Next();
             };
         };
     };
@@ -701,7 +699,7 @@ ERRTYPE RscCompiler :: IncludeParser( ULONG lFileKey )
 |*	  RscCompiler :: ParseOneFile()
 |*
 *************************************************************************/
-ERRTYPE RscCompiler :: ParseOneFile( ULONG lFileKey, 
+ERRTYPE RscCompiler :: ParseOneFile( ULONG lFileKey,
                                      const RscCmdLine::OutputFile* pOutputFile,
                                       const WriteRcContext* pContext )
 {
@@ -718,12 +716,11 @@ ERRTYPE RscCompiler :: ParseOneFile( ULONG lFileKey,
 
         //Include-Dateien vorher lesen
         pFName->bLoaded = TRUE; //Endlos Rekursion vermeiden
-        pDep = pFName->First();
-        while( pDep && aError.IsOk() )
+
+        for ( size_t i = 0; i < pFName->aDepLst.size() && aError.IsOk(); ++i )
         {
+            pDep = pFName->aDepLst[ i ];
             aError = ParseOneFile( pDep->GetFileKey(), pOutputFile, pContext );
-            pFName->Seek( pDep );
-            pDep = pFName->Next();
         }
 
         if( aError.IsError() )
@@ -732,18 +729,18 @@ ERRTYPE RscCompiler :: ParseOneFile( ULONG lFileKey,
         {
             String 		aTmpName( ::GetTmpFileName(), RTL_TEXTENCODING_ASCII_US );
             DirEntry	aTmpPath( aTmpName ), aSrsPath( String( pFName->aPathName.GetBuffer(), RTL_TEXTENCODING_ASCII_US ) );
-    
+
             aTmpPath.ToAbs();
             aSrsPath.ToAbs();
-            
+
             if( pContext && pOutputFile )
                 PreprocessSrsFile( *pOutputFile, *pContext, aSrsPath, aTmpPath );
             else
                 aSrsPath.CopyTo( aTmpPath, FSYS_ACTION_COPYFILE );
-                
+
             ByteString aParseFile( aTmpPath.GetFull(), RTL_TEXTENCODING_ASCII_US );
             finput = fopen( aParseFile.GetBuffer(), "r" );
-            
+
             if( !finput )
             {
                 pTC->pEH->Error( ERR_OPENFILE, NULL, RscId(), pFName->aPathName.GetBuffer() );
@@ -752,18 +749,18 @@ ERRTYPE RscCompiler :: ParseOneFile( ULONG lFileKey,
             else
             {
                 RscFileInst aFileInst( pTC, lFileKey, lFileKey, finput );
-                
+
                 pTC->pEH->StdOut( "reading file ", RscVerbosityVerbose );
                 pTC->pEH->StdOut( aParseFile.GetBuffer(), RscVerbosityVerbose );
                 pTC->pEH->StdOut( " ", RscVerbosityVerbose );
-                
+
                 aError = ::parser( &aFileInst );
                 if( aError.IsError() )
                     pTC->Delete( lFileKey );//Resourceobjekte loeschen
                 pTC->pEH->StdOut( "\n", RscVerbosityVerbose );
                 fclose( finput );
             };
-            
+
             aTmpPath.Kill();
         };
     };
@@ -801,7 +798,7 @@ ERRTYPE RscCompiler::Link()
     if( !(pCL->nCommands & NOLINK_FLAG) )
     {
         ::std::list<RscCmdLine::OutputFile>::const_iterator it;
-        
+
         for( it = pCL->m_aOutputFiles.begin(); it != pCL->m_aOutputFiles.end(); ++it )
         {
             // cleanup nodes
@@ -814,7 +811,7 @@ ERRTYPE RscCompiler::Link()
                     pFName->bLoaded = FALSE;
                 }
             }
-                       
+
             // rc-Datei schreiben
             ByteString aDir( it->aOutputRc );
             aDir.SetToken( aDir.GetTokenCount( PATHSEP )-1, PATHSEP, ByteString() );
@@ -830,7 +827,7 @@ ERRTYPE RscCompiler::Link()
             // work dir for absolute Urls
             OUString aCWD, aTmpUrl;
             osl_getProcessWorkingDir( &aCWD.pData );
-            
+
             // get two temp file urls
             OString aRcTmp, aSysListTmp, aSysList;
             OUString aSysPath, aUrlDir;
@@ -863,7 +860,7 @@ ERRTYPE RscCompiler::Link()
                 if( osl_getAbsoluteFileURL( aCWD.pData, aTmpUrl.pData, &aUrlDir.pData ) != osl_File_E_None )
                     pTC->pEH->FatalError( ERR_OPENFILE, RscId(), do_prefix( "absolute url", aTmpUrl ) );
             }
-            
+
             if( osl_getSystemPathFromFileURL( aUrlDir.pData, &aSysPath.pData ) != osl_File_E_None )
                 pTC->pEH->FatalError( ERR_OPENFILE, RscId(), do_prefix( "sys path conversion", aUrlDir ) );
 
@@ -917,7 +914,7 @@ ERRTYPE RscCompiler::Link()
             pTC->SetSysSearchPath( aSysSearchPath );
 
             WriteRcContext	aContext;
-            
+
             aContext.fOutput = foutput;
             aContext.aOutputRc = it->aOutputRc;
             aContext.aOutputSysList = aSysListTmp;
@@ -927,11 +924,11 @@ ERRTYPE RscCompiler::Link()
             if( aContext.aOutputSysList.getLength() )
             {
                 FILE* pSysListFile = fopen( aContext.aOutputSysList.getStr(), "wb" );
-                
+
                 if( !pSysListFile )
                     pTC->pEH->FatalError( ERR_OPENFILE, RscId(), aContext.aOutputSysList.getStr() );
                 else
-                    fclose( pSysListFile ); 
+                    fclose( pSysListFile );
             }
 
             // parse files for specific language
@@ -943,9 +940,9 @@ ERRTYPE RscCompiler::Link()
                     pTC->aFileTab.Seek( pFName );
                 }
             };
-            
+
             aError = pTC->WriteRc( aContext );
-            
+
             fclose( foutput );
             fExitFile = NULL;
             unlink( it->aOutputRc.GetBuffer() );
@@ -959,11 +956,11 @@ ERRTYPE RscCompiler::Link()
             }
             else
             {
-#ifdef UNX			
+#ifdef UNX
                 chmod( it->aOutputRc.GetBuffer(), S_IRWXU | S_IRWXG | S_IROTH );
 #endif
             }
-            
+
             unlink( aSysList.getStr() );
             if( rename( aSysListTmp.getStr(), aSysList.getStr() ) )
             {
@@ -975,7 +972,7 @@ ERRTYPE RscCompiler::Link()
             }
             else
             {
-#ifdef UNX			
+#ifdef UNX
                 chmod( aSysList.getStr(), S_IRWXU | S_IRWXG | S_IROTH );
 #endif
             }
@@ -1129,16 +1126,16 @@ void RscCompiler::OpenInput( const ByteString& rInput )
 
 bool RscCompiler::GetImageFilePath( const RscCmdLine::OutputFile& rOutputFile,
                                        const WriteRcContext& rContext,
-                                    const ByteString& rBaseFileName, 
+                                    const ByteString& rBaseFileName,
                                     ByteString& rImagePath,
                                     FILE* pSysListFile )
 {
     ::std::list< ByteString >					aFileNames;
     bool       									bFound = false;
-    
+
     ByteString 	aFileName( rBaseFileName );
     aFileNames.push_back( aFileName += ".png" );
-    
+
     aFileName = rBaseFileName;
     aFileNames.push_back( aFileName += ".bmp" );
 
@@ -1147,16 +1144,16 @@ bool RscCompiler::GetImageFilePath( const RscCmdLine::OutputFile& rOutputFile,
     while( ( aFileIter != aFileNames.end() ) && !bFound )
     {
         ::std::list< ByteString >::const_iterator aDirIter( rOutputFile.aSysSearchDirs.begin() );
-    
+
         while( ( aDirIter != rOutputFile.aSysSearchDirs.end() ) && !bFound )
         {
             const DirEntry	aPath( String( *aDirIter, RTL_TEXTENCODING_ASCII_US ) );
             DirEntry 		aRelPath( aPath );
             DirEntry 		aAbsPath( aRelPath += DirEntry( String( *aFileIter, RTL_TEXTENCODING_ASCII_US ) ) );
-            
+
             aAbsPath.ToAbs();
             const FileStat aFS( aAbsPath.GetFull() );
-            
+
 #if OSL_DEBUG_LEVEL > 1
             fprintf( stderr, "Searching image: %s\n", ByteString( aRelPath.GetFull(), RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
 #endif
@@ -1166,7 +1163,7 @@ bool RscCompiler::GetImageFilePath( const RscCmdLine::OutputFile& rOutputFile,
                 std::list< std::pair< OString, OString > >::const_iterator 	aReplIter( rContext.pCmdLine->m_aReplacements.begin() );
                 String														aStr( aRelPath.GetFull() );
                 OString														aRelPathStr( aStr.GetBuffer(), aStr.Len(), RTL_TEXTENCODING_ASCII_US );
-                
+
                 while( ( aReplIter != rContext.pCmdLine->m_aReplacements.end() ) && !bFound )
                 {
                     ByteString aSearch( aReplIter->second );
@@ -1177,41 +1174,41 @@ bool RscCompiler::GetImageFilePath( const RscCmdLine::OutputFile& rOutputFile,
                     {
                         sal_Int32 		nCopyPos = aReplIter->second.getLength(), nLength = aRelPathStr.getLength();
                         const sal_Char*	pChars = aRelPathStr.getStr();
-                        
+
                         while( ( nCopyPos < nLength ) && ( pChars[ nCopyPos ] == '/' || pChars[ nCopyPos ] == '\\' || pChars[ nCopyPos ] == ':' ) )
                         {
                             ++nCopyPos;
                         }
-                        
+
                         if( nCopyPos < nLength )
                             rImagePath = aRelPathStr.copy( nCopyPos ).replace( '\\', '/' );
-                                                        
+
                         bFound = true;
                     }
-                    
+
                     ++aReplIter;
                 }
-                
+
                 if( bFound && pSysListFile )
                 {
                     DirEntry	aSysPath( String( *aDirIter, RTL_TEXTENCODING_ASCII_US ) );
                     String		aSysPathFull( ( aSysPath += DirEntry( String( *aFileIter, RTL_TEXTENCODING_ASCII_US ) ) ).GetFull() );
                     OString		aSysPathStr( aSysPathFull.GetBuffer(), aSysPathFull.Len(), RTL_TEXTENCODING_ASCII_US );
-                    
+
                     fprintf( pSysListFile, "%s\n", rContext.pCmdLine->substitutePaths( aSysPathStr ).getStr() );
                 }
-        
+
 #if OSL_DEBUG_LEVEL > 1
                 fprintf( stderr, "ImagePath to add: %s\n", rImagePath.GetBuffer() );
 #endif
             }
-            
+
             ++aDirIter;
         }
-        
+
         ++aFileIter;
     }
-    
+
     return bFound;
 }
 
@@ -1219,7 +1216,7 @@ bool RscCompiler::GetImageFilePath( const RscCmdLine::OutputFile& rOutputFile,
 
 void RscCompiler::PreprocessSrsFile( const RscCmdLine::OutputFile& rOutputFile,
                                         const WriteRcContext& rContext,
-                                       const DirEntry& rSrsInPath, 
+                                       const DirEntry& rSrsInPath,
                                        const DirEntry& rSrsOutPath )
 {
     SvFileStream 				aIStm( rSrsInPath.GetFull(), STREAM_READ );
@@ -1230,48 +1227,48 @@ void RscCompiler::PreprocessSrsFile( const RscCmdLine::OutputFile& rOutputFile,
     if( !aIStm.GetError() && !aOStm.GetError() )
     {
         ByteString aLine, aFilePath;
-                            
+
         while( aIStm.ReadLine( aLine ) )
         {
             if( ( aLine.GetTokenCount( '=' ) == 2 ) &&
                 ( aLine.GetToken( 0, '=' ).Search( "File" ) != STRING_NOTFOUND ) )
             {
                 ByteString aBaseFileName( aLine.GetToken( 1, '"' ).GetToken( 0, '.' ) );
-                
+
                 if( GetImageFilePath( rOutputFile, rContext, aBaseFileName, aFilePath, pSysListFile ) )
                     ( ( aLine = "File = \"" ) += aFilePath ) += "\";";
                 else
                     aMissingImages.push_back( aBaseFileName );
-            
+
                 aOStm.WriteLine( aLine );
             }
             else if( aLine.Search( "ImageList" ) != STRING_NOTFOUND )
             {
                 ::std::vector< ::std::pair< ByteString, sal_Int32 > > aEntryVector;
-                
+
                 aOStm.WriteLine( aLine );
-            
+
                 if( aLine.Search( ';' ) == STRING_NOTFOUND )
                 {
                     const sal_uInt32 nImgListStartPos = aIStm.Tell();
-                    
+
                     do
                     {
                         if( !aIStm.ReadLine( aLine ) )
                             break;
                     }
                     while( aLine.Search( "Prefix" ) == STRING_NOTFOUND );
-                
+
                     const ByteString aPrefix( aLine.GetToken( 1, '"' ) );
                     aIStm.Seek( nImgListStartPos );
-    
+
                     do
                     {
                         if (!aIStm.ReadLine( aLine ) )
                             break;
                     }
                     while( aLine.Search( "IdList" ) == STRING_NOTFOUND );
-                
+
                     // scan all ids and collect images
                     while( aLine.Search( '}' ) == STRING_NOTFOUND )
                     {
@@ -1289,20 +1286,20 @@ void RscCompiler::PreprocessSrsFile( const RscCmdLine::OutputFile& rOutputFile,
 
                             if( nNumber < 10000 )
                                 aBaseFileName += ByteString::CreateFromInt32( 0 );
-                                
+
                             if( GetImageFilePath( rOutputFile, rContext, aBaseFileName += aLine , aFilePath, pSysListFile ) )
                                 aEntryVector.push_back( ::std::pair< ByteString, sal_Int32 >( aFilePath, nNumber ) );
                             else
                                 aMissingImages.push_back( aBaseFileName );
                         }
                     }
-                    
+
                     const sal_uInt32 nImgListEndPos = aIStm.Tell();
                     aIStm.Seek( nImgListStartPos );
                     while( aIStm.Tell() < nImgListEndPos )
                     {
                         aIStm.ReadLine( aLine );
-                        
+
                         if( aLine.Search( "IdList" ) != STRING_NOTFOUND )
                         {
                             while( aLine.Search( '}' ) == STRING_NOTFOUND )
@@ -1311,21 +1308,21 @@ void RscCompiler::PreprocessSrsFile( const RscCmdLine::OutputFile& rOutputFile,
                         else
                             aOStm.WriteLine( aLine );
                     }
-                    
+
                     aOStm.WriteLine( "FileList = {" );
-                    
+
                     for( sal_uInt32 i = 0; i < aEntryVector.size(); ++i )
                     {
                         ByteString aEntryString( "< \"" );
-                        
+
                         aEntryString += aEntryVector[ i ].first;
                         aEntryString += "\"; ";
                         aEntryString += ByteString::CreateFromInt32( aEntryVector[ i ].second );
                         aEntryString += "; >;";
-                        
+
                         aOStm.WriteLine( aEntryString );
                     }
-                    
+
                     aOStm.WriteLine( "};" );
                    }
                 else
@@ -1335,22 +1332,22 @@ void RscCompiler::PreprocessSrsFile( const RscCmdLine::OutputFile& rOutputFile,
                 aOStm.WriteLine( aLine );
         }
     }
-        
+
     if( aMissingImages.size() > 0 )
     {
         ByteString aImagesStr;
-        
+
         for( sal_uInt32 i = 0; i < aMissingImages.size(); ++i )
         {
             if( i )
                 aImagesStr += ' ';
-                
+
             aImagesStr += aMissingImages[ i ];
         }
-    
+
         pTC->pEH->FatalError( ERR_NOIMAGE, RscId(), aImagesStr.GetBuffer() );
     }
-    
+
     if( pSysListFile )
         fclose( pSysListFile );
 }
diff --git a/rsc/source/tools/rscdef.cxx b/rsc/source/tools/rscdef.cxx
index 26ba6b8..69f6348 100644
--- a/rsc/source/tools/rscdef.cxx
+++ b/rsc/source/tools/rscdef.cxx
@@ -606,13 +606,10 @@ RscFile :: RscFile(){
 |*	  RscFile::~RscFile()
 |*
 *************************************************************************/
-RscFile :: ~RscFile(){
-    RscDepend * pDep = Remove( (ULONG)0 );
-
-    while( pDep ){
-        delete pDep;
-        pDep = Remove( (ULONG)0 );
-    }
+RscFile :: ~RscFile() {
+    for ( size_t i = 0, n = aDepLst.size(); i < n; ++i )
+        delete aDepLst[ i ];
+    aDepLst.clear();
 
     //von hinten nach vorne ist besser wegen der Abhaengigkeiten
     //Objekte zerstoeren sich, wenn Referenzzaehler NULL
@@ -631,19 +628,19 @@ RscFile :: ~RscFile(){
 BOOL RscFile::Depend( ULONG lDepend, ULONG lFree ){
     RscDepend * pDep;
 
-    pDep = Last();
-    while( pDep ){
-        if( pDep->GetFileKey() == lDepend ){
-            while( pDep ){
+    for ( size_t i = aDepLst.size(); i > 0; )
+    {
+        pDep = aDepLst[ --i ];
+        if( pDep->GetFileKey() == lDepend ) {
+            for ( size_t j = i ? --i : 0; j > 0; )
+            {
+                pDep = aDepLst[ --j ];
                 if( pDep->GetFileKey() == lFree )
                     return TRUE;
-                pDep = Prev();
             }
             return FALSE;
         }
-        pDep = Prev();
-    };
-
+    }
     return TRUE;
 }
 
@@ -652,25 +649,25 @@ BOOL RscFile::Depend( ULONG lDepend, ULONG lFree ){
 |*	  RscFile::InsertDependFile()
 |*
 *************************************************************************/
-BOOL RscFile :: InsertDependFile( ULONG lIncFile, ULONG lPos )
+BOOL RscFile :: InsertDependFile( ULONG lIncFile, size_t lPos )
 {
-    RscDepend * pDep;
-
-    pDep = First();
-    while( pDep ){
+    for ( size_t i = 0, n = aDepLst.size(); i < n; ++i )
+    {
+        RscDepend* pDep = aDepLst[ i ];
         if( pDep->GetFileKey() == lIncFile )
             return TRUE;
-        pDep = Next();
     }
 
     // Current-Zeiger steht auf letztem Element
-    if( lPos >= Count() ){ //letztes Element muss immer letztes bleiben
+    if( lPos >= aDepLst.size() ) { //letztes Element muss immer letztes bleiben
         // Abhaengigkeit vor der letzten Position eintragen
-        Insert( new RscDepend( lIncFile ) );
+        aDepLst.push_back( new RscDepend( lIncFile ) );
+    }
+    else {
+        RscDependList::iterator it = aDepLst.begin();
+        ::std::advance( it, lPos );
+        aDepLst.insert( it, new RscDepend( lIncFile ) );
     }
-    else
-        Insert( new RscDepend( lIncFile ), lPos );
-
     return TRUE;
 }
 
@@ -681,15 +678,15 @@ BOOL RscFile :: InsertDependFile( ULONG lIncFile, ULONG lPos )
 *************************************************************************/
 void RscFile :: RemoveDependFile( ULONG lDepFile )
 {
-
-    RscDepend * pDep = Last();
-
-    while( pDep ){
-        if( pDep->GetFileKey() == lDepFile ){
-            Remove( pDep );
-            delete pDep;
+    for ( size_t i = aDepLst.size(); i > 0; )
+    {
+        RscDepend* pDep = aDepLst[ --i ];
+        if( pDep->GetFileKey() == lDepFile ) {
+            RscDependList::iterator it = aDepLst.begin();
+            ::std::advance( it, i );
+            delete *it;
+            aDepLst.erase( it );
         }
-        pDep = Prev();
     }
 }
 


More information about the Libreoffice-commits mailing list