1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OutlinerIterator.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "OutlinerIterator.hxx"
35 #include "OutlinerIteratorImpl.hxx"
36 #include <svx/svditer.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include "Outliner.hxx"
41 #include "drawdoc.hxx"
42 #include "DrawViewShell.hxx"
43 #include "drawview.hxx"
46 #include "FrameView.hxx"
48 #include "DrawDocShell.hxx"
51 namespace sd
{ namespace outliner
{
54 //===== IteratorPosition ======================================================
56 IteratorPosition::IteratorPosition (void)
59 , mePageKind(PK_STANDARD
)
64 IteratorPosition::IteratorPosition (const IteratorPosition
& aPosition
)
65 : mxObject(aPosition
.mxObject
)
66 , mnText(aPosition
.mnText
)
67 , mnPageIndex(aPosition
.mnPageIndex
)
68 , mePageKind(aPosition
.mePageKind
)
69 , meEditMode(aPosition
.meEditMode
)
73 IteratorPosition::IteratorPosition (SdrObject
* pObject
, sal_Int32 nText
, sal_Int32 nPageIndex
, PageKind ePageKind
, EditMode eEditMode
)
76 , mnPageIndex(nPageIndex
)
77 , mePageKind(ePageKind
)
78 , meEditMode(eEditMode
)
82 IteratorPosition::~IteratorPosition (void)
86 IteratorPosition
& IteratorPosition::operator= (const IteratorPosition
& aPosition
)
88 mxObject
= aPosition
.mxObject
;
89 mnText
= aPosition
.mnText
;
90 mnPageIndex
= aPosition
.mnPageIndex
;
91 mePageKind
= aPosition
.mePageKind
;
92 meEditMode
= aPosition
.meEditMode
;
96 bool IteratorPosition::operator== (const IteratorPosition
& aPosition
) const
98 return mxObject
.get() == aPosition
.mxObject
.get()
99 && mnText
== aPosition
.mnText
100 && mnPageIndex
== aPosition
.mnPageIndex
101 && mePageKind
== aPosition
.mePageKind
102 && meEditMode
== aPosition
.meEditMode
;
108 //===== Iterator ==============================================================
110 Iterator::Iterator (void)
115 Iterator::Iterator (const Iterator
& rIterator
)
117 mpIterator
= rIterator
.mpIterator
->Clone();
120 Iterator::Iterator (IteratorImplBase
* pObject
)
122 mpIterator
= pObject
;
125 Iterator::Iterator (const IteratorImplBase
& rObject
)
127 mpIterator
= rObject
.Clone();
130 Iterator::~Iterator (void)
135 Iterator
& Iterator::operator= (const Iterator
& rIterator
)
137 if (this != &rIterator
)
140 if (rIterator
.mpIterator
!= NULL
)
141 mpIterator
= rIterator
.mpIterator
->Clone();
148 const IteratorPosition
& Iterator::operator* () const
150 DBG_ASSERT (mpIterator
!=NULL
, "::sd::outliner::Iterator::operator* : missing implementation object");
151 return mpIterator
->GetPosition();
154 Iterator
& Iterator::operator++ ()
156 if (mpIterator
!=NULL
)
157 mpIterator
->GotoNextText();
161 Iterator
Iterator::operator++ (int)
163 Iterator
aTmp (*this);
164 if (mpIterator
!=NULL
)
165 mpIterator
->GotoNextText();
169 bool Iterator::operator== (const Iterator
& rIterator
)
171 if (mpIterator
== NULL
|| rIterator
.mpIterator
==NULL
)
172 return mpIterator
== rIterator
.mpIterator
;
174 return *mpIterator
== *rIterator
.mpIterator
;
177 bool Iterator::operator!= (const Iterator
& rIterator
)
179 return ! operator==(rIterator
);
182 void Iterator::Reverse (void)
184 if (mpIterator
!= NULL
)
185 mpIterator
->Reverse();
188 //===== IteratorFactory =======================================================
190 OutlinerContainer::OutlinerContainer (Outliner
* pOutliner
)
191 : mpOutliner(pOutliner
)
195 Iterator
OutlinerContainer::begin (void)
197 return CreateIterator (BEGIN
);
200 Iterator
OutlinerContainer::end (void)
202 return CreateIterator (END
);
205 Iterator
OutlinerContainer::current (void)
207 return CreateIterator (CURRENT
);
211 Iterator
OutlinerContainer::CreateIterator (IteratorLocation aLocation
)
213 // Decide on certain features of the outliner which kind of iterator to
215 if (mpOutliner
->mbRestrictSearchToSelection
)
216 // There is a selection. Search only in this.
217 return CreateSelectionIterator (
218 mpOutliner
->maMarkListCopy
,
219 mpOutliner
->mpDrawDocument
,
220 mpOutliner
->mpViewShell
,
221 mpOutliner
->mbDirectionIsForward
,
224 // Search in the whole document.
225 return CreateDocumentIterator (
226 mpOutliner
->mpDrawDocument
,
227 mpOutliner
->mpViewShell
,
228 mpOutliner
->mbDirectionIsForward
,
232 Iterator
OutlinerContainer::CreateSelectionIterator (
233 const ::std::vector
<SdrObjectWeakRef
>& rObjectList
,
234 SdDrawDocument
* pDocument
,
235 const ::boost::shared_ptr
<ViewShell
>& rpViewShell
,
236 bool bDirectionIsForward
,
237 IteratorLocation aLocation
)
239 OSL_ASSERT(rpViewShell
.get());
241 sal_Int32 nObjectIndex
;
243 if (bDirectionIsForward
)
252 nObjectIndex
= rObjectList
.size();
261 nObjectIndex
= rObjectList
.size()-1;
268 return Iterator (new SelectionIteratorImpl (
269 rObjectList
, nObjectIndex
, pDocument
, rpViewShell
, bDirectionIsForward
));
272 Iterator
OutlinerContainer::CreateViewIterator (
273 SdDrawDocument
* pDocument
,
274 const ::boost::shared_ptr
<ViewShell
>& rpViewShell
,
275 bool bDirectionIsForward
,
276 IteratorLocation aLocation
)
278 OSL_ASSERT(rpViewShell
.get());
280 const ::boost::shared_ptr
<DrawViewShell
> pDrawViewShell(
281 ::boost::dynamic_pointer_cast
<DrawViewShell
>(rpViewShell
));
282 sal_Int32 nPageIndex
= GetPageIndex (
285 pDrawViewShell
.get() ? pDrawViewShell
->GetPageKind() : PK_STANDARD
,
286 pDrawViewShell
.get() ? pDrawViewShell
->GetEditMode() : EM_PAGE
,
290 return Iterator (new ViewIteratorImpl (
291 nPageIndex
, pDocument
, rpViewShell
, bDirectionIsForward
));
294 Iterator
OutlinerContainer::CreateDocumentIterator (
295 SdDrawDocument
* pDocument
,
296 const ::boost::shared_ptr
<ViewShell
>& rpViewShell
,
297 bool bDirectionIsForward
,
298 IteratorLocation aLocation
)
300 OSL_ASSERT(rpViewShell
.get());
309 if (bDirectionIsForward
)
311 ePageKind
= PK_STANDARD
;
316 ePageKind
= PK_HANDOUT
;
317 eEditMode
= EM_MASTERPAGE
;
322 if (bDirectionIsForward
)
324 ePageKind
= PK_HANDOUT
;
325 eEditMode
= EM_MASTERPAGE
;
329 ePageKind
= PK_STANDARD
;
335 const ::boost::shared_ptr
<DrawViewShell
> pDrawViewShell(
336 ::boost::dynamic_pointer_cast
<DrawViewShell
>(rpViewShell
));
337 if (pDrawViewShell
.get())
339 ePageKind
= pDrawViewShell
->GetPageKind();
340 eEditMode
= pDrawViewShell
->GetEditMode();
344 ePageKind
= PK_STANDARD
;
350 sal_Int32 nPageIndex
= GetPageIndex (pDocument
, rpViewShell
,
351 ePageKind
, eEditMode
, bDirectionIsForward
, aLocation
);
354 new DocumentIteratorImpl (nPageIndex
, ePageKind
, eEditMode
,
355 pDocument
, rpViewShell
, bDirectionIsForward
));
358 sal_Int32
OutlinerContainer::GetPageIndex (
359 SdDrawDocument
* pDocument
,
360 const ::boost::shared_ptr
<ViewShell
>& rpViewShell
,
363 bool bDirectionIsForward
,
364 IteratorLocation aLocation
)
366 OSL_ASSERT(rpViewShell
);
368 sal_Int32 nPageIndex
;
369 sal_Int32 nPageCount
;
371 const ::boost::shared_ptr
<DrawViewShell
> pDrawViewShell(
372 ::boost::dynamic_pointer_cast
<DrawViewShell
>(rpViewShell
));
377 nPageCount
= pDocument
->GetSdPageCount (ePageKind
);
380 nPageCount
= pDocument
->GetMasterSdPageCount(ePageKind
);
389 if (pDrawViewShell
.get())
390 nPageIndex
= pDrawViewShell
->GetCurPageId() - 1;
393 const SdPage
* pPage
= rpViewShell
->GetActualPage();
395 nPageIndex
= (pPage
->GetPageNum()-1)/2;
403 if (bDirectionIsForward
)
406 nPageIndex
= nPageCount
-1;
410 if (bDirectionIsForward
)
411 nPageIndex
= nPageCount
;
423 //===== IteratorImplBase ====================================================
425 IteratorImplBase::IteratorImplBase(SdDrawDocument
* pDocument
,
426 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
427 bool bDirectionIsForward
)
429 , mpDocument (pDocument
)
430 , mpViewShellWeak (rpViewShellWeak
)
431 , mbDirectionIsForward (bDirectionIsForward
)
433 ::boost::shared_ptr
<DrawViewShell
> pDrawViewShell
;
434 if ( ! mpViewShellWeak
.expired())
435 pDrawViewShell
= ::boost::dynamic_pointer_cast
<DrawViewShell
>(rpViewShellWeak
.lock());
437 if (pDrawViewShell
.get())
439 maPosition
.mePageKind
= pDrawViewShell
->GetPageKind();
440 maPosition
.meEditMode
= pDrawViewShell
->GetEditMode();
444 maPosition
.mePageKind
= PK_STANDARD
;
445 maPosition
.meEditMode
= EM_PAGE
;
449 IteratorImplBase::IteratorImplBase( SdDrawDocument
* pDocument
,
450 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
451 bool bDirectionIsForward
, PageKind ePageKind
, EditMode eEditMode
)
453 , mpDocument (pDocument
)
454 , mpViewShellWeak (rpViewShellWeak
)
455 , mbDirectionIsForward (bDirectionIsForward
)
457 maPosition
.mePageKind
= ePageKind
;
458 maPosition
.meEditMode
= eEditMode
;
461 IteratorImplBase::~IteratorImplBase (void)
464 bool IteratorImplBase::operator== (const IteratorImplBase
& rIterator
) const
466 return maPosition
== rIterator
.maPosition
;
469 bool IteratorImplBase::IsEqual (const IteratorImplBase
& rIterator
, IteratorType
) const
471 // When this method is executed instead of the ones from derived classes
472 // then the argument is of another type then the object itself. In this
473 // just compare the position objects.
474 return maPosition
== rIterator
.maPosition
;
477 const IteratorPosition
& IteratorImplBase::GetPosition (void)
485 IteratorImplBase
* IteratorImplBase::Clone (IteratorImplBase
* pObject
) const
489 pObject
->maPosition
= maPosition
;
490 pObject
->mpDocument
= mpDocument
;
491 pObject
->mpViewShellWeak
= mpViewShellWeak
;
492 pObject
->mbDirectionIsForward
= mbDirectionIsForward
;
499 void IteratorImplBase::Reverse (void)
501 mbDirectionIsForward
= ! mbDirectionIsForward
;
506 //===== SelectionIteratorImpl ===========================================
508 SelectionIteratorImpl::SelectionIteratorImpl (
509 const ::std::vector
<SdrObjectWeakRef
>& rObjectList
,
510 sal_Int32 nObjectIndex
,
511 SdDrawDocument
* pDocument
,
512 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
513 bool bDirectionIsForward
)
514 : IteratorImplBase (pDocument
, rpViewShellWeak
, bDirectionIsForward
),
515 mrObjectList(rObjectList
),
516 mnObjectIndex(nObjectIndex
)
520 SelectionIteratorImpl::~SelectionIteratorImpl (void)
523 IteratorImplBase
* SelectionIteratorImpl::Clone (IteratorImplBase
* pObject
) const
525 SelectionIteratorImpl
* pIterator
= static_cast<SelectionIteratorImpl
*>(pObject
);
526 if (pIterator
== NULL
)
527 pIterator
= new SelectionIteratorImpl (
528 mrObjectList
, mnObjectIndex
, mpDocument
, mpViewShellWeak
, mbDirectionIsForward
);
533 void SelectionIteratorImpl::GotoNextText (void)
535 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( mrObjectList
.at(mnObjectIndex
).get() );
536 if (mbDirectionIsForward
)
541 if( maPosition
.mnText
>= pTextObj
->getTextCount() )
543 maPosition
.mnText
= 0;
557 if( maPosition
.mnText
< 0 )
559 maPosition
.mnText
= -1;
566 maPosition
.mnText
= -1;
569 if( (maPosition
.mnText
== -1) && (mnObjectIndex
>= 0) )
571 pTextObj
= dynamic_cast< SdrTextObj
* >( mrObjectList
.at(mnObjectIndex
).get() );
573 maPosition
.mnText
= pTextObj
->getTextCount() - 1;
576 if( maPosition
.mnText
== -1 )
577 maPosition
.mnText
= 0;
582 const IteratorPosition
& SelectionIteratorImpl::GetPosition (void)
584 maPosition
.mxObject
= mrObjectList
.at(mnObjectIndex
);
590 bool SelectionIteratorImpl::operator== (const IteratorImplBase
& rIterator
) const
592 return rIterator
.IsEqual (*this, SELECTION
);
596 bool SelectionIteratorImpl::IsEqual (
597 const IteratorImplBase
& rIterator
,
598 IteratorType aType
) const
600 if (aType
== SELECTION
)
602 const SelectionIteratorImpl
* pSelectionIterator
=
603 static_cast<const SelectionIteratorImpl
*>(&rIterator
);
604 return mpDocument
== pSelectionIterator
->mpDocument
605 && mnObjectIndex
== pSelectionIterator
->mnObjectIndex
;
614 //===== ViewIteratorImpl ================================================
616 ViewIteratorImpl::ViewIteratorImpl (
617 sal_Int32 nPageIndex
,
618 SdDrawDocument
* pDocument
,
619 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
620 bool bDirectionIsForward
)
621 : IteratorImplBase (pDocument
, rpViewShellWeak
, bDirectionIsForward
),
622 mbPageChangeOccured(false),
624 mpObjectIterator(NULL
)
626 SetPage (nPageIndex
);
632 ViewIteratorImpl::ViewIteratorImpl (
633 sal_Int32 nPageIndex
,
634 SdDrawDocument
* pDocument
,
635 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
636 bool bDirectionIsForward
,
639 : IteratorImplBase (pDocument
, rpViewShellWeak
, bDirectionIsForward
, ePageKind
, eEditMode
),
640 mbPageChangeOccured(false),
642 mpObjectIterator(NULL
)
644 SetPage (nPageIndex
);
650 ViewIteratorImpl::~ViewIteratorImpl (void)
657 IteratorImplBase
* ViewIteratorImpl::Clone (IteratorImplBase
* pObject
) const
660 ViewIteratorImpl
* pIterator
= static_cast<ViewIteratorImpl
*>(pObject
);
661 if (pIterator
== NULL
)
662 pIterator
= new ViewIteratorImpl (
663 maPosition
.mnPageIndex
, mpDocument
, mpViewShellWeak
, mbDirectionIsForward
);
665 IteratorImplBase::Clone (pObject
);
667 if (mpObjectIterator
!= NULL
)
669 pIterator
->mpObjectIterator
= new SdrObjListIter(*mpPage
, IM_DEEPNOGROUPS
, !mbDirectionIsForward
);
671 // No direct way to set the object iterator to the current object.
672 pIterator
->maPosition
.mxObject
.reset(NULL
);
673 while (pIterator
->mpObjectIterator
->IsMore() && pIterator
->maPosition
.mxObject
!=maPosition
.mxObject
)
674 pIterator
->maPosition
.mxObject
.reset(pIterator
->mpObjectIterator
->Next());
677 pIterator
->mpObjectIterator
= NULL
;
684 void ViewIteratorImpl::GotoNextText(void)
686 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( maPosition
.mxObject
.get() );
689 if (mbDirectionIsForward
)
692 if( maPosition
.mnText
< pTextObj
->getTextCount() )
698 if( maPosition
.mnText
>= 0 )
703 if (mpObjectIterator
!= NULL
&& mpObjectIterator
->IsMore())
704 maPosition
.mxObject
.reset(mpObjectIterator
->Next());
706 maPosition
.mxObject
.reset(NULL
);
708 if (!maPosition
.mxObject
.is() )
710 if (mbDirectionIsForward
)
711 SetPage (maPosition
.mnPageIndex
+1);
713 SetPage (maPosition
.mnPageIndex
-1);
716 mpObjectIterator
= new SdrObjListIter(*mpPage
, IM_DEEPNOGROUPS
, !mbDirectionIsForward
);
717 if (mpObjectIterator
!=NULL
&& mpObjectIterator
->IsMore())
718 maPosition
.mxObject
.reset(mpObjectIterator
->Next());
720 maPosition
.mxObject
.reset(NULL
);
723 maPosition
.mnText
= 0;
724 if( !mbDirectionIsForward
&& maPosition
.mxObject
.is() )
726 pTextObj
= dynamic_cast< SdrTextObj
* >( maPosition
.mxObject
.get() );
728 maPosition
.mnText
= pTextObj
->getTextCount() - 1;
735 void ViewIteratorImpl::SetPage (sal_Int32 nPageIndex
)
737 mbPageChangeOccured
= (maPosition
.mnPageIndex
!=nPageIndex
);
738 if (mbPageChangeOccured
)
740 maPosition
.mnPageIndex
= nPageIndex
;
742 sal_Int32 nPageCount
;
743 if (maPosition
.meEditMode
== EM_PAGE
)
744 nPageCount
= mpDocument
->GetSdPageCount(maPosition
.mePageKind
);
746 nPageCount
= mpDocument
->GetMasterSdPageCount(
747 maPosition
.mePageKind
);
749 // Get page pointer. Here we have three cases: regular pages,
750 // master pages and invalid page indices. The later ones are not
751 // errors but the effect of the iterator advancing to the next page
752 // and going past the last one. This dropping of the rim at the far
753 // side is detected here and has to be reacted to by the caller.
754 if (nPageIndex
>=0 && nPageIndex
< nPageCount
)
756 if (maPosition
.meEditMode
== EM_PAGE
)
757 mpPage
= mpDocument
->GetSdPage (
759 maPosition
.mePageKind
);
761 mpPage
= mpDocument
->GetMasterSdPage (
763 maPosition
.mePageKind
);
769 // Set up object list iterator.
771 mpObjectIterator
= new SdrObjListIter(*mpPage
, IM_DEEPNOGROUPS
, ! mbDirectionIsForward
);
773 mpObjectIterator
= NULL
;
775 // Get object pointer.
776 if (mpObjectIterator
!=NULL
&& mpObjectIterator
->IsMore())
777 maPosition
.mxObject
.reset( mpObjectIterator
->Next() );
779 maPosition
.mxObject
.reset( NULL
);
781 maPosition
.mnText
= 0;
782 if( !mbDirectionIsForward
&& maPosition
.mxObject
.is() )
784 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( maPosition
.mxObject
.get() );
786 maPosition
.mnText
= pTextObj
->getTextCount() - 1;
794 void ViewIteratorImpl::Reverse (void)
796 IteratorImplBase::Reverse ();
798 // Create reversed object list iterator.
799 if (mpObjectIterator
!= NULL
)
800 delete mpObjectIterator
;
802 mpObjectIterator
= new SdrObjListIter(*mpPage
, IM_DEEPNOGROUPS
, ! mbDirectionIsForward
);
804 mpObjectIterator
= NULL
;
806 // Move iterator to the current object.
807 SdrObjectWeakRef xObject
= maPosition
.mxObject
;
808 maPosition
.mxObject
.reset(NULL
);
809 while (mpObjectIterator
->IsMore() && maPosition
.mxObject
!= xObject
)
810 maPosition
.mxObject
.reset(mpObjectIterator
->Next());
816 //===== DocumentIteratorImpl ============================================
818 DocumentIteratorImpl::DocumentIteratorImpl (
819 sal_Int32 nPageIndex
,
820 PageKind ePageKind
, EditMode eEditMode
,
821 SdDrawDocument
* pDocument
,
822 const ::boost::weak_ptr
<ViewShell
>& rpViewShellWeak
,
823 bool bDirectionIsForward
)
824 : ViewIteratorImpl (nPageIndex
, pDocument
, rpViewShellWeak
, bDirectionIsForward
,
825 ePageKind
, eEditMode
)
827 if (eEditMode
== EM_PAGE
)
828 mnPageCount
= pDocument
->GetSdPageCount (ePageKind
);
830 mnPageCount
= pDocument
->GetMasterSdPageCount(ePageKind
);
836 DocumentIteratorImpl::~DocumentIteratorImpl (void)
842 IteratorImplBase
* DocumentIteratorImpl::Clone (IteratorImplBase
* pObject
) const
844 DocumentIteratorImpl
* pIterator
= static_cast<DocumentIteratorImpl
*>(pObject
);
845 if (pIterator
== NULL
)
846 pIterator
= new DocumentIteratorImpl (
847 maPosition
.mnPageIndex
, maPosition
.mePageKind
, maPosition
.meEditMode
,
848 mpDocument
, mpViewShellWeak
, mbDirectionIsForward
);
849 // Finish the cloning.
850 return ViewIteratorImpl::Clone (pIterator
);
856 void DocumentIteratorImpl::GotoNextText (void)
858 bool bSetToOnePastLastPage
= false;
859 bool bViewChanged
= false;
861 ViewIteratorImpl::GotoNextText();
863 if (mbDirectionIsForward
)
865 if (maPosition
.mnPageIndex
>= mnPageCount
)
867 // Switch to master page.
868 if (maPosition
.meEditMode
== EM_PAGE
)
870 maPosition
.meEditMode
= EM_MASTERPAGE
;
874 // Switch to next view mode.
877 if (maPosition
.mePageKind
== PK_HANDOUT
)
878 // Not really necessary but makes things more clear.
879 bSetToOnePastLastPage
= true;
882 maPosition
.meEditMode
= EM_PAGE
;
883 if (maPosition
.mePageKind
== PK_STANDARD
)
884 maPosition
.mePageKind
= PK_NOTES
;
885 else if (maPosition
.mePageKind
== PK_NOTES
)
886 maPosition
.mePageKind
= PK_HANDOUT
;
894 if (maPosition
.mnPageIndex
< 0)
896 // Switch from master pages to draw pages.
897 if (maPosition
.meEditMode
== EM_MASTERPAGE
)
899 maPosition
.meEditMode
= EM_PAGE
;
900 bSetToOnePastLastPage
= true;
903 // Switch to previous view mode.
906 if (maPosition
.mePageKind
== PK_STANDARD
)
910 maPosition
.meEditMode
= EM_MASTERPAGE
;
911 if (maPosition
.mePageKind
== PK_HANDOUT
)
912 maPosition
.mePageKind
= PK_NOTES
;
913 else if (maPosition
.mePageKind
== PK_NOTES
)
914 maPosition
.mePageKind
= PK_STANDARD
;
915 bSetToOnePastLastPage
= true;
923 // Get new page count;
924 sal_Int32 nPageCount
;
925 if (maPosition
.meEditMode
== EM_PAGE
)
926 nPageCount
= mpDocument
->GetSdPageCount (maPosition
.mePageKind
);
928 nPageCount
= mpDocument
->GetMasterSdPageCount(maPosition
.mePageKind
);
930 // Now that we know the number of pages we can set the current page index.
931 if (bSetToOnePastLastPage
)
932 SetPage (nPageCount
);
937 } } // end of namespace ::sd::outliner