LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/controller - SlsSlotManager.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 555 2.2 %
Date: 2015-06-13 12:38:46 Functions: 5 23 21.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/presentation/XPresentation2.hpp>
      21             : #include <com/sun/star/beans/PropertyValue.hpp>
      22             : #include <com/sun/star/uno/Any.hxx>
      23             : 
      24             : #include <editeng/outlobj.hxx>
      25             : 
      26             : #include "controller/SlsSlotManager.hxx"
      27             : #include "SlideSorter.hxx"
      28             : #include "SlideSorterViewShell.hxx"
      29             : #include "controller/SlideSorterController.hxx"
      30             : #include "controller/SlsClipboard.hxx"
      31             : #include "controller/SlsCurrentSlideManager.hxx"
      32             : #include "controller/SlsFocusManager.hxx"
      33             : #include "controller/SlsInsertionIndicatorHandler.hxx"
      34             : #include "controller/SlsPageSelector.hxx"
      35             : #include "controller/SlsSelectionFunction.hxx"
      36             : #include "controller/SlsSelectionManager.hxx"
      37             : #include "controller/SlsSelectionObserver.hxx"
      38             : #include "model/SlideSorterModel.hxx"
      39             : #include "model/SlsPageEnumerationProvider.hxx"
      40             : #include "model/SlsPageDescriptor.hxx"
      41             : #include "view/SlideSorterView.hxx"
      42             : #include "view/SlsLayouter.hxx"
      43             : #include "framework/FrameworkHelper.hxx"
      44             : #include "Window.hxx"
      45             : #include "fupoor.hxx"
      46             : #include "fuzoom.hxx"
      47             : #include "fucushow.hxx"
      48             : #include "fusldlg.hxx"
      49             : #include "fuexpand.hxx"
      50             : #include "fusumry.hxx"
      51             : #include "fuscale.hxx"
      52             : #include "slideshow.hxx"
      53             : #include "app.hrc"
      54             : #include "strings.hrc"
      55             : #include "sdresid.hxx"
      56             : #include "drawdoc.hxx"
      57             : #include "DrawDocShell.hxx"
      58             : #include "ViewShellBase.hxx"
      59             : #include "ViewShellImplementation.hxx"
      60             : #include "sdattr.hxx"
      61             : #include "FrameView.hxx"
      62             : #include "zoomlist.hxx"
      63             : #include "sdpage.hxx"
      64             : #include "sdxfer.hxx"
      65             : #include "helpids.h"
      66             : #include "glob.hrc"
      67             : #include "unmodpg.hxx"
      68             : #include "DrawViewShell.hxx"
      69             : #include "sdabstdlg.hxx"
      70             : 
      71             : #include <sfx2/request.hxx>
      72             : #include <sfx2/viewfrm.hxx>
      73             : #include <sfx2/bindings.hxx>
      74             : #include <sfx2/dispatch.hxx>
      75             : #include <sfx2/sidebar/Sidebar.hxx>
      76             : #include <svx/svxids.hrc>
      77             : #include <sfx2/zoomitem.hxx>
      78             : #include <svx/svxdlg.hxx>
      79             : #include <svx/dialogs.hrc>
      80             : #include <vcl/msgbox.hxx>
      81             : #include <svl/intitem.hxx>
      82             : #include <svl/whiter.hxx>
      83             : #include <svl/itempool.hxx>
      84             : #include <svl/aeitem.hxx>
      85             : #include <com/sun/star/presentation/FadeEffect.hpp>
      86             : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
      87             : #include <com/sun/star/drawing/XDrawPages.hpp>
      88             : #include <vcl/svapp.hxx>
      89             : 
      90             : #include <boost/bind.hpp>
      91             : #include <boost/scoped_ptr.hpp>
      92             : 
      93             : using namespace ::com::sun::star;
      94             : using namespace ::com::sun::star::uno;
      95             : using namespace ::com::sun::star::presentation;
      96             : using namespace ::com::sun::star::beans;
      97             : 
      98             : namespace sd { namespace slidesorter { namespace controller {
      99             : 
     100             : namespace {
     101             : 
     102             : /** The state of a set of slides with respect to being excluded from the
     103             :     slide show.
     104             : */
     105             : enum SlideExclusionState {UNDEFINED, EXCLUDED, INCLUDED, MIXED};
     106             : 
     107             : /** Return for the given set of slides whether they included are
     108             :     excluded from the slide show.
     109             : */
     110             : SlideExclusionState GetSlideExclusionState (model::PageEnumeration& rPageSet);
     111             : 
     112             : } // end of anonymous namespace
     113             : 
     114          64 : SlotManager::SlotManager (SlideSorter& rSlideSorter)
     115             :     : mrSlideSorter(rSlideSorter),
     116          64 :       maCommandQueue()
     117             : {
     118          64 : }
     119             : 
     120          64 : SlotManager::~SlotManager()
     121             : {
     122          64 : }
     123             : 
     124           0 : void SlotManager::FuTemporary (SfxRequest& rRequest)
     125             : {
     126           0 :     SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument();
     127             : 
     128             :     SlideSorterViewShell* pShell
     129           0 :         = dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell());
     130           0 :     if (pShell == NULL)
     131           0 :         return;
     132             : 
     133           0 :     switch (rRequest.GetSlot())
     134             :     {
     135             :         case SID_PRESENTATION:
     136             :         case SID_PRESENTATION_CURRENT_SLIDE:
     137             :         case SID_REHEARSE_TIMINGS:
     138           0 :             ShowSlideShow (rRequest);
     139           0 :             pShell->Cancel();
     140           0 :             rRequest.Done();
     141           0 :             break;
     142             : 
     143             :         case SID_HIDE_SLIDE:
     144           0 :             ChangeSlideExclusionState(model::SharedPageDescriptor(), true);
     145           0 :             break;
     146             : 
     147             :         case SID_SHOW_SLIDE:
     148           0 :             ChangeSlideExclusionState(model::SharedPageDescriptor(), false);
     149           0 :             break;
     150             : 
     151             :         case SID_PAGES_PER_ROW:
     152           0 :             if (rRequest.GetArgs() != NULL)
     153             :             {
     154           0 :                 SFX_REQUEST_ARG(rRequest, pPagesPerRow, SfxUInt16Item,
     155             :                     SID_PAGES_PER_ROW, false);
     156           0 :                 if (pPagesPerRow != NULL)
     157             :                 {
     158           0 :                     sal_Int32 nColumnCount = pPagesPerRow->GetValue();
     159             :                     // Force the given number of columns by setting
     160             :                     // the minimal and maximal number of columns to
     161             :                     // the same value.
     162           0 :                     mrSlideSorter.GetView().GetLayouter().SetColumnCount (
     163           0 :                         nColumnCount, nColumnCount);
     164             :                     // Force a repaint and re-layout.
     165           0 :                     pShell->ArrangeGUIElements ();
     166             :                     // Rearrange the UI-elements controlled by the
     167             :                     // controller and force a rearrangement of the
     168             :                     // view.
     169           0 :                     mrSlideSorter.GetController().Rearrange(true);
     170             :                 }
     171             :             }
     172           0 :             rRequest.Done();
     173           0 :             break;
     174             : 
     175             :         case SID_SELECTALL:
     176           0 :             mrSlideSorter.GetController().GetPageSelector().SelectAllPages();
     177           0 :             rRequest.Done();
     178           0 :             break;
     179             : 
     180             :         case SID_SLIDE_TRANSITIONS_PANEL:
     181             :         {
     182             :             // Make the slide transition panel visible in the sidebar.
     183             :             ::sfx2::sidebar::Sidebar::ShowPanel(
     184             :                 OUString("SlideTransitionPanel"),
     185           0 :                 pShell->GetViewFrame()->GetFrame().GetFrameInterface());
     186           0 :             rRequest.Ignore ();
     187           0 :             break;
     188             :         }
     189             : 
     190             :         case SID_PRESENTATION_DLG:
     191             :             FuSlideShowDlg::Create (
     192             :                 pShell,
     193             :                 mrSlideSorter.GetContentWindow(),
     194           0 :                 &mrSlideSorter.GetView(),
     195             :                 pDocument,
     196           0 :                 rRequest);
     197           0 :             break;
     198             : 
     199             :         case SID_CUSTOMSHOW_DLG:
     200             :             FuCustomShowDlg::Create (
     201             :                 pShell,
     202             :                 mrSlideSorter.GetContentWindow(),
     203           0 :                 &mrSlideSorter.GetView(),
     204             :                 pDocument,
     205           0 :                 rRequest);
     206           0 :                 break;
     207             : 
     208             :         case SID_EXPAND_PAGE:
     209             :             FuExpandPage::Create (
     210             :                 pShell,
     211             :                 mrSlideSorter.GetContentWindow(),
     212           0 :                 &mrSlideSorter.GetView(),
     213             :                 pDocument,
     214           0 :                 rRequest);
     215           0 :             break;
     216             : 
     217             :         case SID_SUMMARY_PAGE:
     218             :             FuSummaryPage::Create (
     219             :                 pShell,
     220             :                 mrSlideSorter.GetContentWindow(),
     221           0 :                 &mrSlideSorter.GetView(),
     222             :                 pDocument,
     223           0 :                 rRequest);
     224           0 :             break;
     225             : 
     226             :         case SID_INSERTPAGE:
     227             :         case SID_INSERT_MASTER_PAGE:
     228           0 :             InsertSlide(rRequest);
     229           0 :             rRequest.Done();
     230           0 :             break;
     231             : 
     232             :         case SID_DUPLICATE_PAGE:
     233           0 :             DuplicateSelectedSlides(rRequest);
     234           0 :             rRequest.Done();
     235           0 :             break;
     236             : 
     237             :         case SID_DELETE_PAGE:
     238             :         case SID_DELETE_MASTER_PAGE:
     239             :         case SID_DELETE: // we need SID_CUT to handle the delete key
     240             :             // (DEL -> accelerator -> SID_CUT).
     241           0 :             if (mrSlideSorter.GetModel().GetPageCount() > 1)
     242             :             {
     243           0 :                 mrSlideSorter.GetController().GetSelectionManager()->DeleteSelectedPages();
     244             :             }
     245             : 
     246           0 :             rRequest.Done();
     247           0 :             break;
     248             : 
     249             :         case SID_RENAMEPAGE:
     250             :         case SID_RENAME_MASTER_PAGE:
     251           0 :             RenameSlide ();
     252           0 :             rRequest.Done ();
     253           0 :             break;
     254             : 
     255             :         case SID_ASSIGN_LAYOUT:
     256             :         {
     257           0 :             pShell->mpImpl->AssignLayout( rRequest, mrSlideSorter.GetModel().GetPageType() );
     258           0 :             rRequest.Done ();
     259             :         }
     260           0 :         break;
     261             : 
     262             :         case SID_PHOTOALBUM:
     263             :         {
     264           0 :             SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     265             :             boost::scoped_ptr<VclAbstractDialog> pDlg(pFact ? pFact->CreateSdPhotoAlbumDialog(
     266             :                 mrSlideSorter.GetContentWindow(),
     267           0 :                 pDocument) : 0);
     268             : 
     269           0 :             if (pDlg)
     270             :             {
     271           0 :                 pDlg->Execute();
     272           0 :                 pDlg.reset();
     273             :             }
     274           0 :             rRequest.Done ();
     275             :         }
     276           0 :         break;
     277             : 
     278             :         case SID_REMOTE_DLG:
     279             :         {
     280             : #ifdef ENABLE_SDREMOTE
     281           0 :              SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     282             :              VclAbstractDialog* pDlg = pFact ?
     283           0 :                  pFact->CreateRemoteDialog( mrSlideSorter.GetContentWindow() ) :
     284           0 :                  0;
     285           0 :              if (pDlg)
     286           0 :                  pDlg->Execute();
     287             : #endif
     288             :         }
     289           0 :         break;
     290             : 
     291             :         default:
     292           0 :             break;
     293             :     }
     294             : }
     295             : 
     296           0 : void SlotManager::FuPermanent (SfxRequest& rRequest)
     297             : {
     298           0 :     ViewShell* pShell = mrSlideSorter.GetViewShell();
     299           0 :     if (pShell == NULL)
     300           0 :         return;
     301             : 
     302           0 :     if(pShell->GetCurrentFunction().is())
     303             :     {
     304           0 :         rtl::Reference<FuPoor> xEmpty;
     305           0 :         if (pShell->GetOldFunction() == pShell->GetCurrentFunction())
     306           0 :             pShell->SetOldFunction(xEmpty);
     307             : 
     308           0 :         pShell->GetCurrentFunction()->Deactivate();
     309           0 :         pShell->SetCurrentFunction(xEmpty);
     310             :     }
     311             : 
     312           0 :     switch(rRequest.GetSlot())
     313             :     {
     314             :         case SID_OBJECT_SELECT:
     315           0 :             pShell->SetCurrentFunction( SelectionFunction::Create(mrSlideSorter, rRequest) );
     316           0 :             rRequest.Done();
     317           0 :             break;
     318             : 
     319             :         default:
     320           0 :                 break;
     321             :     }
     322             : 
     323           0 :     if(pShell->GetOldFunction().is())
     324             :     {
     325           0 :         pShell->GetOldFunction()->Deactivate();
     326           0 :         rtl::Reference<FuPoor> xEmpty;
     327           0 :         pShell->SetOldFunction(xEmpty);
     328             :     }
     329             : 
     330           0 :     if(pShell->GetCurrentFunction().is())
     331             :     {
     332           0 :         pShell->GetCurrentFunction()->Activate();
     333           0 :         pShell->SetOldFunction(pShell->GetCurrentFunction());
     334             :     }
     335             : 
     336             :     //! that's only until ENUM-Slots ?are
     337             :     //  Invalidate( SID_OBJECT_SELECT );
     338             : }
     339             : 
     340           0 : void SlotManager::FuSupport (SfxRequest& rRequest)
     341             : {
     342           0 :     switch (rRequest.GetSlot())
     343             :     {
     344             :         case SID_STYLE_FAMILY:
     345           0 :             if (rRequest.GetArgs() != NULL)
     346             :             {
     347             :                 SdDrawDocument* pDocument
     348           0 :                     = mrSlideSorter.GetModel().GetDocument();
     349           0 :                 if (pDocument != NULL)
     350             :                 {
     351             :                     const SfxPoolItem& rItem (
     352           0 :                         rRequest.GetArgs()->Get(SID_STYLE_FAMILY));
     353             :                     pDocument->GetDocSh()->SetStyleFamily(
     354           0 :                         static_cast<const SfxUInt16Item&>(rItem).GetValue());
     355             :                 }
     356             :             }
     357           0 :             break;
     358             : 
     359             :         case SID_PASTE:
     360             :         {
     361           0 :             SdTransferable* pTransferClip = SD_MOD()->pTransferClip;
     362           0 :             if( pTransferClip )
     363             :             {
     364           0 :                 SfxObjectShell* pTransferDocShell = pTransferClip->GetDocShell();
     365             : 
     366           0 :                 DrawDocShell* pDocShell = dynamic_cast<DrawDocShell*>(pTransferDocShell);
     367           0 :                 if (pDocShell && pDocShell->GetDoc()->GetPageCount() > 1)
     368             :                 {
     369           0 :                     mrSlideSorter.GetController().GetClipboard().HandleSlotCall(rRequest);
     370           0 :                     break;
     371             :                 }
     372             :             }
     373           0 :             ViewShellBase* pBase = mrSlideSorter.GetViewShellBase();
     374           0 :             if (pBase != NULL)
     375             :             {
     376             :                 ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
     377           0 :                     ::boost::dynamic_pointer_cast<DrawViewShell>(pBase->GetMainViewShell()));
     378           0 :                 if (pDrawViewShell.get() != NULL)
     379           0 :                     pDrawViewShell->FuSupport(rRequest);
     380             :             }
     381             :         }
     382           0 :         break;
     383             : 
     384             :         case SID_CUT:
     385             :         case SID_COPY:
     386             :         case SID_DELETE:
     387           0 :             mrSlideSorter.GetController().GetClipboard().HandleSlotCall(rRequest);
     388           0 :             break;
     389             : 
     390             :         case SID_DRAWINGMODE:
     391             :         case SID_NOTESMODE:
     392             :         case SID_HANDOUTMODE:
     393             :         case SID_DIAMODE:
     394             :         case SID_OUTLINEMODE:
     395             :         {
     396           0 :             ViewShellBase* pBase = mrSlideSorter.GetViewShellBase();
     397           0 :             if (pBase != NULL)
     398             :             {
     399             :                 framework::FrameworkHelper::Instance(*pBase)->HandleModeChangeSlot(
     400           0 :                     rRequest.GetSlot(), rRequest);
     401           0 :                 rRequest.Done();
     402             :             }
     403           0 :             break;
     404             :         }
     405             : 
     406             :         case SID_UNDO:
     407             :         {
     408             :             SlideSorterViewShell* pViewShell
     409           0 :                 = dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell());
     410           0 :             if (pViewShell != NULL)
     411             :             {
     412           0 :                 view::SlideSorterView::DrawLock aDrawLock (mrSlideSorter);
     413           0 :                 SlideSorterController::ModelChangeLock aModelLock (mrSlideSorter.GetController());
     414           0 :                 PageSelector::UpdateLock aUpdateLock (mrSlideSorter);
     415           0 :                 SelectionObserver::Context aContext (mrSlideSorter);
     416           0 :                 pViewShell->ImpSidUndo (false, rRequest);
     417             :             }
     418           0 :             break;
     419             :         }
     420             : 
     421             :         case SID_REDO:
     422             :         {
     423             :             SlideSorterViewShell* pViewShell
     424           0 :                 = dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell());
     425           0 :             if (pViewShell != NULL)
     426             :             {
     427           0 :                 view::SlideSorterView::DrawLock aDrawLock (mrSlideSorter);
     428           0 :                 SlideSorterController::ModelChangeLock aModelLock (mrSlideSorter.GetController());
     429           0 :                 PageSelector::UpdateLock aUpdateLock (mrSlideSorter);
     430           0 :                 SelectionObserver::Context aContext (mrSlideSorter);
     431           0 :                 pViewShell->ImpSidRedo (false, rRequest);
     432             :             }
     433           0 :             break;
     434             :         }
     435             : 
     436             :         default:
     437           0 :             break;
     438             :     }
     439           0 : }
     440             : 
     441           0 : void SlotManager::ExecCtrl (SfxRequest& rRequest)
     442             : {
     443           0 :     ViewShell* pViewShell = mrSlideSorter.GetViewShell();
     444           0 :     sal_uInt16 nSlot = rRequest.GetSlot();
     445           0 :     switch (nSlot)
     446             :     {
     447             :         case SID_RELOAD:
     448             :         {
     449             :             // empty Undo-Manager
     450           0 :             mrSlideSorter.GetModel().GetDocument()->GetDocSh()->ClearUndoBuffer();
     451             : 
     452             :             // normal forwarding to ViewFrame for execution
     453           0 :             if (pViewShell != NULL)
     454           0 :                 pViewShell->GetViewFrame()->ExecuteSlot(rRequest);
     455             : 
     456             :             // has to be finished right away
     457           0 :             return;
     458             :         }
     459             : 
     460             :         case SID_OUTPUT_QUALITY_COLOR:
     461             :         case SID_OUTPUT_QUALITY_GRAYSCALE:
     462             :         case SID_OUTPUT_QUALITY_BLACKWHITE:
     463             :         case SID_OUTPUT_QUALITY_CONTRAST:
     464             :         {
     465             :             // flush page cache
     466           0 :             if (pViewShell != NULL)
     467           0 :                 pViewShell->ExecReq (rRequest);
     468           0 :             break;
     469             :         }
     470             : 
     471             :         case SID_MAIL_SCROLLBODY_PAGEDOWN:
     472             :         {
     473           0 :             if (pViewShell != NULL)
     474           0 :                 pViewShell->ExecReq (rRequest);
     475           0 :             break;
     476             :         }
     477             : 
     478             :         case SID_OPT_LOCALE_CHANGED:
     479             :         {
     480           0 :             mrSlideSorter.GetController().UpdateAllPages();
     481           0 :             if (pViewShell != NULL)
     482           0 :                 pViewShell->UpdatePreview (pViewShell->GetActualPage());
     483           0 :             rRequest.Done();
     484           0 :             break;
     485             :         }
     486             : 
     487             :         case SID_SEARCH_DLG:
     488             :             // We have to handle the SID_SEARCH_DLG slot explicitly because
     489             :             // in some cases (when the slide sorter is displayed in the
     490             :             // center pane) we want to disable the search dialog.  Therefore
     491             :             // we have to handle the execution of that slot as well.
     492             :             // We try to do that by forwarding the request to the view frame
     493             :             // of the view shell.
     494           0 :             if (pViewShell != NULL)
     495           0 :                 pViewShell->GetViewFrame()->ExecuteSlot(rRequest);
     496           0 :             break;
     497             : 
     498             :         default:
     499           0 :             break;
     500             :     }
     501             : }
     502             : 
     503           0 : void SlotManager::GetAttrState (SfxItemSet& rSet)
     504             : {
     505             :     // Iterate over all items.
     506           0 :     SfxWhichIter aIter (rSet);
     507           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     508           0 :     while (nWhich)
     509             :     {
     510           0 :         sal_uInt16 nSlotId (nWhich);
     511           0 :         if (SfxItemPool::IsWhich(nWhich) && mrSlideSorter.GetViewShell()!=NULL)
     512           0 :             nSlotId = mrSlideSorter.GetViewShell()->GetPool().GetSlotId(nWhich);
     513           0 :         switch (nSlotId)
     514             :         {
     515             :             case SID_PAGES_PER_ROW:
     516             :                 rSet.Put (
     517             :                     SfxUInt16Item (
     518             :                         nSlotId,
     519           0 :                         (sal_uInt16)mrSlideSorter.GetView().GetLayouter().GetColumnCount()
     520             :                         )
     521           0 :                     );
     522           0 :             break;
     523             :         }
     524           0 :         nWhich = aIter.NextWhich();
     525           0 :     }
     526           0 : }
     527             : 
     528           0 : void SlotManager::GetMenuState (SfxItemSet& rSet)
     529             : {
     530           0 :     EditMode eEditMode = mrSlideSorter.GetModel().GetEditMode();
     531           0 :     ViewShell* pShell = mrSlideSorter.GetViewShell();
     532           0 :     DrawDocShell* pDocShell = mrSlideSorter.GetModel().GetDocument()->GetDocSh();
     533             : 
     534           0 :     if (pShell!=NULL && pShell->GetCurrentFunction().is())
     535             :     {
     536           0 :         sal_uInt16 nSId = pShell->GetCurrentFunction()->GetSlotID();
     537             : 
     538           0 :         rSet.Put( SfxBoolItem( nSId, true ) );
     539             :     }
     540           0 :     rSet.Put( SfxBoolItem( SID_DRAWINGMODE, false ) );
     541           0 :     rSet.Put( SfxBoolItem( SID_DIAMODE, true ) );
     542           0 :     rSet.Put( SfxBoolItem( SID_OUTLINEMODE, false ) );
     543           0 :     rSet.Put( SfxBoolItem( SID_NOTESMODE, false ) );
     544           0 :     rSet.Put( SfxBoolItem( SID_HANDOUTMODE, false ) );
     545             : 
     546           0 :     if (pShell!=NULL && pShell->IsMainViewShell())
     547             :     {
     548           0 :         rSet.DisableItem(SID_SPELL_DIALOG);
     549           0 :         rSet.DisableItem(SID_SEARCH_DLG);
     550             :     }
     551             : 
     552           0 :     if (SfxItemState::DEFAULT == rSet.GetItemState(SID_EXPAND_PAGE))
     553             :     {
     554           0 :         bool bDisable = true;
     555           0 :         if (eEditMode == EM_PAGE)
     556             :         {
     557             :             // At least one of the selected pages has to contain an outline
     558             :             // presentation objects in order to enable the expand page menu
     559             :             // entry.
     560             :             model::PageEnumeration aSelectedPages (
     561             :                 model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
     562           0 :                     mrSlideSorter.GetModel()));
     563           0 :             while (aSelectedPages.HasMoreElements())
     564             :             {
     565           0 :                 SdPage* pPage = aSelectedPages.GetNextElement()->GetPage();
     566           0 :                 SdrObject* pObj = pPage->GetPresObj(PRESOBJ_OUTLINE);
     567           0 :                 if (pObj!=NULL )
     568             :                 {
     569           0 :                     if( !pObj->IsEmptyPresObj() )
     570             :                     {
     571           0 :                         bDisable = false;
     572             :                     }
     573             :                     else
     574             :                     {
     575             :                         // check if the object is in edit, than its temporarily not empty
     576           0 :                         SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
     577           0 :                         if( pTextObj )
     578             :                         {
     579           0 :                             OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject();
     580           0 :                             if( pParaObj )
     581             :                             {
     582           0 :                                 delete pParaObj;
     583           0 :                                 bDisable = false;
     584             :                             }
     585             :                         }
     586             :                     }
     587             :                 }
     588           0 :             }
     589             :         }
     590             : 
     591           0 :         if (bDisable)
     592           0 :             rSet.DisableItem (SID_EXPAND_PAGE);
     593             :     }
     594             : 
     595           0 :     if (SfxItemState::DEFAULT == rSet.GetItemState(SID_SUMMARY_PAGE))
     596             :     {
     597           0 :         bool bDisable = true;
     598           0 :         if (eEditMode == EM_PAGE)
     599             :         {
     600             :             // At least one of the selected pages has to contain a title
     601             :             // presentation objects in order to enable the summary page menu
     602             :             // entry.
     603             :             model::PageEnumeration aSelectedPages (
     604             :                 model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
     605           0 :                     mrSlideSorter.GetModel()));
     606           0 :             while (aSelectedPages.HasMoreElements())
     607             :             {
     608           0 :                 SdPage* pPage = aSelectedPages.GetNextElement()->GetPage();
     609           0 :                 SdrObject* pObj = pPage->GetPresObj(PRESOBJ_TITLE);
     610             : 
     611           0 :                 if (pObj!=NULL && !pObj->IsEmptyPresObj())
     612           0 :                     bDisable = false;
     613           0 :             }
     614             :         }
     615           0 :         if (bDisable)
     616           0 :             rSet.DisableItem (SID_SUMMARY_PAGE);
     617             :     }
     618             : 
     619             :     // starting of presentation possible?
     620           0 :     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_PRESENTATION ) ||
     621           0 :         SfxItemState::DEFAULT == rSet.GetItemState( SID_REHEARSE_TIMINGS ) )
     622             :     {
     623           0 :         bool bDisable = true;
     624             :         model::PageEnumeration aAllPages (
     625           0 :             model::PageEnumerationProvider::CreateAllPagesEnumeration(mrSlideSorter.GetModel()));
     626           0 :         while (aAllPages.HasMoreElements())
     627             :         {
     628           0 :             SdPage* pPage = aAllPages.GetNextElement()->GetPage();
     629             : 
     630           0 :             if( !pPage->IsExcluded() )
     631           0 :                 bDisable = false;
     632             :         }
     633           0 :         if( bDisable || pDocShell->IsPreview())
     634             :         {
     635           0 :             rSet.DisableItem( SID_PRESENTATION );
     636           0 :             rSet.DisableItem( SID_REHEARSE_TIMINGS );
     637           0 :         }
     638             :     }
     639             : 
     640             :     // Disable the rename slots when there are no or more than one slides/master
     641             :     // pages selected; disable the duplicate slot when there are no slides
     642             :     // selected:
     643           0 :     if (rSet.GetItemState(SID_RENAMEPAGE) == SfxItemState::DEFAULT
     644           0 :         || rSet.GetItemState(SID_RENAME_MASTER_PAGE) == SfxItemState::DEFAULT
     645           0 :         || rSet.GetItemState(SID_DUPLICATE_PAGE) == SfxItemState::DEFAULT)
     646             :     {
     647           0 :         int n = mrSlideSorter.GetController().GetPageSelector()
     648           0 :             .GetSelectedPageCount();
     649           0 :         if (n != 1)
     650             :         {
     651           0 :             rSet.DisableItem(SID_RENAMEPAGE);
     652           0 :             rSet.DisableItem(SID_RENAME_MASTER_PAGE);
     653             :         }
     654           0 :         if (n == 0)
     655             :         {
     656           0 :             rSet.DisableItem(SID_DUPLICATE_PAGE);
     657             :         }
     658             :     }
     659             : 
     660           0 :     if (rSet.GetItemState(SID_HIDE_SLIDE) == SfxItemState::DEFAULT
     661           0 :         || rSet.GetItemState(SID_SHOW_SLIDE)  == SfxItemState::DEFAULT)
     662             :     {
     663             :         model::PageEnumeration aSelectedPages (
     664             :             model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
     665           0 :                 mrSlideSorter.GetModel()));
     666           0 :         const SlideExclusionState eState (GetSlideExclusionState(aSelectedPages));
     667           0 :         switch (eState)
     668             :         {
     669             :             case MIXED:
     670             :                 // Show both entries.
     671           0 :                 break;
     672             : 
     673             :             case EXCLUDED:
     674           0 :                 rSet.DisableItem(SID_HIDE_SLIDE);
     675           0 :                 break;
     676             : 
     677             :             case INCLUDED:
     678           0 :                 rSet.DisableItem(SID_SHOW_SLIDE);
     679           0 :                 break;
     680             : 
     681             :             case UNDEFINED:
     682           0 :                 rSet.DisableItem(SID_HIDE_SLIDE);
     683           0 :                 rSet.DisableItem(SID_SHOW_SLIDE);
     684           0 :                 break;
     685           0 :         }
     686             :     }
     687             : 
     688           0 :     PageKind ePageKind = mrSlideSorter.GetModel().GetPageType();
     689           0 :     if ((eEditMode == EM_MASTERPAGE) && (ePageKind != PK_HANDOUT))
     690             :     {
     691           0 :         rSet.DisableItem(SID_ASSIGN_LAYOUT);
     692             :     }
     693             : 
     694           0 :     if ((eEditMode == EM_MASTERPAGE) || (ePageKind==PK_NOTES))
     695             :     {
     696           0 :         rSet.DisableItem(SID_INSERTPAGE);
     697             :     }
     698             : 
     699             :     // Disable some slots when in master page mode.
     700           0 :     if (eEditMode == EM_MASTERPAGE)
     701             :     {
     702           0 :         if (rSet.GetItemState(SID_INSERTPAGE) == SfxItemState::DEFAULT)
     703           0 :             rSet.DisableItem(SID_INSERTPAGE);
     704           0 :         if (rSet.GetItemState(SID_DUPLICATE_PAGE) == SfxItemState::DEFAULT)
     705           0 :             rSet.DisableItem(SID_DUPLICATE_PAGE);
     706             :     }
     707           0 : }
     708             : 
     709           0 : void SlotManager::GetClipboardState ( SfxItemSet& rSet)
     710             : {
     711           0 :     SdTransferable* pTransferClip = SD_MOD()->pTransferClip;
     712             : 
     713           0 :     if (rSet.GetItemState(SID_PASTE)  == SfxItemState::DEFAULT
     714           0 :         || rSet.GetItemState(SID_PASTE_SPECIAL)  == SfxItemState::DEFAULT)
     715             :     {
     716             :         // no own clipboard data?
     717           0 :         if ( !pTransferClip || !pTransferClip->GetDocShell() )
     718             :         {
     719           0 :             rSet.DisableItem(SID_PASTE);
     720           0 :             rSet.DisableItem(SID_PASTE_SPECIAL);
     721             :         }
     722             :         else
     723             :         {
     724           0 :             SfxObjectShell* pTransferDocShell = pTransferClip->GetDocShell();
     725             : 
     726           0 :             if( !pTransferDocShell || static_cast<DrawDocShell*>(pTransferDocShell)->GetDoc()->GetPageCount() <= 1 )
     727             :             {
     728           0 :                 bool bIsPastingSupported (false);
     729             : 
     730             :                 // No or just one page.  Check if there is anything that can be
     731             :                 // pasted via a DrawViewShell.
     732           0 :                 ViewShellBase* pBase = mrSlideSorter.GetViewShellBase();
     733           0 :                 if (pBase != NULL)
     734             :                 {
     735             :                     ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
     736           0 :                         ::boost::dynamic_pointer_cast<DrawViewShell>(pBase->GetMainViewShell()));
     737           0 :                     if (pDrawViewShell.get() != NULL)
     738             :                     {
     739             :                         TransferableDataHelper aDataHelper (
     740             :                             TransferableDataHelper::CreateFromSystemClipboard(
     741           0 :                                 pDrawViewShell->GetActiveWindow()));
     742           0 :                         if (aDataHelper.GetFormatCount() > 0)
     743           0 :                             bIsPastingSupported = true;
     744           0 :                     }
     745             :                 }
     746             : 
     747           0 :                 if ( ! bIsPastingSupported)
     748             :                 {
     749           0 :                     rSet.DisableItem(SID_PASTE);
     750           0 :                     rSet.DisableItem(SID_PASTE_SPECIAL);
     751             :                 }
     752             :             }
     753             :         }
     754             :     }
     755             : 
     756             :     // Cut, copy and paste of master pages is not yet implemented properly
     757           0 :     if (rSet.GetItemState(SID_COPY) == SfxItemState::DEFAULT
     758           0 :         || rSet.GetItemState(SID_PASTE)  == SfxItemState::DEFAULT
     759           0 :         || rSet.GetItemState(SID_PASTE_SPECIAL)  == SfxItemState::DEFAULT
     760           0 :         || rSet.GetItemState(SID_CUT)  == SfxItemState::DEFAULT)
     761             :     {
     762           0 :         if (mrSlideSorter.GetModel().GetEditMode() == EM_MASTERPAGE)
     763             :         {
     764           0 :             if (rSet.GetItemState(SID_CUT) == SfxItemState::DEFAULT)
     765           0 :                 rSet.DisableItem(SID_CUT);
     766           0 :             if (rSet.GetItemState(SID_COPY) == SfxItemState::DEFAULT)
     767           0 :                 rSet.DisableItem(SID_COPY);
     768           0 :             if (rSet.GetItemState(SID_PASTE) == SfxItemState::DEFAULT)
     769           0 :                 rSet.DisableItem(SID_PASTE);
     770           0 :             if (rSet.GetItemState(SID_PASTE_SPECIAL) == SfxItemState::DEFAULT)
     771           0 :                 rSet.DisableItem(SID_PASTE_SPECIAL);
     772             :         }
     773             :     }
     774             : 
     775             :     // Cut, copy, and delete page are disabled when there is no selection.
     776           0 :     if (rSet.GetItemState(SID_CUT) == SfxItemState::DEFAULT
     777           0 :         || rSet.GetItemState(SID_COPY)  == SfxItemState::DEFAULT
     778           0 :         || rSet.GetItemState(SID_DELETE) == SfxItemState::DEFAULT
     779           0 :         || rSet.GetItemState(SID_DELETE_PAGE) == SfxItemState::DEFAULT
     780           0 :         || rSet.GetItemState(SID_DELETE_MASTER_PAGE) == SfxItemState::DEFAULT)
     781             :     {
     782             :         model::PageEnumeration aSelectedPages (
     783             :             model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
     784           0 :                 mrSlideSorter.GetModel()));
     785             : 
     786             :         // For copy to work we have to have at least one selected page.
     787           0 :         if ( ! aSelectedPages.HasMoreElements())
     788           0 :             rSet.DisableItem(SID_COPY);
     789             : 
     790           0 :         bool bDisable = false;
     791             :         // The operations that lead to the deletion of a page are valid if
     792             :         // a) there is at least one selected page
     793             :         // b) deleting the selected pages leaves at least one page in the
     794             :         // document
     795             :         // c) selected master pages must not be used by slides.
     796             : 
     797             :         // Test a).
     798           0 :         if ( ! aSelectedPages.HasMoreElements())
     799           0 :             bDisable = true;
     800             :         // Test b): Count the number of selected pages.  It has to be less
     801             :         // than the number of all pages.
     802           0 :         else if (mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount()
     803           0 :             >= mrSlideSorter.GetController().GetPageSelector().GetPageCount())
     804           0 :             bDisable = true;
     805             :         // Test c): Iterate over the selected pages and look for a master
     806             :         // page that is used by at least one page.
     807           0 :         else while (aSelectedPages.HasMoreElements())
     808             :         {
     809           0 :             SdPage* pPage = aSelectedPages.GetNextElement()->GetPage();
     810           0 :             int nUseCount (mrSlideSorter.GetModel().GetDocument()
     811           0 :                 ->GetMasterPageUserCount(pPage));
     812           0 :             if (nUseCount > 0)
     813             :             {
     814           0 :                 bDisable = true;
     815           0 :                 break;
     816             :             }
     817             :         }
     818             : 
     819           0 :         if (bDisable)
     820             :         {
     821           0 :             rSet.DisableItem(SID_CUT);
     822           0 :             rSet.DisableItem(SID_DELETE_PAGE);
     823           0 :             rSet.DisableItem(SID_DELETE_MASTER_PAGE);
     824           0 :         }
     825             :     }
     826           0 : }
     827             : 
     828           0 : void SlotManager::GetStatusBarState (SfxItemSet& rSet)
     829             : {
     830             :     // page view and layout
     831           0 :     SdPage* pPage      = NULL;
     832           0 :     SdPage* pFirstPage = NULL;
     833             :     sal_uInt16 nFirstPage;
     834             :     sal_Int32 nPageCount;
     835             :     sal_Int32 nActivePageCount;
     836           0 :     sal_uInt16 nSelectedPages = mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount();
     837           0 :     OUString aPageStr;
     838           0 :     OUString aLayoutStr;
     839             : 
     840             :     //Set number of slides
     841           0 :     if (nSelectedPages > 0)
     842             :     {
     843             :         model::PageEnumeration aSelectedPages (
     844             :             model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
     845           0 :                 mrSlideSorter.GetModel()));
     846           0 :         model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
     847           0 :         if (pDescriptor)
     848             :         {
     849           0 :             pPage = pDescriptor->GetPage();
     850           0 :             nFirstPage = (pPage->GetPageNum()/2) + 1;
     851           0 :             nPageCount = mrSlideSorter.GetModel().GetPageCount();
     852           0 :             nActivePageCount = static_cast<sal_Int32>(mrSlideSorter.GetModel().GetDocument()->GetActiveSdPageCount());
     853             : 
     854           0 :             aPageStr = (nPageCount == nActivePageCount) ? SD_RESSTR(STR_SD_PAGE_COUNT) : SD_RESSTR(STR_SD_PAGE_COUNT_CUSTOM);
     855             : 
     856           0 :             aPageStr = aPageStr.replaceFirst("%1", OUString::number(nFirstPage));
     857           0 :             aPageStr = aPageStr.replaceFirst("%2", OUString::number(nPageCount));
     858           0 :             if(nPageCount != nActivePageCount)
     859           0 :                 aPageStr = aPageStr.replaceFirst("%3", OUString::number(nActivePageCount));
     860             :         }
     861           0 :       rSet.Put( SfxStringItem( SID_STATUS_PAGE, aPageStr ) );
     862             :     }
     863             :     //Set layout
     864           0 :     if (nSelectedPages == 1 && pPage != NULL)
     865             :     {
     866           0 :         pFirstPage = pPage;
     867           0 :         aLayoutStr = pFirstPage->GetLayoutName();
     868           0 :         sal_Int32 nIndex = aLayoutStr.indexOf( SD_LT_SEPARATOR );
     869           0 :         if( nIndex != -1 )
     870           0 :             aLayoutStr = aLayoutStr.copy(0, nIndex);
     871           0 :         rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aLayoutStr ) );
     872           0 :     }
     873           0 : }
     874             : 
     875           0 : void SlotManager::ShowSlideShow( SfxRequest& rReq)
     876             : {
     877           0 :     slideshowhelp::ShowSlideShow(rReq, *mrSlideSorter.GetModel().GetDocument());
     878           0 : }
     879             : 
     880           0 : void SlotManager::RenameSlide()
     881             : {
     882           0 :     PageKind ePageKind = mrSlideSorter.GetModel().GetPageType();
     883           0 :     View* pDrView = &mrSlideSorter.GetView();
     884             : 
     885           0 :     if (ePageKind==PK_STANDARD || ePageKind==PK_NOTES)
     886             :     {
     887           0 :         if ( pDrView->IsTextEdit() )
     888             :         {
     889           0 :             pDrView->SdrEndTextEdit();
     890             :         }
     891             : 
     892           0 :         SdPage* pSelectedPage = NULL;
     893             :         model::PageEnumeration aSelectedPages (
     894             :             model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
     895           0 :                 mrSlideSorter.GetModel()));
     896           0 :         if (aSelectedPages.HasMoreElements())
     897           0 :             pSelectedPage = aSelectedPages.GetNextElement()->GetPage();
     898           0 :         if (pSelectedPage != NULL)
     899             :         {
     900           0 :             OUString aTitle( SdResId( STR_TITLE_RENAMESLIDE ) );
     901           0 :             OUString aDescr( SdResId( STR_DESC_RENAMESLIDE ) );
     902           0 :             OUString aPageName = pSelectedPage->GetName();
     903             : 
     904           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     905             :             DBG_ASSERT(pFact, "Dialog creation failed!");
     906             :             boost::scoped_ptr<AbstractSvxNameDialog> aNameDlg(pFact->CreateSvxNameDialog(
     907             :                 mrSlideSorter.GetContentWindow(),
     908           0 :                 aPageName, aDescr));
     909             :             DBG_ASSERT(aNameDlg, "Dialog creation failed!");
     910           0 :             aNameDlg->SetText( aTitle );
     911           0 :             aNameDlg->SetCheckNameHdl( LINK( this, SlotManager, RenameSlideHdl ), true );
     912           0 :             aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE );
     913             : 
     914           0 :             if( aNameDlg->Execute() == RET_OK )
     915             :             {
     916           0 :                 OUString aNewName;
     917           0 :                 aNameDlg->GetName( aNewName );
     918           0 :                 if (aNewName != aPageName)
     919             :                 {
     920             : #ifdef DBG_UTIL
     921             :                     bool bResult =
     922             : #endif
     923             :                         RenameSlideFromDrawViewShell(
     924           0 :                           pSelectedPage->GetPageNum()/2, aNewName );
     925             :                     DBG_ASSERT( bResult, "Couldn't rename slide" );
     926           0 :                 }
     927             :             }
     928           0 :             aNameDlg.reset();
     929             : 
     930             :             // Tell the slide sorter about the name change (necessary for
     931             :             // accessibility.)
     932           0 :             mrSlideSorter.GetController().PageNameHasChanged(
     933           0 :                 (pSelectedPage->GetPageNum()-1)/2, aPageName);
     934           0 :         }
     935             :     }
     936           0 : }
     937             : 
     938           0 : IMPL_LINK(SlotManager, RenameSlideHdl, AbstractSvxNameDialog*, pDialog)
     939             : {
     940           0 :     if( ! pDialog )
     941           0 :         return 0;
     942             : 
     943           0 :     OUString aNewName;
     944           0 :     pDialog->GetName( aNewName );
     945             : 
     946             :     model::SharedPageDescriptor pDescriptor (
     947           0 :         mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide());
     948           0 :     SdPage* pCurrentPage = NULL;
     949           0 :     if (pDescriptor.get() != NULL)
     950           0 :         pCurrentPage = pDescriptor->GetPage();
     951             : 
     952           0 :     return long( (pCurrentPage!=NULL && aNewName == pCurrentPage->GetName())
     953           0 :         || (mrSlideSorter.GetViewShell()
     954           0 :             && mrSlideSorter.GetViewShell()->GetDocSh()->IsNewPageNameValid( aNewName ) ));
     955             : }
     956             : 
     957           0 : bool SlotManager::RenameSlideFromDrawViewShell( sal_uInt16 nPageId, const OUString & rName  )
     958             : {
     959             :     bool   bOutDummy;
     960           0 :     SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument();
     961           0 :     if( pDocument->GetPageByName( rName, bOutDummy ) != SDRPAGE_NOTFOUND )
     962           0 :         return false;
     963             : 
     964           0 :     SdPage* pPageToRename = NULL;
     965           0 :     PageKind ePageKind = mrSlideSorter.GetModel().GetPageType();
     966             : 
     967           0 :     ::svl::IUndoManager* pManager = pDocument->GetDocSh()->GetUndoManager();
     968             : 
     969           0 :     if( mrSlideSorter.GetModel().GetEditMode() == EM_PAGE )
     970             :     {
     971             :         model::SharedPageDescriptor pDescriptor (
     972           0 :             mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide());
     973           0 :         if (pDescriptor.get() != NULL)
     974           0 :             pPageToRename = pDescriptor->GetPage();
     975             : 
     976           0 :         if (pPageToRename != NULL)
     977             :         {
     978             :             // Undo
     979           0 :             SdPage* pUndoPage = pPageToRename;
     980           0 :             SdrLayerAdmin &  rLayerAdmin = pDocument->GetLayerAdmin();
     981           0 :             sal_uInt8 nBackground = rLayerAdmin.GetLayerID( SD_RESSTR( STR_LAYER_BCKGRND ), false );
     982           0 :             sal_uInt8 nBgObj = rLayerAdmin.GetLayerID( SD_RESSTR( STR_LAYER_BCKGRNDOBJ ), false );
     983           0 :             SetOfByte aVisibleLayers = pPageToRename->TRG_GetMasterPageVisibleLayers();
     984             : 
     985             :             // (#67720#)
     986             :             ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
     987             :                 pDocument, pUndoPage, rName, pUndoPage->GetAutoLayout(),
     988           0 :                 aVisibleLayers.IsSet( nBackground ),
     989           0 :                 aVisibleLayers.IsSet( nBgObj ));
     990           0 :             pManager->AddUndoAction( pAction );
     991             : 
     992             :             // rename
     993           0 :             pPageToRename->SetName( rName );
     994             : 
     995           0 :             if( ePageKind == PK_STANDARD )
     996             :             {
     997             :                 // also rename notes-page
     998           0 :                 SdPage* pNotesPage = pDocument->GetSdPage( nPageId, PK_NOTES );
     999           0 :                 if (pNotesPage != NULL)
    1000           0 :                     pNotesPage->SetName (rName);
    1001             :             }
    1002           0 :         }
    1003             :     }
    1004             :     else
    1005             :     {
    1006             :         // rename MasterPage -> rename LayoutTemplate
    1007           0 :         pPageToRename = pDocument->GetMasterSdPage( nPageId, ePageKind );
    1008           0 :         if (pPageToRename != NULL)
    1009             :         {
    1010           0 :             const OUString aOldLayoutName( pPageToRename->GetLayoutName() );
    1011           0 :             pManager->AddUndoAction( new RenameLayoutTemplateUndoAction( pDocument, aOldLayoutName, rName ) );
    1012           0 :             pDocument->RenameLayoutTemplate( aOldLayoutName, rName );
    1013             :         }
    1014             :     }
    1015             : 
    1016           0 :     bool bSuccess = pPageToRename!=NULL && ( rName == pPageToRename->GetName() );
    1017             : 
    1018           0 :     if( bSuccess )
    1019             :     {
    1020             :         // user edited page names may be changed by the page so update control
    1021             :         //        aTabControl.SetPageText( nPageId, rName );
    1022             : 
    1023             :         // set document to modified state
    1024           0 :         pDocument->SetChanged( true );
    1025             : 
    1026             :         // inform navigator about change
    1027           0 :         SfxBoolItem aItem( SID_NAVIGATOR_INIT, true );
    1028           0 :         if (mrSlideSorter.GetViewShell() != NULL)
    1029           0 :             mrSlideSorter.GetViewShell()->GetDispatcher()->Execute(
    1030           0 :                 SID_NAVIGATOR_INIT, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, &aItem, 0L );
    1031             :     }
    1032             : 
    1033           0 :     return bSuccess;
    1034             : }
    1035             : 
    1036             : /** Insert a slide.  The insertion position depends on a) the selection and
    1037             :     b) the mouse position when there is no selection.
    1038             : 
    1039             :     When there is a selection then insertion takes place after the last
    1040             :     slide of the selection.  For this to work all but the last selected
    1041             :     slide are deselected first.
    1042             : 
    1043             :     Otherwise, when there is no selection but the insertion marker is visible
    1044             :     the slide is inserted at that position.  The slide before that marker is
    1045             :     selected first.
    1046             : 
    1047             :     When both the selection and the insertion marker are not visible--can
    1048             :     that happen?--the new slide is inserted after the last slide.
    1049             : */
    1050           0 : void SlotManager::InsertSlide (SfxRequest& rRequest)
    1051             : {
    1052           0 :     const sal_Int32 nInsertionIndex (GetInsertionPosition());
    1053             : 
    1054           0 :     PageSelector::BroadcastLock aBroadcastLock (mrSlideSorter);
    1055             : 
    1056           0 :     SdPage* pNewPage = NULL;
    1057           0 :     if (mrSlideSorter.GetModel().GetEditMode() == EM_PAGE)
    1058             :     {
    1059             :         SlideSorterViewShell* pShell = dynamic_cast<SlideSorterViewShell*>(
    1060           0 :             mrSlideSorter.GetViewShell());
    1061           0 :         if (pShell != NULL)
    1062             :         {
    1063             :             pNewPage = pShell->CreateOrDuplicatePage (
    1064             :                 rRequest,
    1065           0 :                 mrSlideSorter.GetModel().GetPageType(),
    1066             :                 nInsertionIndex>=0
    1067           0 :                     ? mrSlideSorter.GetModel().GetPageDescriptor(nInsertionIndex)->GetPage()
    1068           0 :                         : NULL);
    1069             :         }
    1070             :     }
    1071             :     else
    1072             :     {
    1073             :         // Use the API to create a new page.
    1074           0 :         SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument();
    1075             :         Reference<drawing::XMasterPagesSupplier> xMasterPagesSupplier (
    1076           0 :             pDocument->getUnoModel(), UNO_QUERY);
    1077           0 :         if (xMasterPagesSupplier.is())
    1078             :         {
    1079             :             Reference<drawing::XDrawPages> xMasterPages (
    1080           0 :                 xMasterPagesSupplier->getMasterPages());
    1081           0 :             if (xMasterPages.is())
    1082             :             {
    1083           0 :                 xMasterPages->insertNewByIndex (nInsertionIndex+1);
    1084             : 
    1085             :                 // Create shapes for the default layout.
    1086             :                 pNewPage = pDocument->GetMasterSdPage(
    1087           0 :                     (sal_uInt16)(nInsertionIndex+1), PK_STANDARD);
    1088           0 :                 pNewPage->CreateTitleAndLayout (true,true);
    1089           0 :             }
    1090           0 :         }
    1091             :     }
    1092           0 :     if (pNewPage == NULL)
    1093           0 :         return;
    1094             : 
    1095             :     // When a new page has been inserted then select it, make it the
    1096             :     // current page, and focus it.
    1097           0 :     view::SlideSorterView::DrawLock aDrawLock (mrSlideSorter);
    1098           0 :     PageSelector::UpdateLock aUpdateLock (mrSlideSorter);
    1099           0 :     mrSlideSorter.GetController().GetPageSelector().DeselectAllPages();
    1100           0 :     mrSlideSorter.GetController().GetPageSelector().SelectPage(pNewPage);
    1101             : }
    1102             : 
    1103           0 : void SlotManager::DuplicateSelectedSlides (SfxRequest& rRequest)
    1104             : {
    1105             :     // Create a list of the pages that are to be duplicated.  The process of
    1106             :     // duplication alters the selection.
    1107           0 :     sal_Int32 nInsertPosition (0);
    1108           0 :     ::std::vector<SdPage*> aPagesToDuplicate;
    1109             :     model::PageEnumeration aSelectedPages (
    1110           0 :         model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel()));
    1111           0 :     while (aSelectedPages.HasMoreElements())
    1112             :     {
    1113           0 :         model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
    1114           0 :         if (pDescriptor && pDescriptor->GetPage())
    1115             :         {
    1116           0 :             aPagesToDuplicate.push_back(pDescriptor->GetPage());
    1117           0 :             nInsertPosition = pDescriptor->GetPage()->GetPageNum()+2;
    1118             :         }
    1119           0 :     }
    1120             : 
    1121             :     // Duplicate the pages in aPagesToDuplicate and collect the newly
    1122             :     // created pages in aPagesToSelect.
    1123           0 :     const bool bUndo (aPagesToDuplicate.size()>1 && mrSlideSorter.GetView().IsUndoEnabled());
    1124           0 :     if (bUndo)
    1125           0 :         mrSlideSorter.GetView().BegUndo(SD_RESSTR(STR_INSERTPAGE));
    1126             : 
    1127           0 :     ::std::vector<SdPage*> aPagesToSelect;
    1128           0 :     for(::std::vector<SdPage*>::const_iterator
    1129           0 :             iPage(aPagesToDuplicate.begin()),
    1130           0 :             iEnd(aPagesToDuplicate.end());
    1131             :         iPage!=iEnd;
    1132             :         ++iPage, nInsertPosition+=2)
    1133             :     {
    1134             :         aPagesToSelect.push_back(
    1135           0 :             mrSlideSorter.GetViewShell()->CreateOrDuplicatePage(
    1136           0 :                 rRequest, PK_STANDARD, *iPage, nInsertPosition));
    1137             :     }
    1138           0 :     aPagesToDuplicate.clear();
    1139             : 
    1140           0 :     if (bUndo)
    1141           0 :         mrSlideSorter.GetView().EndUndo();
    1142             : 
    1143             :     // Set the selection to the pages in aPagesToSelect.
    1144           0 :     PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector());
    1145           0 :     rSelector.DeselectAllPages();
    1146             :     ::std::for_each (
    1147             :         aPagesToSelect.begin(),
    1148             :         aPagesToSelect.end(),
    1149             :         ::boost::bind(
    1150             :             static_cast<void (PageSelector::*)(const SdPage*)>(&PageSelector::SelectPage),
    1151             :             ::boost::ref(rSelector),
    1152           0 :             _1));
    1153           0 : }
    1154             : 
    1155           0 : void SlotManager::ChangeSlideExclusionState (
    1156             :     const model::SharedPageDescriptor& rpDescriptor,
    1157             :     const bool bExcludeSlide)
    1158             : {
    1159           0 :     if (rpDescriptor)
    1160             :     {
    1161           0 :         mrSlideSorter.GetView().SetState(
    1162             :             rpDescriptor,
    1163             :             model::PageDescriptor::ST_Excluded,
    1164           0 :             bExcludeSlide);
    1165             :     }
    1166             :     else
    1167             :     {
    1168             :         model::PageEnumeration aSelectedPages (
    1169             :             model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
    1170           0 :                 mrSlideSorter.GetModel()));
    1171           0 :         while (aSelectedPages.HasMoreElements())
    1172             :         {
    1173           0 :             model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
    1174           0 :             mrSlideSorter.GetView().SetState(
    1175             :                 pDescriptor,
    1176             :                 model::PageDescriptor::ST_Excluded,
    1177           0 :                 bExcludeSlide);
    1178           0 :         }
    1179             :     }
    1180             : 
    1181           0 :     SfxBindings& rBindings (mrSlideSorter.GetViewShell()->GetViewFrame()->GetBindings());
    1182           0 :     rBindings.Invalidate(SID_PRESENTATION);
    1183           0 :     rBindings.Invalidate(SID_REHEARSE_TIMINGS);
    1184           0 :     rBindings.Invalidate(SID_HIDE_SLIDE);
    1185           0 :     rBindings.Invalidate(SID_SHOW_SLIDE);
    1186           0 :     mrSlideSorter.GetModel().GetDocument()->SetChanged();
    1187           0 : }
    1188             : 
    1189           0 : sal_Int32 SlotManager::GetInsertionPosition()
    1190             : {
    1191           0 :     PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector());
    1192             : 
    1193             :     // The insertion indicator is preferred.  After all the user explicitly
    1194             :     // used it to define the insertion position.
    1195           0 :     if (mrSlideSorter.GetController().GetInsertionIndicatorHandler()->IsActive())
    1196             :     {
    1197             :         // Select the page before the insertion indicator.
    1198           0 :         return mrSlideSorter.GetController().GetInsertionIndicatorHandler()->GetInsertionPageIndex()
    1199           0 :             - 1;
    1200             :     }
    1201             : 
    1202             :     // Is there a stored insertion position?
    1203           0 :     else if (mrSlideSorter.GetController().GetSelectionManager()->GetInsertionPosition() >= 0)
    1204             :     {
    1205           0 :         return mrSlideSorter.GetController().GetSelectionManager()->GetInsertionPosition() - 1;
    1206             :     }
    1207             : 
    1208             :     // Use the index of the last selected slide.
    1209           0 :     else if (rSelector.GetSelectedPageCount() > 0)
    1210             :     {
    1211           0 :         for (int nIndex=rSelector.GetPageCount()-1; nIndex>=0; --nIndex)
    1212           0 :             if (rSelector.IsPageSelected(nIndex))
    1213           0 :                 return nIndex;
    1214             : 
    1215             :         // We should never get here.
    1216             :         OSL_ASSERT(false);
    1217           0 :         return rSelector.GetPageCount() - 1;
    1218             :     }
    1219             : 
    1220             :     // Select the last page when there is at least one page.
    1221           0 :     else if (rSelector.GetPageCount() > 0)
    1222             :     {
    1223           0 :         return rSelector.GetPageCount() - 1;
    1224             :     }
    1225             : 
    1226             :     // Hope for the best that CreateOrDuplicatePage() can cope with an empty
    1227             :     // selection.
    1228             :     else
    1229             :     {
    1230             :         // We should never get here because there has to be at least one page.
    1231             :         OSL_ASSERT(false);
    1232           0 :         return -1;
    1233             :     }
    1234             : }
    1235             : 
    1236          72 : void SlotManager::NotifyEditModeChange()
    1237             : {
    1238          72 :     SfxBindings& rBindings (mrSlideSorter.GetViewShell()->GetViewFrame()->GetBindings());
    1239          72 :     rBindings.Invalidate(SID_PRESENTATION);
    1240          72 :     rBindings.Invalidate(SID_INSERTPAGE);
    1241          72 :     rBindings.Invalidate(SID_DUPLICATE_PAGE);
    1242          72 : }
    1243             : 
    1244             : namespace {
    1245             : 
    1246           0 : SlideExclusionState GetSlideExclusionState (model::PageEnumeration& rPageSet)
    1247             : {
    1248           0 :     SlideExclusionState eState (UNDEFINED);
    1249             : 
    1250             :     // Get toggle state of the selected pages.
    1251           0 :     while (rPageSet.HasMoreElements() && eState!=MIXED)
    1252             :     {
    1253           0 :         const bool bState = rPageSet.GetNextElement()->GetPage()->IsExcluded();
    1254           0 :         switch (eState)
    1255             :         {
    1256             :             case UNDEFINED:
    1257             :                 // Use the first selected page to set the initial value.
    1258           0 :                 eState = bState ? EXCLUDED : INCLUDED;
    1259           0 :                 break;
    1260             : 
    1261             :             case EXCLUDED:
    1262             :                 // The pages before where all not part of the show,
    1263             :                 // this one is.
    1264           0 :                 if ( ! bState)
    1265           0 :                     eState = MIXED;
    1266           0 :                 break;
    1267             : 
    1268             :             case INCLUDED:
    1269             :                 // The pages before where all part of the show,
    1270             :                 // this one is not.
    1271           0 :                 if (bState)
    1272           0 :                     eState = MIXED;
    1273           0 :                 break;
    1274             : 
    1275             :             default:
    1276             :                 // No need to change anything.
    1277           0 :                 break;
    1278             :         }
    1279             :     }
    1280             : 
    1281           0 :     return eState;
    1282             : }
    1283             : 
    1284             : } // end of anonymous namespace
    1285             : 
    1286          66 : } } } // end of namespace ::sd::slidesorter::controller
    1287             : 
    1288             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11