Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "toolkit/controls/tksimpleanimation.hxx"
21 : #include "toolkit/helper/property.hxx"
22 : #include "toolkit/helper/unopropertyarrayhelper.hxx"
23 : #include <cppuhelper/typeprovider.hxx>
24 :
25 : //........................................................................
26 : namespace toolkit
27 : {
28 : //........................................................................
29 :
30 : using namespace ::com::sun::star;
31 :
32 : //====================================================================
33 : //= UnoSimpleAnimationControlModel
34 : //====================================================================
35 : //--------------------------------------------------------------------
36 0 : UnoSimpleAnimationControlModel::UnoSimpleAnimationControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory )
37 0 : :UnoControlModel( i_factory )
38 : {
39 0 : ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
40 0 : ImplRegisterProperty( BASEPROPERTY_REPEAT );
41 0 : ImplRegisterProperty( BASEPROPERTY_STEP_TIME );
42 0 : }
43 :
44 : //--------------------------------------------------------------------
45 0 : ::rtl::OUString UnoSimpleAnimationControlModel::getServiceName()
46 : throw( uno::RuntimeException )
47 : {
48 0 : return ::rtl::OUString::createFromAscii( szServiceName_UnoSimpleAnimationControlModel );
49 : }
50 :
51 : //--------------------------------------------------------------------
52 0 : uno::Any UnoSimpleAnimationControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
53 : {
54 0 : switch ( nPropId )
55 : {
56 : case BASEPROPERTY_DEFAULTCONTROL:
57 0 : return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoSimpleAnimationControl ) );
58 :
59 : case BASEPROPERTY_STEP_TIME:
60 0 : return uno::makeAny( (sal_Int32) 100 );
61 :
62 : case BASEPROPERTY_REPEAT:
63 0 : return uno::makeAny( (sal_Bool)sal_True );
64 :
65 : default:
66 0 : return UnoControlModel::ImplGetDefaultValue( nPropId );
67 : }
68 : }
69 :
70 : //--------------------------------------------------------------------
71 0 : ::cppu::IPropertyArrayHelper& UnoSimpleAnimationControlModel::getInfoHelper()
72 : {
73 : static UnoPropertyArrayHelper* pHelper = NULL;
74 0 : if ( !pHelper )
75 : {
76 0 : uno::Sequence< sal_Int32 > aIDs = ImplGetPropertyIds();
77 0 : pHelper = new UnoPropertyArrayHelper( aIDs );
78 : }
79 0 : return *pHelper;
80 : }
81 :
82 : //--------------------------------------------------------------------
83 0 : uno::Reference< beans::XPropertySetInfo > UnoSimpleAnimationControlModel::getPropertySetInfo( )
84 : throw( uno::RuntimeException )
85 : {
86 0 : static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
87 0 : return xInfo;
88 : }
89 :
90 : //--------------------------------------------------------------------
91 0 : ::rtl::OUString SAL_CALL UnoSimpleAnimationControlModel::getImplementationName()
92 : throw( uno::RuntimeException )
93 : {
94 0 : return ::rtl::OUString( "com.sun.star.comp.toolkit.UnoSimpleAnimationControlModel" );
95 : }
96 :
97 : //--------------------------------------------------------------------
98 0 : uno::Sequence< ::rtl::OUString > SAL_CALL UnoSimpleAnimationControlModel::getSupportedServiceNames()
99 : throw( uno::RuntimeException )
100 : {
101 0 : uno::Sequence< ::rtl::OUString > aServices( UnoControlModel::getSupportedServiceNames() );
102 0 : aServices.realloc( aServices.getLength() + 2 );
103 0 : aServices[sal::static_int_cast<sal_uInt32>(aServices.getLength()) - 2]
104 0 : = ::rtl::OUString::createFromAscii( szServiceName_UnoSimpleAnimationControlModel );
105 0 : aServices[sal::static_int_cast<sal_uInt32>(aServices.getLength()) - 1]
106 0 : = ::rtl::OUString::createFromAscii( szServiceName2_UnoSimpleAnimationControlModel );
107 0 : return aServices;
108 : }
109 :
110 : //====================================================================
111 : //= UnoSimpleAnimationControl
112 : //====================================================================
113 : //--------------------------------------------------------------------
114 0 : UnoSimpleAnimationControl::UnoSimpleAnimationControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory )
115 0 : :UnoSimpleAnimationControl_Base( i_factory )
116 : {
117 0 : }
118 :
119 : //--------------------------------------------------------------------
120 0 : ::rtl::OUString UnoSimpleAnimationControl::GetComponentServiceName()
121 : {
122 0 : return ::rtl::OUString("SimpleAnimation");
123 : }
124 :
125 : //--------------------------------------------------------------------
126 0 : ::rtl::OUString SAL_CALL UnoSimpleAnimationControl::getImplementationName()
127 : throw( uno::RuntimeException )
128 : {
129 0 : return ::rtl::OUString( "com.sun.star.comp.toolkit.UnoSimpleAnimationControl" );
130 : }
131 :
132 : //--------------------------------------------------------------------
133 0 : uno::Sequence< ::rtl::OUString > SAL_CALL UnoSimpleAnimationControl::getSupportedServiceNames()
134 : throw( uno::RuntimeException )
135 : {
136 0 : uno::Sequence< ::rtl::OUString > aServices( UnoSimpleAnimationControl_Base::getSupportedServiceNames() );
137 0 : aServices.realloc( aServices.getLength() + 1 );
138 0 : aServices[ aServices.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_UnoSimpleAnimationControl );
139 0 : return aServices;
140 : }
141 :
142 : //--------------------------------------------------------------------
143 0 : void SAL_CALL UnoSimpleAnimationControl::start() throw ( uno::RuntimeException )
144 : {
145 0 : uno::Reference< XSimpleAnimation > xAnimation;
146 : {
147 0 : ::osl::MutexGuard aGuard( GetMutex() );
148 0 : xAnimation.set( getPeer(), uno::UNO_QUERY );
149 : }
150 0 : if ( xAnimation.is() )
151 0 : xAnimation->start();
152 0 : }
153 :
154 : //--------------------------------------------------------------------
155 0 : void SAL_CALL UnoSimpleAnimationControl::stop() throw ( uno::RuntimeException )
156 : {
157 0 : uno::Reference< XSimpleAnimation > xAnimation;
158 : {
159 0 : ::osl::MutexGuard aGuard( GetMutex() );
160 0 : xAnimation.set( getPeer(), uno::UNO_QUERY );
161 : }
162 0 : if ( xAnimation.is() )
163 0 : xAnimation->stop();
164 0 : }
165 :
166 : //--------------------------------------------------------------------
167 0 : void SAL_CALL UnoSimpleAnimationControl::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& ImageList )
168 : throw ( uno::RuntimeException )
169 : {
170 0 : uno::Reference< XSimpleAnimation > xAnimation;
171 : {
172 0 : ::osl::MutexGuard aGuard( GetMutex() );
173 0 : xAnimation.set( getPeer(), uno::UNO_QUERY );
174 : }
175 0 : if ( xAnimation.is() )
176 0 : xAnimation->setImageList( ImageList );
177 0 : }
178 :
179 : //........................................................................
180 : } // namespace toolkit
181 : //........................................................................
182 :
183 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|