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: tkthrobber.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/tkthrobber.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 //= UnoThrobberControlModel
48 //====================================================================
49 //--------------------------------------------------------------------
50 UnoThrobberControlModel::UnoThrobberControlModel()
52 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
53 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
56 //--------------------------------------------------------------------
57 ::rtl::OUString
UnoThrobberControlModel::getServiceName( ) throw ( uno::RuntimeException
)
59 return ::rtl::OUString::createFromAscii( szServiceName_UnoThrobberControlModel
);
62 //--------------------------------------------------------------------
63 uno::Any
UnoThrobberControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
67 case BASEPROPERTY_DEFAULTCONTROL
:
68 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoThrobberControl
) );
70 return UnoControlModel::ImplGetDefaultValue( nPropId
);
74 //--------------------------------------------------------------------
75 ::cppu::IPropertyArrayHelper
& UnoThrobberControlModel::getInfoHelper()
77 static UnoPropertyArrayHelper
* pHelper
= NULL
;
80 uno::Sequence
< sal_Int32
> aIDs
= ImplGetPropertyIds();
81 pHelper
= new UnoPropertyArrayHelper( aIDs
);
86 //--------------------------------------------------------------------
87 uno::Reference
< beans::XPropertySetInfo
> UnoThrobberControlModel::getPropertySetInfo()
88 throw( uno::RuntimeException
)
90 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
94 //--------------------------------------------------------------------
95 ::rtl::OUString SAL_CALL
UnoThrobberControlModel::getImplementationName()
96 throw( uno::RuntimeException
)
98 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.toolkit.UnoThrobberControlModel" ) );
101 //--------------------------------------------------------------------
102 uno::Sequence
< ::rtl::OUString
> SAL_CALL
UnoThrobberControlModel::getSupportedServiceNames()
103 throw( uno::RuntimeException
)
105 uno::Sequence
< ::rtl::OUString
> aServices( UnoControlModel::getSupportedServiceNames() );
106 aServices
.realloc( aServices
.getLength() + 1 );
107 aServices
[ aServices
.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_UnoThrobberControlModel
);
111 //====================================================================
112 //= UnoThrobberControl
113 //====================================================================
114 //--------------------------------------------------------------------
115 UnoThrobberControl::UnoThrobberControl()
119 //--------------------------------------------------------------------
120 ::rtl::OUString
UnoThrobberControl::GetComponentServiceName()
122 return ::rtl::OUString::createFromAscii( "Throbber" );
125 //--------------------------------------------------------------------
126 uno::Any
UnoThrobberControl::queryAggregation( const uno::Type
& rType
) throw( uno::RuntimeException
)
128 uno::Any aRet
= UnoControlBase::queryAggregation( rType
);
129 if ( !aRet
.hasValue() )
130 aRet
= UnoThrobberControl_Base::queryInterface( rType
);
134 //--------------------------------------------------------------------
135 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoThrobberControl
, UnoControlBase
, UnoThrobberControl_Base
)
137 //--------------------------------------------------------------------
138 void UnoThrobberControl::dispose() throw( uno::RuntimeException
)
140 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
142 UnoControl::dispose();
145 //--------------------------------------------------------------------
146 ::rtl::OUString SAL_CALL
UnoThrobberControl::getImplementationName()
147 throw( uno::RuntimeException
)
149 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.toolkit.UnoThrobberControl" ) );
152 //--------------------------------------------------------------------
153 uno::Sequence
< ::rtl::OUString
> SAL_CALL
UnoThrobberControl::getSupportedServiceNames()
154 throw( uno::RuntimeException
)
156 uno::Sequence
< ::rtl::OUString
> aServices( UnoControlBase::getSupportedServiceNames() );
157 aServices
.realloc( aServices
.getLength() + 1 );
158 aServices
[ aServices
.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_UnoThrobberControl
);
162 //--------------------------------------------------------------------
163 void UnoThrobberControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
,
164 const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
165 throw( uno::RuntimeException
)
167 UnoControl::createPeer( rxToolkit
, rParentPeer
);
170 //--------------------------------------------------------------------
171 void SAL_CALL
UnoThrobberControl::start() throw ( uno::RuntimeException
)
173 ::osl::MutexGuard
aGuard( GetMutex() );
175 uno::Reference
< XThrobber
> xAnimation( getPeer(), uno::UNO_QUERY
);
176 if ( xAnimation
.is() )
180 //--------------------------------------------------------------------
181 void SAL_CALL
UnoThrobberControl::stop() throw ( uno::RuntimeException
)
183 ::osl::MutexGuard
aGuard( GetMutex() );
185 uno::Reference
< XThrobber
> xAnimation( getPeer(), uno::UNO_QUERY
);
186 if ( xAnimation
.is() )
190 //........................................................................
191 } // namespace toolkit
192 //........................................................................