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