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