22#include <helper/property.hxx>
24#include <com/sun/star/lang/DisposedException.hpp>
25#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26#include <com/sun/star/awt/VisualEffect.hpp>
27#include <com/sun/star/awt/ImageScaleMode.hpp>
28#include <com/sun/star/awt/XAnimation.hpp>
29#include <com/sun/star/awt/XAnimatedImages.hpp>
30#include <com/sun/star/beans/XPropertySetInfo.hpp>
31#include <com/sun/star/container/XContainerListener.hpp>
32#include <com/sun/star/uno/XComponentContext.hpp>
33#include <com/sun/star/util/XModifyListener.hpp>
42using namespace css::awt;
43using namespace css::container;
44using namespace css::lang;
45using namespace css::uno;
50 , css::awt::XAnimation
51 , css::container::XContainerListener
52 > AnimatedImagesControl_Base;
54class AnimatedImagesControl :
public AnimatedImagesControl_Base
57 AnimatedImagesControl();
58 OUString GetComponentServiceName()
const override;
61 virtual void SAL_CALL startAnimation( )
override;
62 virtual void SAL_CALL stopAnimation( )
override;
63 virtual sal_Bool SAL_CALL isAnimationRunning( )
override;
70 sal_Bool SAL_CALL setModel(
const css::uno::Reference< css::awt::XControlModel >& i_rModel )
override;
71 void SAL_CALL createPeer(
const css::uno::Reference< css::awt::XToolkit >& i_toolkit,
const css::uno::Reference< css::awt::XWindowPeer >& i_parentPeer )
override;
75 virtual void SAL_CALL
elementInserted(
const css::container::ContainerEvent& Event )
override;
76 virtual void SAL_CALL
elementRemoved(
const css::container::ContainerEvent& Event )
override;
77 virtual void SAL_CALL
elementReplaced(
const css::container::ContainerEvent& Event )
override;
80 virtual void SAL_CALL disposing(
const css::lang::EventObject& i_event )
override;
83 AnimatedImagesControl::AnimatedImagesControl()
88 OUString AnimatedImagesControl::GetComponentServiceName()
const
90 return "AnimatedImages";
94 void SAL_CALL AnimatedImagesControl::startAnimation( )
96 Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY );
97 if ( xAnimation.is() )
98 xAnimation->startAnimation();
102 void SAL_CALL AnimatedImagesControl::stopAnimation( )
104 Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY );
105 if ( xAnimation.is() )
106 xAnimation->stopAnimation();
110 sal_Bool SAL_CALL AnimatedImagesControl::isAnimationRunning( )
112 Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY );
113 if ( xAnimation.is() )
114 return xAnimation->isAnimationRunning();
119 OUString SAL_CALL AnimatedImagesControl::getImplementationName( )
121 return "org.openoffice.comp.toolkit.AnimatedImagesControl";
125 Sequence< OUString > SAL_CALL AnimatedImagesControl::getSupportedServiceNames()
127 Sequence< OUString > aServices( AnimatedImagesControl_Base::getSupportedServiceNames() );
128 aServices.realloc( aServices.getLength() + 1 );
129 aServices.getArray()[ aServices.getLength() - 1 ] =
"com.sun.star.awt.AnimatedImagesControl";
133 void lcl_updatePeer( Reference< XWindowPeer >
const& i_peer, Reference< XControlModel >
const& i_model )
135 const Reference< css::util::XModifyListener > xPeerModify( i_peer, UNO_QUERY );
136 if ( xPeerModify.is() )
140 xPeerModify->modified( aEvent );
144 sal_Bool SAL_CALL AnimatedImagesControl::setModel(
const Reference< XControlModel >& i_rModel )
146 const Reference< XAnimatedImages > xOldContainer( getModel(), UNO_QUERY );
147 const Reference< XAnimatedImages > xNewContainer( i_rModel, UNO_QUERY );
149 if ( !AnimatedImagesControl_Base::setModel( i_rModel ) )
152 if ( xOldContainer.is() )
153 xOldContainer->removeContainerListener(
this );
155 if ( xNewContainer.is() )
156 xNewContainer->addContainerListener(
this );
158 lcl_updatePeer( getPeer(), getModel() );
164 void SAL_CALL AnimatedImagesControl::createPeer(
const Reference< XToolkit >& i_toolkit,
const Reference< XWindowPeer >& i_parentPeer )
166 AnimatedImagesControl_Base::createPeer( i_toolkit, i_parentPeer );
168 lcl_updatePeer( getPeer(), getModel() );
174 const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY );
175 if ( xPeerListener.is() )
176 xPeerListener->elementInserted( i_event );
182 const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY );
183 if ( xPeerListener.is() )
184 xPeerListener->elementRemoved( i_event );
190 const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY );
191 if ( xPeerListener.is() )
192 xPeerListener->elementReplaced( i_event );
196 void SAL_CALL AnimatedImagesControl::disposing(
const EventObject& i_event )
207 void lcl_checkIndex(
const std::vector< css::uno::Sequence< OUString > > & rImageSets,
const sal_Int32 i_index,
const Reference< XInterface >& i_context,
208 const bool i_forInsert =
false )
210 if ( ( i_index < 0 ) || (
o3tl::make_unsigned( i_index ) > rImageSets.size() + ( i_forInsert ? 1 : 0 ) ) )
211 throw IndexOutOfBoundsException( OUString(), i_context );
215 void ( SAL_CALL XContainerListener::*i_notificationMethod )(
const ContainerEvent& ),
216 const sal_Int32 i_accessor,
const Sequence< OUString >& i_imageURLs,
const Reference< XInterface >& i_context )
222 aEvent.Source = i_context;
223 aEvent.Accessor <<= i_accessor;
224 aEvent.Element <<= i_imageURLs;
226 rContainer.
notifyEach( i_guard, i_notificationMethod, aEvent );
249 ,maImageSets( i_copySource.maImageSets )
267 static Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo(
getInfoHelper() ) );
274 return "com.sun.star.awt.AnimatedImagesControlModel";
280 return "org.openoffice.comp.toolkit.AnimatedImagesControlModel";
286 return {
"com.sun.star.awt.AnimatedImagesControlModel",
"com.sun.star.awt.UnoControlModel" };
296 sal_Int16 nImageScaleMode( ImageScaleMode::ANISOTROPIC );
297 OSL_VERIFY( i_value >>= nImageScaleMode );
298 if ( ( nImageScaleMode != ImageScaleMode::NONE )
299 && ( nImageScaleMode != ImageScaleMode::ISOTROPIC )
300 && ( nImageScaleMode != ImageScaleMode::ANISOTROPIC )
302 throw IllegalArgumentException( OUString(), *
this, 1 );
307 AnimatedImagesControlModel_Base::setFastPropertyValue_NoBroadcast( rGuard, i_handle, i_value );
313 switch ( i_propertyId )
316 return Any( OUString(
"com.sun.star.awt.AnimatedImagesControl") );
319 return Any( css::awt::VisualEffect::NONE );
322 return Any( sal_Int32(100) );
328 return Any( ImageScaleMode::NONE );
345 sal_Int32 nStepTime( 100 );
359 bool bAutoRepeat(
true );
373 sal_Int16 nImageScaleMode( ImageScaleMode::ANISOTROPIC );
375 return nImageScaleMode;
387 std::unique_lock aGuard(
m_aMutex );
389 throw DisposedException();
397 std::unique_lock aGuard(
m_aMutex );
399 throw DisposedException();
409 std::unique_lock aGuard(
m_aMutex );
412 throw DisposedException();
414 lcl_checkIndex(
maImageSets, i_index, *
this,
true );
426 std::unique_lock aGuard(
m_aMutex );
429 throw DisposedException();
443 std::unique_lock aGuard(
m_aMutex );
446 throw DisposedException();
451 ::std::vector< Sequence< OUString > >::iterator removalPos =
maImageSets.begin() + i_index;
452 Sequence< OUString > aRemovedElement( *removalPos );
462 std::unique_lock aGuard(
m_aMutex );
469 std::unique_lock aGuard(
m_aMutex );
475extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
477 css::uno::XComponentContext *,
478 css::uno::Sequence<css::uno::Any>
const &)
480 return cppu::acquire(
new AnimatedImagesControl());
483extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
485 css::uno::XComponentContext *context,
486 css::uno::Sequence<css::uno::Any>
const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_openoffice_comp_toolkit_AnimatedImagesControlModel_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_openoffice_comp_toolkit_AnimatedImagesControl_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
virtual css::uno::Any ImplGetDefaultValue(sal_uInt16 nPropId) const
void SAL_CALL disposing(const css::lang::EventObject &Source) override
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(std::unique_lock< std::mutex > &rGuard, void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event) const
sal_Int32 getLength(std::unique_lock< std::mutex > &rGuard) const
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void SAL_CALL elementReplaced(const css::container::ContainerEvent &Event) override
void SAL_CALL elementRemoved(const css::container::ContainerEvent &Event) override
DECL_LISTENERMULTIPLEXER_END void SAL_CALL elementInserted(const css::container::ContainerEvent &Event) override
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
const OUString & GetPropertyName(sal_uInt16 nPropertyId)
#define BASEPROPERTY_STEP_TIME
#define BASEPROPERTY_BORDER
#define BASEPROPERTY_HELPURL
#define BASEPROPERTY_BACKGROUNDCOLOR
#define BASEPROPERTY_AUTO_REPEAT
#define BASEPROPERTY_DEFAULTCONTROL
#define BASEPROPERTY_BORDERCOLOR
#define BASEPROPERTY_ENABLEVISIBLE
#define BASEPROPERTY_HELPTEXT
#define BASEPROPERTY_IMAGE_SCALE_MODE