1*c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c142477cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c142477cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c142477cSAndrew Rist  * distributed with this work for additional information
6*c142477cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c142477cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c142477cSAndrew Rist  * "License"); you may not use this file except in compliance
9*c142477cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c142477cSAndrew Rist  *
11*c142477cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c142477cSAndrew Rist  *
13*c142477cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c142477cSAndrew Rist  * software distributed under the License is distributed on an
15*c142477cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c142477cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c142477cSAndrew Rist  * specific language governing permissions and limitations
18*c142477cSAndrew Rist  * under the License.
19*c142477cSAndrew Rist  *
20*c142477cSAndrew Rist  *************************************************************/
21*c142477cSAndrew Rist 
22*c142477cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterSlidePreview.hxx"
28cdf0e10cSrcweir #include "PresenterCanvasHelper.hxx"
29cdf0e10cSrcweir #include "PresenterGeometryHelper.hxx"
30cdf0e10cSrcweir #include "PresenterPaintManager.hxx"
31cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
32cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
33cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
34cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
35cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
36cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XPane.hpp>
37cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir using namespace ::com::sun::star;
40cdf0e10cSrcweir using namespace ::com::sun::star::uno;
41cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
42cdf0e10cSrcweir using ::rtl::OUString;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir namespace
45cdf0e10cSrcweir {
46cdf0e10cSrcweir     // Use a super sample factor greater than 1 to achive a poor mans
47cdf0e10cSrcweir     // antialiasing effect for slide previews.
48cdf0e10cSrcweir     const sal_Int16 gnSuperSampleFactor = 2;
49cdf0e10cSrcweir }
50cdf0e10cSrcweir 
51cdf0e10cSrcweir namespace sdext { namespace presenter {
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //===== PresenterSlidePreview =================================================
54cdf0e10cSrcweir 
PresenterSlidePreview(const Reference<XComponentContext> & rxContext,const Reference<XResourceId> & rxViewId,const Reference<XPane> & rxAnchorPane,const::rtl::Reference<PresenterController> & rpPresenterController)55cdf0e10cSrcweir PresenterSlidePreview::PresenterSlidePreview (
56cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
57cdf0e10cSrcweir     const Reference<XResourceId>& rxViewId,
58cdf0e10cSrcweir     const Reference<XPane>& rxAnchorPane,
59cdf0e10cSrcweir     const ::rtl::Reference<PresenterController>& rpPresenterController)
60cdf0e10cSrcweir     : PresenterSlidePreviewInterfaceBase(m_aMutex),
61cdf0e10cSrcweir       mpPresenterController(rpPresenterController),
62cdf0e10cSrcweir       mxPane(rxAnchorPane),
63cdf0e10cSrcweir       mxViewId(rxViewId),
64cdf0e10cSrcweir       mxPreviewRenderer(),
65cdf0e10cSrcweir       mxPreview(),
66cdf0e10cSrcweir       mxCurrentSlide(),
67cdf0e10cSrcweir       mnSlideAspectRatio(28.0 / 21.0),
68cdf0e10cSrcweir       mxWindow(),
69cdf0e10cSrcweir       mxCanvas()
70cdf0e10cSrcweir {
71cdf0e10cSrcweir     if ( ! rxContext.is()
72cdf0e10cSrcweir         || ! rxViewId.is()
73cdf0e10cSrcweir         || ! rxAnchorPane.is()
74cdf0e10cSrcweir         || ! rpPresenterController.is())
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir         throw RuntimeException(
77cdf0e10cSrcweir             OUString::createFromAscii(
78cdf0e10cSrcweir                 "PresenterSlidePreview can not be constructed due to empty argument"),
79cdf0e10cSrcweir             static_cast<XWeak*>(this));
80cdf0e10cSrcweir     }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     mxWindow = rxAnchorPane->getWindow();
83cdf0e10cSrcweir     mxCanvas = rxAnchorPane->getCanvas();
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     if (mxWindow.is())
86cdf0e10cSrcweir     {
87cdf0e10cSrcweir         mxWindow->addWindowListener(this);
88cdf0e10cSrcweir         mxWindow->addPaintListener(this);
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY);
91cdf0e10cSrcweir         if (xPeer.is())
92cdf0e10cSrcweir             xPeer->setBackground(util::Color(0xff000000));
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         mxWindow->setVisible(sal_True);
95cdf0e10cSrcweir     }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     if (mpPresenterController.get() != NULL)
98cdf0e10cSrcweir         mnSlideAspectRatio = mpPresenterController->GetSlideAspectRatio();
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     Reference<lang::XMultiComponentFactory> xFactory (rxContext->getServiceManager(), UNO_QUERY);
101cdf0e10cSrcweir     if (xFactory.is())
102cdf0e10cSrcweir         mxPreviewRenderer = Reference<drawing::XSlideRenderer>(
103cdf0e10cSrcweir             xFactory->createInstanceWithContext(
104cdf0e10cSrcweir                 OUString::createFromAscii("com.sun.star.drawing.SlideRenderer"),
105cdf0e10cSrcweir                 rxContext),
106cdf0e10cSrcweir             UNO_QUERY);
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     Resize();
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 
~PresenterSlidePreview(void)114cdf0e10cSrcweir PresenterSlidePreview::~PresenterSlidePreview (void)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
disposing(void)121cdf0e10cSrcweir void SAL_CALL PresenterSlidePreview::disposing (void)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     if (mxWindow.is())
124cdf0e10cSrcweir     {
125cdf0e10cSrcweir         mxWindow->removeWindowListener(this);
126cdf0e10cSrcweir         mxWindow->removePaintListener(this);
127cdf0e10cSrcweir         mxWindow = NULL;
128cdf0e10cSrcweir         mxCanvas = NULL;
129cdf0e10cSrcweir     }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     Reference<lang::XComponent> xComponent (mxPreviewRenderer, UNO_QUERY);
132cdf0e10cSrcweir     if (xComponent.is())
133cdf0e10cSrcweir         xComponent->dispose();
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 
139cdf0e10cSrcweir //----- XResourceId -----------------------------------------------------------
140cdf0e10cSrcweir 
getResourceId(void)141cdf0e10cSrcweir Reference<XResourceId> SAL_CALL PresenterSlidePreview::getResourceId (void)
142cdf0e10cSrcweir     throw (RuntimeException)
143cdf0e10cSrcweir {
144cdf0e10cSrcweir     return mxViewId;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 
isAnchorOnly(void)150cdf0e10cSrcweir sal_Bool SAL_CALL PresenterSlidePreview::isAnchorOnly (void)
151cdf0e10cSrcweir     throw (RuntimeException)
152cdf0e10cSrcweir {
153cdf0e10cSrcweir     return false;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 
159cdf0e10cSrcweir //----- XWindowListener -------------------------------------------------------
160cdf0e10cSrcweir 
windowResized(const awt::WindowEvent & rEvent)161cdf0e10cSrcweir void SAL_CALL PresenterSlidePreview::windowResized (const awt::WindowEvent& rEvent)
162cdf0e10cSrcweir     throw (RuntimeException)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     (void)rEvent;
165cdf0e10cSrcweir     ThrowIfDisposed();
166cdf0e10cSrcweir     ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
167cdf0e10cSrcweir     Resize();
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 
windowMoved(const awt::WindowEvent & rEvent)174cdf0e10cSrcweir void SAL_CALL PresenterSlidePreview::windowMoved (const awt::WindowEvent& rEvent)
175cdf0e10cSrcweir     throw (RuntimeException)
176cdf0e10cSrcweir {
177cdf0e10cSrcweir     (void)rEvent;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 
windowShown(const lang::EventObject & rEvent)183cdf0e10cSrcweir void SAL_CALL PresenterSlidePreview::windowShown (const lang::EventObject& rEvent)
184cdf0e10cSrcweir     throw (RuntimeException)
185cdf0e10cSrcweir {
186cdf0e10cSrcweir     (void)rEvent;
187cdf0e10cSrcweir     ThrowIfDisposed();
188cdf0e10cSrcweir     ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
189cdf0e10cSrcweir     Resize();
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 
windowHidden(const lang::EventObject & rEvent)195cdf0e10cSrcweir void SAL_CALL PresenterSlidePreview::windowHidden (const lang::EventObject& rEvent)
196cdf0e10cSrcweir     throw (RuntimeException)
197cdf0e10cSrcweir {
198cdf0e10cSrcweir     (void)rEvent;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 
204cdf0e10cSrcweir //----- XPaintListener --------------------------------------------------------
205cdf0e10cSrcweir 
windowPaint(const awt::PaintEvent & rEvent)206cdf0e10cSrcweir void SAL_CALL PresenterSlidePreview::windowPaint (const awt::PaintEvent& rEvent)
207cdf0e10cSrcweir     throw (RuntimeException)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir     ThrowIfDisposed();
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
212cdf0e10cSrcweir     if (mxWindow.is())
213cdf0e10cSrcweir         Paint(awt::Rectangle(
214cdf0e10cSrcweir             rEvent.UpdateRect.X,
215cdf0e10cSrcweir             rEvent.UpdateRect.Y,
216cdf0e10cSrcweir             rEvent.UpdateRect.Width,
217cdf0e10cSrcweir             rEvent.UpdateRect.Height));
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 
223cdf0e10cSrcweir //----- lang::XEventListener --------------------------------------------------
224cdf0e10cSrcweir 
disposing(const lang::EventObject & rEvent)225cdf0e10cSrcweir void SAL_CALL PresenterSlidePreview::disposing (const lang::EventObject& rEvent)
226cdf0e10cSrcweir     throw (RuntimeException)
227cdf0e10cSrcweir {
228cdf0e10cSrcweir     if (rEvent.Source == mxWindow)
229cdf0e10cSrcweir     {
230cdf0e10cSrcweir         mxWindow = NULL;
231cdf0e10cSrcweir         mxCanvas = NULL;
232cdf0e10cSrcweir         mxPreview = NULL;
233cdf0e10cSrcweir     }
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 
239cdf0e10cSrcweir //----- XDrawView -------------------------------------------------------------
240cdf0e10cSrcweir 
setCurrentPage(const Reference<drawing::XDrawPage> & rxSlide)241cdf0e10cSrcweir void SAL_CALL PresenterSlidePreview::setCurrentPage (const Reference<drawing::XDrawPage>& rxSlide)
242cdf0e10cSrcweir     throw (RuntimeException)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir     ThrowIfDisposed();
245cdf0e10cSrcweir     ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
246cdf0e10cSrcweir     SetSlide(rxSlide);
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 
getCurrentPage(void)252cdf0e10cSrcweir Reference<drawing::XDrawPage> SAL_CALL PresenterSlidePreview::getCurrentPage (void)
253cdf0e10cSrcweir     throw (RuntimeException)
254cdf0e10cSrcweir {
255cdf0e10cSrcweir     ThrowIfDisposed();
256cdf0e10cSrcweir     return NULL;
257cdf0e10cSrcweir }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 
262cdf0e10cSrcweir //-----------------------------------------------------------------------------
263cdf0e10cSrcweir 
SetSlide(const Reference<drawing::XDrawPage> & rxPage)264cdf0e10cSrcweir void PresenterSlidePreview::SetSlide (const Reference<drawing::XDrawPage>& rxPage)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir     mxCurrentSlide = rxPage;
267cdf0e10cSrcweir     mxPreview = NULL;
268cdf0e10cSrcweir 
269cdf0e10cSrcweir     Reference<beans::XPropertySet> xPropertySet (mxCurrentSlide, UNO_QUERY);
270cdf0e10cSrcweir     if (xPropertySet.is())
271cdf0e10cSrcweir     {
272cdf0e10cSrcweir         awt::Size aSlideSize;
273cdf0e10cSrcweir         try
274cdf0e10cSrcweir         {
275cdf0e10cSrcweir             xPropertySet->getPropertyValue(
276cdf0e10cSrcweir                 OUString::createFromAscii("Width")) >>= aSlideSize.Width;
277cdf0e10cSrcweir             xPropertySet->getPropertyValue(
278cdf0e10cSrcweir                 OUString::createFromAscii("Height")) >>= aSlideSize.Height;
279cdf0e10cSrcweir         }
280cdf0e10cSrcweir         catch (beans::UnknownPropertyException&)
281cdf0e10cSrcweir         {
282cdf0e10cSrcweir             OSL_ASSERT(false);
283cdf0e10cSrcweir         }
284cdf0e10cSrcweir     }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir     // The preview is not transparent, therefore only this window, not its
287cdf0e10cSrcweir     // parent, has to be invalidated.
288cdf0e10cSrcweir     mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 
Paint(const awt::Rectangle & rBoundingBox)294cdf0e10cSrcweir void PresenterSlidePreview::Paint (const awt::Rectangle& rBoundingBox)
295cdf0e10cSrcweir {
296cdf0e10cSrcweir     (void)rBoundingBox;
297cdf0e10cSrcweir     if ( ! mxWindow.is())
298cdf0e10cSrcweir         return;
299cdf0e10cSrcweir     if ( ! mxCanvas.is())
300cdf0e10cSrcweir         return;
301cdf0e10cSrcweir     if ( ! mxPreviewRenderer.is())
302cdf0e10cSrcweir         return;
303cdf0e10cSrcweir 
304cdf0e10cSrcweir     // Make sure that a preview in the correct size exists.
305cdf0e10cSrcweir     awt::Rectangle aWindowBox (mxWindow->getPosSize());
306cdf0e10cSrcweir 
307cdf0e10cSrcweir     if ( ! mxPreview.is() && mxCurrentSlide.is())
308cdf0e10cSrcweir     {
309cdf0e10cSrcweir         // Create a new preview bitmap.
310cdf0e10cSrcweir         mxPreview = mxPreviewRenderer->createPreviewForCanvas(
311cdf0e10cSrcweir             mxCurrentSlide,
312cdf0e10cSrcweir             awt::Size(aWindowBox.Width, aWindowBox.Height),
313cdf0e10cSrcweir             gnSuperSampleFactor,
314cdf0e10cSrcweir             mxCanvas);
315cdf0e10cSrcweir     }
316cdf0e10cSrcweir 
317cdf0e10cSrcweir     // Determine the bounding box of the preview.
318cdf0e10cSrcweir     awt::Rectangle aPreviewBox;
319cdf0e10cSrcweir     if (mxPreview.is())
320cdf0e10cSrcweir     {
321cdf0e10cSrcweir         const geometry::IntegerSize2D aPreviewSize (mxPreview->getSize());
322cdf0e10cSrcweir         aPreviewBox = awt::Rectangle(
323cdf0e10cSrcweir             (aWindowBox.Width - aPreviewSize.Width)/2,
324cdf0e10cSrcweir             (aWindowBox.Height - aPreviewSize.Height)/2,
325cdf0e10cSrcweir             aPreviewSize.Width,
326cdf0e10cSrcweir             aPreviewSize.Height);
327cdf0e10cSrcweir     }
328cdf0e10cSrcweir     else
329cdf0e10cSrcweir     {
330cdf0e10cSrcweir         if (mnSlideAspectRatio > 0)
331cdf0e10cSrcweir         {
332cdf0e10cSrcweir             const awt::Size aPreviewSize (mxPreviewRenderer->calculatePreviewSize(
333cdf0e10cSrcweir                 mnSlideAspectRatio,awt::Size(aWindowBox.Width, aWindowBox.Height)));
334cdf0e10cSrcweir             aPreviewBox = awt::Rectangle(
335cdf0e10cSrcweir                 (aWindowBox.Width - aPreviewSize.Width)/2,
336cdf0e10cSrcweir                 (aWindowBox.Height - aPreviewSize.Height)/2,
337cdf0e10cSrcweir                 aPreviewSize.Width,
338cdf0e10cSrcweir                 aPreviewSize.Height);
339cdf0e10cSrcweir         }
340cdf0e10cSrcweir     }
341cdf0e10cSrcweir 
342cdf0e10cSrcweir     // Paint the background.
343cdf0e10cSrcweir     mpPresenterController->GetCanvasHelper()->Paint(
344cdf0e10cSrcweir         mpPresenterController->GetViewBackground(mxViewId->getResourceURL()),
345cdf0e10cSrcweir         mxCanvas,
346cdf0e10cSrcweir         rBoundingBox,
347cdf0e10cSrcweir         awt::Rectangle(0,0,aWindowBox.Width,aWindowBox.Height),
348cdf0e10cSrcweir         aPreviewBox);
349cdf0e10cSrcweir 
350cdf0e10cSrcweir     // Paint the preview.
351cdf0e10cSrcweir     const rendering::ViewState aViewState(
352cdf0e10cSrcweir         geometry::AffineMatrix2D(1,0,0, 0,1,0),
353cdf0e10cSrcweir         NULL);
354cdf0e10cSrcweir 
355cdf0e10cSrcweir     Sequence<double> aBackgroundColor(4);
356cdf0e10cSrcweir     rendering::RenderState aRenderState (
357cdf0e10cSrcweir         geometry::AffineMatrix2D(1, 0, aPreviewBox.X, 0, 1, aPreviewBox.Y),
358cdf0e10cSrcweir         NULL,
359cdf0e10cSrcweir         aBackgroundColor,
360cdf0e10cSrcweir         rendering::CompositeOperation::SOURCE);
361cdf0e10cSrcweir     PresenterCanvasHelper::SetDeviceColor(aRenderState, 0x00000000);
362cdf0e10cSrcweir     if (mxPreview.is())
363cdf0e10cSrcweir     {
364cdf0e10cSrcweir         mxCanvas->drawBitmap(mxPreview, aViewState, aRenderState);
365cdf0e10cSrcweir     }
366cdf0e10cSrcweir     else
367cdf0e10cSrcweir     {
368cdf0e10cSrcweir         if (mnSlideAspectRatio > 0)
369cdf0e10cSrcweir         {
370cdf0e10cSrcweir             Reference<rendering::XPolyPolygon2D> xPolygon (
371cdf0e10cSrcweir                 PresenterGeometryHelper::CreatePolygon(aPreviewBox, mxCanvas->getDevice()));
372cdf0e10cSrcweir             if (xPolygon.is())
373cdf0e10cSrcweir                 mxCanvas->fillPolyPolygon(xPolygon, aViewState, aRenderState);
374cdf0e10cSrcweir         }
375cdf0e10cSrcweir     }
376cdf0e10cSrcweir 
377cdf0e10cSrcweir     Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
378cdf0e10cSrcweir     if (xSpriteCanvas.is())
379cdf0e10cSrcweir         xSpriteCanvas->updateScreen(sal_False);
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 
Resize(void)385cdf0e10cSrcweir void PresenterSlidePreview::Resize (void)
386cdf0e10cSrcweir {
387cdf0e10cSrcweir     if (mxPreviewRenderer.is() && mxPreview.is())
388cdf0e10cSrcweir     {
389cdf0e10cSrcweir         const awt::Rectangle aWindowBox (mxWindow->getPosSize());
390cdf0e10cSrcweir         const awt::Size aNewPreviewSize (mxPreviewRenderer->calculatePreviewSize(
391cdf0e10cSrcweir             mnSlideAspectRatio,
392cdf0e10cSrcweir                 awt::Size(aWindowBox.Width, aWindowBox.Height)));
393cdf0e10cSrcweir         const geometry::IntegerSize2D aPreviewSize (mxPreview->getSize());
394cdf0e10cSrcweir         if (aNewPreviewSize.Width==aPreviewSize.Width
395cdf0e10cSrcweir             && aNewPreviewSize.Height==aPreviewSize.Height)
396cdf0e10cSrcweir         {
397cdf0e10cSrcweir             // The size of the window may have changed but the preview would
398cdf0e10cSrcweir             // be painted in the same size (but not necessarily at the same
399cdf0e10cSrcweir             // position.)
400cdf0e10cSrcweir             return;
401cdf0e10cSrcweir         }
402cdf0e10cSrcweir     }
403cdf0e10cSrcweir     SetSlide(mxCurrentSlide);
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 
ThrowIfDisposed(void)409cdf0e10cSrcweir void PresenterSlidePreview::ThrowIfDisposed (void)
410cdf0e10cSrcweir     throw (::com::sun::star::lang::DisposedException)
411cdf0e10cSrcweir {
412cdf0e10cSrcweir 	if (PresenterSlidePreviewInterfaceBase::rBHelper.bDisposed || PresenterSlidePreviewInterfaceBase::rBHelper.bInDispose)
413cdf0e10cSrcweir 	{
414cdf0e10cSrcweir         throw lang::DisposedException (
415cdf0e10cSrcweir             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
416cdf0e10cSrcweir                 "PresenterSlidePreview object has already been disposed")),
417cdf0e10cSrcweir             static_cast<uno::XWeak*>(this));
418cdf0e10cSrcweir     }
419cdf0e10cSrcweir }
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 
422cdf0e10cSrcweir } } // end of namespace ::sd::presenter
423cdf0e10cSrcweir 
424