diff options
author | Noel Grandin <noel@peralex.com> | 2012-01-31 14:16:38 +0000 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2012-01-31 14:17:33 +0000 |
commit | 5a71069339b3a3c118f3015d978799ef66db7564 (patch) | |
tree | 3244dc4c91e6e2a0cfd70f8edca2e57ab36a5faf | |
parent | d1a84bdb8065c46d98908bc5caec4a995d4d196f (diff) |
convert SdCustomeShow from tools/list to vector
-rw-r--r-- | sd/inc/cusshow.hxx | 14 | ||||
-rw-r--r-- | sd/source/core/cusshow.cxx | 28 | ||||
-rw-r--r-- | sd/source/core/drawdoc_animations.cxx | 3 | ||||
-rw-r--r-- | sd/source/filter/ppt/pptin.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/dlg/custsdlg.cxx | 26 | ||||
-rw-r--r-- | sd/source/ui/dlg/sdtreelb.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/slideshow/slideshowimpl.cxx | 10 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unocpres.cxx | 16 |
8 files changed, 52 insertions, 51 deletions
diff --git a/sd/inc/cusshow.hxx b/sd/inc/cusshow.hxx index 1f981e9a770e..1bd361452b6d 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 c6043446701a..dcdb343469b8 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 5b41d0cbc015..de62ec5b53df 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 203d2f3bfd43..af5dd14d8cf6 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 2a56b7e125dd..210c44667e0b 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 ed79b244f9ef..713273955e1e 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 8df640718584..d61899415384 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 71f70fabf69f..e0aa857e2824 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 ) { |