1 /*************************************************************************
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * Copyright 2000, 2010 Oracle and/or its affiliates.
5  *
6  * OpenOffice.org - a multi-platform office productivity suite
7  *
8  * This file is part of OpenOffice.org.
9  *
10  * OpenOffice.org is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License version 3
12  * only, as published by the Free Software Foundation.
13  *
14  * OpenOffice.org is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License version 3 for more details
18  * (a copy is included in the LICENSE file that accompanied this code).
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with OpenOffice.org.  If not, see
22  * <http://www.openoffice.org/license.html>
23  * for a copy of the LGPLv3 License.
24  *
25  ************************************************************************/
26 
27 #include "precompiled_toolkit.hxx"
28 
29 #include "toolkit/controls/spinningprogress.hxx"
30 #include "toolkit/helper/servicenames.hxx"
31 #include "toolkit/helper/unopropertyarrayhelper.hxx"
32 
33 /** === begin UNO includes === **/
34 /** === end UNO includes === **/
35 
36 #include <rtl/ustrbuf.hxx>
37 #include <tools/diagnose_ex.h>
38 #include <vcl/throbber.hxx>
39 
40 //......................................................................................................................
41 namespace toolkit
42 {
43 //......................................................................................................................
44 
45 	/** === begin UNO using === **/
46 	using ::com::sun::star::uno::Reference;
47 	using ::com::sun::star::uno::XInterface;
48 	using ::com::sun::star::uno::UNO_QUERY;
49 	using ::com::sun::star::uno::UNO_QUERY_THROW;
50 	using ::com::sun::star::uno::UNO_SET_THROW;
51 	using ::com::sun::star::uno::Exception;
52 	using ::com::sun::star::uno::RuntimeException;
53 	using ::com::sun::star::uno::Any;
54 	using ::com::sun::star::uno::makeAny;
55 	using ::com::sun::star::uno::Sequence;
56 	using ::com::sun::star::uno::Type;
57     using ::com::sun::star::beans::XPropertySetInfo;
58     using ::com::sun::star::lang::XMultiServiceFactory;
59 	/** === end UNO using === **/
60 
61 	//==================================================================================================================
62 	//= SpinningProgressControlModel
63 	//==================================================================================================================
64 	//------------------------------------------------------------------------------------------------------------------
65     SpinningProgressControlModel::SpinningProgressControlModel( Reference< XMultiServiceFactory > const & i_factory )
66         :SpinningProgressControlModel_Base( i_factory )
67     {
68         // default image sets
69         osl_incrementInterlockedCount( &m_refCount );
70         {
71             try
72             {
73                 Throbber::ImageSet aImageSets[] =
74                 {
75                     Throbber::IMAGES_16_PX, Throbber::IMAGES_32_PX, Throbber::IMAGES_64_PX
76                 };
77                 for ( size_t i=0; i < sizeof( aImageSets ) / sizeof( aImageSets[0] ); ++i )
78                 {
79                     const ::std::vector< ::rtl::OUString > aDefaultURLs( Throbber::getDefaultImageURLs( aImageSets[i] ) );
80                     const Sequence< ::rtl::OUString > aImageURLs( &aDefaultURLs[0], aDefaultURLs.size() );
81                     insertImageSet( i, aImageURLs );
82                 }
83             }
84             catch( const Exception& )
85             {
86             	DBG_UNHANDLED_EXCEPTION();
87             }
88         }
89         osl_decrementInterlockedCount( &m_refCount );
90     }
91 
92 	//------------------------------------------------------------------------------------------------------------------
93     SpinningProgressControlModel::SpinningProgressControlModel( const SpinningProgressControlModel& i_copySource )
94         :SpinningProgressControlModel_Base( i_copySource )
95     {
96     }
97 
98     //------------------------------------------------------------------------------------------------------------------
99     SpinningProgressControlModel::~SpinningProgressControlModel()
100     {
101     }
102 
103     //------------------------------------------------------------------------------------------------------------------
104     UnoControlModel* SpinningProgressControlModel::Clone() const
105     {
106         return new SpinningProgressControlModel( *this );
107     }
108 
109     //------------------------------------------------------------------------------------------------------------------
110     Reference< XPropertySetInfo > SAL_CALL SpinningProgressControlModel::getPropertySetInfo(  ) throw(RuntimeException)
111     {
112         static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
113         return xInfo;
114     }
115 
116     //------------------------------------------------------------------------------------------------------------------
117     ::rtl::OUString SAL_CALL SpinningProgressControlModel::getServiceName() throw(RuntimeException)
118     {
119         return ::rtl::OUString::createFromAscii( szServiceName_SpinningProgressControlModel );
120     }
121 
122     //------------------------------------------------------------------------------------------------------------------
123     ::rtl::OUString SAL_CALL SpinningProgressControlModel::getImplementationName(  ) throw(RuntimeException)
124     {
125         return ::rtl::OUString::createFromAscii( "org.openoffice.comp.toolkit.SpinningProgressControlModel" );
126     }
127 
128     //------------------------------------------------------------------------------------------------------------------
129     Sequence< ::rtl::OUString > SAL_CALL SpinningProgressControlModel::getSupportedServiceNames() throw(RuntimeException)
130     {
131         Sequence< ::rtl::OUString > aServiceNames(3);
132         aServiceNames[0] = ::rtl::OUString::createFromAscii( szServiceName_SpinningProgressControlModel );
133         aServiceNames[1] = ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControlModel );
134         aServiceNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.UnoControlModel" );
135         return aServiceNames;
136     }
137 
138 //......................................................................................................................
139 } // namespace toolkit
140 //......................................................................................................................
141