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