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

Generated by: LCOV version 1.10