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: PresenterPane.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 "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
),
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"),
71 PresenterPane::~PresenterPane (void)
78 //----- XPane -----------------------------------------------------------------
80 Reference
<awt::XWindow
> SAL_CALL
PresenterPane::getWindow (void)
81 throw (RuntimeException
)
84 return mxContentWindow
;
90 Reference
<rendering::XCanvas
> SAL_CALL
PresenterPane::getCanvas (void)
91 throw (RuntimeException
)
94 return mxContentCanvas
;
100 //----- XWindowListener -------------------------------------------------------
102 void SAL_CALL
PresenterPane::windowResized (const awt::WindowEvent
& rEvent
)
103 throw (RuntimeException
)
106 PresenterPaneBase::windowResized(rEvent
);
108 Invalidate(maBoundingBox
);
110 LayoutContextWindow();
114 Invalidate(maBoundingBox
);
121 void SAL_CALL
PresenterPane::windowMoved (const awt::WindowEvent
& rEvent
)
122 throw (RuntimeException
)
125 PresenterPaneBase::windowMoved(rEvent
);
127 Invalidate(maBoundingBox
);
132 Invalidate(maBoundingBox
);
138 void SAL_CALL
PresenterPane::windowShown (const lang::EventObject
& rEvent
)
139 throw (RuntimeException
)
142 PresenterPaneBase::windowShown(rEvent
);
146 if (mxContentWindow
.is())
148 LayoutContextWindow();
149 mxContentWindow
->setVisible(sal_True
);
153 Invalidate(maBoundingBox
);
159 void SAL_CALL
PresenterPane::windowHidden (const lang::EventObject
& rEvent
)
160 throw (RuntimeException
)
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
)
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())
195 if ( ! rxParentWindow
.is())
197 if ( ! rxParentCanvas
.is())
200 mxBorderCanvas
= mxPresenterHelper
->createSharedCanvas(
203 Reference
<rendering::XCanvas
>(rxParentCanvas
, UNO_QUERY
),
206 mxContentCanvas
= mxPresenterHelper
->createSharedCanvas(
209 Reference
<rendering::XCanvas
>(rxParentCanvas
, UNO_QUERY
),
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();
234 maBoundingBox
= awt::Rectangle();
238 } } // end of namespace ::sd::presenter