Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / inc / FormattedString.hxx
blob23c81454facf9be68a4a253c7b47c49a5f4df342
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 .
19 #pragma once
21 #include "OPropertySet.hxx"
22 #include <cppuhelper/implbase.hxx>
23 #include <comphelper/uno3.hxx>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
26 #include <com/sun/star/util/XCloneable.hpp>
27 #include "ModifyListenerHelper.hxx"
28 #include "PropertyHelper.hxx"
30 namespace chart
33 namespace impl
35 typedef ::cppu::WeakImplHelper<
36 css::chart2::XDataPointCustomLabelField, // inherits from XFormattedString2
37 css::lang::XServiceInfo,
38 css::util::XCloneable,
39 css::util::XModifyBroadcaster,
40 css::util::XModifyListener >
41 FormattedString_Base;
44 class FormattedString final :
45 public impl::FormattedString_Base,
46 public ::property::OPropertySet
48 public:
49 explicit FormattedString();
50 virtual ~FormattedString() override;
52 /// declare XServiceInfo methods
53 virtual OUString SAL_CALL getImplementationName() override;
54 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
55 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
57 /// merge XInterface implementations
58 DECLARE_XINTERFACE()
59 /// merge XTypeProvider implementations
60 DECLARE_XTYPEPROVIDER()
62 virtual void SAL_CALL setPropertyValue(const OUString& p1, const css::uno::Any& p2) override
63 { ::property::OPropertySet::setPropertyValue(p1, p2); }
64 virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& p1) override
65 { return ::property::OPropertySet::getPropertyValue(p1); }
66 virtual void SAL_CALL addPropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) override
67 { ::property::OPropertySet::addPropertyChangeListener(p1, p2); }
68 virtual void SAL_CALL removePropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) override
69 { ::property::OPropertySet::removePropertyChangeListener(p1, p2); }
70 virtual void SAL_CALL addVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) override
71 { ::property::OPropertySet::addVetoableChangeListener(p1, p2); }
72 virtual void SAL_CALL removeVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) override
73 { ::property::OPropertySet::removeVetoableChangeListener(p1, p2); }
75 explicit FormattedString( const FormattedString & rOther );
77 // ____ XFormattedString ____
78 virtual OUString SAL_CALL getString() override;
79 virtual void SAL_CALL setString( const OUString& String ) override;
81 // ____ XDataPointCustomLabelField ____
82 virtual css::chart2::DataPointCustomLabelFieldType SAL_CALL getFieldType() override;
83 virtual void SAL_CALL
84 setFieldType( const css::chart2::DataPointCustomLabelFieldType FieldType ) override;
85 virtual OUString SAL_CALL getGuid() override;
86 void SAL_CALL setGuid( const OUString& guid ) override;
87 virtual sal_Bool SAL_CALL getDataLabelsRange() override;
88 virtual void SAL_CALL setDataLabelsRange( sal_Bool dataLabelsRange ) override;
89 virtual OUString SAL_CALL getCellRange() override;
90 virtual void SAL_CALL setCellRange( const OUString& cellRange ) override;
92 // ____ OPropertySet ____
93 virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
95 // ____ OPropertySet ____
96 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
98 // ____ XPropertySet ____
99 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
100 getPropertySetInfo() override;
102 // ____ XCloneable ____
103 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
105 // ____ XModifyBroadcaster ____
106 virtual void SAL_CALL addModifyListener(
107 const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
108 virtual void SAL_CALL removeModifyListener(
109 const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
111 // ____ XModifyListener ____
112 virtual void SAL_CALL modified(
113 const css::lang::EventObject& aEvent ) override;
115 // ____ XEventListener (base of XModifyListener) ____
116 virtual void SAL_CALL disposing(
117 const css::lang::EventObject& Source ) override;
119 private:
120 // ____ OPropertySet ____
121 virtual void firePropertyChangeEvent() override;
122 using OPropertySet::disposing;
124 void fireModifyEvent();
126 // ____ XFormattedString ____
127 OUString m_aString;
129 // ____ XDataPointCustomLabelField ____
130 css::chart2::DataPointCustomLabelFieldType m_aType;
131 OUString m_aGuid;
132 OUString m_aCellRange;
133 bool m_bDataLabelsRange;
135 rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
138 OOO_DLLPUBLIC_CHARTTOOLS const ::chart::tPropertyValueMap & StaticFormattedStringDefaults();
140 } // namespace chart
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */