1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tksimpleanimation.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_toolkit.hxx"
33 #include "toolkit/controls/tksimpleanimation.hxx"
34 #include "toolkit/helper/property.hxx"
35 #include "toolkit/helper/unopropertyarrayhelper.hxx"
36 #include <cppuhelper/typeprovider.hxx>
37 #include <tools/debug.hxx>
39 //........................................................................
42 //........................................................................
44 using namespace ::com::sun::star
;
46 //====================================================================
47 //= UnoSimpleAnimationControlModel
48 //====================================================================
49 //--------------------------------------------------------------------
50 UnoSimpleAnimationControlModel::UnoSimpleAnimationControlModel()
52 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
53 ImplRegisterProperty( BASEPROPERTY_REPEAT
);
54 ImplRegisterProperty( BASEPROPERTY_STEP_TIME
);
57 //--------------------------------------------------------------------
58 ::rtl::OUString
UnoSimpleAnimationControlModel::getServiceName()
59 throw( uno::RuntimeException
)
61 return ::rtl::OUString::createFromAscii( szServiceName_UnoSimpleAnimationControlModel
);
64 //--------------------------------------------------------------------
65 uno::Any
UnoSimpleAnimationControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
69 case BASEPROPERTY_DEFAULTCONTROL
:
70 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoSimpleAnimationControl
) );
72 case BASEPROPERTY_STEP_TIME
:
73 return uno::makeAny( (sal_Int32
) 100 );
75 case BASEPROPERTY_REPEAT
:
76 return uno::makeAny( (sal_Bool
)sal_True
);
79 return UnoControlModel::ImplGetDefaultValue( nPropId
);
83 //--------------------------------------------------------------------
84 ::cppu::IPropertyArrayHelper
& UnoSimpleAnimationControlModel::getInfoHelper()
86 static UnoPropertyArrayHelper
* pHelper
= NULL
;
89 uno::Sequence
< sal_Int32
> aIDs
= ImplGetPropertyIds();
90 pHelper
= new UnoPropertyArrayHelper( aIDs
);
95 //--------------------------------------------------------------------
96 uno::Reference
< beans::XPropertySetInfo
> UnoSimpleAnimationControlModel::getPropertySetInfo( )
97 throw( uno::RuntimeException
)
99 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
103 //--------------------------------------------------------------------
104 ::rtl::OUString SAL_CALL
UnoSimpleAnimationControlModel::getImplementationName()
105 throw( uno::RuntimeException
)
107 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.toolkit.UnoSimpleAnimationControlModel" ) );
110 //--------------------------------------------------------------------
111 uno::Sequence
< ::rtl::OUString
> SAL_CALL
UnoSimpleAnimationControlModel::getSupportedServiceNames()
112 throw( uno::RuntimeException
)
114 uno::Sequence
< ::rtl::OUString
> aServices( UnoControlModel::getSupportedServiceNames() );
115 aServices
.realloc( aServices
.getLength() + 1 );
116 aServices
[ aServices
.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_UnoSimpleAnimationControlModel
);
120 //====================================================================
121 //= UnoSimpleAnimationControl
122 //====================================================================
123 //--------------------------------------------------------------------
124 UnoSimpleAnimationControl::UnoSimpleAnimationControl()
128 //--------------------------------------------------------------------
129 ::rtl::OUString
UnoSimpleAnimationControl::GetComponentServiceName()
131 return ::rtl::OUString::createFromAscii( "SimpleAnimation" );
134 //--------------------------------------------------------------------
135 uno::Any
UnoSimpleAnimationControl::queryAggregation( const uno::Type
& rType
)
136 throw( uno::RuntimeException
)
138 uno::Any aRet
= UnoControlBase::queryAggregation( rType
);
139 if ( !aRet
.hasValue() )
140 aRet
= UnoSimpleAnimationControl_Base::queryInterface( rType
);
144 //--------------------------------------------------------------------
145 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoSimpleAnimationControl
, UnoControlBase
, UnoSimpleAnimationControl_Base
)
147 //--------------------------------------------------------------------
148 void UnoSimpleAnimationControl::dispose() throw( uno::RuntimeException
)
150 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
152 UnoControl::dispose();
155 //--------------------------------------------------------------------
156 ::rtl::OUString SAL_CALL
UnoSimpleAnimationControl::getImplementationName()
157 throw( uno::RuntimeException
)
159 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.toolkit.UnoSimpleAnimationControl" ) );
162 //--------------------------------------------------------------------
163 uno::Sequence
< ::rtl::OUString
> SAL_CALL
UnoSimpleAnimationControl::getSupportedServiceNames()
164 throw( uno::RuntimeException
)
166 uno::Sequence
< ::rtl::OUString
> aServices( UnoControlBase::getSupportedServiceNames() );
167 aServices
.realloc( aServices
.getLength() + 1 );
168 aServices
[ aServices
.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_UnoSimpleAnimationControl
);
172 //--------------------------------------------------------------------
173 void UnoSimpleAnimationControl::createPeer( const uno::Reference
< awt::XToolkit
> &rxToolkit
,
174 const uno::Reference
< awt::XWindowPeer
> &rParentPeer
)
175 throw( uno::RuntimeException
)
177 UnoControl::createPeer( rxToolkit
, rParentPeer
);
180 //--------------------------------------------------------------------
181 void SAL_CALL
UnoSimpleAnimationControl::start() throw ( uno::RuntimeException
)
183 ::osl::MutexGuard
aGuard( GetMutex() );
185 uno::Reference
< XSimpleAnimation
> xAnimation( getPeer(), uno::UNO_QUERY
);
186 if ( xAnimation
.is() )
190 //--------------------------------------------------------------------
191 void SAL_CALL
UnoSimpleAnimationControl::stop() throw ( uno::RuntimeException
)
193 ::osl::MutexGuard
aGuard( GetMutex() );
195 uno::Reference
< XSimpleAnimation
> xAnimation( getPeer(), uno::UNO_QUERY
);
196 if ( xAnimation
.is() )
200 //--------------------------------------------------------------------
201 void SAL_CALL
UnoSimpleAnimationControl::setImageList( const uno::Sequence
< uno::Reference
< graphic::XGraphic
> >& ImageList
)
202 throw ( uno::RuntimeException
)
204 ::osl::MutexGuard
aGuard( GetMutex() );
206 uno::Reference
< XSimpleAnimation
> xAnimation( getPeer(), uno::UNO_QUERY
);
207 if ( xAnimation
.is() )
208 xAnimation
->setImageList( ImageList
);
211 //........................................................................
212 } // namespace toolkit
213 //........................................................................