Update ooo320-m1
[ooovba.git] / sdext / source / presenter / PresenterPane.cxx
blob17e5f91557eef6a97bb9a480b40660ce8a57d045
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterPane.cxx,v $
11 * $Revision: 1.5 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #include "PresenterPane.hxx"
36 #include "PresenterController.hxx"
37 #include "PresenterPaintManager.hxx"
38 #include <com/sun/star/awt/XWindowPeer.hpp>
39 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
40 #include <com/sun/star/drawing/CanvasFeature.hpp>
41 #include <com/sun/star/rendering/CompositeOperation.hpp>
42 #include <osl/mutex.hxx>
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::drawing::framework;
47 using ::rtl::OUString;
49 namespace sdext { namespace presenter {
51 //===== PresenterPane =========================================================
53 PresenterPane::PresenterPane (
54 const Reference<XComponentContext>& rxContext,
55 const ::rtl::Reference<PresenterController>& rpPresenterController)
56 : PresenterPaneBase(rxContext, rpPresenterController),
57 maBoundingBox()
59 Reference<lang::XMultiComponentFactory> xFactory (
60 mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
61 mxPresenterHelper = Reference<drawing::XPresenterHelper>(
62 xFactory->createInstanceWithContext(
63 OUString::createFromAscii("com.sun.star.comp.Draw.PresenterHelper"),
64 mxComponentContext),
65 UNO_QUERY_THROW);
71 PresenterPane::~PresenterPane (void)
78 //----- XPane -----------------------------------------------------------------
80 Reference<awt::XWindow> SAL_CALL PresenterPane::getWindow (void)
81 throw (RuntimeException)
83 ThrowIfDisposed();
84 return mxContentWindow;
90 Reference<rendering::XCanvas> SAL_CALL PresenterPane::getCanvas (void)
91 throw (RuntimeException)
93 ThrowIfDisposed();
94 return mxContentCanvas;
100 //----- XWindowListener -------------------------------------------------------
102 void SAL_CALL PresenterPane::windowResized (const awt::WindowEvent& rEvent)
103 throw (RuntimeException)
105 (void)rEvent;
106 PresenterPaneBase::windowResized(rEvent);
108 Invalidate(maBoundingBox);
110 LayoutContextWindow();
111 ToTop();
113 UpdateBoundingBox();
114 Invalidate(maBoundingBox);
121 void SAL_CALL PresenterPane::windowMoved (const awt::WindowEvent& rEvent)
122 throw (RuntimeException)
124 (void)rEvent;
125 PresenterPaneBase::windowMoved(rEvent);
127 Invalidate(maBoundingBox);
129 ToTop();
131 UpdateBoundingBox();
132 Invalidate(maBoundingBox);
138 void SAL_CALL PresenterPane::windowShown (const lang::EventObject& rEvent)
139 throw (RuntimeException)
141 (void)rEvent;
142 PresenterPaneBase::windowShown(rEvent);
144 ToTop();
146 if (mxContentWindow.is())
148 LayoutContextWindow();
149 mxContentWindow->setVisible(sal_True);
152 UpdateBoundingBox();
153 Invalidate(maBoundingBox);
159 void SAL_CALL PresenterPane::windowHidden (const lang::EventObject& rEvent)
160 throw (RuntimeException)
162 (void)rEvent;
163 PresenterPaneBase::windowHidden(rEvent);
165 if (mxContentWindow.is())
166 mxContentWindow->setVisible(sal_False);
172 //----- XPaintListener --------------------------------------------------------
174 void SAL_CALL PresenterPane::windowPaint (const awt::PaintEvent& rEvent)
175 throw (RuntimeException)
177 (void)rEvent;
178 ThrowIfDisposed();
180 PaintBorder(rEvent.UpdateRect);
186 //-----------------------------------------------------------------------------
189 void PresenterPane::CreateCanvases (
190 const Reference<awt::XWindow>& rxParentWindow,
191 const Reference<rendering::XSpriteCanvas>& rxParentCanvas)
193 if ( ! mxPresenterHelper.is())
194 return;
195 if ( ! rxParentWindow.is())
196 return;
197 if ( ! rxParentCanvas.is())
198 return;
200 mxBorderCanvas = mxPresenterHelper->createSharedCanvas(
201 rxParentCanvas,
202 rxParentWindow,
203 Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY),
204 rxParentWindow,
205 mxBorderWindow);
206 mxContentCanvas = mxPresenterHelper->createSharedCanvas(
207 rxParentCanvas,
208 rxParentWindow,
209 Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY),
210 rxParentWindow,
211 mxContentWindow);
213 PaintBorder(mxBorderWindow->getPosSize());
219 void PresenterPane::Invalidate (const css::awt::Rectangle& rRepaintBox)
221 // Invalidate the parent window to be able to invalidate an area outside
222 // the current window area.
223 mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow, rRepaintBox);
229 void PresenterPane::UpdateBoundingBox (void)
231 if (mxBorderWindow.is() && IsVisible())
232 maBoundingBox = mxBorderWindow->getPosSize();
233 else
234 maBoundingBox = awt::Rectangle();
238 } } // end of namespace ::sd::presenter