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

Generated by: LCOV version 1.10