From 874cb08467709b5e37163193f9b8073398432400 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 6 Oct 2010 14:21:47 +0200 Subject: dba34b: #i112779# new 'animated images' UNO control, superseding the (X)SimpleAnimation and Throbber controls --- toolkit/inc/toolkit/awt/animatedimagespeer.hxx | 103 +++++ toolkit/inc/toolkit/awt/xsimpleanimation.hxx | 25 +- toolkit/inc/toolkit/awt/xthrobber.hxx | 25 +- toolkit/inc/toolkit/controls/animatedimages.hxx | 144 ++++++ toolkit/inc/toolkit/controls/spinningprogress.hxx | 70 +++ toolkit/inc/toolkit/controls/tksimpleanimation.hxx | 18 +- .../inc/toolkit/helper/mutexandbroadcasthelper.hxx | 2 +- toolkit/inc/toolkit/helper/property.hxx | 1 + toolkit/inc/toolkit/helper/servicenames.hxx | 3 + toolkit/inc/toolkit/helper/throbberimpl.hxx | 29 +- toolkit/source/awt/animatedimagespeer.cxx | 372 ++++++++++++++++ toolkit/source/awt/makefile.mk | 6 +- toolkit/source/awt/spinningprogress.src | 72 +++ toolkit/source/awt/vclxtoolkit.cxx | 23 +- toolkit/source/awt/xsimpleanimation.cxx | 41 +- toolkit/source/awt/xthrobber.cxx | 60 +-- toolkit/source/controls/animatedimages.cxx | 491 +++++++++++++++++++++ toolkit/source/controls/makefile.mk | 4 +- toolkit/source/controls/spinningprogress.cxx | 151 +++++++ toolkit/source/controls/tksimpleanimation.cxx | 55 +-- toolkit/source/controls/unocontrolmodel.cxx | 2 + toolkit/source/helper/property.cxx | 4 +- toolkit/source/helper/registerservices.cxx | 16 + toolkit/source/helper/servicenames.cxx | 3 + toolkit/source/helper/throbberimpl.cxx | 87 ++-- toolkit/util/tk.component | 9 + 26 files changed, 1574 insertions(+), 242 deletions(-) create mode 100755 toolkit/inc/toolkit/awt/animatedimagespeer.hxx create mode 100755 toolkit/inc/toolkit/controls/animatedimages.hxx create mode 100755 toolkit/inc/toolkit/controls/spinningprogress.hxx create mode 100755 toolkit/source/awt/animatedimagespeer.cxx create mode 100755 toolkit/source/awt/spinningprogress.src create mode 100755 toolkit/source/controls/animatedimages.cxx create mode 100755 toolkit/source/controls/spinningprogress.cxx (limited to 'toolkit') diff --git a/toolkit/inc/toolkit/awt/animatedimagespeer.hxx b/toolkit/inc/toolkit/awt/animatedimagespeer.hxx new file mode 100755 index 000000000000..0d1204cb1309 --- /dev/null +++ b/toolkit/inc/toolkit/awt/animatedimagespeer.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef TOOLKIT_ANIMATEDIMAGEPEER_HXX +#define TOOLKIT_ANIMATEDIMAGEPEER_HXX + +#include "toolkit/awt/vclxwindow.hxx" + +/** === begin UNO includes === **/ +#include +#include +/** === end UNO includes === **/ + +#include + +#include +#include + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + //================================================================================================================== + //= AnimatedImagesPeer + //================================================================================================================== + struct AnimatedImagesPeer_Data; + typedef ::cppu::ImplInheritanceHelper3 < VCLXWindow + , ::com::sun::star::awt::XAnimation + , ::com::sun::star::container::XContainerListener + , ::com::sun::star::util::XModifyListener + > AnimatedImagesPeer_Base; + + class AnimatedImagesPeer :public AnimatedImagesPeer_Base + ,public ::boost::noncopyable + { + public: + AnimatedImagesPeer(); + + protected: + ~AnimatedImagesPeer(); + + public: + // XAnimation + virtual void SAL_CALL startAnimation( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL stopAnimation( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isAnimationRunning( ) throw (::com::sun::star::uno::RuntimeException); + + // VclWindowPeer + virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); + + // XContainerListener + virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& i_event ) throw (::com::sun::star::uno::RuntimeException); + + // XModifyListener + virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& i_event ) throw (::com::sun::star::uno::RuntimeException); + + protected: + void ProcessWindowEvent( const VclWindowEvent& i_windowEvent ); + + private: + /** updates our images with the ones from the givem XAnimatedImages component + */ + void impl_updateImages_nolck( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_animatedImages ); + + private: + ::boost::scoped_ptr< AnimatedImagesPeer_Data > m_pData; + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_ANIMATEDIMAGEPEER_HXX diff --git a/toolkit/inc/toolkit/awt/xsimpleanimation.hxx b/toolkit/inc/toolkit/awt/xsimpleanimation.hxx index dc8fbe4506ed..673c7eaddf61 100644 --- a/toolkit/inc/toolkit/awt/xsimpleanimation.hxx +++ b/toolkit/inc/toolkit/awt/xsimpleanimation.hxx @@ -33,6 +33,8 @@ #include #include +#include + //........................................................................ namespace toolkit { @@ -42,18 +44,14 @@ namespace toolkit //==================================================================== //= XSimpleAnimation //==================================================================== - typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XSimpleAnimation - > XSimpleAnimation_Base; + typedef ::cppu::ImplInheritanceHelper1 < VCLXWindow + , ::com::sun::star::awt::XSimpleAnimation + > XSimpleAnimation_Base; - class XSimpleAnimation :public VCLXWindow - ,public XSimpleAnimation_Base + class XSimpleAnimation : public XSimpleAnimation_Base { private: - //::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > > maImageList; - sal_Bool mbRepeat; - sal_Int32 mnStepTime; - - Throbber_Impl *mpThrobber; + ::boost::scoped_ptr< Throbber_Impl > mpThrobber; public: XSimpleAnimation(); @@ -61,12 +59,6 @@ namespace toolkit protected: ~XSimpleAnimation(); - // XInterface - DECLARE_XINTERFACE() - - // XTypeProvider - DECLARE_XTYPEPROVIDER() - // XSimpleAnimation virtual void SAL_CALL start() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL stop() throw (::com::sun::star::uno::RuntimeException); @@ -76,9 +68,6 @@ namespace toolkit virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); - // VCLXWindow - void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ); - private: XSimpleAnimation( const XSimpleAnimation& ); // never implemented XSimpleAnimation& operator=( const XSimpleAnimation& ); // never implemented diff --git a/toolkit/inc/toolkit/awt/xthrobber.hxx b/toolkit/inc/toolkit/awt/xthrobber.hxx index 511f3f76ecf6..fa0df0047180 100644 --- a/toolkit/inc/toolkit/awt/xthrobber.hxx +++ b/toolkit/inc/toolkit/awt/xthrobber.hxx @@ -33,6 +33,9 @@ #include #include +#include +#include + //........................................................................ namespace toolkit { @@ -42,11 +45,12 @@ namespace toolkit //==================================================================== //= XThrobber //==================================================================== - typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XThrobber - > XThrobber_Base; + typedef ::cppu::ImplInheritanceHelper1 < VCLXWindow + , ::com::sun::star::awt::XThrobber + > XThrobber_Base; - class XThrobber :public VCLXWindow - ,public XThrobber_Base + class XThrobber :public XThrobber_Base + ,public ::boost::noncopyable { private: Throbber_Impl *mpThrobber; @@ -58,23 +62,10 @@ namespace toolkit protected: ~XThrobber(); - // XInterface - DECLARE_XINTERFACE() - - // XTypeProvider - DECLARE_XTYPEPROVIDER() - // XThrobber virtual void SAL_CALL start() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL stop() throw (::com::sun::star::uno::RuntimeException); - // VclWindowPeer - virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); - - // VCLXWindow - void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ); - private: XThrobber( const XThrobber& ); // never implemented XThrobber& operator=( const XThrobber& ); // never implemented diff --git a/toolkit/inc/toolkit/controls/animatedimages.hxx b/toolkit/inc/toolkit/controls/animatedimages.hxx new file mode 100755 index 000000000000..96791c252b0b --- /dev/null +++ b/toolkit/inc/toolkit/controls/animatedimages.hxx @@ -0,0 +1,144 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef TOOLKIT_ANIMATEDIMAGES_HXX +#define TOOLKIT_ANIMATEDIMAGES_HXX + +#include "toolkit/controls/unocontrolbase.hxx" +#include "toolkit/controls/unocontrolmodel.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include + +#include + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + //================================================================================================================== + //= + //================================================================================================================== + typedef ::cppu::AggImplInheritanceHelper2 < UnoControlBase + , ::com::sun::star::awt::XAnimation + , ::com::sun::star::container::XContainerListener + > AnimatedImagesControl_Base; + + class AnimatedImagesControl : public AnimatedImagesControl_Base + { + public: + AnimatedImagesControl(); + ::rtl::OUString GetComponentServiceName(); + + // XAnimation + virtual void SAL_CALL startAnimation( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL stopAnimation( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isAnimationRunning( ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XControl + sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& i_rModel ) throw ( ::com::sun::star::uno::RuntimeException ); + void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& i_toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& i_parentPeer ) throw(::com::sun::star::uno::RuntimeException); + + + // XContainerListener + virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& i_event ) throw (::com::sun::star::uno::RuntimeException); + }; + + //================================================================================================================== + //= AnimatedImagesControlModel + //================================================================================================================== + struct AnimatedImagesControlModel_Data; + typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel + , ::com::sun::star::awt::XAnimatedImages + > AnimatedImagesControlModel_Base; + class AnimatedImagesControlModel : public AnimatedImagesControlModel_Base + { + public: + AnimatedImagesControlModel(); + AnimatedImagesControlModel( const AnimatedImagesControlModel& i_copySource ); + + virtual UnoControlModel* Clone() const; + + // XPropertySet + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + + // XPersistObject + ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XAnimatedImages + virtual ::sal_Int32 SAL_CALL getStepTime() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setStepTime( ::sal_Int32 _steptime ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getAutoRepeat() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAutoRepeat( ::sal_Bool _autorepeat ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getScaleMode() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setScaleMode( ::sal_Int16 _scalemode ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getImageSetCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getImageSet( ::sal_Int32 i_index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertImageSet( ::sal_Int32 i_index, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_imageURLs ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL replaceImageSet( ::sal_Int32 i_index, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_imageURLs ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeImageSet( ::sal_Int32 i_index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + // XAnimatedImages::XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException); + + protected: + ~AnimatedImagesControlModel(); + + ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception); + + private: + ::boost::scoped_ptr< AnimatedImagesControlModel_Data > + m_pData; + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_ANIMATEDIMAGES_HXX diff --git a/toolkit/inc/toolkit/controls/spinningprogress.hxx b/toolkit/inc/toolkit/controls/spinningprogress.hxx new file mode 100755 index 000000000000..b2e8204ca999 --- /dev/null +++ b/toolkit/inc/toolkit/controls/spinningprogress.hxx @@ -0,0 +1,70 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef TOOLKIT_SPINNINGPROGRESS_HXX +#define TOOLKIT_SPINNINGPROGRESS_HXX + +#include "toolkit/controls/animatedimages.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + //================================================================================================================== + //= SpinningProgressControlModel + //================================================================================================================== + typedef AnimatedImagesControlModel SpinningProgressControlModel_Base; + class SpinningProgressControlModel : public SpinningProgressControlModel_Base + { + public: + SpinningProgressControlModel(); + SpinningProgressControlModel( const SpinningProgressControlModel& i_copySource ); + + virtual UnoControlModel* Clone() const; + + // XPropertySet + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + + // XPersistObject + ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + protected: + ~SpinningProgressControlModel(); + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_SPINNINGPROGRESS_HXX diff --git a/toolkit/inc/toolkit/controls/tksimpleanimation.hxx b/toolkit/inc/toolkit/controls/tksimpleanimation.hxx index 697d1679af45..1d059c749902 100644 --- a/toolkit/inc/toolkit/controls/tksimpleanimation.hxx +++ b/toolkit/inc/toolkit/controls/tksimpleanimation.hxx @@ -71,11 +71,11 @@ namespace toolkit //= UnoSimpleAnimationControl //==================================================================== - typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XSimpleAnimation - > UnoSimpleAnimationControl_Base; + typedef ::cppu::AggImplInheritanceHelper1 < UnoControlBase + , ::com::sun::star::awt::XSimpleAnimation + > UnoSimpleAnimationControl_Base; - class UnoSimpleAnimationControl :public UnoControlBase - ,public UnoSimpleAnimationControl_Base + class UnoSimpleAnimationControl : public UnoSimpleAnimationControl_Base { private: @@ -83,16 +83,6 @@ namespace toolkit UnoSimpleAnimationControl(); ::rtl::OUString GetComponentServiceName(); - DECLARE_UNO3_AGG_DEFAULTS( UnoSimpleAnimationControl, UnoControlBase ); - ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - - void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) { UnoControlBase::disposing( Source ); } - void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); - - // XTypeProvider - DECLARE_XTYPEPROVIDER() - // XSimpleAnimation virtual void SAL_CALL start() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL stop() throw (::com::sun::star::uno::RuntimeException); diff --git a/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx b/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx index c84a6e54d73b..45e0bdf93dc4 100644 --- a/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx +++ b/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx @@ -44,7 +44,7 @@ public: ::cppu::OBroadcastHelper BrdcstHelper; ::osl::Mutex& GetMutex() { return Mutex; } - + ::cppu::OBroadcastHelper& GetBroadcastHelper() { return BrdcstHelper; } }; diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index 837d283f4e8c..082ac75bafae 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -202,6 +202,7 @@ namespace rtl { #define BASEPROPERTY_GRID_ROW_BACKGROUND 151 #define BASEPROPERTY_MULTISELECTION_SIMPLEMODE 152 #define BASEPROPERTY_ITEM_SEPARATOR_POS 153 +#define BASEPROPERTY_AUTO_REPEAT 154 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen. diff --git a/toolkit/inc/toolkit/helper/servicenames.hxx b/toolkit/inc/toolkit/helper/servicenames.hxx index 2d1df79b733b..b217e8f90402 100644 --- a/toolkit/inc/toolkit/helper/servicenames.hxx +++ b/toolkit/inc/toolkit/helper/servicenames.hxx @@ -102,6 +102,9 @@ extern const sal_Char __FAR_DATA szServiceName_UnoSimpleAnimationControl[], szSe extern const sal_Char __FAR_DATA szServiceName_UnoSimpleAnimationControlModel[], szServiceName2_UnoSimpleAnimationControlModel[]; extern const sal_Char __FAR_DATA szServiceName_UnoThrobberControl[], szServiceName2_UnoThrobberControl[]; extern const sal_Char __FAR_DATA szServiceName_UnoThrobberControlModel[], szServiceName2_UnoThrobberControlModel[]; +extern const sal_Char __FAR_DATA szServiceName_AnimatedImagesControl[]; +extern const sal_Char __FAR_DATA szServiceName_AnimatedImagesControlModel[]; +extern const sal_Char __FAR_DATA szServiceName_SpinningProgressControlModel[]; extern const sal_Char __FAR_DATA szServiceName_UnoControlFixedHyperlink[], szServiceName_UnoControlFixedHyperlinkModel[]; #endif // _TOOLKIT_HELPER_SERVICENAMES_HXX_ diff --git a/toolkit/inc/toolkit/helper/throbberimpl.hxx b/toolkit/inc/toolkit/helper/throbberimpl.hxx index b944a74b65d2..92fb177fd89d 100644 --- a/toolkit/inc/toolkit/helper/throbberimpl.hxx +++ b/toolkit/inc/toolkit/helper/throbberimpl.hxx @@ -45,7 +45,7 @@ namespace toolkit private: vos::IMutex& mrMutex; // Reference to SolarMutex ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > > maImageList; - ::com::sun::star::uno::Reference< VCLXWindow > mxParent; + VCLXWindow& mrParent; sal_Bool mbRepeat; sal_Int32 mnStepTime; @@ -58,24 +58,29 @@ namespace toolkit vos::IMutex& GetMutex() { return mrMutex; } public: - Throbber_Impl( ::com::sun::star::uno::Reference< VCLXWindow > xParent, - sal_Int32 nStepTime, - sal_Bool bRepeat ); + Throbber_Impl( VCLXWindow& i_rParent ); ~Throbber_Impl(); // Properties - void setStepTime( sal_Int32 nStepTime ) { mnStepTime = nStepTime; } - void setRepeat( sal_Bool bRepeat ) { mbRepeat = bRepeat; } + void setStepTime( sal_Int32 nStepTime ) { mnStepTime = nStepTime; } + sal_Int32 getStepTime() const { return mnStepTime; } + + void setRepeat( sal_Bool bRepeat ) { mbRepeat = bRepeat; } + sal_Bool getRepeat() const { return mbRepeat; } + + Window const* getWindow() const { return mrParent.GetWindow(); } + Window* getWindow() { return mrParent.GetWindow(); } // XSimpleAnimation - void start() throw ( ::com::sun::star::uno::RuntimeException ); - void stop() throw ( ::com::sun::star::uno::RuntimeException ); - void setImageList( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& ImageList ) - throw ( ::com::sun::star::uno::RuntimeException ); + void start(); + void stop(); + bool isRunning() const; + void setImageList( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& ImageList ); + // Helpers - void initImage() throw ( ::com::sun::star::uno::RuntimeException ); - sal_Bool isHCMode() throw ( ::com::sun::star::uno::RuntimeException ); + sal_Bool isHCMode(); }; + //........................................................................ } // namespacetoolkit //........................................................................ diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx new file mode 100755 index 000000000000..e4cc832da384 --- /dev/null +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -0,0 +1,372 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_toolkit.hxx" + +#include "toolkit/awt/animatedimagespeer.hxx" +#include "toolkit/helper/property.hxx" +#include "toolkit/helper/throbberimpl.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include +#include +#include +#include + +#include + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::awt::XAnimatedImages; + using ::com::sun::star::awt::Size; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::graphic::XGraphicProvider; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::graphic::XGraphic; + /** === end UNO using === **/ + namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; + + //================================================================================================================== + //= AnimatedImagesPeer_Data + //================================================================================================================== + struct AnimatedImagesPeer_Data + { + Throbber_Impl aThrobber; + ::std::vector< Sequence< ::rtl::OUString > > aCachedImageSets; + + AnimatedImagesPeer_Data( VCLXWindow& i_window ) + :aThrobber( i_window ) + ,aCachedImageSets() + { + } + }; + + //================================================================================================================== + //= helper + //================================================================================================================== + namespace + { + //-------------------------------------------------------------------------------------------------------------- + Reference< XGraphic > lcl_getGraphic_throw( const Reference< XGraphicProvider >& i_graphicProvider, const ::rtl::OUString& i_imageURL ) + { + ::comphelper::NamedValueCollection aMediaProperties; + aMediaProperties.put( "URL", i_imageURL ); + return Reference< XGraphic >( i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY ); + } + + //-------------------------------------------------------------------------------------------------------------- + Size lcl_getGraphicSizePixel( const Reference< XGraphicProvider >& i_graphicProvider, const ::rtl::OUString& i_imageURL ) + { + Size aSizePixel; + try + { + ::comphelper::NamedValueCollection aMediaProperties; + aMediaProperties.put( "URL", i_imageURL ); + const Reference< XPropertySet > xGraphicProps( lcl_getGraphic_throw( i_graphicProvider, i_imageURL ), UNO_QUERY_THROW ); + OSL_VERIFY( xGraphicProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SizePixel" ) ) ) >>= aSizePixel ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return aSizePixel; + } + + //-------------------------------------------------------------------------------------------------------------- + void lcl_updateImageList_nothrow( AnimatedImagesPeer_Data& i_data ) + { + const Window* pWindow = i_data.aThrobber.getWindow(); + if ( pWindow == NULL ) + return; + + try + { + // collect the image sizes of the different image sets + const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + const Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); + + const size_t nImageSetCount = i_data.aCachedImageSets.size(); + ::std::vector< Size > aImageSizes( nImageSetCount ); + for ( sal_Int32 nImageSet = 0; nImageSet < nImageSetCount; ++nImageSet ) + { + Sequence< ::rtl::OUString > const& rImageSet( i_data.aCachedImageSets[ nImageSet ] ); + if ( rImageSet.getLength() ) + aImageSizes[ nImageSet ] = lcl_getGraphicSizePixel( xGraphicProvider, rImageSet[0] ); + else + aImageSizes[ nImageSet ] = Size( ::std::numeric_limits< long >::max(), ::std::numeric_limits< long >::max() ); + } + + // find the set with the smallest difference between window size and image size + const ::Size aWindowSizePixel = pWindow->GetSizePixel(); + sal_Int32 nPreferredSet = -1; + long nMinimalDistance = ::std::numeric_limits< long >::max(); + for ( ::std::vector< Size >::const_iterator check = aImageSizes.begin(); + check != aImageSizes.end(); + ++check + ) + { + const sal_Int64 distance = + ( aWindowSizePixel.Width() - check->Width ) * ( aWindowSizePixel.Width() - check->Width ) + + ( aWindowSizePixel.Height() - check->Height ) * ( aWindowSizePixel.Height() - check->Height ); + if ( distance < nMinimalDistance ) + { + nMinimalDistance = distance; + nPreferredSet = check - aImageSizes.begin(); + } + } + + // found a set? + Sequence< Reference< XGraphic > > aImages; + if ( ( nPreferredSet >= 0 ) && ( nPreferredSet < nImageSetCount ) ) + { + // => set the images + Sequence< ::rtl::OUString > const& rImageSet( i_data.aCachedImageSets[ nPreferredSet ] ); + aImages.realloc( rImageSet.getLength() ); + sal_Int32 imageIndex = 0; + for ( ::rtl::OUString const* pImageURL = rImageSet.getConstArray(); + pImageURL != rImageSet.getConstArray() + rImageSet.getLength(); + ++pImageURL, ++imageIndex + ) + { + aImages[ imageIndex ] = lcl_getGraphic_throw( xGraphicProvider, *pImageURL ); + } + } + i_data.aThrobber.setImageList( aImages ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //-------------------------------------------------------------------------------------------------------------- + void lcl_updateImageList_nothrow( AnimatedImagesPeer_Data& i_data, const Reference< XAnimatedImages >& i_images ) + { + try + { + const sal_Int32 nImageSetCount = i_images->getImageSetCount(); + i_data.aCachedImageSets.resize(0); + for ( sal_Int32 set = 0; set < nImageSetCount; ++set ) + i_data.aCachedImageSets.push_back( i_images->getImageSet( set ) ); + + lcl_updateImageList_nothrow( i_data ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + + //================================================================================================================== + //= AnimatedImagesPeer + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesPeer::AnimatedImagesPeer() + :AnimatedImagesPeer_Base() + ,m_pData( new AnimatedImagesPeer_Data( *this ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesPeer::~AnimatedImagesPeer() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::startAnimation( ) throw (RuntimeException) + { + ::vos::OGuard aGuard( GetMutex() ); + m_pData->aThrobber.start(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::stopAnimation( ) throw (RuntimeException) + { + ::vos::OGuard aGuard( GetMutex() ); + m_pData->aThrobber.stop(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL AnimatedImagesPeer::isAnimationRunning( ) throw (RuntimeException) + { + ::vos::OGuard aGuard( GetMutex() ); + return m_pData->aThrobber.isRunning(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::setProperty( const ::rtl::OUString& i_propertyName, const Any& i_value ) throw(RuntimeException) + { + ::vos::OGuard aGuard( GetMutex() ); + + const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_STEP_TIME: + { + sal_Int32 nStepTime( 0 ); + if ( i_value >>= nStepTime ) + m_pData->aThrobber.setStepTime( nStepTime ); + break; + } + case BASEPROPERTY_AUTO_REPEAT: + { + sal_Bool bRepeat( sal_True ); + if ( i_value >>= bRepeat ) + m_pData->aThrobber.setRepeat( bRepeat ); + break; + } + + case BASEPROPERTY_IMAGE_SCALE_MODE: + { + sal_Int16 nScaleMode( ImageScaleMode::Anisotropic ); + ImageControl* pImageControl = dynamic_cast< ImageControl* >( GetWindow() ); + if ( pImageControl && ( i_value >>= nScaleMode ) ) + { + pImageControl->SetScaleMode( nScaleMode ); + } + } + break; + + default: + AnimatedImagesPeer_Base::setProperty( i_propertyName, i_value ); + break; + } + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL AnimatedImagesPeer::getProperty( const ::rtl::OUString& i_propertyName ) throw(RuntimeException) + { + ::vos::OGuard aGuard( GetMutex() ); + + Any aReturn; + + const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_STEP_TIME: + aReturn <<= m_pData->aThrobber.getStepTime(); + break; + + case BASEPROPERTY_AUTO_REPEAT: + aReturn <<= m_pData->aThrobber.getRepeat(); + break; + + case BASEPROPERTY_IMAGE_SCALE_MODE: + { + ImageControl const* pImageControl = dynamic_cast< ImageControl* >( GetWindow() ); + aReturn <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::Anisotropic ); + } + break; + + default: + aReturn = AnimatedImagesPeer_Base::getProperty( i_propertyName ); + break; + } + + return aReturn; + } + + //------------------------------------------------------------------------------------------------------------------ + void AnimatedImagesPeer::ProcessWindowEvent( const VclWindowEvent& i_windowEvent ) + { + switch ( i_windowEvent.GetId() ) + { + case VCLEVENT_WINDOW_RESIZE: + lcl_updateImageList_nothrow( *m_pData ); + break; + } + + AnimatedImagesPeer_Base::ProcessWindowEvent( i_windowEvent ); + } + + //------------------------------------------------------------------------------------------------------------------ + void AnimatedImagesPeer::impl_updateImages_nolck( const Reference< XInterface >& i_animatedImages ) + { + ::vos::OGuard aGuard( GetMutex() ); + + lcl_updateImageList_nothrow( *m_pData, Reference< XAnimatedImages >( i_animatedImages, UNO_QUERY_THROW ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) + { + impl_updateImages_nolck( i_event.Source ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) + { + impl_updateImages_nolck( i_event.Source ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) + { + impl_updateImages_nolck( i_event.Source ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::disposing( const EventObject& i_event ) throw (RuntimeException) + { + VCLXWindow::disposing( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::modified( const EventObject& i_event ) throw (RuntimeException) + { + impl_updateImages_nolck( i_event.Source ); + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... diff --git a/toolkit/source/awt/makefile.mk b/toolkit/source/awt/makefile.mk index 88b40a597410..152427ca9659 100644 --- a/toolkit/source/awt/makefile.mk +++ b/toolkit/source/awt/makefile.mk @@ -72,11 +72,13 @@ SLOFILES= \ $(SLO)/vclxscroller.obj\ $(SLO)/vclxsplitter.obj\ $(SLO)/vclxtabcontrol.obj\ - $(SLO)/vclxtabpage.obj + $(SLO)/vclxtabpage.obj\ + $(SLO)/animatedimagespeer.obj SRS1NAME=$(TARGET) SRC1FILES=\ - xthrobber.src + xthrobber.src \ + spinningprogress.src # --- Targets ------------------------------------------------------ diff --git a/toolkit/source/awt/spinningprogress.src b/toolkit/source/awt/spinningprogress.src new file mode 100755 index 000000000000..1c6ce7737804 --- /dev/null +++ b/toolkit/source/awt/spinningprogress.src @@ -0,0 +1,72 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// TODO: we need a mechanism to add images to images.zip, *without* +// referring them in resource files. The below resources are never loaded +// at runtime, instead, the images in images.zip are accessed via +// private:graphicrepository/* URLs. + +Resource 1000 +{ + Image 1 { ImageBitmap = Bitmap{ file = "shared/spinner-16-01.png"; }; }; + Image 2 { ImageBitmap = Bitmap{ file = "shared/spinner-16-02.png"; }; }; + Image 3 { ImageBitmap = Bitmap{ file = "shared/spinner-16-03.png"; }; }; + Image 4 { ImageBitmap = Bitmap{ file = "shared/spinner-16-04.png"; }; }; + Image 5 { ImageBitmap = Bitmap{ file = "shared/spinner-16-05.png"; }; }; + Image 6 { ImageBitmap = Bitmap{ file = "shared/spinner-16-06.png"; }; }; +}; + +Resource 1001 +{ + Image 1 { ImageBitmap = Bitmap{ file = "shared/spinner-32-01.png"; }; }; + Image 2 { ImageBitmap = Bitmap{ file = "shared/spinner-32-02.png"; }; }; + Image 3 { ImageBitmap = Bitmap{ file = "shared/spinner-32-03.png"; }; }; + Image 4 { ImageBitmap = Bitmap{ file = "shared/spinner-32-04.png"; }; }; + Image 5 { ImageBitmap = Bitmap{ file = "shared/spinner-32-05.png"; }; }; + Image 6 { ImageBitmap = Bitmap{ file = "shared/spinner-32-06.png"; }; }; + Image 7 { ImageBitmap = Bitmap{ file = "shared/spinner-32-07.png"; }; }; + Image 8 { ImageBitmap = Bitmap{ file = "shared/spinner-32-08.png"; }; }; + Image 9 { ImageBitmap = Bitmap{ file = "shared/spinner-32-09.png"; }; }; + Image 10 { ImageBitmap = Bitmap{ file = "shared/spinner-32-10.png"; }; }; + Image 11 { ImageBitmap = Bitmap{ file = "shared/spinner-32-11.png"; }; }; + Image 12 { ImageBitmap = Bitmap{ file = "shared/spinner-32-12.png"; }; }; +}; + +Resource 1002 +{ + Image 1 { ImageBitmap = Bitmap{ file = "shared/spinner-64-01.png"; }; }; + Image 2 { ImageBitmap = Bitmap{ file = "shared/spinner-64-02.png"; }; }; + Image 3 { ImageBitmap = Bitmap{ file = "shared/spinner-64-03.png"; }; }; + Image 4 { ImageBitmap = Bitmap{ file = "shared/spinner-64-04.png"; }; }; + Image 5 { ImageBitmap = Bitmap{ file = "shared/spinner-64-05.png"; }; }; + Image 6 { ImageBitmap = Bitmap{ file = "shared/spinner-64-06.png"; }; }; + Image 7 { ImageBitmap = Bitmap{ file = "shared/spinner-64-07.png"; }; }; + Image 8 { ImageBitmap = Bitmap{ file = "shared/spinner-64-08.png"; }; }; + Image 9 { ImageBitmap = Bitmap{ file = "shared/spinner-64-09.png"; }; }; + Image 10 { ImageBitmap = Bitmap{ file = "shared/spinner-64-10.png"; }; }; + Image 11 { ImageBitmap = Bitmap{ file = "shared/spinner-64-11.png"; }; }; + Image 12 { ImageBitmap = Bitmap{ file = "shared/spinner-64-12.png"; }; }; +}; diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 1af422bf7f00..5d4dbe77116c 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -71,6 +71,7 @@ #include #include +#include #include #include #include @@ -313,6 +314,7 @@ static ComponentInfo __FAR_DATA aComponentInfos [] = { "scrollbar", WINDOW_SCROLLBAR }, { "scrollbarbox", WINDOW_SCROLLBARBOX }, { "simpleanimation", WINDOW_CONTROL }, + { "animatedimages", WINDOW_CONTROL }, { "spinbutton", WINDOW_SPINBUTTON }, { "spinfield", WINDOW_SPINFIELD }, { "throbber", WINDOW_CONTROL }, @@ -984,22 +986,25 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, } break; case WINDOW_CONTROL: - if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase( - ::rtl::OUString::createFromAscii("simpleanimation") ) ) + if ( aServiceName.EqualsAscii( "simpleanimation" ) ) { - nWinBits |= WB_SCALE; - pNewWindow = new FixedImage( pParent, nWinBits ); + pNewWindow = new FixedImage( pParent, nWinBits | WB_SCALE ); *ppNewComp = new ::toolkit::XSimpleAnimation; } - else if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase( - ::rtl::OUString::createFromAscii("throbber") ) ) + else if ( aServiceName.EqualsAscii( "throbber" ) ) { - nWinBits |= WB_SCALE; - pNewWindow = new FixedImage( pParent, nWinBits ); + pNewWindow = new FixedImage( pParent, nWinBits | WB_SCALE ); *ppNewComp = new ::toolkit::XThrobber; } + else if ( aServiceName.EqualsAscii( "animatedimages" ) ) + { + pNewWindow = new ImageControl( pParent, nWinBits ); + *ppNewComp = new ::toolkit::AnimatedImagesPeer; + } break; - default: DBG_ERRORFILE( "UNO3!" ); + default: + OSL_ENSURE( false, "VCLXToolkit::ImplCreateWindow: unknown window type!" ); + break; } } diff --git a/toolkit/source/awt/xsimpleanimation.cxx b/toolkit/source/awt/xsimpleanimation.cxx index c7ccbde118f4..63de993e0e43 100644 --- a/toolkit/source/awt/xsimpleanimation.cxx +++ b/toolkit/source/awt/xsimpleanimation.cxx @@ -46,35 +46,28 @@ namespace toolkit //-------------------------------------------------------------------- XSimpleAnimation::XSimpleAnimation() + :mpThrobber( new Throbber_Impl( *this ) ) { DBG_CTOR( XSimpleAnimation, NULL ); - mbRepeat = sal_True; - mnStepTime = 100; - mpThrobber = new Throbber_Impl( this, mnStepTime, mbRepeat ); } //-------------------------------------------------------------------- XSimpleAnimation::~XSimpleAnimation() { DBG_DTOR( XSimpleAnimation, NULL ); - delete mpThrobber; } - //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XINTERFACE2( XSimpleAnimation, VCLXWindow, XSimpleAnimation_Base ) - - //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XTYPEPROVIDER2( XSimpleAnimation, VCLXWindow, XSimpleAnimation_Base ) - //-------------------------------------------------------------------- void SAL_CALL XSimpleAnimation::start() throw ( uno::RuntimeException ) { + ::vos::OGuard aGuard( GetMutex() ); mpThrobber->start(); } //-------------------------------------------------------------------- void SAL_CALL XSimpleAnimation::stop() throw ( uno::RuntimeException ) { + ::vos::OGuard aGuard( GetMutex() ); mpThrobber->stop(); } @@ -82,22 +75,10 @@ namespace toolkit void SAL_CALL XSimpleAnimation::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& rImageList ) throw ( uno::RuntimeException ) { + ::vos::OGuard aGuard( GetMutex() ); mpThrobber->setImageList( rImageList ); } - //-------------------------------------------------------------------- - void XSimpleAnimation::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) - { - // TODO: XSimpleAnimation::ProcessWindowEvent - //::vos::OClearableGuard aGuard( GetMutex() ); - //Reference< XSimpleAnimation > xKeepAlive( this ); - //SpinButton* pSpinButton = static_cast< SpinButton* >( GetWindow() ); - //if ( !pSpinButton ) - // return; - - VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); - } - //-------------------------------------------------------------------- void SAL_CALL XSimpleAnimation::setProperty( const ::rtl::OUString& PropertyName, const uno::Any& Value ) throw( uno::RuntimeException ) @@ -112,20 +93,14 @@ namespace toolkit case BASEPROPERTY_STEP_TIME: { sal_Int32 nStepTime( 0 ); if ( Value >>= nStepTime ) - { - mnStepTime = nStepTime; - mpThrobber->setStepTime( mnStepTime ); - } + mpThrobber->setStepTime( nStepTime ); break; } case BASEPROPERTY_REPEAT: { sal_Bool bRepeat( sal_True ); if ( Value >>= bRepeat ) - { - mbRepeat = bRepeat; - mpThrobber->setRepeat( mbRepeat ); - } + mpThrobber->setRepeat( bRepeat ); break; } default: @@ -148,10 +123,10 @@ namespace toolkit switch ( nPropertyId ) { case BASEPROPERTY_STEP_TIME: - aReturn <<= mnStepTime; + aReturn <<= mpThrobber->getStepTime(); break; case BASEPROPERTY_REPEAT: - aReturn <<= mbRepeat; + aReturn <<= mpThrobber->getRepeat(); break; default: aReturn = VCLXWindow::getProperty( PropertyName ); diff --git a/toolkit/source/awt/xthrobber.cxx b/toolkit/source/awt/xthrobber.cxx index 439fb49c1cbe..2a5d8d2d19af 100644 --- a/toolkit/source/awt/xthrobber.cxx +++ b/toolkit/source/awt/xthrobber.cxx @@ -53,11 +53,9 @@ namespace toolkit //-------------------------------------------------------------------- XThrobber::XThrobber() + :mpThrobber( new Throbber_Impl( *this ) ) { DBG_CTOR( XThrobber, NULL ); - - mpThrobber = new Throbber_Impl( this, 100, sal_True ); - InitImageList(); } @@ -65,72 +63,20 @@ namespace toolkit XThrobber::~XThrobber() { DBG_DTOR( XThrobber, NULL ); - delete mpThrobber; } - //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XINTERFACE2( XThrobber, VCLXWindow, XThrobber_Base ) - - //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XTYPEPROVIDER2( XThrobber, VCLXWindow, XThrobber_Base ) - //-------------------------------------------------------------------- void SAL_CALL XThrobber::start() throw ( uno::RuntimeException ) { + ::vos::OGuard aGuard( GetMutex() ); mpThrobber->start(); } //-------------------------------------------------------------------- void SAL_CALL XThrobber::stop() throw ( uno::RuntimeException ) - { - mpThrobber->stop(); - } - - //-------------------------------------------------------------------- - void XThrobber::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) - { - static bool bInit = false; - if ( !bInit ) - { - // Images won't be shown if set too early - mpThrobber->initImage(); - bInit = true; - } - // TODO: XSimpleAnimation::ProcessWindowEvent - //::vos::OClearableGuard aGuard( GetMutex() ); - //Reference< XSimpleAnimation > xKeepAlive( this ); - //SpinButton* pSpinButton = static_cast< SpinButton* >( GetWindow() ); - //if ( !pSpinButton ) - // return; - - VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); - } - - //-------------------------------------------------------------------- - void SAL_CALL XThrobber::setProperty( const ::rtl::OUString& PropertyName, const uno::Any& Value ) - throw( uno::RuntimeException ) { ::vos::OGuard aGuard( GetMutex() ); - - if ( GetWindow() ) - { - VCLXWindow::setProperty( PropertyName, Value ); - } - } - - //-------------------------------------------------------------------- - uno::Any SAL_CALL XThrobber::getProperty( const ::rtl::OUString& PropertyName ) - throw( uno::RuntimeException ) - { - ::vos::OGuard aGuard( GetMutex() ); - - uno::Any aReturn; - - if ( GetWindow() ) - { - aReturn = VCLXWindow::getProperty( PropertyName ); - } - return aReturn; + mpThrobber->stop(); } //-------------------------------------------------------------------- diff --git a/toolkit/source/controls/animatedimages.cxx b/toolkit/source/controls/animatedimages.cxx new file mode 100755 index 000000000000..03cb2f26f324 --- /dev/null +++ b/toolkit/source/controls/animatedimages.cxx @@ -0,0 +1,491 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_toolkit.hxx" + +#include "toolkit/controls/animatedimages.hxx" +#include "toolkit/helper/servicenames.hxx" +#include "toolkit/helper/property.hxx" +#include "toolkit/helper/unopropertyarrayhelper.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +#include +/** === end UNO includes === **/ + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::container::XContainerListener; + using ::com::sun::star::beans::XPropertySetInfo; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::awt::XControlModel; + using ::com::sun::star::awt::XAnimatedImages; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::awt::XWindowPeer; + using ::com::sun::star::util::XModifyListener; + using ::com::sun::star::awt::XToolkit; + /** === end UNO using === **/ + namespace VisualEffect = ::com::sun::star::awt::VisualEffect; + namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; + + //================================================================================================================== + //= AnimatedImagesControl + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesControl::AnimatedImagesControl() + :AnimatedImagesControl_Base() + { + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString AnimatedImagesControl::GetComponentServiceName() + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AnimatedImages" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::startAnimation( ) throw (RuntimeException) + { + Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY ); + if ( xAnimation.is() ) + xAnimation->startAnimation(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::stopAnimation( ) throw (RuntimeException) + { + Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY ); + if ( xAnimation.is() ) + xAnimation->stopAnimation(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL AnimatedImagesControl::isAnimationRunning( ) throw (RuntimeException) + { + Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY ); + if ( xAnimation.is() ) + return xAnimation->isAnimationRunning(); + return sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL AnimatedImagesControl::getImplementationName( ) throw(RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.AnimatedImagesControl" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL AnimatedImagesControl::getSupportedServiceNames() throw(RuntimeException) + { + Sequence< ::rtl::OUString > aServices( AnimatedImagesControl_Base::getSupportedServiceNames() ); + aServices.realloc( aServices.getLength() + 1 ); + aServices[ aServices.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControl ); + return aServices; + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + void lcl_updatePeer( Reference< XWindowPeer > const& i_peer, Reference< XControlModel > const& i_model ) + { + const Reference< XModifyListener > xPeerModify( i_peer, UNO_QUERY ); + if ( xPeerModify.is() ) + { + EventObject aEvent; + aEvent.Source = i_model; + xPeerModify->modified( aEvent ); + } + } + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL AnimatedImagesControl::setModel( const Reference< XControlModel >& i_rModel ) throw ( RuntimeException ) + { + const Reference< XAnimatedImages > xOldContainer( getModel(), UNO_QUERY ); + const Reference< XAnimatedImages > xNewContainer( i_rModel, UNO_QUERY ); + + if ( !AnimatedImagesControl_Base::setModel( i_rModel ) ) + return sal_False; + + if ( xOldContainer.is() ) + xOldContainer->removeContainerListener( this ); + + if ( xNewContainer.is() ) + xNewContainer->addContainerListener( this ); + + lcl_updatePeer( getPeer(), getModel() ); + + return sal_True; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::createPeer( const Reference< XToolkit >& i_toolkit, const Reference< XWindowPeer >& i_parentPeer ) throw(RuntimeException) + { + AnimatedImagesControl_Base::createPeer( i_toolkit, i_parentPeer ); + + lcl_updatePeer( getPeer(), getModel() ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) + { + const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY ); + if ( xPeerListener.is() ) + xPeerListener->elementInserted( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) + { + const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY ); + if ( xPeerListener.is() ) + xPeerListener->elementRemoved( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) + { + const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY ); + if ( xPeerListener.is() ) + xPeerListener->elementReplaced( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::disposing( const EventObject& i_event ) throw (RuntimeException) + { + UnoControlBase::disposing( i_event ); + } + + //================================================================================================================== + //= AnimatedImagesControlModel_Data + //================================================================================================================== + struct AnimatedImagesControlModel_Data + { + ::std::vector< Sequence< ::rtl::OUString > > aImageSets; + }; + + namespace + { + void lcl_checkIndex( const AnimatedImagesControlModel_Data& i_data, const sal_Int32 i_index, const Reference< XInterface >& i_context, + const bool i_forInsert = false ) + { + if ( ( i_index < 0 ) || ( size_t( i_index ) > i_data.aImageSets.size() + ( i_forInsert ? 1 : 0 ) ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), i_context ); + } + + void lcl_notify( ::osl::ClearableMutexGuard& i_guard, ::cppu::OBroadcastHelper& i_broadcaseHelper, + void ( SAL_CALL XContainerListener::*i_notificationMethod )( const ContainerEvent& ), + const sal_Int32 i_accessor, const Sequence< ::rtl::OUString >& i_imageURLs, const Reference< XInterface >& i_context ) + { + ::cppu::OInterfaceContainerHelper* pContainerListeners = i_broadcaseHelper.getContainer( XContainerListener::static_type() ); + if ( pContainerListeners == NULL ) + return; + + ContainerEvent aEvent; + aEvent.Source = i_context; + aEvent.Accessor <<= i_accessor; + aEvent.Element <<= i_imageURLs; + + i_guard.clear(); + pContainerListeners->notifyEach( i_notificationMethod, aEvent ); + } + } + + //================================================================================================================== + //= AnimatedImagesControlModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesControlModel::AnimatedImagesControlModel() + :m_pData( new AnimatedImagesControlModel_Data ) + { + ImplRegisterProperty( BASEPROPERTY_AUTO_REPEAT ); + ImplRegisterProperty( BASEPROPERTY_BORDER ); + ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR ); + ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); + ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); + ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE ); + ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); + ImplRegisterProperty( BASEPROPERTY_HELPURL ); + ImplRegisterProperty( BASEPROPERTY_IMAGE_SCALE_MODE ); + ImplRegisterProperty( BASEPROPERTY_STEP_TIME ); + } + + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesControlModel::AnimatedImagesControlModel( const AnimatedImagesControlModel& i_copySource ) + :AnimatedImagesControlModel_Base( i_copySource ) + ,m_pData( new AnimatedImagesControlModel_Data( *i_copySource.m_pData ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesControlModel::~AnimatedImagesControlModel() + { + } + + //------------------------------------------------------------------------------------------------------------------ + UnoControlModel* AnimatedImagesControlModel::Clone() const + { + return new AnimatedImagesControlModel( *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XPropertySetInfo > SAL_CALL AnimatedImagesControlModel::getPropertySetInfo( ) throw(RuntimeException) + { + static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL AnimatedImagesControlModel::getServiceName() throw(RuntimeException) + { + return ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControlModel ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL AnimatedImagesControlModel::getImplementationName( ) throw(RuntimeException) + { + return ::rtl::OUString::createFromAscii( "org.openoffice.comp.toolkit.AnimatedImagesControlModel" ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL AnimatedImagesControlModel::getSupportedServiceNames() throw(RuntimeException) + { + Sequence< ::rtl::OUString > aServiceNames(2); + aServiceNames[0] = ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControlModel ); + aServiceNames[1] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.UnoControlModel" ); + return aServiceNames; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 i_handle, const Any& i_value ) throw (Exception) + { + switch ( i_handle ) + { + case BASEPROPERTY_IMAGE_SCALE_MODE: + { + sal_Int16 nImageScaleMode( ImageScaleMode::Anisotropic ); + OSL_VERIFY( i_value >>= nImageScaleMode ); // convertFastPropertyValue ensures that this has the proper type + if ( ( nImageScaleMode != ImageScaleMode::None ) + && ( nImageScaleMode != ImageScaleMode::Isotropic ) + && ( nImageScaleMode != ImageScaleMode::Anisotropic ) + ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + } + break; + } + + AnimatedImagesControlModel_Base::setFastPropertyValue_NoBroadcast( i_handle, i_value ); + } + + //------------------------------------------------------------------------------------------------------------------ + Any AnimatedImagesControlModel::ImplGetDefaultValue( sal_uInt16 i_propertyId ) const + { + switch ( i_propertyId ) + { + case BASEPROPERTY_DEFAULTCONTROL: + return makeAny( ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControl ) ); + + case BASEPROPERTY_BORDER: + return makeAny( VisualEffect::NONE ); + + case BASEPROPERTY_STEP_TIME: + return makeAny( (sal_Int32) 100 ); + + case BASEPROPERTY_AUTO_REPEAT: + return makeAny( (sal_Bool)sal_True ); + + case BASEPROPERTY_IMAGE_SCALE_MODE: + return makeAny( ImageScaleMode::None ); + + default: + return UnoControlModel::ImplGetDefaultValue( i_propertyId ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + ::cppu::IPropertyArrayHelper& SAL_CALL AnimatedImagesControlModel::getInfoHelper() + { + static UnoPropertyArrayHelper* pHelper = NULL; + if ( !pHelper ) + { + Sequence< sal_Int32 > aIDs = ImplGetPropertyIds(); + pHelper = new UnoPropertyArrayHelper( aIDs ); + } + return *pHelper; + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL AnimatedImagesControlModel::getStepTime() throw (RuntimeException) + { + sal_Int32 nStepTime( 100 ); + OSL_VERIFY( getPropertyValue( GetPropertyName( BASEPROPERTY_STEP_TIME ) ) >>= nStepTime ); + return nStepTime; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::setStepTime( ::sal_Int32 i_stepTime ) throw (RuntimeException) + { + setPropertyValue( GetPropertyName( BASEPROPERTY_STEP_TIME ), makeAny( i_stepTime ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL AnimatedImagesControlModel::getAutoRepeat() throw (RuntimeException) + { + sal_Bool bAutoRepeat( sal_True ); + OSL_VERIFY( getPropertyValue( GetPropertyName( BASEPROPERTY_AUTO_REPEAT ) ) >>= bAutoRepeat ); + return bAutoRepeat; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::setAutoRepeat( ::sal_Bool i_autoRepeat ) throw (RuntimeException) + { + setPropertyValue( GetPropertyName( BASEPROPERTY_AUTO_REPEAT ), makeAny( i_autoRepeat ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int16 SAL_CALL AnimatedImagesControlModel::getScaleMode() throw (RuntimeException) + { + sal_Int16 nImageScaleMode( ImageScaleMode::Anisotropic ); + OSL_VERIFY( getPropertyValue( GetPropertyName( BASEPROPERTY_IMAGE_SCALE_MODE ) ) >>= nImageScaleMode ); + return nImageScaleMode; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::setScaleMode( ::sal_Int16 i_scaleMode ) throw (IllegalArgumentException, RuntimeException) + { + setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGE_SCALE_MODE ), makeAny( i_scaleMode ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL AnimatedImagesControlModel::getImageSetCount( ) throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose ) + throw DisposedException(); + + return m_pData->aImageSets.size(); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL AnimatedImagesControlModel::getImageSet( ::sal_Int32 i_index ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose ) + throw DisposedException(); + + lcl_checkIndex( *m_pData, i_index, *this ); + + return m_pData->aImageSets[ i_index ]; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::insertImageSet( ::sal_Int32 i_index, const Sequence< ::rtl::OUString >& i_imageURLs ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // sanity checks + if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose ) + throw DisposedException(); + + lcl_checkIndex( *m_pData, i_index, *this, true ); + + // actaul insertion + m_pData->aImageSets.insert( m_pData->aImageSets.begin() + i_index, i_imageURLs ); + + // listener notification + lcl_notify( aGuard, BrdcstHelper, &XContainerListener::elementInserted, i_index, i_imageURLs, *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::replaceImageSet( ::sal_Int32 i_index, const Sequence< ::rtl::OUString >& i_imageURLs ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // sanity checks + if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose ) + throw DisposedException(); + + lcl_checkIndex( *m_pData, i_index, *this ); + + // actaul insertion + m_pData->aImageSets[ i_index ] = i_imageURLs; + + // listener notification + lcl_notify( aGuard, BrdcstHelper, &XContainerListener::elementReplaced, i_index, i_imageURLs, *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::removeImageSet( ::sal_Int32 i_index ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // sanity checks + if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose ) + throw DisposedException(); + + lcl_checkIndex( *m_pData, i_index, *this ); + + // actual removal + ::std::vector< Sequence< ::rtl::OUString > >::iterator removalPos = m_pData->aImageSets.begin() + i_index; + Sequence< ::rtl::OUString > aRemovedElement( *removalPos ); + m_pData->aImageSets.erase( removalPos ); + + // listener notification + lcl_notify( aGuard, BrdcstHelper, &XContainerListener::elementRemoved, i_index, aRemovedElement, *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::addContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) + { + BrdcstHelper.addListener( XContainerListener::static_type(), i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::removeContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) + { + BrdcstHelper.removeListener( XContainerListener::static_type(), i_listener ); + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... diff --git a/toolkit/source/controls/makefile.mk b/toolkit/source/controls/makefile.mk index 1ce9f7b22c8c..8a776c87ff1f 100644 --- a/toolkit/source/controls/makefile.mk +++ b/toolkit/source/controls/makefile.mk @@ -59,7 +59,9 @@ SLOFILES= \ $(SLO)$/tkscrollbar.obj \ $(SLO)$/tkspinbutton.obj \ $(SLO)$/tksimpleanimation.obj \ - $(SLO)$/tkthrobber.obj + $(SLO)$/tkthrobber.obj \ + $(SLO)$/animatedimages.obj \ + $(SLO)$/spinningprogress.obj \ # --- Targets ------------------------------------------------------ diff --git a/toolkit/source/controls/spinningprogress.cxx b/toolkit/source/controls/spinningprogress.cxx new file mode 100755 index 000000000000..e901d2a5cca2 --- /dev/null +++ b/toolkit/source/controls/spinningprogress.cxx @@ -0,0 +1,151 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_toolkit.hxx" + +#include "toolkit/controls/spinningprogress.hxx" +#include "toolkit/helper/servicenames.hxx" +#include "toolkit/helper/unopropertyarrayhelper.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include +#include + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::beans::XPropertySetInfo; + /** === end UNO using === **/ + + //================================================================================================================== + //= SpinningProgressControlModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + SpinningProgressControlModel::SpinningProgressControlModel() + { + // default image sets + osl_incrementInterlockedCount( &m_refCount ); + { + sal_Char const* const pResolutions[] = { "16", "32", "64" }; + size_t const nImageCounts[] = { 6, 12, 12 }; + + for ( size_t set=0; set<3; ++set ) + { + ::std::vector< ::rtl::OUString > aImageURLs; + aImageURLs.reserve( nImageCounts[set] ); + + for ( size_t i=0; i( &aImageURLs[0], aImageURLs.size() ) ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + osl_decrementInterlockedCount( &m_refCount ); + } + + //------------------------------------------------------------------------------------------------------------------ + SpinningProgressControlModel::SpinningProgressControlModel( const SpinningProgressControlModel& i_copySource ) + :SpinningProgressControlModel_Base( i_copySource ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + SpinningProgressControlModel::~SpinningProgressControlModel() + { + } + + //------------------------------------------------------------------------------------------------------------------ + UnoControlModel* SpinningProgressControlModel::Clone() const + { + return new SpinningProgressControlModel( *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XPropertySetInfo > SAL_CALL SpinningProgressControlModel::getPropertySetInfo( ) throw(RuntimeException) + { + static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL SpinningProgressControlModel::getServiceName() throw(RuntimeException) + { + return ::rtl::OUString::createFromAscii( szServiceName_SpinningProgressControlModel ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL SpinningProgressControlModel::getImplementationName( ) throw(RuntimeException) + { + return ::rtl::OUString::createFromAscii( "org.openoffice.comp.toolkit.SpinningProgressControlModel" ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL SpinningProgressControlModel::getSupportedServiceNames() throw(RuntimeException) + { + Sequence< ::rtl::OUString > aServiceNames(3); + aServiceNames[0] = ::rtl::OUString::createFromAscii( szServiceName_SpinningProgressControlModel ); + aServiceNames[1] = ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControlModel ); + aServiceNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.UnoControlModel" ); + return aServiceNames; + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... diff --git a/toolkit/source/controls/tksimpleanimation.cxx b/toolkit/source/controls/tksimpleanimation.cxx index 3d89bf59af82..6ad33608f6ee 100644 --- a/toolkit/source/controls/tksimpleanimation.cxx +++ b/toolkit/source/controls/tksimpleanimation.cxx @@ -129,27 +129,6 @@ namespace toolkit return ::rtl::OUString::createFromAscii( "SimpleAnimation" ); } - //-------------------------------------------------------------------- - uno::Any UnoSimpleAnimationControl::queryAggregation( const uno::Type & rType ) - throw( uno::RuntimeException ) - { - uno::Any aRet = UnoControlBase::queryAggregation( rType ); - if ( !aRet.hasValue() ) - aRet = UnoSimpleAnimationControl_Base::queryInterface( rType ); - return aRet; - } - - //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoSimpleAnimationControl, UnoControlBase, UnoSimpleAnimationControl_Base ) - - //-------------------------------------------------------------------- - void UnoSimpleAnimationControl::dispose() throw( uno::RuntimeException ) - { - ::osl::ClearableMutexGuard aGuard( GetMutex() ); - - UnoControl::dispose(); - } - //-------------------------------------------------------------------- ::rtl::OUString SAL_CALL UnoSimpleAnimationControl::getImplementationName() throw( uno::RuntimeException ) @@ -161,26 +140,20 @@ namespace toolkit uno::Sequence< ::rtl::OUString > SAL_CALL UnoSimpleAnimationControl::getSupportedServiceNames() throw( uno::RuntimeException ) { - uno::Sequence< ::rtl::OUString > aServices( UnoControlBase::getSupportedServiceNames() ); + uno::Sequence< ::rtl::OUString > aServices( UnoSimpleAnimationControl_Base::getSupportedServiceNames() ); aServices.realloc( aServices.getLength() + 1 ); aServices[ aServices.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_UnoSimpleAnimationControl ); return aServices; } - //-------------------------------------------------------------------- - void UnoSimpleAnimationControl::createPeer( const uno::Reference< awt::XToolkit > &rxToolkit, - const uno::Reference< awt::XWindowPeer > &rParentPeer ) - throw( uno::RuntimeException ) - { - UnoControl::createPeer( rxToolkit, rParentPeer ); - } - //-------------------------------------------------------------------- void SAL_CALL UnoSimpleAnimationControl::start() throw ( uno::RuntimeException ) { - ::osl::MutexGuard aGuard( GetMutex() ); - - uno::Reference< XSimpleAnimation > xAnimation( getPeer(), uno::UNO_QUERY ); + uno::Reference< XSimpleAnimation > xAnimation; + { + ::osl::MutexGuard aGuard( GetMutex() ); + xAnimation.set( getPeer(), uno::UNO_QUERY ); + } if ( xAnimation.is() ) xAnimation->start(); } @@ -188,9 +161,11 @@ namespace toolkit //-------------------------------------------------------------------- void SAL_CALL UnoSimpleAnimationControl::stop() throw ( uno::RuntimeException ) { - ::osl::MutexGuard aGuard( GetMutex() ); - - uno::Reference< XSimpleAnimation > xAnimation( getPeer(), uno::UNO_QUERY ); + uno::Reference< XSimpleAnimation > xAnimation; + { + ::osl::MutexGuard aGuard( GetMutex() ); + xAnimation.set( getPeer(), uno::UNO_QUERY ); + } if ( xAnimation.is() ) xAnimation->stop(); } @@ -199,9 +174,11 @@ namespace toolkit void SAL_CALL UnoSimpleAnimationControl::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& ImageList ) throw ( uno::RuntimeException ) { - ::osl::MutexGuard aGuard( GetMutex() ); - - uno::Reference< XSimpleAnimation > xAnimation( getPeer(), uno::UNO_QUERY ); + uno::Reference< XSimpleAnimation > xAnimation; + { + ::osl::MutexGuard aGuard( GetMutex() ); + xAnimation.set( getPeer(), uno::UNO_QUERY ); + } if ( xAnimation.is() ) xAnimation->setImageList( ImageList ); } diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx index 91d202409e86..e55f4809ed0b 100644 --- a/toolkit/source/controls/unocontrolmodel.cxx +++ b/toolkit/source/controls/unocontrolmodel.cxx @@ -532,6 +532,8 @@ void UnoControlModel::dispose( ) throw(::com::sun::star::uno::RuntimeException) aEvt.Source = (::com::sun::star::uno::XAggregation*)(::cppu::OWeakAggObject*)this; maDisposeListeners.disposeAndClear( aEvt ); + BrdcstHelper.aLC.disposeAndClear( aEvt ); + // let the property set helper notify our property listeners OPropertySetHelper::disposing(); } diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index 3a83465a3218..1e90c0172e83 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -66,6 +66,7 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::awt::XDevice; using ::com::sun::star::awt::FontDescriptor; using ::com::sun::star::style::VerticalAlignment; +using ::com::sun::star::graphic::XGraphic; struct ImplPropertyInfo { @@ -181,7 +182,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_3 ( "FormatKey", FORMATKEY, sal_Int32, BOUND, MAYBEVOID, TRANSIENT ), DECL_PROP_3 ( "FormatsSupplier", FORMATSSUPPLIER, Reference< ::com::sun::star::util::XNumberFormatsSupplier >, BOUND, MAYBEVOID, TRANSIENT ), - DECL_PROP_2 ( "Graphic", GRAPHIC, Reference< ::com::sun::star::graphic::XGraphic >, BOUND, TRANSIENT ), + DECL_PROP_2 ( "Graphic", GRAPHIC, Reference< XGraphic >, BOUND, TRANSIENT ), DECL_PROP_2 ( "HelpText", HELPTEXT, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "HelpURL", HELPURL, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "HideInactiveSelection", HIDEINACTIVESELECTION, bool, BOUND, MAYBEDEFAULT ), @@ -218,6 +219,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_2 ( "PushButtonType", PUSHBUTTONTYPE, sal_Int16, BOUND, MAYBEDEFAULT), DECL_PROP_2 ( "ReadOnly", READONLY, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "Repeat", REPEAT, bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "AutoRepeat", AUTO_REPEAT, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "RepeatDelay", REPEAT_DELAY, sal_Int32, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ScaleImage", SCALEIMAGE, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ScaleMode", IMAGE_SCALE_MODE, sal_Int16, BOUND, MAYBEDEFAULT ), diff --git a/toolkit/source/helper/registerservices.cxx b/toolkit/source/helper/registerservices.cxx index 477032538af8..165caa38f95d 100644 --- a/toolkit/source/helper/registerservices.cxx +++ b/toolkit/source/helper/registerservices.cxx @@ -51,6 +51,8 @@ #include "toolkit/controls/tkspinbutton.hxx" #include #include +#include +#include #include #include "toolkit/dllapi.h" @@ -135,6 +137,14 @@ namespace toolkit if ( pRet ) \ return pRet; \ +#define TRY_OOO_FACTORY( ImplName, ServiceName ) \ + pRet = tryCreateFactory( sImplementationName, "org.openoffice.comp.toolkit." #ImplName, \ + ServiceName, NULL, \ + ImplName##_CreateInstance, xServiceFactory \ + ); \ + if ( pRet ) \ + return pRet; \ + using namespace toolkit; IMPL_CREATEINSTANCE2( VCLXToolkit ) @@ -195,6 +205,9 @@ IMPL_CREATEINSTANCE( UnoSimpleAnimationControl ) IMPL_CREATEINSTANCE( UnoSimpleAnimationControlModel ) IMPL_CREATEINSTANCE( UnoThrobberControl ) IMPL_CREATEINSTANCE( UnoThrobberControlModel ) +IMPL_CREATEINSTANCE( AnimatedImagesControl ) +IMPL_CREATEINSTANCE( AnimatedImagesControlModel ) +IMPL_CREATEINSTANCE( SpinningProgressControlModel ) extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL TreeControl_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL TreeControlModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); @@ -288,6 +301,9 @@ TOOLKIT_DLLPUBLIC void* SAL_CALL component_getFactory( const sal_Char* sImplemen CHECKANDCREATEFACTORY( UnoSimpleAnimationControl, szServiceName_UnoSimpleAnimationControl, szServiceName2_UnoSimpleAnimationControl ) CHECKANDCREATEFACTORY( UnoThrobberControlModel, szServiceName_UnoThrobberControlModel, szServiceName2_UnoThrobberControlModel ) CHECKANDCREATEFACTORY( UnoThrobberControl, szServiceName_UnoThrobberControl, szServiceName2_UnoThrobberControl ) + TRY_OOO_FACTORY( AnimatedImagesControl, szServiceName_AnimatedImagesControl ) + TRY_OOO_FACTORY( AnimatedImagesControlModel, szServiceName_AnimatedImagesControlModel ) + TRY_OOO_FACTORY( SpinningProgressControlModel, szServiceName_SpinningProgressControlModel ) CHECKANDCREATEFACTORY( UnoFixedHyperlinkControl, szServiceName_UnoControlFixedHyperlink, NULL ) CHECKANDCREATEFACTORY( UnoControlFixedHyperlinkModel, szServiceName_UnoControlFixedHyperlinkModel, NULL ) CHECKANDCREATEFACTORY( GridControl, szServiceName_GridControl, NULL ); diff --git a/toolkit/source/helper/servicenames.cxx b/toolkit/source/helper/servicenames.cxx index f57f52f13e57..afd23dd53af8 100644 --- a/toolkit/source/helper/servicenames.cxx +++ b/toolkit/source/helper/servicenames.cxx @@ -92,6 +92,9 @@ const sal_Char __FAR_DATA szServiceName_TreeControl[] = "com.sun.star.awt.tree.T const sal_Char __FAR_DATA szServiceName_TreeControlModel[] = "com.sun.star.awt.tree.TreeControlModel"; const sal_Char __FAR_DATA szServiceName_MutableTreeDataModel[] = "com.sun.star.awt.tree.MutableTreeDataModel"; const sal_Char __FAR_DATA szServiceName_UnoSimpleAnimationControlModel[] = "com.sun.star.awt.UnoSimpleAnimationControlModel", szServiceName2_UnoSimpleAnimationControlModel[] = "com.sun.star.awt.UnoControlSimpleAnimationModel"; +const sal_Char __FAR_DATA szServiceName_AnimatedImagesControl[] = "com.sun.star.awt.AnimatedImagesControl"; +const sal_Char __FAR_DATA szServiceName_AnimatedImagesControlModel[] = "com.sun.star.awt.AnimatedImagesControlModel"; +const sal_Char __FAR_DATA szServiceName_SpinningProgressControlModel[] = "com.sun.star.awt.SpinningProgressControlModel"; const sal_Char __FAR_DATA szServiceName_UnoSimpleAnimationControl[] = "com.sun.star.awt.UnoSimpleAnimationControl", szServiceName2_UnoSimpleAnimationControl[] = "com.sun.star.awt.UnoControlSimpleAnimation"; const sal_Char __FAR_DATA szServiceName_UnoThrobberControlModel[] = "com.sun.star.awt.UnoThrobberControlModel", szServiceName2_UnoThrobberControlModel[] = "com.sun.star.awt.UnoControlThrobberModel"; const sal_Char __FAR_DATA szServiceName_UnoThrobberControl[] = "com.sun.star.awt.UnoThrobberControl", szServiceName2_UnoThrobberControl[] = "com.sun.star.awt.UnoControlThrobber"; diff --git a/toolkit/source/helper/throbberimpl.cxx b/toolkit/source/helper/throbberimpl.cxx index 7a8e260ab4b8..5eb6b838a924 100644 --- a/toolkit/source/helper/throbberimpl.cxx +++ b/toolkit/source/helper/throbberimpl.cxx @@ -28,7 +28,7 @@ #include #include -#include +#include //........................................................................ namespace toolkit @@ -37,14 +37,14 @@ namespace toolkit using namespace ::com::sun::star; //-------------------------------------------------------------------- - Throbber_Impl::Throbber_Impl( uno::Reference< VCLXWindow > xParent, - sal_Int32 nStepTime, - sal_Bool bRepeat ) + Throbber_Impl::Throbber_Impl( VCLXWindow& i_rParent ) :mrMutex( Application::GetSolarMutex() ) + ,mrParent( i_rParent ) + ,mbRepeat( sal_True ) + ,mnStepTime( 100 ) + ,mnCurStep( 0 ) + ,mnStepCount( 0 ) { - mxParent = xParent; - mbRepeat = bRepeat; - mnStepTime = nStepTime; maWaitTimer.SetTimeout( mnStepTime ); maWaitTimer.SetTimeoutHdl( LINK( this, Throbber_Impl, TimeOutHdl ) ); } @@ -53,59 +53,59 @@ namespace toolkit Throbber_Impl::~Throbber_Impl() { maWaitTimer.Stop(); - mxParent = NULL; } //-------------------------------------------------------------------- - void Throbber_Impl::start() throw ( uno::RuntimeException ) + void Throbber_Impl::start() { - ::vos::OGuard aGuard( GetMutex() ); - - mnCurStep = 0; + DBG_TESTSOLARMUTEX(); maWaitTimer.Start(); } //-------------------------------------------------------------------- - void Throbber_Impl::stop() throw ( uno::RuntimeException ) + void Throbber_Impl::stop() { - ::vos::OGuard aGuard( GetMutex() ); - + DBG_TESTSOLARMUTEX(); maWaitTimer.Stop(); } //-------------------------------------------------------------------- - void Throbber_Impl::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& rImageList ) - throw ( uno::RuntimeException ) + bool Throbber_Impl::isRunning() const { - ::vos::OGuard aGuard( GetMutex() ); - - maImageList = rImageList; + DBG_TESTSOLARMUTEX(); + return maWaitTimer.IsActive(); + } - mnStepCount = maImageList.getLength(); - FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() ); - if ( pImage ) + //-------------------------------------------------------------------- + namespace + { + void lcl_setImage( FixedImage& i_fixedImage, Image const& i_image ) { - if ( mnStepCount ) - pImage->SetImage( maImageList[ 0 ] ); + ImageControl* pImageControl = dynamic_cast< ImageControl* >( &i_fixedImage ); + if ( pImageControl != NULL ) + pImageControl->SetBitmap( i_image.GetBitmapEx() ); else - pImage->SetImage( Image() ); + i_fixedImage.SetImage( i_image ); } } //-------------------------------------------------------------------- - void Throbber_Impl::initImage() - throw ( uno::RuntimeException ) + void Throbber_Impl::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& rImageList ) { - FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() ); - if ( pImage && maImageList.getLength() ) - pImage->SetImage( maImageList[ 0 ] ); + DBG_TESTSOLARMUTEX(); + + maImageList = rImageList; + + mnStepCount = maImageList.getLength(); + FixedImage* pFixedImage = dynamic_cast< FixedImage* >( mrParent.GetWindow() ); + if ( pFixedImage ) + lcl_setImage( *pFixedImage, mnStepCount ? maImageList[ 0 ] : Image() ); } //-------------------------------------------------------------------- sal_Bool Throbber_Impl::isHCMode() - throw ( uno::RuntimeException ) { - FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() ); + FixedImage* pImage = dynamic_cast< FixedImage* >( mrParent.GetWindow() ); if ( pImage ) return pImage->GetSettings().GetStyleSettings().GetHighContrastMode(); else @@ -116,18 +116,29 @@ namespace toolkit IMPL_LINK( Throbber_Impl, TimeOutHdl, Throbber_Impl*, EMPTYARG ) { ::vos::OGuard aGuard( GetMutex() ); + if ( !maImageList.getLength() ) + return 0; - FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() ); - - if ( !pImage || !maImageList.getLength() ) + FixedImage* pFixedImage = dynamic_cast< FixedImage* >( mrParent.GetWindow() ); + if ( pFixedImage == NULL ) return 0; if ( mnCurStep < mnStepCount - 1 ) mnCurStep += 1; else - mnCurStep = 0; + { + if ( mbRepeat ) + { + // start over + mnCurStep = 0; + } + else + { + stop(); + } + } - pImage->SetImage( maImageList[ mnCurStep ] ); + lcl_setImage( *pFixedImage, maImageList[ mnCurStep ] ); return 0; } diff --git a/toolkit/util/tk.component b/toolkit/util/tk.component index e782283c39eb..74637c45375f 100644 --- a/toolkit/util/tk.component +++ b/toolkit/util/tk.component @@ -257,6 +257,15 @@ + + + + + + + + + -- cgit From 0b4116b8c093ec6e786bd66945ad21ab62ea581c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 6 Oct 2010 21:09:05 +0200 Subject: dba34b: GCC WaE --- toolkit/source/awt/animatedimagespeer.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toolkit') diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx index e4cc832da384..6acf946930be 100755 --- a/toolkit/source/awt/animatedimagespeer.cxx +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -136,7 +136,7 @@ namespace toolkit const size_t nImageSetCount = i_data.aCachedImageSets.size(); ::std::vector< Size > aImageSizes( nImageSetCount ); - for ( sal_Int32 nImageSet = 0; nImageSet < nImageSetCount; ++nImageSet ) + for ( sal_Int32 nImageSet = 0; size_t( nImageSet ) < nImageSetCount; ++nImageSet ) { Sequence< ::rtl::OUString > const& rImageSet( i_data.aCachedImageSets[ nImageSet ] ); if ( rImageSet.getLength() ) @@ -166,7 +166,7 @@ namespace toolkit // found a set? Sequence< Reference< XGraphic > > aImages; - if ( ( nPreferredSet >= 0 ) && ( nPreferredSet < nImageSetCount ) ) + if ( ( nPreferredSet >= 0 ) && ( size_t( nPreferredSet ) < nImageSetCount ) ) { // => set the images Sequence< ::rtl::OUString > const& rImageSet( i_data.aCachedImageSets[ nPreferredSet ] ); -- cgit From 381af19adb8a081296f4322f8fd880dfba33a1fe Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 7 Oct 2010 13:22:07 +0200 Subject: dba34b: outsourced the Throbber_Impl from toolkit to VCL, promoted to a 'real' control --- toolkit/inc/toolkit/awt/xsimpleanimation.hxx | 4 - toolkit/inc/toolkit/awt/xthrobber.hxx | 5 +- toolkit/inc/toolkit/helper/throbberimpl.hxx | 89 ---------------- toolkit/source/awt/animatedimagespeer.cxx | 49 ++++++--- toolkit/source/awt/vclxtoolkit.cxx | 14 ++- toolkit/source/awt/xsimpleanimation.cxx | 85 ++++++++------- toolkit/source/awt/xthrobber.cxx | 28 +++-- toolkit/source/helper/makefile.mk | 1 - toolkit/source/helper/throbberimpl.cxx | 149 --------------------------- 9 files changed, 114 insertions(+), 310 deletions(-) delete mode 100644 toolkit/inc/toolkit/helper/throbberimpl.hxx delete mode 100644 toolkit/source/helper/throbberimpl.cxx (limited to 'toolkit') diff --git a/toolkit/inc/toolkit/awt/xsimpleanimation.hxx b/toolkit/inc/toolkit/awt/xsimpleanimation.hxx index 673c7eaddf61..9e6043b7d9ef 100644 --- a/toolkit/inc/toolkit/awt/xsimpleanimation.hxx +++ b/toolkit/inc/toolkit/awt/xsimpleanimation.hxx @@ -38,7 +38,6 @@ //........................................................................ namespace toolkit { - class Throbber_Impl; //........................................................................ //==================================================================== @@ -50,9 +49,6 @@ namespace toolkit class XSimpleAnimation : public XSimpleAnimation_Base { - private: - ::boost::scoped_ptr< Throbber_Impl > mpThrobber; - public: XSimpleAnimation(); diff --git a/toolkit/inc/toolkit/awt/xthrobber.hxx b/toolkit/inc/toolkit/awt/xthrobber.hxx index fa0df0047180..67015e049a48 100644 --- a/toolkit/inc/toolkit/awt/xthrobber.hxx +++ b/toolkit/inc/toolkit/awt/xthrobber.hxx @@ -40,7 +40,6 @@ namespace toolkit { //........................................................................ - class Throbber_Impl; //==================================================================== //= XThrobber @@ -53,7 +52,6 @@ namespace toolkit ,public ::boost::noncopyable { private: - Throbber_Impl *mpThrobber; void SAL_CALL InitImageList() throw(::com::sun::star::uno::RuntimeException); public: @@ -66,6 +64,9 @@ namespace toolkit virtual void SAL_CALL start() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL stop() throw (::com::sun::star::uno::RuntimeException); + // VCLXWindow + virtual void SetWindow( Window* pWindow ); + private: XThrobber( const XThrobber& ); // never implemented XThrobber& operator=( const XThrobber& ); // never implemented diff --git a/toolkit/inc/toolkit/helper/throbberimpl.hxx b/toolkit/inc/toolkit/helper/throbberimpl.hxx deleted file mode 100644 index 92fb177fd89d..000000000000 --- a/toolkit/inc/toolkit/helper/throbberimpl.hxx +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _TOOLKIT_HELPER_THROBBERIMPL_HXX_ -#define _TOOLKIT_HELPER_THROBBERIMPL_HXX_ - -#include -#include - -#include -#include -#include - -//........................................................................ -namespace toolkit -//........................................................................ -{ - - class Throbber_Impl - { - private: - vos::IMutex& mrMutex; // Reference to SolarMutex - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > > maImageList; - VCLXWindow& mrParent; - - sal_Bool mbRepeat; - sal_Int32 mnStepTime; - sal_Int32 mnCurStep; - sal_Int32 mnStepCount; - AutoTimer maWaitTimer; - - DECL_LINK( TimeOutHdl, Throbber_Impl* ); - - vos::IMutex& GetMutex() { return mrMutex; } - - public: - Throbber_Impl( VCLXWindow& i_rParent ); - ~Throbber_Impl(); - - // Properties - void setStepTime( sal_Int32 nStepTime ) { mnStepTime = nStepTime; } - sal_Int32 getStepTime() const { return mnStepTime; } - - void setRepeat( sal_Bool bRepeat ) { mbRepeat = bRepeat; } - sal_Bool getRepeat() const { return mbRepeat; } - - Window const* getWindow() const { return mrParent.GetWindow(); } - Window* getWindow() { return mrParent.GetWindow(); } - - // XSimpleAnimation - void start(); - void stop(); - bool isRunning() const; - void setImageList( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& ImageList ); - - // Helpers - sal_Bool isHCMode(); - }; - -//........................................................................ -} // namespacetoolkit -//........................................................................ - -#endif //_TOOLKIT_HELPER_THROBBERIMPL_HXX_ - diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx index 6acf946930be..4130b841f34a 100755 --- a/toolkit/source/awt/animatedimagespeer.cxx +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -28,7 +28,6 @@ #include "toolkit/awt/animatedimagespeer.hxx" #include "toolkit/helper/property.hxx" -#include "toolkit/helper/throbberimpl.hxx" /** === begin UNO includes === **/ #include @@ -43,7 +42,7 @@ #include #include #include -#include +#include #include @@ -80,11 +79,11 @@ namespace toolkit //================================================================================================================== struct AnimatedImagesPeer_Data { - Throbber_Impl aThrobber; + AnimatedImagesPeer& rAntiImpl; ::std::vector< Sequence< ::rtl::OUString > > aCachedImageSets; - AnimatedImagesPeer_Data( VCLXWindow& i_window ) - :aThrobber( i_window ) + AnimatedImagesPeer_Data( AnimatedImagesPeer& i_antiImpl ) + :rAntiImpl( i_antiImpl ) ,aCachedImageSets() { } @@ -124,8 +123,8 @@ namespace toolkit //-------------------------------------------------------------------------------------------------------------- void lcl_updateImageList_nothrow( AnimatedImagesPeer_Data& i_data ) { - const Window* pWindow = i_data.aThrobber.getWindow(); - if ( pWindow == NULL ) + Throbber* pThrobber = dynamic_cast< Throbber* >( i_data.rAntiImpl.GetWindow() ); + if ( pThrobber == NULL ) return; try @@ -146,7 +145,7 @@ namespace toolkit } // find the set with the smallest difference between window size and image size - const ::Size aWindowSizePixel = pWindow->GetSizePixel(); + const ::Size aWindowSizePixel = pThrobber->GetSizePixel(); sal_Int32 nPreferredSet = -1; long nMinimalDistance = ::std::numeric_limits< long >::max(); for ( ::std::vector< Size >::const_iterator check = aImageSizes.begin(); @@ -180,7 +179,7 @@ namespace toolkit aImages[ imageIndex ] = lcl_getGraphic_throw( xGraphicProvider, *pImageURL ); } } - i_data.aThrobber.setImageList( aImages ); + pThrobber->setImageList( aImages ); } catch( const Exception& ) { @@ -226,21 +225,28 @@ namespace toolkit void SAL_CALL AnimatedImagesPeer::startAnimation( ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); - m_pData->aThrobber.start(); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->start(); } //------------------------------------------------------------------------------------------------------------------ void SAL_CALL AnimatedImagesPeer::stopAnimation( ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); - m_pData->aThrobber.stop(); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->stop(); } //------------------------------------------------------------------------------------------------------------------ ::sal_Bool SAL_CALL AnimatedImagesPeer::isAnimationRunning( ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); - return m_pData->aThrobber.isRunning(); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + return pThrobber->isRunning(); + return sal_False; } //------------------------------------------------------------------------------------------------------------------ @@ -248,6 +254,13 @@ namespace toolkit { ::vos::OGuard aGuard( GetMutex() ); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber == NULL ) + { + VCLXWindow::setProperty( i_propertyName, i_value ); + return; + } + const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName ); switch ( nPropertyId ) { @@ -255,14 +268,14 @@ namespace toolkit { sal_Int32 nStepTime( 0 ); if ( i_value >>= nStepTime ) - m_pData->aThrobber.setStepTime( nStepTime ); + pThrobber->setStepTime( nStepTime ); break; } case BASEPROPERTY_AUTO_REPEAT: { sal_Bool bRepeat( sal_True ); if ( i_value >>= bRepeat ) - m_pData->aThrobber.setRepeat( bRepeat ); + pThrobber->setRepeat( bRepeat ); break; } @@ -290,15 +303,19 @@ namespace toolkit Any aReturn; + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber == NULL ) + return VCLXWindow::getProperty( i_propertyName ); + const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName ); switch ( nPropertyId ) { case BASEPROPERTY_STEP_TIME: - aReturn <<= m_pData->aThrobber.getStepTime(); + aReturn <<= pThrobber->getStepTime(); break; case BASEPROPERTY_AUTO_REPEAT: - aReturn <<= m_pData->aThrobber.getRepeat(); + aReturn <<= pThrobber->getRepeat(); break; case BASEPROPERTY_IMAGE_SCALE_MODE: diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 5d4dbe77116c..a609a7df3268 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -33,6 +33,7 @@ #include #endif #include +#include #include #include #include @@ -116,6 +117,7 @@ #include #include #include +#include #include "toolkit/awt/vclxspinbutton.hxx" #include @@ -986,19 +988,23 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, } break; case WINDOW_CONTROL: - if ( aServiceName.EqualsAscii( "simpleanimation" ) ) + if ( aServiceName.EqualsAscii( "simpleanimation" ) ) { - pNewWindow = new FixedImage( pParent, nWinBits | WB_SCALE ); + pNewWindow = new Throbber( pParent, nWinBits, Throbber::IMAGES_NONE ); + ((Throbber*)pNewWindow)->SetScaleMode( css::awt::ImageScaleMode::Anisotropic ); + // (compatibility) *ppNewComp = new ::toolkit::XSimpleAnimation; } else if ( aServiceName.EqualsAscii( "throbber" ) ) { - pNewWindow = new FixedImage( pParent, nWinBits | WB_SCALE ); + pNewWindow = new Throbber( pParent, nWinBits, Throbber::IMAGES_NONE ); + ((Throbber*)pNewWindow)->SetScaleMode( css::awt::ImageScaleMode::Anisotropic ); + // (compatibility) *ppNewComp = new ::toolkit::XThrobber; } else if ( aServiceName.EqualsAscii( "animatedimages" ) ) { - pNewWindow = new ImageControl( pParent, nWinBits ); + pNewWindow = new Throbber( pParent, nWinBits ); *ppNewComp = new ::toolkit::AnimatedImagesPeer; } break; diff --git a/toolkit/source/awt/xsimpleanimation.cxx b/toolkit/source/awt/xsimpleanimation.cxx index 63de993e0e43..75701cb94b46 100644 --- a/toolkit/source/awt/xsimpleanimation.cxx +++ b/toolkit/source/awt/xsimpleanimation.cxx @@ -29,8 +29,8 @@ #include "precompiled_toolkit.hxx" #include "toolkit/awt/xsimpleanimation.hxx" #include "toolkit/helper/property.hxx" -#include "toolkit/helper/throbberimpl.hxx" #include +#include //........................................................................ namespace toolkit @@ -46,7 +46,6 @@ namespace toolkit //-------------------------------------------------------------------- XSimpleAnimation::XSimpleAnimation() - :mpThrobber( new Throbber_Impl( *this ) ) { DBG_CTOR( XSimpleAnimation, NULL ); } @@ -61,14 +60,18 @@ namespace toolkit void SAL_CALL XSimpleAnimation::start() throw ( uno::RuntimeException ) { ::vos::OGuard aGuard( GetMutex() ); - mpThrobber->start(); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->start(); } //-------------------------------------------------------------------- void SAL_CALL XSimpleAnimation::stop() throw ( uno::RuntimeException ) { ::vos::OGuard aGuard( GetMutex() ); - mpThrobber->stop(); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->stop(); } //-------------------------------------------------------------------- @@ -76,7 +79,9 @@ namespace toolkit throw ( uno::RuntimeException ) { ::vos::OGuard aGuard( GetMutex() ); - mpThrobber->setImageList( rImageList ); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->setImageList( rImageList ); } //-------------------------------------------------------------------- @@ -85,27 +90,31 @@ namespace toolkit { ::vos::OGuard aGuard( GetMutex() ); - if ( GetWindow() ) + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber == NULL ) { - sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); - switch ( nPropertyId ) - { - case BASEPROPERTY_STEP_TIME: { - sal_Int32 nStepTime( 0 ); - if ( Value >>= nStepTime ) - mpThrobber->setStepTime( nStepTime ); - - break; - } - case BASEPROPERTY_REPEAT: { - sal_Bool bRepeat( sal_True ); - if ( Value >>= bRepeat ) - mpThrobber->setRepeat( bRepeat ); - break; - } - default: - VCLXWindow::setProperty( PropertyName, Value ); + VCLXWindow::setProperty( PropertyName, Value ); + return; + } + + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_STEP_TIME: { + sal_Int32 nStepTime( 0 ); + if ( Value >>= nStepTime ) + pThrobber->setStepTime( nStepTime ); + + break; + } + case BASEPROPERTY_REPEAT: { + sal_Bool bRepeat( sal_True ); + if ( Value >>= bRepeat ) + pThrobber->setRepeat( bRepeat ); + break; } + default: + VCLXWindow::setProperty( PropertyName, Value ); } } @@ -115,22 +124,22 @@ namespace toolkit { ::vos::OGuard aGuard( GetMutex() ); - uno::Any aReturn; + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber == NULL ) + return VCLXWindow::getProperty( PropertyName ); - if ( GetWindow() ) + uno::Any aReturn; + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) { - sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); - switch ( nPropertyId ) - { - case BASEPROPERTY_STEP_TIME: - aReturn <<= mpThrobber->getStepTime(); - break; - case BASEPROPERTY_REPEAT: - aReturn <<= mpThrobber->getRepeat(); - break; - default: - aReturn = VCLXWindow::getProperty( PropertyName ); - } + case BASEPROPERTY_STEP_TIME: + aReturn <<= pThrobber->getStepTime(); + break; + case BASEPROPERTY_REPEAT: + aReturn <<= pThrobber->getRepeat(); + break; + default: + aReturn = VCLXWindow::getProperty( PropertyName ); } return aReturn; } diff --git a/toolkit/source/awt/xthrobber.cxx b/toolkit/source/awt/xthrobber.cxx index 2a5d8d2d19af..768bd6ab4330 100644 --- a/toolkit/source/awt/xthrobber.cxx +++ b/toolkit/source/awt/xthrobber.cxx @@ -30,7 +30,6 @@ #include "toolkit/awt/xthrobber.hxx" #include "toolkit/helper/property.hxx" #include -#include #ifndef _TOOLKIT_AWT_XTHROBBER_HRC_ #include "xthrobber.hrc" @@ -38,6 +37,7 @@ #include #include #include +#include //........................................................................ namespace toolkit @@ -53,10 +53,8 @@ namespace toolkit //-------------------------------------------------------------------- XThrobber::XThrobber() - :mpThrobber( new Throbber_Impl( *this ) ) { DBG_CTOR( XThrobber, NULL ); - InitImageList(); } //-------------------------------------------------------------------- @@ -69,14 +67,25 @@ namespace toolkit void SAL_CALL XThrobber::start() throw ( uno::RuntimeException ) { ::vos::OGuard aGuard( GetMutex() ); - mpThrobber->start(); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->start(); } //-------------------------------------------------------------------- void SAL_CALL XThrobber::stop() throw ( uno::RuntimeException ) { ::vos::OGuard aGuard( GetMutex() ); - mpThrobber->stop(); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->stop(); + } + + //-------------------------------------------------------------------- + void XThrobber::SetWindow( Window* pWindow ) + { + XThrobber_Base::SetWindow( pWindow ); + InitImageList(); } //-------------------------------------------------------------------- @@ -84,10 +93,15 @@ namespace toolkit throw( uno::RuntimeException ) { ::vos::OGuard aGuard( GetMutex() ); + + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + return; + uno::Sequence< uno::Reference< graphic::XGraphic > > aImageList(12); sal_uInt16 nIconIdStart = RID_TK_ICON_THROBBER_START; - if ( mpThrobber->isHCMode() ) + if ( pThrobber->GetSettings().GetStyleSettings().GetHighContrastMode() ) nIconIdStart = RID_TK_HC_ICON_THROBBER_START; for ( sal_uInt16 i=0; i<12; i++ ) @@ -96,7 +110,7 @@ namespace toolkit aImageList[i] = aImage.GetXGraphic(); } - mpThrobber->setImageList( aImageList ); + pThrobber->setImageList( aImageList ); } //........................................................................ diff --git a/toolkit/source/helper/makefile.mk b/toolkit/source/helper/makefile.mk index bf10b0aa0178..a0a254ef1f00 100644 --- a/toolkit/source/helper/makefile.mk +++ b/toolkit/source/helper/makefile.mk @@ -53,7 +53,6 @@ SLOFILES= \ $(SLO)$/vclunohelper.obj \ $(SLO)$/externallock.obj \ $(SLO)$/imagealign.obj \ - $(SLO)$/throbberimpl.obj \ $(SLO)$/formpdfexport.obj \ $(SLO)$/accessibilityclient.obj \ $(SLO)$/fixedhyperbase.obj diff --git a/toolkit/source/helper/throbberimpl.cxx b/toolkit/source/helper/throbberimpl.cxx deleted file mode 100644 index 5eb6b838a924..000000000000 --- a/toolkit/source/helper/throbberimpl.cxx +++ /dev/null @@ -1,149 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "precompiled_toolkit.hxx" -#include - -#include -#include - -//........................................................................ -namespace toolkit -//........................................................................ -{ - using namespace ::com::sun::star; - - //-------------------------------------------------------------------- - Throbber_Impl::Throbber_Impl( VCLXWindow& i_rParent ) - :mrMutex( Application::GetSolarMutex() ) - ,mrParent( i_rParent ) - ,mbRepeat( sal_True ) - ,mnStepTime( 100 ) - ,mnCurStep( 0 ) - ,mnStepCount( 0 ) - { - maWaitTimer.SetTimeout( mnStepTime ); - maWaitTimer.SetTimeoutHdl( LINK( this, Throbber_Impl, TimeOutHdl ) ); - } - - //-------------------------------------------------------------------- - Throbber_Impl::~Throbber_Impl() - { - maWaitTimer.Stop(); - } - - //-------------------------------------------------------------------- - void Throbber_Impl::start() - { - DBG_TESTSOLARMUTEX(); - maWaitTimer.Start(); - } - - //-------------------------------------------------------------------- - void Throbber_Impl::stop() - { - DBG_TESTSOLARMUTEX(); - maWaitTimer.Stop(); - } - - //-------------------------------------------------------------------- - bool Throbber_Impl::isRunning() const - { - DBG_TESTSOLARMUTEX(); - return maWaitTimer.IsActive(); - } - - //-------------------------------------------------------------------- - namespace - { - void lcl_setImage( FixedImage& i_fixedImage, Image const& i_image ) - { - ImageControl* pImageControl = dynamic_cast< ImageControl* >( &i_fixedImage ); - if ( pImageControl != NULL ) - pImageControl->SetBitmap( i_image.GetBitmapEx() ); - else - i_fixedImage.SetImage( i_image ); - } - } - - //-------------------------------------------------------------------- - void Throbber_Impl::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& rImageList ) - { - DBG_TESTSOLARMUTEX(); - - maImageList = rImageList; - - mnStepCount = maImageList.getLength(); - FixedImage* pFixedImage = dynamic_cast< FixedImage* >( mrParent.GetWindow() ); - if ( pFixedImage ) - lcl_setImage( *pFixedImage, mnStepCount ? maImageList[ 0 ] : Image() ); - } - - //-------------------------------------------------------------------- - sal_Bool Throbber_Impl::isHCMode() - { - FixedImage* pImage = dynamic_cast< FixedImage* >( mrParent.GetWindow() ); - if ( pImage ) - return pImage->GetSettings().GetStyleSettings().GetHighContrastMode(); - else - return Application::GetSettings().GetStyleSettings().GetHighContrastMode(); - } - - // ----------------------------------------------------------------------- - IMPL_LINK( Throbber_Impl, TimeOutHdl, Throbber_Impl*, EMPTYARG ) - { - ::vos::OGuard aGuard( GetMutex() ); - if ( !maImageList.getLength() ) - return 0; - - FixedImage* pFixedImage = dynamic_cast< FixedImage* >( mrParent.GetWindow() ); - if ( pFixedImage == NULL ) - return 0; - - if ( mnCurStep < mnStepCount - 1 ) - mnCurStep += 1; - else - { - if ( mbRepeat ) - { - // start over - mnCurStep = 0; - } - else - { - stop(); - } - } - - lcl_setImage( *pFixedImage, maImageList[ mnCurStep ] ); - - return 0; - } - -//........................................................................ -} // namespacetoolkit -//........................................................................ - -- cgit From 9c18a3edd46fcff26b0fb3f2c583f3200c283154 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 7 Oct 2010 14:13:53 +0200 Subject: dba34b: #i112779# moved the new throbber resources from toolkit to VCL (forgot those when moving the code) --- toolkit/source/awt/makefile.mk | 3 +- toolkit/source/awt/spinningprogress.src | 72 ---------------------------- toolkit/source/controls/spinningprogress.cxx | 39 +++++---------- 3 files changed, 14 insertions(+), 100 deletions(-) delete mode 100755 toolkit/source/awt/spinningprogress.src (limited to 'toolkit') diff --git a/toolkit/source/awt/makefile.mk b/toolkit/source/awt/makefile.mk index 152427ca9659..927c8fd22af7 100644 --- a/toolkit/source/awt/makefile.mk +++ b/toolkit/source/awt/makefile.mk @@ -77,8 +77,7 @@ SLOFILES= \ SRS1NAME=$(TARGET) SRC1FILES=\ - xthrobber.src \ - spinningprogress.src + xthrobber.src # --- Targets ------------------------------------------------------ diff --git a/toolkit/source/awt/spinningprogress.src b/toolkit/source/awt/spinningprogress.src deleted file mode 100755 index 1c6ce7737804..000000000000 --- a/toolkit/source/awt/spinningprogress.src +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// TODO: we need a mechanism to add images to images.zip, *without* -// referring them in resource files. The below resources are never loaded -// at runtime, instead, the images in images.zip are accessed via -// private:graphicrepository/* URLs. - -Resource 1000 -{ - Image 1 { ImageBitmap = Bitmap{ file = "shared/spinner-16-01.png"; }; }; - Image 2 { ImageBitmap = Bitmap{ file = "shared/spinner-16-02.png"; }; }; - Image 3 { ImageBitmap = Bitmap{ file = "shared/spinner-16-03.png"; }; }; - Image 4 { ImageBitmap = Bitmap{ file = "shared/spinner-16-04.png"; }; }; - Image 5 { ImageBitmap = Bitmap{ file = "shared/spinner-16-05.png"; }; }; - Image 6 { ImageBitmap = Bitmap{ file = "shared/spinner-16-06.png"; }; }; -}; - -Resource 1001 -{ - Image 1 { ImageBitmap = Bitmap{ file = "shared/spinner-32-01.png"; }; }; - Image 2 { ImageBitmap = Bitmap{ file = "shared/spinner-32-02.png"; }; }; - Image 3 { ImageBitmap = Bitmap{ file = "shared/spinner-32-03.png"; }; }; - Image 4 { ImageBitmap = Bitmap{ file = "shared/spinner-32-04.png"; }; }; - Image 5 { ImageBitmap = Bitmap{ file = "shared/spinner-32-05.png"; }; }; - Image 6 { ImageBitmap = Bitmap{ file = "shared/spinner-32-06.png"; }; }; - Image 7 { ImageBitmap = Bitmap{ file = "shared/spinner-32-07.png"; }; }; - Image 8 { ImageBitmap = Bitmap{ file = "shared/spinner-32-08.png"; }; }; - Image 9 { ImageBitmap = Bitmap{ file = "shared/spinner-32-09.png"; }; }; - Image 10 { ImageBitmap = Bitmap{ file = "shared/spinner-32-10.png"; }; }; - Image 11 { ImageBitmap = Bitmap{ file = "shared/spinner-32-11.png"; }; }; - Image 12 { ImageBitmap = Bitmap{ file = "shared/spinner-32-12.png"; }; }; -}; - -Resource 1002 -{ - Image 1 { ImageBitmap = Bitmap{ file = "shared/spinner-64-01.png"; }; }; - Image 2 { ImageBitmap = Bitmap{ file = "shared/spinner-64-02.png"; }; }; - Image 3 { ImageBitmap = Bitmap{ file = "shared/spinner-64-03.png"; }; }; - Image 4 { ImageBitmap = Bitmap{ file = "shared/spinner-64-04.png"; }; }; - Image 5 { ImageBitmap = Bitmap{ file = "shared/spinner-64-05.png"; }; }; - Image 6 { ImageBitmap = Bitmap{ file = "shared/spinner-64-06.png"; }; }; - Image 7 { ImageBitmap = Bitmap{ file = "shared/spinner-64-07.png"; }; }; - Image 8 { ImageBitmap = Bitmap{ file = "shared/spinner-64-08.png"; }; }; - Image 9 { ImageBitmap = Bitmap{ file = "shared/spinner-64-09.png"; }; }; - Image 10 { ImageBitmap = Bitmap{ file = "shared/spinner-64-10.png"; }; }; - Image 11 { ImageBitmap = Bitmap{ file = "shared/spinner-64-11.png"; }; }; - Image 12 { ImageBitmap = Bitmap{ file = "shared/spinner-64-12.png"; }; }; -}; diff --git a/toolkit/source/controls/spinningprogress.cxx b/toolkit/source/controls/spinningprogress.cxx index e901d2a5cca2..d4b89d5123ec 100755 --- a/toolkit/source/controls/spinningprogress.cxx +++ b/toolkit/source/controls/spinningprogress.cxx @@ -35,6 +35,7 @@ #include #include +#include //...................................................................................................................... namespace toolkit @@ -65,37 +66,23 @@ namespace toolkit // default image sets osl_incrementInterlockedCount( &m_refCount ); { - sal_Char const* const pResolutions[] = { "16", "32", "64" }; - size_t const nImageCounts[] = { 6, 12, 12 }; - - for ( size_t set=0; set<3; ++set ) + try { - ::std::vector< ::rtl::OUString > aImageURLs; - aImageURLs.reserve( nImageCounts[set] ); - - for ( size_t i=0; i( &aImageURLs[0], aImageURLs.size() ) ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); + const ::std::vector< ::rtl::OUString > aDefaultURLs( Throbber::getDefaultImageURLs( aImageSets[i] ) ); + const Sequence< ::rtl::OUString > aImageURLs( &aDefaultURLs[0], aDefaultURLs.size() ); + insertImageSet( i, aImageURLs ); } } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } osl_decrementInterlockedCount( &m_refCount ); } -- cgit From 7fcbcc4b70c1e905e6cdd08ab79ea8ebd0720a5b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 11 Oct 2010 13:59:41 +0200 Subject: dba34b: during #i112779#: don't hold an extra BitmapEx in ImageControl, use base classes Image instead --- toolkit/inc/toolkit/awt/vclxwindows.hxx | 2 +- toolkit/source/awt/vclxwindows.cxx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'toolkit') diff --git a/toolkit/inc/toolkit/awt/vclxwindows.hxx b/toolkit/inc/toolkit/awt/vclxwindows.hxx index fb110cb74391..0e597779342e 100644 --- a/toolkit/inc/toolkit/awt/vclxwindows.hxx +++ b/toolkit/inc/toolkit/awt/vclxwindows.hxx @@ -121,7 +121,7 @@ private: Image maImage; protected: - BitmapEx GetBitmap() const { return maImage.GetBitmapEx(); } + const Image& GetImage() const { return maImage; } protected: // ::com::sun::star::awt::XWindow diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index db34c840f8eb..c69e7c550d90 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -219,7 +219,7 @@ void VCLXGraphicControl::ImplSetNewImage() { OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" ); Button* pButton = static_cast< Button* >( GetWindow() ); - pButton->SetModeBitmap( GetBitmap() ); + pButton->SetModeImage( GetImage() ); } void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, short Flags ) throw(::com::sun::star::uno::RuntimeException) @@ -660,14 +660,14 @@ void VCLXImageControl::ImplSetNewImage() { OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" ); ImageControl* pControl = static_cast< ImageControl* >( GetWindow() ); - pControl->SetBitmap( GetBitmap() ); + pControl->SetImage( GetImage() ); } ::com::sun::star::awt::Size VCLXImageControl::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); - Size aSz = GetBitmap().GetSizePixel(); + Size aSz = GetImage().GetSizePixel(); aSz = ImplCalcWindowSize( aSz ); return AWTSize(aSz); -- cgit From ba2506b0e46d9c2854cda846f982ed4add24c24a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 11 Oct 2010 16:02:59 +0200 Subject: dba34b: #i112779# support automatic HC theme in AnimatedImagesPeer --- toolkit/inc/toolkit/awt/animatedimagespeer.hxx | 3 + toolkit/source/awt/animatedimagespeer.cxx | 184 +++++++++++++++++++++---- 2 files changed, 163 insertions(+), 24 deletions(-) (limited to 'toolkit') diff --git a/toolkit/inc/toolkit/awt/animatedimagespeer.hxx b/toolkit/inc/toolkit/awt/animatedimagespeer.hxx index 0d1204cb1309..b9bdecdf0e47 100755 --- a/toolkit/inc/toolkit/awt/animatedimagespeer.hxx +++ b/toolkit/inc/toolkit/awt/animatedimagespeer.hxx @@ -84,6 +84,9 @@ namespace toolkit // XModifyListener virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& i_event ) throw (::com::sun::star::uno::RuntimeException); + // XComponent + void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); + protected: void ProcessWindowEvent( const VclWindowEvent& i_windowEvent ); diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx index 4130b841f34a..0cc15114e89a 100755 --- a/toolkit/source/awt/animatedimagespeer.cxx +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -41,7 +41,9 @@ #include #include #include +#include #include +#include #include #include @@ -77,10 +79,28 @@ namespace toolkit //================================================================================================================== //= AnimatedImagesPeer_Data //================================================================================================================== + struct CachedImage + { + ::rtl::OUString sImageURL; + mutable Reference< XGraphic > xGraphic; + + CachedImage() + :sImageURL() + ,xGraphic() + { + } + + CachedImage( ::rtl::OUString const& i_imageURL ) + :sImageURL( i_imageURL ) + ,xGraphic() + { + } + }; + struct AnimatedImagesPeer_Data { AnimatedImagesPeer& rAntiImpl; - ::std::vector< Sequence< ::rtl::OUString > > aCachedImageSets; + ::std::vector< ::std::vector< CachedImage > > aCachedImageSets; AnimatedImagesPeer_Data( AnimatedImagesPeer& i_antiImpl ) :rAntiImpl( i_antiImpl ) @@ -95,23 +115,58 @@ namespace toolkit namespace { //-------------------------------------------------------------------------------------------------------------- - Reference< XGraphic > lcl_getGraphic_throw( const Reference< XGraphicProvider >& i_graphicProvider, const ::rtl::OUString& i_imageURL ) + ::rtl::OUString lcl_getHighContrastURL( ::rtl::OUString const& i_imageURL ) + { + INetURLObject aURL( i_imageURL ); + if ( aURL.GetProtocol() != INET_PROT_PRIV_SOFFICE ) + { + OSL_VERIFY( aURL.insertName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "hicontrast" ) ), false, 0 ) ); + return aURL.GetMainURL( INetURLObject::NO_DECODE ); + } + // the private: scheme is not considered to be hierarchical by INetURLObject, so manually insert the + // segment + const sal_Int32 separatorPos = i_imageURL.indexOf( '/' ); + ENSURE_OR_RETURN( separatorPos != -1, "lcl_getHighContrastURL: unsipported URL scheme - cannot automatically determine HC version!", i_imageURL ); + + ::rtl::OUStringBuffer composer; + composer.append( i_imageURL.copy( 0, separatorPos ) ); + composer.appendAscii( "/hicontrast" ); + composer.append( i_imageURL.copy( separatorPos ) ); + return composer.makeStringAndClear(); + } + + //-------------------------------------------------------------------------------------------------------------- + bool lcl_ensureImage_throw( Reference< XGraphicProvider > const& i_graphicProvider, const bool i_isHighContrast, const CachedImage& i_cachedImage ) { - ::comphelper::NamedValueCollection aMediaProperties; - aMediaProperties.put( "URL", i_imageURL ); - return Reference< XGraphic >( i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY ); + if ( !i_cachedImage.xGraphic.is() ) + { + ::comphelper::NamedValueCollection aMediaProperties; + if ( i_isHighContrast ) + { + // try (to find) the high-contrast version of the graphic first + aMediaProperties.put( "URL", lcl_getHighContrastURL( i_cachedImage.sImageURL ) ); + i_cachedImage.xGraphic.set( i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY ); + } + if ( !i_cachedImage.xGraphic.is() ) + { + aMediaProperties.put( "URL", i_cachedImage.sImageURL ); + i_cachedImage.xGraphic.set( i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY ); + } + } + return i_cachedImage.xGraphic.is(); } //-------------------------------------------------------------------------------------------------------------- - Size lcl_getGraphicSizePixel( const Reference< XGraphicProvider >& i_graphicProvider, const ::rtl::OUString& i_imageURL ) + Size lcl_getGraphicSizePixel( Reference< XGraphic > const& i_graphic ) { Size aSizePixel; try { - ::comphelper::NamedValueCollection aMediaProperties; - aMediaProperties.put( "URL", i_imageURL ); - const Reference< XPropertySet > xGraphicProps( lcl_getGraphic_throw( i_graphicProvider, i_imageURL ), UNO_QUERY_THROW ); - OSL_VERIFY( xGraphicProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SizePixel" ) ) ) >>= aSizePixel ); + if ( i_graphic.is() ) + { + const Reference< XPropertySet > xGraphicProps( i_graphic, UNO_QUERY_THROW ); + OSL_VERIFY( xGraphicProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SizePixel" ) ) ) >>= aSizePixel ); + } } catch( const Exception& ) { @@ -120,6 +175,18 @@ namespace toolkit return aSizePixel; } + //-------------------------------------------------------------------------------------------------------------- + void lcl_init( Sequence< ::rtl::OUString > const& i_imageURLs, ::std::vector< CachedImage >& o_images ) + { + o_images.resize(0); + size_t count = size_t( i_imageURLs.getLength() ); + o_images.reserve( count ); + for ( size_t i = 0; i < count; ++i ) + { + o_images.push_back( CachedImage( i_imageURLs[i] ) ); + } + } + //-------------------------------------------------------------------------------------------------------------- void lcl_updateImageList_nothrow( AnimatedImagesPeer_Data& i_data ) { @@ -133,15 +200,23 @@ namespace toolkit const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); const Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); + const bool isHighContrast = pThrobber->GetSettings().GetStyleSettings().GetHighContrastMode(); + const size_t nImageSetCount = i_data.aCachedImageSets.size(); ::std::vector< Size > aImageSizes( nImageSetCount ); for ( sal_Int32 nImageSet = 0; size_t( nImageSet ) < nImageSetCount; ++nImageSet ) { - Sequence< ::rtl::OUString > const& rImageSet( i_data.aCachedImageSets[ nImageSet ] ); - if ( rImageSet.getLength() ) - aImageSizes[ nImageSet ] = lcl_getGraphicSizePixel( xGraphicProvider, rImageSet[0] ); - else + ::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nImageSet ] ); + if ( ( rImageSet.empty() ) + || ( !lcl_ensureImage_throw( xGraphicProvider, isHighContrast, rImageSet[0] ) ) + ) + { aImageSizes[ nImageSet ] = Size( ::std::numeric_limits< long >::max(), ::std::numeric_limits< long >::max() ); + } + else + { + aImageSizes[ nImageSet ] = lcl_getGraphicSizePixel( rImageSet[0].xGraphic ); + } } // find the set with the smallest difference between window size and image size @@ -168,15 +243,16 @@ namespace toolkit if ( ( nPreferredSet >= 0 ) && ( size_t( nPreferredSet ) < nImageSetCount ) ) { // => set the images - Sequence< ::rtl::OUString > const& rImageSet( i_data.aCachedImageSets[ nPreferredSet ] ); - aImages.realloc( rImageSet.getLength() ); + ::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nPreferredSet ] ); + aImages.realloc( rImageSet.size() ); sal_Int32 imageIndex = 0; - for ( ::rtl::OUString const* pImageURL = rImageSet.getConstArray(); - pImageURL != rImageSet.getConstArray() + rImageSet.getLength(); - ++pImageURL, ++imageIndex + for ( ::std::vector< CachedImage >::const_iterator cachedImage = rImageSet.begin(); + cachedImage != rImageSet.end(); + ++cachedImage, ++imageIndex ) { - aImages[ imageIndex ] = lcl_getGraphic_throw( xGraphicProvider, *pImageURL ); + lcl_ensureImage_throw( xGraphicProvider, isHighContrast, *cachedImage ); + aImages[ imageIndex ] = cachedImage->xGraphic; } } pThrobber->setImageList( aImages ); @@ -195,7 +271,12 @@ namespace toolkit const sal_Int32 nImageSetCount = i_images->getImageSetCount(); i_data.aCachedImageSets.resize(0); for ( sal_Int32 set = 0; set < nImageSetCount; ++set ) - i_data.aCachedImageSets.push_back( i_images->getImageSet( set ) ); + { + const Sequence< ::rtl::OUString > aImageURLs( i_images->getImageSet( set ) ); + ::std::vector< CachedImage > aImages; + lcl_init( aImageURLs, aImages ); + i_data.aCachedImageSets.push_back( aImages ); + } lcl_updateImageList_nothrow( i_data ); } @@ -357,19 +438,66 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL AnimatedImagesPeer::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) { - impl_updateImages_nolck( i_event.Source ); + ::vos::OGuard aGuard( GetMutex() ); + Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW ); + + sal_Int32 nPosition(0); + OSL_VERIFY( i_event.Accessor >>= nPosition ); + size_t position = size_t( nPosition ); + if ( position > m_pData->aCachedImageSets.size() ) + { + OSL_ENSURE( false, "AnimatedImagesPeer::elementInserted: illegal accessor/index!" ); + lcl_updateImageList_nothrow( *m_pData, xAnimatedImages ); + } + + Sequence< ::rtl::OUString > aImageURLs; + OSL_VERIFY( i_event.Element >>= aImageURLs ); + ::std::vector< CachedImage > aImages; + lcl_init( aImageURLs, aImages ); + m_pData->aCachedImageSets.insert( m_pData->aCachedImageSets.begin() + position, aImages ); + lcl_updateImageList_nothrow( *m_pData ); } //------------------------------------------------------------------------------------------------------------------ void SAL_CALL AnimatedImagesPeer::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) { - impl_updateImages_nolck( i_event.Source ); + ::vos::OGuard aGuard( GetMutex() ); + Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW ); + + sal_Int32 nPosition(0); + OSL_VERIFY( i_event.Accessor >>= nPosition ); + size_t position = size_t( nPosition ); + if ( position >= m_pData->aCachedImageSets.size() ) + { + OSL_ENSURE( false, "AnimatedImagesPeer::elementRemoved: illegal accessor/index!" ); + lcl_updateImageList_nothrow( *m_pData, xAnimatedImages ); + } + + m_pData->aCachedImageSets.erase( m_pData->aCachedImageSets.begin() + position ); + lcl_updateImageList_nothrow( *m_pData ); } //------------------------------------------------------------------------------------------------------------------ void SAL_CALL AnimatedImagesPeer::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) { - impl_updateImages_nolck( i_event.Source ); + ::vos::OGuard aGuard( GetMutex() ); + Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW ); + + sal_Int32 nPosition(0); + OSL_VERIFY( i_event.Accessor >>= nPosition ); + size_t position = size_t( nPosition ); + if ( position >= m_pData->aCachedImageSets.size() ) + { + OSL_ENSURE( false, "AnimatedImagesPeer::elementReplaced: illegal accessor/index!" ); + lcl_updateImageList_nothrow( *m_pData, xAnimatedImages ); + } + + Sequence< ::rtl::OUString > aImageURLs; + OSL_VERIFY( i_event.Element >>= aImageURLs ); + ::std::vector< CachedImage > aImages; + lcl_init( aImageURLs, aImages ); + m_pData->aCachedImageSets[ position ] = aImages; + lcl_updateImageList_nothrow( *m_pData ); } //------------------------------------------------------------------------------------------------------------------ @@ -384,6 +512,14 @@ namespace toolkit impl_updateImages_nolck( i_event.Source ); } + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::dispose( ) throw(RuntimeException) + { + AnimatedImagesPeer_Base::dispose(); + ::vos::OGuard aGuard( GetMutex() ); + m_pData->aCachedImageSets.resize(0); + } + //...................................................................................................................... } // namespace toolkit //...................................................................................................................... -- cgit From 4f5e614c0af7173ac61a2eb28f6bc0e9daa95409 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 11 Oct 2010 21:10:50 +0200 Subject: dba34b: #i112779# don't search for the best image set if there is only one (or even none) --- toolkit/source/awt/animatedimagespeer.cxx | 61 +++++++++++++++++-------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'toolkit') diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx index 0cc15114e89a..dcba2d303cba 100755 --- a/toolkit/source/awt/animatedimagespeer.cxx +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -202,39 +202,46 @@ namespace toolkit const bool isHighContrast = pThrobber->GetSettings().GetStyleSettings().GetHighContrastMode(); + sal_Int32 nPreferredSet = -1; const size_t nImageSetCount = i_data.aCachedImageSets.size(); - ::std::vector< Size > aImageSizes( nImageSetCount ); - for ( sal_Int32 nImageSet = 0; size_t( nImageSet ) < nImageSetCount; ++nImageSet ) + if ( nImageSetCount < 2 ) { - ::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nImageSet ] ); - if ( ( rImageSet.empty() ) - || ( !lcl_ensureImage_throw( xGraphicProvider, isHighContrast, rImageSet[0] ) ) - ) - { - aImageSizes[ nImageSet ] = Size( ::std::numeric_limits< long >::max(), ::std::numeric_limits< long >::max() ); - } - else + nPreferredSet = sal_Int32( nImageSetCount ) - 1; + } + else + { + ::std::vector< Size > aImageSizes( nImageSetCount ); + for ( sal_Int32 nImageSet = 0; size_t( nImageSet ) < nImageSetCount; ++nImageSet ) { - aImageSizes[ nImageSet ] = lcl_getGraphicSizePixel( rImageSet[0].xGraphic ); + ::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nImageSet ] ); + if ( ( rImageSet.empty() ) + || ( !lcl_ensureImage_throw( xGraphicProvider, isHighContrast, rImageSet[0] ) ) + ) + { + aImageSizes[ nImageSet ] = Size( ::std::numeric_limits< long >::max(), ::std::numeric_limits< long >::max() ); + } + else + { + aImageSizes[ nImageSet ] = lcl_getGraphicSizePixel( rImageSet[0].xGraphic ); + } } - } - // find the set with the smallest difference between window size and image size - const ::Size aWindowSizePixel = pThrobber->GetSizePixel(); - sal_Int32 nPreferredSet = -1; - long nMinimalDistance = ::std::numeric_limits< long >::max(); - for ( ::std::vector< Size >::const_iterator check = aImageSizes.begin(); - check != aImageSizes.end(); - ++check - ) - { - const sal_Int64 distance = - ( aWindowSizePixel.Width() - check->Width ) * ( aWindowSizePixel.Width() - check->Width ) - + ( aWindowSizePixel.Height() - check->Height ) * ( aWindowSizePixel.Height() - check->Height ); - if ( distance < nMinimalDistance ) + // find the set with the smallest difference between window size and image size + const ::Size aWindowSizePixel = pThrobber->GetSizePixel(); + long nMinimalDistance = ::std::numeric_limits< long >::max(); + for ( ::std::vector< Size >::const_iterator check = aImageSizes.begin(); + check != aImageSizes.end(); + ++check + ) { - nMinimalDistance = distance; - nPreferredSet = check - aImageSizes.begin(); + const sal_Int64 distance = + ( aWindowSizePixel.Width() - check->Width ) * ( aWindowSizePixel.Width() - check->Width ) + + ( aWindowSizePixel.Height() - check->Height ) * ( aWindowSizePixel.Height() - check->Height ); + if ( distance < nMinimalDistance ) + { + nMinimalDistance = distance; + nPreferredSet = check - aImageSizes.begin(); + } } } -- cgit From d077f1af17a5bf22b79ef6380542c84ab2a89c36 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 29 Oct 2010 12:56:56 +0200 Subject: dba34b: => --- toolkit/source/awt/animatedimagespeer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolkit') diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx index dcba2d303cba..5e127d399434 100755 --- a/toolkit/source/awt/animatedimagespeer.cxx +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -46,7 +46,7 @@ #include #include -#include +#include //...................................................................................................................... namespace toolkit -- cgit From e275aa2d11ae62ca665a2abe0baa55e970adb4c0 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 19 Nov 2010 13:40:23 +0100 Subject: dba34b: #i115291# when cloning a ListBoxModel, also copy the string items --- toolkit/source/controls/unocontrols.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'toolkit') diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index d3838a7421a4..abef85f491fa 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -1801,6 +1801,11 @@ struct UnoControlListBoxModel_Data return aItems; } + void copyItems( const UnoControlListBoxModel_Data& i_copySource ) + { + m_aListItems = i_copySource.m_aListItems; + } + void setAllItems( const ::std::vector< ListItem >& i_rItems ) { m_aListItems = i_rItems; @@ -1852,6 +1857,7 @@ UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel& i_ ,m_pData( new UnoControlListBoxModel_Data( *this ) ) ,m_aItemListListeners( GetMutex() ) { + m_pData->copyItems( *i_rSource.m_pData ); } UnoControlListBoxModel::~UnoControlListBoxModel() { -- cgit From 255da0d3dc8891c9595c1bd65b93dda4c2d7b32e Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 2 Dec 2010 14:43:46 +0100 Subject: dba34b InitImageList: corrected condition for early exit --- toolkit/source/awt/xthrobber.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolkit') diff --git a/toolkit/source/awt/xthrobber.cxx b/toolkit/source/awt/xthrobber.cxx index 768bd6ab4330..3b9b361202e9 100644 --- a/toolkit/source/awt/xthrobber.cxx +++ b/toolkit/source/awt/xthrobber.cxx @@ -95,7 +95,7 @@ namespace toolkit ::vos::OGuard aGuard( GetMutex() ); Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); - if ( pThrobber != NULL) + if ( pThrobber == NULL) return; uno::Sequence< uno::Reference< graphic::XGraphic > > aImageList(12); -- cgit From d6987b06b0e069a5276ff59d02b71c5fd5c5e626 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 6 Jan 2011 08:44:39 +0100 Subject: dba34b: adjusted CWS'es changes to new build system --- toolkit/Library_tk.mk | 4 +++- toolkit/Package_inc.mk | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'toolkit') diff --git a/toolkit/Library_tk.mk b/toolkit/Library_tk.mk index 9d94c76314f1..b54bee4e231d 100644 --- a/toolkit/Library_tk.mk +++ b/toolkit/Library_tk.mk @@ -82,6 +82,7 @@ $(eval $(call gb_Library_add_exception_objects,tk,\ toolkit/source/awt/vclxsystemdependentwindow \ toolkit/source/awt/vclxtabcontrol \ toolkit/source/awt/vclxtabpage \ + toolkit/source/awt/animatedimagespeer \ toolkit/source/awt/vclxtoolkit \ toolkit/source/awt/vclxtopwindow \ toolkit/source/awt/vclxwindow \ @@ -106,6 +107,8 @@ $(eval $(call gb_Library_add_exception_objects,tk,\ toolkit/source/controls/tksimpleanimation \ toolkit/source/controls/tkspinbutton \ toolkit/source/controls/tkthrobber \ + toolkit/source/controls/animatedimages \ + toolkit/source/controls/spinningprogress \ toolkit/source/controls/tree/treecontrol \ toolkit/source/controls/tree/treedatamodel \ toolkit/source/controls/unocontrol \ @@ -123,7 +126,6 @@ $(eval $(call gb_Library_add_exception_objects,tk,\ toolkit/source/helper/property \ toolkit/source/helper/registerservices \ toolkit/source/helper/servicenames \ - toolkit/source/helper/throbberimpl \ toolkit/source/helper/tkresmgr \ toolkit/source/helper/unomemorystream \ toolkit/source/helper/unopropertyarrayhelper \ diff --git a/toolkit/Package_inc.mk b/toolkit/Package_inc.mk index 3fc23a5b9f1f..4079a3d53383 100644 --- a/toolkit/Package_inc.mk +++ b/toolkit/Package_inc.mk @@ -59,7 +59,6 @@ $(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/mutexhelper.hxx $(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/property.hxx,toolkit/helper/property.hxx)) $(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/servicenames.hxx,toolkit/helper/servicenames.hxx)) $(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/solarrelease.hxx,toolkit/helper/solarrelease.hxx)) -$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/throbberimpl.hxx,toolkit/helper/throbberimpl.hxx)) $(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/tkresmgr.hxx,toolkit/helper/tkresmgr.hxx)) $(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/unomemorystream.hxx,toolkit/helper/unomemorystream.hxx)) $(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/unopropertyarrayhelper.hxx,toolkit/helper/unopropertyarrayhelper.hxx)) -- cgit From b699625287f8fe517bfd018fd6a7edeacdb9c270 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 28 Jan 2011 10:22:51 +0100 Subject: dba34b: do not use a throbber image which doesn't fit into the window --- toolkit/source/awt/animatedimagespeer.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'toolkit') diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx index 5e127d399434..c9c640d51c60 100755 --- a/toolkit/source/awt/animatedimagespeer.cxx +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -234,6 +234,12 @@ namespace toolkit ++check ) { + if ( ( check->Width > aWindowSizePixel.Width() ) + || ( check->Height > aWindowSizePixel.Height() ) + ) + // do not use an image set which doesn't fit into the window + continue; + const sal_Int64 distance = ( aWindowSizePixel.Width() - check->Width ) * ( aWindowSizePixel.Width() - check->Width ) + ( aWindowSizePixel.Height() - check->Height ) * ( aWindowSizePixel.Height() - check->Height ); -- cgit