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