[Libreoffice-commits] .: cui/source

Joseph Powers jpowers at kemper.freedesktop.org
Sun Jun 19 06:59:39 PDT 2011


 cui/source/dialogs/cuigaldlg.cxx |   47 +++++++++++++++++++++++++++++----------
 cui/source/inc/cuigaldlg.hxx     |   15 ++++++------
 2 files changed, 43 insertions(+), 19 deletions(-)

New commits:
commit 1b10ca272fee3f956d3126b5a02136c2c700f7fb
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Sun Jun 19 06:59:30 2011 -0700

    Replace List with std::vector< FilterEntry* >

diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx
index d39e95a..07a11c4 100644
--- a/cui/source/dialogs/cuigaldlg.cxx
+++ b/cui/source/dialogs/cuigaldlg.cxx
@@ -116,7 +116,7 @@ void SAL_CALL SearchThread::run()
             nBeginFormat = nEndFormat = nFileNumber;
 
         for( sal_uInt16 i = nBeginFormat; i <= nEndFormat; ++i )
-            aFormats.push_back( ( (FilterEntry*) mpBrowser->aFilterEntryList.GetObject( i ) )->aFilterName.ToLowerAscii() );
+            aFormats.push_back( mpBrowser->aFilterEntryList[ i ]->aFilterName.ToLowerAscii() );
 
         ImplSearch( maStartURL, aFormats, mpBrowser->bSearchRecursive );
     }
@@ -830,8 +830,9 @@ TPGalleryThemeProperties::~TPGalleryThemeProperties()
     for ( size_t i = 0, n = aFoundList.size(); i < n; ++i )
         delete aFoundList[ i ];
 
-    for( void* pEntry = aFilterEntryList.First(); pEntry; pEntry = aFilterEntryList.Next() )
-        delete (FilterEntry*) pEntry;
+    for ( size_t i = 0, n = aFilterEntryList.size(); i < n; ++i ) {
+        delete aFilterEntryList[ i ];
+    }
 }
 
 // ------------------------------------------------------------------------
@@ -877,7 +878,8 @@ void TPGalleryThemeProperties::FillFilterList()
     {
         aExt = rFilter.GetImportFormatShortName( i );
         aName = rFilter.GetImportFormatName( i );
-        pTestEntry = (FilterEntry*) aFilterEntryList.First();
+        size_t entryIndex = 0;
+        pTestEntry = aFilterEntryList.empty() ? NULL : aFilterEntryList[ entryIndex ];
         bInList = sal_False;
 
         String aExtensions;
@@ -904,18 +906,24 @@ void TPGalleryThemeProperties::FillFilterList()
                 bInList = sal_True;
                 break;
             }
-            pTestEntry = (FilterEntry*) aFilterEntryList.Next();
+            pTestEntry = ( ++entryIndex < aFilterEntryList.size() )
+                       ? aFilterEntryList[ entryIndex ] : NULL;
         }
         if ( !bInList )
         {
             pFilterEntry = new FilterEntry;
             pFilterEntry->aFilterName = aExt;
-            aFilterEntryList.Insert( pFilterEntry, aCbbFileType.InsertEntry( aName ) );
+            size_t pos = aCbbFileType.InsertEntry( aName );
+            if ( pos < aFilterEntryList.size() ) {
+                aFilterEntryList.insert( aFilterEntryList.begin() + pos, pFilterEntry );
+            } else {
+                aFilterEntryList.push_back( pFilterEntry );
+            }
         }
     }
 
     // media filters
-       static const ::rtl::OUString aWildcard( RTL_CONSTASCII_USTRINGPARAM( "*." ) );
+    static const ::rtl::OUString aWildcard( RTL_CONSTASCII_USTRINGPARAM( "*." ) );
     ::avmedia::FilterNameVector     aFilters;
     const ::rtl::OUString           aSeparator( RTL_CONSTASCII_USTRINGPARAM( ";" ) );
     ::rtl::OUString                 aAllTypes;
@@ -930,9 +938,20 @@ void TPGalleryThemeProperties::FillFilterList()
 
             pFilterEntry = new FilterEntry;
             pFilterEntry->aFilterName = aFilters[ l ].second.getToken( 0, ';', nIndex );
-            nFirstExtFilterPos = aCbbFileType.InsertEntry( addExtension( aFilters[ l ].first,
-                                                           aFilterWildcard += pFilterEntry->aFilterName ) );
-            aFilterEntryList.Insert( pFilterEntry, nFirstExtFilterPos );
+            nFirstExtFilterPos = aCbbFileType.InsertEntry(
+                addExtension(
+                    aFilters[ l ].first,
+                    aFilterWildcard += pFilterEntry->aFilterName
+                )
+            );
+            if ( nFirstExtFilterPos < aFilterEntryList.size() ) {
+                aFilterEntryList.insert(
+                    aFilterEntryList.begin() + nFirstExtFilterPos,
+                    pFilterEntry
+                );
+            } else {
+                aFilterEntryList.push_back( pFilterEntry );
+            }
         }
     }
 
@@ -978,8 +997,12 @@ void TPGalleryThemeProperties::FillFilterList()
     pFilterEntry = new FilterEntry;
     pFilterEntry->aFilterName = String( CUI_RES( RID_SVXSTR_GALLERY_ALLFILES ) );
     pFilterEntry->aFilterName = addExtension( pFilterEntry->aFilterName, aExtensions );
-    aFilterEntryList.Insert(pFilterEntry, aCbbFileType. InsertEntry( pFilterEntry->aFilterName, 0 ) );
-
+    size_t pos = aCbbFileType.InsertEntry( pFilterEntry->aFilterName, 0 );
+    if ( pos < aFilterEntryList.size() ) {
+        aFilterEntryList.insert( aFilterEntryList.begin() + pos, pFilterEntry );
+    } else {
+        aFilterEntryList.push_back( pFilterEntry );
+    }
     aCbbFileType.SetText( pFilterEntry->aFilterName );
 }
 
diff --git a/cui/source/inc/cuigaldlg.hxx b/cui/source/inc/cuigaldlg.hxx
index 0d82fd0..1009ce0 100644
--- a/cui/source/inc/cuigaldlg.hxx
+++ b/cui/source/inc/cuigaldlg.hxx
@@ -309,6 +309,7 @@ public:
 // ----------------------------
 // - TPGalleryThemeProperties -
 // ----------------------------
+typedef ::std::vector< FilterEntry* > FilterEntryList_impl;
 
 class TPGalleryThemeProperties : public SfxTabPage
 {
@@ -325,13 +326,13 @@ class TPGalleryThemeProperties : public SfxTabPage
     CheckBox            aCbxPreview;
     GalleryPreview      aWndPreview;
 
-    ExchangeData*       pData;
-    StringList          aFoundList;
-    List                aFilterEntryList;
-    Timer               aPreviewTimer;
-    String              aLastFilterName;
-    String              aPreviewString;
-    INetURLObject       aURL;
+    ExchangeData*           pData;
+    StringList              aFoundList;
+    FilterEntryList_impl    aFilterEntryList;
+    Timer                   aPreviewTimer;
+    String                  aLastFilterName;
+    String                  aPreviewString;
+    INetURLObject           aURL;
     sal_uInt16              nCurFilterPos;
     sal_uInt16              nFirstExtFilterPos;
     sal_Bool                bEntriesFound;


More information about the Libreoffice-commits mailing list