1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_TOOL_BAR_HXX
29*cdf0e10cSrcweir #define SDEXT_PRESENTER_TOOL_BAR_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "PresenterController.hxx"
32*cdf0e10cSrcweir #include "PresenterViewFactory.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
35*cdf0e10cSrcweir #include <cppuhelper/compbase3.hxx>
36*cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx>
37*cdf0e10cSrcweir #include <com/sun/star/awt/ActionEvent.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/awt/XActionListener.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/awt/XButton.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/awt/XControl.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/awt/XControlContainer.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/awt/XFixedText.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/awt/XMouseListener.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/awt/XMouseMotionListener.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/awt/XPaintListener.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowListener.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/drawing/XPresenterHelper.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XView.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceId.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
54*cdf0e10cSrcweir #include <map>
55*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
56*cdf0e10cSrcweir #include <boost/function.hpp>
57*cdf0e10cSrcweir #include <boost/noncopyable.hpp>
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir namespace css = ::com::sun::star;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir namespace {
62*cdf0e10cSrcweir     typedef cppu::WeakComponentImplHelper5<
63*cdf0e10cSrcweir         css::awt::XWindowListener,
64*cdf0e10cSrcweir         css::awt::XPaintListener,
65*cdf0e10cSrcweir         css::awt::XMouseListener,
66*cdf0e10cSrcweir         css::awt::XMouseMotionListener,
67*cdf0e10cSrcweir         css::drawing::XDrawView
68*cdf0e10cSrcweir         > PresenterToolBarInterfaceBase;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     typedef cppu::WeakComponentImplHelper3<
71*cdf0e10cSrcweir         css::awt::XPaintListener,
72*cdf0e10cSrcweir         css::drawing::framework::XView,
73*cdf0e10cSrcweir         css::drawing::XDrawView
74*cdf0e10cSrcweir         > PresenterToolBarViewInterfaceBase;
75*cdf0e10cSrcweir }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir namespace sdext { namespace presenter {
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir /** A simple tool bar that can display bitmapped buttons and labels.  At the
80*cdf0e10cSrcweir     moment there are buttons for moving to the next and previous slide and
81*cdf0e10cSrcweir     to the next effect.  A label displayes the index of the current slide
82*cdf0e10cSrcweir     and the total number of slides.
83*cdf0e10cSrcweir */
84*cdf0e10cSrcweir class PresenterToolBar
85*cdf0e10cSrcweir     : private ::cppu::BaseMutex,
86*cdf0e10cSrcweir       private ::boost::noncopyable,
87*cdf0e10cSrcweir       public PresenterToolBarInterfaceBase,
88*cdf0e10cSrcweir       public CachablePresenterView
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir public:
91*cdf0e10cSrcweir     typedef ::boost::function<void(void)> Action;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     enum Anchor { Left, Center, Right };
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     PresenterToolBar (
96*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
97*cdf0e10cSrcweir         const css::uno::Reference<css::awt::XWindow>& rxWindow,
98*cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
99*cdf0e10cSrcweir         const ::rtl::Reference<PresenterController>& rpPresenterController,
100*cdf0e10cSrcweir         const Anchor eAnchor);
101*cdf0e10cSrcweir     virtual ~PresenterToolBar (void);
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     void Initialize (
104*cdf0e10cSrcweir         const ::rtl::OUString& rsConfigurationPath);
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     void InvalidateArea (
109*cdf0e10cSrcweir         const css::awt::Rectangle& rRepaintBox,
110*cdf0e10cSrcweir         const bool bSynchronous);
111*cdf0e10cSrcweir     sal_Int32 GetSlideCount (void);
112*cdf0e10cSrcweir     sal_Int32 GetCurrentSlideIndex (void);
113*cdf0e10cSrcweir     void RequestLayout (void);
114*cdf0e10cSrcweir     css::geometry::RealSize2D GetSize (void);
115*cdf0e10cSrcweir     css::geometry::RealSize2D GetMinimalSize (void);
116*cdf0e10cSrcweir     ::rtl::Reference<PresenterController> GetPresenterController (void) const;
117*cdf0e10cSrcweir     css::uno::Reference<css::awt::XWindow> GetWindow (void) const;
118*cdf0e10cSrcweir     css::uno::Reference<css::uno::XComponentContext> GetComponentContext (void) const;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     // lang::XEventListener
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     virtual void SAL_CALL
123*cdf0e10cSrcweir         disposing (const css::lang::EventObject& rEventObject)
124*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     // XWindowListener
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
130*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
133*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
136*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
139*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir     // XPaintListener
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
145*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     // XMouseListener
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
151*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir     virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
154*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
157*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
160*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir     // XMouseMotionListener
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent)
166*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent)
169*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     // XDrawView
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir     virtual void SAL_CALL setCurrentPage (
175*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
176*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void)
179*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     class Context;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir private:
184*cdf0e10cSrcweir     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     class ElementContainerPart;
187*cdf0e10cSrcweir     typedef ::boost::shared_ptr<ElementContainerPart> SharedElementContainerPart;
188*cdf0e10cSrcweir     typedef ::std::vector<SharedElementContainerPart> ElementContainer;
189*cdf0e10cSrcweir     ElementContainer maElementContainer;
190*cdf0e10cSrcweir     SharedElementContainerPart mpCurrentContainerPart;
191*cdf0e10cSrcweir     css::uno::Reference<css::awt::XWindow> mxWindow;
192*cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
193*cdf0e10cSrcweir     css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
194*cdf0e10cSrcweir     css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide;
195*cdf0e10cSrcweir     ::rtl::Reference<PresenterController> mpPresenterController;
196*cdf0e10cSrcweir     bool mbIsLayoutPending;
197*cdf0e10cSrcweir     const Anchor meAnchor;
198*cdf0e10cSrcweir     css::geometry::RealRectangle2D maBoundingBox;
199*cdf0e10cSrcweir     /** The minimal size that is necessary to display all elements without
200*cdf0e10cSrcweir         overlap and with minimal gaps between them.
201*cdf0e10cSrcweir     */
202*cdf0e10cSrcweir     css::geometry::RealSize2D maMinimalSize;
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     void CreateControls (
205*cdf0e10cSrcweir         const ::rtl::OUString& rsConfigurationPath);
206*cdf0e10cSrcweir     void Layout (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
207*cdf0e10cSrcweir     css::geometry::RealSize2D CalculatePartSize (
208*cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
209*cdf0e10cSrcweir         const SharedElementContainerPart& rpPart,
210*cdf0e10cSrcweir         const bool bIsHorizontal);
211*cdf0e10cSrcweir     void LayoutPart (
212*cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
213*cdf0e10cSrcweir         const SharedElementContainerPart& rpPart,
214*cdf0e10cSrcweir         const css::geometry::RealRectangle2D& rBoundingBox,
215*cdf0e10cSrcweir         const css::geometry::RealSize2D& rPartSize,
216*cdf0e10cSrcweir         const bool bIsHorizontal);
217*cdf0e10cSrcweir     void Clear (
218*cdf0e10cSrcweir         const css::awt::Rectangle& rUpdateBox,
219*cdf0e10cSrcweir         const css::rendering::ViewState& rViewState);
220*cdf0e10cSrcweir     void Paint (
221*cdf0e10cSrcweir         const css::awt::Rectangle& rUpdateBox,
222*cdf0e10cSrcweir         const css::rendering::ViewState& rViewState);
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir     void UpdateSlideNumber (void);
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     void CheckMouseOver (
227*cdf0e10cSrcweir         const css::awt::MouseEvent& rEvent,
228*cdf0e10cSrcweir         const bool bOverWindow,
229*cdf0e10cSrcweir         const bool bMouseDown=false);
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir     void ProcessEntry (
232*cdf0e10cSrcweir         const ::css::uno::Reference<css::beans::XPropertySet>& rProperties,
233*cdf0e10cSrcweir         Context& rContext);
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     /** This method throws a DisposedException when the object has already been
236*cdf0e10cSrcweir         disposed.
237*cdf0e10cSrcweir     */
238*cdf0e10cSrcweir     void ThrowIfDisposed (void) const
239*cdf0e10cSrcweir         throw (css::lang::DisposedException);
240*cdf0e10cSrcweir };
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir /** View for the PresenterToolBar.
246*cdf0e10cSrcweir */
247*cdf0e10cSrcweir class PresenterToolBarView
248*cdf0e10cSrcweir     : private ::cppu::BaseMutex,
249*cdf0e10cSrcweir       private ::boost::noncopyable,
250*cdf0e10cSrcweir       public PresenterToolBarViewInterfaceBase
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir public:
253*cdf0e10cSrcweir     explicit PresenterToolBarView (
254*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
255*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
256*cdf0e10cSrcweir         const css::uno::Reference<css::frame::XController>& rxController,
257*cdf0e10cSrcweir         const ::rtl::Reference<PresenterController>& rpPresenterController);
258*cdf0e10cSrcweir     virtual ~PresenterToolBarView (void);
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir     ::rtl::Reference<PresenterToolBar> GetPresenterToolBar (void) const;
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir     // XPaintListener
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
268*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     // lang::XEventListener
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir     virtual void SAL_CALL
274*cdf0e10cSrcweir         disposing (const css::lang::EventObject& rEventObject)
275*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir     // XResourceId
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
281*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isAnchorOnly (void)
284*cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     // XDrawView
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir     virtual void SAL_CALL setCurrentPage (
290*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
291*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void)
294*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir private:
297*cdf0e10cSrcweir     //    css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
298*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XPane> mxPane;
299*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
300*cdf0e10cSrcweir     css::uno::Reference<css::awt::XWindow> mxWindow;
301*cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
302*cdf0e10cSrcweir     ::rtl::Reference<PresenterController> mpPresenterController;
303*cdf0e10cSrcweir     css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
304*cdf0e10cSrcweir     ::rtl::Reference<PresenterToolBar> mpToolBar;
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir     /** This method throws a DisposedException when the object has already been
307*cdf0e10cSrcweir         disposed.
308*cdf0e10cSrcweir     */
309*cdf0e10cSrcweir     void ThrowIfDisposed (void) const
310*cdf0e10cSrcweir         throw (css::lang::DisposedException);
311*cdf0e10cSrcweir };
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir #endif
316