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 : && 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(rtl::OUString("CurrentPage"), this);
228 : }
229 0 : catch (beans::UnknownPropertyException&)
230 : {
231 : DBG_UNHANDLED_EXCEPTION();
232 : }
233 : try
234 : {
235 0 : xSet->addPropertyChangeListener(rtl::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 : rtl::OUString("CurrentPage"),
272 0 : this);
273 0 : xSet->removePropertyChangeListener (
274 : rtl::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_PAGEORDERCHG:
308 0 : if (&rBroadcaster == mrSlideSorter.GetModel().GetDocument())
309 0 : HandleModelChange(rSdrHint.GetPage());
310 0 : break;
311 :
312 : default:
313 0 : break;
314 : }
315 : }
316 0 : else if (rHint.ISA(ViewShellHint))
317 : {
318 0 : ViewShellHint& rViewShellHint (*PTR_CAST(ViewShellHint,&rHint));
319 0 : switch (rViewShellHint.GetHintId())
320 : {
321 : case ViewShellHint::HINT_PAGE_RESIZE_START:
322 : // Initiate a model change but do nothing (well, not much)
323 : // until we are told that all slides have been resized.
324 0 : mpModelChangeLock.reset(new SlideSorterController::ModelChangeLock(mrController));
325 0 : mrController.HandleModelChange();
326 0 : break;
327 :
328 : case ViewShellHint::HINT_PAGE_RESIZE_END:
329 : // All slides have been resized. The model has to be updated.
330 0 : mpModelChangeLock.reset();
331 0 : break;
332 :
333 : case ViewShellHint::HINT_CHANGE_EDIT_MODE_START:
334 0 : mrController.PrepareEditModeChange();
335 0 : break;
336 :
337 : case ViewShellHint::HINT_CHANGE_EDIT_MODE_END:
338 0 : mrController.FinishEditModeChange();
339 0 : break;
340 :
341 : case ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START:
342 0 : mpModelChangeLock.reset(new SlideSorterController::ModelChangeLock(mrController));
343 0 : break;
344 :
345 : case ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END:
346 0 : mpModelChangeLock.reset();
347 0 : break;
348 : }
349 : }
350 0 : else if (rHint.ISA(SfxSimpleHint))
351 : {
352 0 : SfxSimpleHint& rSfxSimpleHint (*PTR_CAST(SfxSimpleHint,&rHint));
353 0 : switch (rSfxSimpleHint.GetId())
354 : {
355 : case SFX_HINT_DOCCHANGED:
356 0 : mrController.CheckForMasterPageAssignment();
357 0 : mrController.CheckForSlideTransitionAssignment();
358 0 : break;
359 : }
360 : }
361 0 : }
362 :
363 :
364 :
365 :
366 0 : IMPL_LINK(Listener, EventMultiplexerCallback, ::sd::tools::EventMultiplexerEvent*, pEvent)
367 : {
368 0 : switch (pEvent->meEventId)
369 : {
370 : case tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
371 : {
372 0 : if (mpBase != NULL)
373 : {
374 0 : ViewShell* pMainViewShell = mpBase->GetMainViewShell().get();
375 0 : if (pMainViewShell != NULL)
376 0 : EndListening(*pMainViewShell);
377 : }
378 : }
379 0 : break;
380 :
381 :
382 : case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
383 0 : mbIsMainViewChangePending = true;
384 0 : break;
385 :
386 : case tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED:
387 0 : if (mbIsMainViewChangePending && mpBase != NULL)
388 : {
389 0 : mbIsMainViewChangePending = false;
390 0 : ViewShell* pMainViewShell = mpBase->GetMainViewShell().get();
391 0 : if (pMainViewShell != NULL
392 0 : && pMainViewShell!=mrSlideSorter.GetViewShell())
393 : {
394 0 : StartListening (*pMainViewShell);
395 : }
396 : }
397 0 : break;
398 :
399 : case tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED:
400 : {
401 0 : ConnectToController();
402 : // mrController.GetPageSelector().GetCoreSelection();
403 0 : UpdateEditMode();
404 : }
405 0 : break;
406 :
407 :
408 : case tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED:
409 0 : DisconnectFromController();
410 0 : break;
411 :
412 : case tools::EventMultiplexerEvent::EID_SHAPE_CHANGED:
413 : case tools::EventMultiplexerEvent::EID_SHAPE_INSERTED:
414 : case tools::EventMultiplexerEvent::EID_SHAPE_REMOVED:
415 0 : HandleShapeModification(static_cast<const SdrPage*>(pEvent->mpUserData));
416 0 : break;
417 :
418 : case tools::EventMultiplexerEvent::EID_END_TEXT_EDIT:
419 0 : if (pEvent->mpUserData != NULL)
420 : {
421 0 : const SdrObject* pObject = static_cast<const SdrObject*>(pEvent->mpUserData);
422 0 : HandleShapeModification(pObject->GetPage());
423 : }
424 0 : break;
425 :
426 : default:
427 0 : break;
428 : }
429 :
430 0 : return 0;
431 : }
432 :
433 :
434 :
435 :
436 : //===== lang::XEventListener ================================================
437 :
438 0 : void SAL_CALL Listener::disposing (
439 : const lang::EventObject& rEventObject)
440 : throw (RuntimeException)
441 : {
442 0 : if ((mbListeningToDocument || mbListeningToUNODocument)
443 0 : && mrSlideSorter.GetModel().GetDocument()!=NULL
444 : && rEventObject.Source
445 0 : == mrSlideSorter.GetModel().GetDocument()->getUnoModel())
446 : {
447 0 : mbListeningToDocument = false;
448 0 : mbListeningToUNODocument = false;
449 : }
450 0 : else if (mbListeningToController)
451 : {
452 0 : Reference<frame::XController> xController (mxControllerWeak);
453 0 : if (rEventObject.Source == xController)
454 : {
455 0 : mbListeningToController = false;
456 0 : }
457 : }
458 0 : }
459 :
460 :
461 :
462 :
463 : //===== document::XEventListener ============================================
464 :
465 0 : void SAL_CALL Listener::notifyEvent (
466 : const document::EventObject& )
467 : throw (RuntimeException)
468 : {
469 0 : }
470 :
471 :
472 :
473 :
474 : //===== beans::XPropertySetListener =========================================
475 :
476 0 : void SAL_CALL Listener::propertyChange (
477 : const PropertyChangeEvent& rEvent)
478 : throw (RuntimeException)
479 : {
480 0 : ThrowIfDisposed();
481 :
482 0 : static const ::rtl::OUString sCurrentPagePropertyName ("CurrentPage");
483 0 : static const ::rtl::OUString sEditModePropertyName ("IsMasterPageMode");
484 :
485 0 : if (rEvent.PropertyName.equals(sCurrentPagePropertyName))
486 : {
487 0 : Any aCurrentPage = rEvent.NewValue;
488 0 : Reference<beans::XPropertySet> xPageSet (aCurrentPage, UNO_QUERY);
489 0 : if (xPageSet.is())
490 : {
491 : try
492 : {
493 0 : Any aPageNumber = xPageSet->getPropertyValue ("Number");
494 0 : sal_Int32 nCurrentPage = 0;
495 0 : aPageNumber >>= nCurrentPage;
496 : // The selection is already set but we call SelectPage()
497 : // nevertheless in order to make the new current page the
498 : // last recently selected page of the PageSelector. This is
499 : // used when making the selection visible.
500 0 : mrController.GetCurrentSlideManager()->NotifyCurrentSlideChange(nCurrentPage-1);
501 0 : mrController.GetPageSelector().SelectPage(nCurrentPage-1);
502 : }
503 0 : catch (beans::UnknownPropertyException&)
504 : {
505 : DBG_UNHANDLED_EXCEPTION();
506 : }
507 0 : catch (lang::DisposedException&)
508 : {
509 : // Something is already disposed. There is not much we can
510 : // do, except not to crash.
511 : }
512 0 : }
513 : }
514 0 : else if (rEvent.PropertyName.equals (sEditModePropertyName))
515 : {
516 0 : sal_Bool bIsMasterPageMode = sal_False;
517 0 : rEvent.NewValue >>= bIsMasterPageMode;
518 : mrController.ChangeEditMode (
519 0 : bIsMasterPageMode ? EM_MASTERPAGE : EM_PAGE);
520 : }
521 0 : }
522 :
523 :
524 :
525 :
526 : //===== frame::XFrameActionListener ==========================================
527 :
528 0 : void SAL_CALL Listener::frameAction (const frame::FrameActionEvent& rEvent)
529 : throw (::com::sun::star::uno::RuntimeException)
530 : {
531 0 : switch (rEvent.Action)
532 : {
533 : case frame::FrameAction_COMPONENT_DETACHING:
534 0 : DisconnectFromController();
535 0 : break;
536 :
537 : case frame::FrameAction_COMPONENT_REATTACHED:
538 : {
539 0 : ConnectToController();
540 0 : mrController.GetPageSelector().GetCoreSelection();
541 0 : UpdateEditMode();
542 : }
543 0 : break;
544 :
545 : default:
546 0 : break;
547 : }
548 0 : }
549 :
550 :
551 :
552 :
553 : //===== accessibility::XAccessibleEventListener ==============================
554 :
555 0 : void SAL_CALL Listener::notifyEvent (
556 : const AccessibleEventObject& )
557 : throw (RuntimeException)
558 : {
559 0 : }
560 :
561 :
562 :
563 :
564 0 : void SAL_CALL Listener::disposing (void)
565 : {
566 0 : ReleaseListeners();
567 0 : }
568 :
569 :
570 :
571 :
572 0 : void Listener::UpdateEditMode (void)
573 : {
574 : // When there is a new controller then the edit mode may have changed at
575 : // the same time.
576 0 : Reference<frame::XController> xController (mxControllerWeak);
577 0 : Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
578 0 : bool bIsMasterPageMode = false;
579 0 : if (xSet != NULL)
580 : {
581 : try
582 : {
583 0 : Any aValue (xSet->getPropertyValue( "IsMasterPageMode" ));
584 0 : aValue >>= bIsMasterPageMode;
585 : }
586 0 : catch (beans::UnknownPropertyException&)
587 : {
588 : // When the property is not supported then the master page mode
589 : // is not supported, too.
590 0 : bIsMasterPageMode = false;
591 : }
592 : }
593 : mrController.ChangeEditMode (
594 0 : bIsMasterPageMode ? EM_MASTERPAGE : EM_PAGE);
595 0 : }
596 :
597 :
598 :
599 0 : void Listener::HandleModelChange (const SdrPage* pPage)
600 : {
601 : // Notify model and selection observer about the page. The return value
602 : // of the model call acts as filter as to which events to pass to the
603 : // selection observer.
604 0 : if (mrSlideSorter.GetModel().NotifyPageEvent(pPage))
605 : {
606 : // The page of the hint belongs (or belonged) to the model.
607 :
608 : // Tell the cache manager that the preview bitmaps for a deleted
609 : // page can be removed from all caches.
610 0 : if (pPage!=NULL && ! pPage->IsInserted())
611 0 : cache::PageCacheManager::Instance()->ReleasePreviewBitmap(pPage);
612 :
613 0 : mrController.GetSelectionManager()->GetSelectionObserver()->NotifyPageEvent(pPage);
614 : }
615 :
616 : // Tell the controller about the model change only when the document is
617 : // in a sane state, not just in the middle of a larger change.
618 0 : SdDrawDocument* pDocument (mrSlideSorter.GetModel().GetDocument());
619 0 : if (pDocument != NULL
620 0 : && pDocument->GetMasterSdPageCount(PK_STANDARD) == pDocument->GetMasterSdPageCount(PK_NOTES))
621 : {
622 : // A model change can make updates of some text fields necessary
623 : // (like page numbers and page count.) Invalidate all previews in
624 : // the cache to cope with this. Doing this on demand would be a
625 : // nice optimization.
626 0 : cache::PageCacheManager::Instance()->InvalidateAllPreviewBitmaps(pDocument->getUnoModel());
627 :
628 0 : mrController.HandleModelChange();
629 : }
630 0 : }
631 :
632 :
633 :
634 0 : void Listener::HandleShapeModification (const SdrPage* pPage)
635 : {
636 0 : if (pPage == NULL)
637 : return;
638 :
639 : // Invalidate the preview of the page (in all slide sorters that display
640 : // it.)
641 0 : ::boost::shared_ptr<cache::PageCacheManager> pCacheManager (cache::PageCacheManager::Instance());
642 0 : if ( ! pCacheManager)
643 : return;
644 0 : SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument();
645 0 : if (pDocument == NULL)
646 : {
647 : OSL_ASSERT(pDocument!=NULL);
648 : return;
649 : }
650 0 : pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pPage);
651 0 : mrSlideSorter.GetView().GetPreviewCache()->RequestPreviewBitmap(pPage);
652 :
653 : // When the page is a master page then invalidate the previews of all
654 : // pages that are linked to this master page.
655 0 : if (pPage->IsMasterPage())
656 : {
657 0 : for (sal_uInt16 nIndex=0,nCount=pDocument->GetSdPageCount(PK_STANDARD);
658 : nIndex<nCount;
659 : ++nIndex)
660 : {
661 0 : const SdPage* pCandidate = pDocument->GetSdPage(nIndex, PK_STANDARD);
662 0 : if (pCandidate!=NULL && pCandidate->TRG_HasMasterPage())
663 : {
664 0 : if (&pCandidate->TRG_GetMasterPage() == pPage)
665 0 : pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pCandidate);
666 : }
667 : else
668 : {
669 : OSL_ASSERT(pCandidate!=NULL && pCandidate->TRG_HasMasterPage());
670 : }
671 : }
672 0 : }
673 : }
674 :
675 :
676 :
677 :
678 0 : void Listener::ThrowIfDisposed (void)
679 : throw (::com::sun::star::lang::DisposedException)
680 : {
681 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
682 : {
683 : throw lang::DisposedException ("SlideSorterController object has already been disposed",
684 0 : static_cast<uno::XWeak*>(this));
685 : }
686 0 : }
687 :
688 :
689 :
690 :
691 : } } } // end of namespace ::sd::slidesorter::controller
692 :
693 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|