Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / inc / BaseCoordinateSystem.hxx
blob71f226abcd5187dbb56739361786deedc4bc21a8
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/XCoordinateSystem.hpp>
26 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
27 #include <com/sun/star/util/XCloneable.hpp>
28 #include "ModifyListenerHelper.hxx"
30 #include <vector>
32 namespace chart
34 class Axis;
35 class ChartType;
37 namespace impl
39 typedef ::cppu::WeakImplHelper
40 < css::lang::XServiceInfo,
41 css::chart2::XCoordinateSystem,
42 css::chart2::XChartTypeContainer,
43 css::util::XCloneable,
44 css::util::XModifyBroadcaster,
45 css::util::XModifyListener >
46 BaseCoordinateSystem_Base;
49 class SAL_DLLPUBLIC_RTTI BaseCoordinateSystem :
50 public impl::BaseCoordinateSystem_Base,
51 public ::property::OPropertySet
53 public:
54 BaseCoordinateSystem( sal_Int32 nDimensionCount );
55 explicit BaseCoordinateSystem( const BaseCoordinateSystem & rSource );
56 virtual ~BaseCoordinateSystem() override;
58 // ____ OPropertySet ____
59 virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
61 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
63 // ____ XPropertySet ____
64 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
65 getPropertySetInfo() override;
67 /// merge XInterface implementations
68 DECLARE_XINTERFACE()
69 /// merge XTypeProvider implementations
70 DECLARE_XTYPEPROVIDER()
72 // ____ XCoordinateSystem ____
73 virtual ::sal_Int32 SAL_CALL getDimension() override;
74 virtual void SAL_CALL setAxisByDimension(
75 ::sal_Int32 nDimension,
76 const css::uno::Reference< css::chart2::XAxis >& xAxis,
77 ::sal_Int32 nIndex ) override;
78 virtual css::uno::Reference< css::chart2::XAxis > SAL_CALL getAxisByDimension(
79 ::sal_Int32 nDimension, ::sal_Int32 nIndex ) override;
80 virtual ::sal_Int32 SAL_CALL getMaximumAxisIndexByDimension( ::sal_Int32 nDimension ) override;
82 // ____ XChartTypeContainer ____
83 virtual void SAL_CALL addChartType(
84 const css::uno::Reference< css::chart2::XChartType >& aChartType ) override;
85 virtual void SAL_CALL removeChartType(
86 const css::uno::Reference< css::chart2::XChartType >& aChartType ) override;
87 virtual css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > > SAL_CALL getChartTypes() override;
88 virtual void SAL_CALL setChartTypes(
89 const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aChartTypes ) final override;
91 // ____ XModifyBroadcaster ____
92 virtual void SAL_CALL addModifyListener(
93 const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
94 virtual void SAL_CALL removeModifyListener(
95 const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
97 void setAxisByDimension( sal_Int32 nDimension, const rtl::Reference< ::chart::Axis >& xAxis, sal_Int32 nIndex );
98 const rtl::Reference< ::chart::Axis > & getAxisByDimension2(sal_Int32 nDimension, sal_Int32 nIndex ) const;
100 void setChartTypes( const std::vector< rtl::Reference< ::chart::ChartType > >& aChartTypes );
101 const std::vector< rtl::Reference<::chart::ChartType > > & getChartTypes2() const { return m_aChartTypes; }
103 protected:
105 // ____ XModifyListener ____
106 virtual void SAL_CALL modified(
107 const css::lang::EventObject& aEvent ) override;
109 // ____ XEventListener (base of XModifyListener) ____
110 virtual void SAL_CALL disposing(
111 const css::lang::EventObject& Source ) override;
113 // ____ OPropertySet ____
114 virtual void firePropertyChangeEvent() override;
115 using OPropertySet::disposing;
117 void fireModifyEvent();
119 private:
120 rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
121 sal_Int32 m_nDimensionCount;
122 typedef std::vector< std::vector< rtl::Reference< ::chart::Axis > > > tAxisVecVecType;
123 tAxisVecVecType m_aAllAxis; //outer sequence is the dimension; inner sequence is the axis index that indicates main or secondary axis
124 std::vector< rtl::Reference<::chart::ChartType > > m_aChartTypes;
127 } // namespace chart
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */