Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / toolkit / source / controls / tkthrobber.cxx
blob7de89801210ba35f9badd584b0987397a6fe7a7d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "toolkit/controls/tkthrobber.hxx"
21 #include "toolkit/helper/property.hxx"
22 #include "toolkit/helper/unopropertyarrayhelper.hxx"
23 #include <cppuhelper/typeprovider.hxx>
25 //........................................................................
26 namespace toolkit
28 //........................................................................
30 using namespace ::com::sun::star;
32 //====================================================================
33 //= UnoThrobberControlModel
34 //====================================================================
35 //--------------------------------------------------------------------
36 UnoThrobberControlModel::UnoThrobberControlModel( const uno::Reference< lang::XMultiServiceFactory >& i_factory )
37 :UnoControlModel( i_factory )
39 ImplRegisterProperty( BASEPROPERTY_BORDER );
40 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
41 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
42 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
43 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
44 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
45 ImplRegisterProperty( BASEPROPERTY_HELPURL );
48 //--------------------------------------------------------------------
49 ::rtl::OUString UnoThrobberControlModel::getServiceName( ) throw ( uno::RuntimeException )
51 return ::rtl::OUString::createFromAscii( szServiceName_UnoThrobberControlModel );
54 //--------------------------------------------------------------------
55 uno::Any UnoThrobberControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
57 switch ( nPropId )
59 case BASEPROPERTY_DEFAULTCONTROL:
60 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoThrobberControl ) );
61 case BASEPROPERTY_BORDER:
62 return uno::makeAny( (sal_Int16) 0 );
63 default:
64 return UnoControlModel::ImplGetDefaultValue( nPropId );
68 //--------------------------------------------------------------------
69 ::cppu::IPropertyArrayHelper& UnoThrobberControlModel::getInfoHelper()
71 static UnoPropertyArrayHelper* pHelper = NULL;
72 if ( !pHelper )
74 uno::Sequence< sal_Int32 > aIDs = ImplGetPropertyIds();
75 pHelper = new UnoPropertyArrayHelper( aIDs );
77 return *pHelper;
80 //--------------------------------------------------------------------
81 uno::Reference< beans::XPropertySetInfo > UnoThrobberControlModel::getPropertySetInfo()
82 throw( uno::RuntimeException )
84 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
85 return xInfo;
88 //--------------------------------------------------------------------
89 ::rtl::OUString SAL_CALL UnoThrobberControlModel::getImplementationName()
90 throw( uno::RuntimeException )
92 return ::rtl::OUString( "com.sun.star.comp.toolkit.UnoThrobberControlModel" );
95 //--------------------------------------------------------------------
96 uno::Sequence< ::rtl::OUString > SAL_CALL UnoThrobberControlModel::getSupportedServiceNames()
97 throw( uno::RuntimeException )
99 uno::Sequence< ::rtl::OUString > aServices( UnoControlModel::getSupportedServiceNames() );
100 aServices.realloc( aServices.getLength() + 2 );
101 aServices[sal::static_int_cast<sal_uInt32>(aServices.getLength()) - 2] =
102 ::rtl::OUString::createFromAscii(szServiceName_UnoThrobberControlModel);
103 aServices[sal::static_int_cast<sal_uInt32>(aServices.getLength()) - 1] =
104 ::rtl::OUString::createFromAscii(szServiceName2_UnoThrobberControlModel);
105 return aServices;
108 //====================================================================
109 //= UnoThrobberControl
110 //====================================================================
111 //--------------------------------------------------------------------
112 UnoThrobberControl::UnoThrobberControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory )
113 :UnoControlBase( i_factory )
117 //--------------------------------------------------------------------
118 ::rtl::OUString UnoThrobberControl::GetComponentServiceName()
120 return ::rtl::OUString("Throbber");
123 //--------------------------------------------------------------------
124 uno::Any UnoThrobberControl::queryAggregation( const uno::Type & rType ) throw( uno::RuntimeException )
126 uno::Any aRet = UnoControlBase::queryAggregation( rType );
127 if ( !aRet.hasValue() )
128 aRet = UnoThrobberControl_Base::queryInterface( rType );
129 return aRet;
132 //--------------------------------------------------------------------
133 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoThrobberControl, UnoControlBase, UnoThrobberControl_Base )
135 //--------------------------------------------------------------------
136 void UnoThrobberControl::dispose() throw( uno::RuntimeException )
138 ::osl::ClearableMutexGuard aGuard( GetMutex() );
140 UnoControl::dispose();
143 //--------------------------------------------------------------------
144 ::rtl::OUString SAL_CALL UnoThrobberControl::getImplementationName()
145 throw( uno::RuntimeException )
147 return ::rtl::OUString( "com.sun.star.comp.toolkit.UnoThrobberControl" );
150 //--------------------------------------------------------------------
151 uno::Sequence< ::rtl::OUString > SAL_CALL UnoThrobberControl::getSupportedServiceNames()
152 throw( uno::RuntimeException )
154 uno::Sequence< ::rtl::OUString > aServices( UnoControlBase::getSupportedServiceNames() );
155 aServices.realloc( aServices.getLength() + 2 );
156 aServices[sal::static_int_cast<sal_uInt32>(aServices.getLength()) - 2] =
157 ::rtl::OUString::createFromAscii(szServiceName_UnoThrobberControl);
158 aServices[sal::static_int_cast<sal_uInt32>(aServices.getLength()) - 1] =
159 ::rtl::OUString::createFromAscii(szServiceName2_UnoThrobberControl);
160 return aServices;
163 //--------------------------------------------------------------------
164 void UnoThrobberControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit,
165 const uno::Reference< awt::XWindowPeer > & rParentPeer )
166 throw( uno::RuntimeException )
168 UnoControl::createPeer( rxToolkit, rParentPeer );
171 //--------------------------------------------------------------------
172 void SAL_CALL UnoThrobberControl::start() throw ( uno::RuntimeException )
174 ::osl::MutexGuard aGuard( GetMutex() );
176 uno::Reference< XThrobber > xAnimation( getPeer(), uno::UNO_QUERY );
177 if ( xAnimation.is() )
178 xAnimation->start();
181 //--------------------------------------------------------------------
182 void SAL_CALL UnoThrobberControl::stop() throw ( uno::RuntimeException )
184 ::osl::MutexGuard aGuard( GetMutex() );
186 uno::Reference< XThrobber > xAnimation( getPeer(), uno::UNO_QUERY );
187 if ( xAnimation.is() )
188 xAnimation->stop();
191 //........................................................................
192 } // namespace toolkit
193 //........................................................................
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */