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

Noel Power noelp at kemper.freedesktop.org
Tue Jan 31 06:16:44 PST 2012


 sd/inc/cusshow.hxx                       |   14 +++++++++-----
 sd/source/core/cusshow.cxx               |   28 ++++++++++------------------
 sd/source/core/drawdoc_animations.cxx    |    3 ++-
 sd/source/filter/ppt/pptin.cxx           |    2 +-
 sd/source/ui/dlg/custsdlg.cxx            |   26 +++++++++++++-------------
 sd/source/ui/dlg/sdtreelb.cxx            |    4 ++--
 sd/source/ui/slideshow/slideshowimpl.cxx |   10 +++++-----
 sd/source/ui/unoidl/unocpres.cxx         |   16 ++++++++++------
 8 files changed, 52 insertions(+), 51 deletions(-)

New commits:
commit 5a71069339b3a3c118f3015d978799ef66db7564
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Jan 31 14:16:38 2012 +0000

    convert SdCustomeShow from tools/list to vector

diff --git a/sd/inc/cusshow.hxx b/sd/inc/cusshow.hxx
index 1f981e9..1bd3614 100644
--- a/sd/inc/cusshow.hxx
+++ b/sd/inc/cusshow.hxx
@@ -29,7 +29,7 @@
 #ifndef _SD_CUSSHOW_HXX
 #define _SD_CUSSHOW_HXX
 
-#include <tools/list.hxx>
+#include <vector>
 #include <tools/stream.hxx>
 #include <tools/string.hxx>
 #include <cppuhelper/weakref.hxx>
@@ -43,9 +43,13 @@ class SdPage;
 |* CustomShow
 |*
 \************************************************************************/
-class SD_DLLPUBLIC SdCustomShow : public List
+class SD_DLLPUBLIC SdCustomShow
 {
+public:
+    typedef ::std::vector<const SdPage*> PageVec;
+
 private:
+    PageVec       maPages;
     String          aName;
     SdDrawDocument* pDoc;
 
@@ -65,14 +69,14 @@ public:
     // @@@ copy ctor, but no copy assignment? @@@
     SdCustomShow( const SdCustomShow& rShow );
 
+    PageVec& PagesVector();
+    void ReplacePage( const SdPage* pOldPage, const SdPage* pNewPage );
+
     void   SetName(const String& rName);
     String GetName() const;
 
     SdDrawDocument* GetDoc() const { return pDoc; }
 
-    void ReplacePage( const SdPage* pOldPage, const SdPage* pNewPage );
-    void RemovePage( const SdPage* pPage );
-
     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoCustomShow();
 };
 
diff --git a/sd/source/core/cusshow.cxx b/sd/source/core/cusshow.cxx
index c604344..dcdb343 100644
--- a/sd/source/core/cusshow.cxx
+++ b/sd/source/core/cusshow.cxx
@@ -45,7 +45,7 @@ using namespace ::com::sun::star;
 |*
 \************************************************************************/
 SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc)
-  : List(),
+  : maPages(),
   pDoc(pDrawDoc)
 {
 }
@@ -56,14 +56,14 @@ SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc)
 |*
 \************************************************************************/
 SdCustomShow::SdCustomShow( const SdCustomShow& rShow )
-    : List( rShow )
+    : maPages(rShow.maPages)
 {
     aName = rShow.GetName();
     pDoc = rShow.GetDoc();
 }
 
 SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xShow )
-  : List(),
+  : maPages(),
   pDoc(pDrawDoc),
   mxUnoCustomShow( xShow )
 {
@@ -97,28 +97,20 @@ uno::Reference< uno::XInterface > SdCustomShow::getUnoCustomShow()
     return xShow;
 }
 
+SdCustomShow::PageVec& SdCustomShow::PagesVector()
+{
+    return maPages;
+}
+
 void SdCustomShow::ReplacePage( const SdPage* pOldPage, const SdPage* pNewPage )
 {
     if( !pNewPage )
     {
-        RemovePage( pOldPage );
+        ::std::remove(maPages.begin(), maPages.end(), pOldPage);
     }
     else
     {
-        sal_uLong nPos;
-        while( (nPos = GetPos( (void*)pOldPage )) != CONTAINER_ENTRY_NOTFOUND  )
-        {
-            Replace( (void*)pNewPage, nPos );
-        }
-    }
-}
-
-void SdCustomShow::RemovePage( const SdPage* pPage )
-{
-    sal_uLong nPos;
-    while( (nPos = GetPos( (void*)pPage )) != CONTAINER_ENTRY_NOTFOUND  )
-    {
-        Remove( nPos );
+        ::std::replace(maPages.begin(), maPages.end(), pOldPage, pNewPage);
     }
 }
 
diff --git a/sd/source/core/drawdoc_animations.cxx b/sd/source/core/drawdoc_animations.cxx
index 5b41d0c..de62ec5 100644
--- a/sd/source/core/drawdoc_animations.cxx
+++ b/sd/source/core/drawdoc_animations.cxx
@@ -44,7 +44,8 @@ void SdDrawDocument::ReplacePageInCustomShows( const SdPage* pOldPage, const SdP
         {
             SdCustomShow* pCustomShow = (SdCustomShow*) mpCustomShowList->GetObject(i);
             if( pNewPage == 0 )
-                pCustomShow->RemovePage(pOldPage);
+                ::std::remove(pCustomShow->PagesVector().begin(), pCustomShow->PagesVector().end(),
+                    pOldPage);
             else
                 pCustomShow->ReplacePage(pOldPage,pNewPage);
         }
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 203d2f3..af5dd14 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -1301,7 +1301,7 @@ sal_Bool ImplSdPPTImport::Import()
                                                 SdPage* pPage = mpDoc->GetSdPage( nPage, PK_STANDARD );
                                                 if ( pPage )
                                                 {
-                                                    pSdCustomShow->Insert( pPage, LIST_APPEND );
+                                                    pSdCustomShow->PagesVector().push_back( pPage );
                                                     nFound++;
                                                 }
                                             }
diff --git a/sd/source/ui/dlg/custsdlg.cxx b/sd/source/ui/dlg/custsdlg.cxx
index 2a56b7e..210c446 100644
--- a/sd/source/ui/dlg/custsdlg.cxx
+++ b/sd/source/ui/dlg/custsdlg.cxx
@@ -356,12 +356,11 @@ SdDefineCustomShowDlg::SdDefineCustomShowDlg( Window* pWindow,
         aEdtName.SetText( aOldName );
 
         // ListBox mit CustomShow-Seiten fuellen
-        for( pPage = (SdPage*) rpCustomShow->First();
-             pPage != NULL;
-             pPage = (SdPage*) rpCustomShow->Next() )
+        for( SdCustomShow::PageVec::iterator it = rpCustomShow->PagesVector().begin();
+             it != rpCustomShow->PagesVector().end(); ++it )
         {
-            SvLBoxEntry* pEntry = aLbCustomPages.InsertEntry( pPage->GetName() );
-            pEntry->SetUserData( pPage );
+            SvLBoxEntry* pEntry = aLbCustomPages.InsertEntry( (*it)->GetName() );
+            pEntry->SetUserData( (SdPage*) (*it) );
         }
     }
     else
@@ -473,22 +472,23 @@ void SdDefineCustomShowDlg::CheckCustomShow()
     SvLBoxEntry* pEntry = NULL;
 
     // Anzahl vergleichen
-    if( rpCustomShow->Count() != aLbCustomPages.GetEntryCount() )
+    if( rpCustomShow->PagesVector().size() != aLbCustomPages.GetEntryCount() )
     {
-        rpCustomShow->Clear();
+        rpCustomShow->PagesVector().clear();
         bDifferent = sal_True;
     }
 
     // Seiten-Pointer vergleichen
     if( !bDifferent )
     {
-        for( pPage = (SdPage*) rpCustomShow->First(), pEntry = aLbCustomPages.First();
-             pPage != NULL && pEntry != NULL && !bDifferent;
-             pPage = (SdPage*) rpCustomShow->Next(), pEntry = aLbCustomPages.Next( pEntry ) )
+        SdCustomShow::PageVec::iterator it1 = rpCustomShow->PagesVector().begin();
+        pEntry = aLbCustomPages.First();
+        for( ; it1 != rpCustomShow->PagesVector().end() && pEntry != NULL && !bDifferent;
+             ++it1, pEntry = aLbCustomPages.Next( pEntry ) )
         {
-            if( pPage != pEntry->GetUserData() )
+            if( *it1 != pEntry->GetUserData() )
             {
-                rpCustomShow->Clear();
+                rpCustomShow->PagesVector().clear();
                 bDifferent = sal_True;
             }
         }
@@ -502,7 +502,7 @@ void SdDefineCustomShowDlg::CheckCustomShow()
              pEntry = aLbCustomPages.Next( pEntry ) )
         {
             pPage = (SdPage*) pEntry->GetUserData();
-            rpCustomShow->Insert( pPage, LIST_APPEND );
+            rpCustomShow->PagesVector().push_back( pPage );
         }
         bModified = sal_True;
     }
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index ed79b24..7132739 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -1201,9 +1201,9 @@ bool SdPageObjsTLB::PageBelongsToCurrentShow (const SdPage* pPage) const
         if (pCustomShow != NULL)
         {
             bBelongsToShow = false;
-            sal_uLong nPageCount = pCustomShow->Count();
+            sal_uLong nPageCount = pCustomShow->PagesVector().size();
             for (sal_uInt16 i=0; i<nPageCount && !bBelongsToShow; i++)
-                if (pPage == static_cast<SdPage*>(pCustomShow->GetObject (i)))
+                if (pPage == pCustomShow->PagesVector()[i])
                     bBelongsToShow = true;
         }
     }
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx
index 8df6407..d618994 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -2485,7 +2485,7 @@ void SlideshowImpl::createSlideList( bool bAll, bool bStartWithActualSlide, cons
 
         // create animation slide controller
         AnimationSlideController::Mode eMode =
-            ( pCustomShow && pCustomShow->Count() ) ? AnimationSlideController::CUSTOM :
+            ( pCustomShow && pCustomShow->PagesVector().size() ) ? AnimationSlideController::CUSTOM :
                 (bAll ? AnimationSlideController::ALL : AnimationSlideController::FROM);
 
         Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(), UNO_QUERY_THROW );
@@ -2546,11 +2546,11 @@ void SlideshowImpl::createSlideList( bool bAll, bool bStartWithActualSlide, cons
                     mpSlideController->insertSlideNumber( (sal_uInt16) nSlide );
             }
 
-            void* pCustomSlide;
-            sal_Int32 nSlideIndex;
-            for( pCustomSlide = pCustomShow->First(),nSlideIndex=0; pCustomSlide; pCustomSlide = pCustomShow->Next(), nSlideIndex++ )
+            sal_Int32 nSlideIndex = 0;
+            for( SdCustomShow::PageVec::iterator it = pCustomShow->PagesVector().begin();
+                 it != pCustomShow->PagesVector().end(); ++it, nSlideIndex++ )
             {
-                const sal_uInt16 nSdSlide = ( ( (SdPage*) pCustomSlide )->GetPageNum() - 1 ) / 2;
+                const sal_uInt16 nSdSlide = ( ( (SdPage*) (*it) )->GetPageNum() - 1 ) / 2;
 
                 if( !( mpDoc->GetSdPage( nSdSlide, PK_STANDARD ) )->IsExcluded())
                     mpSlideController->insertSlideNumber( nSdSlide );
diff --git a/sd/source/ui/unoidl/unocpres.cxx b/sd/source/ui/unoidl/unocpres.cxx
index 71f70fa..e0aa857 100644
--- a/sd/source/ui/unoidl/unocpres.cxx
+++ b/sd/source/ui/unoidl/unocpres.cxx
@@ -26,6 +26,8 @@
  *
  ************************************************************************/
 
+#include <algorithm>
+
 #include <com/sun/star/lang/DisposedException.hpp>
 #include <osl/mutex.hxx>
 #include <osl/mutex.hxx>
@@ -100,7 +102,7 @@ void SAL_CALL SdXCustomPresentation::insertByIndex( sal_Int32 Index, const uno::
     if( bDisposing )
         throw lang::DisposedException();
 
-    if( Index < 0 || Index > (sal_Int32)( mpSdCustomShow ? mpSdCustomShow->Count() : 0 ) )
+    if( Index < 0 || Index > (sal_Int32)( mpSdCustomShow ? mpSdCustomShow->PagesVector().size() : 0 ) )
         throw lang::IndexOutOfBoundsException();
 
     uno::Reference< drawing::XDrawPage > xPage;
@@ -119,7 +121,8 @@ void SAL_CALL SdXCustomPresentation::insertByIndex( sal_Int32 Index, const uno::
         if( NULL != mpModel && NULL == mpSdCustomShow && mpModel->GetDoc() )
             mpSdCustomShow = new SdCustomShow( mpModel->GetDoc() );
 
-        mpSdCustomShow->Insert(pPage->GetSdrPage(), Index);
+        mpSdCustomShow->PagesVector().insert(mpSdCustomShow->PagesVector().begin() + Index,
+            (SdPage*) pPage->GetSdrPage());
     }
 
     if( mpModel )
@@ -143,7 +146,8 @@ void SAL_CALL SdXCustomPresentation::removeByIndex( sal_Int32 Index )
         {
             SvxDrawPage* pPage = SvxDrawPage::getImplementation(  xPage );
             if(pPage)
-                mpSdCustomShow->Remove(pPage->GetSdrPage());
+                ::std::remove(mpSdCustomShow->PagesVector().begin(), mpSdCustomShow->PagesVector().end(),
+                    pPage->GetSdrPage());
         }
     }
 
@@ -185,7 +189,7 @@ sal_Int32 SAL_CALL SdXCustomPresentation::getCount()
     if( bDisposing )
         throw lang::DisposedException();
 
-    return mpSdCustomShow?mpSdCustomShow->Count():0;
+    return mpSdCustomShow ? mpSdCustomShow->PagesVector().size() : 0;
 }
 
 uno::Any SAL_CALL SdXCustomPresentation::getByIndex( sal_Int32 Index )
@@ -196,13 +200,13 @@ uno::Any SAL_CALL SdXCustomPresentation::getByIndex( sal_Int32 Index )
     if( bDisposing )
         throw lang::DisposedException();
 
-    if( Index < 0 || Index >= (sal_Int32)mpSdCustomShow->Count() )
+    if( Index < 0 || Index >= (sal_Int32)mpSdCustomShow->PagesVector().size() )
         throw lang::IndexOutOfBoundsException();
 
     uno::Any aAny;
     if(mpSdCustomShow )
     {
-        SdrPage* pPage = (SdrPage*)mpSdCustomShow->GetObject(Index);
+        SdrPage* pPage = (SdrPage*)mpSdCustomShow->PagesVector()[Index];
 
         if( pPage )
         {


More information about the Libreoffice-commits mailing list