1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsSlotManager.cxx,v $
10 * $Revision: 1.34.52.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "precompiled_sd.hxx"
33 #include <com/sun/star/presentation/XPresentation2.hpp>
35 #include "controller/SlsSlotManager.hxx"
36 #include "SlideSorter.hxx"
37 #include "SlideSorterViewShell.hxx"
38 #include "controller/SlideSorterController.hxx"
39 #include "controller/SlsPageSelector.hxx"
40 #include "controller/SlsClipboard.hxx"
41 #include "controller/SlsSelectionFunction.hxx"
42 #include "controller/SlsFocusManager.hxx"
43 #include "controller/SlsCurrentSlideManager.hxx"
44 #include "controller/SlsSelectionManager.hxx"
45 #include "SlsHideSlideFunction.hxx"
46 #include "SlsCommand.hxx"
47 #include "model/SlideSorterModel.hxx"
48 #include "model/SlsPageEnumerationProvider.hxx"
49 #include "model/SlsPageDescriptor.hxx"
50 #include "view/SlideSorterView.hxx"
51 #include "view/SlsLayouter.hxx"
52 #include "view/SlsViewOverlay.hxx"
53 #include "framework/FrameworkHelper.hxx"
57 #include "fucushow.hxx"
58 #include "fusldlg.hxx"
59 #include "fuexpand.hxx"
60 #include "fusumry.hxx"
61 #include "fuscale.hxx"
62 #include "slideshow.hxx"
64 #include "strings.hrc"
65 #include "sdresid.hxx"
66 #include "drawdoc.hxx"
67 #include "DrawDocShell.hxx"
68 #include "ViewShellBase.hxx"
69 #include "ViewShellImplementation.hxx"
71 #include "TaskPaneViewShell.hxx"
72 #include "FrameView.hxx"
73 #include "zoomlist.hxx"
78 #include "unmodpg.hxx"
79 #include "DrawViewShell.hxx"
81 #include <sfx2/request.hxx>
82 #include <sfx2/viewfrm.hxx>
83 #include <sfx2/topfrm.hxx>
84 #include <sfx2/bindings.hxx>
85 #include <sfx2/dispatch.hxx>
86 #include <svx/svxids.hrc>
87 #include <svx/zoomitem.hxx>
88 #include <svx/svxdlg.hxx>
89 #include <svx/dialogs.hrc>
90 #include <vcl/msgbox.hxx>
91 #include <svtools/intitem.hxx>
92 #include <svtools/whiter.hxx>
93 #include <svtools/itempool.hxx>
94 #include <svtools/aeitem.hxx>
95 #include <com/sun/star/presentation/FadeEffect.hpp>
96 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
97 #include <com/sun/star/drawing/XDrawPages.hpp>
98 #include <vcl/svapp.hxx>
100 using namespace ::com::sun::star
;
101 using namespace ::com::sun::star::uno
;
102 using namespace ::com::sun::star::presentation
;
104 namespace sd
{ namespace slidesorter
{ namespace controller
{
106 SlotManager::SlotManager (SlideSorter
& rSlideSorter
)
107 : mrSlideSorter(rSlideSorter
),
115 SlotManager::~SlotManager (void)
122 void SlotManager::FuTemporary (SfxRequest
& rRequest
)
124 SdDrawDocument
* pDocument
= mrSlideSorter
.GetModel().GetDocument();
126 SlideSorterViewShell
* pShell
127 = dynamic_cast<SlideSorterViewShell
*>(mrSlideSorter
.GetViewShell());
131 switch (rRequest
.GetSlot())
133 case SID_PRESENTATION
:
134 case SID_REHEARSE_TIMINGS
:
135 ShowSlideShow (rRequest
);
142 HideSlideFunction::Create(mrSlideSorter
, rRequest
);
145 case SID_PAGES_PER_ROW
:
146 if (rRequest
.GetArgs() != NULL
)
148 SFX_REQUEST_ARG(rRequest
, pPagesPerRow
, SfxUInt16Item
,
149 SID_PAGES_PER_ROW
, FALSE
);
150 if (pPagesPerRow
!= NULL
)
152 sal_Int32 nColumnCount
= pPagesPerRow
->GetValue();
153 // Force the given number of columns by setting the
154 // minimal and maximal number of columns to the same
156 mrSlideSorter
.GetView().GetLayouter().SetColumnCount (
157 nColumnCount
, nColumnCount
);
158 // Force a repaint and re-layout.
159 pShell
->ArrangeGUIElements ();
160 // Rearrange the UI-elements controlled by the
161 // controller and force a rearrangement of the view.
162 mrSlideSorter
.GetController().Rearrange(true);
169 mrSlideSorter
.GetController().GetPageSelector().SelectAllPages();
173 case SID_SLIDE_TRANSITIONS_PANEL
:
175 // Make the slide transition panel visible (expand it) in the
177 if (mrSlideSorter
.GetViewShellBase() != NULL
)
178 framework::FrameworkHelper::Instance(*mrSlideSorter
.GetViewShellBase())
179 ->RequestTaskPanel(sd::framework::FrameworkHelper::msSlideTransitionTaskPanelURL
);
184 case SID_PRESENTATION_DLG
:
185 FuSlideShowDlg::Create (
187 mrSlideSorter
.GetView().GetWindow(),
188 &mrSlideSorter
.GetView(),
193 case SID_CUSTOMSHOW_DLG
:
194 FuCustomShowDlg::Create (
196 mrSlideSorter
.GetView().GetWindow(),
197 &mrSlideSorter
.GetView(),
202 case SID_EXPAND_PAGE
:
203 FuExpandPage::Create (
205 mrSlideSorter
.GetView().GetWindow(),
206 &mrSlideSorter
.GetView(),
211 case SID_SUMMARY_PAGE
:
212 FuSummaryPage::Create (
214 mrSlideSorter
.GetView().GetWindow(),
215 &mrSlideSorter
.GetView(),
221 case SID_INSERT_MASTER_PAGE
:
222 InsertSlide(rRequest
);
226 case SID_DELETE_PAGE
:
227 case SID_DELETE_MASTER_PAGE
:
228 case SID_DELETE
: // we need SID_CUT to handle the delete key
229 // (DEL -> accelerator -> SID_CUT).
230 if (mrSlideSorter
.GetModel().GetPageCount() > 1)
232 mrSlideSorter
.GetController().GetSelectionManager()->DeleteSelectedPages();
239 case SID_RENAME_MASTER_PAGE
:
244 case SID_ASSIGN_LAYOUT
:
246 SFX_REQUEST_ARG (rRequest
, pWhatPage
, SfxUInt32Item
, ID_VAL_WHATPAGE
, FALSE
);
247 SFX_REQUEST_ARG (rRequest
, pWhatLayout
, SfxUInt32Item
, ID_VAL_WHATLAYOUT
, FALSE
);
248 pShell
->mpImpl
->AssignLayout(
249 pDocument
->GetSdPage((USHORT
)pWhatPage
->GetValue(),
250 mrSlideSorter
.GetModel().GetPageType()),
251 (AutoLayout
)pWhatLayout
->GetValue());
264 void SlotManager::FuPermanent (SfxRequest
& rRequest
)
266 ViewShell
* pShell
= mrSlideSorter
.GetViewShell();
270 if(pShell
->GetCurrentFunction().is())
272 FunctionReference xEmpty
;
273 if (pShell
->GetOldFunction() == pShell
->GetCurrentFunction())
274 pShell
->SetOldFunction(xEmpty
);
276 pShell
->GetCurrentFunction()->Deactivate();
277 pShell
->SetCurrentFunction(xEmpty
);
280 switch(rRequest
.GetSlot())
282 case SID_OBJECT_SELECT
:
283 pShell
->SetCurrentFunction( SelectionFunction::Create(mrSlideSorter
, rRequest
) );
291 if(pShell
->GetOldFunction().is())
293 pShell
->GetOldFunction()->Deactivate();
294 FunctionReference xEmpty
;
295 pShell
->SetOldFunction(xEmpty
);
298 if(pShell
->GetCurrentFunction().is())
300 pShell
->GetCurrentFunction()->Activate();
301 pShell
->SetOldFunction(pShell
->GetCurrentFunction());
304 //! das ist nur bis das ENUM-Slots sind
305 // Invalidate( SID_OBJECT_SELECT );
308 void SlotManager::FuSupport (SfxRequest
& rRequest
)
310 switch (rRequest
.GetSlot())
312 case SID_STYLE_FAMILY
:
313 if (rRequest
.GetArgs() != NULL
)
315 SdDrawDocument
* pDocument
316 = mrSlideSorter
.GetModel().GetDocument();
317 if (pDocument
!= NULL
)
319 const SfxPoolItem
& rItem (
320 rRequest
.GetArgs()->Get(SID_STYLE_FAMILY
));
321 pDocument
->GetDocSh()->SetStyleFamily(
322 static_cast<const SfxUInt16Item
&>(rItem
).GetValue());
329 SdTransferable
* pTransferClip
= SD_MOD()->pTransferClip
;
332 SfxObjectShell
* pTransferDocShell
= pTransferClip
->GetDocShell();
334 DrawDocShell
* pDocShell
= dynamic_cast<DrawDocShell
*>(pTransferDocShell
);
335 if (pDocShell
&& pDocShell
->GetDoc()->GetPageCount() > 1)
337 mrSlideSorter
.GetController().GetClipboard().HandleSlotCall(rRequest
);
341 ViewShellBase
* pBase
= mrSlideSorter
.GetViewShellBase();
344 ::boost::shared_ptr
<DrawViewShell
> pDrawViewShell (
345 ::boost::dynamic_pointer_cast
<DrawViewShell
>(pBase
->GetMainViewShell()));
346 if (pDrawViewShell
.get() != NULL
)
347 pDrawViewShell
->FuSupport(rRequest
);
355 mrSlideSorter
.GetController().GetClipboard().HandleSlotCall(rRequest
);
358 case SID_DRAWINGMODE
:
360 case SID_HANDOUTMODE
:
362 case SID_OUTLINEMODE
:
364 ViewShellBase
* pBase
= mrSlideSorter
.GetViewShellBase();
367 framework::FrameworkHelper::Instance(*pBase
)->HandleModeChangeSlot(
368 rRequest
.GetSlot(), rRequest
);
376 SlideSorterViewShell
* pViewShell
377 = dynamic_cast<SlideSorterViewShell
*>(mrSlideSorter
.GetViewShell());
378 if (pViewShell
!= NULL
)
379 pViewShell
->ImpSidUndo (FALSE
, rRequest
);
385 SlideSorterViewShell
* pViewShell
386 = dynamic_cast<SlideSorterViewShell
*>(mrSlideSorter
.GetViewShell());
387 if (pViewShell
!= NULL
)
388 pViewShell
->ImpSidRedo (FALSE
, rRequest
);
400 void SlotManager::ExecCtrl (SfxRequest
& rRequest
)
402 ViewShell
* pViewShell
= mrSlideSorter
.GetViewShell();
403 USHORT nSlot
= rRequest
.GetSlot();
408 // Undo-Manager leeren
409 mrSlideSorter
.GetModel().GetDocument()->GetDocSh()->ClearUndoBuffer();
411 // Normale Weiterleitung an ViewFrame zur Ausfuehrung
412 if (pViewShell
!= NULL
)
413 pViewShell
->GetViewFrame()->ExecuteSlot(rRequest
);
415 // Muss sofort beendet werden
419 case SID_OUTPUT_QUALITY_COLOR
:
420 case SID_OUTPUT_QUALITY_GRAYSCALE
:
421 case SID_OUTPUT_QUALITY_BLACKWHITE
:
422 case SID_OUTPUT_QUALITY_CONTRAST
:
425 if (pViewShell
!= NULL
)
426 pViewShell
->ExecReq (rRequest
);
430 case SID_MAIL_SCROLLBODY_PAGEDOWN
:
432 if (pViewShell
!= NULL
)
433 pViewShell
->ExecReq (rRequest
);
437 case SID_OPT_LOCALE_CHANGED
:
439 mrSlideSorter
.GetController().UpdateAllPages();
440 if (pViewShell
!= NULL
)
441 pViewShell
->UpdatePreview (pViewShell
->GetActualPage());
447 // We have to handle the SID_SEARCH_DLG slot explicitly because
448 // in some cases (when the slide sorter is displayed in the
449 // center pane) we want to disable the search dialog. Therefore
450 // we have to handle the execution of that slot as well.
451 // We try to do that by forwarding the request to the view frame
452 // of the view shell.
453 if (pViewShell
!= NULL
)
454 pViewShell
->GetViewFrame()->ExecuteSlot(rRequest
);
465 void SlotManager::GetAttrState (SfxItemSet
& rSet
)
467 // Iteratate over all items.
468 SfxWhichIter
aIter (rSet
);
469 USHORT nWhich
= aIter
.FirstWhich();
472 USHORT
nSlotId (nWhich
);
473 if (SfxItemPool::IsWhich(nWhich
) && mrSlideSorter
.GetViewShell()!=NULL
)
474 nSlotId
= mrSlideSorter
.GetViewShell()->GetPool().GetSlotId(nWhich
);
477 case SID_PAGES_PER_ROW
:
481 (USHORT
)mrSlideSorter
.GetView().GetLayouter().GetColumnCount()
486 nWhich
= aIter
.NextWhich();
493 void SlotManager::GetCtrlState (SfxItemSet
& rSet
)
495 if (rSet
.GetItemState(SID_RELOAD
) != SFX_ITEM_UNKNOWN
)
497 // "Letzte Version" vom SFx en/disablen lassen
498 ViewShell
* pShell
= mrSlideSorter
.GetViewShell();
501 SfxViewFrame
* pSlideViewFrame
= pShell
->GetViewFrame();
502 DBG_ASSERT(pSlideViewFrame
!=NULL
,
503 "SlideSorterController::GetCtrlState: ViewFrame not found");
504 if (pSlideViewFrame
->ISA(SfxTopViewFrame
))
506 pSlideViewFrame
->GetSlotState (SID_RELOAD
, NULL
, &rSet
);
508 else // MI sagt: kein MDIFrame --> disablen
510 rSet
.DisableItem(SID_RELOAD
);
516 if (rSet
.GetItemState(SID_OUTPUT_QUALITY_COLOR
)==SFX_ITEM_AVAILABLE
517 ||rSet
.GetItemState(SID_OUTPUT_QUALITY_GRAYSCALE
)==SFX_ITEM_AVAILABLE
518 ||rSet
.GetItemState(SID_OUTPUT_QUALITY_BLACKWHITE
)==SFX_ITEM_AVAILABLE
519 ||rSet
.GetItemState(SID_OUTPUT_QUALITY_CONTRAST
)==SFX_ITEM_AVAILABLE
)
521 ULONG nMode
= mrSlideSorter
.GetView().GetWindow()->GetDrawMode();
526 case ::sd::ViewShell::OUTPUT_DRAWMODE_COLOR
:
529 case ::sd::ViewShell::OUTPUT_DRAWMODE_GRAYSCALE
:
532 case ::sd::ViewShell::OUTPUT_DRAWMODE_BLACKWHITE
:
535 case ::sd::ViewShell::OUTPUT_DRAWMODE_CONTRAST
:
540 rSet
.Put (SfxBoolItem (SID_OUTPUT_QUALITY_COLOR
,
541 (BOOL
)(nQuality
==0)));
542 rSet
.Put (SfxBoolItem (SID_OUTPUT_QUALITY_GRAYSCALE
,
543 (BOOL
)(nQuality
==1)));
544 rSet
.Put (SfxBoolItem (SID_OUTPUT_QUALITY_BLACKWHITE
,
545 (BOOL
)(nQuality
==2)));
546 rSet
.Put (SfxBoolItem (SID_OUTPUT_QUALITY_CONTRAST
,
547 (BOOL
)(nQuality
==3)));
550 if (rSet
.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN
) == SFX_ITEM_AVAILABLE
)
552 rSet
.Put (SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN
, TRUE
));
559 void SlotManager::GetMenuState ( SfxItemSet
& rSet
)
561 EditMode eEditMode
= mrSlideSorter
.GetModel().GetEditMode();
562 ViewShell
* pShell
= mrSlideSorter
.GetViewShell();
563 DrawDocShell
* pDocShell
= mrSlideSorter
.GetModel().GetDocument()->GetDocSh();
565 if (pShell
!=NULL
&& pShell
->GetCurrentFunction().is())
567 USHORT nSId
= pShell
->GetCurrentFunction()->GetSlotID();
569 rSet
.Put( SfxBoolItem( nSId
, TRUE
) );
571 rSet
.Put( SfxBoolItem( SID_DRAWINGMODE
, FALSE
) );
572 rSet
.Put( SfxBoolItem( SID_DIAMODE
, TRUE
) );
573 rSet
.Put( SfxBoolItem( SID_OUTLINEMODE
, FALSE
) );
574 rSet
.Put( SfxBoolItem( SID_NOTESMODE
, FALSE
) );
575 rSet
.Put( SfxBoolItem( SID_HANDOUTMODE
, FALSE
) );
577 // Vorlagenkatalog darf nicht aufgerufen werden
578 rSet
.DisableItem(SID_STYLE_CATALOG
);
580 if (pShell
!=NULL
&& pShell
->IsMainViewShell())
582 rSet
.DisableItem(SID_SPELL_DIALOG
);
583 rSet
.DisableItem(SID_SEARCH_DLG
);
586 if (SFX_ITEM_AVAILABLE
== rSet
.GetItemState(SID_EXPAND_PAGE
))
588 bool bDisable
= true;
589 if (eEditMode
== EM_PAGE
)
591 // At least one of the selected pages has to contain an outline
592 // presentation objects in order to enable the expand page menu
594 model::PageEnumeration
aSelectedPages (
595 model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
596 mrSlideSorter
.GetModel()));
597 while (aSelectedPages
.HasMoreElements())
599 SdPage
* pPage
= aSelectedPages
.GetNextElement()->GetPage();
600 SdrObject
* pObj
= pPage
->GetPresObj(PRESOBJ_OUTLINE
);
601 if (pObj
!=NULL
&& !pObj
->IsEmptyPresObj())
607 rSet
.DisableItem (SID_EXPAND_PAGE
);
610 if (SFX_ITEM_AVAILABLE
== rSet
.GetItemState(SID_SUMMARY_PAGE
))
612 bool bDisable
= true;
613 if (eEditMode
== EM_PAGE
)
615 // At least one of the selected pages has to contain a title
616 // presentation objects in order to enable the summary page menu
618 model::PageEnumeration
aSelectedPages (
619 model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
620 mrSlideSorter
.GetModel()));
621 while (aSelectedPages
.HasMoreElements())
623 SdPage
* pPage
= aSelectedPages
.GetNextElement()->GetPage();
624 SdrObject
* pObj
= pPage
->GetPresObj(PRESOBJ_TITLE
);
626 if (pObj
!=NULL
&& !pObj
->IsEmptyPresObj())
631 rSet
.DisableItem (SID_SUMMARY_PAGE
);
634 // Starten der Praesentation moeglich?
635 if( SFX_ITEM_AVAILABLE
== rSet
.GetItemState( SID_PRESENTATION
) ||
636 SFX_ITEM_AVAILABLE
== rSet
.GetItemState( SID_REHEARSE_TIMINGS
) )
638 BOOL bDisable
= TRUE
;
639 model::PageEnumeration
aAllPages (
640 model::PageEnumerationProvider::CreateAllPagesEnumeration(mrSlideSorter
.GetModel()));
641 while (aAllPages
.HasMoreElements())
643 SdPage
* pPage
= aAllPages
.GetNextElement()->GetPage();
645 if( !pPage
->IsExcluded() )
648 if( bDisable
|| pDocShell
->IsPreview())
650 rSet
.DisableItem( SID_PRESENTATION
);
651 rSet
.DisableItem( SID_REHEARSE_TIMINGS
);
656 // Disable the rename slots when there are no or more than one slides/master
658 if (rSet
.GetItemState(SID_RENAMEPAGE
) == SFX_ITEM_AVAILABLE
659 || rSet
.GetItemState(SID_RENAME_MASTER_PAGE
) == SFX_ITEM_AVAILABLE
)
661 if (mrSlideSorter
.GetController().GetPageSelector().GetSelectedPageCount() != 1)
663 rSet
.DisableItem(SID_RENAMEPAGE
);
664 rSet
.DisableItem(SID_RENAME_MASTER_PAGE
);
668 if (rSet
.GetItemState(SID_HIDE_SLIDE
) == SFX_ITEM_AVAILABLE
669 || rSet
.GetItemState(SID_SHOW_SLIDE
) == SFX_ITEM_AVAILABLE
)
671 model::PageEnumeration
aSelectedPages (
672 model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
673 mrSlideSorter
.GetModel()));
674 HideSlideFunction::ExclusionState
eState (
675 HideSlideFunction::GetExclusionState(aSelectedPages
));
678 case HideSlideFunction::MIXED
:
679 // Show both entries.
682 case HideSlideFunction::EXCLUDED
:
683 rSet
.DisableItem(SID_HIDE_SLIDE
);
686 case HideSlideFunction::INCLUDED
:
687 rSet
.DisableItem(SID_SHOW_SLIDE
);
690 case HideSlideFunction::UNDEFINED
:
691 rSet
.DisableItem(SID_HIDE_SLIDE
);
692 rSet
.DisableItem(SID_SHOW_SLIDE
);
701 void SlotManager::GetClipboardState ( SfxItemSet
& rSet
)
703 SdTransferable
* pTransferClip
= SD_MOD()->pTransferClip
;
705 if (rSet
.GetItemState(SID_PASTE
) == SFX_ITEM_AVAILABLE
706 || rSet
.GetItemState(SID_PASTE_SPECIAL
) == SFX_ITEM_AVAILABLE
)
708 // Keine eigenen Clipboard-Daten?
709 if ( !pTransferClip
|| !pTransferClip
->GetDocShell() )
711 rSet
.DisableItem(SID_PASTE
);
712 rSet
.DisableItem(SID_PASTE_SPECIAL
);
716 SfxObjectShell
* pTransferDocShell
= pTransferClip
->GetDocShell();
718 if( !pTransferDocShell
|| ( (DrawDocShell
*) pTransferDocShell
)->GetDoc()->GetPageCount() <= 1 )
720 bool bIsPastingSupported (false);
722 // No or just one page. Check if there is anything that can be
723 // pasted via a DrawViewShell.
724 ViewShellBase
* pBase
= mrSlideSorter
.GetViewShellBase();
727 ::boost::shared_ptr
<DrawViewShell
> pDrawViewShell (
728 ::boost::dynamic_pointer_cast
<DrawViewShell
>(pBase
->GetMainViewShell()));
729 if (pDrawViewShell
.get() != NULL
)
731 TransferableDataHelper
aDataHelper (
732 TransferableDataHelper::CreateFromSystemClipboard(
733 pDrawViewShell
->GetActiveWindow()));
734 if (aDataHelper
.GetFormatCount() > 0)
735 bIsPastingSupported
= true;
739 if ( ! bIsPastingSupported
)
741 rSet
.DisableItem(SID_PASTE
);
742 rSet
.DisableItem(SID_PASTE_SPECIAL
);
748 // Cut, copy and paste of master pages is not yet implemented properly
749 if (rSet
.GetItemState(SID_COPY
) == SFX_ITEM_AVAILABLE
750 || rSet
.GetItemState(SID_PASTE
) == SFX_ITEM_AVAILABLE
751 || rSet
.GetItemState(SID_PASTE_SPECIAL
) == SFX_ITEM_AVAILABLE
752 || rSet
.GetItemState(SID_CUT
) == SFX_ITEM_AVAILABLE
)
754 if (mrSlideSorter
.GetModel().GetEditMode() == EM_MASTERPAGE
)
756 if (rSet
.GetItemState(SID_CUT
) == SFX_ITEM_AVAILABLE
)
757 rSet
.DisableItem(SID_CUT
);
758 if (rSet
.GetItemState(SID_COPY
) == SFX_ITEM_AVAILABLE
)
759 rSet
.DisableItem(SID_COPY
);
760 if (rSet
.GetItemState(SID_PASTE
) == SFX_ITEM_AVAILABLE
)
761 rSet
.DisableItem(SID_PASTE
);
762 if (rSet
.GetItemState(SID_PASTE_SPECIAL
) == SFX_ITEM_AVAILABLE
)
763 rSet
.DisableItem(SID_PASTE_SPECIAL
);
767 // Cut, copy, and delete page are disabled when there is no selection.
768 if (rSet
.GetItemState(SID_CUT
) == SFX_ITEM_AVAILABLE
769 || rSet
.GetItemState(SID_COPY
) == SFX_ITEM_AVAILABLE
770 || rSet
.GetItemState(SID_DELETE
) == SFX_ITEM_AVAILABLE
771 || rSet
.GetItemState(SID_DELETE_PAGE
) == SFX_ITEM_AVAILABLE
772 || rSet
.GetItemState(SID_DELETE_MASTER_PAGE
) == SFX_ITEM_AVAILABLE
)
774 model::PageEnumeration
aSelectedPages (
775 model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
776 mrSlideSorter
.GetModel()));
778 // For copy to work we have to have at least one selected page.
779 if ( ! aSelectedPages
.HasMoreElements())
780 rSet
.DisableItem(SID_COPY
);
782 bool bDisable
= false;
783 // The operations that lead to the deletion of a page are valid if
784 // a) there is at least one selected page
785 // b) deleting the selected pages leaves at least one page in the
787 // c) selected master pages must not be used by slides.
790 if ( ! aSelectedPages
.HasMoreElements())
792 // Test b): Count the number of selected pages. It has to be less
793 // than the number of all pages.
794 else if (mrSlideSorter
.GetController().GetPageSelector().GetSelectedPageCount()
795 >= mrSlideSorter
.GetController().GetPageSelector().GetPageCount())
797 // Test c): Iterate over the selected pages and look for a master
798 // page that is used by at least one page.
799 else while (aSelectedPages
.HasMoreElements())
801 SdPage
* pPage
= aSelectedPages
.GetNextElement()->GetPage();
802 int nUseCount (mrSlideSorter
.GetModel().GetDocument()
803 ->GetMasterPageUserCount(pPage
));
813 rSet
.DisableItem(SID_CUT
);
814 rSet
.DisableItem(SID_DELETE_PAGE
);
815 rSet
.DisableItem(SID_DELETE_MASTER_PAGE
);
823 void SlotManager::GetStatusBarState (SfxItemSet
& rSet
)
825 // Seitenanzeige und Layout
827 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_PAGE ) ||
828 SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_LAYOUT ) )
830 SdPage
* pPage
= NULL
;
831 SdPage
* pFirstPage
= NULL
;
833 USHORT nSelectedPages
= (USHORT
)mrSlideSorter
.GetController().GetPageSelector().GetSelectedPageCount();
837 if (nSelectedPages
> 0)
838 aPageStr
= String(SdResId(STR_SD_PAGE
));
840 if (nSelectedPages
== 1)
842 model::PageEnumeration
aSelectedPages (
843 model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
844 mrSlideSorter
.GetModel()));
845 pPage
= aSelectedPages
.GetNextElement()->GetPage();
846 nFirstPage
= pPage
->GetPageNum()/2;
849 aPageStr
+= sal_Unicode(' ');
850 aPageStr
+= String::CreateFromInt32( nFirstPage
+ 1 );
851 aPageStr
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " ));
852 aPageStr
+= String::CreateFromInt32(
853 mrSlideSorter
.GetModel().GetPageCount());
855 aLayoutStr
= pFirstPage
->GetLayoutName();
856 aLayoutStr
.Erase( aLayoutStr
.SearchAscii( SD_LT_SEPARATOR
) );
859 rSet
.Put( SfxStringItem( SID_STATUS_PAGE
, aPageStr
) );
860 rSet
.Put( SfxStringItem( SID_STATUS_LAYOUT
, aLayoutStr
) );
862 if( SFX_ITEM_AVAILABLE
== rSet
.GetItemState( SID_ATTR_ZOOMSLIDER
) )
864 rSet
.Put( SfxVoidItem( SID_ATTR_ZOOMSLIDER
) );
868 void SlotManager::ShowSlideShow( SfxRequest
& rReq
)
870 Reference
< XPresentation2
> xPresentation( mrSlideSorter
.GetModel().GetDocument()->getPresentation() );
871 if( xPresentation
.is() )
873 if( ( SID_REHEARSE_TIMINGS
!= rReq
.GetSlot() ) )
874 xPresentation
->start();
876 xPresentation
->rehearseTimings();
880 void SlotManager::RenameSlide (void)
882 PageKind ePageKind
= mrSlideSorter
.GetModel().GetPageType();
883 View
* pDrView
= &mrSlideSorter
.GetView();
885 if (ePageKind
==PK_STANDARD
|| ePageKind
==PK_NOTES
)
887 if ( pDrView
->IsTextEdit() )
889 pDrView
->SdrEndTextEdit();
892 SdPage
* pSelectedPage
= NULL
;
893 model::PageEnumeration
aSelectedPages (
894 model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
895 mrSlideSorter
.GetModel()));
896 if (aSelectedPages
.HasMoreElements())
897 pSelectedPage
= aSelectedPages
.GetNextElement()->GetPage();
898 if (pSelectedPage
!= NULL
)
900 String
aTitle( SdResId( STR_TITLE_RENAMESLIDE
) );
901 String
aDescr( SdResId( STR_DESC_RENAMESLIDE
) );
902 String aPageName
= pSelectedPage
->GetName();
904 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
905 DBG_ASSERT(pFact
, "Dialogdiet fail!");
906 AbstractSvxNameDialog
* aNameDlg
= pFact
->CreateSvxNameDialog(
907 mrSlideSorter
.GetActiveWindow(),
908 aPageName
, aDescr
, RID_SVXDLG_NAME
);
909 DBG_ASSERT(aNameDlg
, "Dialogdiet fail!");
910 aNameDlg
->SetText( aTitle
);
911 aNameDlg
->SetCheckNameHdl( LINK( this, SlotManager
, RenameSlideHdl
), true );
912 aNameDlg
->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE
);
914 if( aNameDlg
->Execute() == RET_OK
)
917 aNameDlg
->GetName( aNewName
);
918 if( ! aNewName
.Equals( aPageName
) )
923 RenameSlideFromDrawViewShell(
924 pSelectedPage
->GetPageNum()/2, aNewName
);
925 DBG_ASSERT( bResult
, "Couldn't rename slide" );
930 // Tell the slide sorter about the name change (necessary for
932 mrSlideSorter
.GetController().PageNameHasChanged(
933 (pSelectedPage
->GetPageNum()-1)/2, aPageName
);
938 IMPL_LINK(SlotManager
, RenameSlideHdl
, AbstractSvxNameDialog
*, pDialog
)
944 pDialog
->GetName( aNewName
);
946 model::SharedPageDescriptor
pDescriptor (
947 mrSlideSorter
.GetController().GetCurrentSlideManager()->GetCurrentSlide());
948 SdPage
* pCurrentPage
= NULL
;
949 if (pDescriptor
.get() != NULL
)
950 pCurrentPage
= pDescriptor
->GetPage();
952 return ( (pCurrentPage
!=NULL
&& aNewName
.Equals( pCurrentPage
->GetName() ))
953 || (mrSlideSorter
.GetViewShell()
954 && mrSlideSorter
.GetViewShell()->GetDocSh()->IsNewPageNameValid( aNewName
) ));
957 bool SlotManager::RenameSlideFromDrawViewShell( USHORT nPageId
, const String
& rName
)
960 SdDrawDocument
* pDocument
= mrSlideSorter
.GetModel().GetDocument();
961 if( pDocument
->GetPageByName( rName
, bOutDummy
) != SDRPAGE_NOTFOUND
)
964 SdPage
* pPageToRename
= NULL
;
965 PageKind ePageKind
= mrSlideSorter
.GetModel().GetPageType();
967 SfxUndoManager
* pManager
= pDocument
->GetDocSh()->GetUndoManager();
969 if( mrSlideSorter
.GetModel().GetEditMode() == EM_PAGE
)
971 model::SharedPageDescriptor
pDescriptor (
972 mrSlideSorter
.GetController().GetCurrentSlideManager()->GetCurrentSlide());
973 if (pDescriptor
.get() != NULL
)
974 pPageToRename
= pDescriptor
->GetPage();
976 if (pPageToRename
!= NULL
)
979 SdPage
* pUndoPage
= pPageToRename
;
980 SdrLayerAdmin
& rLayerAdmin
= pDocument
->GetLayerAdmin();
981 BYTE nBackground
= rLayerAdmin
.GetLayerID( String( SdResId( STR_LAYER_BCKGRND
)), FALSE
);
982 BYTE nBgObj
= rLayerAdmin
.GetLayerID( String( SdResId( STR_LAYER_BCKGRNDOBJ
)), FALSE
);
983 SetOfByte aVisibleLayers
= pPageToRename
->TRG_GetMasterPageVisibleLayers();
986 ModifyPageUndoAction
* pAction
= new ModifyPageUndoAction(
987 pManager
, pDocument
, pUndoPage
, rName
, pUndoPage
->GetAutoLayout(),
988 aVisibleLayers
.IsSet( nBackground
),
989 aVisibleLayers
.IsSet( nBgObj
));
990 pManager
->AddUndoAction( pAction
);
993 pPageToRename
->SetName( rName
);
995 if( ePageKind
== PK_STANDARD
)
997 // also rename notes-page
998 SdPage
* pNotesPage
= pDocument
->GetSdPage( nPageId
, PK_NOTES
);
999 if (pNotesPage
!= NULL
)
1000 pNotesPage
->SetName (rName
);
1006 // rename MasterPage -> rename LayoutTemplate
1007 pPageToRename
= pDocument
->GetMasterSdPage( nPageId
, ePageKind
);
1008 if (pPageToRename
!= NULL
)
1010 const String
aOldLayoutName( pPageToRename
->GetLayoutName() );
1011 pManager
->AddUndoAction( new RenameLayoutTemplateUndoAction( pDocument
, aOldLayoutName
, rName
) );
1012 pDocument
->RenameLayoutTemplate( aOldLayoutName
, rName
);
1016 bool bSuccess
= pPageToRename
!=NULL
&& ( FALSE
!= rName
.Equals( pPageToRename
->GetName()));
1020 // user edited page names may be changed by the page so update control
1021 // aTabControl.SetPageText( nPageId, rName );
1023 // set document to modified state
1024 pDocument
->SetChanged( TRUE
);
1026 // inform navigator about change
1027 SfxBoolItem
aItem( SID_NAVIGATOR_INIT
, TRUE
);
1028 if (mrSlideSorter
.GetViewShell() != NULL
)
1029 mrSlideSorter
.GetViewShell()->GetDispatcher()->Execute(
1030 SID_NAVIGATOR_INIT
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
, &aItem
, 0L );
1039 /** Insert a slide. The insertion position depends on a) the selection and
1040 b) the mouse position when there is no selection.
1042 When there is a selection then insertion takes place after the last
1043 slide of the selection. For this to work all but the last selected
1044 slide are deselected first.
1046 Otherwise, when there is no selection but the insertion marker is visible
1047 the slide is inserted at that position. The slide before that marker is
1050 When both the selection and the insertion marker are not visible--can
1051 that happen?--the new slide is inserted after the last slide.
1053 void SlotManager::InsertSlide (SfxRequest
& rRequest
)
1055 PageSelector
& rSelector (mrSlideSorter
.GetController().GetPageSelector());
1056 // The fallback insertion position is after the last slide.
1057 sal_Int32
nInsertionIndex (rSelector
.GetPageCount() - 1);
1058 if (rSelector
.GetSelectedPageCount() > 0)
1060 // Deselect all but the last selected slide.
1061 bool bLastSelectedSlideSeen (false);
1062 for (int nIndex
=rSelector
.GetPageCount()-1; nIndex
>=0; --nIndex
)
1064 if (rSelector
.IsPageSelected(nIndex
))
1066 if (bLastSelectedSlideSeen
)
1067 rSelector
.DeselectPage (nIndex
);
1070 nInsertionIndex
= nIndex
;
1071 bLastSelectedSlideSeen
= true;
1077 // No selection. Is there an insertion indicator?
1078 else if (mrSlideSorter
.GetView().GetOverlay()
1079 .GetInsertionIndicatorOverlay().isVisible())
1081 // Select the page before the insertion indicator.
1082 nInsertionIndex
= mrSlideSorter
.GetView().GetOverlay()
1083 .GetInsertionIndicatorOverlay().GetInsertionPageIndex();
1085 rSelector
.SelectPage (nInsertionIndex
);
1088 // Select the last page when there is at least one page.
1089 else if (rSelector
.GetPageCount() > 0)
1091 nInsertionIndex
= rSelector
.GetPageCount() - 1;
1092 rSelector
.SelectPage (nInsertionIndex
);
1095 // Hope for the best that CreateOrDuplicatePage() can cope with an empty
1099 nInsertionIndex
= -1;
1102 USHORT
nPageCount ((USHORT
)mrSlideSorter
.GetModel().GetPageCount());
1104 rSelector
.DisableBroadcasting();
1105 // In order for SlideSorterController::GetActualPage() to select the
1106 // selected page as current page we have to turn off the focus
1109 FocusManager::FocusHider
aTemporaryFocusHider (
1110 mrSlideSorter
.GetController().GetFocusManager());
1112 SdPage
* pPreviousPage
= NULL
;
1113 if (nInsertionIndex
>= 0)
1114 pPreviousPage
= mrSlideSorter
.GetModel()
1115 .GetPageDescriptor(nInsertionIndex
)->GetPage();
1117 if (mrSlideSorter
.GetModel().GetEditMode() == EM_PAGE
)
1119 SlideSorterViewShell
* pShell
= dynamic_cast<SlideSorterViewShell
*>(
1120 mrSlideSorter
.GetViewShell());
1123 pShell
->CreateOrDuplicatePage (
1125 mrSlideSorter
.GetModel().GetPageType(),
1131 // Use the API to create a new page.
1132 SdDrawDocument
* pDocument
= mrSlideSorter
.GetModel().GetDocument();
1133 Reference
<drawing::XMasterPagesSupplier
> xMasterPagesSupplier (
1134 pDocument
->getUnoModel(), UNO_QUERY
);
1135 if (xMasterPagesSupplier
.is())
1137 Reference
<drawing::XDrawPages
> xMasterPages (
1138 xMasterPagesSupplier
->getMasterPages());
1139 if (xMasterPages
.is())
1141 xMasterPages
->insertNewByIndex (nInsertionIndex
+1);
1143 // Create shapes for the default layout.
1144 SdPage
* pMasterPage
= pDocument
->GetMasterSdPage(
1145 (USHORT
)(nInsertionIndex
+1), PK_STANDARD
);
1146 pMasterPage
->CreateTitleAndLayout (TRUE
,TRUE
);
1152 // When a new page has been inserted then select it and make it the
1154 mrSlideSorter
.GetView().LockRedraw(TRUE
);
1155 if (mrSlideSorter
.GetModel().GetPageCount() > nPageCount
)
1158 model::SharedPageDescriptor pDescriptor
= mrSlideSorter
.GetModel().GetPageDescriptor(nInsertionIndex
);
1159 if (pDescriptor
.get() != NULL
)
1160 mrSlideSorter
.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(pDescriptor
);
1162 rSelector
.EnableBroadcasting();
1163 mrSlideSorter
.GetView().LockRedraw(FALSE
);
1169 void SlotManager::AssignTransitionEffect (void)
1171 model::SlideSorterModel
& rModel (mrSlideSorter
.GetModel());
1173 // We have to manually select the pages in the document that are
1174 // selected in the slide sorter.
1175 rModel
.SynchronizeDocumentSelection();
1177 // #i34011#: Needs review, AF's bugfix is removed here
1178 //rShell.AssignFromSlideChangeWindow(rModel.GetEditMode());
1180 // We have to remove the selection of master pages to not confuse the
1182 if (rModel
.GetEditMode() == EM_MASTERPAGE
)
1184 SdDrawDocument
* pDocument
= mrSlideSorter
.GetModel().GetDocument();
1185 USHORT nMasterPageCount
= pDocument
->GetMasterSdPageCount(PK_STANDARD
);
1186 for (USHORT nIndex
=0; nIndex
<nMasterPageCount
; nIndex
++)
1188 SdPage
* pPage
= pDocument
->GetMasterSdPage(nIndex
, PK_STANDARD
);
1190 pPage
->SetSelected (FALSE
);
1198 void SlotManager::ExecuteCommandAsynchronously (::std::auto_ptr
<Command
> pCommand
)
1200 // Ownership of command is (implicitely) transferred to the queue.
1201 maCommandQueue
.push(pCommand
.get());
1203 Application::PostUserEvent(LINK(this,SlotManager
,UserEventCallback
));
1206 IMPL_LINK(SlotManager
, UserEventCallback
, void*, EMPTYARG
)
1208 if ( ! maCommandQueue
.empty())
1210 Command
* pCommand
= maCommandQueue
.front();
1211 maCommandQueue
.pop();
1213 if (pCommand
!= NULL
)
1215 // The queue ownes the command that has just been removed from
1216 // it. Therefore it is deleted after it has been executed.
1225 } } } // end of namespace ::sd::slidesorter::controller