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