Avoid potential negative array index access to cached text.
[LibreOffice.git] / toolkit / source / controls / spinningprogress.cxx
blob851d624a3dd2ddad62fa30a4c4be85f12cea211b
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 <com/sun/star/uno/XComponentContext.hpp>
21 #include <controls/animatedimages.hxx>
22 #include <comphelper/diagnose_ex.hxx>
23 #include <vcl/toolkit/throbber.hxx>
25 using namespace css;
26 using namespace css::uno;
28 namespace {
30 typedef toolkit::AnimatedImagesControlModel SpinningProgressControlModel_Base;
31 class SpinningProgressControlModel : public SpinningProgressControlModel_Base
33 public:
34 explicit SpinningProgressControlModel( css::uno::Reference< css::uno::XComponentContext > const & i_factory );
35 SpinningProgressControlModel(const SpinningProgressControlModel& rOther) : SpinningProgressControlModel_Base(rOther) {}
37 virtual rtl::Reference<UnoControlModel> Clone() const override;
39 // XPropertySet
40 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
42 // XPersistObject
43 OUString SAL_CALL getServiceName() override;
45 // XServiceInfo
46 OUString SAL_CALL getImplementationName( ) override;
47 css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
49 protected:
50 virtual ~SpinningProgressControlModel() override;
53 SpinningProgressControlModel::SpinningProgressControlModel( Reference< XComponentContext > const & i_factory )
54 :SpinningProgressControlModel_Base( i_factory )
56 // default image sets
57 osl_atomic_increment( &m_refCount );
59 try
61 Throbber::ImageSet aImageSets[] =
63 Throbber::ImageSet::N16px, Throbber::ImageSet::N32px, Throbber::ImageSet::N64px
65 for ( size_t i=0; i < SAL_N_ELEMENTS(aImageSets); ++i )
67 const ::std::vector< OUString > aDefaultURLs( Throbber::getDefaultImageURLs( aImageSets[i] ) );
68 const Sequence< OUString > aImageURLs( aDefaultURLs.data(), aDefaultURLs.size() );
69 insertImageSet( i, aImageURLs );
72 catch( const Exception& )
74 DBG_UNHANDLED_EXCEPTION("toolkit.controls");
77 osl_atomic_decrement( &m_refCount );
81 SpinningProgressControlModel::~SpinningProgressControlModel()
86 rtl::Reference<UnoControlModel> SpinningProgressControlModel::Clone() const
88 return new SpinningProgressControlModel( *this );
92 Reference< beans::XPropertySetInfo > SAL_CALL SpinningProgressControlModel::getPropertySetInfo( )
94 static Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
95 return xInfo;
99 OUString SAL_CALL SpinningProgressControlModel::getServiceName()
101 return "com.sun.star.awt.SpinningProgressControlModel";
105 OUString SAL_CALL SpinningProgressControlModel::getImplementationName( )
107 return "org.openoffice.comp.toolkit.SpinningProgressControlModel";
111 Sequence< OUString > SAL_CALL SpinningProgressControlModel::getSupportedServiceNames()
113 return { "com.sun.star.awt.SpinningProgressControlModel",
114 "com.sun.star.awt.AnimatedImagesControlModel",
115 "com.sun.star.awt.UnoControlModel" };
120 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
121 org_openoffice_comp_toolkit_SpinningProgressControlModel_get_implementation(
122 css::uno::XComponentContext *context,
123 css::uno::Sequence<css::uno::Any> const &)
125 return cppu::acquire(new SpinningProgressControlModel(context));
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */