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 "PresenterPane.hxx"
28cdf0e10cSrcweir #include "PresenterController.hxx"
29cdf0e10cSrcweir #include "PresenterPaintManager.hxx"
30cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
31cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/CanvasFeature.hpp>
33cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp>
34cdf0e10cSrcweir #include <osl/mutex.hxx>
35cdf0e10cSrcweir
36cdf0e10cSrcweir using namespace ::com::sun::star;
37cdf0e10cSrcweir using namespace ::com::sun::star::uno;
38cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
39cdf0e10cSrcweir using ::rtl::OUString;
40cdf0e10cSrcweir
41cdf0e10cSrcweir namespace sdext { namespace presenter {
42cdf0e10cSrcweir
43cdf0e10cSrcweir //===== PresenterPane =========================================================
44cdf0e10cSrcweir
PresenterPane(const Reference<XComponentContext> & rxContext,const::rtl::Reference<PresenterController> & rpPresenterController)45cdf0e10cSrcweir PresenterPane::PresenterPane (
46cdf0e10cSrcweir const Reference<XComponentContext>& rxContext,
47cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController)
48cdf0e10cSrcweir : PresenterPaneBase(rxContext, rpPresenterController),
49cdf0e10cSrcweir maBoundingBox()
50cdf0e10cSrcweir {
51cdf0e10cSrcweir Reference<lang::XMultiComponentFactory> xFactory (
52cdf0e10cSrcweir mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
53cdf0e10cSrcweir mxPresenterHelper = Reference<drawing::XPresenterHelper>(
54cdf0e10cSrcweir xFactory->createInstanceWithContext(
55cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.comp.Draw.PresenterHelper"),
56cdf0e10cSrcweir mxComponentContext),
57cdf0e10cSrcweir UNO_QUERY_THROW);
58cdf0e10cSrcweir }
59cdf0e10cSrcweir
60cdf0e10cSrcweir
61cdf0e10cSrcweir
62cdf0e10cSrcweir
~PresenterPane(void)63cdf0e10cSrcweir PresenterPane::~PresenterPane (void)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
67cdf0e10cSrcweir
68cdf0e10cSrcweir
69cdf0e10cSrcweir
70cdf0e10cSrcweir //----- XPane -----------------------------------------------------------------
71cdf0e10cSrcweir
getWindow(void)72cdf0e10cSrcweir Reference<awt::XWindow> SAL_CALL PresenterPane::getWindow (void)
73cdf0e10cSrcweir throw (RuntimeException)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir ThrowIfDisposed();
76cdf0e10cSrcweir return mxContentWindow;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir
80cdf0e10cSrcweir
81cdf0e10cSrcweir
getCanvas(void)82cdf0e10cSrcweir Reference<rendering::XCanvas> SAL_CALL PresenterPane::getCanvas (void)
83cdf0e10cSrcweir throw (RuntimeException)
84cdf0e10cSrcweir {
85cdf0e10cSrcweir ThrowIfDisposed();
86cdf0e10cSrcweir return mxContentCanvas;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89cdf0e10cSrcweir
90cdf0e10cSrcweir
91cdf0e10cSrcweir
92cdf0e10cSrcweir //----- XWindowListener -------------------------------------------------------
93cdf0e10cSrcweir
windowResized(const awt::WindowEvent & rEvent)94cdf0e10cSrcweir void SAL_CALL PresenterPane::windowResized (const awt::WindowEvent& rEvent)
95cdf0e10cSrcweir throw (RuntimeException)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir (void)rEvent;
98cdf0e10cSrcweir PresenterPaneBase::windowResized(rEvent);
99cdf0e10cSrcweir
100cdf0e10cSrcweir Invalidate(maBoundingBox);
101cdf0e10cSrcweir
102cdf0e10cSrcweir LayoutContextWindow();
103cdf0e10cSrcweir ToTop();
104cdf0e10cSrcweir
105cdf0e10cSrcweir UpdateBoundingBox();
106cdf0e10cSrcweir Invalidate(maBoundingBox);
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
109cdf0e10cSrcweir
110cdf0e10cSrcweir
111cdf0e10cSrcweir
112cdf0e10cSrcweir
windowMoved(const awt::WindowEvent & rEvent)113cdf0e10cSrcweir void SAL_CALL PresenterPane::windowMoved (const awt::WindowEvent& rEvent)
114cdf0e10cSrcweir throw (RuntimeException)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir (void)rEvent;
117cdf0e10cSrcweir PresenterPaneBase::windowMoved(rEvent);
118cdf0e10cSrcweir
119cdf0e10cSrcweir Invalidate(maBoundingBox);
120cdf0e10cSrcweir
121cdf0e10cSrcweir ToTop();
122cdf0e10cSrcweir
123cdf0e10cSrcweir UpdateBoundingBox();
124cdf0e10cSrcweir Invalidate(maBoundingBox);
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir
128cdf0e10cSrcweir
129cdf0e10cSrcweir
windowShown(const lang::EventObject & rEvent)130cdf0e10cSrcweir void SAL_CALL PresenterPane::windowShown (const lang::EventObject& rEvent)
131cdf0e10cSrcweir throw (RuntimeException)
132cdf0e10cSrcweir {
133cdf0e10cSrcweir (void)rEvent;
134cdf0e10cSrcweir PresenterPaneBase::windowShown(rEvent);
135cdf0e10cSrcweir
136cdf0e10cSrcweir ToTop();
137cdf0e10cSrcweir
138cdf0e10cSrcweir if (mxContentWindow.is())
139cdf0e10cSrcweir {
140cdf0e10cSrcweir LayoutContextWindow();
141cdf0e10cSrcweir mxContentWindow->setVisible(sal_True);
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
144cdf0e10cSrcweir UpdateBoundingBox();
145cdf0e10cSrcweir Invalidate(maBoundingBox);
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
148cdf0e10cSrcweir
149cdf0e10cSrcweir
150cdf0e10cSrcweir
windowHidden(const lang::EventObject & rEvent)151cdf0e10cSrcweir void SAL_CALL PresenterPane::windowHidden (const lang::EventObject& rEvent)
152cdf0e10cSrcweir throw (RuntimeException)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir (void)rEvent;
155cdf0e10cSrcweir PresenterPaneBase::windowHidden(rEvent);
156cdf0e10cSrcweir
157cdf0e10cSrcweir if (mxContentWindow.is())
158cdf0e10cSrcweir mxContentWindow->setVisible(sal_False);
159cdf0e10cSrcweir }
160cdf0e10cSrcweir
161cdf0e10cSrcweir
162cdf0e10cSrcweir
163cdf0e10cSrcweir
164cdf0e10cSrcweir //----- XPaintListener --------------------------------------------------------
165cdf0e10cSrcweir
windowPaint(const awt::PaintEvent & rEvent)166cdf0e10cSrcweir void SAL_CALL PresenterPane::windowPaint (const awt::PaintEvent& rEvent)
167cdf0e10cSrcweir throw (RuntimeException)
168cdf0e10cSrcweir {
169cdf0e10cSrcweir (void)rEvent;
170cdf0e10cSrcweir ThrowIfDisposed();
171cdf0e10cSrcweir
172cdf0e10cSrcweir PaintBorder(rEvent.UpdateRect);
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
175cdf0e10cSrcweir
176cdf0e10cSrcweir
177cdf0e10cSrcweir
178cdf0e10cSrcweir //-----------------------------------------------------------------------------
179cdf0e10cSrcweir
180cdf0e10cSrcweir
CreateCanvases(const Reference<awt::XWindow> & rxParentWindow,const Reference<rendering::XSpriteCanvas> & rxParentCanvas)181cdf0e10cSrcweir void PresenterPane::CreateCanvases (
182cdf0e10cSrcweir const Reference<awt::XWindow>& rxParentWindow,
183cdf0e10cSrcweir const Reference<rendering::XSpriteCanvas>& rxParentCanvas)
184cdf0e10cSrcweir {
185cdf0e10cSrcweir if ( ! mxPresenterHelper.is())
186cdf0e10cSrcweir return;
187cdf0e10cSrcweir if ( ! rxParentWindow.is())
188cdf0e10cSrcweir return;
189cdf0e10cSrcweir if ( ! rxParentCanvas.is())
190cdf0e10cSrcweir return;
191cdf0e10cSrcweir
192cdf0e10cSrcweir mxBorderCanvas = mxPresenterHelper->createSharedCanvas(
193cdf0e10cSrcweir rxParentCanvas,
194cdf0e10cSrcweir rxParentWindow,
195cdf0e10cSrcweir Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY),
196cdf0e10cSrcweir rxParentWindow,
197cdf0e10cSrcweir mxBorderWindow);
198cdf0e10cSrcweir mxContentCanvas = mxPresenterHelper->createSharedCanvas(
199cdf0e10cSrcweir rxParentCanvas,
200cdf0e10cSrcweir rxParentWindow,
201cdf0e10cSrcweir Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY),
202cdf0e10cSrcweir rxParentWindow,
203cdf0e10cSrcweir mxContentWindow);
204cdf0e10cSrcweir
205cdf0e10cSrcweir PaintBorder(mxBorderWindow->getPosSize());
206cdf0e10cSrcweir }
207cdf0e10cSrcweir
208cdf0e10cSrcweir
209cdf0e10cSrcweir
210cdf0e10cSrcweir
Invalidate(const css::awt::Rectangle & rRepaintBox)211cdf0e10cSrcweir void PresenterPane::Invalidate (const css::awt::Rectangle& rRepaintBox)
212cdf0e10cSrcweir {
213cdf0e10cSrcweir // Invalidate the parent window to be able to invalidate an area outside
214cdf0e10cSrcweir // the current window area.
215cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow, rRepaintBox);
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
218cdf0e10cSrcweir
219cdf0e10cSrcweir
220cdf0e10cSrcweir
UpdateBoundingBox(void)221cdf0e10cSrcweir void PresenterPane::UpdateBoundingBox (void)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir if (mxBorderWindow.is() && IsVisible())
224cdf0e10cSrcweir maBoundingBox = mxBorderWindow->getPosSize();
225cdf0e10cSrcweir else
226cdf0e10cSrcweir maBoundingBox = awt::Rectangle();
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
229cdf0e10cSrcweir
230cdf0e10cSrcweir } } // end of namespace ::sd::presenter
231