1cdf0e10cSrcweir /************************************************************************* 2cdf0e10cSrcweir * 3cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4cdf0e10cSrcweir * 5cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6cdf0e10cSrcweir * 7cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8cdf0e10cSrcweir * 9cdf0e10cSrcweir * This file is part of OpenOffice.org. 10cdf0e10cSrcweir * 11cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14cdf0e10cSrcweir * 15cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20cdf0e10cSrcweir * 21cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25cdf0e10cSrcweir * 26cdf0e10cSrcweir ************************************************************************/ 27cdf0e10cSrcweir 28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29cdf0e10cSrcweir #include "precompiled_sd.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "OutlinerIterator.hxx" 32cdf0e10cSrcweir #include "OutlinerIteratorImpl.hxx" 33cdf0e10cSrcweir #include <svx/svditer.hxx> 34cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 35cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 36cdf0e10cSrcweir #include "Outliner.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include "drawdoc.hxx" 39cdf0e10cSrcweir #include "DrawViewShell.hxx" 40cdf0e10cSrcweir #include "drawview.hxx" 41cdf0e10cSrcweir #include "sdpage.hxx" 42cdf0e10cSrcweir #ifndef SD_FRAME_VIEW 43cdf0e10cSrcweir #include "FrameView.hxx" 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #include "DrawDocShell.hxx" 46cdf0e10cSrcweir #include "Window.hxx" 47cdf0e10cSrcweir 48cdf0e10cSrcweir namespace sd { namespace outliner { 49cdf0e10cSrcweir 50cdf0e10cSrcweir 51cdf0e10cSrcweir //===== IteratorPosition ====================================================== 52cdf0e10cSrcweir 53cdf0e10cSrcweir IteratorPosition::IteratorPosition (void) 54cdf0e10cSrcweir : mnText(0) 55cdf0e10cSrcweir , mnPageIndex(-1) 56cdf0e10cSrcweir , mePageKind(PK_STANDARD) 57cdf0e10cSrcweir , meEditMode(EM_PAGE) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir IteratorPosition::IteratorPosition (const IteratorPosition& aPosition) 62cdf0e10cSrcweir : mxObject(aPosition.mxObject) 63cdf0e10cSrcweir , mnText(aPosition.mnText) 64cdf0e10cSrcweir , mnPageIndex(aPosition.mnPageIndex) 65cdf0e10cSrcweir , mePageKind(aPosition.mePageKind) 66cdf0e10cSrcweir , meEditMode(aPosition.meEditMode) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir IteratorPosition::~IteratorPosition (void) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir IteratorPosition& IteratorPosition::operator= (const IteratorPosition& aPosition) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir mxObject = aPosition.mxObject; 77cdf0e10cSrcweir mnText = aPosition.mnText; 78cdf0e10cSrcweir mnPageIndex = aPosition.mnPageIndex; 79cdf0e10cSrcweir mePageKind = aPosition.mePageKind; 80cdf0e10cSrcweir meEditMode = aPosition.meEditMode; 81cdf0e10cSrcweir return *this; 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir bool IteratorPosition::operator== (const IteratorPosition& aPosition) const 85cdf0e10cSrcweir { 86cdf0e10cSrcweir return mxObject.get() == aPosition.mxObject.get() 87cdf0e10cSrcweir && mnText == aPosition.mnText 88cdf0e10cSrcweir && mnPageIndex == aPosition.mnPageIndex 89cdf0e10cSrcweir && mePageKind == aPosition.mePageKind 90cdf0e10cSrcweir && meEditMode == aPosition.meEditMode; 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir 94cdf0e10cSrcweir 95cdf0e10cSrcweir 96cdf0e10cSrcweir //===== Iterator ============================================================== 97cdf0e10cSrcweir 98cdf0e10cSrcweir Iterator::Iterator (void) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir mpIterator = NULL; 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir Iterator::Iterator (const Iterator& rIterator) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir mpIterator = rIterator.mpIterator->Clone(); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir Iterator::Iterator (IteratorImplBase* pObject) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir mpIterator = pObject; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir Iterator::~Iterator (void) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir delete mpIterator; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir Iterator& Iterator::operator= (const Iterator& rIterator) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir if (this != &rIterator) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir delete mpIterator; 123cdf0e10cSrcweir if (rIterator.mpIterator != NULL) 124cdf0e10cSrcweir mpIterator = rIterator.mpIterator->Clone(); 125cdf0e10cSrcweir else 126cdf0e10cSrcweir mpIterator = NULL; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir return *this; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir const IteratorPosition& Iterator::operator* () const 132cdf0e10cSrcweir { 133cdf0e10cSrcweir DBG_ASSERT (mpIterator!=NULL, "::sd::outliner::Iterator::operator* : missing implementation object"); 134cdf0e10cSrcweir return mpIterator->GetPosition(); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir Iterator& Iterator::operator++ () 138cdf0e10cSrcweir { 139cdf0e10cSrcweir if (mpIterator!=NULL) 140cdf0e10cSrcweir mpIterator->GotoNextText(); 141cdf0e10cSrcweir return *this; 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir Iterator Iterator::operator++ (int) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir Iterator aTmp (*this); 147cdf0e10cSrcweir if (mpIterator!=NULL) 148cdf0e10cSrcweir mpIterator->GotoNextText(); 149cdf0e10cSrcweir return aTmp; 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir bool Iterator::operator== (const Iterator& rIterator) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir if (mpIterator == NULL || rIterator.mpIterator==NULL) 155cdf0e10cSrcweir return mpIterator == rIterator.mpIterator; 156cdf0e10cSrcweir else 157cdf0e10cSrcweir return *mpIterator == *rIterator.mpIterator; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir bool Iterator::operator!= (const Iterator& rIterator) 161cdf0e10cSrcweir { 162cdf0e10cSrcweir return ! operator==(rIterator); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir void Iterator::Reverse (void) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir if (mpIterator != NULL) 168cdf0e10cSrcweir mpIterator->Reverse(); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir //===== IteratorFactory ======================================================= 172cdf0e10cSrcweir 173cdf0e10cSrcweir OutlinerContainer::OutlinerContainer (Outliner* pOutliner) 174cdf0e10cSrcweir : mpOutliner(pOutliner) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir Iterator OutlinerContainer::begin (void) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir return CreateIterator (BEGIN); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir Iterator OutlinerContainer::end (void) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir return CreateIterator (END); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir Iterator OutlinerContainer::current (void) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir return CreateIterator (CURRENT); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir 194cdf0e10cSrcweir Iterator OutlinerContainer::CreateIterator (IteratorLocation aLocation) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir // Decide on certain features of the outliner which kind of iterator to 197cdf0e10cSrcweir // use. 198cdf0e10cSrcweir if (mpOutliner->mbRestrictSearchToSelection) 199cdf0e10cSrcweir // There is a selection. Search only in this. 200cdf0e10cSrcweir return CreateSelectionIterator ( 201cdf0e10cSrcweir mpOutliner->maMarkListCopy, 202cdf0e10cSrcweir mpOutliner->mpDrawDocument, 203*967189efSMichael Stahl mpOutliner->mpWeakViewShell.lock(), 204cdf0e10cSrcweir mpOutliner->mbDirectionIsForward, 205cdf0e10cSrcweir aLocation); 206cdf0e10cSrcweir else 207cdf0e10cSrcweir // Search in the whole document. 208cdf0e10cSrcweir return CreateDocumentIterator ( 209cdf0e10cSrcweir mpOutliner->mpDrawDocument, 210*967189efSMichael Stahl mpOutliner->mpWeakViewShell.lock(), 211cdf0e10cSrcweir mpOutliner->mbDirectionIsForward, 212cdf0e10cSrcweir aLocation); 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir Iterator OutlinerContainer::CreateSelectionIterator ( 216cdf0e10cSrcweir const ::std::vector<SdrObjectWeakRef>& rObjectList, 217cdf0e10cSrcweir SdDrawDocument* pDocument, 218cdf0e10cSrcweir const ::boost::shared_ptr<ViewShell>& rpViewShell, 219cdf0e10cSrcweir bool bDirectionIsForward, 220cdf0e10cSrcweir IteratorLocation aLocation) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir OSL_ASSERT(rpViewShell.get()); 223cdf0e10cSrcweir 224cdf0e10cSrcweir sal_Int32 nObjectIndex; 225cdf0e10cSrcweir 226cdf0e10cSrcweir if (bDirectionIsForward) 227cdf0e10cSrcweir switch (aLocation) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir case CURRENT: 230cdf0e10cSrcweir case BEGIN: 231cdf0e10cSrcweir default: 232cdf0e10cSrcweir nObjectIndex = 0; 233cdf0e10cSrcweir break; 234cdf0e10cSrcweir case END: 235cdf0e10cSrcweir nObjectIndex = rObjectList.size(); 236cdf0e10cSrcweir break; 237cdf0e10cSrcweir } 238cdf0e10cSrcweir else 239cdf0e10cSrcweir switch (aLocation) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir case CURRENT: 242cdf0e10cSrcweir case BEGIN: 243cdf0e10cSrcweir default: 244cdf0e10cSrcweir nObjectIndex = rObjectList.size()-1; 245cdf0e10cSrcweir break; 246cdf0e10cSrcweir case END: 247cdf0e10cSrcweir nObjectIndex = -1; 248cdf0e10cSrcweir break; 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir return Iterator (new SelectionIteratorImpl ( 252cdf0e10cSrcweir rObjectList, nObjectIndex, pDocument, rpViewShell, bDirectionIsForward)); 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir Iterator OutlinerContainer::CreateDocumentIterator ( 256cdf0e10cSrcweir SdDrawDocument* pDocument, 257cdf0e10cSrcweir const ::boost::shared_ptr<ViewShell>& rpViewShell, 258cdf0e10cSrcweir bool bDirectionIsForward, 259cdf0e10cSrcweir IteratorLocation aLocation) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir OSL_ASSERT(rpViewShell.get()); 262cdf0e10cSrcweir 263cdf0e10cSrcweir PageKind ePageKind; 264cdf0e10cSrcweir EditMode eEditMode; 265cdf0e10cSrcweir 266cdf0e10cSrcweir switch (aLocation) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir case BEGIN: 269cdf0e10cSrcweir default: 270cdf0e10cSrcweir if (bDirectionIsForward) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir ePageKind = PK_STANDARD; 273cdf0e10cSrcweir eEditMode = EM_PAGE; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir else 276cdf0e10cSrcweir { 277cdf0e10cSrcweir ePageKind = PK_HANDOUT; 278cdf0e10cSrcweir eEditMode = EM_MASTERPAGE; 279cdf0e10cSrcweir } 280cdf0e10cSrcweir break; 281cdf0e10cSrcweir 282cdf0e10cSrcweir case END: 283cdf0e10cSrcweir if (bDirectionIsForward) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir ePageKind = PK_HANDOUT; 286cdf0e10cSrcweir eEditMode = EM_MASTERPAGE; 287cdf0e10cSrcweir } 288cdf0e10cSrcweir else 289cdf0e10cSrcweir { 290cdf0e10cSrcweir ePageKind = PK_STANDARD; 291cdf0e10cSrcweir eEditMode = EM_PAGE; 292cdf0e10cSrcweir } 293cdf0e10cSrcweir break; 294cdf0e10cSrcweir 295cdf0e10cSrcweir case CURRENT: 296cdf0e10cSrcweir const ::boost::shared_ptr<DrawViewShell> pDrawViewShell( 297cdf0e10cSrcweir ::boost::dynamic_pointer_cast<DrawViewShell>(rpViewShell)); 298cdf0e10cSrcweir if (pDrawViewShell.get()) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir ePageKind = pDrawViewShell->GetPageKind(); 301cdf0e10cSrcweir eEditMode = pDrawViewShell->GetEditMode(); 302cdf0e10cSrcweir } 303cdf0e10cSrcweir else 304cdf0e10cSrcweir { 305cdf0e10cSrcweir ePageKind = PK_STANDARD; 306cdf0e10cSrcweir eEditMode = EM_PAGE; 307cdf0e10cSrcweir } 308cdf0e10cSrcweir break; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir sal_Int32 nPageIndex = GetPageIndex (pDocument, rpViewShell, 312cdf0e10cSrcweir ePageKind, eEditMode, bDirectionIsForward, aLocation); 313cdf0e10cSrcweir 314cdf0e10cSrcweir return Iterator ( 315cdf0e10cSrcweir new DocumentIteratorImpl (nPageIndex, ePageKind, eEditMode, 316cdf0e10cSrcweir pDocument, rpViewShell, bDirectionIsForward)); 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir sal_Int32 OutlinerContainer::GetPageIndex ( 320cdf0e10cSrcweir SdDrawDocument* pDocument, 321cdf0e10cSrcweir const ::boost::shared_ptr<ViewShell>& rpViewShell, 322cdf0e10cSrcweir PageKind ePageKind, 323cdf0e10cSrcweir EditMode eEditMode, 324cdf0e10cSrcweir bool bDirectionIsForward, 325cdf0e10cSrcweir IteratorLocation aLocation) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir OSL_ASSERT(rpViewShell); 328cdf0e10cSrcweir 329cdf0e10cSrcweir sal_Int32 nPageIndex; 330cdf0e10cSrcweir sal_Int32 nPageCount; 331cdf0e10cSrcweir 332cdf0e10cSrcweir const ::boost::shared_ptr<DrawViewShell> pDrawViewShell( 333cdf0e10cSrcweir ::boost::dynamic_pointer_cast<DrawViewShell>(rpViewShell)); 334cdf0e10cSrcweir 335cdf0e10cSrcweir switch (eEditMode) 336cdf0e10cSrcweir { 337cdf0e10cSrcweir case EM_PAGE: 338cdf0e10cSrcweir nPageCount = pDocument->GetSdPageCount (ePageKind); 339cdf0e10cSrcweir break; 340cdf0e10cSrcweir case EM_MASTERPAGE: 341cdf0e10cSrcweir nPageCount = pDocument->GetMasterSdPageCount(ePageKind); 342cdf0e10cSrcweir break; 343cdf0e10cSrcweir default: 344cdf0e10cSrcweir nPageCount = 0; 345cdf0e10cSrcweir } 346cdf0e10cSrcweir 347cdf0e10cSrcweir switch (aLocation) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir case CURRENT: 350cdf0e10cSrcweir if (pDrawViewShell.get()) 351cdf0e10cSrcweir nPageIndex = pDrawViewShell->GetCurPageId() - 1; 352cdf0e10cSrcweir else 353cdf0e10cSrcweir { 354cdf0e10cSrcweir const SdPage* pPage = rpViewShell->GetActualPage(); 355cdf0e10cSrcweir if (pPage != NULL) 356cdf0e10cSrcweir nPageIndex = (pPage->GetPageNum()-1)/2; 357cdf0e10cSrcweir else 358cdf0e10cSrcweir nPageIndex = 0; 359cdf0e10cSrcweir } 360cdf0e10cSrcweir break; 361cdf0e10cSrcweir 362cdf0e10cSrcweir case BEGIN: 363cdf0e10cSrcweir default: 364cdf0e10cSrcweir if (bDirectionIsForward) 365cdf0e10cSrcweir nPageIndex = 0; 366cdf0e10cSrcweir else 367cdf0e10cSrcweir nPageIndex = nPageCount-1; 368cdf0e10cSrcweir break; 369cdf0e10cSrcweir 370cdf0e10cSrcweir case END: 371cdf0e10cSrcweir if (bDirectionIsForward) 372cdf0e10cSrcweir nPageIndex = nPageCount; 373cdf0e10cSrcweir else 374cdf0e10cSrcweir nPageIndex = -1; 375cdf0e10cSrcweir break; 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir return nPageIndex; 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir 382cdf0e10cSrcweir 383cdf0e10cSrcweir 384cdf0e10cSrcweir //===== IteratorImplBase ==================================================== 385cdf0e10cSrcweir 386cdf0e10cSrcweir IteratorImplBase::IteratorImplBase(SdDrawDocument* pDocument, 387cdf0e10cSrcweir const ::boost::weak_ptr<ViewShell>& rpViewShellWeak, 388cdf0e10cSrcweir bool bDirectionIsForward) 389cdf0e10cSrcweir : maPosition() 390cdf0e10cSrcweir , mpDocument (pDocument) 391cdf0e10cSrcweir , mpViewShellWeak (rpViewShellWeak) 392cdf0e10cSrcweir , mbDirectionIsForward (bDirectionIsForward) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir ::boost::shared_ptr<DrawViewShell> pDrawViewShell; 395cdf0e10cSrcweir if ( ! mpViewShellWeak.expired()) 396cdf0e10cSrcweir pDrawViewShell = ::boost::dynamic_pointer_cast<DrawViewShell>(rpViewShellWeak.lock()); 397cdf0e10cSrcweir 398cdf0e10cSrcweir if (pDrawViewShell.get()) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir maPosition.mePageKind = pDrawViewShell->GetPageKind(); 401cdf0e10cSrcweir maPosition.meEditMode = pDrawViewShell->GetEditMode(); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir else 404cdf0e10cSrcweir { 405cdf0e10cSrcweir maPosition.mePageKind = PK_STANDARD; 406cdf0e10cSrcweir maPosition.meEditMode = EM_PAGE; 407cdf0e10cSrcweir } 408cdf0e10cSrcweir } 409cdf0e10cSrcweir 410cdf0e10cSrcweir IteratorImplBase::IteratorImplBase( SdDrawDocument* pDocument, 411cdf0e10cSrcweir const ::boost::weak_ptr<ViewShell>& rpViewShellWeak, 412cdf0e10cSrcweir bool bDirectionIsForward, PageKind ePageKind, EditMode eEditMode) 413cdf0e10cSrcweir : maPosition() 414cdf0e10cSrcweir , mpDocument (pDocument) 415cdf0e10cSrcweir , mpViewShellWeak (rpViewShellWeak) 416cdf0e10cSrcweir , mbDirectionIsForward (bDirectionIsForward) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir maPosition.mePageKind = ePageKind; 419cdf0e10cSrcweir maPosition.meEditMode = eEditMode; 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir IteratorImplBase::~IteratorImplBase (void) 423cdf0e10cSrcweir {} 424cdf0e10cSrcweir 425cdf0e10cSrcweir bool IteratorImplBase::operator== (const IteratorImplBase& rIterator) const 426cdf0e10cSrcweir { 427cdf0e10cSrcweir return maPosition == rIterator.maPosition; 428cdf0e10cSrcweir } 429cdf0e10cSrcweir 430cdf0e10cSrcweir bool IteratorImplBase::IsEqual (const IteratorImplBase& rIterator, IteratorType ) const 431cdf0e10cSrcweir { 432cdf0e10cSrcweir // When this method is executed instead of the ones from derived classes 433cdf0e10cSrcweir // then the argument is of another type then the object itself. In this 434cdf0e10cSrcweir // just compare the position objects. 435cdf0e10cSrcweir return maPosition == rIterator.maPosition; 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir const IteratorPosition& IteratorImplBase::GetPosition (void) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir return maPosition; 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir 444cdf0e10cSrcweir 445cdf0e10cSrcweir 446cdf0e10cSrcweir IteratorImplBase* IteratorImplBase::Clone (IteratorImplBase* pObject) const 447cdf0e10cSrcweir { 448cdf0e10cSrcweir if (pObject != NULL) 449cdf0e10cSrcweir { 450cdf0e10cSrcweir pObject->maPosition = maPosition; 451cdf0e10cSrcweir pObject->mpDocument = mpDocument; 452cdf0e10cSrcweir pObject->mpViewShellWeak = mpViewShellWeak; 453cdf0e10cSrcweir pObject->mbDirectionIsForward = mbDirectionIsForward; 454cdf0e10cSrcweir } 455cdf0e10cSrcweir return pObject; 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir 459cdf0e10cSrcweir 460cdf0e10cSrcweir void IteratorImplBase::Reverse (void) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir mbDirectionIsForward = ! mbDirectionIsForward; 463cdf0e10cSrcweir } 464cdf0e10cSrcweir 465cdf0e10cSrcweir 466cdf0e10cSrcweir 467cdf0e10cSrcweir //===== SelectionIteratorImpl =========================================== 468cdf0e10cSrcweir 469cdf0e10cSrcweir SelectionIteratorImpl::SelectionIteratorImpl ( 470cdf0e10cSrcweir const ::std::vector<SdrObjectWeakRef>& rObjectList, 471cdf0e10cSrcweir sal_Int32 nObjectIndex, 472cdf0e10cSrcweir SdDrawDocument* pDocument, 473cdf0e10cSrcweir const ::boost::weak_ptr<ViewShell>& rpViewShellWeak, 474cdf0e10cSrcweir bool bDirectionIsForward) 475cdf0e10cSrcweir : IteratorImplBase (pDocument, rpViewShellWeak, bDirectionIsForward), 476cdf0e10cSrcweir mrObjectList(rObjectList), 477cdf0e10cSrcweir mnObjectIndex(nObjectIndex) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir SelectionIteratorImpl::~SelectionIteratorImpl (void) 482cdf0e10cSrcweir {} 483cdf0e10cSrcweir 484cdf0e10cSrcweir IteratorImplBase* SelectionIteratorImpl::Clone (IteratorImplBase* pObject) const 485cdf0e10cSrcweir { 486cdf0e10cSrcweir SelectionIteratorImpl* pIterator = static_cast<SelectionIteratorImpl*>(pObject); 487cdf0e10cSrcweir if (pIterator == NULL) 488cdf0e10cSrcweir pIterator = new SelectionIteratorImpl ( 489cdf0e10cSrcweir mrObjectList, mnObjectIndex, mpDocument, mpViewShellWeak, mbDirectionIsForward); 490cdf0e10cSrcweir return pIterator; 491cdf0e10cSrcweir } 492cdf0e10cSrcweir 493cdf0e10cSrcweir 494cdf0e10cSrcweir void SelectionIteratorImpl::GotoNextText (void) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mrObjectList.at(mnObjectIndex).get() ); 497cdf0e10cSrcweir if (mbDirectionIsForward) 498cdf0e10cSrcweir { 499cdf0e10cSrcweir if( pTextObj ) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir ++maPosition.mnText; 502cdf0e10cSrcweir if( maPosition.mnText >= pTextObj->getTextCount() ) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir maPosition.mnText = 0; 505cdf0e10cSrcweir ++mnObjectIndex; 506cdf0e10cSrcweir } 507cdf0e10cSrcweir } 508cdf0e10cSrcweir else 509cdf0e10cSrcweir { 510cdf0e10cSrcweir ++mnObjectIndex; 511cdf0e10cSrcweir } 512cdf0e10cSrcweir } 513cdf0e10cSrcweir else 514cdf0e10cSrcweir { 515cdf0e10cSrcweir if( pTextObj ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir --maPosition.mnText; 518cdf0e10cSrcweir if( maPosition.mnText < 0 ) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir maPosition.mnText = -1; 521cdf0e10cSrcweir --mnObjectIndex; 522cdf0e10cSrcweir } 523cdf0e10cSrcweir } 524cdf0e10cSrcweir else 525cdf0e10cSrcweir { 526cdf0e10cSrcweir --mnObjectIndex; 527cdf0e10cSrcweir maPosition.mnText = -1; 528cdf0e10cSrcweir } 529cdf0e10cSrcweir 530cdf0e10cSrcweir if( (maPosition.mnText == -1) && (mnObjectIndex >= 0) ) 531cdf0e10cSrcweir { 532cdf0e10cSrcweir pTextObj = dynamic_cast< SdrTextObj* >( mrObjectList.at(mnObjectIndex).get() ); 533cdf0e10cSrcweir if( pTextObj ) 534cdf0e10cSrcweir maPosition.mnText = pTextObj->getTextCount() - 1; 535cdf0e10cSrcweir } 536cdf0e10cSrcweir 537cdf0e10cSrcweir if( maPosition.mnText == -1 ) 538cdf0e10cSrcweir maPosition.mnText = 0; 539cdf0e10cSrcweir } 540cdf0e10cSrcweir } 541cdf0e10cSrcweir 542cdf0e10cSrcweir 543cdf0e10cSrcweir const IteratorPosition& SelectionIteratorImpl::GetPosition (void) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir maPosition.mxObject = mrObjectList.at(mnObjectIndex); 546cdf0e10cSrcweir 547cdf0e10cSrcweir return maPosition; 548cdf0e10cSrcweir } 549cdf0e10cSrcweir 550cdf0e10cSrcweir 551cdf0e10cSrcweir bool SelectionIteratorImpl::operator== (const IteratorImplBase& rIterator) const 552cdf0e10cSrcweir { 553cdf0e10cSrcweir return rIterator.IsEqual (*this, SELECTION); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir 557cdf0e10cSrcweir bool SelectionIteratorImpl::IsEqual ( 558cdf0e10cSrcweir const IteratorImplBase& rIterator, 559cdf0e10cSrcweir IteratorType aType) const 560cdf0e10cSrcweir { 561cdf0e10cSrcweir if (aType == SELECTION) 562cdf0e10cSrcweir { 563cdf0e10cSrcweir const SelectionIteratorImpl* pSelectionIterator = 564cdf0e10cSrcweir static_cast<const SelectionIteratorImpl*>(&rIterator); 565cdf0e10cSrcweir return mpDocument == pSelectionIterator->mpDocument 566cdf0e10cSrcweir && mnObjectIndex == pSelectionIterator->mnObjectIndex; 567cdf0e10cSrcweir } 568cdf0e10cSrcweir else 569cdf0e10cSrcweir return false; 570cdf0e10cSrcweir } 571cdf0e10cSrcweir 572cdf0e10cSrcweir 573cdf0e10cSrcweir 574cdf0e10cSrcweir 575cdf0e10cSrcweir //===== ViewIteratorImpl ================================================ 576cdf0e10cSrcweir 577cdf0e10cSrcweir ViewIteratorImpl::ViewIteratorImpl ( 578cdf0e10cSrcweir sal_Int32 nPageIndex, 579cdf0e10cSrcweir SdDrawDocument* pDocument, 580cdf0e10cSrcweir const ::boost::weak_ptr<ViewShell>& rpViewShellWeak, 581cdf0e10cSrcweir bool bDirectionIsForward) 582cdf0e10cSrcweir : IteratorImplBase (pDocument, rpViewShellWeak, bDirectionIsForward), 583cdf0e10cSrcweir mbPageChangeOccured(false), 584cdf0e10cSrcweir mpPage(NULL), 585cdf0e10cSrcweir mpObjectIterator(NULL) 586cdf0e10cSrcweir { 587cdf0e10cSrcweir SetPage (nPageIndex); 588cdf0e10cSrcweir } 589cdf0e10cSrcweir 590cdf0e10cSrcweir 591cdf0e10cSrcweir 592cdf0e10cSrcweir 593cdf0e10cSrcweir ViewIteratorImpl::ViewIteratorImpl ( 594cdf0e10cSrcweir sal_Int32 nPageIndex, 595cdf0e10cSrcweir SdDrawDocument* pDocument, 596cdf0e10cSrcweir const ::boost::weak_ptr<ViewShell>& rpViewShellWeak, 597cdf0e10cSrcweir bool bDirectionIsForward, 598cdf0e10cSrcweir PageKind ePageKind, 599cdf0e10cSrcweir EditMode eEditMode) 600cdf0e10cSrcweir : IteratorImplBase (pDocument, rpViewShellWeak, bDirectionIsForward, ePageKind, eEditMode), 601cdf0e10cSrcweir mbPageChangeOccured(false), 602cdf0e10cSrcweir mpPage(NULL), 603cdf0e10cSrcweir mpObjectIterator(NULL) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir SetPage (nPageIndex); 606cdf0e10cSrcweir } 607cdf0e10cSrcweir 608cdf0e10cSrcweir 609cdf0e10cSrcweir 610cdf0e10cSrcweir 611cdf0e10cSrcweir ViewIteratorImpl::~ViewIteratorImpl (void) 612cdf0e10cSrcweir { 613cdf0e10cSrcweir } 614cdf0e10cSrcweir 615cdf0e10cSrcweir 616cdf0e10cSrcweir 617cdf0e10cSrcweir 618cdf0e10cSrcweir IteratorImplBase* ViewIteratorImpl::Clone (IteratorImplBase* pObject) const 619cdf0e10cSrcweir { 620cdf0e10cSrcweir 621cdf0e10cSrcweir ViewIteratorImpl* pIterator = static_cast<ViewIteratorImpl*>(pObject); 622cdf0e10cSrcweir if (pIterator == NULL) 623cdf0e10cSrcweir pIterator = new ViewIteratorImpl ( 624cdf0e10cSrcweir maPosition.mnPageIndex, mpDocument, mpViewShellWeak, mbDirectionIsForward); 625cdf0e10cSrcweir 626cdf0e10cSrcweir IteratorImplBase::Clone (pObject); 627cdf0e10cSrcweir 628cdf0e10cSrcweir if (mpObjectIterator != NULL) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir pIterator->mpObjectIterator = new SdrObjListIter(*mpPage, IM_DEEPNOGROUPS, !mbDirectionIsForward); 631cdf0e10cSrcweir 632cdf0e10cSrcweir // No direct way to set the object iterator to the current object. 633cdf0e10cSrcweir pIterator->maPosition.mxObject.reset(NULL); 634cdf0e10cSrcweir while (pIterator->mpObjectIterator->IsMore() && pIterator->maPosition.mxObject!=maPosition.mxObject) 635cdf0e10cSrcweir pIterator->maPosition.mxObject.reset(pIterator->mpObjectIterator->Next()); 636cdf0e10cSrcweir } 637cdf0e10cSrcweir else 638cdf0e10cSrcweir pIterator->mpObjectIterator = NULL; 639cdf0e10cSrcweir 640cdf0e10cSrcweir return pIterator; 641cdf0e10cSrcweir } 642cdf0e10cSrcweir 643cdf0e10cSrcweir 644cdf0e10cSrcweir 645cdf0e10cSrcweir void ViewIteratorImpl::GotoNextText(void) 646cdf0e10cSrcweir { 647cdf0e10cSrcweir SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get() ); 648cdf0e10cSrcweir if( pTextObj ) 649cdf0e10cSrcweir { 650cdf0e10cSrcweir if (mbDirectionIsForward) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir ++maPosition.mnText; 653cdf0e10cSrcweir if( maPosition.mnText < pTextObj->getTextCount() ) 654cdf0e10cSrcweir return; 655cdf0e10cSrcweir } 656cdf0e10cSrcweir else 657cdf0e10cSrcweir { 658cdf0e10cSrcweir --maPosition.mnText; 659cdf0e10cSrcweir if( maPosition.mnText >= 0 ) 660cdf0e10cSrcweir return; 661cdf0e10cSrcweir } 662cdf0e10cSrcweir } 663cdf0e10cSrcweir 664cdf0e10cSrcweir if (mpObjectIterator != NULL && mpObjectIterator->IsMore()) 665cdf0e10cSrcweir maPosition.mxObject.reset(mpObjectIterator->Next()); 666cdf0e10cSrcweir else 667cdf0e10cSrcweir maPosition.mxObject.reset(NULL); 668cdf0e10cSrcweir 669cdf0e10cSrcweir if (!maPosition.mxObject.is() ) 670cdf0e10cSrcweir { 671cdf0e10cSrcweir if (mbDirectionIsForward) 672cdf0e10cSrcweir SetPage (maPosition.mnPageIndex+1); 673cdf0e10cSrcweir else 674cdf0e10cSrcweir SetPage (maPosition.mnPageIndex-1); 675cdf0e10cSrcweir 676cdf0e10cSrcweir if (mpPage != NULL) 677cdf0e10cSrcweir mpObjectIterator = new SdrObjListIter(*mpPage, IM_DEEPNOGROUPS, !mbDirectionIsForward); 678cdf0e10cSrcweir if (mpObjectIterator!=NULL && mpObjectIterator->IsMore()) 679cdf0e10cSrcweir maPosition.mxObject.reset(mpObjectIterator->Next()); 680cdf0e10cSrcweir else 681cdf0e10cSrcweir maPosition.mxObject.reset(NULL); 682cdf0e10cSrcweir } 683cdf0e10cSrcweir 684cdf0e10cSrcweir maPosition.mnText = 0; 685cdf0e10cSrcweir if( !mbDirectionIsForward && maPosition.mxObject.is() ) 686cdf0e10cSrcweir { 687cdf0e10cSrcweir pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get() ); 688cdf0e10cSrcweir if( pTextObj ) 689cdf0e10cSrcweir maPosition.mnText = pTextObj->getTextCount() - 1; 690cdf0e10cSrcweir } 691cdf0e10cSrcweir } 692cdf0e10cSrcweir 693cdf0e10cSrcweir 694cdf0e10cSrcweir 695cdf0e10cSrcweir 696cdf0e10cSrcweir void ViewIteratorImpl::SetPage (sal_Int32 nPageIndex) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir mbPageChangeOccured = (maPosition.mnPageIndex!=nPageIndex); 699cdf0e10cSrcweir if (mbPageChangeOccured) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir maPosition.mnPageIndex = nPageIndex; 702cdf0e10cSrcweir 703cdf0e10cSrcweir sal_Int32 nPageCount; 704cdf0e10cSrcweir if (maPosition.meEditMode == EM_PAGE) 705cdf0e10cSrcweir nPageCount = mpDocument->GetSdPageCount(maPosition.mePageKind); 706cdf0e10cSrcweir else 707cdf0e10cSrcweir nPageCount = mpDocument->GetMasterSdPageCount( 708cdf0e10cSrcweir maPosition.mePageKind); 709cdf0e10cSrcweir 710cdf0e10cSrcweir // Get page pointer. Here we have three cases: regular pages, 711cdf0e10cSrcweir // master pages and invalid page indices. The later ones are not 712cdf0e10cSrcweir // errors but the effect of the iterator advancing to the next page 713cdf0e10cSrcweir // and going past the last one. This dropping of the rim at the far 714cdf0e10cSrcweir // side is detected here and has to be reacted to by the caller. 715cdf0e10cSrcweir if (nPageIndex>=0 && nPageIndex < nPageCount) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir if (maPosition.meEditMode == EM_PAGE) 718cdf0e10cSrcweir mpPage = mpDocument->GetSdPage ( 719cdf0e10cSrcweir (sal_uInt16)nPageIndex, 720cdf0e10cSrcweir maPosition.mePageKind); 721cdf0e10cSrcweir else 722cdf0e10cSrcweir mpPage = mpDocument->GetMasterSdPage ( 723cdf0e10cSrcweir (sal_uInt16)nPageIndex, 724cdf0e10cSrcweir maPosition.mePageKind); 725cdf0e10cSrcweir } 726cdf0e10cSrcweir else 727cdf0e10cSrcweir mpPage = NULL; 728cdf0e10cSrcweir } 729cdf0e10cSrcweir 730cdf0e10cSrcweir // Set up object list iterator. 731cdf0e10cSrcweir if (mpPage != NULL) 732cdf0e10cSrcweir mpObjectIterator = new SdrObjListIter(*mpPage, IM_DEEPNOGROUPS, ! mbDirectionIsForward); 733cdf0e10cSrcweir else 734cdf0e10cSrcweir mpObjectIterator = NULL; 735cdf0e10cSrcweir 736cdf0e10cSrcweir // Get object pointer. 737cdf0e10cSrcweir if (mpObjectIterator!=NULL && mpObjectIterator->IsMore()) 738cdf0e10cSrcweir maPosition.mxObject.reset( mpObjectIterator->Next() ); 739cdf0e10cSrcweir else 740cdf0e10cSrcweir maPosition.mxObject.reset( NULL ); 741cdf0e10cSrcweir 742cdf0e10cSrcweir maPosition.mnText = 0; 743cdf0e10cSrcweir if( !mbDirectionIsForward && maPosition.mxObject.is() ) 744cdf0e10cSrcweir { 745cdf0e10cSrcweir SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get() ); 746cdf0e10cSrcweir if( pTextObj ) 747cdf0e10cSrcweir maPosition.mnText = pTextObj->getTextCount() - 1; 748cdf0e10cSrcweir } 749cdf0e10cSrcweir 750cdf0e10cSrcweir } 751cdf0e10cSrcweir 752cdf0e10cSrcweir 753cdf0e10cSrcweir 754cdf0e10cSrcweir 755cdf0e10cSrcweir void ViewIteratorImpl::Reverse (void) 756cdf0e10cSrcweir { 757cdf0e10cSrcweir IteratorImplBase::Reverse (); 758cdf0e10cSrcweir 759cdf0e10cSrcweir // Create reversed object list iterator. 760cdf0e10cSrcweir if (mpObjectIterator != NULL) 761cdf0e10cSrcweir delete mpObjectIterator; 762cdf0e10cSrcweir if (mpPage != NULL) 763cdf0e10cSrcweir mpObjectIterator = new SdrObjListIter(*mpPage, IM_DEEPNOGROUPS, ! mbDirectionIsForward); 764cdf0e10cSrcweir else 765cdf0e10cSrcweir mpObjectIterator = NULL; 766cdf0e10cSrcweir 767cdf0e10cSrcweir // Move iterator to the current object. 768cdf0e10cSrcweir SdrObjectWeakRef xObject = maPosition.mxObject; 769cdf0e10cSrcweir maPosition.mxObject.reset(NULL); 770cdf0e10cSrcweir while (mpObjectIterator->IsMore() && maPosition.mxObject != xObject) 771cdf0e10cSrcweir maPosition.mxObject.reset(mpObjectIterator->Next()); 772cdf0e10cSrcweir } 773cdf0e10cSrcweir 774cdf0e10cSrcweir 775cdf0e10cSrcweir 776cdf0e10cSrcweir 777cdf0e10cSrcweir //===== DocumentIteratorImpl ============================================ 778cdf0e10cSrcweir 779cdf0e10cSrcweir DocumentIteratorImpl::DocumentIteratorImpl ( 780cdf0e10cSrcweir sal_Int32 nPageIndex, 781cdf0e10cSrcweir PageKind ePageKind, EditMode eEditMode, 782cdf0e10cSrcweir SdDrawDocument* pDocument, 783cdf0e10cSrcweir const ::boost::weak_ptr<ViewShell>& rpViewShellWeak, 784cdf0e10cSrcweir bool bDirectionIsForward) 785cdf0e10cSrcweir : ViewIteratorImpl (nPageIndex, pDocument, rpViewShellWeak, bDirectionIsForward, 786cdf0e10cSrcweir ePageKind, eEditMode) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir if (eEditMode == EM_PAGE) 789cdf0e10cSrcweir mnPageCount = pDocument->GetSdPageCount (ePageKind); 790cdf0e10cSrcweir else 791cdf0e10cSrcweir mnPageCount = pDocument->GetMasterSdPageCount(ePageKind); 792cdf0e10cSrcweir } 793cdf0e10cSrcweir 794cdf0e10cSrcweir 795cdf0e10cSrcweir 796cdf0e10cSrcweir 797cdf0e10cSrcweir DocumentIteratorImpl::~DocumentIteratorImpl (void) 798cdf0e10cSrcweir {} 799cdf0e10cSrcweir 800cdf0e10cSrcweir 801cdf0e10cSrcweir 802cdf0e10cSrcweir 803cdf0e10cSrcweir IteratorImplBase* DocumentIteratorImpl::Clone (IteratorImplBase* pObject) const 804cdf0e10cSrcweir { 805cdf0e10cSrcweir DocumentIteratorImpl* pIterator = static_cast<DocumentIteratorImpl*>(pObject); 806cdf0e10cSrcweir if (pIterator == NULL) 807cdf0e10cSrcweir pIterator = new DocumentIteratorImpl ( 808cdf0e10cSrcweir maPosition.mnPageIndex, maPosition.mePageKind, maPosition.meEditMode, 809cdf0e10cSrcweir mpDocument, mpViewShellWeak, mbDirectionIsForward); 810cdf0e10cSrcweir // Finish the cloning. 811cdf0e10cSrcweir return ViewIteratorImpl::Clone (pIterator); 812cdf0e10cSrcweir } 813cdf0e10cSrcweir 814cdf0e10cSrcweir 815cdf0e10cSrcweir 816cdf0e10cSrcweir 817cdf0e10cSrcweir void DocumentIteratorImpl::GotoNextText (void) 818cdf0e10cSrcweir { 819cdf0e10cSrcweir bool bSetToOnePastLastPage = false; 820cdf0e10cSrcweir bool bViewChanged = false; 821cdf0e10cSrcweir 822cdf0e10cSrcweir ViewIteratorImpl::GotoNextText(); 823cdf0e10cSrcweir 824cdf0e10cSrcweir if (mbDirectionIsForward) 825cdf0e10cSrcweir { 826cdf0e10cSrcweir if (maPosition.mnPageIndex >= mnPageCount) 827cdf0e10cSrcweir { 828cdf0e10cSrcweir // Switch to master page. 829cdf0e10cSrcweir if (maPosition.meEditMode == EM_PAGE) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir maPosition.meEditMode = EM_MASTERPAGE; 832cdf0e10cSrcweir SetPage (0); 833cdf0e10cSrcweir } 834cdf0e10cSrcweir 835cdf0e10cSrcweir // Switch to next view mode. 836cdf0e10cSrcweir else 837cdf0e10cSrcweir { 838cdf0e10cSrcweir if (maPosition.mePageKind == PK_HANDOUT) 839cdf0e10cSrcweir // Not really necessary but makes things more clear. 840cdf0e10cSrcweir bSetToOnePastLastPage = true; 841cdf0e10cSrcweir else 842cdf0e10cSrcweir { 843cdf0e10cSrcweir maPosition.meEditMode = EM_PAGE; 844cdf0e10cSrcweir if (maPosition.mePageKind == PK_STANDARD) 845cdf0e10cSrcweir maPosition.mePageKind = PK_NOTES; 846cdf0e10cSrcweir else if (maPosition.mePageKind == PK_NOTES) 847cdf0e10cSrcweir maPosition.mePageKind = PK_HANDOUT; 848cdf0e10cSrcweir SetPage (0); 849cdf0e10cSrcweir } 850cdf0e10cSrcweir } 851cdf0e10cSrcweir bViewChanged = true; 852cdf0e10cSrcweir } 853cdf0e10cSrcweir } 854cdf0e10cSrcweir else 855cdf0e10cSrcweir if (maPosition.mnPageIndex < 0) 856cdf0e10cSrcweir { 857cdf0e10cSrcweir // Switch from master pages to draw pages. 858cdf0e10cSrcweir if (maPosition.meEditMode == EM_MASTERPAGE) 859cdf0e10cSrcweir { 860cdf0e10cSrcweir maPosition.meEditMode = EM_PAGE; 861cdf0e10cSrcweir bSetToOnePastLastPage = true; 862cdf0e10cSrcweir } 863cdf0e10cSrcweir 864cdf0e10cSrcweir // Switch to previous view mode. 865cdf0e10cSrcweir else 866cdf0e10cSrcweir { 867cdf0e10cSrcweir if (maPosition.mePageKind == PK_STANDARD) 868cdf0e10cSrcweir SetPage (-1); 869cdf0e10cSrcweir else 870cdf0e10cSrcweir { 871cdf0e10cSrcweir maPosition.meEditMode = EM_MASTERPAGE; 872cdf0e10cSrcweir if (maPosition.mePageKind == PK_HANDOUT) 873cdf0e10cSrcweir maPosition.mePageKind = PK_NOTES; 874cdf0e10cSrcweir else if (maPosition.mePageKind == PK_NOTES) 875cdf0e10cSrcweir maPosition.mePageKind = PK_STANDARD; 876cdf0e10cSrcweir bSetToOnePastLastPage = true; 877cdf0e10cSrcweir } 878cdf0e10cSrcweir } 879cdf0e10cSrcweir bViewChanged = true; 880cdf0e10cSrcweir } 881cdf0e10cSrcweir 882cdf0e10cSrcweir if (bViewChanged) 883cdf0e10cSrcweir { 884cdf0e10cSrcweir // Get new page count; 885cdf0e10cSrcweir sal_Int32 nPageCount; 886cdf0e10cSrcweir if (maPosition.meEditMode == EM_PAGE) 887cdf0e10cSrcweir nPageCount = mpDocument->GetSdPageCount (maPosition.mePageKind); 888cdf0e10cSrcweir else 889cdf0e10cSrcweir nPageCount = mpDocument->GetMasterSdPageCount(maPosition.mePageKind); 890cdf0e10cSrcweir 891cdf0e10cSrcweir // Now that we know the number of pages we can set the current page index. 892cdf0e10cSrcweir if (bSetToOnePastLastPage) 893cdf0e10cSrcweir SetPage (nPageCount); 894cdf0e10cSrcweir } 895cdf0e10cSrcweir } 896cdf0e10cSrcweir 897cdf0e10cSrcweir 898cdf0e10cSrcweir } } // end of namespace ::sd::outliner 899