Update ooo320-m1
[ooovba.git] / sdext / source / presenter / PresenterToolBar.hxx
blob4e52d0f77f50126dbf0eeb47e0eccb5197ef7c7c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterToolBar.hxx,v $
11 * $Revision: 1.4 $
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 #ifndef SDEXT_PRESENTER_TOOL_BAR_HXX
33 #define SDEXT_PRESENTER_TOOL_BAR_HXX
35 #include "PresenterController.hxx"
36 #include "PresenterViewFactory.hxx"
38 #include <cppuhelper/basemutex.hxx>
39 #include <cppuhelper/compbase3.hxx>
40 #include <cppuhelper/compbase5.hxx>
41 #include <com/sun/star/awt/ActionEvent.hpp>
42 #include <com/sun/star/awt/XActionListener.hpp>
43 #include <com/sun/star/awt/XButton.hpp>
44 #include <com/sun/star/awt/XControl.hpp>
45 #include <com/sun/star/awt/XControlContainer.hpp>
46 #include <com/sun/star/awt/XFixedText.hpp>
47 #include <com/sun/star/awt/XMouseListener.hpp>
48 #include <com/sun/star/awt/XMouseMotionListener.hpp>
49 #include <com/sun/star/awt/XPaintListener.hpp>
50 #include <com/sun/star/awt/XWindowListener.hpp>
51 #include <com/sun/star/container/XNameAccess.hpp>
52 #include <com/sun/star/drawing/XDrawPage.hpp>
53 #include <com/sun/star/drawing/XDrawView.hpp>
54 #include <com/sun/star/drawing/XPresenterHelper.hpp>
55 #include <com/sun/star/drawing/framework/XView.hpp>
56 #include <com/sun/star/drawing/framework/XResourceId.hpp>
57 #include <com/sun/star/frame/XController.hpp>
58 #include <map>
59 #include <boost/scoped_ptr.hpp>
60 #include <boost/function.hpp>
61 #include <boost/noncopyable.hpp>
63 namespace css = ::com::sun::star;
65 namespace {
66 typedef cppu::WeakComponentImplHelper5<
67 css::awt::XWindowListener,
68 css::awt::XPaintListener,
69 css::awt::XMouseListener,
70 css::awt::XMouseMotionListener,
71 css::drawing::XDrawView
72 > PresenterToolBarInterfaceBase;
74 typedef cppu::WeakComponentImplHelper3<
75 css::awt::XPaintListener,
76 css::drawing::framework::XView,
77 css::drawing::XDrawView
78 > PresenterToolBarViewInterfaceBase;
81 namespace sdext { namespace presenter {
83 /** A simple tool bar that can display bitmapped buttons and labels. At the
84 moment there are buttons for moving to the next and previous slide and
85 to the next effect. A label displayes the index of the current slide
86 and the total number of slides.
88 class PresenterToolBar
89 : private ::cppu::BaseMutex,
90 private ::boost::noncopyable,
91 public PresenterToolBarInterfaceBase,
92 public CachablePresenterView
94 public:
95 typedef ::boost::function<void(void)> Action;
97 enum Anchor { Left, Center, Right };
99 PresenterToolBar (
100 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
101 const css::uno::Reference<css::awt::XWindow>& rxWindow,
102 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
103 const ::rtl::Reference<PresenterController>& rpPresenterController,
104 const Anchor eAnchor);
105 virtual ~PresenterToolBar (void);
107 void Initialize (
108 const ::rtl::OUString& rsConfigurationPath);
110 virtual void SAL_CALL disposing (void);
112 void InvalidateArea (
113 const css::awt::Rectangle& rRepaintBox,
114 const bool bSynchronous);
115 sal_Int32 GetSlideCount (void);
116 sal_Int32 GetCurrentSlideIndex (void);
117 void RequestLayout (void);
118 css::geometry::RealSize2D GetSize (void);
119 css::geometry::RealSize2D GetMinimalSize (void);
120 ::rtl::Reference<PresenterController> GetPresenterController (void) const;
121 css::uno::Reference<css::awt::XWindow> GetWindow (void) const;
122 css::uno::Reference<css::uno::XComponentContext> GetComponentContext (void) const;
124 // lang::XEventListener
126 virtual void SAL_CALL
127 disposing (const css::lang::EventObject& rEventObject)
128 throw (css::uno::RuntimeException);
131 // XWindowListener
133 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
134 throw (css::uno::RuntimeException);
136 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
137 throw (css::uno::RuntimeException);
139 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
140 throw (css::uno::RuntimeException);
142 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
143 throw (css::uno::RuntimeException);
146 // XPaintListener
148 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
149 throw (css::uno::RuntimeException);
152 // XMouseListener
154 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
155 throw (css::uno::RuntimeException);
157 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
158 throw (css::uno::RuntimeException);
160 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
161 throw (css::uno::RuntimeException);
163 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
164 throw (css::uno::RuntimeException);
167 // XMouseMotionListener
169 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent)
170 throw (css::uno::RuntimeException);
172 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent)
173 throw (css::uno::RuntimeException);
176 // XDrawView
178 virtual void SAL_CALL setCurrentPage (
179 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
180 throw (css::uno::RuntimeException);
182 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void)
183 throw (css::uno::RuntimeException);
185 class Context;
187 private:
188 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
190 class ElementContainerPart;
191 typedef ::boost::shared_ptr<ElementContainerPart> SharedElementContainerPart;
192 typedef ::std::vector<SharedElementContainerPart> ElementContainer;
193 ElementContainer maElementContainer;
194 SharedElementContainerPart mpCurrentContainerPart;
195 css::uno::Reference<css::awt::XWindow> mxWindow;
196 css::uno::Reference<css::rendering::XCanvas> mxCanvas;
197 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
198 css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide;
199 ::rtl::Reference<PresenterController> mpPresenterController;
200 bool mbIsLayoutPending;
201 const Anchor meAnchor;
202 css::geometry::RealRectangle2D maBoundingBox;
203 /** The minimal size that is necessary to display all elements without
204 overlap and with minimal gaps between them.
206 css::geometry::RealSize2D maMinimalSize;
208 void CreateControls (
209 const ::rtl::OUString& rsConfigurationPath);
210 void Layout (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
211 css::geometry::RealSize2D CalculatePartSize (
212 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
213 const SharedElementContainerPart& rpPart,
214 const bool bIsHorizontal);
215 void LayoutPart (
216 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
217 const SharedElementContainerPart& rpPart,
218 const css::geometry::RealRectangle2D& rBoundingBox,
219 const css::geometry::RealSize2D& rPartSize,
220 const bool bIsHorizontal);
221 void Clear (
222 const css::awt::Rectangle& rUpdateBox,
223 const css::rendering::ViewState& rViewState);
224 void Paint (
225 const css::awt::Rectangle& rUpdateBox,
226 const css::rendering::ViewState& rViewState);
228 void UpdateSlideNumber (void);
230 void CheckMouseOver (
231 const css::awt::MouseEvent& rEvent,
232 const bool bOverWindow,
233 const bool bMouseDown=false);
235 void ProcessEntry (
236 const ::css::uno::Reference<css::beans::XPropertySet>& rProperties,
237 Context& rContext);
239 /** This method throws a DisposedException when the object has already been
240 disposed.
242 void ThrowIfDisposed (void) const
243 throw (css::lang::DisposedException);
249 /** View for the PresenterToolBar.
251 class PresenterToolBarView
252 : private ::cppu::BaseMutex,
253 private ::boost::noncopyable,
254 public PresenterToolBarViewInterfaceBase
256 public:
257 explicit PresenterToolBarView (
258 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
259 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
260 const css::uno::Reference<css::frame::XController>& rxController,
261 const ::rtl::Reference<PresenterController>& rpPresenterController);
262 virtual ~PresenterToolBarView (void);
264 virtual void SAL_CALL disposing (void);
266 ::rtl::Reference<PresenterToolBar> GetPresenterToolBar (void) const;
269 // XPaintListener
271 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
272 throw (css::uno::RuntimeException);
275 // lang::XEventListener
277 virtual void SAL_CALL
278 disposing (const css::lang::EventObject& rEventObject)
279 throw (css::uno::RuntimeException);
282 // XResourceId
284 virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
285 throw (css::uno::RuntimeException);
287 virtual sal_Bool SAL_CALL isAnchorOnly (void)
288 throw (com::sun::star::uno::RuntimeException);
291 // XDrawView
293 virtual void SAL_CALL setCurrentPage (
294 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
295 throw (css::uno::RuntimeException);
297 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void)
298 throw (css::uno::RuntimeException);
300 private:
301 // css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
302 css::uno::Reference<css::drawing::framework::XPane> mxPane;
303 css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
304 css::uno::Reference<css::awt::XWindow> mxWindow;
305 css::uno::Reference<css::rendering::XCanvas> mxCanvas;
306 ::rtl::Reference<PresenterController> mpPresenterController;
307 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
308 ::rtl::Reference<PresenterToolBar> mpToolBar;
310 /** This method throws a DisposedException when the object has already been
311 disposed.
313 void ThrowIfDisposed (void) const
314 throw (css::lang::DisposedException);
317 } } // end of namespace ::sdext::presenter
319 #endif