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 64 : Listener::Listener (
58 : SlideSorter& rSlideSorter)
59 : : ListenerInterfaceBase(maMutex),
60 : mrSlideSorter(rSlideSorter),
61 64 : mrController(mrSlideSorter.GetController()),
62 64 : mpBase(mrSlideSorter.GetViewShellBase()),
63 : mbListeningToDocument (false),
64 : mbListeningToUNODocument (false),
65 : mbListeningToController (false),
66 : mbListeningToFrame (false),
67 : mbIsMainViewChangePending(false),
68 : mxControllerWeak(),
69 : mxFrameWeak(),
70 192 : mpModelChangeLock()
71 : {
72 64 : StartListening(*mrSlideSorter.GetModel().GetDocument());
73 64 : StartListening(*mrSlideSorter.GetModel().GetDocument()->GetDocSh());
74 64 : mbListeningToDocument = true;
75 :
76 : // Connect to the UNO document.
77 : Reference<document::XEventBroadcaster> xBroadcaster (
78 64 : mrSlideSorter.GetModel().GetDocument()->getUnoModel(), uno::UNO_QUERY);
79 64 : if (xBroadcaster.is())
80 : {
81 64 : xBroadcaster->addEventListener (this);
82 64 : mbListeningToUNODocument = true;
83 : }
84 :
85 : // Listen for disposing events from the document.
86 128 : Reference<XComponent> xComponent (xBroadcaster, UNO_QUERY);
87 64 : if (xComponent.is())
88 64 : xComponent->addEventListener (
89 : Reference<lang::XEventListener>(
90 64 : static_cast<XWeak*>(this), UNO_QUERY));
91 :
92 : // Connect to the frame to listen for controllers being exchanged.
93 64 : bool bIsMainViewShell (false);
94 64 : ViewShell* pViewShell = mrSlideSorter.GetViewShell();
95 64 : if (pViewShell != NULL)
96 64 : bIsMainViewShell = pViewShell->IsMainViewShell();
97 64 : if ( ! bIsMainViewShell)
98 : {
99 : // Listen to changes of certain properties.
100 64 : Reference<frame::XFrame> xFrame;
101 128 : Reference<frame::XController> xController (mrSlideSorter.GetXController());
102 64 : if (xController.is())
103 64 : xFrame = xController->getFrame();
104 64 : mxFrameWeak = xFrame;
105 64 : if (xFrame.is())
106 : {
107 64 : xFrame->addFrameActionListener (
108 : Reference<frame::XFrameActionListener>(
109 64 : static_cast<XWeak*>(this), UNO_QUERY));
110 64 : mbListeningToFrame = true;
111 : }
112 :
113 : // Connect to the current controller.
114 128 : 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 64 : if (mpBase != NULL)
120 : {
121 64 : ViewShell* pMainViewShell = mpBase->GetMainViewShell().get();
122 64 : if (pMainViewShell != NULL
123 63 : && pMainViewShell!=pViewShell)
124 : {
125 63 : StartListening(*pMainViewShell);
126 : }
127 :
128 64 : 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 64 : | tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED);
136 64 : }
137 64 : }
138 :
139 128 : Listener::~Listener()
140 : {
141 : DBG_ASSERT( !mbListeningToDocument && !mbListeningToUNODocument && !mbListeningToFrame,
142 : "sd::Listener::~Listener(), disposing() was not called, ask DBO!" );
143 128 : }
144 :
145 64 : void Listener::ReleaseListeners()
146 : {
147 64 : if (mbListeningToDocument)
148 : {
149 64 : EndListening(*mrSlideSorter.GetModel().GetDocument()->GetDocSh());
150 64 : EndListening(*mrSlideSorter.GetModel().GetDocument());
151 64 : mbListeningToDocument = false;
152 : }
153 :
154 64 : if (mbListeningToUNODocument)
155 : {
156 : Reference<document::XEventBroadcaster> xBroadcaster (
157 64 : mrSlideSorter.GetModel().GetDocument()->getUnoModel(), UNO_QUERY);
158 64 : if (xBroadcaster.is())
159 64 : xBroadcaster->removeEventListener (this);
160 :
161 : // Remove the dispose listener.
162 128 : Reference<XComponent> xComponent (xBroadcaster, UNO_QUERY);
163 64 : if (xComponent.is())
164 64 : xComponent->removeEventListener (
165 : Reference<lang::XEventListener>(
166 64 : static_cast<XWeak*>(this), UNO_QUERY));
167 :
168 128 : mbListeningToUNODocument = false;
169 : }
170 :
171 64 : if (mbListeningToFrame)
172 : {
173 : // Listen to changes of certain properties.
174 64 : Reference<frame::XFrame> xFrame (mxFrameWeak);
175 64 : if (xFrame.is())
176 : {
177 64 : xFrame->removeFrameActionListener (
178 : Reference<frame::XFrameActionListener>(
179 64 : static_cast<XWeak*>(this), UNO_QUERY));
180 64 : mbListeningToFrame = false;
181 64 : }
182 : }
183 :
184 64 : DisconnectFromController ();
185 :
186 64 : if (mpBase != NULL)
187 : {
188 64 : 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 64 : | tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED);
196 : }
197 64 : }
198 :
199 64 : void Listener::ConnectToController()
200 : {
201 64 : ViewShell* pShell = mrSlideSorter.GetViewShell();
202 :
203 : // Register at the controller of the main view shell (if we are that not
204 : // ourself).
205 64 : if (pShell==NULL || ! pShell->IsMainViewShell())
206 : {
207 64 : Reference<frame::XController> xController (mrSlideSorter.GetXController());
208 :
209 : // Listen to changes of certain properties.
210 128 : Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
211 64 : if (xSet.is())
212 : {
213 : try
214 : {
215 64 : xSet->addPropertyChangeListener(OUString("CurrentPage"), this);
216 : }
217 0 : catch (beans::UnknownPropertyException&)
218 : {
219 : DBG_UNHANDLED_EXCEPTION();
220 : }
221 : try
222 : {
223 64 : 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 128 : Reference<XComponent> xComponent (xController, UNO_QUERY);
233 64 : if (xComponent.is())
234 : {
235 64 : xComponent->addEventListener (
236 64 : Reference<lang::XEventListener>(static_cast<XWeak*>(this), UNO_QUERY));
237 :
238 64 : mxControllerWeak = xController;
239 64 : mbListeningToController = true;
240 64 : }
241 : }
242 64 : }
243 :
244 192 : void Listener::DisconnectFromController()
245 : {
246 192 : if (mbListeningToController)
247 : {
248 64 : Reference<frame::XController> xController = mxControllerWeak;
249 128 : Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
250 : try
251 : {
252 : // Remove the property listener.
253 64 : if (xSet.is())
254 : {
255 64 : xSet->removePropertyChangeListener (
256 : OUString("CurrentPage"),
257 64 : this);
258 64 : xSet->removePropertyChangeListener (
259 : OUString("IsMasterPageMode"),
260 64 : this);
261 : }
262 :
263 : // Remove the dispose listener.
264 64 : Reference<XComponent> xComponent (xController, UNO_QUERY);
265 64 : if (xComponent.is())
266 64 : xComponent->removeEventListener (
267 : Reference<lang::XEventListener>(
268 64 : static_cast<XWeak*>(this), UNO_QUERY));
269 : }
270 0 : catch (beans::UnknownPropertyException&)
271 : {
272 : DBG_UNHANDLED_EXCEPTION();
273 : }
274 :
275 64 : mbListeningToController = false;
276 128 : mxControllerWeak = Reference<frame::XController>();
277 : }
278 192 : }
279 :
280 1968 : void Listener::Notify (
281 : SfxBroadcaster& rBroadcaster,
282 : const SfxHint& rHint)
283 : {
284 1968 : const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>(&rHint);
285 1968 : if (pSdrHint)
286 : {
287 484 : 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 1968 : return;
294 : }
295 0 : break;
296 : case HINT_PAGEORDERCHG:
297 60 : if (&rBroadcaster == mrSlideSorter.GetModel().GetDocument())
298 60 : HandleModelChange(pSdrHint->GetPage());
299 60 : break;
300 :
301 : default:
302 424 : break;
303 : }
304 : }
305 1484 : 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 1484 : else if (dynamic_cast<const SfxSimpleHint*>(&rHint))
340 : {
341 1341 : const SfxSimpleHint& rSfxSimpleHint = static_cast<const SfxSimpleHint&>(rHint);
342 1341 : switch (rSfxSimpleHint.GetId())
343 : {
344 : case SFX_HINT_DOCCHANGED:
345 1125 : mrController.CheckForMasterPageAssignment();
346 1125 : mrController.CheckForSlideTransitionAssignment();
347 1125 : break;
348 : }
349 : }
350 : }
351 :
352 2170 : IMPL_LINK(Listener, EventMultiplexerCallback, ::sd::tools::EventMultiplexerEvent*, pEvent)
353 : {
354 1085 : switch (pEvent->meEventId)
355 : {
356 : case tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
357 : {
358 69 : if (mpBase != NULL)
359 : {
360 69 : ViewShell* pMainViewShell = mpBase->GetMainViewShell().get();
361 69 : if (pMainViewShell != NULL)
362 0 : EndListening(*pMainViewShell);
363 : }
364 : }
365 69 : break;
366 :
367 : case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
368 6 : mbIsMainViewChangePending = true;
369 6 : break;
370 :
371 : case tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED:
372 162 : if (mbIsMainViewChangePending && mpBase != NULL)
373 : {
374 6 : mbIsMainViewChangePending = false;
375 6 : ViewShell* pMainViewShell = mpBase->GetMainViewShell().get();
376 6 : if (pMainViewShell != NULL
377 6 : && pMainViewShell!=mrSlideSorter.GetViewShell())
378 : {
379 6 : StartListening (*pMainViewShell);
380 : }
381 : }
382 162 : 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 64 : DisconnectFromController();
394 64 : break;
395 :
396 : case tools::EventMultiplexerEvent::EID_SHAPE_CHANGED:
397 : case tools::EventMultiplexerEvent::EID_SHAPE_INSERTED:
398 : case tools::EventMultiplexerEvent::EID_SHAPE_REMOVED:
399 422 : HandleShapeModification(static_cast<const SdrPage*>(pEvent->mpUserData));
400 422 : break;
401 :
402 : case tools::EventMultiplexerEvent::EID_END_TEXT_EDIT:
403 27 : if (pEvent->mpUserData != NULL)
404 : {
405 0 : const SdrObject* pObject = static_cast<const SdrObject*>(pEvent->mpUserData);
406 0 : HandleShapeModification(pObject->GetPage());
407 : }
408 27 : break;
409 :
410 : default:
411 335 : break;
412 : }
413 :
414 1085 : 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 770 : void SAL_CALL Listener::notifyEvent (
444 : const document::EventObject& )
445 : throw (RuntimeException, std::exception)
446 : {
447 770 : }
448 :
449 : //===== beans::XPropertySetListener =========================================
450 :
451 28 : void SAL_CALL Listener::propertyChange (
452 : const PropertyChangeEvent& rEvent)
453 : throw (RuntimeException, std::exception)
454 : {
455 28 : ThrowIfDisposed();
456 :
457 : static const char sCurrentPagePropertyName[] = "CurrentPage";
458 : static const char sEditModePropertyName[] = "IsMasterPageMode";
459 :
460 28 : if (rEvent.PropertyName == sCurrentPagePropertyName)
461 : {
462 20 : Any aCurrentPage = rEvent.NewValue;
463 40 : Reference<beans::XPropertySet> xPageSet (aCurrentPage, UNO_QUERY);
464 20 : if (xPageSet.is())
465 : {
466 : try
467 : {
468 20 : Any aPageNumber = xPageSet->getPropertyValue ("Number");
469 20 : sal_Int32 nCurrentPage = 0;
470 20 : 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 20 : mrController.GetCurrentSlideManager()->NotifyCurrentSlideChange(nCurrentPage-1);
476 20 : 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 20 : }
488 : }
489 8 : else if (rEvent.PropertyName == sEditModePropertyName)
490 : {
491 8 : bool bIsMasterPageMode = false;
492 8 : rEvent.NewValue >>= bIsMasterPageMode;
493 : mrController.ChangeEditMode (
494 8 : bIsMasterPageMode ? EM_MASTERPAGE : EM_PAGE);
495 : }
496 28 : }
497 :
498 : //===== frame::XFrameActionListener ==========================================
499 :
500 180 : void SAL_CALL Listener::frameAction (const frame::FrameActionEvent& rEvent)
501 : throw (::com::sun::star::uno::RuntimeException, std::exception)
502 : {
503 180 : switch (rEvent.Action)
504 : {
505 : case frame::FrameAction_COMPONENT_DETACHING:
506 64 : DisconnectFromController();
507 64 : 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 116 : break;
519 : }
520 180 : }
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 64 : void SAL_CALL Listener::disposing()
531 : {
532 64 : ReleaseListeners();
533 64 : }
534 :
535 0 : void Listener::UpdateEditMode()
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 60 : 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 60 : 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 11 : if (pPage!=NULL && ! pPage->IsInserted())
572 1 : cache::PageCacheManager::Instance()->ReleasePreviewBitmap(pPage);
573 :
574 11 : 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 60 : SdDrawDocument* pDocument (mrSlideSorter.GetModel().GetDocument());
580 60 : if (pDocument != NULL
581 60 : && 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 47 : cache::PageCacheManager::Instance()->InvalidateAllPreviewBitmaps(pDocument->getUnoModel());
588 :
589 47 : mrController.HandleModelChange();
590 : }
591 60 : }
592 :
593 422 : void Listener::HandleShapeModification (const SdrPage* pPage)
594 : {
595 422 : if (pPage == NULL)
596 0 : return;
597 :
598 : // Invalidate the preview of the page (in all slide sorters that display
599 : // it.)
600 422 : ::boost::shared_ptr<cache::PageCacheManager> pCacheManager (cache::PageCacheManager::Instance());
601 422 : if ( ! pCacheManager)
602 0 : return;
603 422 : SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument();
604 422 : if (pDocument == NULL)
605 : {
606 : OSL_ASSERT(pDocument!=NULL);
607 0 : return;
608 : }
609 422 : pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pPage);
610 422 : 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 422 : if (pPage->IsMasterPage())
615 : {
616 140 : for (sal_uInt16 nIndex=0,nCount=pDocument->GetSdPageCount(PK_STANDARD);
617 : nIndex<nCount;
618 : ++nIndex)
619 : {
620 70 : const SdPage* pCandidate = pDocument->GetSdPage(nIndex, PK_STANDARD);
621 70 : if (pCandidate!=NULL && pCandidate->TRG_HasMasterPage())
622 : {
623 70 : if (&pCandidate->TRG_GetMasterPage() == pPage)
624 70 : pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pCandidate);
625 : }
626 : else
627 : {
628 : OSL_ASSERT(pCandidate!=NULL && pCandidate->TRG_HasMasterPage());
629 : }
630 : }
631 422 : }
632 : }
633 :
634 28 : void Listener::ThrowIfDisposed()
635 : throw (::com::sun::star::lang::DisposedException)
636 : {
637 28 : 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 28 : }
643 :
644 66 : } } } // end of namespace ::sd::slidesorter::controller
645 :
646 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|