bump product version to 5.0.4.1
[LibreOffice.git] / sdext / source / presenter / PresenterToolBar.hxx
blob42c225c076a9906d89e7e5f0fb759b8932c51038
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERTOOLBAR_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERTOOLBAR_HXX
23 #include "PresenterController.hxx"
24 #include "PresenterViewFactory.hxx"
26 #include <cppuhelper/basemutex.hxx>
27 #include <cppuhelper/compbase3.hxx>
28 #include <cppuhelper/compbase5.hxx>
29 #include <com/sun/star/awt/ActionEvent.hpp>
30 #include <com/sun/star/awt/XActionListener.hpp>
31 #include <com/sun/star/awt/XButton.hpp>
32 #include <com/sun/star/awt/XControl.hpp>
33 #include <com/sun/star/awt/XControlContainer.hpp>
34 #include <com/sun/star/awt/XFixedText.hpp>
35 #include <com/sun/star/awt/XMouseListener.hpp>
36 #include <com/sun/star/awt/XMouseMotionListener.hpp>
37 #include <com/sun/star/awt/XPaintListener.hpp>
38 #include <com/sun/star/awt/XWindowListener.hpp>
39 #include <com/sun/star/container/XNameAccess.hpp>
40 #include <com/sun/star/drawing/XDrawPage.hpp>
41 #include <com/sun/star/drawing/XDrawView.hpp>
42 #include <com/sun/star/drawing/XPresenterHelper.hpp>
43 #include <com/sun/star/drawing/framework/XView.hpp>
44 #include <com/sun/star/drawing/framework/XResourceId.hpp>
45 #include <com/sun/star/frame/XController.hpp>
46 #include <boost/function.hpp>
47 #include <boost/noncopyable.hpp>
49 namespace {
50 typedef cppu::WeakComponentImplHelper5<
51 css::awt::XWindowListener,
52 css::awt::XPaintListener,
53 css::awt::XMouseListener,
54 css::awt::XMouseMotionListener,
55 css::drawing::XDrawView
56 > PresenterToolBarInterfaceBase;
58 typedef cppu::WeakComponentImplHelper3<
59 css::awt::XPaintListener,
60 css::drawing::framework::XView,
61 css::drawing::XDrawView
62 > PresenterToolBarViewInterfaceBase;
65 namespace sdext { namespace presenter {
67 /** A simple tool bar that can display bitmapped buttons and labels. At the
68 moment there are buttons for moving to the next and previous slide and
69 to the next effect. A label displayes the index of the current slide
70 and the total number of slides.
72 class PresenterToolBar
73 : private ::cppu::BaseMutex,
74 private ::boost::noncopyable,
75 public PresenterToolBarInterfaceBase,
76 public CachablePresenterView
78 public:
79 typedef ::boost::function<void()> Action;
81 enum Anchor { Left, Center, Right };
83 PresenterToolBar (
84 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
85 const css::uno::Reference<css::awt::XWindow>& rxWindow,
86 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
87 const ::rtl::Reference<PresenterController>& rpPresenterController,
88 const Anchor eAnchor);
89 virtual ~PresenterToolBar();
91 void Initialize (
92 const OUString& rsConfigurationPath);
94 virtual void SAL_CALL disposing() SAL_OVERRIDE;
96 void InvalidateArea (
97 const css::awt::Rectangle& rRepaintBox,
98 const bool bSynchronous);
100 void RequestLayout();
101 css::geometry::RealSize2D GetMinimalSize();
102 ::rtl::Reference<PresenterController> GetPresenterController() const;
103 css::uno::Reference<css::uno::XComponentContext> GetComponentContext() const;
105 // lang::XEventListener
107 virtual void SAL_CALL
108 disposing (const css::lang::EventObject& rEventObject)
109 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 // XWindowListener
113 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
114 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
117 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
120 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
123 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
125 // XPaintListener
127 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
128 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
130 // XMouseListener
132 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
133 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
136 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
138 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
139 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
142 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 // XMouseMotionListener
146 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent)
147 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
149 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent)
150 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
152 // XDrawView
154 virtual void SAL_CALL setCurrentPage (
155 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
156 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
158 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage()
159 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
161 class Context;
163 private:
164 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
166 class ElementContainerPart;
167 typedef ::boost::shared_ptr<ElementContainerPart> SharedElementContainerPart;
168 typedef ::std::vector<SharedElementContainerPart> ElementContainer;
169 ElementContainer maElementContainer;
170 SharedElementContainerPart mpCurrentContainerPart;
171 css::uno::Reference<css::awt::XWindow> mxWindow;
172 css::uno::Reference<css::rendering::XCanvas> mxCanvas;
173 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
174 css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide;
175 ::rtl::Reference<PresenterController> mpPresenterController;
176 bool mbIsLayoutPending;
177 const Anchor meAnchor;
178 css::geometry::RealRectangle2D maBoundingBox;
179 /** The minimal size that is necessary to display all elements without
180 overlap and with minimal gaps between them.
182 css::geometry::RealSize2D maMinimalSize;
184 void CreateControls (
185 const OUString& rsConfigurationPath);
186 void Layout (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
187 css::geometry::RealSize2D CalculatePartSize (
188 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
189 const SharedElementContainerPart& rpPart,
190 const bool bIsHorizontal);
191 static void LayoutPart (
192 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
193 const SharedElementContainerPart& rpPart,
194 const css::geometry::RealRectangle2D& rBoundingBox,
195 const css::geometry::RealSize2D& rPartSize,
196 const bool bIsHorizontal);
197 void Clear (
198 const css::awt::Rectangle& rUpdateBox,
199 const css::rendering::ViewState& rViewState);
200 void Paint (
201 const css::awt::Rectangle& rUpdateBox,
202 const css::rendering::ViewState& rViewState);
204 void UpdateSlideNumber();
206 void CheckMouseOver (
207 const css::awt::MouseEvent& rEvent,
208 const bool bOverWindow,
209 const bool bMouseDown=false);
211 void ProcessEntry (
212 const css::uno::Reference<css::beans::XPropertySet>& rProperties,
213 Context& rContext);
215 /** This method throws a DisposedException when the object has already been
216 disposed.
218 void ThrowIfDisposed() const
219 throw (css::lang::DisposedException);
222 /** View for the PresenterToolBar.
224 class PresenterToolBarView
225 : private ::cppu::BaseMutex,
226 private ::boost::noncopyable,
227 public PresenterToolBarViewInterfaceBase
229 public:
230 explicit PresenterToolBarView (
231 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
232 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
233 const css::uno::Reference<css::frame::XController>& rxController,
234 const ::rtl::Reference<PresenterController>& rpPresenterController);
235 virtual ~PresenterToolBarView();
237 virtual void SAL_CALL disposing() SAL_OVERRIDE;
239 ::rtl::Reference<PresenterToolBar> GetPresenterToolBar() const;
241 // XPaintListener
243 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
244 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
246 // lang::XEventListener
248 virtual void SAL_CALL
249 disposing (const css::lang::EventObject& rEventObject)
250 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
252 // XResourceId
254 virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId()
255 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
257 virtual sal_Bool SAL_CALL isAnchorOnly()
258 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
260 // XDrawView
262 virtual void SAL_CALL setCurrentPage (
263 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
264 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
266 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage()
267 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
269 private:
270 // css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
271 css::uno::Reference<css::drawing::framework::XPane> mxPane;
272 css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
273 css::uno::Reference<css::awt::XWindow> mxWindow;
274 css::uno::Reference<css::rendering::XCanvas> mxCanvas;
275 ::rtl::Reference<PresenterController> mpPresenterController;
276 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
277 ::rtl::Reference<PresenterToolBar> mpToolBar;
281 } } // end of namespace ::sdext::presenter
283 #endif
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */