xref: /AOO41X/main/sdext/source/presenter/PresenterToolBar.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sdext.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "PresenterToolBar.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "PresenterBitmapContainer.hxx"
34*cdf0e10cSrcweir #include "PresenterCanvasHelper.hxx"
35*cdf0e10cSrcweir #include "PresenterComponent.hxx"
36*cdf0e10cSrcweir #include "PresenterGeometryHelper.hxx"
37*cdf0e10cSrcweir #include "PresenterPaintManager.hxx"
38*cdf0e10cSrcweir #include "PresenterPaneBase.hxx"
39*cdf0e10cSrcweir #include "PresenterPaneFactory.hxx"
40*cdf0e10cSrcweir #include "PresenterTimer.hxx"
41*cdf0e10cSrcweir #include "PresenterWindowManager.hxx"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
44*cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/deployment/XPackageInformationProvider.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XPane.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/geometry/AffineMatrix2D.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/rendering/RenderState.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/rendering/TextDirection.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/rendering/ViewState.hpp>
57*cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp>
58*cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp>
59*cdf0e10cSrcweir #include <com/sun/star/util/Color.hpp>
60*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
61*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
62*cdf0e10cSrcweir #include <boost/bind.hpp>
63*cdf0e10cSrcweir #include <boost/function.hpp>
64*cdf0e10cSrcweir #include <boost/enable_shared_from_this.hpp>
65*cdf0e10cSrcweir #include <map>
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir using namespace ::com::sun::star;
68*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
69*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
70*cdf0e10cSrcweir using ::rtl::OUString;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir namespace sdext { namespace presenter {
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir static const sal_Int32 gnGapSize (20);
77*cdf0e10cSrcweir static const sal_Int32 gnMinimalSeparatorSize (20);
78*cdf0e10cSrcweir static const sal_Int32 gnSeparatorInset (0);
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir namespace {
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     class Text
83*cdf0e10cSrcweir     {
84*cdf0e10cSrcweir     public:
85*cdf0e10cSrcweir         Text (void);
86*cdf0e10cSrcweir         Text (const Text& rText);
87*cdf0e10cSrcweir         Text (
88*cdf0e10cSrcweir             const OUString& rsText,
89*cdf0e10cSrcweir             const PresenterTheme::SharedFontDescriptor& rpFont);
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir         void SetText (const OUString& rsText);
92*cdf0e10cSrcweir         OUString GetText (void) const;
93*cdf0e10cSrcweir         PresenterTheme::SharedFontDescriptor GetFont (void) const;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir         void Paint (
96*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas,
97*cdf0e10cSrcweir             const rendering::ViewState& rViewState,
98*cdf0e10cSrcweir             const awt::Rectangle& rBoundingBox,
99*cdf0e10cSrcweir             const awt::Point& rOffset);
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir         geometry::RealRectangle2D GetBoundingBox (
102*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas);
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     private:
105*cdf0e10cSrcweir         OUString msText;
106*cdf0e10cSrcweir         PresenterTheme::SharedFontDescriptor mpFont;
107*cdf0e10cSrcweir     };
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     class ElementMode
110*cdf0e10cSrcweir         : private ::boost::noncopyable
111*cdf0e10cSrcweir     {
112*cdf0e10cSrcweir     public:
113*cdf0e10cSrcweir         ElementMode (void);
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir         SharedBitmapDescriptor mpIcon;
116*cdf0e10cSrcweir         OUString msAction;
117*cdf0e10cSrcweir         Text maText;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir         void ReadElementMode (
120*cdf0e10cSrcweir             const Reference<beans::XPropertySet>& rxProperties,
121*cdf0e10cSrcweir             const ::rtl::OUString& rsModeName,
122*cdf0e10cSrcweir             ::boost::shared_ptr<ElementMode>& rpDefaultMode,
123*cdf0e10cSrcweir             ::sdext::presenter::PresenterToolBar::Context& rContext);
124*cdf0e10cSrcweir     };
125*cdf0e10cSrcweir     typedef ::boost::shared_ptr<ElementMode> SharedElementMode;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir }  // end of anonymous namespace
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir class PresenterToolBar::Context
131*cdf0e10cSrcweir     : private ::boost::noncopyable
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir public:
134*cdf0e10cSrcweir     ::rtl::OUString msBasePath;
135*cdf0e10cSrcweir     Reference<drawing::XPresenterHelper> mxPresenterHelper;
136*cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
137*cdf0e10cSrcweir };
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir //===== PresenterToolBar::Element =============================================
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir namespace {
145*cdf0e10cSrcweir     typedef cppu::WeakComponentImplHelper2<
146*cdf0e10cSrcweir         css::document::XEventListener,
147*cdf0e10cSrcweir         css::frame::XStatusListener
148*cdf0e10cSrcweir         > ElementInterfaceBase;
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     class Element
151*cdf0e10cSrcweir         : private ::cppu::BaseMutex,
152*cdf0e10cSrcweir           private ::boost::noncopyable,
153*cdf0e10cSrcweir           public ElementInterfaceBase
154*cdf0e10cSrcweir     {
155*cdf0e10cSrcweir     public:
156*cdf0e10cSrcweir         Element (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
157*cdf0e10cSrcweir         virtual ~Element (void);
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir         virtual void SAL_CALL disposing (void);
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir         virtual void SetModes (
162*cdf0e10cSrcweir             const SharedElementMode& rpNormalMode,
163*cdf0e10cSrcweir             const SharedElementMode& rpMouseOverMode,
164*cdf0e10cSrcweir             const SharedElementMode& rpSelectedMode,
165*cdf0e10cSrcweir             const SharedElementMode& rpDisabledMode);
166*cdf0e10cSrcweir         virtual void CurrentSlideHasChanged (void);
167*cdf0e10cSrcweir         virtual void SetLocation (const awt::Point& rLocation);
168*cdf0e10cSrcweir         virtual void SetSize (const geometry::RealSize2D& rSize);
169*cdf0e10cSrcweir         virtual void Paint (
170*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas,
171*cdf0e10cSrcweir             const rendering::ViewState& rViewState) = 0;
172*cdf0e10cSrcweir         awt::Size GetBoundingSize (
173*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas);
174*cdf0e10cSrcweir         awt::Rectangle GetBoundingBox (void) const;
175*cdf0e10cSrcweir         virtual bool SetState (const bool bIsOver, const bool bIsPressed);
176*cdf0e10cSrcweir         virtual void Invalidate (const bool bSynchronous = true);
177*cdf0e10cSrcweir         virtual bool IsOutside (const awt::Rectangle& rBox);
178*cdf0e10cSrcweir         virtual bool IsFilling (void) const;
179*cdf0e10cSrcweir         void UpdateState (void);
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir         OUString GetAction (void) const;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir         // lang::XEventListener
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir         virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
186*cdf0e10cSrcweir             throw(css::uno::RuntimeException);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir         // document::XEventListener
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir         virtual void SAL_CALL notifyEvent (const css::document::EventObject& rEvent)
191*cdf0e10cSrcweir             throw(css::uno::RuntimeException);
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir         // frame::XStatusListener
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir         virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent)
196*cdf0e10cSrcweir             throw(css::uno::RuntimeException);
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     protected:
199*cdf0e10cSrcweir         ::rtl::Reference<PresenterToolBar> mpToolBar;
200*cdf0e10cSrcweir         awt::Point maLocation;
201*cdf0e10cSrcweir         awt::Size maSize;
202*cdf0e10cSrcweir         SharedElementMode mpNormal;
203*cdf0e10cSrcweir         SharedElementMode mpMouseOver;
204*cdf0e10cSrcweir         SharedElementMode mpSelected;
205*cdf0e10cSrcweir         SharedElementMode mpDisabled;
206*cdf0e10cSrcweir         SharedElementMode mpMode;
207*cdf0e10cSrcweir         bool mbIsOver;
208*cdf0e10cSrcweir         bool mbIsPressed;
209*cdf0e10cSrcweir         bool mbIsSelected;
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir         virtual awt::Size CreateBoundingSize (
212*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas) = 0;
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir         bool IsEnabled (void) const;
215*cdf0e10cSrcweir         void SetEnabledState (const bool bIsEnabled);
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     private:
218*cdf0e10cSrcweir         bool mbIsEnabled;
219*cdf0e10cSrcweir     };
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir } // end of anonymous namespace
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir class PresenterToolBar::ElementContainerPart
225*cdf0e10cSrcweir     : public ::std::vector<rtl::Reference<Element> >
226*cdf0e10cSrcweir {
227*cdf0e10cSrcweir };
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir //===== Button ================================================================
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir namespace {
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir     class Button : public Element
237*cdf0e10cSrcweir     {
238*cdf0e10cSrcweir     public:
239*cdf0e10cSrcweir         static ::rtl::Reference<Element> Create (
240*cdf0e10cSrcweir             const ::rtl::Reference<PresenterToolBar>& rpToolBar);
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir         virtual ~Button (void);
243*cdf0e10cSrcweir         virtual void SAL_CALL disposing (void);
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir         virtual void Paint (
246*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas,
247*cdf0e10cSrcweir             const rendering::ViewState& rViewState);
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir         // lang::XEventListener
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir         virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
252*cdf0e10cSrcweir             throw(css::uno::RuntimeException);
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir     protected:
255*cdf0e10cSrcweir         virtual awt::Size CreateBoundingSize (
256*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas);
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir     private:
259*cdf0e10cSrcweir         bool mbIsListenerRegistered;
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir         Button (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
262*cdf0e10cSrcweir         void Initialize (void);
263*cdf0e10cSrcweir         void PaintIcon (
264*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas,
265*cdf0e10cSrcweir             const sal_Int32 nTextHeight,
266*cdf0e10cSrcweir             const rendering::ViewState& rViewState);
267*cdf0e10cSrcweir         PresenterBitmapDescriptor::Mode GetMode (void) const;
268*cdf0e10cSrcweir     };
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir //===== Label =================================================================
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir     class Label : public Element
276*cdf0e10cSrcweir     {
277*cdf0e10cSrcweir     public:
278*cdf0e10cSrcweir         Label (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir         void SetText (const OUString& rsText);
281*cdf0e10cSrcweir         virtual void Paint (
282*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas,
283*cdf0e10cSrcweir             const rendering::ViewState& rViewState);
284*cdf0e10cSrcweir         virtual bool SetState (const bool bIsOver, const bool bIsPressed);
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir     protected:
287*cdf0e10cSrcweir         virtual awt::Size CreateBoundingSize (
288*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas);
289*cdf0e10cSrcweir     };
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir // Some specialized controls.
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir     class ProgressLabel : public Label
296*cdf0e10cSrcweir     {
297*cdf0e10cSrcweir     public:
298*cdf0e10cSrcweir         ProgressLabel (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
299*cdf0e10cSrcweir         virtual void CurrentSlideHasChanged (void);
300*cdf0e10cSrcweir     };
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     class TimeFormatter
303*cdf0e10cSrcweir     {
304*cdf0e10cSrcweir     public:
305*cdf0e10cSrcweir         TimeFormatter (void);
306*cdf0e10cSrcweir         OUString FormatTime (const oslDateTime& rTime);
307*cdf0e10cSrcweir     private:
308*cdf0e10cSrcweir         bool mbIs24HourFormat;
309*cdf0e10cSrcweir         bool mbIsAmPmFormat;
310*cdf0e10cSrcweir         bool mbIsShowSeconds;
311*cdf0e10cSrcweir     };
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir     class TimeLabel : public Label
314*cdf0e10cSrcweir     {
315*cdf0e10cSrcweir     public:
316*cdf0e10cSrcweir         void ConnectToTimer (void);
317*cdf0e10cSrcweir         virtual void TimeHasChanged (const oslDateTime& rCurrentTime) = 0;
318*cdf0e10cSrcweir     protected:
319*cdf0e10cSrcweir         TimeLabel(const ::rtl::Reference<PresenterToolBar>& rpToolBar);
320*cdf0e10cSrcweir         using Element::disposing;
321*cdf0e10cSrcweir         virtual void SAL_CALL disposing (void);
322*cdf0e10cSrcweir     private:
323*cdf0e10cSrcweir         class Listener : public PresenterClockTimer::Listener
324*cdf0e10cSrcweir         {
325*cdf0e10cSrcweir         public:
326*cdf0e10cSrcweir             Listener (const ::rtl::Reference<TimeLabel>& rxLabel)
327*cdf0e10cSrcweir                 : mxLabel(rxLabel) {}
328*cdf0e10cSrcweir             virtual ~Listener (void) {}
329*cdf0e10cSrcweir             virtual void TimeHasChanged (const oslDateTime& rCurrentTime)
330*cdf0e10cSrcweir             { if (mxLabel.is()) mxLabel->TimeHasChanged(rCurrentTime); }
331*cdf0e10cSrcweir         private:
332*cdf0e10cSrcweir             ::rtl::Reference<TimeLabel> mxLabel;
333*cdf0e10cSrcweir         };
334*cdf0e10cSrcweir         ::boost::shared_ptr<PresenterClockTimer::Listener> mpListener;
335*cdf0e10cSrcweir     };
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir     class CurrentTimeLabel : public TimeLabel
338*cdf0e10cSrcweir     {
339*cdf0e10cSrcweir     public:
340*cdf0e10cSrcweir         static ::rtl::Reference<Element> Create (
341*cdf0e10cSrcweir             const ::rtl::Reference<PresenterToolBar>& rpToolBar);
342*cdf0e10cSrcweir         virtual void SetModes (
343*cdf0e10cSrcweir             const SharedElementMode& rpNormalMode,
344*cdf0e10cSrcweir             const SharedElementMode& rpMouseOverMode,
345*cdf0e10cSrcweir             const SharedElementMode& rpSelectedMode,
346*cdf0e10cSrcweir             const SharedElementMode& rpDisabledMode);
347*cdf0e10cSrcweir     private:
348*cdf0e10cSrcweir         TimeFormatter maTimeFormatter;
349*cdf0e10cSrcweir         CurrentTimeLabel (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
350*cdf0e10cSrcweir         virtual ~CurrentTimeLabel (void);
351*cdf0e10cSrcweir         virtual void TimeHasChanged (const oslDateTime& rCurrentTime);
352*cdf0e10cSrcweir     };
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir     class PresentationTimeLabel : public TimeLabel
355*cdf0e10cSrcweir     {
356*cdf0e10cSrcweir     public:
357*cdf0e10cSrcweir         static ::rtl::Reference<Element> Create (
358*cdf0e10cSrcweir             const ::rtl::Reference<PresenterToolBar>& rpToolBar);
359*cdf0e10cSrcweir         virtual void SetModes (
360*cdf0e10cSrcweir             const SharedElementMode& rpNormalMode,
361*cdf0e10cSrcweir             const SharedElementMode& rpMouseOverMode,
362*cdf0e10cSrcweir             const SharedElementMode& rpSelectedMode,
363*cdf0e10cSrcweir             const SharedElementMode& rpDisabledMode);
364*cdf0e10cSrcweir     private:
365*cdf0e10cSrcweir         TimeFormatter maTimeFormatter;
366*cdf0e10cSrcweir         TimeValue maStartTimeValue;
367*cdf0e10cSrcweir         PresentationTimeLabel (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
368*cdf0e10cSrcweir         virtual ~PresentationTimeLabel (void);
369*cdf0e10cSrcweir         virtual void TimeHasChanged (const oslDateTime& rCurrentTime);
370*cdf0e10cSrcweir     };
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir     class VerticalSeparator : public Element
373*cdf0e10cSrcweir     {
374*cdf0e10cSrcweir     public:
375*cdf0e10cSrcweir         explicit VerticalSeparator (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
376*cdf0e10cSrcweir         virtual void Paint (
377*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas,
378*cdf0e10cSrcweir             const rendering::ViewState& rViewState);
379*cdf0e10cSrcweir         virtual bool IsFilling (void) const;
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir     protected:
382*cdf0e10cSrcweir         virtual awt::Size CreateBoundingSize (
383*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas);
384*cdf0e10cSrcweir     };
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir     class HorizontalSeparator : public Element
387*cdf0e10cSrcweir     {
388*cdf0e10cSrcweir     public:
389*cdf0e10cSrcweir         explicit HorizontalSeparator (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
390*cdf0e10cSrcweir         virtual void Paint (
391*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas,
392*cdf0e10cSrcweir             const rendering::ViewState& rViewState);
393*cdf0e10cSrcweir         virtual bool IsFilling (void) const;
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir     protected:
396*cdf0e10cSrcweir         virtual awt::Size CreateBoundingSize (
397*cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas);
398*cdf0e10cSrcweir     };
399*cdf0e10cSrcweir } // end of anonymous namespace
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir //===== PresenterToolBar ======================================================
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir PresenterToolBar::PresenterToolBar (
406*cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
407*cdf0e10cSrcweir     const css::uno::Reference<css::awt::XWindow>& rxWindow,
408*cdf0e10cSrcweir     const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
409*cdf0e10cSrcweir     const ::rtl::Reference<PresenterController>& rpPresenterController,
410*cdf0e10cSrcweir     const Anchor eAnchor)
411*cdf0e10cSrcweir     : PresenterToolBarInterfaceBase(m_aMutex),
412*cdf0e10cSrcweir       mxComponentContext(rxContext),
413*cdf0e10cSrcweir       maElementContainer(),
414*cdf0e10cSrcweir       mpCurrentContainerPart(),
415*cdf0e10cSrcweir       mxWindow(rxWindow),
416*cdf0e10cSrcweir       mxCanvas(rxCanvas),
417*cdf0e10cSrcweir       mxSlideShowController(),
418*cdf0e10cSrcweir       mxCurrentSlide(),
419*cdf0e10cSrcweir       mpPresenterController(rpPresenterController),
420*cdf0e10cSrcweir       mbIsLayoutPending(false),
421*cdf0e10cSrcweir       meAnchor(eAnchor),
422*cdf0e10cSrcweir       maBoundingBox(),
423*cdf0e10cSrcweir       maMinimalSize()
424*cdf0e10cSrcweir {
425*cdf0e10cSrcweir }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir void PresenterToolBar::Initialize (
431*cdf0e10cSrcweir     const ::rtl::OUString& rsConfigurationPath)
432*cdf0e10cSrcweir {
433*cdf0e10cSrcweir     try
434*cdf0e10cSrcweir     {
435*cdf0e10cSrcweir         CreateControls(rsConfigurationPath);
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir         if (mxWindow.is())
438*cdf0e10cSrcweir         {
439*cdf0e10cSrcweir             mxWindow->addWindowListener(this);
440*cdf0e10cSrcweir             mxWindow->addPaintListener(this);
441*cdf0e10cSrcweir             mxWindow->addMouseListener(this);
442*cdf0e10cSrcweir             mxWindow->addMouseMotionListener(this);
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir             Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY);
445*cdf0e10cSrcweir             if (xPeer.is())
446*cdf0e10cSrcweir                 xPeer->setBackground(util::Color(0xff000000));
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir             mxWindow->setVisible(sal_True);
449*cdf0e10cSrcweir         }
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir         mxSlideShowController = mpPresenterController->GetSlideShowController();
452*cdf0e10cSrcweir         UpdateSlideNumber();
453*cdf0e10cSrcweir         mbIsLayoutPending = true;
454*cdf0e10cSrcweir     }
455*cdf0e10cSrcweir     catch (RuntimeException&)
456*cdf0e10cSrcweir     {
457*cdf0e10cSrcweir         mpCurrentContainerPart.reset();
458*cdf0e10cSrcweir         maElementContainer.clear();
459*cdf0e10cSrcweir         throw;
460*cdf0e10cSrcweir     }
461*cdf0e10cSrcweir }
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir PresenterToolBar::~PresenterToolBar (void)
467*cdf0e10cSrcweir {
468*cdf0e10cSrcweir }
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::disposing (void)
474*cdf0e10cSrcweir {
475*cdf0e10cSrcweir     if (mxWindow.is())
476*cdf0e10cSrcweir     {
477*cdf0e10cSrcweir         mxWindow->removeWindowListener(this);
478*cdf0e10cSrcweir         mxWindow->removePaintListener(this);
479*cdf0e10cSrcweir         mxWindow->removeMouseListener(this);
480*cdf0e10cSrcweir         mxWindow->removeMouseMotionListener(this);
481*cdf0e10cSrcweir         mxWindow = NULL;
482*cdf0e10cSrcweir     }
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir     // Dispose tool bar elements.
485*cdf0e10cSrcweir     ElementContainer::iterator iPart (maElementContainer.begin());
486*cdf0e10cSrcweir     ElementContainer::const_iterator iEnd (maElementContainer.end());
487*cdf0e10cSrcweir     for ( ; iPart!=iEnd; ++iPart)
488*cdf0e10cSrcweir     {
489*cdf0e10cSrcweir         OSL_ASSERT(iPart->get()!=NULL);
490*cdf0e10cSrcweir         ElementContainerPart::iterator iElement ((*iPart)->begin());
491*cdf0e10cSrcweir         ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
492*cdf0e10cSrcweir         for ( ; iElement!=iPartEnd; ++iElement)
493*cdf0e10cSrcweir         {
494*cdf0e10cSrcweir             if (iElement->get() != NULL)
495*cdf0e10cSrcweir             {
496*cdf0e10cSrcweir                 ::rtl::Reference<Element> pElement (*iElement);
497*cdf0e10cSrcweir                 Reference<lang::XComponent> xComponent (
498*cdf0e10cSrcweir                     static_cast<XWeak*>(pElement.get()), UNO_QUERY);
499*cdf0e10cSrcweir                 if (xComponent.is())
500*cdf0e10cSrcweir                     xComponent->dispose();
501*cdf0e10cSrcweir             }
502*cdf0e10cSrcweir         }
503*cdf0e10cSrcweir     }
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir     mpCurrentContainerPart.reset();
506*cdf0e10cSrcweir     maElementContainer.clear();
507*cdf0e10cSrcweir }
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir void PresenterToolBar::InvalidateArea (
513*cdf0e10cSrcweir     const awt::Rectangle& rRepaintBox,
514*cdf0e10cSrcweir     const bool bSynchronous)
515*cdf0e10cSrcweir {
516*cdf0e10cSrcweir     mpPresenterController->GetPaintManager()->Invalidate(
517*cdf0e10cSrcweir         mxWindow,
518*cdf0e10cSrcweir         rRepaintBox,
519*cdf0e10cSrcweir         bSynchronous);
520*cdf0e10cSrcweir }
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir sal_Int32 PresenterToolBar::GetCurrentSlideIndex (void)
526*cdf0e10cSrcweir {
527*cdf0e10cSrcweir     if (mxSlideShowController.is())
528*cdf0e10cSrcweir         return mxSlideShowController->getCurrentSlideIndex();
529*cdf0e10cSrcweir     else
530*cdf0e10cSrcweir         return -1;
531*cdf0e10cSrcweir }
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir sal_Int32 PresenterToolBar::GetSlideCount (void)
537*cdf0e10cSrcweir {
538*cdf0e10cSrcweir     if (mxSlideShowController.is())
539*cdf0e10cSrcweir         return mxSlideShowController->getSlideCount();
540*cdf0e10cSrcweir     else
541*cdf0e10cSrcweir         return 0;
542*cdf0e10cSrcweir }
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir void PresenterToolBar::RequestLayout (void)
548*cdf0e10cSrcweir {
549*cdf0e10cSrcweir     mbIsLayoutPending = true;
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir     mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
552*cdf0e10cSrcweir }
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir geometry::RealSize2D PresenterToolBar::GetSize (void)
558*cdf0e10cSrcweir {
559*cdf0e10cSrcweir     if (mbIsLayoutPending)
560*cdf0e10cSrcweir         Layout(mxCanvas);
561*cdf0e10cSrcweir     return geometry::RealSize2D(
562*cdf0e10cSrcweir         maBoundingBox.X2 - maBoundingBox.X1,
563*cdf0e10cSrcweir         maBoundingBox.Y2 - maBoundingBox.Y1);
564*cdf0e10cSrcweir }
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir geometry::RealSize2D PresenterToolBar::GetMinimalSize (void)
570*cdf0e10cSrcweir {
571*cdf0e10cSrcweir     if (mbIsLayoutPending)
572*cdf0e10cSrcweir         Layout(mxCanvas);
573*cdf0e10cSrcweir     return maMinimalSize;
574*cdf0e10cSrcweir }
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir ::rtl::Reference<PresenterController> PresenterToolBar::GetPresenterController (void) const
580*cdf0e10cSrcweir {
581*cdf0e10cSrcweir     return mpPresenterController;
582*cdf0e10cSrcweir }
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir Reference<awt::XWindow> PresenterToolBar::GetWindow (void) const
588*cdf0e10cSrcweir {
589*cdf0e10cSrcweir     return mxWindow;
590*cdf0e10cSrcweir }
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir Reference<XComponentContext> PresenterToolBar::GetComponentContext (void) const
596*cdf0e10cSrcweir {
597*cdf0e10cSrcweir     return mxComponentContext;
598*cdf0e10cSrcweir }
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir //-----  lang::XEventListener -------------------------------------------------
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::disposing (const lang::EventObject& rEventObject)
606*cdf0e10cSrcweir     throw (RuntimeException)
607*cdf0e10cSrcweir {
608*cdf0e10cSrcweir     if (rEventObject.Source == mxWindow)
609*cdf0e10cSrcweir         mxWindow = NULL;
610*cdf0e10cSrcweir }
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir //----- XWindowListener -------------------------------------------------------
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::windowResized (const awt::WindowEvent& rEvent)
618*cdf0e10cSrcweir     throw (RuntimeException)
619*cdf0e10cSrcweir {
620*cdf0e10cSrcweir     (void)rEvent;
621*cdf0e10cSrcweir     mbIsLayoutPending = true;
622*cdf0e10cSrcweir }
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::windowMoved (const awt::WindowEvent& rEvent)
628*cdf0e10cSrcweir     throw (RuntimeException)
629*cdf0e10cSrcweir {
630*cdf0e10cSrcweir     (void)rEvent;
631*cdf0e10cSrcweir }
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::windowShown (const lang::EventObject& rEvent)
637*cdf0e10cSrcweir     throw (RuntimeException)
638*cdf0e10cSrcweir {
639*cdf0e10cSrcweir     (void)rEvent;
640*cdf0e10cSrcweir     mbIsLayoutPending = true;
641*cdf0e10cSrcweir }
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::windowHidden (const lang::EventObject& rEvent)
647*cdf0e10cSrcweir     throw (RuntimeException)
648*cdf0e10cSrcweir {
649*cdf0e10cSrcweir     (void)rEvent;
650*cdf0e10cSrcweir }
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir 
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir //----- XPaintListener --------------------------------------------------------
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::windowPaint (const css::awt::PaintEvent& rEvent)
658*cdf0e10cSrcweir     throw (RuntimeException)
659*cdf0e10cSrcweir {
660*cdf0e10cSrcweir     if ( ! mxCanvas.is())
661*cdf0e10cSrcweir         return;
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir     if ( ! mbIsPresenterViewActive)
664*cdf0e10cSrcweir         return;
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir     const rendering::ViewState aViewState (
667*cdf0e10cSrcweir         geometry::AffineMatrix2D(1,0,0, 0,1,0),
668*cdf0e10cSrcweir         PresenterGeometryHelper::CreatePolygon(rEvent.UpdateRect, mxCanvas->getDevice()));
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir     if (mbIsLayoutPending)
671*cdf0e10cSrcweir         Layout(mxCanvas);
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir     Paint(rEvent.UpdateRect, aViewState);
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir     // Make the back buffer visible.
676*cdf0e10cSrcweir     Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
677*cdf0e10cSrcweir     if (xSpriteCanvas.is())
678*cdf0e10cSrcweir         xSpriteCanvas->updateScreen(sal_False);
679*cdf0e10cSrcweir }
680*cdf0e10cSrcweir 
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir //----- XMouseListener --------------------------------------------------------
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::mousePressed (const css::awt::MouseEvent& rEvent)
687*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
688*cdf0e10cSrcweir {
689*cdf0e10cSrcweir     CheckMouseOver(rEvent, true, true);
690*cdf0e10cSrcweir }
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::mouseReleased (const css::awt::MouseEvent& rEvent)
696*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
697*cdf0e10cSrcweir {
698*cdf0e10cSrcweir     CheckMouseOver(rEvent, true);
699*cdf0e10cSrcweir }
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::mouseEntered (const css::awt::MouseEvent& rEvent)
705*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
706*cdf0e10cSrcweir {
707*cdf0e10cSrcweir     CheckMouseOver(rEvent, true);
708*cdf0e10cSrcweir }
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::mouseExited (const css::awt::MouseEvent& rEvent)
714*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
715*cdf0e10cSrcweir {
716*cdf0e10cSrcweir     CheckMouseOver(rEvent, false);
717*cdf0e10cSrcweir }
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir 
722*cdf0e10cSrcweir //----- XMouseMotionListener --------------------------------------------------
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::mouseMoved (const css::awt::MouseEvent& rEvent)
725*cdf0e10cSrcweir     throw (css::uno::RuntimeException)
726*cdf0e10cSrcweir {
727*cdf0e10cSrcweir     ThrowIfDisposed();
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir     CheckMouseOver(rEvent, true);
730*cdf0e10cSrcweir }
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::mouseDragged (const css::awt::MouseEvent& rEvent)
736*cdf0e10cSrcweir     throw (css::uno::RuntimeException)
737*cdf0e10cSrcweir {
738*cdf0e10cSrcweir     ThrowIfDisposed();
739*cdf0e10cSrcweir     (void)rEvent;
740*cdf0e10cSrcweir }
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir 
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir 
745*cdf0e10cSrcweir //----- XDrawView -------------------------------------------------------------
746*cdf0e10cSrcweir 
747*cdf0e10cSrcweir void SAL_CALL PresenterToolBar::setCurrentPage (const Reference<drawing::XDrawPage>& rxSlide)
748*cdf0e10cSrcweir     throw (RuntimeException)
749*cdf0e10cSrcweir {
750*cdf0e10cSrcweir     if (rxSlide != mxCurrentSlide)
751*cdf0e10cSrcweir     {
752*cdf0e10cSrcweir         mxCurrentSlide = rxSlide;
753*cdf0e10cSrcweir         UpdateSlideNumber();
754*cdf0e10cSrcweir     }
755*cdf0e10cSrcweir }
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir Reference<drawing::XDrawPage> SAL_CALL PresenterToolBar::getCurrentPage (void)
761*cdf0e10cSrcweir     throw (RuntimeException)
762*cdf0e10cSrcweir {
763*cdf0e10cSrcweir     return mxCurrentSlide;
764*cdf0e10cSrcweir }
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir //-----------------------------------------------------------------------------
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir void PresenterToolBar::CreateControls (
772*cdf0e10cSrcweir     const ::rtl::OUString& rsConfigurationPath)
773*cdf0e10cSrcweir {
774*cdf0e10cSrcweir     if ( ! mxWindow.is())
775*cdf0e10cSrcweir         return;
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir     // Expand the macro in the bitmap file names.
778*cdf0e10cSrcweir     PresenterConfigurationAccess aConfiguration (
779*cdf0e10cSrcweir         mxComponentContext,
780*cdf0e10cSrcweir         OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
781*cdf0e10cSrcweir         PresenterConfigurationAccess::READ_ONLY);
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir     const OUString sBasePath (PresenterComponent::GetBasePath(mxComponentContext));
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir     mpCurrentContainerPart.reset(new ElementContainerPart());
786*cdf0e10cSrcweir     maElementContainer.clear();
787*cdf0e10cSrcweir     maElementContainer.push_back(mpCurrentContainerPart);
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir     Reference<container::XHierarchicalNameAccess> xToolBarNode (
790*cdf0e10cSrcweir         aConfiguration.GetConfigurationNode(rsConfigurationPath),
791*cdf0e10cSrcweir         UNO_QUERY);
792*cdf0e10cSrcweir     if (xToolBarNode.is())
793*cdf0e10cSrcweir     {
794*cdf0e10cSrcweir         Reference<container::XNameAccess> xEntries (
795*cdf0e10cSrcweir             PresenterConfigurationAccess::GetConfigurationNode(xToolBarNode, A2S("Entries")),
796*cdf0e10cSrcweir             UNO_QUERY);
797*cdf0e10cSrcweir         Context aContext;
798*cdf0e10cSrcweir         aContext.msBasePath = sBasePath;
799*cdf0e10cSrcweir         aContext.mxPresenterHelper = mpPresenterController->GetPresenterHelper();
800*cdf0e10cSrcweir         aContext.mxCanvas = mxCanvas;
801*cdf0e10cSrcweir         if (xEntries.is()
802*cdf0e10cSrcweir             && aContext.mxPresenterHelper.is()
803*cdf0e10cSrcweir             && aContext.mxCanvas.is())
804*cdf0e10cSrcweir         {
805*cdf0e10cSrcweir             PresenterConfigurationAccess::ForAll(
806*cdf0e10cSrcweir                 xEntries,
807*cdf0e10cSrcweir                 ::boost::bind(&PresenterToolBar::ProcessEntry, this, _2, ::boost::ref(aContext)));
808*cdf0e10cSrcweir         }
809*cdf0e10cSrcweir     }
810*cdf0e10cSrcweir }
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir 
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir 
815*cdf0e10cSrcweir void PresenterToolBar::ProcessEntry (
816*cdf0e10cSrcweir     const Reference<beans::XPropertySet>& rxProperties,
817*cdf0e10cSrcweir     Context& rContext)
818*cdf0e10cSrcweir {
819*cdf0e10cSrcweir     if ( ! rxProperties.is())
820*cdf0e10cSrcweir         return;
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir     // Type has to be present.
823*cdf0e10cSrcweir     OUString sType;
824*cdf0e10cSrcweir     if ( ! (PresenterConfigurationAccess::GetProperty(rxProperties, A2S("Type")) >>= sType))
825*cdf0e10cSrcweir         return;
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir     OUString sName;
828*cdf0e10cSrcweir     PresenterConfigurationAccess::GetProperty(rxProperties, A2S("Name")) >>= sName;
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir     // Read mode specific values.
831*cdf0e10cSrcweir     SharedElementMode pNormalMode (new ElementMode());
832*cdf0e10cSrcweir     SharedElementMode pMouseOverMode (new ElementMode());
833*cdf0e10cSrcweir     SharedElementMode pSelectedMode (new ElementMode());
834*cdf0e10cSrcweir     SharedElementMode pDisabledMode (new ElementMode());
835*cdf0e10cSrcweir     pNormalMode->ReadElementMode(rxProperties, A2S("Normal"), pNormalMode, rContext);
836*cdf0e10cSrcweir     pMouseOverMode->ReadElementMode(rxProperties, A2S("MouseOver"), pNormalMode, rContext);
837*cdf0e10cSrcweir     pSelectedMode->ReadElementMode(rxProperties, A2S("Selected"), pNormalMode, rContext);
838*cdf0e10cSrcweir     pDisabledMode->ReadElementMode(rxProperties, A2S("Disabled"), pNormalMode, rContext);
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir     // Create new element.
841*cdf0e10cSrcweir     ::rtl::Reference<Element> pElement;
842*cdf0e10cSrcweir     if (sType.equalsAscii("Button"))
843*cdf0e10cSrcweir         pElement = Button::Create(this);
844*cdf0e10cSrcweir     else if (sType.equalsAscii("CurrentTimeLabel"))
845*cdf0e10cSrcweir         pElement = CurrentTimeLabel::Create(this);
846*cdf0e10cSrcweir     else if (sType.equalsAscii("PresentationTimeLabel"))
847*cdf0e10cSrcweir         pElement = PresentationTimeLabel::Create(this);
848*cdf0e10cSrcweir     else if (sType.equalsAscii("VerticalSeparator"))
849*cdf0e10cSrcweir         pElement = ::rtl::Reference<Element>(new VerticalSeparator(this));
850*cdf0e10cSrcweir     else if (sType.equalsAscii("HorizontalSeparator"))
851*cdf0e10cSrcweir         pElement = ::rtl::Reference<Element>(new HorizontalSeparator(this));
852*cdf0e10cSrcweir     else if (sType.equalsAscii("Label"))
853*cdf0e10cSrcweir         pElement = ::rtl::Reference<Element>(new Label(this));
854*cdf0e10cSrcweir     else if (sType.equalsAscii("ChangeOrientation"))
855*cdf0e10cSrcweir     {
856*cdf0e10cSrcweir         mpCurrentContainerPart.reset(new ElementContainerPart());
857*cdf0e10cSrcweir         maElementContainer.push_back(mpCurrentContainerPart);
858*cdf0e10cSrcweir         return;
859*cdf0e10cSrcweir     }
860*cdf0e10cSrcweir     if (pElement.is())
861*cdf0e10cSrcweir     {
862*cdf0e10cSrcweir         pElement->SetModes( pNormalMode, pMouseOverMode, pSelectedMode, pDisabledMode);
863*cdf0e10cSrcweir         pElement->UpdateState();
864*cdf0e10cSrcweir         if (mpCurrentContainerPart.get() != NULL)
865*cdf0e10cSrcweir             mpCurrentContainerPart->push_back(pElement);
866*cdf0e10cSrcweir     }
867*cdf0e10cSrcweir }
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir 
870*cdf0e10cSrcweir 
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir void PresenterToolBar::Layout (
873*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas)
874*cdf0e10cSrcweir {
875*cdf0e10cSrcweir     if (maElementContainer.size() == 0)
876*cdf0e10cSrcweir         return;
877*cdf0e10cSrcweir 
878*cdf0e10cSrcweir     mbIsLayoutPending = false;
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir     const awt::Rectangle aWindowBox (mxWindow->getPosSize());
881*cdf0e10cSrcweir     ElementContainer::iterator iPart;
882*cdf0e10cSrcweir     ElementContainer::iterator iEnd (maElementContainer.end());
883*cdf0e10cSrcweir     ::std::vector<geometry::RealSize2D> aPartSizes (maElementContainer.size());
884*cdf0e10cSrcweir     geometry::RealSize2D aTotalSize (0,0);
885*cdf0e10cSrcweir 	bool bIsHorizontal (true);
886*cdf0e10cSrcweir     sal_Int32 nIndex;
887*cdf0e10cSrcweir     double nTotalHorizontalGap (0);
888*cdf0e10cSrcweir     sal_Int32 nGapCount (0);
889*cdf0e10cSrcweir     for (iPart=maElementContainer.begin(),nIndex=0; iPart!=iEnd; ++iPart,++nIndex)
890*cdf0e10cSrcweir     {
891*cdf0e10cSrcweir         geometry::RealSize2D aSize (CalculatePartSize(rxCanvas, *iPart, bIsHorizontal));
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir         // Remember the size of each part for later.
894*cdf0e10cSrcweir         aPartSizes[nIndex] = aSize;
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir         // Add gaps between elements.
897*cdf0e10cSrcweir         if ((*iPart)->size()>1 && bIsHorizontal)
898*cdf0e10cSrcweir         {
899*cdf0e10cSrcweir             nTotalHorizontalGap += ((*iPart)->size() - 1) * gnGapSize;
900*cdf0e10cSrcweir             nGapCount += (*iPart)->size()-1;
901*cdf0e10cSrcweir         }
902*cdf0e10cSrcweir 
903*cdf0e10cSrcweir         // Orientation changes for each part.
904*cdf0e10cSrcweir         bIsHorizontal = !bIsHorizontal;
905*cdf0e10cSrcweir         // Width is accumulated.
906*cdf0e10cSrcweir         aTotalSize.Width += aSize.Width;
907*cdf0e10cSrcweir         // Height is the maximum height of all parts.
908*cdf0e10cSrcweir         aTotalSize.Height = ::std::max(aTotalSize.Height, aSize.Height);
909*cdf0e10cSrcweir     }
910*cdf0e10cSrcweir     // Add gaps between parts.
911*cdf0e10cSrcweir     if (maElementContainer.size() > 1)
912*cdf0e10cSrcweir     {
913*cdf0e10cSrcweir         nTotalHorizontalGap += (maElementContainer.size() - 1) * gnGapSize;
914*cdf0e10cSrcweir         nGapCount += maElementContainer.size()-1;
915*cdf0e10cSrcweir     }
916*cdf0e10cSrcweir 
917*cdf0e10cSrcweir     // Calculate the minimal size so that the window size of the tool bar
918*cdf0e10cSrcweir     // can be adapted accordingly.
919*cdf0e10cSrcweir     maMinimalSize = aTotalSize;
920*cdf0e10cSrcweir     maMinimalSize.Width += nTotalHorizontalGap;
921*cdf0e10cSrcweir 
922*cdf0e10cSrcweir     // Calculate the gaps between elements.
923*cdf0e10cSrcweir     double nGapWidth (0);
924*cdf0e10cSrcweir     if (nGapCount > 0)
925*cdf0e10cSrcweir     {
926*cdf0e10cSrcweir         if (aTotalSize.Width + nTotalHorizontalGap > aWindowBox.Width)
927*cdf0e10cSrcweir             nTotalHorizontalGap = aWindowBox.Width - aTotalSize.Width;
928*cdf0e10cSrcweir         nGapWidth = nTotalHorizontalGap / nGapCount;
929*cdf0e10cSrcweir     }
930*cdf0e10cSrcweir 
931*cdf0e10cSrcweir     // Determine the location of the left edge.
932*cdf0e10cSrcweir     double nX (0);
933*cdf0e10cSrcweir     switch (meAnchor)
934*cdf0e10cSrcweir     {
935*cdf0e10cSrcweir         case Left : nX = 0; break;
936*cdf0e10cSrcweir         case Center: nX = (aWindowBox.Width - aTotalSize.Width - nTotalHorizontalGap) / 2; break;
937*cdf0e10cSrcweir         case Right: nX = aWindowBox.Width - aTotalSize.Width - nTotalHorizontalGap; break;
938*cdf0e10cSrcweir     }
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir     // Place the parts.
941*cdf0e10cSrcweir     double nY ((aWindowBox.Height - aTotalSize.Height) / 2);
942*cdf0e10cSrcweir     bIsHorizontal = true;
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir     maBoundingBox.X1 = nX;
945*cdf0e10cSrcweir     maBoundingBox.Y1 = nY;
946*cdf0e10cSrcweir     maBoundingBox.X2 = nX + aTotalSize.Width + nTotalHorizontalGap;
947*cdf0e10cSrcweir     maBoundingBox.Y2 = nY + aTotalSize.Height;
948*cdf0e10cSrcweir 
949*cdf0e10cSrcweir     for (iPart=maElementContainer.begin(), nIndex=0; iPart!=iEnd; ++iPart,++nIndex)
950*cdf0e10cSrcweir     {
951*cdf0e10cSrcweir         geometry::RealRectangle2D aBoundingBox(
952*cdf0e10cSrcweir             nX, nY,
953*cdf0e10cSrcweir             nX+aPartSizes[nIndex].Width, nY+aTotalSize.Height);
954*cdf0e10cSrcweir 
955*cdf0e10cSrcweir         // Add space for gaps between elements.
956*cdf0e10cSrcweir         if ((*iPart)->size() > 1)
957*cdf0e10cSrcweir             if (bIsHorizontal)
958*cdf0e10cSrcweir                 aBoundingBox.X2 += ((*iPart)->size()-1) * nGapWidth;
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir         LayoutPart(rxCanvas, *iPart, aBoundingBox, aPartSizes[nIndex], bIsHorizontal);
961*cdf0e10cSrcweir         bIsHorizontal = !bIsHorizontal;
962*cdf0e10cSrcweir         nX += aBoundingBox.X2 - aBoundingBox.X1 + nGapWidth;
963*cdf0e10cSrcweir     }
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir     // The whole window has to be repainted.
966*cdf0e10cSrcweir     mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
967*cdf0e10cSrcweir }
968*cdf0e10cSrcweir 
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir 
971*cdf0e10cSrcweir 
972*cdf0e10cSrcweir geometry::RealSize2D PresenterToolBar::CalculatePartSize (
973*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas,
974*cdf0e10cSrcweir     const SharedElementContainerPart& rpPart,
975*cdf0e10cSrcweir     const bool bIsHorizontal)
976*cdf0e10cSrcweir {
977*cdf0e10cSrcweir     geometry::RealSize2D aTotalSize (0,0);
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir     if (mxWindow.is())
980*cdf0e10cSrcweir     {
981*cdf0e10cSrcweir         const awt::Rectangle aWindowBox (mxWindow->getPosSize());
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir         // Calculate the summed width of all elements.
984*cdf0e10cSrcweir         ElementContainerPart::const_iterator iElement;
985*cdf0e10cSrcweir         for (iElement=rpPart->begin(); iElement!=rpPart->end(); ++iElement)
986*cdf0e10cSrcweir         {
987*cdf0e10cSrcweir             if (iElement->get() == NULL)
988*cdf0e10cSrcweir                 continue;
989*cdf0e10cSrcweir 
990*cdf0e10cSrcweir             const awt::Size aBSize ((*iElement)->GetBoundingSize(rxCanvas));
991*cdf0e10cSrcweir             if (bIsHorizontal)
992*cdf0e10cSrcweir             {
993*cdf0e10cSrcweir                 aTotalSize.Width += aBSize.Width;
994*cdf0e10cSrcweir                 if (aBSize.Height > aTotalSize.Height)
995*cdf0e10cSrcweir                     aTotalSize.Height = aBSize.Height;
996*cdf0e10cSrcweir             }
997*cdf0e10cSrcweir             else
998*cdf0e10cSrcweir             {
999*cdf0e10cSrcweir                 aTotalSize.Height += aBSize.Height;
1000*cdf0e10cSrcweir                 if (aBSize.Width > aTotalSize.Width)
1001*cdf0e10cSrcweir                     aTotalSize.Width = aBSize.Width;
1002*cdf0e10cSrcweir             }
1003*cdf0e10cSrcweir         }
1004*cdf0e10cSrcweir     }
1005*cdf0e10cSrcweir     return aTotalSize;
1006*cdf0e10cSrcweir }
1007*cdf0e10cSrcweir 
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir 
1010*cdf0e10cSrcweir 
1011*cdf0e10cSrcweir void PresenterToolBar::LayoutPart (
1012*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas,
1013*cdf0e10cSrcweir     const SharedElementContainerPart& rpPart,
1014*cdf0e10cSrcweir     const geometry::RealRectangle2D& rBoundingBox,
1015*cdf0e10cSrcweir     const geometry::RealSize2D& rPartSize,
1016*cdf0e10cSrcweir     const bool bIsHorizontal)
1017*cdf0e10cSrcweir {
1018*cdf0e10cSrcweir     double nGap (0);
1019*cdf0e10cSrcweir     if (rpPart->size() > 1)
1020*cdf0e10cSrcweir     {
1021*cdf0e10cSrcweir         if (bIsHorizontal)
1022*cdf0e10cSrcweir             nGap = (rBoundingBox.X2 - rBoundingBox.X1 - rPartSize.Width) / (rpPart->size()-1);
1023*cdf0e10cSrcweir         else
1024*cdf0e10cSrcweir             nGap = (rBoundingBox.Y2 - rBoundingBox.Y1 - rPartSize.Height) / (rpPart->size()-1);
1025*cdf0e10cSrcweir     }
1026*cdf0e10cSrcweir 
1027*cdf0e10cSrcweir     // Place the elements.
1028*cdf0e10cSrcweir     double nX (rBoundingBox.X1);
1029*cdf0e10cSrcweir     double nY (rBoundingBox.Y1);
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir     ElementContainerPart::const_iterator iElement;
1032*cdf0e10cSrcweir     ElementContainerPart::const_iterator iEnd (rpPart->end());
1033*cdf0e10cSrcweir     for (iElement=rpPart->begin(); iElement!=iEnd; ++iElement)
1034*cdf0e10cSrcweir     {
1035*cdf0e10cSrcweir         if (iElement->get() == NULL)
1036*cdf0e10cSrcweir             continue;
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir         const awt::Size aElementSize ((*iElement)->GetBoundingSize(rxCanvas));
1039*cdf0e10cSrcweir         if (bIsHorizontal)
1040*cdf0e10cSrcweir         {
1041*cdf0e10cSrcweir             if ((*iElement)->IsFilling())
1042*cdf0e10cSrcweir             {
1043*cdf0e10cSrcweir                 nY = rBoundingBox.Y1;
1044*cdf0e10cSrcweir                 (*iElement)->SetSize(geometry::RealSize2D(aElementSize.Width, rBoundingBox.Y2 - rBoundingBox.Y1));
1045*cdf0e10cSrcweir             }
1046*cdf0e10cSrcweir             else
1047*cdf0e10cSrcweir                 nY = rBoundingBox.Y1 + (rBoundingBox.Y2-rBoundingBox.Y1 - aElementSize.Height) / 2;
1048*cdf0e10cSrcweir             (*iElement)->SetLocation(awt::Point(sal_Int32(0.5 + nX), sal_Int32(0.5 + nY)));
1049*cdf0e10cSrcweir             nX += aElementSize.Width + nGap;
1050*cdf0e10cSrcweir         }
1051*cdf0e10cSrcweir         else
1052*cdf0e10cSrcweir         {
1053*cdf0e10cSrcweir             if ((*iElement)->IsFilling())
1054*cdf0e10cSrcweir             {
1055*cdf0e10cSrcweir                 nX = rBoundingBox.X1;
1056*cdf0e10cSrcweir                 (*iElement)->SetSize(geometry::RealSize2D(rBoundingBox.X2 - rBoundingBox.X1, aElementSize.Height));
1057*cdf0e10cSrcweir             }
1058*cdf0e10cSrcweir             else
1059*cdf0e10cSrcweir                 nX = rBoundingBox.X1 + (rBoundingBox.X2-rBoundingBox.X1 - aElementSize.Width) / 2;
1060*cdf0e10cSrcweir             (*iElement)->SetLocation(awt::Point(sal_Int32(0.5 + nX), sal_Int32(0.5 + nY)));
1061*cdf0e10cSrcweir             nY += aElementSize.Height + nGap;
1062*cdf0e10cSrcweir         }
1063*cdf0e10cSrcweir     }
1064*cdf0e10cSrcweir }
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir 
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir 
1069*cdf0e10cSrcweir void PresenterToolBar::Paint (
1070*cdf0e10cSrcweir     const awt::Rectangle& rUpdateBox,
1071*cdf0e10cSrcweir     const rendering::ViewState& rViewState)
1072*cdf0e10cSrcweir {
1073*cdf0e10cSrcweir     OSL_ASSERT(mxCanvas.is());
1074*cdf0e10cSrcweir 
1075*cdf0e10cSrcweir     ElementContainer::iterator iPart;
1076*cdf0e10cSrcweir     ElementContainer::const_iterator iEnd (maElementContainer.end());
1077*cdf0e10cSrcweir     for (iPart=maElementContainer.begin(); iPart!=iEnd; ++iPart)
1078*cdf0e10cSrcweir     {
1079*cdf0e10cSrcweir         ElementContainerPart::iterator iElement;
1080*cdf0e10cSrcweir         ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
1081*cdf0e10cSrcweir         for (iElement=(*iPart)->begin(); iElement!=iPartEnd; ++iElement)
1082*cdf0e10cSrcweir         {
1083*cdf0e10cSrcweir             if (iElement->get() != NULL)
1084*cdf0e10cSrcweir             {
1085*cdf0e10cSrcweir                 if ( ! (*iElement)->IsOutside(rUpdateBox))
1086*cdf0e10cSrcweir                     (*iElement)->Paint(mxCanvas, rViewState);
1087*cdf0e10cSrcweir             }
1088*cdf0e10cSrcweir         }
1089*cdf0e10cSrcweir     }
1090*cdf0e10cSrcweir }
1091*cdf0e10cSrcweir 
1092*cdf0e10cSrcweir 
1093*cdf0e10cSrcweir 
1094*cdf0e10cSrcweir 
1095*cdf0e10cSrcweir void PresenterToolBar::UpdateSlideNumber (void)
1096*cdf0e10cSrcweir {
1097*cdf0e10cSrcweir 	if( mxSlideShowController.is() )
1098*cdf0e10cSrcweir 	{
1099*cdf0e10cSrcweir         ElementContainer::iterator iPart;
1100*cdf0e10cSrcweir         ElementContainer::const_iterator iEnd (maElementContainer.end());
1101*cdf0e10cSrcweir         for (iPart=maElementContainer.begin(); iPart!=iEnd; ++iPart)
1102*cdf0e10cSrcweir         {
1103*cdf0e10cSrcweir             ElementContainerPart::iterator iElement;
1104*cdf0e10cSrcweir             ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
1105*cdf0e10cSrcweir             for (iElement=(*iPart)->begin(); iElement!=iPartEnd; ++iElement)
1106*cdf0e10cSrcweir             {
1107*cdf0e10cSrcweir                 if (iElement->get() != NULL)
1108*cdf0e10cSrcweir                     (*iElement)->CurrentSlideHasChanged();
1109*cdf0e10cSrcweir             }
1110*cdf0e10cSrcweir         }
1111*cdf0e10cSrcweir 	}
1112*cdf0e10cSrcweir }
1113*cdf0e10cSrcweir 
1114*cdf0e10cSrcweir 
1115*cdf0e10cSrcweir 
1116*cdf0e10cSrcweir 
1117*cdf0e10cSrcweir void PresenterToolBar::CheckMouseOver (
1118*cdf0e10cSrcweir     const css::awt::MouseEvent& rEvent,
1119*cdf0e10cSrcweir     const bool bOverWindow,
1120*cdf0e10cSrcweir     const bool bMouseDown)
1121*cdf0e10cSrcweir {
1122*cdf0e10cSrcweir     ElementContainer::iterator iPart;
1123*cdf0e10cSrcweir     ElementContainer::const_iterator iEnd (maElementContainer.end());
1124*cdf0e10cSrcweir     for (iPart=maElementContainer.begin(); iPart!=iEnd; ++iPart)
1125*cdf0e10cSrcweir     {
1126*cdf0e10cSrcweir         ElementContainerPart::iterator iElement;
1127*cdf0e10cSrcweir         ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
1128*cdf0e10cSrcweir         for (iElement=(*iPart)->begin(); iElement!=iPartEnd; ++iElement)
1129*cdf0e10cSrcweir         {
1130*cdf0e10cSrcweir             if (iElement->get() == NULL)
1131*cdf0e10cSrcweir                 continue;
1132*cdf0e10cSrcweir 
1133*cdf0e10cSrcweir             awt::Rectangle aBox ((*iElement)->GetBoundingBox());
1134*cdf0e10cSrcweir             const bool bIsOver = bOverWindow
1135*cdf0e10cSrcweir                 && aBox.X <= rEvent.X
1136*cdf0e10cSrcweir                 && aBox.Width+aBox.X-1 >= rEvent.X
1137*cdf0e10cSrcweir                 && aBox.Y <= rEvent.Y
1138*cdf0e10cSrcweir                 && aBox.Height+aBox.Y-1 >= rEvent.Y;
1139*cdf0e10cSrcweir             (*iElement)->SetState(
1140*cdf0e10cSrcweir                 bIsOver,
1141*cdf0e10cSrcweir                 bIsOver && rEvent.Buttons!=0 && bMouseDown && rEvent.ClickCount>0);
1142*cdf0e10cSrcweir         }
1143*cdf0e10cSrcweir     }
1144*cdf0e10cSrcweir }
1145*cdf0e10cSrcweir 
1146*cdf0e10cSrcweir 
1147*cdf0e10cSrcweir 
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir void PresenterToolBar::ThrowIfDisposed (void) const
1150*cdf0e10cSrcweir     throw (::com::sun::star::lang::DisposedException)
1151*cdf0e10cSrcweir {
1152*cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
1153*cdf0e10cSrcweir 	{
1154*cdf0e10cSrcweir         throw lang::DisposedException (
1155*cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM(
1156*cdf0e10cSrcweir                 "PresenterToolBar has already been disposed")),
1157*cdf0e10cSrcweir             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
1158*cdf0e10cSrcweir     }
1159*cdf0e10cSrcweir }
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir 
1162*cdf0e10cSrcweir 
1163*cdf0e10cSrcweir 
1164*cdf0e10cSrcweir //===== PresenterToolBarView ==================================================
1165*cdf0e10cSrcweir 
1166*cdf0e10cSrcweir PresenterToolBarView::PresenterToolBarView (
1167*cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
1168*cdf0e10cSrcweir     const Reference<XResourceId>& rxViewId,
1169*cdf0e10cSrcweir     const Reference<frame::XController>& rxController,
1170*cdf0e10cSrcweir     const ::rtl::Reference<PresenterController>& rpPresenterController)
1171*cdf0e10cSrcweir     : PresenterToolBarViewInterfaceBase(m_aMutex),
1172*cdf0e10cSrcweir       mxPane(),
1173*cdf0e10cSrcweir       mxViewId(rxViewId),
1174*cdf0e10cSrcweir       mxWindow(),
1175*cdf0e10cSrcweir       mxCanvas(),
1176*cdf0e10cSrcweir       mpPresenterController(rpPresenterController),
1177*cdf0e10cSrcweir       mxSlideShowController(rpPresenterController->GetSlideShowController()),
1178*cdf0e10cSrcweir       mpToolBar()
1179*cdf0e10cSrcweir {
1180*cdf0e10cSrcweir     try
1181*cdf0e10cSrcweir     {
1182*cdf0e10cSrcweir         Reference<XControllerManager> xCM (rxController, UNO_QUERY_THROW);
1183*cdf0e10cSrcweir         Reference<XConfigurationController> xCC(xCM->getConfigurationController(),UNO_QUERY_THROW);
1184*cdf0e10cSrcweir         mxPane = Reference<XPane>(xCC->getResource(rxViewId->getAnchor()), UNO_QUERY_THROW);
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir         mxWindow = mxPane->getWindow();
1187*cdf0e10cSrcweir         mxCanvas = mxPane->getCanvas();
1188*cdf0e10cSrcweir 
1189*cdf0e10cSrcweir         mpToolBar = new PresenterToolBar(
1190*cdf0e10cSrcweir             rxContext,
1191*cdf0e10cSrcweir             mxWindow,
1192*cdf0e10cSrcweir             mxCanvas,
1193*cdf0e10cSrcweir             rpPresenterController,
1194*cdf0e10cSrcweir             PresenterToolBar::Center);
1195*cdf0e10cSrcweir         mpToolBar->Initialize(A2S("PresenterScreenSettings/ToolBars/ToolBar"));
1196*cdf0e10cSrcweir 
1197*cdf0e10cSrcweir         if (mxWindow.is())
1198*cdf0e10cSrcweir         {
1199*cdf0e10cSrcweir             mxWindow->addPaintListener(this);
1200*cdf0e10cSrcweir 
1201*cdf0e10cSrcweir             Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY);
1202*cdf0e10cSrcweir             if (xPeer.is())
1203*cdf0e10cSrcweir                 xPeer->setBackground(util::Color(0xff000000));
1204*cdf0e10cSrcweir 
1205*cdf0e10cSrcweir             mxWindow->setVisible(sal_True);
1206*cdf0e10cSrcweir         }
1207*cdf0e10cSrcweir     }
1208*cdf0e10cSrcweir     catch (RuntimeException&)
1209*cdf0e10cSrcweir     {
1210*cdf0e10cSrcweir         mxViewId = NULL;
1211*cdf0e10cSrcweir         throw;
1212*cdf0e10cSrcweir     }
1213*cdf0e10cSrcweir }
1214*cdf0e10cSrcweir 
1215*cdf0e10cSrcweir 
1216*cdf0e10cSrcweir 
1217*cdf0e10cSrcweir 
1218*cdf0e10cSrcweir PresenterToolBarView::~PresenterToolBarView (void)
1219*cdf0e10cSrcweir {
1220*cdf0e10cSrcweir }
1221*cdf0e10cSrcweir 
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir 
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir void SAL_CALL PresenterToolBarView::disposing (void)
1226*cdf0e10cSrcweir {
1227*cdf0e10cSrcweir     Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpToolBar.get()), UNO_QUERY);
1228*cdf0e10cSrcweir     mpToolBar = NULL;
1229*cdf0e10cSrcweir     if (xComponent.is())
1230*cdf0e10cSrcweir         xComponent->dispose();
1231*cdf0e10cSrcweir 
1232*cdf0e10cSrcweir     if (mxWindow.is())
1233*cdf0e10cSrcweir     {
1234*cdf0e10cSrcweir         mxWindow->removePaintListener(this);
1235*cdf0e10cSrcweir         mxWindow = NULL;
1236*cdf0e10cSrcweir     }
1237*cdf0e10cSrcweir     mxCanvas = NULL;
1238*cdf0e10cSrcweir     mxViewId = NULL;
1239*cdf0e10cSrcweir     mxPane = NULL;
1240*cdf0e10cSrcweir     mpPresenterController = NULL;
1241*cdf0e10cSrcweir     mxSlideShowController = NULL;
1242*cdf0e10cSrcweir 
1243*cdf0e10cSrcweir }
1244*cdf0e10cSrcweir 
1245*cdf0e10cSrcweir 
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir 
1248*cdf0e10cSrcweir ::rtl::Reference<PresenterToolBar> PresenterToolBarView::GetPresenterToolBar (void) const
1249*cdf0e10cSrcweir {
1250*cdf0e10cSrcweir     return mpToolBar;
1251*cdf0e10cSrcweir }
1252*cdf0e10cSrcweir 
1253*cdf0e10cSrcweir 
1254*cdf0e10cSrcweir 
1255*cdf0e10cSrcweir 
1256*cdf0e10cSrcweir //----- XPaintListener --------------------------------------------------------
1257*cdf0e10cSrcweir 
1258*cdf0e10cSrcweir void SAL_CALL PresenterToolBarView::windowPaint (const css::awt::PaintEvent& rEvent)
1259*cdf0e10cSrcweir     throw (RuntimeException)
1260*cdf0e10cSrcweir {
1261*cdf0e10cSrcweir     awt::Rectangle aWindowBox (mxWindow->getPosSize());
1262*cdf0e10cSrcweir     mpPresenterController->GetCanvasHelper()->Paint(
1263*cdf0e10cSrcweir         mpPresenterController->GetViewBackground(mxViewId->getResourceURL()),
1264*cdf0e10cSrcweir         mxCanvas,
1265*cdf0e10cSrcweir         rEvent.UpdateRect,
1266*cdf0e10cSrcweir         awt::Rectangle(0,0,aWindowBox.Width, aWindowBox.Height),
1267*cdf0e10cSrcweir         awt::Rectangle());
1268*cdf0e10cSrcweir }
1269*cdf0e10cSrcweir 
1270*cdf0e10cSrcweir 
1271*cdf0e10cSrcweir 
1272*cdf0e10cSrcweir 
1273*cdf0e10cSrcweir //-----  lang::XEventListener -------------------------------------------------
1274*cdf0e10cSrcweir 
1275*cdf0e10cSrcweir void SAL_CALL PresenterToolBarView::disposing (const lang::EventObject& rEventObject)
1276*cdf0e10cSrcweir     throw (RuntimeException)
1277*cdf0e10cSrcweir {
1278*cdf0e10cSrcweir     if (rEventObject.Source == mxWindow)
1279*cdf0e10cSrcweir         mxWindow = NULL;
1280*cdf0e10cSrcweir }
1281*cdf0e10cSrcweir 
1282*cdf0e10cSrcweir 
1283*cdf0e10cSrcweir 
1284*cdf0e10cSrcweir 
1285*cdf0e10cSrcweir //----- XResourceId -----------------------------------------------------------
1286*cdf0e10cSrcweir 
1287*cdf0e10cSrcweir Reference<XResourceId> SAL_CALL PresenterToolBarView::getResourceId (void)
1288*cdf0e10cSrcweir     throw (RuntimeException)
1289*cdf0e10cSrcweir {
1290*cdf0e10cSrcweir     return mxViewId;
1291*cdf0e10cSrcweir }
1292*cdf0e10cSrcweir 
1293*cdf0e10cSrcweir 
1294*cdf0e10cSrcweir 
1295*cdf0e10cSrcweir 
1296*cdf0e10cSrcweir sal_Bool SAL_CALL PresenterToolBarView::isAnchorOnly (void)
1297*cdf0e10cSrcweir     throw (RuntimeException)
1298*cdf0e10cSrcweir {
1299*cdf0e10cSrcweir     return false;
1300*cdf0e10cSrcweir }
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir 
1303*cdf0e10cSrcweir 
1304*cdf0e10cSrcweir 
1305*cdf0e10cSrcweir //----- XDrawView -------------------------------------------------------------
1306*cdf0e10cSrcweir 
1307*cdf0e10cSrcweir void SAL_CALL PresenterToolBarView::setCurrentPage (const Reference<drawing::XDrawPage>& rxSlide)
1308*cdf0e10cSrcweir     throw (RuntimeException)
1309*cdf0e10cSrcweir {
1310*cdf0e10cSrcweir     Reference<drawing::XDrawView> xToolBar (static_cast<XWeak*>(mpToolBar.get()), UNO_QUERY);
1311*cdf0e10cSrcweir     if (xToolBar.is())
1312*cdf0e10cSrcweir         xToolBar->setCurrentPage(rxSlide);
1313*cdf0e10cSrcweir }
1314*cdf0e10cSrcweir 
1315*cdf0e10cSrcweir 
1316*cdf0e10cSrcweir 
1317*cdf0e10cSrcweir 
1318*cdf0e10cSrcweir Reference<drawing::XDrawPage> SAL_CALL PresenterToolBarView::getCurrentPage (void)
1319*cdf0e10cSrcweir     throw (RuntimeException)
1320*cdf0e10cSrcweir {
1321*cdf0e10cSrcweir     return NULL;
1322*cdf0e10cSrcweir }
1323*cdf0e10cSrcweir 
1324*cdf0e10cSrcweir 
1325*cdf0e10cSrcweir 
1326*cdf0e10cSrcweir 
1327*cdf0e10cSrcweir //-----------------------------------------------------------------------------
1328*cdf0e10cSrcweir 
1329*cdf0e10cSrcweir void PresenterToolBarView::ThrowIfDisposed (void) const
1330*cdf0e10cSrcweir     throw (::com::sun::star::lang::DisposedException)
1331*cdf0e10cSrcweir {
1332*cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
1333*cdf0e10cSrcweir 	{
1334*cdf0e10cSrcweir         throw lang::DisposedException (
1335*cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM(
1336*cdf0e10cSrcweir                 "PresenterToolBarView has already been disposed")),
1337*cdf0e10cSrcweir             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
1338*cdf0e10cSrcweir     }
1339*cdf0e10cSrcweir }
1340*cdf0e10cSrcweir 
1341*cdf0e10cSrcweir 
1342*cdf0e10cSrcweir 
1343*cdf0e10cSrcweir 
1344*cdf0e10cSrcweir //===== PresenterToolBar::Element =============================================
1345*cdf0e10cSrcweir 
1346*cdf0e10cSrcweir namespace {
1347*cdf0e10cSrcweir 
1348*cdf0e10cSrcweir Element::Element (
1349*cdf0e10cSrcweir     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
1350*cdf0e10cSrcweir     : ElementInterfaceBase(m_aMutex),
1351*cdf0e10cSrcweir       mpToolBar(rpToolBar),
1352*cdf0e10cSrcweir       maLocation(),
1353*cdf0e10cSrcweir       maSize(),
1354*cdf0e10cSrcweir       mpNormal(),
1355*cdf0e10cSrcweir       mpMouseOver(),
1356*cdf0e10cSrcweir       mpSelected(),
1357*cdf0e10cSrcweir       mpDisabled(),
1358*cdf0e10cSrcweir       mpMode(),
1359*cdf0e10cSrcweir       mbIsOver(false),
1360*cdf0e10cSrcweir       mbIsPressed(false),
1361*cdf0e10cSrcweir       mbIsSelected(false),
1362*cdf0e10cSrcweir       mbIsEnabled(true)
1363*cdf0e10cSrcweir {
1364*cdf0e10cSrcweir     if (mpToolBar.get() != NULL)
1365*cdf0e10cSrcweir     {
1366*cdf0e10cSrcweir         OSL_ASSERT(mpToolBar->GetPresenterController().is());
1367*cdf0e10cSrcweir         OSL_ASSERT(mpToolBar->GetPresenterController()->GetWindowManager().is());
1368*cdf0e10cSrcweir     }
1369*cdf0e10cSrcweir }
1370*cdf0e10cSrcweir 
1371*cdf0e10cSrcweir 
1372*cdf0e10cSrcweir 
1373*cdf0e10cSrcweir 
1374*cdf0e10cSrcweir Element::~Element (void)
1375*cdf0e10cSrcweir {
1376*cdf0e10cSrcweir }
1377*cdf0e10cSrcweir 
1378*cdf0e10cSrcweir 
1379*cdf0e10cSrcweir 
1380*cdf0e10cSrcweir 
1381*cdf0e10cSrcweir void Element::SetModes (
1382*cdf0e10cSrcweir     const SharedElementMode& rpNormalMode,
1383*cdf0e10cSrcweir     const SharedElementMode& rpMouseOverMode,
1384*cdf0e10cSrcweir     const SharedElementMode& rpSelectedMode,
1385*cdf0e10cSrcweir     const SharedElementMode& rpDisabledMode)
1386*cdf0e10cSrcweir {
1387*cdf0e10cSrcweir     mpNormal = rpNormalMode;
1388*cdf0e10cSrcweir     mpMouseOver = rpMouseOverMode;
1389*cdf0e10cSrcweir     mpSelected = rpSelectedMode;
1390*cdf0e10cSrcweir     mpDisabled = rpDisabledMode;
1391*cdf0e10cSrcweir     mpMode = rpNormalMode;
1392*cdf0e10cSrcweir }
1393*cdf0e10cSrcweir 
1394*cdf0e10cSrcweir 
1395*cdf0e10cSrcweir 
1396*cdf0e10cSrcweir 
1397*cdf0e10cSrcweir void Element::disposing (void)
1398*cdf0e10cSrcweir {
1399*cdf0e10cSrcweir }
1400*cdf0e10cSrcweir 
1401*cdf0e10cSrcweir 
1402*cdf0e10cSrcweir 
1403*cdf0e10cSrcweir 
1404*cdf0e10cSrcweir awt::Size Element::GetBoundingSize (
1405*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas)
1406*cdf0e10cSrcweir {
1407*cdf0e10cSrcweir     maSize = CreateBoundingSize(rxCanvas);
1408*cdf0e10cSrcweir     return maSize;
1409*cdf0e10cSrcweir }
1410*cdf0e10cSrcweir 
1411*cdf0e10cSrcweir 
1412*cdf0e10cSrcweir 
1413*cdf0e10cSrcweir 
1414*cdf0e10cSrcweir awt::Rectangle Element::GetBoundingBox (void) const
1415*cdf0e10cSrcweir {
1416*cdf0e10cSrcweir     return awt::Rectangle(maLocation.X,maLocation.Y, maSize.Width, maSize.Height);
1417*cdf0e10cSrcweir }
1418*cdf0e10cSrcweir 
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir 
1421*cdf0e10cSrcweir 
1422*cdf0e10cSrcweir void Element::CurrentSlideHasChanged (void)
1423*cdf0e10cSrcweir {
1424*cdf0e10cSrcweir     UpdateState();
1425*cdf0e10cSrcweir }
1426*cdf0e10cSrcweir 
1427*cdf0e10cSrcweir 
1428*cdf0e10cSrcweir 
1429*cdf0e10cSrcweir 
1430*cdf0e10cSrcweir void Element::SetLocation (const awt::Point& rLocation)
1431*cdf0e10cSrcweir {
1432*cdf0e10cSrcweir     maLocation = rLocation;
1433*cdf0e10cSrcweir }
1434*cdf0e10cSrcweir 
1435*cdf0e10cSrcweir 
1436*cdf0e10cSrcweir 
1437*cdf0e10cSrcweir void Element::SetSize (const geometry::RealSize2D& rSize)
1438*cdf0e10cSrcweir {
1439*cdf0e10cSrcweir     maSize = awt::Size(sal_Int32(0.5+rSize.Width), sal_Int32(0.5+rSize.Height));
1440*cdf0e10cSrcweir }
1441*cdf0e10cSrcweir 
1442*cdf0e10cSrcweir 
1443*cdf0e10cSrcweir 
1444*cdf0e10cSrcweir 
1445*cdf0e10cSrcweir bool Element::SetState (
1446*cdf0e10cSrcweir     const bool bIsOver,
1447*cdf0e10cSrcweir     const bool bIsPressed)
1448*cdf0e10cSrcweir {
1449*cdf0e10cSrcweir     bool bModified (mbIsOver != bIsOver || mbIsPressed != bIsPressed);
1450*cdf0e10cSrcweir     bool bClicked (mbIsPressed && bIsOver && ! bIsPressed);
1451*cdf0e10cSrcweir 
1452*cdf0e10cSrcweir     mbIsOver = bIsOver;
1453*cdf0e10cSrcweir     mbIsPressed = bIsPressed;
1454*cdf0e10cSrcweir 
1455*cdf0e10cSrcweir     // When the element is disabled then ignore mouse over or selection.
1456*cdf0e10cSrcweir     // When the element is selected then ignore mouse over.
1457*cdf0e10cSrcweir     if ( ! mbIsEnabled)
1458*cdf0e10cSrcweir         mpMode = mpDisabled;
1459*cdf0e10cSrcweir     else if (mbIsSelected)
1460*cdf0e10cSrcweir         mpMode = mpSelected;
1461*cdf0e10cSrcweir     else if (mbIsOver)
1462*cdf0e10cSrcweir         mpMode = mpMouseOver;
1463*cdf0e10cSrcweir     else
1464*cdf0e10cSrcweir         mpMode = mpNormal;
1465*cdf0e10cSrcweir 
1466*cdf0e10cSrcweir     if (bClicked && mbIsEnabled)
1467*cdf0e10cSrcweir     {
1468*cdf0e10cSrcweir         if (mpMode.get() != NULL)
1469*cdf0e10cSrcweir         {
1470*cdf0e10cSrcweir             do
1471*cdf0e10cSrcweir             {
1472*cdf0e10cSrcweir                 if (mpMode->msAction.getLength() <= 0)
1473*cdf0e10cSrcweir                     break;
1474*cdf0e10cSrcweir 
1475*cdf0e10cSrcweir                 if (mpToolBar.get() == NULL)
1476*cdf0e10cSrcweir                     break;
1477*cdf0e10cSrcweir 
1478*cdf0e10cSrcweir                 if (mpToolBar->GetPresenterController().get() == NULL)
1479*cdf0e10cSrcweir                     break;
1480*cdf0e10cSrcweir 
1481*cdf0e10cSrcweir                 mpToolBar->GetPresenterController()->DispatchUnoCommand(mpMode->msAction);
1482*cdf0e10cSrcweir                 mpToolBar->RequestLayout();
1483*cdf0e10cSrcweir             }
1484*cdf0e10cSrcweir             while (false);
1485*cdf0e10cSrcweir         }
1486*cdf0e10cSrcweir 
1487*cdf0e10cSrcweir     }
1488*cdf0e10cSrcweir     else if (bModified)
1489*cdf0e10cSrcweir     {
1490*cdf0e10cSrcweir         Invalidate();
1491*cdf0e10cSrcweir     }
1492*cdf0e10cSrcweir 
1493*cdf0e10cSrcweir     return bModified;
1494*cdf0e10cSrcweir }
1495*cdf0e10cSrcweir 
1496*cdf0e10cSrcweir 
1497*cdf0e10cSrcweir 
1498*cdf0e10cSrcweir 
1499*cdf0e10cSrcweir void Element::Invalidate (const bool bSynchronous)
1500*cdf0e10cSrcweir {
1501*cdf0e10cSrcweir     OSL_ASSERT(mpToolBar.is());
1502*cdf0e10cSrcweir     mpToolBar->InvalidateArea(GetBoundingBox(), bSynchronous);
1503*cdf0e10cSrcweir }
1504*cdf0e10cSrcweir 
1505*cdf0e10cSrcweir 
1506*cdf0e10cSrcweir 
1507*cdf0e10cSrcweir 
1508*cdf0e10cSrcweir bool Element::IsOutside (const awt::Rectangle& rBox)
1509*cdf0e10cSrcweir {
1510*cdf0e10cSrcweir     if (rBox.X >= maLocation.X+maSize.Width)
1511*cdf0e10cSrcweir         return true;
1512*cdf0e10cSrcweir     else if (rBox.Y >= maLocation.Y+maSize.Height)
1513*cdf0e10cSrcweir         return true;
1514*cdf0e10cSrcweir     else if (maLocation.X >= rBox.X+rBox.Width)
1515*cdf0e10cSrcweir         return true;
1516*cdf0e10cSrcweir     else if (maLocation.Y >= rBox.Y+rBox.Height)
1517*cdf0e10cSrcweir         return true;
1518*cdf0e10cSrcweir     else
1519*cdf0e10cSrcweir         return false;
1520*cdf0e10cSrcweir }
1521*cdf0e10cSrcweir 
1522*cdf0e10cSrcweir 
1523*cdf0e10cSrcweir 
1524*cdf0e10cSrcweir bool Element::IsEnabled (void) const
1525*cdf0e10cSrcweir {
1526*cdf0e10cSrcweir     return mbIsEnabled;
1527*cdf0e10cSrcweir }
1528*cdf0e10cSrcweir 
1529*cdf0e10cSrcweir 
1530*cdf0e10cSrcweir 
1531*cdf0e10cSrcweir 
1532*cdf0e10cSrcweir void Element::SetEnabledState (const bool bIsEnabled)
1533*cdf0e10cSrcweir {
1534*cdf0e10cSrcweir     mbIsEnabled = bIsEnabled;
1535*cdf0e10cSrcweir }
1536*cdf0e10cSrcweir 
1537*cdf0e10cSrcweir 
1538*cdf0e10cSrcweir 
1539*cdf0e10cSrcweir 
1540*cdf0e10cSrcweir bool Element::IsFilling (void) const
1541*cdf0e10cSrcweir {
1542*cdf0e10cSrcweir     return false;
1543*cdf0e10cSrcweir }
1544*cdf0e10cSrcweir 
1545*cdf0e10cSrcweir 
1546*cdf0e10cSrcweir 
1547*cdf0e10cSrcweir 
1548*cdf0e10cSrcweir void Element::UpdateState (void)
1549*cdf0e10cSrcweir {
1550*cdf0e10cSrcweir     OSL_ASSERT(mpToolBar.get() != NULL);
1551*cdf0e10cSrcweir     OSL_ASSERT(mpToolBar->GetPresenterController().get() != NULL);
1552*cdf0e10cSrcweir 
1553*cdf0e10cSrcweir     if (mpMode.get() == NULL)
1554*cdf0e10cSrcweir         return;
1555*cdf0e10cSrcweir 
1556*cdf0e10cSrcweir     util::URL aURL (mpToolBar->GetPresenterController()->CreateURLFromString(mpMode->msAction));
1557*cdf0e10cSrcweir     Reference<frame::XDispatch> xDispatch (mpToolBar->GetPresenterController()->GetDispatch(aURL));
1558*cdf0e10cSrcweir     if (xDispatch.is())
1559*cdf0e10cSrcweir     {
1560*cdf0e10cSrcweir         xDispatch->addStatusListener(this, aURL);
1561*cdf0e10cSrcweir         xDispatch->removeStatusListener(this, aURL);
1562*cdf0e10cSrcweir     }
1563*cdf0e10cSrcweir }
1564*cdf0e10cSrcweir 
1565*cdf0e10cSrcweir 
1566*cdf0e10cSrcweir 
1567*cdf0e10cSrcweir 
1568*cdf0e10cSrcweir //----- lang::XEventListener --------------------------------------------------
1569*cdf0e10cSrcweir 
1570*cdf0e10cSrcweir void SAL_CALL Element::disposing (const css::lang::EventObject& rEvent)
1571*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
1572*cdf0e10cSrcweir {
1573*cdf0e10cSrcweir     (void)rEvent;
1574*cdf0e10cSrcweir }
1575*cdf0e10cSrcweir 
1576*cdf0e10cSrcweir 
1577*cdf0e10cSrcweir 
1578*cdf0e10cSrcweir 
1579*cdf0e10cSrcweir //----- document::XEventListener ----------------------------------------------
1580*cdf0e10cSrcweir 
1581*cdf0e10cSrcweir void SAL_CALL Element::notifyEvent (const css::document::EventObject& rEvent)
1582*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
1583*cdf0e10cSrcweir {
1584*cdf0e10cSrcweir     (void)rEvent;
1585*cdf0e10cSrcweir     UpdateState();
1586*cdf0e10cSrcweir }
1587*cdf0e10cSrcweir 
1588*cdf0e10cSrcweir 
1589*cdf0e10cSrcweir 
1590*cdf0e10cSrcweir 
1591*cdf0e10cSrcweir //----- frame::XStatusListener ------------------------------------------------
1592*cdf0e10cSrcweir 
1593*cdf0e10cSrcweir void SAL_CALL Element::statusChanged (const css::frame::FeatureStateEvent& rEvent)
1594*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
1595*cdf0e10cSrcweir {
1596*cdf0e10cSrcweir     bool bIsSelected (mbIsSelected);
1597*cdf0e10cSrcweir     bool bIsEnabled (rEvent.IsEnabled);
1598*cdf0e10cSrcweir     rEvent.State >>= bIsSelected;
1599*cdf0e10cSrcweir 
1600*cdf0e10cSrcweir     if (bIsSelected != mbIsSelected || bIsEnabled != mbIsEnabled)
1601*cdf0e10cSrcweir     {
1602*cdf0e10cSrcweir         mbIsEnabled = bIsEnabled;
1603*cdf0e10cSrcweir         mbIsSelected = bIsSelected;
1604*cdf0e10cSrcweir         SetState(mbIsOver, mbIsPressed);
1605*cdf0e10cSrcweir         mpToolBar->RequestLayout();
1606*cdf0e10cSrcweir     }
1607*cdf0e10cSrcweir }
1608*cdf0e10cSrcweir 
1609*cdf0e10cSrcweir } // end of anonymous namespace
1610*cdf0e10cSrcweir 
1611*cdf0e10cSrcweir 
1612*cdf0e10cSrcweir 
1613*cdf0e10cSrcweir 
1614*cdf0e10cSrcweir //===== ElementMode ===========================================================
1615*cdf0e10cSrcweir 
1616*cdf0e10cSrcweir namespace {
1617*cdf0e10cSrcweir 
1618*cdf0e10cSrcweir ElementMode::ElementMode (void)
1619*cdf0e10cSrcweir     : mpIcon(),
1620*cdf0e10cSrcweir       msAction(),
1621*cdf0e10cSrcweir       maText()
1622*cdf0e10cSrcweir {
1623*cdf0e10cSrcweir }
1624*cdf0e10cSrcweir 
1625*cdf0e10cSrcweir 
1626*cdf0e10cSrcweir 
1627*cdf0e10cSrcweir 
1628*cdf0e10cSrcweir void ElementMode::ReadElementMode (
1629*cdf0e10cSrcweir     const Reference<beans::XPropertySet>& rxElementProperties,
1630*cdf0e10cSrcweir     const OUString& rsModeName,
1631*cdf0e10cSrcweir     ::boost::shared_ptr<ElementMode>& rpDefaultMode,
1632*cdf0e10cSrcweir     ::sdext::presenter::PresenterToolBar::Context& rContext)
1633*cdf0e10cSrcweir {
1634*cdf0e10cSrcweir     try
1635*cdf0e10cSrcweir     {
1636*cdf0e10cSrcweir     Reference<container::XHierarchicalNameAccess> xNode (
1637*cdf0e10cSrcweir         PresenterConfigurationAccess::GetProperty(rxElementProperties, rsModeName),
1638*cdf0e10cSrcweir         UNO_QUERY);
1639*cdf0e10cSrcweir     Reference<beans::XPropertySet> xProperties (
1640*cdf0e10cSrcweir         PresenterConfigurationAccess::GetNodeProperties(xNode, OUString()));
1641*cdf0e10cSrcweir     if ( ! xProperties.is() && rpDefaultMode.get()!=NULL)
1642*cdf0e10cSrcweir     {
1643*cdf0e10cSrcweir         // The mode is not specified.  Use the given, possibly empty,
1644*cdf0e10cSrcweir         // default mode instead.
1645*cdf0e10cSrcweir         mpIcon = rpDefaultMode->mpIcon;
1646*cdf0e10cSrcweir         msAction = rpDefaultMode->msAction;
1647*cdf0e10cSrcweir         maText = rpDefaultMode->maText;
1648*cdf0e10cSrcweir     }
1649*cdf0e10cSrcweir 
1650*cdf0e10cSrcweir     // Read action.
1651*cdf0e10cSrcweir     if ( ! (PresenterConfigurationAccess::GetProperty(xProperties, A2S("Action")) >>= msAction))
1652*cdf0e10cSrcweir         if (rpDefaultMode.get()!=NULL)
1653*cdf0e10cSrcweir             msAction = rpDefaultMode->msAction;
1654*cdf0e10cSrcweir 
1655*cdf0e10cSrcweir     // Read text and font
1656*cdf0e10cSrcweir     OUString sText (rpDefaultMode.get()!=NULL ? rpDefaultMode->maText.GetText() : OUString());
1657*cdf0e10cSrcweir     PresenterConfigurationAccess::GetProperty(xProperties, A2S("Text")) >>= sText;
1658*cdf0e10cSrcweir     Reference<container::XHierarchicalNameAccess> xFontNode (
1659*cdf0e10cSrcweir         PresenterConfigurationAccess::GetProperty(xProperties, A2S("Font")), UNO_QUERY);
1660*cdf0e10cSrcweir     PresenterTheme::SharedFontDescriptor pFont (PresenterTheme::ReadFont(
1661*cdf0e10cSrcweir         xFontNode,
1662*cdf0e10cSrcweir         A2S(""),
1663*cdf0e10cSrcweir         rpDefaultMode.get()!=NULL
1664*cdf0e10cSrcweir             ? rpDefaultMode->maText.GetFont()
1665*cdf0e10cSrcweir             : PresenterTheme::SharedFontDescriptor()));
1666*cdf0e10cSrcweir     maText = Text(sText,pFont);
1667*cdf0e10cSrcweir 
1668*cdf0e10cSrcweir     // Read bitmaps to display as icons.
1669*cdf0e10cSrcweir     Reference<container::XHierarchicalNameAccess> xIconNode (
1670*cdf0e10cSrcweir         PresenterConfigurationAccess::GetProperty(xProperties, A2S("Icon")), UNO_QUERY);
1671*cdf0e10cSrcweir     mpIcon = PresenterBitmapContainer::LoadBitmap(
1672*cdf0e10cSrcweir         xIconNode,
1673*cdf0e10cSrcweir         A2S(""),
1674*cdf0e10cSrcweir         rContext.mxPresenterHelper,
1675*cdf0e10cSrcweir         rContext.msBasePath,
1676*cdf0e10cSrcweir         rContext.mxCanvas,
1677*cdf0e10cSrcweir         rpDefaultMode.get()!=NULL ? rpDefaultMode->mpIcon : SharedBitmapDescriptor());
1678*cdf0e10cSrcweir     }
1679*cdf0e10cSrcweir     catch(Exception&)
1680*cdf0e10cSrcweir     {
1681*cdf0e10cSrcweir         OSL_ASSERT(false);
1682*cdf0e10cSrcweir     }
1683*cdf0e10cSrcweir }
1684*cdf0e10cSrcweir 
1685*cdf0e10cSrcweir } // end of anonymous namespace
1686*cdf0e10cSrcweir 
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir 
1689*cdf0e10cSrcweir 
1690*cdf0e10cSrcweir //===== Button ================================================================
1691*cdf0e10cSrcweir 
1692*cdf0e10cSrcweir namespace {
1693*cdf0e10cSrcweir 
1694*cdf0e10cSrcweir ::rtl::Reference<Element> Button::Create (
1695*cdf0e10cSrcweir     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
1696*cdf0e10cSrcweir {
1697*cdf0e10cSrcweir     ::rtl::Reference<Button> pElement (new Button(rpToolBar));
1698*cdf0e10cSrcweir     pElement->Initialize();
1699*cdf0e10cSrcweir     return ::rtl::Reference<Element>(pElement.get());
1700*cdf0e10cSrcweir }
1701*cdf0e10cSrcweir 
1702*cdf0e10cSrcweir 
1703*cdf0e10cSrcweir 
1704*cdf0e10cSrcweir 
1705*cdf0e10cSrcweir Button::Button (
1706*cdf0e10cSrcweir     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
1707*cdf0e10cSrcweir     : Element(rpToolBar),
1708*cdf0e10cSrcweir       mbIsListenerRegistered(false)
1709*cdf0e10cSrcweir {
1710*cdf0e10cSrcweir     OSL_ASSERT(mpToolBar.get() != NULL);
1711*cdf0e10cSrcweir     OSL_ASSERT(mpToolBar->GetPresenterController().is());
1712*cdf0e10cSrcweir     OSL_ASSERT(mpToolBar->GetPresenterController()->GetWindowManager().is());
1713*cdf0e10cSrcweir }
1714*cdf0e10cSrcweir 
1715*cdf0e10cSrcweir 
1716*cdf0e10cSrcweir 
1717*cdf0e10cSrcweir 
1718*cdf0e10cSrcweir Button::~Button (void)
1719*cdf0e10cSrcweir {
1720*cdf0e10cSrcweir }
1721*cdf0e10cSrcweir 
1722*cdf0e10cSrcweir 
1723*cdf0e10cSrcweir 
1724*cdf0e10cSrcweir 
1725*cdf0e10cSrcweir void Button::Initialize (void)
1726*cdf0e10cSrcweir {
1727*cdf0e10cSrcweir     mpToolBar->GetPresenterController()->GetWindowManager()->AddLayoutListener(this);
1728*cdf0e10cSrcweir     mbIsListenerRegistered = true;
1729*cdf0e10cSrcweir }
1730*cdf0e10cSrcweir 
1731*cdf0e10cSrcweir 
1732*cdf0e10cSrcweir 
1733*cdf0e10cSrcweir 
1734*cdf0e10cSrcweir void Button::disposing (void)
1735*cdf0e10cSrcweir {
1736*cdf0e10cSrcweir     OSL_ASSERT(mpToolBar.get() != NULL);
1737*cdf0e10cSrcweir     if (mpToolBar.get() != NULL
1738*cdf0e10cSrcweir         && mbIsListenerRegistered)
1739*cdf0e10cSrcweir     {
1740*cdf0e10cSrcweir         OSL_ASSERT(mpToolBar->GetPresenterController().is());
1741*cdf0e10cSrcweir         OSL_ASSERT(mpToolBar->GetPresenterController()->GetWindowManager().is());
1742*cdf0e10cSrcweir 
1743*cdf0e10cSrcweir         mbIsListenerRegistered = false;
1744*cdf0e10cSrcweir         mpToolBar->GetPresenterController()->GetWindowManager()->RemoveLayoutListener(this);
1745*cdf0e10cSrcweir     }
1746*cdf0e10cSrcweir     Element::disposing();
1747*cdf0e10cSrcweir }
1748*cdf0e10cSrcweir 
1749*cdf0e10cSrcweir 
1750*cdf0e10cSrcweir 
1751*cdf0e10cSrcweir 
1752*cdf0e10cSrcweir void Button::Paint (
1753*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas,
1754*cdf0e10cSrcweir     const rendering::ViewState& rViewState)
1755*cdf0e10cSrcweir {
1756*cdf0e10cSrcweir     OSL_ASSERT(rxCanvas.is());
1757*cdf0e10cSrcweir 
1758*cdf0e10cSrcweir     if (mpMode.get() == NULL)
1759*cdf0e10cSrcweir         return;
1760*cdf0e10cSrcweir 
1761*cdf0e10cSrcweir     if (mpMode->mpIcon.get() == NULL)
1762*cdf0e10cSrcweir         return;
1763*cdf0e10cSrcweir 
1764*cdf0e10cSrcweir     geometry::RealRectangle2D aTextBBox (mpMode->maText.GetBoundingBox(rxCanvas));
1765*cdf0e10cSrcweir     sal_Int32 nTextHeight (sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.Y2 - aTextBBox.Y1));
1766*cdf0e10cSrcweir 
1767*cdf0e10cSrcweir     PaintIcon(rxCanvas, nTextHeight, rViewState);
1768*cdf0e10cSrcweir     awt::Point aOffset(0,0);
1769*cdf0e10cSrcweir     if ( ! IsEnabled())
1770*cdf0e10cSrcweir         if (mpMode->mpIcon.get() != NULL)
1771*cdf0e10cSrcweir         {
1772*cdf0e10cSrcweir             Reference<rendering::XBitmap> xBitmap (mpMode->mpIcon->GetNormalBitmap());
1773*cdf0e10cSrcweir             if (xBitmap.is())
1774*cdf0e10cSrcweir                 aOffset.Y = xBitmap->getSize().Height;
1775*cdf0e10cSrcweir         }
1776*cdf0e10cSrcweir     mpMode->maText.Paint(rxCanvas, rViewState, GetBoundingBox(), aOffset);
1777*cdf0e10cSrcweir }
1778*cdf0e10cSrcweir 
1779*cdf0e10cSrcweir 
1780*cdf0e10cSrcweir 
1781*cdf0e10cSrcweir 
1782*cdf0e10cSrcweir awt::Size Button::CreateBoundingSize (
1783*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas)
1784*cdf0e10cSrcweir {
1785*cdf0e10cSrcweir     if (mpMode.get() == NULL)
1786*cdf0e10cSrcweir         return awt::Size();
1787*cdf0e10cSrcweir 
1788*cdf0e10cSrcweir     geometry::RealRectangle2D aTextBBox (mpMode->maText.GetBoundingBox(rxCanvas));
1789*cdf0e10cSrcweir     const sal_Int32 nGap (5);
1790*cdf0e10cSrcweir     sal_Int32 nTextHeight (sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.Y2 - aTextBBox.Y1));
1791*cdf0e10cSrcweir     sal_Int32 nTextWidth (sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.X2 - aTextBBox.X1));
1792*cdf0e10cSrcweir     Reference<rendering::XBitmap> xBitmap;
1793*cdf0e10cSrcweir     if (mpMode->mpIcon.get() != NULL)
1794*cdf0e10cSrcweir         xBitmap = mpMode->mpIcon->GetNormalBitmap();
1795*cdf0e10cSrcweir     if (xBitmap.is())
1796*cdf0e10cSrcweir     {
1797*cdf0e10cSrcweir         geometry::IntegerSize2D aSize (xBitmap->getSize());
1798*cdf0e10cSrcweir         return awt::Size(
1799*cdf0e10cSrcweir             ::std::max(aSize.Width, sal_Int32(0.5 + aTextBBox.X2 - aTextBBox.X1)),
1800*cdf0e10cSrcweir             aSize.Height+ nGap + nTextHeight);
1801*cdf0e10cSrcweir     }
1802*cdf0e10cSrcweir     else
1803*cdf0e10cSrcweir         return awt::Size(nTextWidth,nTextHeight);
1804*cdf0e10cSrcweir }
1805*cdf0e10cSrcweir 
1806*cdf0e10cSrcweir 
1807*cdf0e10cSrcweir 
1808*cdf0e10cSrcweir 
1809*cdf0e10cSrcweir void Button::PaintIcon (
1810*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas,
1811*cdf0e10cSrcweir     const sal_Int32 nTextHeight,
1812*cdf0e10cSrcweir     const rendering::ViewState& rViewState)
1813*cdf0e10cSrcweir {
1814*cdf0e10cSrcweir     if (mpMode.get() == NULL)
1815*cdf0e10cSrcweir         return;
1816*cdf0e10cSrcweir 
1817*cdf0e10cSrcweir     Reference<rendering::XBitmap> xBitmap (mpMode->mpIcon->GetBitmap(GetMode()));
1818*cdf0e10cSrcweir     if (xBitmap.is())
1819*cdf0e10cSrcweir     {
1820*cdf0e10cSrcweir         const sal_Int32 nX (maLocation.X
1821*cdf0e10cSrcweir             + (maSize.Width-xBitmap->getSize().Width) / 2);
1822*cdf0e10cSrcweir         const sal_Int32 nY (maLocation.Y
1823*cdf0e10cSrcweir             + (maSize.Height - nTextHeight - xBitmap->getSize().Height) / 2);
1824*cdf0e10cSrcweir         const rendering::RenderState aRenderState(
1825*cdf0e10cSrcweir             geometry::AffineMatrix2D(1,0,nX, 0,1,nY),
1826*cdf0e10cSrcweir             NULL,
1827*cdf0e10cSrcweir             Sequence<double>(4),
1828*cdf0e10cSrcweir             rendering::CompositeOperation::OVER);
1829*cdf0e10cSrcweir         rxCanvas->drawBitmap(xBitmap, rViewState, aRenderState);
1830*cdf0e10cSrcweir     }
1831*cdf0e10cSrcweir }
1832*cdf0e10cSrcweir 
1833*cdf0e10cSrcweir 
1834*cdf0e10cSrcweir 
1835*cdf0e10cSrcweir 
1836*cdf0e10cSrcweir PresenterBitmapDescriptor::Mode Button::GetMode (void) const
1837*cdf0e10cSrcweir {
1838*cdf0e10cSrcweir     if ( ! IsEnabled())
1839*cdf0e10cSrcweir         return PresenterBitmapDescriptor::Disabled;
1840*cdf0e10cSrcweir     else if (mbIsPressed)
1841*cdf0e10cSrcweir         return PresenterBitmapDescriptor::ButtonDown;
1842*cdf0e10cSrcweir     else if (mbIsOver)
1843*cdf0e10cSrcweir         return PresenterBitmapDescriptor::MouseOver;
1844*cdf0e10cSrcweir     else
1845*cdf0e10cSrcweir         return PresenterBitmapDescriptor::Normal;
1846*cdf0e10cSrcweir }
1847*cdf0e10cSrcweir 
1848*cdf0e10cSrcweir 
1849*cdf0e10cSrcweir 
1850*cdf0e10cSrcweir 
1851*cdf0e10cSrcweir //----- lang::XEventListener --------------------------------------------------
1852*cdf0e10cSrcweir 
1853*cdf0e10cSrcweir void SAL_CALL Button::disposing (const css::lang::EventObject& rEvent)
1854*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
1855*cdf0e10cSrcweir {
1856*cdf0e10cSrcweir     (void)rEvent;
1857*cdf0e10cSrcweir     mbIsListenerRegistered = false;
1858*cdf0e10cSrcweir     Element::disposing(rEvent);
1859*cdf0e10cSrcweir }
1860*cdf0e10cSrcweir 
1861*cdf0e10cSrcweir } // end of anonymous namespace
1862*cdf0e10cSrcweir 
1863*cdf0e10cSrcweir 
1864*cdf0e10cSrcweir 
1865*cdf0e10cSrcweir 
1866*cdf0e10cSrcweir //===== PresenterToolBar::Label ===============================================
1867*cdf0e10cSrcweir 
1868*cdf0e10cSrcweir namespace {
1869*cdf0e10cSrcweir 
1870*cdf0e10cSrcweir Label::Label (const ::rtl::Reference<PresenterToolBar>& rpToolBar)
1871*cdf0e10cSrcweir     : Element(rpToolBar)
1872*cdf0e10cSrcweir {
1873*cdf0e10cSrcweir }
1874*cdf0e10cSrcweir 
1875*cdf0e10cSrcweir 
1876*cdf0e10cSrcweir 
1877*cdf0e10cSrcweir 
1878*cdf0e10cSrcweir awt::Size Label::CreateBoundingSize (
1879*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas)
1880*cdf0e10cSrcweir {
1881*cdf0e10cSrcweir     if (mpMode.get() == NULL)
1882*cdf0e10cSrcweir         return awt::Size(0,0);
1883*cdf0e10cSrcweir 
1884*cdf0e10cSrcweir     geometry::RealRectangle2D aTextBBox (mpMode->maText.GetBoundingBox(rxCanvas));
1885*cdf0e10cSrcweir     return awt::Size(
1886*cdf0e10cSrcweir         sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.X2 - aTextBBox.X1),
1887*cdf0e10cSrcweir         sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.Y2 - aTextBBox.Y1));
1888*cdf0e10cSrcweir }
1889*cdf0e10cSrcweir 
1890*cdf0e10cSrcweir 
1891*cdf0e10cSrcweir 
1892*cdf0e10cSrcweir 
1893*cdf0e10cSrcweir 
1894*cdf0e10cSrcweir void Label::SetText (const OUString& rsText)
1895*cdf0e10cSrcweir {
1896*cdf0e10cSrcweir     OSL_ASSERT(mpToolBar.get() != NULL);
1897*cdf0e10cSrcweir     if (mpMode.get() == NULL)
1898*cdf0e10cSrcweir         return;
1899*cdf0e10cSrcweir 
1900*cdf0e10cSrcweir     const bool bRequestLayout (mpMode->maText.GetText().getLength() != rsText.getLength());
1901*cdf0e10cSrcweir 
1902*cdf0e10cSrcweir     mpMode->maText.SetText(rsText);
1903*cdf0e10cSrcweir     // Just use the character count for determing whether a layout is
1904*cdf0e10cSrcweir     // necessary.  This is an optimization to avoid layouts every time a new
1905*cdf0e10cSrcweir     // time value is set on some labels.
1906*cdf0e10cSrcweir     if (bRequestLayout)
1907*cdf0e10cSrcweir         mpToolBar->RequestLayout();
1908*cdf0e10cSrcweir     else
1909*cdf0e10cSrcweir         Invalidate(false);
1910*cdf0e10cSrcweir }
1911*cdf0e10cSrcweir 
1912*cdf0e10cSrcweir 
1913*cdf0e10cSrcweir 
1914*cdf0e10cSrcweir 
1915*cdf0e10cSrcweir void Label::Paint (
1916*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas,
1917*cdf0e10cSrcweir     const rendering::ViewState& rViewState)
1918*cdf0e10cSrcweir {
1919*cdf0e10cSrcweir     OSL_ASSERT(rxCanvas.is());
1920*cdf0e10cSrcweir     if (mpMode.get() == NULL)
1921*cdf0e10cSrcweir         return;
1922*cdf0e10cSrcweir 
1923*cdf0e10cSrcweir     mpMode->maText.Paint(rxCanvas, rViewState, GetBoundingBox(), awt::Point(0,0));
1924*cdf0e10cSrcweir }
1925*cdf0e10cSrcweir 
1926*cdf0e10cSrcweir 
1927*cdf0e10cSrcweir 
1928*cdf0e10cSrcweir 
1929*cdf0e10cSrcweir bool Label::SetState (const bool bIsOver, const bool bIsPressed)
1930*cdf0e10cSrcweir {
1931*cdf0e10cSrcweir     // For labels there is no mouse over effect.
1932*cdf0e10cSrcweir     (void)bIsOver;
1933*cdf0e10cSrcweir     (void)bIsPressed;
1934*cdf0e10cSrcweir     return Element::SetState(false, false);
1935*cdf0e10cSrcweir }
1936*cdf0e10cSrcweir 
1937*cdf0e10cSrcweir } // end of anonymous namespace
1938*cdf0e10cSrcweir 
1939*cdf0e10cSrcweir 
1940*cdf0e10cSrcweir 
1941*cdf0e10cSrcweir 
1942*cdf0e10cSrcweir //===== Text ==================================================================
1943*cdf0e10cSrcweir 
1944*cdf0e10cSrcweir namespace {
1945*cdf0e10cSrcweir 
1946*cdf0e10cSrcweir Text::Text (void)
1947*cdf0e10cSrcweir     : msText(),
1948*cdf0e10cSrcweir       mpFont()
1949*cdf0e10cSrcweir {
1950*cdf0e10cSrcweir }
1951*cdf0e10cSrcweir 
1952*cdf0e10cSrcweir 
1953*cdf0e10cSrcweir 
1954*cdf0e10cSrcweir 
1955*cdf0e10cSrcweir Text::Text (const Text& rText)
1956*cdf0e10cSrcweir     : msText(rText.msText),
1957*cdf0e10cSrcweir       mpFont(rText.mpFont)
1958*cdf0e10cSrcweir {
1959*cdf0e10cSrcweir }
1960*cdf0e10cSrcweir 
1961*cdf0e10cSrcweir 
1962*cdf0e10cSrcweir 
1963*cdf0e10cSrcweir 
1964*cdf0e10cSrcweir Text::Text (
1965*cdf0e10cSrcweir     const OUString& rsText,
1966*cdf0e10cSrcweir     const PresenterTheme::SharedFontDescriptor& rpFont)
1967*cdf0e10cSrcweir     : msText(rsText),
1968*cdf0e10cSrcweir       mpFont(rpFont)
1969*cdf0e10cSrcweir {
1970*cdf0e10cSrcweir }
1971*cdf0e10cSrcweir 
1972*cdf0e10cSrcweir 
1973*cdf0e10cSrcweir 
1974*cdf0e10cSrcweir 
1975*cdf0e10cSrcweir void Text::SetText (const OUString& rsText)
1976*cdf0e10cSrcweir {
1977*cdf0e10cSrcweir     msText = rsText;
1978*cdf0e10cSrcweir }
1979*cdf0e10cSrcweir 
1980*cdf0e10cSrcweir 
1981*cdf0e10cSrcweir 
1982*cdf0e10cSrcweir 
1983*cdf0e10cSrcweir OUString Text::GetText (void) const
1984*cdf0e10cSrcweir {
1985*cdf0e10cSrcweir     return msText;
1986*cdf0e10cSrcweir }
1987*cdf0e10cSrcweir 
1988*cdf0e10cSrcweir 
1989*cdf0e10cSrcweir 
1990*cdf0e10cSrcweir 
1991*cdf0e10cSrcweir PresenterTheme::SharedFontDescriptor Text::GetFont (void) const
1992*cdf0e10cSrcweir {
1993*cdf0e10cSrcweir     return mpFont;
1994*cdf0e10cSrcweir }
1995*cdf0e10cSrcweir 
1996*cdf0e10cSrcweir 
1997*cdf0e10cSrcweir 
1998*cdf0e10cSrcweir 
1999*cdf0e10cSrcweir void Text::Paint (
2000*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas,
2001*cdf0e10cSrcweir     const rendering::ViewState& rViewState,
2002*cdf0e10cSrcweir     const awt::Rectangle& rBoundingBox,
2003*cdf0e10cSrcweir     const awt::Point& rOffset)
2004*cdf0e10cSrcweir {
2005*cdf0e10cSrcweir     (void)rOffset;
2006*cdf0e10cSrcweir     OSL_ASSERT(rxCanvas.is());
2007*cdf0e10cSrcweir 
2008*cdf0e10cSrcweir     if (msText.getLength() <= 0)
2009*cdf0e10cSrcweir         return;
2010*cdf0e10cSrcweir     if (mpFont.get() == NULL)
2011*cdf0e10cSrcweir         return;
2012*cdf0e10cSrcweir 
2013*cdf0e10cSrcweir     if ( ! mpFont->mxFont.is())
2014*cdf0e10cSrcweir         mpFont->PrepareFont(rxCanvas);
2015*cdf0e10cSrcweir     if ( ! mpFont->mxFont.is())
2016*cdf0e10cSrcweir         return;
2017*cdf0e10cSrcweir 
2018*cdf0e10cSrcweir     rendering::StringContext aContext (msText, 0, msText.getLength());
2019*cdf0e10cSrcweir 
2020*cdf0e10cSrcweir     Reference<rendering::XTextLayout> xLayout (
2021*cdf0e10cSrcweir         mpFont->mxFont->createTextLayout(
2022*cdf0e10cSrcweir             aContext,
2023*cdf0e10cSrcweir             rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
2024*cdf0e10cSrcweir             0));
2025*cdf0e10cSrcweir 
2026*cdf0e10cSrcweir     geometry::RealRectangle2D aBox (xLayout->queryTextBounds());
2027*cdf0e10cSrcweir     const double nTextWidth = aBox.X2 - aBox.X1;
2028*cdf0e10cSrcweir     const double nY = rBoundingBox.Y + rBoundingBox.Height - aBox.Y2;
2029*cdf0e10cSrcweir     const double nX = rBoundingBox.X + (rBoundingBox.Width - nTextWidth)/2;
2030*cdf0e10cSrcweir 
2031*cdf0e10cSrcweir     rendering::RenderState aRenderState(
2032*cdf0e10cSrcweir         geometry::AffineMatrix2D(1,0,nX, 0,1,nY),
2033*cdf0e10cSrcweir         NULL,
2034*cdf0e10cSrcweir         Sequence<double>(4),
2035*cdf0e10cSrcweir         rendering::CompositeOperation::SOURCE);
2036*cdf0e10cSrcweir     PresenterCanvasHelper::SetDeviceColor(aRenderState, mpFont->mnColor);
2037*cdf0e10cSrcweir 
2038*cdf0e10cSrcweir     rxCanvas->drawText(
2039*cdf0e10cSrcweir         aContext,
2040*cdf0e10cSrcweir         mpFont->mxFont,
2041*cdf0e10cSrcweir         rViewState,
2042*cdf0e10cSrcweir         aRenderState,
2043*cdf0e10cSrcweir         rendering::TextDirection::WEAK_LEFT_TO_RIGHT);
2044*cdf0e10cSrcweir }
2045*cdf0e10cSrcweir 
2046*cdf0e10cSrcweir 
2047*cdf0e10cSrcweir 
2048*cdf0e10cSrcweir 
2049*cdf0e10cSrcweir geometry::RealRectangle2D Text::GetBoundingBox (const Reference<rendering::XCanvas>& rxCanvas)
2050*cdf0e10cSrcweir {
2051*cdf0e10cSrcweir     if (mpFont.get() != NULL && msText.getLength() > 0)
2052*cdf0e10cSrcweir     {
2053*cdf0e10cSrcweir         if ( ! mpFont->mxFont.is())
2054*cdf0e10cSrcweir             mpFont->PrepareFont(rxCanvas);
2055*cdf0e10cSrcweir         if (mpFont->mxFont.is())
2056*cdf0e10cSrcweir         {
2057*cdf0e10cSrcweir             rendering::StringContext aContext (msText, 0, msText.getLength());
2058*cdf0e10cSrcweir             Reference<rendering::XTextLayout> xLayout (
2059*cdf0e10cSrcweir                 mpFont->mxFont->createTextLayout(
2060*cdf0e10cSrcweir                     aContext,
2061*cdf0e10cSrcweir                     rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
2062*cdf0e10cSrcweir                     0));
2063*cdf0e10cSrcweir             return xLayout->queryTextBounds();
2064*cdf0e10cSrcweir         }
2065*cdf0e10cSrcweir     }
2066*cdf0e10cSrcweir     return geometry::RealRectangle2D(0,0,0,0);
2067*cdf0e10cSrcweir }
2068*cdf0e10cSrcweir 
2069*cdf0e10cSrcweir 
2070*cdf0e10cSrcweir 
2071*cdf0e10cSrcweir 
2072*cdf0e10cSrcweir //===== ProgressLabel =========================================================
2073*cdf0e10cSrcweir 
2074*cdf0e10cSrcweir ProgressLabel::ProgressLabel (const ::rtl::Reference<PresenterToolBar>& rpToolBar)
2075*cdf0e10cSrcweir     : Label(rpToolBar)
2076*cdf0e10cSrcweir {
2077*cdf0e10cSrcweir     SetText(A2S("-/-"));
2078*cdf0e10cSrcweir }
2079*cdf0e10cSrcweir 
2080*cdf0e10cSrcweir 
2081*cdf0e10cSrcweir 
2082*cdf0e10cSrcweir 
2083*cdf0e10cSrcweir void ProgressLabel::CurrentSlideHasChanged (void)
2084*cdf0e10cSrcweir {
2085*cdf0e10cSrcweir     Label::CurrentSlideHasChanged();
2086*cdf0e10cSrcweir     OSL_ASSERT(mpToolBar.is());
2087*cdf0e10cSrcweir     try
2088*cdf0e10cSrcweir     {
2089*cdf0e10cSrcweir         const sal_Int32 nCurrentSlideIndex (mpToolBar->GetCurrentSlideIndex() + 1);
2090*cdf0e10cSrcweir         const sal_Int32 nSlideCount (mpToolBar->GetSlideCount());
2091*cdf0e10cSrcweir         if (nCurrentSlideIndex >= 0 && nSlideCount > 0)
2092*cdf0e10cSrcweir             SetText(
2093*cdf0e10cSrcweir                 OUString::valueOf(nCurrentSlideIndex)
2094*cdf0e10cSrcweir                     + OUString::createFromAscii(" / ")
2095*cdf0e10cSrcweir                         + OUString::valueOf(nSlideCount));
2096*cdf0e10cSrcweir         else
2097*cdf0e10cSrcweir             SetText(A2S(""));
2098*cdf0e10cSrcweir         Invalidate();
2099*cdf0e10cSrcweir     }
2100*cdf0e10cSrcweir     catch (RuntimeException&)
2101*cdf0e10cSrcweir     {
2102*cdf0e10cSrcweir     }
2103*cdf0e10cSrcweir }
2104*cdf0e10cSrcweir 
2105*cdf0e10cSrcweir 
2106*cdf0e10cSrcweir 
2107*cdf0e10cSrcweir 
2108*cdf0e10cSrcweir //===== TimeFormatter =========================================================
2109*cdf0e10cSrcweir 
2110*cdf0e10cSrcweir TimeFormatter::TimeFormatter (void)
2111*cdf0e10cSrcweir     : mbIs24HourFormat(true),
2112*cdf0e10cSrcweir       mbIsAmPmFormat(false),
2113*cdf0e10cSrcweir       mbIsShowSeconds(true)
2114*cdf0e10cSrcweir {
2115*cdf0e10cSrcweir }
2116*cdf0e10cSrcweir 
2117*cdf0e10cSrcweir 
2118*cdf0e10cSrcweir 
2119*cdf0e10cSrcweir 
2120*cdf0e10cSrcweir OUString TimeFormatter::FormatTime (const oslDateTime& rTime)
2121*cdf0e10cSrcweir {
2122*cdf0e10cSrcweir     ::rtl::OUStringBuffer sText;
2123*cdf0e10cSrcweir 
2124*cdf0e10cSrcweir     const sal_Int32 nHours (sal::static_int_cast<sal_Int32>(rTime.Hours));
2125*cdf0e10cSrcweir     const sal_Int32 nMinutes (sal::static_int_cast<sal_Int32>(rTime.Minutes));
2126*cdf0e10cSrcweir     const sal_Int32 nSeconds(sal::static_int_cast<sal_Int32>(rTime.Seconds));
2127*cdf0e10cSrcweir 
2128*cdf0e10cSrcweir     // Hours
2129*cdf0e10cSrcweir     if (mbIs24HourFormat)
2130*cdf0e10cSrcweir         sText.append(OUString::valueOf(nHours));
2131*cdf0e10cSrcweir     else
2132*cdf0e10cSrcweir         sText.append(OUString::valueOf(
2133*cdf0e10cSrcweir             sal::static_int_cast<sal_Int32>(nHours>12 ? nHours-12 : nHours)));
2134*cdf0e10cSrcweir 
2135*cdf0e10cSrcweir     sText.append(A2S(":"));
2136*cdf0e10cSrcweir 
2137*cdf0e10cSrcweir     // Minutes
2138*cdf0e10cSrcweir     const OUString sMinutes (OUString::valueOf(nMinutes));
2139*cdf0e10cSrcweir     if (sMinutes.getLength() == 1)
2140*cdf0e10cSrcweir         sText.append(A2S("0"));
2141*cdf0e10cSrcweir     sText.append(sMinutes);
2142*cdf0e10cSrcweir 
2143*cdf0e10cSrcweir     // Seconds
2144*cdf0e10cSrcweir     if (mbIsShowSeconds)
2145*cdf0e10cSrcweir     {
2146*cdf0e10cSrcweir         sText.append(A2S(":"));
2147*cdf0e10cSrcweir         const OUString sSeconds (OUString::valueOf(nSeconds));
2148*cdf0e10cSrcweir         if (sSeconds.getLength() == 1)
2149*cdf0e10cSrcweir             sText.append(A2S("0"));
2150*cdf0e10cSrcweir         sText.append(sSeconds);
2151*cdf0e10cSrcweir     }
2152*cdf0e10cSrcweir 
2153*cdf0e10cSrcweir     if (mbIsAmPmFormat)
2154*cdf0e10cSrcweir     {
2155*cdf0e10cSrcweir         if (rTime.Hours < 12)
2156*cdf0e10cSrcweir             sText.append(A2S("am"));
2157*cdf0e10cSrcweir         else
2158*cdf0e10cSrcweir             sText.append(A2S("pm"));
2159*cdf0e10cSrcweir     }
2160*cdf0e10cSrcweir     return sText.makeStringAndClear();
2161*cdf0e10cSrcweir }
2162*cdf0e10cSrcweir 
2163*cdf0e10cSrcweir 
2164*cdf0e10cSrcweir 
2165*cdf0e10cSrcweir 
2166*cdf0e10cSrcweir //===== TimeLabel =============================================================
2167*cdf0e10cSrcweir 
2168*cdf0e10cSrcweir TimeLabel::TimeLabel (const ::rtl::Reference<PresenterToolBar>& rpToolBar)
2169*cdf0e10cSrcweir     : Label(rpToolBar),
2170*cdf0e10cSrcweir       mpListener()
2171*cdf0e10cSrcweir {
2172*cdf0e10cSrcweir }
2173*cdf0e10cSrcweir 
2174*cdf0e10cSrcweir 
2175*cdf0e10cSrcweir 
2176*cdf0e10cSrcweir 
2177*cdf0e10cSrcweir void SAL_CALL TimeLabel::disposing (void)
2178*cdf0e10cSrcweir {
2179*cdf0e10cSrcweir     PresenterClockTimer::Instance(mpToolBar->GetComponentContext())->RemoveListener(mpListener);
2180*cdf0e10cSrcweir     mpListener.reset();
2181*cdf0e10cSrcweir }
2182*cdf0e10cSrcweir 
2183*cdf0e10cSrcweir 
2184*cdf0e10cSrcweir 
2185*cdf0e10cSrcweir 
2186*cdf0e10cSrcweir void TimeLabel::ConnectToTimer (void)
2187*cdf0e10cSrcweir {
2188*cdf0e10cSrcweir     mpListener.reset(new Listener(this));
2189*cdf0e10cSrcweir     PresenterClockTimer::Instance(mpToolBar->GetComponentContext())->AddListener(mpListener);
2190*cdf0e10cSrcweir }
2191*cdf0e10cSrcweir 
2192*cdf0e10cSrcweir 
2193*cdf0e10cSrcweir 
2194*cdf0e10cSrcweir 
2195*cdf0e10cSrcweir //===== CurrentTimeLabel ======================================================
2196*cdf0e10cSrcweir 
2197*cdf0e10cSrcweir ::rtl::Reference<Element> CurrentTimeLabel::Create (
2198*cdf0e10cSrcweir     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
2199*cdf0e10cSrcweir {
2200*cdf0e10cSrcweir     ::rtl::Reference<TimeLabel> pElement(new CurrentTimeLabel(rpToolBar));
2201*cdf0e10cSrcweir     pElement->ConnectToTimer();
2202*cdf0e10cSrcweir     return ::rtl::Reference<Element>(pElement.get());
2203*cdf0e10cSrcweir }
2204*cdf0e10cSrcweir 
2205*cdf0e10cSrcweir 
2206*cdf0e10cSrcweir 
2207*cdf0e10cSrcweir 
2208*cdf0e10cSrcweir CurrentTimeLabel::~CurrentTimeLabel (void)
2209*cdf0e10cSrcweir {
2210*cdf0e10cSrcweir }
2211*cdf0e10cSrcweir 
2212*cdf0e10cSrcweir 
2213*cdf0e10cSrcweir 
2214*cdf0e10cSrcweir 
2215*cdf0e10cSrcweir CurrentTimeLabel::CurrentTimeLabel (
2216*cdf0e10cSrcweir     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
2217*cdf0e10cSrcweir     : TimeLabel(rpToolBar),
2218*cdf0e10cSrcweir       maTimeFormatter()
2219*cdf0e10cSrcweir {
2220*cdf0e10cSrcweir }
2221*cdf0e10cSrcweir 
2222*cdf0e10cSrcweir 
2223*cdf0e10cSrcweir 
2224*cdf0e10cSrcweir 
2225*cdf0e10cSrcweir void CurrentTimeLabel::TimeHasChanged (const oslDateTime& rCurrentTime)
2226*cdf0e10cSrcweir {
2227*cdf0e10cSrcweir     SetText(maTimeFormatter.FormatTime(rCurrentTime));
2228*cdf0e10cSrcweir     Invalidate(false);
2229*cdf0e10cSrcweir }
2230*cdf0e10cSrcweir 
2231*cdf0e10cSrcweir 
2232*cdf0e10cSrcweir 
2233*cdf0e10cSrcweir 
2234*cdf0e10cSrcweir void CurrentTimeLabel::SetModes (
2235*cdf0e10cSrcweir     const SharedElementMode& rpNormalMode,
2236*cdf0e10cSrcweir     const SharedElementMode& rpMouseOverMode,
2237*cdf0e10cSrcweir     const SharedElementMode& rpSelectedMode,
2238*cdf0e10cSrcweir     const SharedElementMode& rpDisabledMode)
2239*cdf0e10cSrcweir {
2240*cdf0e10cSrcweir     TimeLabel::SetModes(rpNormalMode, rpMouseOverMode, rpSelectedMode, rpDisabledMode);
2241*cdf0e10cSrcweir     SetText(maTimeFormatter.FormatTime(PresenterClockTimer::GetCurrentTime()));
2242*cdf0e10cSrcweir }
2243*cdf0e10cSrcweir 
2244*cdf0e10cSrcweir 
2245*cdf0e10cSrcweir 
2246*cdf0e10cSrcweir 
2247*cdf0e10cSrcweir //===== PresentationTimeLabel =================================================
2248*cdf0e10cSrcweir 
2249*cdf0e10cSrcweir ::rtl::Reference<Element> PresentationTimeLabel::Create (
2250*cdf0e10cSrcweir     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
2251*cdf0e10cSrcweir {
2252*cdf0e10cSrcweir     ::rtl::Reference<TimeLabel> pElement(new PresentationTimeLabel(rpToolBar));
2253*cdf0e10cSrcweir     pElement->ConnectToTimer();
2254*cdf0e10cSrcweir     return ::rtl::Reference<Element>(pElement.get());
2255*cdf0e10cSrcweir }
2256*cdf0e10cSrcweir 
2257*cdf0e10cSrcweir 
2258*cdf0e10cSrcweir 
2259*cdf0e10cSrcweir 
2260*cdf0e10cSrcweir PresentationTimeLabel::~PresentationTimeLabel (void)
2261*cdf0e10cSrcweir {
2262*cdf0e10cSrcweir }
2263*cdf0e10cSrcweir 
2264*cdf0e10cSrcweir 
2265*cdf0e10cSrcweir 
2266*cdf0e10cSrcweir 
2267*cdf0e10cSrcweir PresentationTimeLabel::PresentationTimeLabel (
2268*cdf0e10cSrcweir     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
2269*cdf0e10cSrcweir     : TimeLabel(rpToolBar),
2270*cdf0e10cSrcweir       maTimeFormatter(),
2271*cdf0e10cSrcweir       maStartTimeValue()
2272*cdf0e10cSrcweir {
2273*cdf0e10cSrcweir     maStartTimeValue.Seconds = 0;
2274*cdf0e10cSrcweir     maStartTimeValue.Nanosec = 0;
2275*cdf0e10cSrcweir }
2276*cdf0e10cSrcweir 
2277*cdf0e10cSrcweir 
2278*cdf0e10cSrcweir 
2279*cdf0e10cSrcweir 
2280*cdf0e10cSrcweir void PresentationTimeLabel::TimeHasChanged (const oslDateTime& rCurrentTime)
2281*cdf0e10cSrcweir {
2282*cdf0e10cSrcweir     TimeValue aCurrentTimeValue;
2283*cdf0e10cSrcweir     if (osl_getTimeValueFromDateTime(const_cast<oslDateTime*>(&rCurrentTime), &aCurrentTimeValue))
2284*cdf0e10cSrcweir     {
2285*cdf0e10cSrcweir         if (maStartTimeValue.Seconds==0 && maStartTimeValue.Nanosec==0)
2286*cdf0e10cSrcweir         {
2287*cdf0e10cSrcweir             // This method is called for the first time.  Initialize the
2288*cdf0e10cSrcweir             // start time.  The start time is rounded to nearest second to
2289*cdf0e10cSrcweir             // keep the time updates synchronized with the current time label.
2290*cdf0e10cSrcweir             maStartTimeValue = aCurrentTimeValue;
2291*cdf0e10cSrcweir             if (maStartTimeValue.Nanosec >= 500000000)
2292*cdf0e10cSrcweir                 maStartTimeValue.Seconds += 1;
2293*cdf0e10cSrcweir             maStartTimeValue.Nanosec = 0;
2294*cdf0e10cSrcweir         }
2295*cdf0e10cSrcweir 
2296*cdf0e10cSrcweir         TimeValue aElapsedTimeValue;
2297*cdf0e10cSrcweir         aElapsedTimeValue.Seconds = aCurrentTimeValue.Seconds - maStartTimeValue.Seconds;
2298*cdf0e10cSrcweir         aElapsedTimeValue.Nanosec = aCurrentTimeValue.Nanosec - maStartTimeValue.Nanosec;
2299*cdf0e10cSrcweir 
2300*cdf0e10cSrcweir         oslDateTime aElapsedDateTime;
2301*cdf0e10cSrcweir         if (osl_getDateTimeFromTimeValue(&aElapsedTimeValue, &aElapsedDateTime))
2302*cdf0e10cSrcweir         {
2303*cdf0e10cSrcweir             SetText(maTimeFormatter.FormatTime(aElapsedDateTime));
2304*cdf0e10cSrcweir             Invalidate(false);
2305*cdf0e10cSrcweir         }
2306*cdf0e10cSrcweir     }
2307*cdf0e10cSrcweir }
2308*cdf0e10cSrcweir 
2309*cdf0e10cSrcweir 
2310*cdf0e10cSrcweir 
2311*cdf0e10cSrcweir void PresentationTimeLabel::SetModes (
2312*cdf0e10cSrcweir     const SharedElementMode& rpNormalMode,
2313*cdf0e10cSrcweir     const SharedElementMode& rpMouseOverMode,
2314*cdf0e10cSrcweir     const SharedElementMode& rpSelectedMode,
2315*cdf0e10cSrcweir     const SharedElementMode& rpDisabledMode)
2316*cdf0e10cSrcweir {
2317*cdf0e10cSrcweir     TimeLabel::SetModes(rpNormalMode, rpMouseOverMode, rpSelectedMode, rpDisabledMode);
2318*cdf0e10cSrcweir 
2319*cdf0e10cSrcweir     oslDateTime aStartDateTime;
2320*cdf0e10cSrcweir     if (osl_getDateTimeFromTimeValue(&maStartTimeValue, &aStartDateTime))
2321*cdf0e10cSrcweir     {
2322*cdf0e10cSrcweir         SetText(maTimeFormatter.FormatTime(aStartDateTime));
2323*cdf0e10cSrcweir     }
2324*cdf0e10cSrcweir }
2325*cdf0e10cSrcweir 
2326*cdf0e10cSrcweir 
2327*cdf0e10cSrcweir 
2328*cdf0e10cSrcweir 
2329*cdf0e10cSrcweir //===== VerticalSeparator =====================================================
2330*cdf0e10cSrcweir 
2331*cdf0e10cSrcweir VerticalSeparator::VerticalSeparator (
2332*cdf0e10cSrcweir     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
2333*cdf0e10cSrcweir     : Element(rpToolBar)
2334*cdf0e10cSrcweir {
2335*cdf0e10cSrcweir }
2336*cdf0e10cSrcweir 
2337*cdf0e10cSrcweir 
2338*cdf0e10cSrcweir 
2339*cdf0e10cSrcweir 
2340*cdf0e10cSrcweir void VerticalSeparator::Paint (
2341*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas,
2342*cdf0e10cSrcweir     const rendering::ViewState& rViewState)
2343*cdf0e10cSrcweir {
2344*cdf0e10cSrcweir     OSL_ASSERT(rxCanvas.is());
2345*cdf0e10cSrcweir 
2346*cdf0e10cSrcweir     awt::Rectangle aBBox (GetBoundingBox());
2347*cdf0e10cSrcweir 
2348*cdf0e10cSrcweir     rendering::RenderState aRenderState(
2349*cdf0e10cSrcweir         geometry::AffineMatrix2D(1,0,0, 0,1,0),
2350*cdf0e10cSrcweir         NULL,
2351*cdf0e10cSrcweir         Sequence<double>(4),
2352*cdf0e10cSrcweir         rendering::CompositeOperation::OVER);
2353*cdf0e10cSrcweir     if (mpMode.get() != NULL)
2354*cdf0e10cSrcweir     {
2355*cdf0e10cSrcweir         PresenterTheme::SharedFontDescriptor pFont (mpMode->maText.GetFont());
2356*cdf0e10cSrcweir         if (pFont.get() != NULL)
2357*cdf0e10cSrcweir             PresenterCanvasHelper::SetDeviceColor(aRenderState, pFont->mnColor);
2358*cdf0e10cSrcweir     }
2359*cdf0e10cSrcweir 
2360*cdf0e10cSrcweir     if (aBBox.Height >= gnMinimalSeparatorSize + 2*gnSeparatorInset)
2361*cdf0e10cSrcweir     {
2362*cdf0e10cSrcweir         aBBox.Height -= 2*gnSeparatorInset;
2363*cdf0e10cSrcweir         aBBox.Y += gnSeparatorInset;
2364*cdf0e10cSrcweir     }
2365*cdf0e10cSrcweir     rxCanvas->fillPolyPolygon(
2366*cdf0e10cSrcweir         PresenterGeometryHelper::CreatePolygon(aBBox, rxCanvas->getDevice()),
2367*cdf0e10cSrcweir         rViewState,
2368*cdf0e10cSrcweir         aRenderState);
2369*cdf0e10cSrcweir }
2370*cdf0e10cSrcweir 
2371*cdf0e10cSrcweir 
2372*cdf0e10cSrcweir 
2373*cdf0e10cSrcweir 
2374*cdf0e10cSrcweir awt::Size VerticalSeparator::CreateBoundingSize (
2375*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas)
2376*cdf0e10cSrcweir {
2377*cdf0e10cSrcweir     (void)rxCanvas;
2378*cdf0e10cSrcweir     return awt::Size(1,20);
2379*cdf0e10cSrcweir }
2380*cdf0e10cSrcweir 
2381*cdf0e10cSrcweir 
2382*cdf0e10cSrcweir 
2383*cdf0e10cSrcweir 
2384*cdf0e10cSrcweir bool VerticalSeparator::IsFilling (void) const
2385*cdf0e10cSrcweir {
2386*cdf0e10cSrcweir     return true;
2387*cdf0e10cSrcweir }
2388*cdf0e10cSrcweir 
2389*cdf0e10cSrcweir 
2390*cdf0e10cSrcweir 
2391*cdf0e10cSrcweir 
2392*cdf0e10cSrcweir //===== HorizontalSeparator ===================================================
2393*cdf0e10cSrcweir 
2394*cdf0e10cSrcweir HorizontalSeparator::HorizontalSeparator (
2395*cdf0e10cSrcweir     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
2396*cdf0e10cSrcweir     : Element(rpToolBar)
2397*cdf0e10cSrcweir {
2398*cdf0e10cSrcweir }
2399*cdf0e10cSrcweir 
2400*cdf0e10cSrcweir 
2401*cdf0e10cSrcweir 
2402*cdf0e10cSrcweir 
2403*cdf0e10cSrcweir void HorizontalSeparator::Paint (
2404*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas,
2405*cdf0e10cSrcweir     const rendering::ViewState& rViewState)
2406*cdf0e10cSrcweir {
2407*cdf0e10cSrcweir     OSL_ASSERT(rxCanvas.is());
2408*cdf0e10cSrcweir 
2409*cdf0e10cSrcweir     awt::Rectangle aBBox (GetBoundingBox());
2410*cdf0e10cSrcweir 
2411*cdf0e10cSrcweir     rendering::RenderState aRenderState(
2412*cdf0e10cSrcweir         geometry::AffineMatrix2D(1,0,0, 0,1,0),
2413*cdf0e10cSrcweir         NULL,
2414*cdf0e10cSrcweir         Sequence<double>(4),
2415*cdf0e10cSrcweir         rendering::CompositeOperation::OVER);
2416*cdf0e10cSrcweir     if (mpMode.get() != NULL)
2417*cdf0e10cSrcweir     {
2418*cdf0e10cSrcweir         PresenterTheme::SharedFontDescriptor pFont (mpMode->maText.GetFont());
2419*cdf0e10cSrcweir         if (pFont.get() != NULL)
2420*cdf0e10cSrcweir             PresenterCanvasHelper::SetDeviceColor(aRenderState, pFont->mnColor);
2421*cdf0e10cSrcweir     }
2422*cdf0e10cSrcweir 
2423*cdf0e10cSrcweir     if (aBBox.Width >= gnMinimalSeparatorSize+2*gnSeparatorInset)
2424*cdf0e10cSrcweir     {
2425*cdf0e10cSrcweir         aBBox.Width -= 2*gnSeparatorInset;
2426*cdf0e10cSrcweir         aBBox.X += gnSeparatorInset;
2427*cdf0e10cSrcweir     }
2428*cdf0e10cSrcweir     rxCanvas->fillPolyPolygon(
2429*cdf0e10cSrcweir         PresenterGeometryHelper::CreatePolygon(aBBox, rxCanvas->getDevice()),
2430*cdf0e10cSrcweir         rViewState,
2431*cdf0e10cSrcweir         aRenderState);
2432*cdf0e10cSrcweir }
2433*cdf0e10cSrcweir 
2434*cdf0e10cSrcweir 
2435*cdf0e10cSrcweir 
2436*cdf0e10cSrcweir 
2437*cdf0e10cSrcweir awt::Size HorizontalSeparator::CreateBoundingSize (
2438*cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas)
2439*cdf0e10cSrcweir {
2440*cdf0e10cSrcweir     (void)rxCanvas;
2441*cdf0e10cSrcweir     return awt::Size(20,1);
2442*cdf0e10cSrcweir }
2443*cdf0e10cSrcweir 
2444*cdf0e10cSrcweir 
2445*cdf0e10cSrcweir 
2446*cdf0e10cSrcweir 
2447*cdf0e10cSrcweir bool HorizontalSeparator::IsFilling (void) const
2448*cdf0e10cSrcweir {
2449*cdf0e10cSrcweir     return true;
2450*cdf0e10cSrcweir }
2451*cdf0e10cSrcweir 
2452*cdf0e10cSrcweir 
2453*cdf0e10cSrcweir 
2454*cdf0e10cSrcweir 
2455*cdf0e10cSrcweir } // end of anonymous namespace
2456*cdf0e10cSrcweir 
2457*cdf0e10cSrcweir 
2458*cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
2459