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