1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/ActionEvent.hpp>
29 #include <com/sun/star/awt/XActionListener.hpp>
30 #include <com/sun/star/awt/XButton.hpp>
31 #include <com/sun/star/awt/XControl.hpp>
32 #include <com/sun/star/awt/XControlContainer.hpp>
33 #include <com/sun/star/awt/XFixedText.hpp>
34 #include <com/sun/star/awt/XMouseListener.hpp>
35 #include <com/sun/star/awt/XMouseMotionListener.hpp>
36 #include <com/sun/star/awt/XPaintListener.hpp>
37 #include <com/sun/star/awt/XWindowListener.hpp>
38 #include <com/sun/star/container/XNameAccess.hpp>
39 #include <com/sun/star/drawing/XDrawPage.hpp>
40 #include <com/sun/star/drawing/XDrawView.hpp>
41 #include <com/sun/star/drawing/XPresenterHelper.hpp>
42 #include <com/sun/star/drawing/framework/XView.hpp>
43 #include <com/sun/star/drawing/framework/XResourceId.hpp>
44 #include <com/sun/star/frame/XController.hpp>
48 namespace sdext
{ namespace presenter
{
50 typedef cppu::WeakComponentImplHelper
<
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::WeakComponentImplHelper
<
59 css::awt::XPaintListener
,
60 css::drawing::framework::XView
,
61 css::drawing::XDrawView
62 > PresenterToolBarViewInterfaceBase
;
64 /** A simple tool bar that can display bitmapped buttons and labels. At the
65 moment there are buttons for moving to the next and previous slide and
66 to the next effect. A label displays the index of the current slide
67 and the total number of slides.
69 class PresenterToolBar
70 : private ::cppu::BaseMutex
,
71 public PresenterToolBarInterfaceBase
,
72 public CachablePresenterView
75 typedef ::std::function
<void ()> Action
;
77 enum Anchor
{ Left
, Center
};
80 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
81 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
82 const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
,
83 const ::rtl::Reference
<PresenterController
>& rpPresenterController
,
84 const Anchor eAnchor
);
85 virtual ~PresenterToolBar() override
;
86 PresenterToolBar(const PresenterToolBar
&) = delete;
87 PresenterToolBar
& operator=(const PresenterToolBar
&) = delete;
90 const OUString
& rsConfigurationPath
);
92 virtual void SAL_CALL
disposing() override
;
95 const css::awt::Rectangle
& rRepaintBox
,
96 const bool bSynchronous
);
99 css::geometry::RealSize2D
const & GetMinimalSize();
100 const ::rtl::Reference
<PresenterController
>& GetPresenterController() const;
101 const css::uno::Reference
<css::uno::XComponentContext
>& GetComponentContext() const;
103 // lang::XEventListener
105 virtual void SAL_CALL
106 disposing (const css::lang::EventObject
& rEventObject
) override
;
110 virtual void SAL_CALL
windowResized (const css::awt::WindowEvent
& rEvent
) override
;
112 virtual void SAL_CALL
windowMoved (const css::awt::WindowEvent
& rEvent
) override
;
114 virtual void SAL_CALL
windowShown (const css::lang::EventObject
& rEvent
) override
;
116 virtual void SAL_CALL
windowHidden (const css::lang::EventObject
& rEvent
) override
;
120 virtual void SAL_CALL
windowPaint (const css::awt::PaintEvent
& rEvent
) override
;
124 virtual void SAL_CALL
mousePressed (const css::awt::MouseEvent
& rEvent
) override
;
126 virtual void SAL_CALL
mouseReleased (const css::awt::MouseEvent
& rEvent
) override
;
128 virtual void SAL_CALL
mouseEntered (const css::awt::MouseEvent
& rEvent
) override
;
130 virtual void SAL_CALL
mouseExited (const css::awt::MouseEvent
& rEvent
) override
;
132 // XMouseMotionListener
134 virtual void SAL_CALL
mouseMoved (const css::awt::MouseEvent
& rEvent
) override
;
136 virtual void SAL_CALL
mouseDragged (const css::awt::MouseEvent
& rEvent
) override
;
140 virtual void SAL_CALL
setCurrentPage (
141 const css::uno::Reference
<css::drawing::XDrawPage
>& rxSlide
) override
;
143 virtual css::uno::Reference
<css::drawing::XDrawPage
> SAL_CALL
getCurrentPage() override
;
148 css::uno::Reference
<css::uno::XComponentContext
> mxComponentContext
;
150 class ElementContainerPart
;
151 typedef std::shared_ptr
<ElementContainerPart
> SharedElementContainerPart
;
152 typedef ::std::vector
<SharedElementContainerPart
> ElementContainer
;
153 ElementContainer maElementContainer
;
154 SharedElementContainerPart mpCurrentContainerPart
;
155 css::uno::Reference
<css::awt::XWindow
> mxWindow
;
156 css::uno::Reference
<css::rendering::XCanvas
> mxCanvas
;
157 css::uno::Reference
<css::presentation::XSlideShowController
> mxSlideShowController
;
158 css::uno::Reference
<css::drawing::XDrawPage
> mxCurrentSlide
;
159 ::rtl::Reference
<PresenterController
> mpPresenterController
;
160 bool mbIsLayoutPending
;
161 const Anchor meAnchor
;
162 /** The minimal size that is necessary to display all elements without
163 overlap and with minimal gaps between them.
165 css::geometry::RealSize2D maMinimalSize
;
167 void CreateControls (
168 const OUString
& rsConfigurationPath
);
169 void Layout (const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
);
170 css::geometry::RealSize2D
CalculatePartSize (
171 const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
,
172 const SharedElementContainerPart
& rpPart
,
173 const bool bIsHorizontal
);
174 static void LayoutPart (
175 const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
,
176 const SharedElementContainerPart
& rpPart
,
177 const css::geometry::RealRectangle2D
& rBoundingBox
,
178 const css::geometry::RealSize2D
& rPartSize
,
179 const bool bIsHorizontal
);
181 const css::awt::Rectangle
& rUpdateBox
,
182 const css::rendering::ViewState
& rViewState
);
184 void UpdateSlideNumber();
186 void CheckMouseOver (
187 const css::awt::MouseEvent
& rEvent
,
188 const bool bOverWindow
,
189 const bool bMouseDown
=false);
192 const css::uno::Reference
<css::beans::XPropertySet
>& rProperties
,
193 Context
const & rContext
);
195 /** @throws css::lang::DisposedException when the object has already been
198 void ThrowIfDisposed() const;
201 /** View for the PresenterToolBar.
203 class PresenterToolBarView
204 : private ::cppu::BaseMutex
,
205 public PresenterToolBarViewInterfaceBase
208 explicit PresenterToolBarView (
209 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
210 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxViewId
,
211 const css::uno::Reference
<css::frame::XController
>& rxController
,
212 const ::rtl::Reference
<PresenterController
>& rpPresenterController
);
213 virtual ~PresenterToolBarView() override
;
214 PresenterToolBarView(const PresenterToolBarView
&) = delete;
215 PresenterToolBarView
& operator=(const PresenterToolBarView
&) = delete;
217 virtual void SAL_CALL
disposing() override
;
219 const ::rtl::Reference
<PresenterToolBar
>& GetPresenterToolBar() const;
223 virtual void SAL_CALL
windowPaint (const css::awt::PaintEvent
& rEvent
) override
;
225 // lang::XEventListener
227 virtual void SAL_CALL
228 disposing (const css::lang::EventObject
& rEventObject
) override
;
232 virtual css::uno::Reference
<css::drawing::framework::XResourceId
> SAL_CALL
getResourceId() override
;
234 virtual sal_Bool SAL_CALL
isAnchorOnly() override
;
238 virtual void SAL_CALL
setCurrentPage (
239 const css::uno::Reference
<css::drawing::XDrawPage
>& rxSlide
) override
;
241 virtual css::uno::Reference
<css::drawing::XDrawPage
> SAL_CALL
getCurrentPage() override
;
244 // css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
245 css::uno::Reference
<css::drawing::framework::XPane
> mxPane
;
246 css::uno::Reference
<css::drawing::framework::XResourceId
> mxViewId
;
247 css::uno::Reference
<css::awt::XWindow
> mxWindow
;
248 css::uno::Reference
<css::rendering::XCanvas
> mxCanvas
;
249 ::rtl::Reference
<PresenterController
> mpPresenterController
;
250 css::uno::Reference
<css::presentation::XSlideShowController
> mxSlideShowController
;
251 ::rtl::Reference
<PresenterToolBar
> mpToolBar
;
255 } } // end of namespace ::sdext::presenter
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */