1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include "precompiled_sd.hxx"
25
26 #include "SlideSorterViewShell.hxx"
27 #include "ViewShellImplementation.hxx"
28
29 #include "SlideSorter.hxx"
30 #include "controller/SlideSorterController.hxx"
31 #include "controller/SlsClipboard.hxx"
32 #include "controller/SlsFocusManager.hxx"
33 #include "controller/SlsScrollBarManager.hxx"
34 #include "controller/SlsPageSelector.hxx"
35 #include "controller/SlsSlotManager.hxx"
36 #include "controller/SlsCurrentSlideManager.hxx"
37 #include "controller/SlsSelectionManager.hxx"
38 #include "controller/SlsSelectionFunction.hxx"
39 #include "controller/SlsProperties.hxx"
40 #include "view/SlideSorterView.hxx"
41 #include "view/SlsLayouter.hxx"
42 #include "model/SlideSorterModel.hxx"
43 #include "model/SlsPageEnumeration.hxx"
44 #include "model/SlsPageDescriptor.hxx"
45 #include "framework/FrameworkHelper.hxx"
46 #include "ViewShellBase.hxx"
47 #include "drawdoc.hxx"
48 #include "app.hrc"
49 #include "glob.hrc"
50 #include "sdattr.hrc"
51 #include "sdresid.hxx"
52 #include "AccessibleSlideSorterView.hxx"
53 #include "DrawDocShell.hxx"
54 #include "DrawViewShell.hxx"
55 #include "FrameView.hxx"
56 #include "SdUnoSlideView.hxx"
57 #include "ViewShellManager.hxx"
58 #include "Window.hxx"
59 #include "drawview.hxx"
60 #include <sfx2/app.hxx>
61 #include <sfx2/msg.hxx>
62 #include <sfx2/objface.hxx>
63 #include <sfx2/viewfrm.hxx>
64 #include <sfx2/bindings.hxx>
65 #include <sfx2/dispatch.hxx>
66 #include <sfx2/request.hxx>
67 #include <sfx2/sidebar/SidebarChildWindow.hxx>
68 #include <svx/svxids.hrc>
69 #include <sfx2/sidebar/EnumContext.hxx>
70 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
71 #include <svx/sidebar/SelectionAnalyzer.hxx>
72 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
73 #include <com/sun/star/drawing/framework/ResourceId.hpp>
74 #include <cppuhelper/bootstrap.hxx>
75 #include <comphelper/processfactory.hxx>
76
77 using namespace ::sd::slidesorter;
78 #define SlideSorterViewShell
79 #include "sdslots.hxx"
80
81 using namespace ::com::sun::star;
82 using namespace ::com::sun::star::uno;
83 using namespace ::com::sun::star::drawing::framework;
84
85 using ::sd::framework::FrameworkHelper;
86 using ::sfx2::sidebar::EnumContext;
87
88 namespace sd { namespace slidesorter {
89
90
SFX_IMPL_INTERFACE(SlideSorterViewShell,SfxShell,SdResId (STR_SLIDESORTERVIEWSHELL))91 SFX_IMPL_INTERFACE(SlideSorterViewShell, SfxShell, SdResId(STR_SLIDESORTERVIEWSHELL))
92 {
93 SFX_CHILDWINDOW_REGISTRATION(::sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
94 }
95
96
97
98 TYPEINIT1(SlideSorterViewShell, ViewShell);
99
100
101
Create(SfxViewFrame * pFrame,ViewShellBase & rViewShellBase,::Window * pParentWindow,FrameView * pFrameViewArgument,const bool bIsCenterPane)102 ::boost::shared_ptr<SlideSorterViewShell> SlideSorterViewShell::Create (
103 SfxViewFrame* pFrame,
104 ViewShellBase& rViewShellBase,
105 ::Window* pParentWindow,
106 FrameView* pFrameViewArgument,
107 const bool bIsCenterPane)
108 {
109 (void)bIsCenterPane;
110
111 ::boost::shared_ptr<SlideSorterViewShell> pViewShell;
112 try
113 {
114 pViewShell.reset(
115 new SlideSorterViewShell(pFrame,rViewShellBase,pParentWindow,pFrameViewArgument));
116 pViewShell->Initialize();
117 if (pViewShell->mpSlideSorter.get() == NULL)
118 pViewShell.reset();
119 }
120 catch(Exception&)
121 {
122 pViewShell.reset();
123 }
124 return pViewShell;
125 }
126
127
128
129
SlideSorterViewShell(SfxViewFrame * pFrame,ViewShellBase & rViewShellBase,::Window * pParentWindow,FrameView * pFrameViewArgument)130 SlideSorterViewShell::SlideSorterViewShell (
131 SfxViewFrame* pFrame,
132 ViewShellBase& rViewShellBase,
133 ::Window* pParentWindow,
134 FrameView* pFrameViewArgument)
135 : ViewShell (pFrame, pParentWindow, rViewShellBase),
136 mpSlideSorter(),
137 mbIsArrangeGUIElementsPending(true)
138 {
139 meShellType = ST_SLIDE_SORTER;
140
141 SetPool( &GetDoc()->GetPool() );
142 SetUndoManager( GetDoc()->GetDocSh()->GetUndoManager() );
143
144 if (pFrameViewArgument != NULL)
145 mpFrameView = pFrameViewArgument;
146 else
147 mpFrameView = new FrameView(GetDoc());
148 GetFrameView()->Connect();
149
150 SetName (String (RTL_CONSTASCII_USTRINGPARAM("SlideSorterViewShell")));
151
152 pParentWindow->SetStyle(pParentWindow->GetStyle() | WB_DIALOGCONTROL);
153 }
154
155
156
157
~SlideSorterViewShell(void)158 SlideSorterViewShell::~SlideSorterViewShell (void)
159 {
160 DisposeFunctions();
161
162 try
163 {
164 ::sd::Window* pWindow = GetActiveWindow();
165 if (pWindow!=NULL)
166 {
167 ::com::sun::star::uno::Reference<
168 ::com::sun::star::lang::XComponent> xComponent (
169 pWindow->GetAccessible(false),
170 ::com::sun::star::uno::UNO_QUERY);
171 if (xComponent.is())
172 xComponent->dispose();
173 }
174 }
175 catch( ::com::sun::star::uno::Exception& e )
176 {
177 (void)e;
178 DBG_ERROR("sd::SlideSorterViewShell::~SlideSorterViewShell(), exception caught!" );
179 }
180
181 GetFrameView()->Disconnect(); // i120663, release the FrameView object
182 }
183
184
185
186
187
Initialize(void)188 void SlideSorterViewShell::Initialize (void)
189 {
190 mpSlideSorter = SlideSorter::CreateSlideSorter(
191 *this,
192 mpContentWindow,
193 mpHorizontalScrollBar,
194 mpVerticalScrollBar,
195 mpScrollBarBox);
196 mpView = &mpSlideSorter->GetView();
197
198 // For accessibility we have to shortly hide the content window.
199 // This triggers the construction of a new accessibility object for
200 // the new view shell. (One is created earlier while the constructor
201 // of the base class is executed. At that time the correct
202 // accessibility object can not be constructed.)
203 SharedSdWindow pWindow (mpSlideSorter->GetContentWindow());
204 if (pWindow)
205 {
206 pWindow->Hide();
207 pWindow->Show();
208 }
209 }
210
211
212
213
Init(bool bIsMainViewShell)214 void SlideSorterViewShell::Init (bool bIsMainViewShell)
215 {
216 ViewShell::Init(bIsMainViewShell);
217
218 // since the updatePageList will show focus, the window.show() must be called ahead. This show is deferred from Init()
219 ::sd::Window* pActiveWindow = GetActiveWindow();
220 if (pActiveWindow)
221 pActiveWindow->Show();
222 mpSlideSorter->GetModel().UpdatePageList();
223
224 if (mpContentWindow.get() != NULL)
225 mpContentWindow->SetViewShell(this);
226 }
227
228
229
230
GetSlideSorter(ViewShellBase & rBase)231 SlideSorterViewShell* SlideSorterViewShell::GetSlideSorter (ViewShellBase& rBase)
232 {
233 SlideSorterViewShell* pViewShell = NULL;
234
235 // Test the center and left pane for showing a slide sorter.
236 ::rtl::OUString aPaneURLs[] = {
237 FrameworkHelper::msCenterPaneURL,
238 FrameworkHelper::msFullScreenPaneURL,
239 FrameworkHelper::msLeftImpressPaneURL,
240 ::rtl::OUString()};
241
242 try
243 {
244 ::boost::shared_ptr<FrameworkHelper> pFrameworkHelper (FrameworkHelper::Instance(rBase));
245 if (pFrameworkHelper->IsValid())
246 for (int i=0; pViewShell==NULL && aPaneURLs[i].getLength()>0; ++i)
247 {
248 pViewShell = dynamic_cast<SlideSorterViewShell*>(
249 pFrameworkHelper->GetViewShell(aPaneURLs[i]).get());
250 }
251 }
252 catch (RuntimeException&)
253 {}
254
255 return pViewShell;
256 }
257
258
259
260
CreateSubController(void)261 Reference<drawing::XDrawSubController> SlideSorterViewShell::CreateSubController (void)
262 {
263 Reference<drawing::XDrawSubController> xSubController;
264
265 if (IsMainViewShell())
266 {
267 // Create uno controller for the main view shell.
268 xSubController = Reference<drawing::XDrawSubController>(
269 new SdUnoSlideView (
270 GetViewShellBase().GetDrawController(),
271 *mpSlideSorter,
272 *GetView()));
273 }
274
275 return xSubController;
276 }
277
278
279
280
281 /** If there is a valid controller then create a new instance of
282 <type>AccessibleSlideSorterView</type>. Otherwise delegate this call
283 to the base class to return a default object (probably an empty
284 reference).
285 */
286 ::com::sun::star::uno::Reference<
287 ::com::sun::star::accessibility::XAccessible>
CreateAccessibleDocumentView(::sd::Window * pWindow)288 SlideSorterViewShell::CreateAccessibleDocumentView (::sd::Window* pWindow)
289 {
290 OSL_ASSERT(mpSlideSorter.get()!=NULL);
291
292 // When the view is not set then the initialization is not yet complete
293 // and we can not yet provide an accessibility object.
294 if (mpView == NULL)
295 return NULL;
296
297 return new ::accessibility::AccessibleSlideSorterView (
298 *mpSlideSorter.get(),
299 pWindow->GetAccessibleParentWindow()->GetAccessible(),
300 pWindow);
301 }
302
SwitchViewFireFocus(::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> xAcc)303 void SlideSorterViewShell::SwitchViewFireFocus(::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc )
304 {
305 if (xAcc.get())
306 {
307 ::accessibility::AccessibleSlideSorterView* pBase = static_cast< ::accessibility::AccessibleSlideSorterView* >(xAcc.get());
308 if (pBase)
309 {
310 pBase->SwitchViewActivated();
311 }
312 }
313 }
314
315
GetSlideSorter(void) const316 SlideSorter& SlideSorterViewShell::GetSlideSorter (void) const
317 {
318 OSL_ASSERT(mpSlideSorter.get()!=NULL);
319 return *mpSlideSorter;
320 }
321
322
323
324
RelocateToParentWindow(::Window * pParentWindow)325 bool SlideSorterViewShell::RelocateToParentWindow (::Window* pParentWindow)
326 {
327 OSL_ASSERT(mpSlideSorter);
328 if ( ! mpSlideSorter)
329 return false;
330
331 if (pParentWindow == NULL)
332 WriteFrameViewData();
333 const bool bSuccess (mpSlideSorter->RelocateToWindow(pParentWindow));
334 if (pParentWindow != NULL)
335 ReadFrameViewData(mpFrameView);
336
337 return bSuccess;
338 }
339
340
341
342
ImpGetUndoManager(void) const343 ::svl::IUndoManager* SlideSorterViewShell::ImpGetUndoManager (void) const
344 {
345 SfxShell* pObjectBar = GetViewShellBase().GetViewShellManager()->GetTopShell();
346 if (pObjectBar != NULL)
347 {
348 // When it exists then return the undo manager of the currently
349 // active object bar. The object bar is missing when the
350 // SlideSorterViewShell is not the main view shell.
351 return pObjectBar->GetUndoManager();
352 }
353 else
354 {
355 // Return the undo manager of this shell when there is no object or
356 // tool bar.
357 return const_cast<SlideSorterViewShell*>(this)->GetUndoManager();
358 }
359 }
360
361
362
363
GetFocus(void)364 void SlideSorterViewShell::GetFocus (void)
365 {
366 OSL_ASSERT(mpSlideSorter.get()!=NULL);
367 mpSlideSorter->GetController().GetFocusManager().ShowFocus();
368 }
369
370
371
372
LoseFocus(void)373 void SlideSorterViewShell::LoseFocus (void)
374 {
375 OSL_ASSERT(mpSlideSorter.get()!=NULL);
376 mpSlideSorter->GetController().GetFocusManager().HideFocus();
377 }
378
379
380
381
getCurrentPage(void) const382 SdPage* SlideSorterViewShell::getCurrentPage(void) const
383 {
384 // since SlideSorterViewShell::GetActualPage() currently also
385 // returns master pages, which is a wrong behaviour for GetActualPage(),
386 // we can just use that for now
387 return const_cast<SlideSorterViewShell*>(this)->GetActualPage();
388 }
389
390
391
392
GetActualPage(void)393 SdPage* SlideSorterViewShell::GetActualPage (void)
394 {
395 SdPage* pCurrentPage = NULL;
396
397 // 1. Try to get the current page from the view shell in the center pane
398 // (if we are that not ourself).
399 if ( ! IsMainViewShell())
400 {
401 ::boost::shared_ptr<ViewShell> pMainViewShell = GetViewShellBase().GetMainViewShell();
402 if (pMainViewShell.get() != NULL)
403 pCurrentPage = pMainViewShell->GetActualPage();
404 }
405
406 if (pCurrentPage == NULL)
407 {
408 model::SharedPageDescriptor pDescriptor (
409 mpSlideSorter->GetController().GetCurrentSlideManager()->GetCurrentSlide());
410 if (pDescriptor.get() != NULL)
411 pCurrentPage = pDescriptor->GetPage();
412 }
413
414 if (pCurrentPage == NULL)
415 {
416
417 }
418
419 return pCurrentPage;
420 }
421
422
423
424
GetMenuState(SfxItemSet & rSet)425 void SlideSorterViewShell::GetMenuState ( SfxItemSet& rSet)
426 {
427 ViewShell::GetMenuState(rSet);
428 OSL_ASSERT(mpSlideSorter.get()!=NULL);
429 mpSlideSorter->GetController().GetSlotManager()->GetMenuState(rSet);
430 }
431
432
433
434
GetClipboardState(SfxItemSet & rSet)435 void SlideSorterViewShell::GetClipboardState ( SfxItemSet& rSet)
436 {
437 ViewShell::GetMenuState(rSet);
438 OSL_ASSERT(mpSlideSorter.get()!=NULL);
439 mpSlideSorter->GetController().GetSlotManager()->GetClipboardState(rSet);
440 }
441
442
443
444
ExecCtrl(SfxRequest & rRequest)445 void SlideSorterViewShell::ExecCtrl (SfxRequest& rRequest)
446 {
447 OSL_ASSERT(mpSlideSorter.get()!=NULL);
448 mpSlideSorter->GetController().ExecCtrl(rRequest);
449 }
450
451
452
453
GetCtrlState(SfxItemSet & rSet)454 void SlideSorterViewShell::GetCtrlState (SfxItemSet& rSet)
455 {
456 OSL_ASSERT(mpSlideSorter.get()!=NULL);
457 mpSlideSorter->GetController().GetCtrlState(rSet);
458 }
459
460
461
462
FuSupport(SfxRequest & rRequest)463 void SlideSorterViewShell::FuSupport (SfxRequest& rRequest)
464 {
465 OSL_ASSERT(mpSlideSorter.get()!=NULL);
466 mpSlideSorter->GetController().FuSupport(rRequest);
467 }
468
469
470
471
472 /** We have to handle those slot calls here that need to have access to
473 private or protected members and methods of this class.
474 */
FuTemporary(SfxRequest & rRequest)475 void SlideSorterViewShell::FuTemporary (SfxRequest& rRequest)
476 {
477 OSL_ASSERT(mpSlideSorter.get()!=NULL);
478 switch (rRequest.GetSlot())
479 {
480 case SID_MODIFYPAGE:
481 {
482 SdPage* pCurrentPage = GetActualPage();
483 if (pCurrentPage != NULL)
484 mpImpl->ProcessModifyPageSlot (
485 rRequest,
486 pCurrentPage,
487 mpSlideSorter->GetModel().GetPageType());
488 Cancel();
489 rRequest.Done ();
490 }
491 break;
492
493 default:
494 mpSlideSorter->GetController().FuTemporary(rRequest);
495 break;
496 }
497 }
498
499
500
501
GetStatusBarState(SfxItemSet & rSet)502 void SlideSorterViewShell::GetStatusBarState (SfxItemSet& rSet)
503 {
504 OSL_ASSERT(mpSlideSorter.get()!=NULL);
505 mpSlideSorter->GetController().GetStatusBarState(rSet);
506 }
507
508
509
510
FuPermanent(SfxRequest & rRequest)511 void SlideSorterViewShell::FuPermanent (SfxRequest& rRequest)
512 {
513 OSL_ASSERT(mpSlideSorter.get()!=NULL);
514 mpSlideSorter->GetController().FuPermanent(rRequest);
515 }
516
517
518
519
GetAttrState(SfxItemSet & rSet)520 void SlideSorterViewShell::GetAttrState (SfxItemSet& rSet)
521 {
522 OSL_ASSERT(mpSlideSorter.get()!=NULL);
523 mpSlideSorter->GetController().GetAttrState(rSet);
524 }
525
526
527
528
ExecStatusBar(SfxRequest & rRequest)529 void SlideSorterViewShell::ExecStatusBar (SfxRequest& rRequest)
530 {
531 OSL_ASSERT(mpSlideSorter.get()!=NULL);
532 mpSlideSorter->GetController().ExecStatusBar(rRequest);
533 }
534
535
536
537
Paint(const Rectangle & rBBox,::sd::Window * pWindow)538 void SlideSorterViewShell::Paint (
539 const Rectangle& rBBox,
540 ::sd::Window* pWindow)
541 {
542 SetActiveWindow (pWindow);
543 OSL_ASSERT(mpSlideSorter);
544 if (mpSlideSorter)
545 mpSlideSorter->GetController().Paint(rBBox,pWindow);
546 }
547
548
549
550
ArrangeGUIElements(void)551 void SlideSorterViewShell::ArrangeGUIElements (void)
552 {
553 if (IsActive())
554 {
555 OSL_ASSERT(mpSlideSorter.get()!=NULL);
556 mpSlideSorter->ArrangeGUIElements(maViewPos, maViewSize);
557 mbIsArrangeGUIElementsPending = false;
558 }
559 else
560 mbIsArrangeGUIElementsPending = true;
561 }
562
563
564
565
Activate(sal_Bool bIsMDIActivate)566 void SlideSorterViewShell::Activate (sal_Bool bIsMDIActivate)
567 {
568 ViewShell::Activate(bIsMDIActivate);
569 if (mbIsArrangeGUIElementsPending)
570 ArrangeGUIElements();
571
572 // Determine and broadcast the context that belongs to the main view shell.
573 EnumContext::Context eContext = EnumContext::Context_Unknown;
574 ::boost::shared_ptr<ViewShell> pMainViewShell (GetViewShellBase().GetMainViewShell());
575 ViewShell::ShellType eMainViewShellType (
576 pMainViewShell
577 ? pMainViewShell->GetShellType()
578 : ViewShell::ST_NONE);
579 switch (eMainViewShellType)
580 {
581 case ViewShell::ST_IMPRESS:
582 case ViewShell::ST_SLIDE_SORTER:
583 case ViewShell::ST_NOTES:
584 case ViewShell::ST_DRAW:
585 eContext = EnumContext::Context_DrawPage;
586 if (pMainViewShell->ISA(DrawViewShell))
587 {
588 DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pMainViewShell.get());
589 if (pDrawViewShell != NULL)
590 eContext = EnumContext::GetContextEnum(pDrawViewShell->GetSidebarContextName());
591 }
592 break;
593
594 eContext = EnumContext::Context_SlidesorterPage;
595 break;
596
597 default:
598 break;
599 }
600 ContextChangeEventMultiplexer::NotifyContextChange(
601 &GetViewShellBase(),
602 eContext);
603 }
604
605
606
607
Deactivate(sal_Bool bIsMDIActivate)608 void SlideSorterViewShell::Deactivate (sal_Bool bIsMDIActivate)
609 {
610 }
611
612
613
614
GetBorder(bool)615 SvBorder SlideSorterViewShell::GetBorder (bool )
616 {
617 OSL_ASSERT(mpSlideSorter.get()!=NULL);
618 return mpSlideSorter->GetBorder();
619 }
620
621
622
623
Command(const CommandEvent & rEvent,::sd::Window * pWindow)624 void SlideSorterViewShell::Command (
625 const CommandEvent& rEvent,
626 ::sd::Window* pWindow)
627 {
628 OSL_ASSERT(mpSlideSorter.get()!=NULL);
629 if ( ! mpSlideSorter->GetController().Command (rEvent, pWindow))
630 ViewShell::Command (rEvent, pWindow);
631 }
632
633
634
635
ReadFrameViewData(FrameView * pFrameView)636 void SlideSorterViewShell::ReadFrameViewData (FrameView* pFrameView)
637 {
638 OSL_ASSERT(mpSlideSorter.get()!=NULL);
639 if (pFrameView != NULL)
640 {
641 view::SlideSorterView& rView (mpSlideSorter->GetView());
642
643 sal_uInt16 nSlidesPerRow (pFrameView->GetSlidesPerRow());
644 if (nSlidesPerRow > 0
645 && rView.GetOrientation() == view::Layouter::GRID
646 && IsMainViewShell())
647 {
648 rView.GetLayouter().SetColumnCount(nSlidesPerRow,nSlidesPerRow);
649 }
650 if (IsMainViewShell())
651 mpSlideSorter->GetController().GetCurrentSlideManager()->NotifyCurrentSlideChange(
652 mpFrameView->GetSelectedPage());
653 mpSlideSorter->GetController().Rearrange(true);
654
655 // DrawMode for 'main' window
656 if (GetActiveWindow()->GetDrawMode() != pFrameView->GetDrawMode() )
657 GetActiveWindow()->SetDrawMode( pFrameView->GetDrawMode() );
658 }
659
660 // When this slide sorter is not displayed in the main window then we do
661 // not share the same frame view and have to find other ways to acquire
662 // certain values.
663 if ( ! IsMainViewShell())
664 {
665 ::boost::shared_ptr<ViewShell> pMainViewShell = GetViewShellBase().GetMainViewShell();
666 if (pMainViewShell.get() != NULL)
667 mpSlideSorter->GetController().GetCurrentSlideManager()->NotifyCurrentSlideChange(
668 pMainViewShell->getCurrentPage());
669 }
670 }
671
672
673
674
WriteFrameViewData(void)675 void SlideSorterViewShell::WriteFrameViewData (void)
676 {
677 OSL_ASSERT(mpSlideSorter.get()!=NULL);
678 if (mpFrameView != NULL)
679 {
680 view::SlideSorterView& rView (mpSlideSorter->GetView());
681 mpFrameView->SetSlidesPerRow((sal_uInt16)rView.GetLayouter().GetColumnCount());
682
683 // DrawMode for 'main' window
684 if( mpFrameView->GetDrawMode() != GetActiveWindow()->GetDrawMode() )
685 mpFrameView->SetDrawMode( GetActiveWindow()->GetDrawMode() );
686
687 SdPage* pActualPage = GetActualPage();
688 if (pActualPage != NULL)
689 {
690 if (IsMainViewShell())
691 mpFrameView->SetSelectedPage((pActualPage->GetPageNum()- 1) / 2);
692 // else
693 // The slide sorter is not expected to switch the current page
694 // other then by double clicks. That is handled seperatly.
695 }
696 else
697 {
698 // We have no current page to set but at least we can make sure
699 // that the index of the frame view has a legal value.
700 if (mpFrameView->GetSelectedPage() >= mpSlideSorter->GetModel().GetPageCount())
701 mpFrameView->SetSelectedPage((sal_uInt16)mpSlideSorter->GetModel().GetPageCount()-1);
702 }
703 }
704 }
705
706
707
708
SetZoom(long int)709 void SlideSorterViewShell::SetZoom (long int )
710 {
711 // Ignored.
712 // The zoom scale is adapted internally to fit a number of columns in
713 // the window.
714 }
715
716
717
718
SetZoomRect(const Rectangle & rZoomRect)719 void SlideSorterViewShell::SetZoomRect (const Rectangle& rZoomRect)
720 {
721 OSL_ASSERT(mpSlideSorter.get()!=NULL);
722 Size aPageSize (mpSlideSorter->GetView().GetLayouter().GetPageObjectSize());
723
724 Rectangle aRect(rZoomRect);
725
726 if (aRect.GetWidth() < aPageSize.Width())
727 {
728 long nWidthDiff = (aPageSize.Width() - aRect.GetWidth()) / 2;
729
730 aRect.Left() -= nWidthDiff;
731 aRect.Right() += nWidthDiff;
732
733 if (aRect.Left() < 0)
734 {
735 aRect.SetPos(Point(0, aRect.Top()));
736 }
737 }
738
739 if (aRect.GetHeight() < aPageSize.Height())
740 {
741 long nHeightDiff = (aPageSize.Height() - aRect.GetHeight()) / 2;
742
743 aRect.Top() -= nHeightDiff;
744 aRect.Bottom() += nHeightDiff;
745
746 if (aRect.Top() < 0)
747 {
748 aRect.SetPos(Point(aRect.Left(), 0));
749 }
750 }
751
752 ViewShell::SetZoomRect(aRect);
753
754 // #106268#
755 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
756 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
757 }
758
759
760
761
UpdateScrollBars(void)762 void SlideSorterViewShell::UpdateScrollBars (void)
763 {
764 // Do not call the overwritten method of the base class: We do all the
765 // scroll bar setup by ourselves.
766 mpSlideSorter->GetController().GetScrollBarManager().UpdateScrollBars (false);
767 }
768
769
770
771
StartDrag(const Point & rDragPt,::Window * pWindow)772 void SlideSorterViewShell::StartDrag (
773 const Point& rDragPt,
774 ::Window* pWindow )
775 {
776 OSL_ASSERT(mpSlideSorter.get()!=NULL);
777 mpSlideSorter->GetController().GetClipboard().StartDrag (
778 rDragPt,
779 pWindow);
780 }
781
782
783
784
DragFinished(sal_Int8 nDropAction)785 void SlideSorterViewShell::DragFinished (
786 sal_Int8 nDropAction)
787 {
788 OSL_ASSERT(mpSlideSorter.get()!=NULL);
789 mpSlideSorter->GetController().GetClipboard().DragFinished (nDropAction);
790 }
791
792
793
794
AcceptDrop(const AcceptDropEvent & rEvt,DropTargetHelper & rTargetHelper,::sd::Window * pTargetWindow,sal_uInt16 nPage,sal_uInt16 nLayer)795 sal_Int8 SlideSorterViewShell::AcceptDrop (
796 const AcceptDropEvent& rEvt,
797 DropTargetHelper& rTargetHelper,
798 ::sd::Window* pTargetWindow,
799 sal_uInt16 nPage,
800 sal_uInt16 nLayer)
801 {
802 OSL_ASSERT(mpSlideSorter.get()!=NULL);
803 return mpSlideSorter->GetController().GetClipboard().AcceptDrop (
804 rEvt,
805 rTargetHelper,
806 pTargetWindow,
807 nPage,
808 nLayer);
809 }
810
811
812
813
ExecuteDrop(const ExecuteDropEvent & rEvt,DropTargetHelper & rTargetHelper,::sd::Window * pTargetWindow,sal_uInt16 nPage,sal_uInt16 nLayer)814 sal_Int8 SlideSorterViewShell::ExecuteDrop (
815 const ExecuteDropEvent& rEvt,
816 DropTargetHelper& rTargetHelper,
817 ::sd::Window* pTargetWindow,
818 sal_uInt16 nPage,
819 sal_uInt16 nLayer)
820 {
821 OSL_ASSERT(mpSlideSorter.get()!=NULL);
822 return mpSlideSorter->GetController().GetClipboard().ExecuteDrop (
823 rEvt,
824 rTargetHelper,
825 pTargetWindow,
826 nPage,
827 nLayer);
828 }
829
830
831
832
833 ::boost::shared_ptr<SlideSorterViewShell::PageSelection>
GetPageSelection(void) const834 SlideSorterViewShell::GetPageSelection (void) const
835 {
836 OSL_ASSERT(mpSlideSorter.get()!=NULL);
837 return mpSlideSorter->GetController().GetPageSelector().GetPageSelection();
838 }
839
840
841
842
SetPageSelection(const::boost::shared_ptr<PageSelection> & rSelection)843 void SlideSorterViewShell::SetPageSelection (
844 const ::boost::shared_ptr<PageSelection>& rSelection)
845 {
846 OSL_ASSERT(mpSlideSorter.get()!=NULL);
847 mpSlideSorter->GetController().GetPageSelector().SetPageSelection(rSelection);
848 }
849
850
851
852
AddSelectionChangeListener(const Link & rCallback)853 void SlideSorterViewShell::AddSelectionChangeListener (
854 const Link& rCallback)
855 {
856 OSL_ASSERT(mpSlideSorter.get()!=NULL);
857 mpSlideSorter->GetController().GetSelectionManager()->AddSelectionChangeListener(rCallback);
858 }
859
860
861
862
RemoveSelectionChangeListener(const Link & rCallback)863 void SlideSorterViewShell::RemoveSelectionChangeListener (
864 const Link& rCallback)
865 {
866 OSL_ASSERT(mpSlideSorter.get()!=NULL);
867 mpSlideSorter->GetController().GetSelectionManager()->RemoveSelectionChangeListener(rCallback);
868 }
869
870
871
872 } } // end of namespace ::sd::slidesorter
873