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

Generated by: LCOV version 1.10