LibreOffice Module sdext (master)  1
PresenterToolBar.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERTOOLBAR_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERTOOLBAR_HXX
22 
23 #include "PresenterController.hxx"
24 #include "PresenterViewFactory.hxx"
25 
26 #include <cppuhelper/basemutex.hxx>
27 #include <cppuhelper/compbase.hxx>
28 #include <com/sun/star/awt/XMouseListener.hpp>
29 #include <com/sun/star/awt/XMouseMotionListener.hpp>
30 #include <com/sun/star/awt/XPaintListener.hpp>
31 #include <com/sun/star/awt/XWindowListener.hpp>
32 #include <com/sun/star/drawing/XDrawPage.hpp>
33 #include <com/sun/star/drawing/XDrawView.hpp>
34 #include <com/sun/star/drawing/framework/XView.hpp>
35 #include <com/sun/star/drawing/framework/XResourceId.hpp>
36 #include <com/sun/star/frame/XController.hpp>
37 
38 #include <functional>
39 
40 namespace sdext::presenter {
41 
42 typedef cppu::WeakComponentImplHelper<
43  css::awt::XWindowListener,
44  css::awt::XPaintListener,
45  css::awt::XMouseListener,
46  css::awt::XMouseMotionListener,
47  css::drawing::XDrawView
49 
50 typedef cppu::WeakComponentImplHelper<
51  css::awt::XPaintListener,
52  css::drawing::framework::XView,
53  css::drawing::XDrawView
55 
62  : private ::cppu::BaseMutex,
65 {
66 public:
67  typedef ::std::function<void ()> Action;
68 
69  enum Anchor { Left, Center };
70 
72  const css::uno::Reference<css::uno::XComponentContext>& rxContext,
73  const css::uno::Reference<css::awt::XWindow>& rxWindow,
74  const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
75  const ::rtl::Reference<PresenterController>& rpPresenterController,
76  const Anchor eAnchor);
77  virtual ~PresenterToolBar() override;
78  PresenterToolBar(const PresenterToolBar&) = delete;
80 
81  void Initialize (
82  const OUString& rsConfigurationPath);
83 
84  virtual void SAL_CALL disposing() override;
85 
86  void InvalidateArea (
87  const css::awt::Rectangle& rRepaintBox,
88  const bool bSynchronous);
89 
90  void RequestLayout();
91  css::geometry::RealSize2D const & GetMinimalSize();
92  const ::rtl::Reference<PresenterController>& GetPresenterController() const;
93  const css::uno::Reference<css::uno::XComponentContext>& GetComponentContext() const;
94 
95  // lang::XEventListener
96 
97  virtual void SAL_CALL
98  disposing (const css::lang::EventObject& rEventObject) override;
99 
100  // XWindowListener
101 
102  virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) override;
103 
104  virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) override;
105 
106  virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) override;
107 
108  virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) override;
109 
110  // XPaintListener
111 
112  virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) override;
113 
114  // XMouseListener
115 
116  virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) override;
117 
118  virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) override;
119 
120  virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) override;
121 
122  virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) override;
123 
124  // XMouseMotionListener
125 
126  virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent) override;
127 
128  virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent) override;
129 
130  // XDrawView
131 
132  virtual void SAL_CALL setCurrentPage (
133  const css::uno::Reference<css::drawing::XDrawPage>& rxSlide) override;
134 
135  virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage() override;
136 
137  class Context;
138 
139 private:
140  css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
141 
143  typedef std::shared_ptr<ElementContainerPart> SharedElementContainerPart;
144  typedef ::std::vector<SharedElementContainerPart> ElementContainer;
145  ElementContainer maElementContainer;
146  SharedElementContainerPart mpCurrentContainerPart;
147  css::uno::Reference<css::awt::XWindow> mxWindow;
148  css::uno::Reference<css::rendering::XCanvas> mxCanvas;
149  css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
150  css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide;
157  css::geometry::RealSize2D maMinimalSize;
158 
159  void CreateControls (
160  const OUString& rsConfigurationPath);
161  void Layout (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
162  css::geometry::RealSize2D CalculatePartSize (
163  const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
164  const SharedElementContainerPart& rpPart,
165  const bool bIsHorizontal);
166  static void LayoutPart (
167  const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
168  const SharedElementContainerPart& rpPart,
169  const css::geometry::RealRectangle2D& rBoundingBox,
170  const css::geometry::RealSize2D& rPartSize,
171  const bool bIsHorizontal);
172  void Paint (
173  const css::awt::Rectangle& rUpdateBox,
174  const css::rendering::ViewState& rViewState);
175 
176  void UpdateSlideNumber();
177 
178  void CheckMouseOver (
179  const css::awt::MouseEvent& rEvent,
180  const bool bOverWindow,
181  const bool bMouseDown=false);
182 
183  void ProcessEntry (
184  const css::uno::Reference<css::beans::XPropertySet>& rProperties,
185  Context const & rContext);
186 
190  void ThrowIfDisposed() const;
191 };
192 
196  : private ::cppu::BaseMutex,
198 {
199 public:
200  explicit PresenterToolBarView (
201  const css::uno::Reference<css::uno::XComponentContext>& rxContext,
202  const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
203  const css::uno::Reference<css::frame::XController>& rxController,
204  const ::rtl::Reference<PresenterController>& rpPresenterController);
205  virtual ~PresenterToolBarView() override;
208 
209  virtual void SAL_CALL disposing() override;
210 
211  const ::rtl::Reference<PresenterToolBar>& GetPresenterToolBar() const;
212 
213  // XPaintListener
214 
215  virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) override;
216 
217  // lang::XEventListener
218 
219  virtual void SAL_CALL
220  disposing (const css::lang::EventObject& rEventObject) override;
221 
222  // XResourceId
223 
224  virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId() override;
225 
226  virtual sal_Bool SAL_CALL isAnchorOnly() override;
227 
228  // XDrawView
229 
230  virtual void SAL_CALL setCurrentPage (
231  const css::uno::Reference<css::drawing::XDrawPage>& rxSlide) override;
232 
233  virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage() override;
234 
235 private:
236  // css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
237  css::uno::Reference<css::drawing::framework::XPane> mxPane;
238  css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
239  css::uno::Reference<css::awt::XWindow> mxWindow;
240  css::uno::Reference<css::rendering::XCanvas> mxCanvas;
243 
244 };
245 
246 } // end of namespace ::sdext::presenter
247 
248 #endif
249 
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
::rtl::Reference< PresenterController > mpPresenterController
css::geometry::RealSize2D maMinimalSize
The minimal size that is necessary to display all elements without overlap and with minimal gaps betw...
void CreateControls(const OUString &rsConfigurationPath)
css::geometry::RealSize2D const & GetMinimalSize()
virtual void SAL_CALL windowMoved(const css::awt::WindowEvent &rEvent) override
virtual void SAL_CALL windowShown(const css::lang::EventObject &rEvent) override
std::shared_ptr< ElementContainerPart > SharedElementContainerPart
virtual void SAL_CALL windowResized(const css::awt::WindowEvent &rEvent) override
::rtl::Reference< PresenterToolBar > mpToolBar
virtual void SAL_CALL mouseMoved(const css::awt::MouseEvent &rEvent) override
::std::vector< SharedElementContainerPart > ElementContainer
css::uno::Reference< css::drawing::XDrawPage > mxCurrentSlide
void ProcessEntry(const css::uno::Reference< css::beans::XPropertySet > &rProperties, Context const &rContext)
css::uno::Reference< css::awt::XWindow > mxWindow
css::uno::Reference< css::rendering::XCanvas > mxCanvas
void Initialize(const OUString &rsConfigurationPath)
SharedElementContainerPart mpCurrentContainerPart
void CheckMouseOver(const css::awt::MouseEvent &rEvent, const bool bOverWindow, const bool bMouseDown=false)
virtual void SAL_CALL mouseDragged(const css::awt::MouseEvent &rEvent) override
View for the PresenterToolBar.
css::geometry::RealSize2D CalculatePartSize(const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const SharedElementContainerPart &rpPart, const bool bIsHorizontal)
PresenterToolBar & operator=(const PresenterToolBar &)=delete
virtual void SAL_CALL windowHidden(const css::lang::EventObject &rEvent) override
virtual sal_Bool SAL_CALL isAnchorOnly() override
::rtl::Reference< PresenterController > mpPresenterController
const css::uno::Reference< css::uno::XComponentContext > & GetComponentContext() const
virtual void SAL_CALL mouseReleased(const css::awt::MouseEvent &rEvent) override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL setCurrentPage(const css::uno::Reference< css::drawing::XDrawPage > &rxSlide) override
const ::rtl::Reference< PresenterController > & GetPresenterController() const
unsigned char sal_Bool
css::uno::Reference< css::awt::XWindow > mxWindow
void InvalidateArea(const css::awt::Rectangle &rRepaintBox, const bool bSynchronous)
PresenterToolBarView & operator=(const PresenterToolBarView &)=delete
const ::rtl::Reference< PresenterToolBar > & GetPresenterToolBar() const
css::uno::Reference< css::drawing::framework::XResourceId > mxViewId
virtual void SAL_CALL windowPaint(const css::awt::PaintEvent &rEvent) override
PresenterToolBarView(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::drawing::framework::XResourceId > &rxViewId, const css::uno::Reference< css::frame::XController > &rxController, const ::rtl::Reference< PresenterController > &rpPresenterController)
virtual void SAL_CALL mouseExited(const css::awt::MouseEvent &rEvent) override
virtual void SAL_CALL disposing() override
A simple tool bar that can display bitmapped buttons and labels.
css::uno::Reference< css::rendering::XCanvas > mxCanvas
virtual void SAL_CALL mouseEntered(const css::awt::MouseEvent &rEvent) override
css::uno::Reference< css::drawing::framework::XPane > mxPane
cppu::WeakComponentImplHelper< css::awt::XWindowListener, css::awt::XPaintListener, css::awt::XMouseListener, css::awt::XMouseMotionListener, css::drawing::XDrawView > PresenterToolBarInterfaceBase
PresenterToolBar(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::awt::XWindow > &rxWindow, const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const ::rtl::Reference< PresenterController > &rpPresenterController, const Anchor eAnchor)
virtual void SAL_CALL setCurrentPage(const css::uno::Reference< css::drawing::XDrawPage > &rxSlide) override
virtual css::uno::Reference< css::drawing::framework::XResourceId > SAL_CALL getResourceId() override
static void LayoutPart(const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const SharedElementContainerPart &rpPart, const css::geometry::RealRectangle2D &rBoundingBox, const css::geometry::RealSize2D &rPartSize, const bool bIsHorizontal)
virtual void SAL_CALL windowPaint(const css::awt::PaintEvent &rEvent) override
cppu::WeakComponentImplHelper< css::awt::XPaintListener, css::drawing::framework::XView, css::drawing::XDrawView > PresenterToolBarViewInterfaceBase
virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getCurrentPage() override
void Paint(const css::awt::Rectangle &rUpdateBox, const css::rendering::ViewState &rViewState)
virtual void SAL_CALL mousePressed(const css::awt::MouseEvent &rEvent) override
virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getCurrentPage() override
void Layout(const css::uno::Reference< css::rendering::XCanvas > &rxCanvas)
css::uno::Reference< css::presentation::XSlideShowController > mxSlideShowController
Base class for presenter views that allows the view factory to store them in a cache and reuse deacti...