tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / controller / itemsetwrapper / MultipleChartConverters.cxx
blobbbbee7cf318a2fd0508e03ec69fa85fa7a70521b
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 <MultipleChartConverters.hxx>
22 #include "SchWhichPairs.hxx"
23 #include <AxisItemConverter.hxx>
24 #include <StatisticsItemConverter.hxx>
25 #include <GraphicPropertyItemConverter.hxx>
26 #include <DataPointItemConverter.hxx>
27 #include <ChartModelHelper.hxx>
28 #include <ChartModel.hxx>
29 #include <Diagram.hxx>
30 #include <DataSeries.hxx>
31 #include <GridProperties.hxx>
32 #include <TitleHelper.hxx>
33 #include <TitleItemConverter.hxx>
34 #include <Axis.hxx>
35 #include <AxisHelper.hxx>
36 #include <chartview/ExplicitValueProvider.hxx>
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::chart2;
40 using ::com::sun::star::uno::Reference;
42 namespace chart::wrapper {
44 AllAxisItemConverter::AllAxisItemConverter(
45 const rtl::Reference<::chart::ChartModel> & xChartModel,
46 SfxItemPool& rItemPool,
47 SdrModel& rDrawModel,
48 const std::optional<awt::Size>& pRefSize )
49 : MultipleItemConverter( rItemPool )
51 rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() );
52 const std::vector< rtl::Reference< Axis > > aElementList = AxisHelper::getAllAxesOfDiagram( xDiagram );
53 for( rtl::Reference< Axis > const & axis : aElementList )
55 uno::Reference< beans::XPropertySet > xObjectProperties(axis);
56 m_aConverters.emplace_back( new ::chart::wrapper::AxisItemConverter(
57 xObjectProperties, rItemPool, rDrawModel,
58 xChartModel, nullptr, nullptr,
59 pRefSize));
63 AllAxisItemConverter::~AllAxisItemConverter()
67 const WhichRangesContainer& AllAxisItemConverter::GetWhichPairs() const
69 // must span all used items!
70 return nAllAxisWhichPairs;
73 AllGridItemConverter::AllGridItemConverter(
74 const rtl::Reference<::chart::ChartModel> & xChartModel,
75 SfxItemPool& rItemPool,
76 SdrModel& rDrawModel,
77 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
78 : MultipleItemConverter( rItemPool )
80 rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() );
81 std::vector< rtl::Reference< GridProperties > > aElementList( AxisHelper::getAllGrids( xDiagram ) );
82 for( rtl::Reference< GridProperties > const & xObjectProperties : aElementList )
84 m_aConverters.emplace_back( new ::chart::wrapper::GraphicPropertyItemConverter(
85 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
86 ::chart::wrapper::GraphicObjectType::LineProperties ) );
90 AllGridItemConverter::~AllGridItemConverter()
94 const WhichRangesContainer& AllGridItemConverter::GetWhichPairs() const
96 // must span all used items!
97 return nGridWhichPairs;
100 AllDataLabelItemConverter::AllDataLabelItemConverter(
101 const rtl::Reference<::chart::ChartModel> & xChartModel,
102 SfxItemPool& rItemPool,
103 SdrModel& rDrawModel,
104 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
105 : MultipleItemConverter( rItemPool )
107 std::vector< rtl::Reference< DataSeries > > aSeriesList =
108 ::chart::ChartModelHelper::getDataSeries( xChartModel );
110 for (auto const& series : aSeriesList)
112 uno::Reference< uno::XComponentContext> xContext;//do not need Context for label properties
114 sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( series );
115 sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
116 series,xChartModel);
118 m_aConverters.emplace_back(
119 new ::chart::wrapper::DataPointItemConverter(
120 xChartModel, xContext, series, series, rItemPool, rDrawModel,
121 xNamedPropertyContainerFactory, GraphicObjectType::FilledDataPoint,
122 std::nullopt, true, false, 0, true, nNumberFormat, nPercentNumberFormat));
126 AllDataLabelItemConverter::~AllDataLabelItemConverter()
130 const WhichRangesContainer& AllDataLabelItemConverter::GetWhichPairs() const
132 // must span all used items!
133 return nDataLabelWhichPairs;
136 AllTitleItemConverter::AllTitleItemConverter(
137 const rtl::Reference<::chart::ChartModel> & xChartModel,
138 SfxItemPool& rItemPool,
139 SdrModel& rDrawModel,
140 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
141 : MultipleItemConverter( rItemPool )
143 for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ )
145 rtl::Reference< Title > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) );
146 if(!xTitle.is())
147 continue;
148 uno::Reference< beans::XPropertySet > xObjectProperties( xTitle );
149 m_aConverters.emplace_back(
150 new ::chart::wrapper::TitleItemConverter(
151 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, std::nullopt));
155 AllTitleItemConverter::~AllTitleItemConverter()
159 const WhichRangesContainer& AllTitleItemConverter::GetWhichPairs() const
161 // must span all used items!
162 return nTitleWhichPairs;
165 AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
166 const rtl::Reference<::chart::ChartModel> & xChartModel,
167 SfxItemPool& rItemPool )
168 : MultipleItemConverter( rItemPool )
170 std::vector< rtl::Reference< DataSeries > > aSeriesList =
171 ::chart::ChartModelHelper::getDataSeries( xChartModel );
173 for (auto const& series : aSeriesList)
175 m_aConverters.emplace_back( new ::chart::wrapper::StatisticsItemConverter(
176 xChartModel, series, rItemPool ));
180 AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter()
183 const WhichRangesContainer& AllSeriesStatisticsConverter::GetWhichPairs() const
185 // must span all used items!
186 return nStatWhichPairs;
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */