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