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 "SlsListener.hxx"
31 : :
32 : : #include "SlideSorter.hxx"
33 : : #include "SlideSorterViewShell.hxx"
34 : : #include "ViewShellHint.hxx"
35 : : #include "controller/SlideSorterController.hxx"
36 : : #include "controller/SlsPageSelector.hxx"
37 : : #include "controller/SlsCurrentSlideManager.hxx"
38 : : #include "controller/SlsSelectionManager.hxx"
39 : : #include "controller/SlsSelectionObserver.hxx"
40 : : #include "model/SlideSorterModel.hxx"
41 : : #include "model/SlsPageEnumerationProvider.hxx"
42 : : #include "view/SlideSorterView.hxx"
43 : : #include "cache/SlsPageCache.hxx"
44 : : #include "cache/SlsPageCacheManager.hxx"
45 : : #include "drawdoc.hxx"
46 : : #include "DrawDocShell.hxx"
47 : :
48 : : #include "glob.hrc"
49 : : #include "ViewShellBase.hxx"
50 : : #include "ViewShellManager.hxx"
51 : : #include "FrameView.hxx"
52 : : #include "EventMultiplexer.hxx"
53 : : #include <com/sun/star/document/XEventBroadcaster.hpp>
54 : : #include <com/sun/star/beans/XPropertySet.hpp>
55 : : #include <com/sun/star/frame/FrameActionEvent.hpp>
56 : : #include <com/sun/star/frame/FrameAction.hpp>
57 : : #include <sfx2/viewfrm.hxx>
58 : : #include <tools/diagnose_ex.h>
59 : :
60 : :
61 : : using namespace ::com::sun::star::accessibility;
62 : : using namespace ::com::sun::star::beans;
63 : : using namespace ::com::sun::star::uno;
64 : : using namespace ::com::sun::star;
65 : :
66 : : namespace sd { namespace slidesorter { namespace controller {
67 : :
68 : :
69 : 130 : Listener::Listener (
70 : : SlideSorter& rSlideSorter)
71 : : : ListenerInterfaceBase(maMutex),
72 : : mrSlideSorter(rSlideSorter),
73 [ + - ]: 130 : mrController(mrSlideSorter.GetController()),
74 [ + - ]: 130 : mpBase(mrSlideSorter.GetViewShellBase()),
75 : : mbListeningToDocument (false),
76 : : mbListeningToUNODocument (false),
77 : : mbListeningToController (false),
78 : : mbListeningToFrame (false),
79 : : mbIsMainViewChangePending(false),
80 : : mxControllerWeak(),
81 : : mxFrameWeak(),
82 [ + - ][ + - ]: 260 : mpModelChangeLock()
[ + - ][ + - ]
83 : : {
84 [ + - ][ + - ]: 130 : StartListening(*mrSlideSorter.GetModel().GetDocument());
[ + - ]
85 [ + - ][ + - ]: 130 : StartListening(*mrSlideSorter.GetModel().GetDocument()->GetDocSh());
[ + - ]
86 : 130 : mbListeningToDocument = true;
87 : :
88 : : // Connect to the UNO document.
89 : : Reference<document::XEventBroadcaster> xBroadcaster (
90 [ + - ][ + - ]: 130 : mrSlideSorter.GetModel().GetDocument()->getUnoModel(), uno::UNO_QUERY);
[ + - ][ + - ]
91 [ + - ]: 130 : if (xBroadcaster.is())
92 : : {
93 [ + - ][ + - ]: 130 : xBroadcaster->addEventListener (this);
[ + - ]
94 : 130 : mbListeningToUNODocument = true;
95 : : }
96 : :
97 : : // Listen for disposing events from the document.
98 [ + - ]: 130 : Reference<XComponent> xComponent (xBroadcaster, UNO_QUERY);
99 [ + - ]: 130 : if (xComponent.is())
100 [ + - ]: 130 : xComponent->addEventListener (
101 : : Reference<lang::XEventListener>(
102 [ + - ][ + - ]: 130 : static_cast<XWeak*>(this), UNO_QUERY));
103 : :
104 : : // Connect to the frame to listen for controllers being exchanged.
105 : 130 : bool bIsMainViewShell (false);
106 [ + - ]: 130 : ViewShell* pViewShell = mrSlideSorter.GetViewShell();
107 [ + - ]: 130 : if (pViewShell != NULL)
108 [ + - ]: 130 : bIsMainViewShell = pViewShell->IsMainViewShell();
109 [ + - ]: 130 : if ( ! bIsMainViewShell)
110 : : {
111 : : // Listen to changes of certain properties.
112 : 130 : Reference<frame::XFrame> xFrame;
113 [ + - ]: 130 : Reference<frame::XController> xController (mrSlideSorter.GetXController());
114 [ + - ]: 130 : if (xController.is())
115 [ + - ][ + - ]: 130 : xFrame = xController->getFrame();
[ + - ]
116 [ + - ]: 130 : mxFrameWeak = xFrame;
117 [ + - ]: 130 : if (xFrame.is())
118 : : {
119 [ + - ]: 130 : xFrame->addFrameActionListener (
120 : : Reference<frame::XFrameActionListener>(
121 [ + - ][ + - ]: 130 : static_cast<XWeak*>(this), UNO_QUERY));
122 : 130 : mbListeningToFrame = true;
123 : : }
124 : :
125 : : // Connect to the current controller.
126 [ + - ]: 130 : ConnectToController ();
127 : : }
128 : :
129 : : // Listen for hints of the MainViewShell as well. If that is not yet
130 : : // present then the EventMultiplexer will tell us when it is available.
131 [ + - ]: 130 : if (mpBase != NULL)
132 : : {
133 [ + - ][ + - ]: 130 : ViewShell* pMainViewShell = mpBase->GetMainViewShell().get();
134 [ + - ][ + - ]: 130 : if (pMainViewShell != NULL
135 : : && pMainViewShell!=pViewShell)
136 : : {
137 [ + - ]: 130 : StartListening(*pMainViewShell);
138 : : }
139 : :
140 [ + - ]: 130 : Link aLink (LINK(this, Listener, EventMultiplexerCallback));
141 : : mpBase->GetEventMultiplexer()->AddEventListener(
142 : : aLink,
143 : : tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED
144 : : | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
145 : : | tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED
146 : : | tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED
147 [ + - ][ + - ]: 130 : | tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED);
[ + - ]
148 : 130 : }
149 : 130 : }
150 : :
151 : :
152 : :
153 : :
154 [ + - ][ + - ]: 130 : Listener::~Listener (void)
[ + - ][ + - ]
[ + - ]
155 : : {
156 : : DBG_ASSERT( !mbListeningToDocument && !mbListeningToUNODocument && !mbListeningToFrame,
157 : : "sd::Listener::~Listener(), disposing() was not called, ask DBO!" );
158 [ - + ]: 260 : }
159 : :
160 : :
161 : :
162 : :
163 : 130 : void Listener::ReleaseListeners (void)
164 : : {
165 [ + - ]: 130 : if (mbListeningToDocument)
166 : : {
167 : 130 : EndListening(*mrSlideSorter.GetModel().GetDocument()->GetDocSh());
168 : 130 : EndListening(*mrSlideSorter.GetModel().GetDocument());
169 : 130 : mbListeningToDocument = false;
170 : : }
171 : :
172 [ + - ]: 130 : if (mbListeningToUNODocument)
173 : : {
174 : : Reference<document::XEventBroadcaster> xBroadcaster (
175 [ + - ][ + - ]: 130 : mrSlideSorter.GetModel().GetDocument()->getUnoModel(), UNO_QUERY);
[ + - ][ + - ]
176 [ + - ]: 130 : if (xBroadcaster.is())
177 [ + - ][ + - ]: 130 : xBroadcaster->removeEventListener (this);
[ + - ]
178 : :
179 : : // Remove the dispose listener.
180 [ + - ]: 130 : Reference<XComponent> xComponent (xBroadcaster, UNO_QUERY);
181 [ + - ]: 130 : if (xComponent.is())
182 [ + - ]: 130 : xComponent->removeEventListener (
183 : : Reference<lang::XEventListener>(
184 [ + - ][ + - ]: 130 : static_cast<XWeak*>(this), UNO_QUERY));
185 : :
186 : 130 : mbListeningToUNODocument = false;
187 : : }
188 : :
189 [ + - ]: 130 : if (mbListeningToFrame)
190 : : {
191 : : // Listen to changes of certain properties.
192 [ + - ]: 130 : Reference<frame::XFrame> xFrame (mxFrameWeak);
193 [ + - ]: 130 : if (xFrame.is())
194 : : {
195 [ + - ]: 130 : xFrame->removeFrameActionListener (
196 : : Reference<frame::XFrameActionListener>(
197 [ + - ][ + - ]: 130 : static_cast<XWeak*>(this), UNO_QUERY));
198 : 130 : mbListeningToFrame = false;
199 : 130 : }
200 : : }
201 : :
202 : 130 : DisconnectFromController ();
203 : :
204 [ + - ]: 130 : if (mpBase != NULL)
205 : : {
206 [ + - ]: 130 : Link aLink (LINK(this, Listener, EventMultiplexerCallback));
207 : : mpBase->GetEventMultiplexer()->RemoveEventListener(
208 : : aLink,
209 : : tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED
210 : : | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
211 : : | tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED
212 : : | tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED
213 [ + - ][ + - ]: 130 : | tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED);
[ + - ]
214 : : }
215 : 130 : }
216 : :
217 : :
218 : :
219 : :
220 : 130 : void Listener::ConnectToController (void)
221 : : {
222 : 130 : ViewShell* pShell = mrSlideSorter.GetViewShell();
223 : :
224 : : // Register at the controller of the main view shell (if we are that not
225 : : // ourself).
226 [ + - ][ + - ]: 130 : if (pShell==NULL || ! pShell->IsMainViewShell())
[ + - ]
227 : : {
228 [ + - ]: 130 : Reference<frame::XController> xController (mrSlideSorter.GetXController());
229 : :
230 : : // Listen to changes of certain properties.
231 [ + - ]: 130 : Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
232 [ + - ]: 130 : if (xSet.is())
233 : : {
234 : : try
235 : : {
236 [ + - ][ + - ]: 130 : xSet->addPropertyChangeListener(rtl::OUString("CurrentPage"), this);
[ + - ][ # # ]
237 : : }
238 [ # # ]: 0 : catch (beans::UnknownPropertyException&)
239 : : {
240 : : DBG_UNHANDLED_EXCEPTION();
241 : : }
242 : : try
243 : : {
244 [ + - ][ + - ]: 130 : xSet->addPropertyChangeListener(rtl::OUString("IsMasterPageMode"), this);
[ + - ][ # # ]
245 : : }
246 [ # # ]: 0 : catch (beans::UnknownPropertyException&)
247 : : {
248 : : DBG_UNHANDLED_EXCEPTION();
249 : : }
250 : : }
251 : :
252 : : // Listen for disposing events.
253 [ + - ]: 130 : Reference<XComponent> xComponent (xController, UNO_QUERY);
254 [ + - ]: 130 : if (xComponent.is())
255 : : {
256 [ + - ]: 130 : xComponent->addEventListener (
257 [ + - ][ + - ]: 130 : Reference<lang::XEventListener>(static_cast<XWeak*>(this), UNO_QUERY));
258 : :
259 [ + - ]: 130 : mxControllerWeak = xController;
260 : 130 : mbListeningToController = true;
261 : 130 : }
262 : : }
263 : 130 : }
264 : :
265 : :
266 : :
267 : :
268 : 390 : void Listener::DisconnectFromController (void)
269 : : {
270 [ + + ]: 390 : if (mbListeningToController)
271 : : {
272 [ + - ]: 130 : Reference<frame::XController> xController = mxControllerWeak;
273 [ + - ]: 130 : Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
274 : : try
275 : : {
276 : : // Remove the property listener.
277 [ + - ]: 130 : if (xSet.is())
278 : : {
279 [ + - ]: 130 : xSet->removePropertyChangeListener (
280 : : rtl::OUString("CurrentPage"),
281 [ + - ][ + - ]: 130 : this);
282 [ + - ]: 130 : xSet->removePropertyChangeListener (
283 : : rtl::OUString("IsMasterPageMode"),
284 [ + - ][ + - ]: 130 : this);
285 : : }
286 : :
287 : : // Remove the dispose listener.
288 [ + - ]: 130 : Reference<XComponent> xComponent (xController, UNO_QUERY);
289 [ + - ]: 130 : if (xComponent.is())
290 [ + - ]: 130 : xComponent->removeEventListener (
291 : : Reference<lang::XEventListener>(
292 [ + - ][ + - ]: 130 : static_cast<XWeak*>(this), UNO_QUERY));
[ # # ]
293 : : }
294 [ # # ]: 0 : catch (beans::UnknownPropertyException&)
295 : : {
296 : : DBG_UNHANDLED_EXCEPTION();
297 : : }
298 : :
299 : 130 : mbListeningToController = false;
300 [ + - ]: 130 : mxControllerWeak = Reference<frame::XController>();
301 : : }
302 : 390 : }
303 : :
304 : :
305 : :
306 : :
307 : 3982 : void Listener::Notify (
308 : : SfxBroadcaster& rBroadcaster,
309 : : const SfxHint& rHint)
310 : : {
311 [ + + ]: 3982 : if (rHint.ISA(SdrHint))
312 : : {
313 [ + - ][ + - ]: 962 : SdrHint& rSdrHint (*PTR_CAST(SdrHint,&rHint));
314 [ + + ]: 962 : switch (rSdrHint.GetKind())
315 : : {
316 : : case HINT_PAGEORDERCHG:
317 [ + - ]: 120 : if (&rBroadcaster == mrSlideSorter.GetModel().GetDocument())
318 : 120 : HandleModelChange(rSdrHint.GetPage());
319 : 120 : break;
320 : :
321 : : default:
322 : 962 : break;
323 : : }
324 : : }
325 [ - + ]: 3020 : else if (rHint.ISA(ViewShellHint))
326 : : {
327 [ # # ][ # # ]: 0 : ViewShellHint& rViewShellHint (*PTR_CAST(ViewShellHint,&rHint));
328 [ # # # # : 0 : switch (rViewShellHint.GetHintId())
# # # ]
329 : : {
330 : : case ViewShellHint::HINT_PAGE_RESIZE_START:
331 : : // Initiate a model change but do nothing (well, not much)
332 : : // until we are told that all slides have been resized.
333 [ # # ]: 0 : mpModelChangeLock.reset(new SlideSorterController::ModelChangeLock(mrController));
334 : 0 : mrController.HandleModelChange();
335 : 0 : break;
336 : :
337 : : case ViewShellHint::HINT_PAGE_RESIZE_END:
338 : : // All slides have been resized. The model has to be updated.
339 : 0 : mpModelChangeLock.reset();
340 : 0 : break;
341 : :
342 : : case ViewShellHint::HINT_CHANGE_EDIT_MODE_START:
343 : 0 : mrController.PrepareEditModeChange();
344 : 0 : break;
345 : :
346 : : case ViewShellHint::HINT_CHANGE_EDIT_MODE_END:
347 : 0 : mrController.FinishEditModeChange();
348 : 0 : break;
349 : :
350 : : case ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START:
351 [ # # ]: 0 : mpModelChangeLock.reset(new SlideSorterController::ModelChangeLock(mrController));
352 : 0 : break;
353 : :
354 : : case ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END:
355 : 0 : mpModelChangeLock.reset();
356 : 0 : break;
357 : : }
358 : : }
359 [ + + ]: 3020 : else if (rHint.ISA(SfxSimpleHint))
360 : : {
361 [ + - ][ + - ]: 2712 : SfxSimpleHint& rSfxSimpleHint (*PTR_CAST(SfxSimpleHint,&rHint));
362 [ + + ]: 2712 : switch (rSfxSimpleHint.GetId())
363 : : {
364 : : case SFX_HINT_DOCCHANGED:
365 : 2270 : mrController.CheckForMasterPageAssignment();
366 : 2270 : mrController.CheckForSlideTransitionAssignment();
367 : 2712 : break;
368 : : }
369 : : }
370 : 3982 : }
371 : :
372 : :
373 : :
374 : :
375 : 1963 : IMPL_LINK(Listener, EventMultiplexerCallback, ::sd::tools::EventMultiplexerEvent*, pEvent)
376 : : {
377 [ + - + - : 1963 : switch (pEvent->meEventId)
+ + + + ]
378 : : {
379 : : case tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
380 : : {
381 [ + - ]: 130 : if (mpBase != NULL)
382 : : {
383 : 130 : ViewShell* pMainViewShell = mpBase->GetMainViewShell().get();
384 [ - + ]: 130 : if (pMainViewShell != NULL)
385 : 0 : EndListening(*pMainViewShell);
386 : : }
387 : : }
388 : 130 : break;
389 : :
390 : :
391 : : case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
392 : 0 : mbIsMainViewChangePending = true;
393 : 0 : break;
394 : :
395 : : case tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED:
396 [ - + ][ # # ]: 282 : if (mbIsMainViewChangePending && mpBase != NULL)
397 : : {
398 : 0 : mbIsMainViewChangePending = false;
399 : 0 : ViewShell* pMainViewShell = mpBase->GetMainViewShell().get();
400 [ # # ]: 0 : if (pMainViewShell != NULL
[ # # # # ]
401 : 0 : && pMainViewShell!=mrSlideSorter.GetViewShell())
402 : : {
403 : 0 : StartListening (*pMainViewShell);
404 : : }
405 : : }
406 : 282 : break;
407 : :
408 : : case tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED:
409 : : {
410 : 0 : ConnectToController();
411 : : // mrController.GetPageSelector().GetCoreSelection();
412 : 0 : UpdateEditMode();
413 : : }
414 : 0 : break;
415 : :
416 : :
417 : : case tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED:
418 : 130 : DisconnectFromController();
419 : 130 : break;
420 : :
421 : : case tools::EventMultiplexerEvent::EID_SHAPE_CHANGED:
422 : : case tools::EventMultiplexerEvent::EID_SHAPE_INSERTED:
423 : : case tools::EventMultiplexerEvent::EID_SHAPE_REMOVED:
424 : 838 : HandleShapeModification(static_cast<const SdrPage*>(pEvent->mpUserData));
425 : 838 : break;
426 : :
427 : : case tools::EventMultiplexerEvent::EID_END_TEXT_EDIT:
428 [ - + ]: 21 : if (pEvent->mpUserData != NULL)
429 : : {
430 : 0 : const SdrObject* pObject = static_cast<const SdrObject*>(pEvent->mpUserData);
431 : 0 : HandleShapeModification(pObject->GetPage());
432 : : }
433 : 21 : break;
434 : :
435 : : default:
436 : 562 : break;
437 : : }
438 : :
439 : 1963 : return 0;
440 : : }
441 : :
442 : :
443 : :
444 : :
445 : : //===== lang::XEventListener ================================================
446 : :
447 : 0 : void SAL_CALL Listener::disposing (
448 : : const lang::EventObject& rEventObject)
449 : : throw (RuntimeException)
450 : : {
451 [ # # ][ # # ]: 0 : if ((mbListeningToDocument || mbListeningToUNODocument)
[ # # ][ # # ]
[ # # ]
452 [ # # ][ # # ]: 0 : && mrSlideSorter.GetModel().GetDocument()!=NULL
453 : : && rEventObject.Source
454 [ # # ][ # # ]: 0 : == mrSlideSorter.GetModel().GetDocument()->getUnoModel())
[ # # ][ # # ]
[ # # ][ # # ]
455 : : {
456 : 0 : mbListeningToDocument = false;
457 : 0 : mbListeningToUNODocument = false;
458 : : }
459 [ # # ]: 0 : else if (mbListeningToController)
460 : : {
461 [ # # ]: 0 : Reference<frame::XController> xController (mxControllerWeak);
462 [ # # ][ # # ]: 0 : if (rEventObject.Source == xController)
463 : : {
464 : 0 : mbListeningToController = false;
465 : 0 : }
466 : : }
467 : 0 : }
468 : :
469 : :
470 : :
471 : :
472 : : //===== document::XEventListener ============================================
473 : :
474 : 1570 : void SAL_CALL Listener::notifyEvent (
475 : : const document::EventObject& )
476 : : throw (RuntimeException)
477 : : {
478 : 1570 : }
479 : :
480 : :
481 : :
482 : :
483 : : //===== beans::XPropertySetListener =========================================
484 : :
485 : 8 : void SAL_CALL Listener::propertyChange (
486 : : const PropertyChangeEvent& rEvent)
487 : : throw (RuntimeException)
488 : : {
489 : 8 : ThrowIfDisposed();
490 : :
491 [ + - ][ + + ]: 8 : static const ::rtl::OUString sCurrentPagePropertyName ("CurrentPage");
492 [ + + ][ + - ]: 8 : static const ::rtl::OUString sEditModePropertyName ("IsMasterPageMode");
493 : :
494 [ + - ]: 8 : if (rEvent.PropertyName.equals(sCurrentPagePropertyName))
495 : : {
496 : 8 : Any aCurrentPage = rEvent.NewValue;
497 [ + - ]: 8 : Reference<beans::XPropertySet> xPageSet (aCurrentPage, UNO_QUERY);
498 [ + - ]: 8 : if (xPageSet.is())
499 : : {
500 : : try
501 : : {
502 [ + - ][ + - ]: 8 : Any aPageNumber = xPageSet->getPropertyValue ("Number");
503 : 8 : sal_Int32 nCurrentPage = 0;
504 : 8 : aPageNumber >>= nCurrentPage;
505 : : // The selection is already set but we call SelectPage()
506 : : // nevertheless in order to make the new current page the
507 : : // last recently selected page of the PageSelector. This is
508 : : // used when making the selection visible.
509 [ + - ][ + - ]: 8 : mrController.GetCurrentSlideManager()->NotifyCurrentSlideChange(nCurrentPage-1);
[ + - ]
510 [ + - ][ + - ]: 8 : mrController.GetPageSelector().SelectPage(nCurrentPage-1);
[ # # # ]
511 : : }
512 [ # # ]: 0 : catch (beans::UnknownPropertyException&)
513 : : {
514 : : DBG_UNHANDLED_EXCEPTION();
515 : : }
516 [ # # ]: 0 : catch (lang::DisposedException&)
517 : : {
518 : : // Something is already disposed. There is not much we can
519 : : // do, except not to crash.
520 : : }
521 : 8 : }
522 : : }
523 [ # # ]: 0 : else if (rEvent.PropertyName.equals (sEditModePropertyName))
524 : : {
525 : 0 : sal_Bool bIsMasterPageMode = sal_False;
526 : 0 : rEvent.NewValue >>= bIsMasterPageMode;
527 : : mrController.ChangeEditMode (
528 [ # # ][ # # ]: 0 : bIsMasterPageMode ? EM_MASTERPAGE : EM_PAGE);
529 : : }
530 : 8 : }
531 : :
532 : :
533 : :
534 : :
535 : : //===== frame::XFrameActionListener ==========================================
536 : :
537 : 358 : void SAL_CALL Listener::frameAction (const frame::FrameActionEvent& rEvent)
538 : : throw (::com::sun::star::uno::RuntimeException)
539 : : {
540 [ + - + ]: 358 : switch (rEvent.Action)
541 : : {
542 : : case frame::FrameAction_COMPONENT_DETACHING:
543 : 130 : DisconnectFromController();
544 : 130 : break;
545 : :
546 : : case frame::FrameAction_COMPONENT_REATTACHED:
547 : : {
548 : 0 : ConnectToController();
549 : 0 : mrController.GetPageSelector().GetCoreSelection();
550 : 0 : UpdateEditMode();
551 : : }
552 : 0 : break;
553 : :
554 : : default:
555 : 228 : break;
556 : : }
557 : 358 : }
558 : :
559 : :
560 : :
561 : :
562 : : //===== accessibility::XAccessibleEventListener ==============================
563 : :
564 : 0 : void SAL_CALL Listener::notifyEvent (
565 : : const AccessibleEventObject& )
566 : : throw (RuntimeException)
567 : : {
568 : 0 : }
569 : :
570 : :
571 : :
572 : :
573 : 130 : void SAL_CALL Listener::disposing (void)
574 : : {
575 : 130 : ReleaseListeners();
576 : 130 : }
577 : :
578 : :
579 : :
580 : :
581 : 0 : void Listener::UpdateEditMode (void)
582 : : {
583 : : // When there is a new controller then the edit mode may have changed at
584 : : // the same time.
585 [ # # ]: 0 : Reference<frame::XController> xController (mxControllerWeak);
586 [ # # ]: 0 : Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
587 : 0 : bool bIsMasterPageMode = false;
588 [ # # ][ # # ]: 0 : if (xSet != NULL)
589 : : {
590 : : try
591 : : {
592 [ # # ][ # # ]: 0 : Any aValue (xSet->getPropertyValue( "IsMasterPageMode" ));
[ # # ]
593 : 0 : aValue >>= bIsMasterPageMode;
594 : : }
595 [ # # ]: 0 : catch (beans::UnknownPropertyException&)
596 : : {
597 : : // When the property is not supported then the master page mode
598 : : // is not supported, too.
599 : 0 : bIsMasterPageMode = false;
600 : : }
601 : : }
602 : : mrController.ChangeEditMode (
603 [ # # ][ # # ]: 0 : bIsMasterPageMode ? EM_MASTERPAGE : EM_PAGE);
604 : 0 : }
605 : :
606 : :
607 : :
608 : 120 : void Listener::HandleModelChange (const SdrPage* pPage)
609 : : {
610 : : // Notify model and selection observer about the page. The return value
611 : : // of the model call acts as filter as to which events to pass to the
612 : : // selection observer.
613 [ + + ]: 120 : if (mrSlideSorter.GetModel().NotifyPageEvent(pPage))
614 : : {
615 : : // The page of the hint belongs (or belonged) to the model.
616 : :
617 : : // Tell the cache manager that the preview bitmaps for a deleted
618 : : // page can be removed from all caches.
619 [ + - ][ + + ]: 22 : if (pPage!=NULL && ! pPage->IsInserted())
[ + + ]
620 [ + - ]: 2 : cache::PageCacheManager::Instance()->ReleasePreviewBitmap(pPage);
621 : :
622 [ + - ][ + - ]: 22 : mrController.GetSelectionManager()->GetSelectionObserver()->NotifyPageEvent(pPage);
[ + - ]
623 : : }
624 : :
625 : : // Tell the controller about the model change only when the document is
626 : : // in a sane state, not just in the middle of a larger change.
627 : 120 : SdDrawDocument* pDocument (mrSlideSorter.GetModel().GetDocument());
628 [ + + ]: 240 : if (pDocument != NULL
[ + - + + ]
629 : 120 : && pDocument->GetMasterSdPageCount(PK_STANDARD) == pDocument->GetMasterSdPageCount(PK_NOTES))
630 : : {
631 : : // A model change can make updates of some text fields necessary
632 : : // (like page numbers and page count.) Invalidate all previews in
633 : : // the cache to cope with this. Doing this on demand would be a
634 : : // nice optimization.
635 [ + - ][ + - ]: 94 : cache::PageCacheManager::Instance()->InvalidateAllPreviewBitmaps(pDocument->getUnoModel());
[ + - ]
636 : :
637 : 94 : mrController.HandleModelChange();
638 : : }
639 : 120 : }
640 : :
641 : :
642 : :
643 : 838 : void Listener::HandleShapeModification (const SdrPage* pPage)
644 : : {
645 [ + - ]: 838 : if (pPage == NULL)
646 : : return;
647 : :
648 : : // Invalidate the preview of the page (in all slide sorters that display
649 : : // it.)
650 [ + - ]: 838 : ::boost::shared_ptr<cache::PageCacheManager> pCacheManager (cache::PageCacheManager::Instance());
651 [ - + ]: 838 : if ( ! pCacheManager)
652 : : return;
653 [ + - ][ + - ]: 838 : SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument();
654 [ - + ]: 838 : if (pDocument == NULL)
655 : : {
656 : : OSL_ASSERT(pDocument!=NULL);
657 : : return;
658 : : }
659 [ + - ][ + - ]: 838 : pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pPage);
660 [ + - ][ + - ]: 838 : mrSlideSorter.GetView().GetPreviewCache()->RequestPreviewBitmap(pPage);
[ + - ][ + - ]
661 : :
662 : : // When the page is a master page then invalidate the previews of all
663 : : // pages that are linked to this master page.
664 [ + + ]: 838 : if (pPage->IsMasterPage())
665 : : {
666 [ + - ][ + + ]: 976 : for (sal_uInt16 nIndex=0,nCount=pDocument->GetSdPageCount(PK_STANDARD);
667 : : nIndex<nCount;
668 : : ++nIndex)
669 : : {
670 [ + - ]: 138 : const SdPage* pCandidate = pDocument->GetSdPage(nIndex, PK_STANDARD);
671 [ + - ][ + - ]: 138 : if (pCandidate!=NULL && pCandidate->TRG_HasMasterPage())
[ + - ]
672 : : {
673 [ + - ][ + - ]: 138 : if (&pCandidate->TRG_GetMasterPage() == pPage)
674 [ + - ][ + - ]: 138 : pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pCandidate);
675 : : }
676 : : else
677 : : {
678 : : OSL_ASSERT(pCandidate!=NULL && pCandidate->TRG_HasMasterPage());
679 : : }
680 : : }
681 [ + - ][ + - ]: 838 : }
682 : : }
683 : :
684 : :
685 : :
686 : :
687 : 8 : void Listener::ThrowIfDisposed (void)
688 : : throw (::com::sun::star::lang::DisposedException)
689 : : {
690 [ + - ][ - + ]: 8 : if (rBHelper.bDisposed || rBHelper.bInDispose)
691 : : {
692 : : throw lang::DisposedException ("SlideSorterController object has already been disposed",
693 [ # # ][ # # ]: 0 : static_cast<uno::XWeak*>(this));
694 : : }
695 : 8 : }
696 : :
697 : :
698 : :
699 : :
700 : : } } } // end of namespace ::sd::slidesorter::controller
701 : :
702 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|