1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterSpritePane.cxx,v $
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 "PresenterSpritePane.hxx"
36 #include "PresenterGeometryHelper.hxx"
37 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
38 #include <com/sun/star/rendering/CompositeOperation.hpp>
39 #include <osl/mutex.hxx>
41 using namespace ::com::sun::star
;
42 using namespace ::com::sun::star::uno
;
43 using namespace ::com::sun::star::drawing::framework
;
44 using ::rtl::OUString
;
46 namespace sdext
{ namespace presenter
{
48 //===== PresenterSpritePane =========================================================
50 PresenterSpritePane::PresenterSpritePane (const Reference
<XComponentContext
>& rxContext
,
51 const ::rtl::Reference
<PresenterController
>& rpPresenterController
)
52 : PresenterPaneBase(rxContext
, rpPresenterController
),
55 mpSprite(new PresenterSprite())
57 Reference
<lang::XMultiComponentFactory
> xFactory (
58 mxComponentContext
->getServiceManager(), UNO_QUERY_THROW
);
59 mxPresenterHelper
= Reference
<drawing::XPresenterHelper
>(
60 xFactory
->createInstanceWithContext(
61 OUString::createFromAscii("com.sun.star.comp.Draw.PresenterHelper"),
69 PresenterSpritePane::~PresenterSpritePane (void)
76 void PresenterSpritePane::disposing (void)
78 mpSprite
->SetFactory(NULL
);
79 mxParentWindow
= NULL
;
80 mxParentCanvas
= NULL
;
81 PresenterPaneBase::disposing();
87 //----- XPane -----------------------------------------------------------------
89 Reference
<awt::XWindow
> SAL_CALL
PresenterSpritePane::getWindow (void)
90 throw (RuntimeException
)
93 return mxContentWindow
;
99 Reference
<rendering::XCanvas
> SAL_CALL
PresenterSpritePane::getCanvas (void)
100 throw (RuntimeException
)
104 if ( ! mxContentCanvas
.is())
107 return mxContentCanvas
;
113 //----- XWindowListener -------------------------------------------------------
115 void SAL_CALL
PresenterSpritePane::windowResized (const awt::WindowEvent
& rEvent
)
116 throw (RuntimeException
)
119 PresenterPaneBase::windowResized(rEvent
);
121 mpSprite
->Resize(geometry::RealSize2D(rEvent
.Width
, rEvent
.Height
));
122 LayoutContextWindow();
130 void SAL_CALL
PresenterSpritePane::windowMoved (const awt::WindowEvent
& rEvent
)
131 throw (RuntimeException
)
134 PresenterPaneBase::windowMoved(rEvent
);
136 awt::Rectangle
aBox (
137 mxPresenterHelper
->getWindowExtentsRelative(mxBorderWindow
, mxParentWindow
));
138 mpSprite
->MoveTo(geometry::RealPoint2D(aBox
.X
, aBox
.Y
));
145 void SAL_CALL
PresenterSpritePane::windowShown (const lang::EventObject
& rEvent
)
146 throw (RuntimeException
)
149 PresenterPaneBase::windowShown(rEvent
);
154 if (mxContentWindow
.is())
156 LayoutContextWindow();
157 mxContentWindow
->setVisible(sal_True
);
164 void SAL_CALL
PresenterSpritePane::windowHidden (const lang::EventObject
& rEvent
)
165 throw (RuntimeException
)
168 PresenterPaneBase::windowHidden(rEvent
);
171 if (mxContentWindow
.is())
172 mxContentWindow
->setVisible(sal_False
);
178 //----- XPaintListener --------------------------------------------------------
180 void SAL_CALL
PresenterSpritePane::windowPaint (const awt::PaintEvent
& rEvent
)
181 throw (RuntimeException
)
187 Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxParentCanvas, UNO_QUERY);
188 if (xSpriteCanvas.is())
189 xSpriteCanvas->updateScreen(sal_False);
196 //-----------------------------------------------------------------------------
199 ::boost::shared_ptr
<PresenterSprite
> PresenterSpritePane::GetSprite (void)
207 void PresenterSpritePane::ShowTransparentBorder (void)
214 void PresenterSpritePane::UpdateCanvases (void)
216 Reference
<XComponent
> xContentCanvasComponent (mxContentCanvas
, UNO_QUERY
);
217 if (xContentCanvasComponent
.is())
219 if (xContentCanvasComponent
.is())
220 xContentCanvasComponent
->dispose();
223 // The border canvas is the content canvas of the sprite.
224 mxBorderCanvas
= mpSprite
->GetCanvas();
226 // The content canvas is a wrapper of the border canvas.
227 if (mxBorderCanvas
.is())
228 mxContentCanvas
= mxPresenterHelper
->createSharedCanvas(
235 const awt::Rectangle
aWindowBox (mxBorderWindow
->getPosSize());
236 PaintBorder(awt::Rectangle(0,0,aWindowBox
.Width
,aWindowBox
.Height
));
242 void PresenterSpritePane::CreateCanvases (
243 const css::uno::Reference
<css::awt::XWindow
>& rxParentWindow
,
244 const css::uno::Reference
<css::rendering::XSpriteCanvas
>& rxParentCanvas
)
246 OSL_ASSERT(!mxParentWindow
.is() || mxParentWindow
==rxParentWindow
);
247 OSL_ASSERT(!mxParentCanvas
.is() || mxParentCanvas
==rxParentCanvas
);
248 mxParentWindow
= rxParentWindow
;
249 mxParentCanvas
= rxParentCanvas
;
251 mpSprite
->SetFactory(mxParentCanvas
);
252 if (mxBorderWindow
.is())
254 const awt::Rectangle
aBorderBox (mxBorderWindow
->getPosSize());
255 mpSprite
->Resize(geometry::RealSize2D(aBorderBox
.Width
, aBorderBox
.Height
));
264 } } // end of namespace ::sd::presenter