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