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 <rtl/ustrbuf.hxx>
21 : #include <toolkit/controls/animatedimages.hxx>
22 : #include <tools/diagnose_ex.h>
23 : #include <vcl/throbber.hxx>
24 :
25 : using namespace css;
26 : using namespace css::uno;
27 :
28 : namespace {
29 :
30 : typedef toolkit::AnimatedImagesControlModel SpinningProgressControlModel_Base;
31 : class SpinningProgressControlModel : public SpinningProgressControlModel_Base
32 : {
33 : public:
34 : SpinningProgressControlModel( css::uno::Reference< css::uno::XComponentContext > const & i_factory );
35 : SpinningProgressControlModel( const SpinningProgressControlModel& i_copySource );
36 :
37 : virtual UnoControlModel* Clone() const SAL_OVERRIDE;
38 :
39 : // XPropertySet
40 : css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
41 :
42 : // XPersistObject
43 : OUString SAL_CALL getServiceName() throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
44 :
45 : // XServiceInfo
46 : OUString SAL_CALL getImplementationName( ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
47 : css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
48 :
49 : protected:
50 : virtual ~SpinningProgressControlModel();
51 : };
52 :
53 0 : SpinningProgressControlModel::SpinningProgressControlModel( Reference< XComponentContext > const & i_factory )
54 0 : :SpinningProgressControlModel_Base( i_factory )
55 : {
56 : // default image sets
57 0 : osl_atomic_increment( &m_refCount );
58 : {
59 : try
60 : {
61 : Throbber::ImageSet aImageSets[] =
62 : {
63 : Throbber::IMAGES_16_PX, Throbber::IMAGES_32_PX, Throbber::IMAGES_64_PX
64 0 : };
65 0 : for ( size_t i=0; i < sizeof( aImageSets ) / sizeof( aImageSets[0] ); ++i )
66 : {
67 0 : const ::std::vector< OUString > aDefaultURLs( Throbber::getDefaultImageURLs( aImageSets[i] ) );
68 0 : const Sequence< OUString > aImageURLs( &aDefaultURLs[0], aDefaultURLs.size() );
69 0 : insertImageSet( i, aImageURLs );
70 0 : }
71 : }
72 0 : catch( const Exception& )
73 : {
74 : DBG_UNHANDLED_EXCEPTION();
75 : }
76 : }
77 0 : osl_atomic_decrement( &m_refCount );
78 0 : }
79 :
80 :
81 0 : SpinningProgressControlModel::SpinningProgressControlModel( const SpinningProgressControlModel& i_copySource )
82 0 : :SpinningProgressControlModel_Base( i_copySource )
83 : {
84 0 : }
85 :
86 :
87 0 : SpinningProgressControlModel::~SpinningProgressControlModel()
88 : {
89 0 : }
90 :
91 :
92 0 : UnoControlModel* SpinningProgressControlModel::Clone() const
93 : {
94 0 : return new SpinningProgressControlModel( *this );
95 : }
96 :
97 :
98 0 : Reference< beans::XPropertySetInfo > SAL_CALL SpinningProgressControlModel::getPropertySetInfo( ) throw(RuntimeException, std::exception)
99 : {
100 0 : static Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
101 0 : return xInfo;
102 : }
103 :
104 :
105 0 : OUString SAL_CALL SpinningProgressControlModel::getServiceName() throw(RuntimeException, std::exception)
106 : {
107 0 : return OUString("com.sun.star.awt.SpinningProgressControlModel");
108 : }
109 :
110 :
111 0 : OUString SAL_CALL SpinningProgressControlModel::getImplementationName( ) throw(RuntimeException, std::exception)
112 : {
113 0 : return OUString("org.openoffice.comp.toolkit.SpinningProgressControlModel");
114 : }
115 :
116 :
117 0 : Sequence< OUString > SAL_CALL SpinningProgressControlModel::getSupportedServiceNames() throw(RuntimeException, std::exception)
118 : {
119 0 : Sequence< OUString > aServiceNames(3);
120 0 : aServiceNames[0] = "com.sun.star.awt.SpinningProgressControlModel";
121 0 : aServiceNames[1] = "com.sun.star.awt.AnimatedImagesControlModel";
122 0 : aServiceNames[2] = "com.sun.star.awt.UnoControlModel";
123 0 : return aServiceNames;
124 : }
125 :
126 : }
127 :
128 : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
129 0 : org_openoffice_comp_toolkit_SpinningProgressControlModel_get_implementation(
130 : css::uno::XComponentContext *context,
131 : css::uno::Sequence<css::uno::Any> const &)
132 : {
133 0 : return cppu::acquire(new SpinningProgressControlModel(context));
134 : }
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|