LibreOffice Module chart2 (master) 1
DataTableItemConverter.cxx
Go to the documentation of this file.
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
11#include <ItemPropertyMap.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>
26#include <memory>
27
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>
35
36using namespace css;
37
38namespace chart::wrapper
39{
40namespace
41{
42ItemPropertyMapType& lclDataTablePropertyMap()
43{
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 } },
49 };
50 return aPropertyMap;
51};
52}
53
55 const uno::Reference<beans::XPropertySet>& rPropertySet, SfxItemPool& rItemPool,
56 SdrModel& rDrawModel, const rtl::Reference<::chart::ChartModel>& xChartDoc)
57 : ItemConverter(rPropertySet, rItemPool)
58{
60 rPropertySet, rItemPool, rDrawModel, xChartDoc, GraphicObjectType::LineProperties));
61 m_aConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, rItemPool));
62}
63
65
67{
68 for (const auto& pConv : m_aConverters)
69 {
70 pConv->FillItemSet(rOutItemSet);
71 }
72
73 // own items
74 ItemConverter::FillItemSet(rOutItemSet);
75}
76
78{
79 bool bResult = false;
80
81 for (const auto& pConv : m_aConverters)
82 {
83 bResult = pConv->ApplyItemSet(rItemSet) || bResult;
84 }
85
86 // own items
87 return ItemConverter::ApplyItemSet(rItemSet) || bResult;
88}
89
91{
93}
94
96 tPropertyNameWithMemberId& rOutProperty) const
97{
98 ItemPropertyMapType& rMap(lclDataTablePropertyMap());
99 auto aIt = rMap.find(nWhichId);
100 if (aIt == rMap.cend())
101 return false;
102
103 rOutProperty = (*aIt).second;
104
105 return true;
106}
107}
108
109/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATA_TABLE_OUTLINE(SCHATTR_DATA_TABLE_START+2)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATA_TABLE_HORIZONTAL_BORDER(SCHATTR_DATA_TABLE_START+0)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATA_TABLE_KEYS(SCHATTR_DATA_TABLE_START+3)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATA_TABLE_VERTICAL_BORDER(SCHATTR_DATA_TABLE_START+1)
const WhichRangesContainer nDataTableWhichPairs(svl::Items< SCHATTR_DATA_TABLE_START, SCHATTR_DATA_TABLE_END, XATTR_LINE_FIRST, XATTR_LINE_LAST, XATTR_FILL_FIRST, XATTR_FILL_LAST, EE_ITEMS_START, EE_ITEMS_END >)
DataTableItemConverter(const css::uno::Reference< css::beans::XPropertySet > &rPropertySet, SfxItemPool &rItemPool, SdrModel &rDrawModel, const rtl::Reference<::chart::ChartModel > &xChartDoc)
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
virtual void FillItemSet(SfxItemSet &rOutItemSet) const override
applies all properties that can be mapped to items into the given item set.
virtual ~DataTableItemConverter() override
std::vector< std::unique_ptr< ItemConverter > > m_aConverters
virtual bool ApplyItemSet(const SfxItemSet &rItemSet) override
applies all properties that are results of a conversion from all items in rItemSet to the internal XP...
virtual bool GetItemProperty(tWhichIdType nWhichId, tPropertyNameWithMemberId &rOutProperty) const override
implement this method to return a Property object for a given which id.
This class serves for conversion between properties of an XPropertySet and SfxItems in SfxItemSets.
virtual void FillItemSet(SfxItemSet &rOutItemSet) const
applies all properties that can be mapped to items into the given item set.
std::pair< tPropertyNameType, tMemberIdType > tPropertyNameWithMemberId
virtual bool ApplyItemSet(const SfxItemSet &rItemSet)
applies all properties that are results of a conversion from all items in rItemSet to the internal XP...
std::map< ItemConverter::tWhichIdType, std::pair< ItemConverter::tPropertyNameType, ItemConverter::tMemberIdType > > ItemPropertyMapType