Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / controller / itemsetwrapper / DataTableItemConverter.cxx
blob62a5e2b0396bf2c6075a9ce84654639e9b8d1d4c
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/.
8 */
10 #include <DataTableItemConverter.hxx>
11 #include <ItemPropertyMap.hxx>
12 #include <CharacterPropertyItemConverter.hxx>
13 #include <GraphicPropertyItemConverter.hxx>
14 #include <chartview/ChartSfxItemIds.hxx>
15 #include <chartview/ExplicitScaleValues.hxx>
16 #include <chartview/ExplicitValueProvider.hxx>
17 #include "SchWhichPairs.hxx"
18 #include <ChartModelHelper.hxx>
19 #include <ChartModel.hxx>
20 #include <CommonConverters.hxx>
21 #include <ChartType.hxx>
22 #include <ChartTypeHelper.hxx>
23 #include <Diagram.hxx>
24 #include <unonames.hxx>
25 #include <BaseCoordinateSystem.hxx>
26 #include <memory>
28 #include <osl/diagnose.h>
29 #include <o3tl/any.hxx>
30 #include <svl/eitem.hxx>
31 #include <svx/chrtitem.hxx>
32 #include <svx/sdangitm.hxx>
33 #include <svl/intitem.hxx>
34 #include <rtl/math.hxx>
36 using namespace css;
38 namespace chart::wrapper
40 namespace
42 ItemPropertyMapType& lclDataTablePropertyMap()
44 static ItemPropertyMapType aPropertyMap{
45 { SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, { "HBorder", 0 } },
46 { SCHATTR_DATA_TABLE_VERTICAL_BORDER, { "VBorder", 0 } },
47 { SCHATTR_DATA_TABLE_OUTLINE, { "Outline", 0 } },
48 { SCHATTR_DATA_TABLE_KEYS, { "Keys", 0 } },
50 return aPropertyMap;
54 DataTableItemConverter::DataTableItemConverter(
55 const uno::Reference<beans::XPropertySet>& rPropertySet, SfxItemPool& rItemPool,
56 SdrModel& rDrawModel, const rtl::Reference<::chart::ChartModel>& xChartDoc)
57 : ItemConverter(rPropertySet, rItemPool)
59 m_aConverters.emplace_back(new GraphicPropertyItemConverter(
60 rPropertySet, rItemPool, rDrawModel, xChartDoc, GraphicObjectType::LineProperties));
61 m_aConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, rItemPool));
64 DataTableItemConverter::~DataTableItemConverter() = default;
66 void DataTableItemConverter::FillItemSet(SfxItemSet& rOutItemSet) const
68 for (const auto& pConv : m_aConverters)
70 pConv->FillItemSet(rOutItemSet);
73 // own items
74 ItemConverter::FillItemSet(rOutItemSet);
77 bool DataTableItemConverter::ApplyItemSet(const SfxItemSet& rItemSet)
79 bool bResult = false;
81 for (const auto& pConv : m_aConverters)
83 bResult = pConv->ApplyItemSet(rItemSet) || bResult;
86 // own items
87 return ItemConverter::ApplyItemSet(rItemSet) || bResult;
90 const WhichRangesContainer& DataTableItemConverter::GetWhichPairs() const
92 return nDataTableWhichPairs;
95 bool DataTableItemConverter::GetItemProperty(tWhichIdType nWhichId,
96 tPropertyNameWithMemberId& rOutProperty) const
98 ItemPropertyMapType& rMap(lclDataTablePropertyMap());
99 auto aIt = rMap.find(nWhichId);
100 if (aIt == rMap.cend())
101 return false;
103 rOutProperty = (*aIt).second;
105 return true;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */