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

Generated by: LCOV version 1.10