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

Joseph Powers jpowers at kemper.freedesktop.org
Sun Jan 2 21:45:22 PST 2011


 svx/inc/svx/gallery1.hxx         |   43 +++++++++++---------
 svx/source/gallery2/gallery1.cxx |   81 ++++++++++++++++++++++-----------------
 2 files changed, 70 insertions(+), 54 deletions(-)

New commits:
commit 9183ccfb2dafa26e7319726d57a1d64390bc8f28
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Sun Jan 2 21:45:13 2011 -0800

    Remove DECLARE_LIST() GalleryThemeList & GalleryImportThemeList

diff --git a/svx/inc/svx/gallery1.hxx b/svx/inc/svx/gallery1.hxx
index 7bcc6da..ec26c6e 100644
--- a/svx/inc/svx/gallery1.hxx
+++ b/svx/inc/svx/gallery1.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
@@ -37,6 +37,7 @@
 
 #include <cstdio>
 #include <list>
+#include <vector>
 
 // ---------------------
 // - GalleryThemeEntry -
@@ -58,17 +59,17 @@ private:
     BOOL					bImported;
     BOOL					bModified;
     BOOL					bThemeNameFromResource;
-                            
+
                             GalleryThemeEntry();
     INetURLObject			ImplGetURLIgnoreCase( const INetURLObject& rURL ) const;
-                            
-public:						
-                            
+
+public:
+
                             GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName,
                                                UINT32 nFileNumber, BOOL bReadOnly, BOOL bImported,
                                                BOOL bNewFile, UINT32 nId, BOOL bThemeNameFromResource );
                             ~GalleryThemeEntry() {};
-                            
+
     const String&			GetThemeName() const { return aName; }
     UINT32					GetFileNumber() const { return nFileNumber; }
 
@@ -79,20 +80,20 @@ public:
     BOOL					IsImported() const { return bImported; }
     BOOL					IsReadOnly() const { return bReadOnly; }
     BOOL					IsDefault() const;
-                            
+
     BOOL					IsHidden() const { return aName.SearchAscii( "private://gallery/hidden/" ) == 0; }
-                            
+
     BOOL					IsModified() const { return bModified; }
     void					SetModified( BOOL bSet ) { bModified = ( bSet && !IsImported() && !IsReadOnly() ); }
-                            
+
     void					SetName( const String& rNewName );
     BOOL					IsNameFromResource() const { return bThemeNameFromResource; }
-                            
+
     UINT32					GetId() const { return nId; }
     void					SetId( UINT32 nNewId, BOOL bResetThemeName );
 };
 
-DECLARE_LIST( GalleryThemeList, GalleryThemeEntry* )
+typedef ::std::vector< GalleryThemeEntry* > GalleryThemeList;
 
 // ---------------------------
 // - GalleryImportThemeEntry -
@@ -105,7 +106,8 @@ struct GalleryImportThemeEntry
     INetURLObject	aURL;
     String			aImportName;
 };
-DECLARE_LIST( GalleryImportThemeList, GalleryImportThemeEntry* )
+
+typedef ::std::vector< GalleryImportThemeEntry* > GalleryImportThemeList;
 
 // -----------------------------------------------------------------------------
 
@@ -135,12 +137,12 @@ private:
     rtl_TextEncoding			nReadTextEncoding;
     ULONG						nLastFileNumber;
     BOOL						bMultiPath;
-                                
+
     void						ImplLoad( const String& rMultiPath );
     void						ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbIsReadOnly );
     void						ImplLoadImports();
     void 						ImplWriteImportList();
-    
+
     SVX_DLLPUBLIC GalleryThemeEntry*			ImplGetThemeEntry( const String& rThemeName );
     GalleryThemeEntry* 			ImplGetThemeEntry( ULONG nThemeId );
     GalleryImportThemeEntry*	ImplGetImportThemeEntry( const String& rImportName );
@@ -154,11 +156,12 @@ private:
 public:
 
     SVX_DLLPUBLIC static Gallery* GetGalleryInstance();
-                                
-    ULONG					GetThemeCount() const { return aThemeList.Count(); }
-    const GalleryThemeEntry*	GetThemeInfo( ULONG nPos ) { return aThemeList.GetObject( nPos ); }
+
+    size_t                      GetThemeCount() const { return aThemeList.size(); }
+    const GalleryThemeEntry*    GetThemeInfo( size_t nPos )
+                                { return nPos < aThemeList.size() ? aThemeList[ nPos ] : NULL; }
     const GalleryThemeEntry*	GetThemeInfo( const String& rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
-    
+
     SVX_DLLPUBLIC BOOL			HasTheme( const String& rThemeName );
     String						GetThemeName( ULONG nThemeId ) const;
 
@@ -173,10 +176,10 @@ public:
 public:
 
     INetURLObject				GetImportURL( const String& rThemeName );
-    
+
     const INetURLObject&		GetUserURL() const { return aUserURL; }
     const INetURLObject&		GetRelativeURL() const { return aRelURL; }
-    
+
     BOOL						IsMultiPath() const { return bMultiPath; }
 };
 
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index b667413..d03b67b 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.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
@@ -210,12 +210,14 @@ Gallery::Gallery( const String& rMultiPath )
 Gallery::~Gallery()
 {
     // Themen-Liste loeschen
-    for( GalleryThemeEntry* pThemeEntry = aThemeList.First(); pThemeEntry; pThemeEntry = aThemeList.Next() )
-        delete pThemeEntry;
+    for ( size_t i = 0, n = aThemeList.size(); i < n; ++i )
+        delete aThemeList[ i ];
+    aThemeList.clear();
 
     // Import-Liste loeschen
-    for( GalleryImportThemeEntry* pImportEntry = aImportList.First(); pImportEntry; pImportEntry = aImportList.Next() )
-        delete pImportEntry;
+    for ( size_t i = 0, n = aImportList.size(); i < n; ++i )
+        delete aImportList[ i ];
+    aImportList.clear();
 }
 
 // ------------------------------------------------------------------------
@@ -433,7 +435,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR
                                 {
                                     const ULONG nFileNumber = (ULONG) String(aThmURL.GetBase()).Erase( 0, 2 ).Erase( 6 ).ToInt32();
 
-                                    aThemeList.Insert( pEntry, LIST_APPEND );
+                                    aThemeList.push_back( pEntry );
 
                                     if( nFileNumber > nLastFileNumber )
                                         nLastFileNumber = nFileNumber;
@@ -488,10 +490,10 @@ void Gallery::ImplLoadImports()
             UINT16                      i;
             UINT16                      nTempCharSet;
 
-            for( pImportEntry = aImportList.First(); pImportEntry; pImportEntry = aImportList.Next() )
-                delete pImportEntry;
+            for ( size_t j = 0, n = aImportList.size(); j < n; ++j )
+                delete aImportList[ j ];
+            aImportList.clear();
 
-            aImportList.Clear();
             *pIStm >> nInventor;
 
             if( nInventor == COMPAT_FORMAT( 'S', 'G', 'A', '3' ) )
@@ -503,14 +505,14 @@ void Gallery::ImplLoadImports()
                     pImportEntry = new GalleryImportThemeEntry;
 
                     *pIStm >> *pImportEntry;
-                    aImportList.Insert( pImportEntry, LIST_APPEND );
+                    aImportList.push_back( pImportEntry );
                     aFile = INetURLObject( pImportEntry->aURL );
                     pThemeEntry = new GalleryThemeEntry( aFile,
                                                          pImportEntry->aUIName,
                                                          String(aFile.GetBase()).Erase( 0, 2 ).Erase( 6 ).ToInt32(),
                                                          TRUE, TRUE, FALSE, 0, FALSE );
 
-                    aThemeList.Insert( pThemeEntry, LIST_APPEND );
+                    aThemeList.push_back( pThemeEntry );
                 }
             }
 
@@ -532,10 +534,10 @@ void Gallery::ImplWriteImportList()
         const UINT32 nInventor = (UINT32) COMPAT_FORMAT( 'S', 'G', 'A', '3' );
         const UINT16 nId = 0x0004;
 
-        *pOStm << nInventor << nId << (UINT32) aImportList.Count() << (UINT16) gsl_getSystemTextEncoding();
+        *pOStm << nInventor << nId << (UINT32) aImportList.size() << (UINT16) gsl_getSystemTextEncoding();
 
-        for( GalleryImportThemeEntry* pImportEntry = aImportList.First(); pImportEntry; pImportEntry = aImportList.Next() )
-            *pOStm << *pImportEntry;
+        for ( size_t i = 0, n = aImportList.size(); i < n; ++i )
+            *pOStm << *aImportList[ i ];
 
         if( pOStm->GetError() )
             ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
@@ -551,9 +553,9 @@ GalleryThemeEntry* Gallery::ImplGetThemeEntry( const String& rThemeName )
     GalleryThemeEntry* pFound = NULL;
 
     if( rThemeName.Len() )
-        for( GalleryThemeEntry* pEntry = aThemeList.First(); pEntry && !pFound; pEntry = aThemeList.Next() )
-            if( rThemeName == pEntry->GetThemeName() )
-                pFound = pEntry;
+        for ( size_t i = 0, n = aThemeList.size(); i < n && !pFound; ++i )
+            if( rThemeName == aThemeList[ i ]->GetThemeName() )
+                pFound = aThemeList[ i ];
 
     return pFound;
 }
@@ -562,13 +564,10 @@ GalleryThemeEntry* Gallery::ImplGetThemeEntry( const String& rThemeName )
 
 GalleryImportThemeEntry* Gallery::ImplGetImportThemeEntry( const String& rImportName )
 {
-    GalleryImportThemeEntry* pFound = NULL;
-
-    for( GalleryImportThemeEntry* pImportEntry = aImportList.First(); pImportEntry && !pFound; pImportEntry = aImportList.Next() )
-        if ( rImportName == pImportEntry->aUIName )
-            pFound = pImportEntry;
-
-    return pFound;
+    for ( size_t i = 0, n = aImportList.size(); i < n; ++i )
+        if ( rImportName == aImportList[ i ]->aUIName )
+            return aImportList[ i ];
+    return NULL;
 }
 
 // ------------------------------------------------------------------------
@@ -577,10 +576,9 @@ String Gallery::GetThemeName( ULONG nThemeId ) const
 {
     GalleryThemeEntry* pFound = NULL;
 
-    for( ULONG n = 0, nCount = aThemeList.Count(); n < nCount; n++ )
+    for ( size_t i = 0, n = aThemeList.size(); i < n && !pFound; ++i )
     {
-        GalleryThemeEntry* pEntry = aThemeList.GetObject( n );
-
+        GalleryThemeEntry* pEntry = aThemeList[ i ];
         if( nThemeId == pEntry->GetId() )
             pFound = pEntry;
     }
@@ -632,7 +630,7 @@ BOOL Gallery::CreateTheme( const String& rThemeName, UINT32 nNumFrom )
                                                               nLastFileNumber,
                                                               FALSE, FALSE, TRUE, 0, FALSE );
 
-        aThemeList.Insert( pNewEntry, LIST_APPEND );
+        aThemeList.push_back( pNewEntry );
         delete( new GalleryTheme( this, pNewEntry ) );
         Broadcast( GalleryHint( GALLERY_HINT_THEME_CREATED, rThemeName ) );
         bRet = TRUE;
@@ -696,14 +694,14 @@ BOOL Gallery::CreateImportTheme( const INetURLObject& rURL, const String& rImpor
                     }
 
                     pImportTheme->SetImportName( aNewName );
-                    aThemeList.Insert( pThemeEntry, LIST_APPEND );
+                    aThemeList.push_back( pThemeEntry );
 
                     // Thema in Import-Liste eintragen und Import-Liste     speichern
                     GalleryImportThemeEntry* pImportEntry = new GalleryImportThemeEntry;
                     pImportEntry->aThemeName = pImportEntry->aUIName = aNewName;
                     pImportEntry->aURL = rURL;
                     pImportEntry->aImportName = rImportName;
-                    aImportList.Insert( pImportEntry, LIST_APPEND );
+                    aImportList.push_back( pImportEntry );
                     ImplWriteImportList();
                     bRet = TRUE;
                 }
@@ -777,8 +775,15 @@ BOOL Gallery::RemoveTheme( const String& rThemeName )
 
             if( pImportEntry )
             {
-                delete aImportList.Remove( pImportEntry );
-                ImplWriteImportList();
+                for ( GalleryImportThemeList::iterator it = aImportList.begin(); it < aImportList.end(); ++it )
+                {
+                    if ( *it == pImportEntry )
+                    {
+                        delete pImportEntry;
+                        aImportList.erase( it );
+                        break;
+                    }
+                }
             }
         }
         else
@@ -800,7 +805,15 @@ BOOL Gallery::RemoveTheme( const String& rThemeName )
             }
         }
 
-        delete aThemeList.Remove( pThemeEntry );
+        for ( GalleryThemeList::iterator it = aThemeList.begin(); it < aThemeList.end(); ++it )
+        {
+            if ( pThemeEntry == *it ) {
+                delete pThemeEntry;
+                aThemeList.erase( it );
+                break;
+            }
+        }
+
         Broadcast( GalleryHint( GALLERY_HINT_THEME_REMOVED, rThemeName ) );
 
         bRet = TRUE;
@@ -919,7 +932,7 @@ void Gallery::ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener )
     }
 }
 
-BOOL GalleryThemeEntry::IsDefault() const 
+BOOL GalleryThemeEntry::IsDefault() const
 { return( ( nId > 0 ) && ( nId != ( RID_GALLERYSTR_THEME_MYTHEME - RID_GALLERYSTR_THEME_START ) ) ); }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list