Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / console / PresenterToolBar.hxx
blobf95884ee9adc0cc10bdfea29bebcbfed5af37571
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/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>
38 #include <functional>
40 namespace sdext::presenter {
42 typedef cppu::WeakComponentImplHelper<
43 css::awt::XWindowListener,
44 css::awt::XPaintListener,
45 css::awt::XMouseListener,
46 css::awt::XMouseMotionListener,
47 css::drawing::XDrawView
48 > PresenterToolBarInterfaceBase;
50 typedef cppu::WeakComponentImplHelper<
51 css::awt::XPaintListener,
52 css::drawing::framework::XView,
53 css::drawing::XDrawView
54 > PresenterToolBarViewInterfaceBase;
56 /** A simple tool bar that can display bitmapped buttons and labels. At the
57 moment there are buttons for moving to the next and previous slide and
58 to the next effect. A label displays the index of the current slide
59 and the total number of slides.
61 class PresenterToolBar
62 : private ::cppu::BaseMutex,
63 public PresenterToolBarInterfaceBase,
64 public CachablePresenterView
66 public:
67 typedef ::std::function<void ()> Action;
69 enum Anchor { Left, Center };
71 PresenterToolBar (
72 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
73 css::uno::Reference<css::awt::XWindow> xWindow,
74 css::uno::Reference<css::rendering::XCanvas> xCanvas,
75 ::rtl::Reference<PresenterController> pPresenterController,
76 const Anchor eAnchor);
77 virtual ~PresenterToolBar() override;
78 PresenterToolBar(const PresenterToolBar&) = delete;
79 PresenterToolBar& operator=(const PresenterToolBar&) = delete;
81 void Initialize (
82 const OUString& rsConfigurationPath);
84 virtual void SAL_CALL disposing() override;
86 void InvalidateArea (
87 const css::awt::Rectangle& rRepaintBox,
88 const bool bSynchronous);
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;
95 // lang::XEventListener
97 virtual void SAL_CALL
98 disposing (const css::lang::EventObject& rEventObject) override;
100 // XWindowListener
102 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) override;
104 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) override;
106 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) override;
108 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) override;
110 // XPaintListener
112 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) override;
114 // XMouseListener
116 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) override;
118 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) override;
120 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) override;
122 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) override;
124 // XMouseMotionListener
126 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent) override;
128 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent) override;
130 // XDrawView
132 virtual void SAL_CALL setCurrentPage (
133 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide) override;
135 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage() override;
137 class Context;
139 private:
140 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
142 class ElementContainerPart;
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;
151 ::rtl::Reference<PresenterController> mpPresenterController;
152 bool mbIsLayoutPending;
153 const Anchor meAnchor;
154 /** The minimal size that is necessary to display all elements without
155 overlap and with minimal gaps between them.
157 css::geometry::RealSize2D maMinimalSize;
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);
176 void UpdateSlideNumber();
178 void CheckMouseOver (
179 const css::awt::MouseEvent& rEvent,
180 const bool bOverWindow,
181 const bool bMouseDown=false);
183 void ProcessEntry (
184 const css::uno::Reference<css::beans::XPropertySet>& rProperties,
185 Context const & rContext);
187 /** @throws css::lang::DisposedException when the object has already been
188 disposed.
190 void ThrowIfDisposed() const;
193 /** View for the PresenterToolBar.
195 class PresenterToolBarView
196 : private ::cppu::BaseMutex,
197 public PresenterToolBarViewInterfaceBase
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 ::rtl::Reference<::sd::DrawController>& rxController,
204 const ::rtl::Reference<PresenterController>& rpPresenterController);
205 virtual ~PresenterToolBarView() override;
206 PresenterToolBarView(const PresenterToolBarView&) = delete;
207 PresenterToolBarView& operator=(const PresenterToolBarView&) = delete;
209 virtual void SAL_CALL disposing() override;
211 const ::rtl::Reference<PresenterToolBar>& GetPresenterToolBar() const;
213 // XPaintListener
215 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) override;
217 // lang::XEventListener
219 virtual void SAL_CALL
220 disposing (const css::lang::EventObject& rEventObject) override;
222 // XResourceId
224 virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId() override;
226 virtual sal_Bool SAL_CALL isAnchorOnly() override;
228 // XDrawView
230 virtual void SAL_CALL setCurrentPage (
231 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide) override;
233 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage() override;
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;
241 ::rtl::Reference<PresenterController> mpPresenterController;
242 ::rtl::Reference<PresenterToolBar> mpToolBar;
246 } // end of namespace ::sdext::presenter
248 #endif
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */