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