1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SDEXT_PRESENTER_SLIDE_SHOW_VIEW_HXX
25 #define SDEXT_PRESENTER_SLIDE_SHOW_VIEW_HXX
26 
27 #include "PresenterViewFactory.hxx"
28 #include <com/sun/star/presentation/XSlideShowView.hpp>
29 #include <com/sun/star/awt/XPaintListener.hpp>
30 #include <com/sun/star/awt/XMouseListener.hpp>
31 #include <com/sun/star/awt/XMouseMotionListener.hpp>
32 #include <com/sun/star/awt/XPointer.hpp>
33 #include <com/sun/star/awt/XWindowListener.hpp>
34 #include <com/sun/star/drawing/XDrawView.hpp>
35 #include <com/sun/star/drawing/framework/XPane.hpp>
36 #include <com/sun/star/drawing/framework/XResourceId.hpp>
37 #include <com/sun/star/drawing/framework/XView.hpp>
38 #include <com/sun/star/frame/XController.hpp>
39 #include <com/sun/star/presentation/XSlideShowController.hpp>
40 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
41 #include <com/sun/star/uno/XComponentContext.hpp>
42 #include <com/sun/star/util/Color.hpp>
43 #include <cppuhelper/compbase7.hxx>
44 #include <cppuhelper/interfacecontainer.hxx>
45 #include <cppuhelper/basemutex.hxx>
46 #include <boost/noncopyable.hpp>
47 
48 namespace css = ::com::sun::star;
49 
50 namespace sdext { namespace presenter {
51 
52 namespace {
53     typedef cppu::WeakComponentImplHelper7<
54         css::presentation::XSlideShowView,
55         css::awt::XPaintListener,
56         css::awt::XMouseListener,
57         css::awt::XMouseMotionListener,
58         css::awt::XWindowListener,
59         css::drawing::framework::XView,
60         css::drawing::XDrawView
61         > PresenterSlideShowViewInterfaceBase;
62 }
63 
64 /** Life view in a secondary windo of a full screen slide show.
65 */
66 class PresenterSlideShowView
67     : private ::boost::noncopyable,
68       protected ::cppu::BaseMutex,
69       public PresenterSlideShowViewInterfaceBase,
70       public CachablePresenterView
71 {
72 public:
73     PresenterSlideShowView (
74         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
75         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
76         const css::uno::Reference<css::frame::XController>& rxController,
77         const ::rtl::Reference<PresenterController>& rpPresenterController);
78     virtual ~PresenterSlideShowView (void);
79 
80     void LateInit (void);
81     virtual void SAL_CALL disposing (void);
82 
83 
84     // CachablePresenterView
85 
86     virtual void ReleaseView (void);
87 
88 
89     // XSlideShowView
90 
91     virtual css::uno::Reference<
92         css::rendering::XSpriteCanvas > SAL_CALL getCanvas (void)
93         throw (css::uno::RuntimeException);
94 
95     virtual void SAL_CALL clear (void)
96         throw (css::uno::RuntimeException);
97 
98     virtual css::geometry::AffineMatrix2D SAL_CALL getTransformation (void)
99         throw (css::uno::RuntimeException);
100 
101     virtual void SAL_CALL addTransformationChangedListener(
102         const css::uno::Reference<
103             css::util::XModifyListener >& xListener)
104         throw (css::uno::RuntimeException);
105 
106     virtual void SAL_CALL removeTransformationChangedListener(
107         const css::uno::Reference<
108             css::util::XModifyListener >& xListener)
109         throw (css::uno::RuntimeException);
110 
111     virtual void SAL_CALL addPaintListener(
112         const css::uno::Reference<
113             css::awt::XPaintListener >& xListener)
114         throw (css::uno::RuntimeException);
115 
116     virtual void SAL_CALL removePaintListener(
117         const css::uno::Reference<
118             css::awt::XPaintListener >& xListener)
119         throw (css::uno::RuntimeException);
120 
121     virtual void SAL_CALL addMouseListener(
122         const css::uno::Reference<
123             css::awt::XMouseListener >& xListener)
124         throw (css::uno::RuntimeException);
125 
126     virtual void SAL_CALL removeMouseListener(
127         const css::uno::Reference<
128             css::awt::XMouseListener >& xListener)
129         throw (css::uno::RuntimeException);
130 
131     virtual void SAL_CALL addMouseMotionListener(
132         const css::uno::Reference<
133             css::awt::XMouseMotionListener >& xListener)
134         throw (css::uno::RuntimeException);
135 
136     virtual void SAL_CALL removeMouseMotionListener(
137         const css::uno::Reference<
138             css::awt::XMouseMotionListener >& xListener)
139         throw (css::uno::RuntimeException);
140 
141     virtual void SAL_CALL setMouseCursor(::sal_Int16 nPointerShape)
142         throw (css::uno::RuntimeException);
143 
144     virtual ::com::sun::star::awt::Rectangle SAL_CALL getCanvasArea(  )
145 	throw (::com::sun::star::uno::RuntimeException);
146 
147     // lang::XEventListener
148     virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
149         throw (css::uno::RuntimeException);
150 
151 
152     // XPaintListener
153     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
154         throw (css::uno::RuntimeException);
155 
156 
157     // XMouseListener
158     virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
159         throw (css::uno::RuntimeException);
160 
161     virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
162         throw (css::uno::RuntimeException);
163 
164     virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
165         throw (css::uno::RuntimeException);
166 
167     virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
168         throw (css::uno::RuntimeException);
169 
170 
171     // XMouseMotionListener
172 
173     virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent)
174         throw (css::uno::RuntimeException);
175 
176     virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent)
177         throw (css::uno::RuntimeException);
178 
179 
180     // XWindowListener
181 
182     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
183         throw (css::uno::RuntimeException);
184 
185     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
186         throw (css::uno::RuntimeException);
187 
188     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
189         throw (css::uno::RuntimeException);
190 
191     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
192         throw (css::uno::RuntimeException);
193 
194 
195     // XView
196 
197     virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL
198         getResourceId (void)
199         throw(css::uno::RuntimeException);
200 
201     virtual sal_Bool SAL_CALL isAnchorOnly (void)
202         throw (com::sun::star::uno::RuntimeException);
203 
204 
205     // XDrawView
206 
207     virtual void SAL_CALL setCurrentPage (
208         const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
209         throw (css::uno::RuntimeException);
210 
211     virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void)
212         throw (css::uno::RuntimeException);
213 
214 
215     // CachablePresenterView
216 
217     virtual void ActivatePresenterView (void);
218 
219     virtual void DeactivatePresenterView (void);
220 
221 private:
222     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
223     ::rtl::Reference<PresenterController> mpPresenterController;
224     css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
225     css::uno::Reference<css::frame::XController> mxController;
226     css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
227     css::uno::Reference<css::presentation::XSlideShow> mxSlideShow;
228     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
229     css::uno::Reference<css::rendering::XCanvas> mxViewCanvas;
230     css::uno::Reference<css::awt::XPointer> mxPointer;
231     css::uno::Reference<css::awt::XWindow> mxWindow;
232     css::uno::Reference<css::awt::XWindow> mxViewWindow;
233     css::uno::Reference<css::drawing::framework::XPane> mxTopPane;
234     css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
235     css::uno::Reference<css::rendering::XPolyPolygon2D> mxBackgroundPolygon1;
236     css::uno::Reference<css::rendering::XPolyPolygon2D> mxBackgroundPolygon2;
237     bool mbIsViewAdded;
238 
239     /** Aspect ratio of the current slide.
240     */
241     double mnPageAspectRatio;
242 
243     /** This broadcast helper is used to notify listeners registed to a
244         SlideShowView object.
245     */
246     ::cppu::OBroadcastHelper maBroadcaster;
247 
248     SharedBitmapDescriptor mpBackground;
249 
250     bool mbIsInModifyNotification;
251     bool mbIsForcedPaintPending;
252     bool mbIsPaintPending;
253     ::rtl::OUString msClickToExitPresentationText;
254     ::rtl::OUString msClickToExitPresentationTitle;
255     ::rtl::OUString msTitleTemplate;
256     bool mbIsEndSlideVisible;
257     css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide;
258 
259     /** Create the window into which the slide show will render its
260         content.  This window has the correct aspect ratio and is displayed centered
261         and as large as possible in its parent window.
262     */
263     css::uno::Reference<css::awt::XWindow> CreateViewWindow (
264         const css::uno::Reference<css::awt::XWindow>& rxParentWindow) const;
265     css::uno::Reference<css::rendering::XCanvas> CreateViewCanvas (
266         const css::uno::Reference<css::awt::XWindow>& rxWindow) const;
267 
268     void Resize (void);
269 
270     void PaintOuterWindow (const css::awt::Rectangle& rRepaintBox);
271     void PaintInnerWindow (const css::awt::PaintEvent& rEvent);
272     void PaintEndSlide (const css::awt::Rectangle& rRepaintBox);
273 
274     /** The slide show relies on the back buffer of the canvas not being
275         modified.  With a shared canvas there are times when that can not be
276         guaranteed.
277         Call this method when the back buffer may have changed its content,
278         like when the window has been moved but not resized.
279     */
280     void ForceRepaint (void);
281 
282     void CreateBackgroundPolygons (void);
283 
284     /** This method throws a DisposedException when the object has already been
285         disposed.
286     */
287     void ThrowIfDisposed (void)
288         throw (css::lang::DisposedException);
289 };
290 
291 } } // end of namespace ::sd::presenter
292 
293 #endif
294