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