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