1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "precompiled_toolkit.hxx"
25 
26 #include "toolkit/controls/spinningprogress.hxx"
27 #include "toolkit/helper/servicenames.hxx"
28 #include "toolkit/helper/unopropertyarrayhelper.hxx"
29 
30 /** === begin UNO includes === **/
31 /** === end UNO includes === **/
32 
33 #include <rtl/ustrbuf.hxx>
34 #include <tools/diagnose_ex.h>
35 #include <vcl/throbber.hxx>
36 
37 //......................................................................................................................
38 namespace toolkit
39 {
40 //......................................................................................................................
41 
42 	/** === begin UNO using === **/
43 	using ::com::sun::star::uno::Reference;
44 	using ::com::sun::star::uno::XInterface;
45 	using ::com::sun::star::uno::UNO_QUERY;
46 	using ::com::sun::star::uno::UNO_QUERY_THROW;
47 	using ::com::sun::star::uno::UNO_SET_THROW;
48 	using ::com::sun::star::uno::Exception;
49 	using ::com::sun::star::uno::RuntimeException;
50 	using ::com::sun::star::uno::Any;
51 	using ::com::sun::star::uno::makeAny;
52 	using ::com::sun::star::uno::Sequence;
53 	using ::com::sun::star::uno::Type;
54     using ::com::sun::star::beans::XPropertySetInfo;
55     using ::com::sun::star::lang::XMultiServiceFactory;
56 	/** === end UNO using === **/
57 
58 	//==================================================================================================================
59 	//= SpinningProgressControlModel
60 	//==================================================================================================================
61 	//------------------------------------------------------------------------------------------------------------------
SpinningProgressControlModel(Reference<XMultiServiceFactory> const & i_factory)62     SpinningProgressControlModel::SpinningProgressControlModel( Reference< XMultiServiceFactory > const & i_factory )
63         :SpinningProgressControlModel_Base( i_factory )
64     {
65         // default image sets
66         osl_incrementInterlockedCount( &m_refCount );
67         {
68             try
69             {
70                 Throbber::ImageSet aImageSets[] =
71                 {
72                     Throbber::IMAGES_16_PX, Throbber::IMAGES_32_PX, Throbber::IMAGES_64_PX
73                 };
74                 for ( size_t i=0; i < sizeof( aImageSets ) / sizeof( aImageSets[0] ); ++i )
75                 {
76                     const ::std::vector< ::rtl::OUString > aDefaultURLs( Throbber::getDefaultImageURLs( aImageSets[i] ) );
77                     const Sequence< ::rtl::OUString > aImageURLs( &aDefaultURLs[0], aDefaultURLs.size() );
78                     insertImageSet( i, aImageURLs );
79                 }
80             }
81             catch( const Exception& )
82             {
83             	DBG_UNHANDLED_EXCEPTION();
84             }
85         }
86         osl_decrementInterlockedCount( &m_refCount );
87     }
88 
89 	//------------------------------------------------------------------------------------------------------------------
SpinningProgressControlModel(const SpinningProgressControlModel & i_copySource)90     SpinningProgressControlModel::SpinningProgressControlModel( const SpinningProgressControlModel& i_copySource )
91         :SpinningProgressControlModel_Base( i_copySource )
92     {
93     }
94 
95     //------------------------------------------------------------------------------------------------------------------
~SpinningProgressControlModel()96     SpinningProgressControlModel::~SpinningProgressControlModel()
97     {
98     }
99 
100     //------------------------------------------------------------------------------------------------------------------
Clone() const101     UnoControlModel* SpinningProgressControlModel::Clone() const
102     {
103         return new SpinningProgressControlModel( *this );
104     }
105 
106     //------------------------------------------------------------------------------------------------------------------
getPropertySetInfo()107     Reference< XPropertySetInfo > SAL_CALL SpinningProgressControlModel::getPropertySetInfo(  ) throw(RuntimeException)
108     {
109         static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
110         return xInfo;
111     }
112 
113     //------------------------------------------------------------------------------------------------------------------
getServiceName()114     ::rtl::OUString SAL_CALL SpinningProgressControlModel::getServiceName() throw(RuntimeException)
115     {
116         return ::rtl::OUString::createFromAscii( szServiceName_SpinningProgressControlModel );
117     }
118 
119     //------------------------------------------------------------------------------------------------------------------
getImplementationName()120     ::rtl::OUString SAL_CALL SpinningProgressControlModel::getImplementationName(  ) throw(RuntimeException)
121     {
122         return ::rtl::OUString::createFromAscii( "org.openoffice.comp.toolkit.SpinningProgressControlModel" );
123     }
124 
125     //------------------------------------------------------------------------------------------------------------------
getSupportedServiceNames()126     Sequence< ::rtl::OUString > SAL_CALL SpinningProgressControlModel::getSupportedServiceNames() throw(RuntimeException)
127     {
128         Sequence< ::rtl::OUString > aServiceNames(3);
129         aServiceNames[0] = ::rtl::OUString::createFromAscii( szServiceName_SpinningProgressControlModel );
130         aServiceNames[1] = ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControlModel );
131         aServiceNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.UnoControlModel" );
132         return aServiceNames;
133     }
134 
135 //......................................................................................................................
136 } // namespace toolkit
137 //......................................................................................................................
138