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