[Libreoffice-commits] .: svtools/source

Joseph Powers jpowers at kemper.freedesktop.org
Wed Feb 9 06:29:27 PST 2011


 svtools/source/dialogs/filedlg2.cxx |   67 +++++++++++++++---------------------
 svtools/source/dialogs/filedlg2.hxx |   27 +++++++-------
 2 files changed, 43 insertions(+), 51 deletions(-)

New commits:
commit dab17b16bbdd36c645b73b6064a130e10982d58a
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Wed Feb 9 06:29:19 2011 -0800

    Remove DECLARE_LIST( ImpFilterList, ImpFilterItem* )

diff --git a/svtools/source/dialogs/filedlg2.cxx b/svtools/source/dialogs/filedlg2.cxx
index f117499..676defa 100644
--- a/svtools/source/dialogs/filedlg2.cxx
+++ b/svtools/source/dialogs/filedlg2.cxx
@@ -43,7 +43,6 @@
 #include <com/sun/star/i18n/XCollator.hpp>
 
 #include <svtools/stdctrl.hxx>
-#include <vector>
 
 #ifdef _MSC_VER
 #pragma optimize ("", off)
@@ -725,12 +724,10 @@ ImpFileDialog::ImpFileDialog( PathDialog* pDlg, WinBits nWinBits, RESOURCE_TYPE
 
 ImpFileDialog::~ImpFileDialog()
 {
-    ImpFilterItem* pItem = aFilterList.First();
-    while( pItem )
-    {
-        delete pItem;
-        pItem = aFilterList.Next();
+    for ( size_t i = 0, n = aFilterList.size(); i < n; ++i ) {
+        delete aFilterList[ i ];
     }
+    aFilterList.clear();
 
     delete pFileTitel;
     if (pFileList && ( pFileList != pDirList ) )
@@ -913,16 +910,13 @@ IMPL_LINK( ImpFileDialog, DblClickHdl, ListBox *, pBox )
     if( pBox == pTypeList )
     {
         // Neue Maske setzen, und Listboxen updaten
-        USHORT nCurPos = pTypeList->GetSelectEntryPos();
-        if( nCurPos+1 > (USHORT)aFilterList.Count() )
+        size_t nCurPos = pTypeList->GetSelectEntryPos();
+        if( nCurPos+1 > aFilterList.size() )
             aMask = UniString::CreateFromAscii( ALLFILES );
         else
         {
-            UniString aFilterListMask = aFilterList.GetObject( nCurPos )->aMask;
-//						if( aFilterListMask.Search( ';' ) == STRING_NOTFOUND ) // kein ; in der Maske
-//								aMask = WildCard( aFilterListMask, '\0' );
-//						else // ; muss beruecksichtigt werden
-                aMask = WildCard( aFilterListMask, ';' );
+            UniString aFilterListMask = aFilterList[ nCurPos ]->aMask;
+            aMask = WildCard( aFilterListMask, ';' );
         }
 
         pEdit->SetText( aMask() );
@@ -1191,7 +1185,7 @@ void ImpFileDialog::SetPath( Edit const& rEdit )
 
 void ImpFileDialog::AddFilter( const UniString& rFilter, const UniString& rMask )
 {
-    aFilterList.Insert( new ImpFilterItem( rFilter, rMask ), LIST_APPEND );
+    aFilterList.push_back( new ImpFilterItem( rFilter, rMask ) );
     if( pTypeList )
         pTypeList->InsertEntry( rFilter, LISTBOX_APPEND );
 
@@ -1201,27 +1195,24 @@ void ImpFileDialog::AddFilter( const UniString& rFilter, const UniString& rMask
 
 void ImpFileDialog::RemoveFilter( const UniString& rFilter )
 {
-    ImpFilterItem* pItem = aFilterList.First();
-    while( pItem && pItem->aName != rFilter )
-        pItem = aFilterList.Next();
-
-    if( pItem )
-    {
-        delete aFilterList.Remove();
-        if( pTypeList )
-            pTypeList->RemoveEntry( rFilter );
+    for ( ImpFilterList::iterator it = aFilterList.begin(); it < aFilterList.end(); ++it ) {
+        if ( (*it)->aName == rFilter ) {
+            delete *it;
+            aFilterList.erase( it );
+            if ( pTypeList ) {
+                pTypeList->RemoveEntry( rFilter );
+            }
+            break;
+        }
     }
 }
 
 void ImpFileDialog::RemoveAllFilter()
 {
-    ImpFilterItem* pItem = aFilterList.First();
-    while( pItem )
-    {
-        delete pItem;
-        pItem = aFilterList.Next();
+    for ( size_t i = 0, n = aFilterList.size(); i < n ; ++i ) {
+        delete aFilterList[ i ];
     }
-    aFilterList.Clear();
+    aFilterList.clear();
 
     if( pTypeList )
         pTypeList->Clear();
@@ -1232,14 +1223,14 @@ void ImpFileDialog::SetCurFilter( const UniString& rFilter )
     if( !pTypeList )
         return;
 
-    ImpFilterItem* pItem = aFilterList.First();
-    while( pItem && pItem->aName != rFilter )
-        pItem = aFilterList.Next();
+    for ( size_t i = 0, n = aFilterList.size(); i < n; ++i ) {
+        if ( aFilterList[ i ]->aName == rFilter ) {
+            pTypeList->SelectEntryPos( USHORT( i ) );
+            return;
+        }
+    }
 
-    if( pItem )
-        pTypeList->SelectEntryPos( (USHORT)aFilterList.GetCurPos() );
-    else
-        pTypeList->SetNoSelection();
+    pTypeList->SetNoSelection();
 }
 
 UniString ImpFileDialog::GetCurFilter() const
@@ -1269,9 +1260,9 @@ void ImpFileDialog::PreExecute()
     if( pTypeList )
     {
         USHORT nCurType = pTypeList->GetSelectEntryPos();
-        if( nCurType < aFilterList.Count() )
+        if( nCurType < aFilterList.size() )
         {
-            UniString aFilterListMask = aFilterList.GetObject( nCurType )->aMask;
+            UniString aFilterListMask = aFilterList[ nCurType ]->aMask;
             if( aFilterListMask.Search( ';' ) == STRING_NOTFOUND ) // kein ; in der Maske
                 aMask = WildCard( aFilterListMask, '\0' );
             else // ; in der Maske, muss in der Wildcard beruecksichtigt werden
diff --git a/svtools/source/dialogs/filedlg2.hxx b/svtools/source/dialogs/filedlg2.hxx
index 9a5874a..7e19335 100644
--- a/svtools/source/dialogs/filedlg2.hxx
+++ b/svtools/source/dialogs/filedlg2.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
@@ -33,6 +33,7 @@
 #include <tools/fsys.hxx>
 #include <vcl/button.hxx>
 #include <vcl/unohelp.hxx>
+#include <vector>
 
 class FixedText;
 class Edit;
@@ -56,7 +57,7 @@ struct ImpFilterItem
     }
 };
 
-DECLARE_LIST( ImpFilterList, ImpFilterItem* )
+typedef ::std::vector< ImpFilterItem* > ImpFilterList;
 #include <vcl/lstbox.hxx>
 
 class KbdListBox : public ListBox
@@ -167,9 +168,9 @@ public:
     void				SetCurFilter( const String& rFilter );
     String				GetCurFilter() const;
 
-    USHORT				GetFilterCount() const	{ return (USHORT)aFilterList.Count(); }
-    inline String		GetFilterName( USHORT nPos ) const;
-    inline String		GetFilterType( USHORT nPos ) const;
+    size_t              GetFilterCount() const	{ return aFilterList.size(); }
+    inline String		GetFilterName( size_t nPos ) const;
+    inline String		GetFilterType( size_t nPos ) const;
 
     virtual	void		SetPath( const String& rPath );
     virtual void 		SetPath( const Edit& rEdit );
@@ -180,21 +181,21 @@ public:
     FileDialog*		GetFileDialog() const { return (FileDialog*)GetPathDialog(); }
 };
 
-inline String ImpFileDialog::GetFilterName( USHORT nPos ) const
+inline String ImpFileDialog::GetFilterName( size_t nPos ) const
 {
     String aName;
-    ImpFilterItem* pItem = aFilterList.GetObject( nPos );
-    if ( pItem )
-        aName = pItem->aName;
+    if ( nPos < aFilterList.size() ) {
+        aName = aFilterList[ nPos ]->aName;
+    }
     return aName;
 }
 
-inline String ImpFileDialog::GetFilterType( USHORT nPos ) const
+inline String ImpFileDialog::GetFilterType( size_t nPos ) const
 {
     String aFilterMask;
-    ImpFilterItem* pItem = aFilterList.GetObject( nPos );
-    if ( pItem )
-        aFilterMask = pItem->aMask;
+    if ( nPos < aFilterList.size() ) {
+        aFilterMask = aFilterList[ nPos ]->aMask;
+    }
     return aFilterMask;
 }
 


More information about the Libreoffice-commits mailing list