[Libreoffice-commits] .: sd/source

Thorsten Behrens thorsten at kemper.freedesktop.org
Mon Mar 14 09:29:09 PDT 2011


 sd/source/ui/func/fuinsfil.cxx   |   10 +--
 sd/source/ui/func/fuprobjs.cxx   |   16 +++--
 sd/source/ui/inc/OutlineView.hxx |    4 -
 sd/source/ui/view/drawview.cxx   |   15 +++-
 sd/source/ui/view/drtxtob.cxx    |   19 +++---
 sd/source/ui/view/outlnvsh.cxx   |   86 ++++++++++++++++-----------
 sd/source/ui/view/outlview.cxx   |  121 +++++++++++++++++++--------------------
 7 files changed, 151 insertions(+), 120 deletions(-)

New commits:
commit ea3475a0a7a22278ee7755ed156ce61157a412a3
Author: npcdoom <venccsralph at gmail.com>
Date:   Mon Mar 14 16:51:38 2011 +0100

    Remove usage of deprecated container List in sd.

diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx
index 09e0058..efbf7fb 100644
--- a/sd/source/ui/func/fuinsfil.cxx
+++ b/sd/source/ui/func/fuinsfil.cxx
@@ -630,14 +630,16 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium)
         nFormat = EE_FORMAT_HTML;
 
     ::Outliner*	   pDocliner = static_cast<OutlineView*>(mpView)->GetOutliner();
-    List*		   pList	 = pDocliner->GetView(0)->CreateSelectionList();
-    Paragraph*	   pPara	 = (Paragraph*)pList->First();
+
+    std::vector<Paragraph*> aSelList;
+    pDocliner->GetView(0)->CreateSelectionList(aSelList);
+
+    Paragraph* pPara = aSelList.empty() ? NULL : *(aSelList.begin());
 
     // wo soll eingefuegt werden?
     while( !pDocliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
-    {
         pPara = pDocliner->GetParent(pPara);
-    }
+
     ULONG nTargetPos = pDocliner->GetAbsPos(pPara) + 1;
 
     // Layout der Vorgaengerseite uebernehmen
diff --git a/sd/source/ui/func/fuprobjs.cxx b/sd/source/ui/func/fuprobjs.cxx
index 402bd9c..408b43f 100644
--- a/sd/source/ui/func/fuprobjs.cxx
+++ b/sd/source/ui/func/fuprobjs.cxx
@@ -99,13 +99,20 @@ void FuPresentationObjects::DoExecute( SfxRequest& )
     OutlineView* pOlView = static_cast<OutlineView*>(pOutlineViewShell->GetView());
     OutlinerView* pOutlinerView = pOlView->GetViewByWindow( (Window*) mpWindow );
     ::Outliner* pOutl = pOutlinerView->GetOutliner();
-    List* pList = pOutlinerView->CreateSelectionList();
-    Paragraph* pPara = (Paragraph*)pList->First();
+
+    std::vector<Paragraph*> aSelList;
+    pOutlinerView->CreateSelectionList(aSelList);
+
+    std::vector<Paragraph*>::const_iterator iter = aSelList.begin();
+    Paragraph* pPara = aSelList.empty() ? NULL : *iter;
+
     nDepth = pOutl->GetDepth((USHORT)pOutl->GetAbsPos( pPara ) );
     bool bPage = pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE );
 
-    while( pPara )
+    while( iter != aSelList.end() )
     {
+        pPara = *iter;
+
         nTmp = pOutl->GetDepth((USHORT) pOutl->GetAbsPos( pPara ) );
 
         if( nDepth != nTmp )
@@ -120,8 +127,7 @@ void FuPresentationObjects::DoExecute( SfxRequest& )
             break;
         }
         bUnique = TRUE;
-
-        pPara = (Paragraph*) pList->Next();
+        ++iter;
     }
 
     if( bUnique )
diff --git a/sd/source/ui/inc/OutlineView.hxx b/sd/source/ui/inc/OutlineView.hxx
index 7d08c07..c13b453 100644
--- a/sd/source/ui/inc/OutlineView.hxx
+++ b/sd/source/ui/inc/OutlineView.hxx
@@ -191,8 +191,8 @@ private:
     SdrOutliner*		mpOutliner;
     OutlinerView*		mpOutlinerView[MAX_OUTLINERVIEWS];
 
-    List*				mpOldParaOrder;
-    List*				mpSelectedParas;
+    std::vector<Paragraph*> maOldParaOrder;
+    std::vector<Paragraph*> maSelectedParas;
 
     USHORT				mnPagesToProcess;	 // fuer die Fortschrittsanzeige
     USHORT				mnPagesProcessed;
diff --git a/sd/source/ui/view/drawview.cxx b/sd/source/ui/view/drawview.cxx
index 0be35b8..0cb307e 100644
--- a/sd/source/ui/view/drawview.cxx
+++ b/sd/source/ui/view/drawview.cxx
@@ -206,7 +206,7 @@ BOOL DrawView::SetAttributes(const SfxItemSet& rSet,
                     // Presentation object outline
                     OutlinerView* pOV	= GetTextEditOutlinerView();
                     ::Outliner* pOutliner = pOV->GetOutliner();
-                    List*		  pList = (List*)pOV->CreateSelectionList();
+
                     aTemplateName += String(SdResId(STR_LAYOUT_OUTLINE));
 
                     pOutliner->SetUpdateMode(FALSE);
@@ -219,7 +219,12 @@ BOOL DrawView::SetAttributes(const SfxItemSet& rSet,
                     aComment.Insert( String((SdResId(STR_PSEUDOSHEET_OUTLINE))), nPos);
                     mpDocSh->GetUndoManager()->EnterListAction( aComment, String() );
 
-                    Paragraph* pPara = (Paragraph*)pList->Last();
+                    std::vector<Paragraph*> aSelList;
+                    pOV->CreateSelectionList(aSelList);
+
+                    std::vector<Paragraph*>::reverse_iterator iter = aSelList.rbegin();
+                    Paragraph* pPara = iter != aSelList.rend() ? *iter : NULL;
+
                     while (pPara)
                     {
                         ULONG nParaPos = pOutliner->GetAbsPos( pPara );
@@ -260,10 +265,11 @@ BOOL DrawView::SetAttributes(const SfxItemSet& rSet,
                                 pOutlSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
                         }
 
-                        pPara = (Paragraph*)pList->Prev();
+                        ++iter;
+                        pPara = iter != aSelList.rend() ? *iter : NULL;
 
                         if( !pPara && nDepth > 0 &&  rSet.GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON &&
-                            pOutliner->GetDepth( (USHORT) pOutliner->GetAbsPos( (Paragraph*) pList->First() ) ) > 0 )
+                            pOutliner->GetDepth( (USHORT) pOutliner->GetAbsPos(*(aSelList.begin())) ) > 0 )
                             pPara = pOutliner->GetParagraph( 0 );  // Put NumBulletItem in outline level 1
                     }
 
@@ -272,7 +278,6 @@ BOOL DrawView::SetAttributes(const SfxItemSet& rSet,
 
                     mpDocSh->GetUndoManager()->LeaveListAction();
 
-                    delete pList;
                     bOk = TRUE;
                 }
                 else
diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx
index a5d4241..0e23e4e 100644
--- a/sd/source/ui/view/drtxtob.cxx
+++ b/sd/source/ui/view/drtxtob.cxx
@@ -262,8 +262,10 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
                 {
                     // Outliner im Gliederungsmodus
                     ::Outliner* pOutl = pOLV->GetOutliner();
-                    List* pList = pOLV->CreateSelectionList();
-                    Paragraph* pPara = (Paragraph*) pList->First();
+
+                    std::vector<Paragraph*> aSelList;
+                    pOLV->CreateSelectionList(aSelList);
+                    Paragraph* pPara = aSelList.empty() ? NULL : *(aSelList.begin());
 
                     // find out if we are a OutlineView
                     BOOL bIsOutlineView(OUTLINERMODE_OUTLINEVIEW == pOLV->GetOutliner()->GetMode());
@@ -289,8 +291,10 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
                         }
                     }
 
-                    while (pPara)
+                    for (std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); iter != aSelList.end(); ++iter)
                     {
+                        pPara = *iter;
+
                         sal_Int16 nDepth = pOutl->GetDepth( (USHORT) pOutl->GetAbsPos( pPara ) );
 
                         if (nDepth > 0 || (bOutlineViewSh && (nDepth <= 0) && !pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE )) )
@@ -305,11 +309,9 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
                             // Nicht maximale Tiefe und nicht ganz oben
                             bDisableRight = FALSE;
                         }
-
-                        pPara = static_cast<Paragraph*>( pList->Next() );
                     }
 
-                    if ( ( pOutl->GetAbsPos((Paragraph*) pList->Last()) < pOutl->GetParagraphCount() - 1 ) &&
+                    if ( ( pOutl->GetAbsPos(pPara) < pOutl->GetParagraphCount() - 1 ) &&
                          ( pOutl->GetParagraphCount() > 1 || !bOutlineViewSh) )
                     {
                         // Nicht letzter Absatz
@@ -317,7 +319,8 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
                     }
 
                     // disable when first para and 2nd is not a title
-                    pPara = static_cast< Paragraph* >( pList->First() );
+                    pPara = aSelList.empty() ? NULL : *(aSelList.begin());
+
                     if(!bDisableDown && bIsOutlineView
                         && pPara
                         && 0 == pOutl->GetAbsPos(pPara)
@@ -327,8 +330,6 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
                         // Needs to be disabled
                         bDisableDown = TRUE;
                     }
-
-                    delete pList;
                 }
 
                 if (bDisableLeft)
diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx
index e14a166..5149c85 100644
--- a/sd/source/ui/view/outlnvsh.cxx
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -862,29 +862,39 @@ void OutlineViewShell::GetMenuState( SfxItemSet &rSet )
     BOOL bDisableExpand   = TRUE;
     BOOL bUnique		  = TRUE;
     OutlinerView* pOutlinerView = pOlView->GetViewByWindow(GetActiveWindow());
-    List* pList = pOutlinerView->CreateSelectionList();
-    Paragraph* pPara = (Paragraph*)pList->First();
 
-    sal_Int16 nDepth;
-    sal_Int16 nTmpDepth = pOutl->GetDepth( (USHORT) pOutl->GetAbsPos( pPara ) );
-    bool bPage = pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE );
-    while (pPara)
+    std::vector<Paragraph*> aSelList;
+    pOutlinerView->CreateSelectionList(aSelList);
+
+    if (!aSelList.empty())
     {
-        nDepth = pOutl->GetDepth( (USHORT) pOutl->GetAbsPos( pPara ) );
+        std::vector<Paragraph*>::const_iterator iter = aSelList.begin();
+        Paragraph* pPara = *iter;
 
-        if( nDepth != nTmpDepth )
-            bUnique = FALSE;
-        if( bPage != pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
-            bUnique = FALSE;
-        if (!pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
-            bDisableExpand = FALSE;
-        if (pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
-            bDisableCollapse = FALSE;
+        sal_Int16 nDepth;
+        sal_Int16 nTmpDepth = pOutl->GetDepth( (USHORT) pOutl->GetAbsPos( pPara ) );
+        bool bPage = pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE );
 
-        pPara = (Paragraph*)pList->Next();
-    }
+        while (iter != aSelList.begin())
+        {
+            pPara = *iter;
 
-    delete pList;
+            nDepth = pOutl->GetDepth( (USHORT) pOutl->GetAbsPos( pPara ) );
+
+            if( nDepth != nTmpDepth || bPage != pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ))
+                bUnique = FALSE;
+
+            if (pOutl->HasChilds(pPara))
+            {
+                if (!pOutl->IsExpanded(pPara))
+                    bDisableExpand = FALSE;
+                else
+                    bDisableCollapse = FALSE;
+            }
+
+            ++iter;
+        }
+    }
 
     if (bDisableExpand)
         rSet.DisableItem(SID_OUTLINE_EXPAND);
@@ -919,7 +929,7 @@ void OutlineViewShell::GetMenuState( SfxItemSet &rSet )
     if (bDisableCollapseAll || bDisableExpandAll)
     {
         ULONG nParaPos = 0;
-        pPara = pOutl->GetParagraph( nParaPos );
+        Paragraph* pPara = pOutl->GetParagraph( nParaPos );
         while (pPara && (bDisableCollapseAll || bDisableExpandAll))
         {
             if (!pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
@@ -1393,9 +1403,18 @@ void OutlineViewShell::GetStatusBarState(SfxItemSet& rSet)
     ::sd::Window*		pWin		= GetActiveWindow();
     OutlinerView*	pActiveView = pOlView->GetViewByWindow( pWin );
     ::Outliner*     pOutliner   = pOlView->GetOutliner();
-    List*			pSelList	= (List*)pActiveView->CreateSelectionList();
-    Paragraph*		pFirstPara	= (Paragraph*)pSelList->First();
-    Paragraph*		pLastPara	= (Paragraph*)pSelList->Last();
+
+    std::vector<Paragraph*> aSelList;
+    pActiveView->CreateSelectionList(aSelList);
+
+    Paragraph *pFirstPara = NULL;
+    Paragraph *pLastPara = NULL;
+
+    if (!aSelList.empty())
+    {
+        pFirstPara = *(aSelList.begin());
+        pLastPara = *(aSelList.rbegin());
+    }
 
     if( !pOutliner->HasParaFlag(pFirstPara,PARAFLAG_ISPAGE) )
         pFirstPara = pOlView->GetPrevTitle( pFirstPara );
@@ -1403,8 +1422,6 @@ void OutlineViewShell::GetStatusBarState(SfxItemSet& rSet)
     if( !pOutliner->HasParaFlag(pLastPara, PARAFLAG_ISPAGE) )
         pLastPara = pOlView->GetPrevTitle( pLastPara );
 
-    delete pSelList;				// has been created only for us
-
     // only one page selected?
     if( pFirstPara == pLastPara )
     {
@@ -1759,12 +1776,6 @@ SdPage* OutlineViewShell::GetActualPage()
 
 String OutlineViewShell::GetPageRangeString()
 {
-    ::sd::Window*	   pWin 			= GetActiveWindow();
-    OutlinerView*  pActiveView		= pOlView->GetViewByWindow(pWin);
-    ::Outliner*      pOutl            = pActiveView->GetOutliner();
-    List*		   pSelList 		= (List*)pActiveView->CreateSelectionList();
-    Paragraph*	   pPara			= (Paragraph*)pSelList->First();
-
     String aStrPageRange;
     BOOL bFirstPageNo = TRUE;
     BOOL bOpenRange = FALSE;
@@ -1776,8 +1787,18 @@ String OutlineViewShell::GetPageRangeString()
         if( ( (SdPage*)GetDoc()->GetPage( n ) )->GetPageKind() == PK_STANDARD )
             nPageCount++;
 
-    while ( pPara )
+    ::sd::Window *pWin = GetActiveWindow();
+    OutlinerView *pActiveView = pOlView->GetViewByWindow(pWin);
+    ::Outliner *pOutl = pActiveView->GetOutliner();
+
+    std::vector<Paragraph*> aSelList;
+    pActiveView->CreateSelectionList(aSelList);
+    Paragraph *pPara = NULL;
+
+    for (std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); iter != aSelList.end(); ++iter)
     {
+        pPara = *iter;
+
         if ( !pOutl->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
         {
             pPara = pOlView->GetPrevTitle(pPara);
@@ -1827,7 +1848,6 @@ String OutlineViewShell::GetPageRangeString()
         }
 
         nLastPage = nPageToSelect;
-        pPara = (Paragraph*)pSelList->Next();
     }
 
     if( bOpenRange )
@@ -1843,8 +1863,6 @@ String OutlineViewShell::GetPageRangeString()
     if( nPageCount == 0 )
         aStrPageRange.Erase();
 
-    delete pSelList;				// has been created only for us
-
     return aStrPageRange;
 }
 
diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx
index 1dbd13c..43d58e0 100644
--- a/sd/source/ui/view/outlview.cxx
+++ b/sd/source/ui/view/outlview.cxx
@@ -113,8 +113,6 @@ OutlineView::OutlineView( DrawDocShell* pDocSh, ::Window* pWindow, OutlineViewSh
 : ::sd::View(pDocSh->GetDoc(), pWindow, pOutlineViewSh)
 , mpOutlineViewShell(pOutlineViewSh)
 , mpOutliner( mpDoc->GetOutliner(TRUE) )
-, mpOldParaOrder(NULL)
-, mpSelectedParas(NULL)
 , mnPagesToProcess(0)
 , mnPagesProcessed(0)
 , mbFirstPaint(TRUE)
@@ -669,14 +667,18 @@ IMPL_LINK( OutlineView, DepthChangedHdl, ::Outliner *, pOutliner )
         {
             Window* 	  pActWin = mpOutlineViewShell->GetActiveWindow();
             OutlinerView* pOlView = GetViewByWindow(pActWin);
-            List*		  pList   = pOlView->CreateSelectionList();
 
-            Paragraph*	  pParagraph   = (Paragraph*)pList->First();
-            while (pParagraph)
+            std::vector<Paragraph*> aSelList;
+            pOlView->CreateSelectionList(aSelList);
+
+            Paragraph *pParagraph = NULL;
+            for (std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); iter != aSelList.end(); ++iter)
             {
-                if( !pOutliner->HasParaFlag( pParagraph, PARAFLAG_ISPAGE ) && (pOutliner->GetDepth( (USHORT) pOutliner->GetAbsPos( pParagraph ) ) <= 0) )
+                pParagraph = *iter;
+
+                if( !pOutliner->HasParaFlag( pParagraph, PARAFLAG_ISPAGE ) && 
+                    (pOutliner->GetDepth( (USHORT) pOutliner->GetAbsPos( pParagraph ) ) <= 0) )
                     mnPagesToProcess++;
-                pParagraph = (Paragraph*)pList->Next();
             }
 
             mnPagesToProcess++;	// the paragraph being in level 0 already
@@ -695,7 +697,6 @@ IMPL_LINK( OutlineView, DepthChangedHdl, ::Outliner *, pOutliner )
             {
                 mpDocSh->SetWaitCursor( TRUE );
             }
-            delete pList;
         }
 
         ParagraphInsertedHdl(pOutliner);
@@ -923,41 +924,35 @@ IMPL_LINK( OutlineView, BeginMovingHdl, ::Outliner *, pOutliner )
 
     OutlineViewPageChangesGuard aGuard(this);
 
-    mpOldParaOrder = new List;
-
     // list of selected title paragraphs
-    mpSelectedParas = mpOutlinerView[0]->CreateSelectionList();
-    Paragraph* pPara = static_cast<Paragraph*>(mpSelectedParas->First());
-    while (pPara)
+    mpOutlinerView[0]->CreateSelectionList(maSelectedParas);
+
+    for (std::vector<Paragraph*>::iterator it = maSelectedParas.begin(); it != maSelectedParas.end();)
     {
-        if( !pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
-        {
-            mpSelectedParas->Remove();
-            pPara = static_cast<Paragraph*>(mpSelectedParas->GetCurObject());
-        }
+        if (!pOutliner->HasParaFlag(*it, PARAFLAG_ISPAGE))
+            it = maSelectedParas.erase(it);
         else
-        {
-            pPara = static_cast<Paragraph*>(mpSelectedParas->Next());
-        }
+            ++it;
     }
 
     // select the pages belonging to the paragraphs on level 0 to select
     USHORT nPos = 0;
     ULONG nParaPos = 0;
-    pPara = pOutliner->GetParagraph( 0 );
+    Paragraph* pPara = pOutliner->GetParagraph( 0 );
+    std::vector<Paragraph*>::const_iterator fiter;
 
     while(pPara)
     {
         if( pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )                     // one page?
         {
-            mpOldParaOrder->Insert(pPara, LIST_APPEND);
+            maOldParaOrder.push_back(pPara);
             SdPage* pPage = mpDoc->GetSdPage(nPos, PK_STANDARD);
-            pPage->SetSelected(FALSE);
-            if (mpSelectedParas->Seek(pPara))            // selected?
-            {
-                pPage->SetSelected(TRUE);
-            }
-            nPos++;
+
+            fiter = std::find(maSelectedParas.begin(),maSelectedParas.end(),pPara);
+
+            pPage->SetSelected(fiter != maSelectedParas.end());
+
+            ++nPos;
         }
         pPara = pOutliner->GetParagraph( ++nParaPos );
     }
@@ -975,12 +970,10 @@ IMPL_LINK( OutlineView, EndMovingHdl, ::Outliner *, pOutliner )
 {
     OutlineViewPageChangesGuard aGuard(this);
 
-    DBG_ASSERT(mpSelectedParas, "keine Absatzliste");
-    DBG_ASSERT(mpOldParaOrder, "keine Absatzliste");
     DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::EndMovingHdl(), model change without undo?!" );
 
     // look for insertion position via the first paragraph
-    Paragraph* pSearchIt = (Paragraph*)mpSelectedParas->First();
+    Paragraph* pSearchIt = maSelectedParas.empty() ? NULL : *(maSelectedParas.begin());
 
     // look for the first of the selected paragraphs in the new ordering
     USHORT nPosNewOrder = 0;
@@ -1005,14 +998,22 @@ IMPL_LINK( OutlineView, EndMovingHdl, ::Outliner *, pOutliner )
     else
     {
         // look for the predecessor in the old ordering
-        nPos = (USHORT)mpOldParaOrder->GetPos(pPrev);
+        std::vector<Paragraph*>::const_iterator it = std::find(maOldParaOrder.begin(),
+                                                               maOldParaOrder.end(),
+                                                               pPrev);
+
+        if (it != maOldParaOrder.end())
+            nPos = static_cast<USHORT>(it-maOldParaOrder.begin());
+        else
+            nPos = 0xffff;
+
         DBG_ASSERT(nPos != 0xffff, "Absatz nicht gefunden");
     }
 
     mpDoc->MovePages(nPos);
 
     // deselect the pages again
-    USHORT nPageCount = (USHORT)mpSelectedParas->Count();
+    USHORT nPageCount = (USHORT)maSelectedParas.size();
     while (nPageCount)
     {
         SdPage* pPage = mpDoc->GetSdPage(nPosNewOrder, PK_STANDARD);
@@ -1023,10 +1024,8 @@ IMPL_LINK( OutlineView, EndMovingHdl, ::Outliner *, pOutliner )
 
     pOutliner->UpdateFields();
 
-    delete mpSelectedParas;
-    mpSelectedParas = NULL;
-    delete mpOldParaOrder;
-    mpOldParaOrder = NULL;
+    maSelectedParas.clear();
+    maOldParaOrder.clear();
 
     InvalidateSlideNumberArea();
 
@@ -1350,17 +1349,22 @@ SdPage* OutlineView::GetActualPage()
 {
     ::sd::Window* pWin = mpOutlineViewShell->GetActiveWindow();
     OutlinerView* pActiveView = GetViewByWindow(pWin);
-    std::auto_ptr<List> pSelList( static_cast< List* >(pActiveView->CreateSelectionList()) );
 
-    SdPage* pCurrent = GetPageForParagraph(static_cast<Paragraph*>(pSelList->First()) );
+    std::vector<Paragraph*> aSelList;
+    pActiveView->CreateSelectionList(aSelList);
+
+    Paragraph *pPar = aSelList.empty() ? NULL : *(aSelList.begin());
+    SdPage* pCurrent = GetPageForParagraph(pPar);
+
     DBG_ASSERT( pCurrent ||
                 (mpDocSh->GetUndoManager() && static_cast< sd::UndoManager *>(mpDocSh->GetUndoManager())->isInUndo()) ||
                 maDragAndDropModelGuard.get(),
                 "sd::OutlineView::GetActualPage(), no current page?" );
+
     if( pCurrent )
         return pCurrent;
-    else
-        return mpDoc->GetSdPage( 0, PK_STANDARD );
+    
+    return mpDoc->GetSdPage( 0, PK_STANDARD );
 }
 
 SdPage* OutlineView::GetPageForParagraph( Paragraph* pPara )
@@ -1378,8 +1382,8 @@ SdPage* OutlineView::GetPageForParagraph( Paragraph* pPara )
 
     if( nPageToSelect < (sal_uInt32)mpDoc->GetSdPageCount( PK_STANDARD ) )
         return static_cast< SdPage* >( mpDoc->GetSdPage( (USHORT)nPageToSelect, PK_STANDARD) );
-    else
-        return 0;
+    
+    return 0;
 }
 
 Paragraph* OutlineView::GetParagraphForPage( ::Outliner* pOutl, SdPage* pPage )
@@ -1447,26 +1451,22 @@ SfxStyleSheet* OutlineView::GetStyleSheet() const
 void OutlineView::SetSelectedPages()
 {
     // list of selected title paragraphs
-    List* pSelParas = mpOutlinerView[0]->CreateSelectionList();
-    Paragraph* pPara = (Paragraph*) pSelParas->First();
+    std::vector<Paragraph*> aSelParas;
+    mpOutlinerView[0]->CreateSelectionList(aSelParas);
 
-    while(pPara)
+    for (std::vector<Paragraph*>::iterator it = aSelParas.begin(); it != aSelParas.end();)
     {
-        if( !mpOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
-        {
-            pSelParas->Remove();
-            pPara = (Paragraph*) pSelParas->GetCurObject();
-        }
+        if (!mpOutliner->HasParaFlag(*it, PARAFLAG_ISPAGE))
+            it = aSelParas.erase(it);
         else
-        {
-            pPara = (Paragraph*) pSelParas->Next();
-        }
+            ++it;
     }
 
     // select the pages belonging to the paragraphs on level 0 to select
     USHORT nPos = 0;
     ULONG nParaPos = 0;
-    pPara = mpOutliner->GetParagraph( 0 );
+    Paragraph *pPara = mpOutliner->GetParagraph( 0 );
+    std::vector<Paragraph*>::const_iterator fiter;
 
     while(pPara)
     {
@@ -1475,12 +1475,11 @@ void OutlineView::SetSelectedPages()
             SdPage* pPage = mpDoc->GetSdPage(nPos, PK_STANDARD);
             DBG_ASSERT(pPage!=NULL,
                 "Trying to select non-existing page OutlineView::SetSelectedPages()");
-            if (pPage != NULL)
-            {
-                pPage->SetSelected(FALSE);
 
-                if (pSelParas->Seek(pPara))            // selected?
-                    pPage->SetSelected(TRUE);
+            if (pPage)
+            {
+                fiter = std::find(aSelParas.begin(),aSelParas.end(),pPara);
+                pPage->SetSelected(fiter != aSelParas.end());
             }
 
             nPos++;


More information about the Libreoffice-commits mailing list