Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / controller / itemsetwrapper / MultipleChartConverters.cxx
blobb9e75ea51111efcb3a6f6fb30c752faf059a2838
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 <chartview/ChartSfxItemIds.hxx>
23 #include "SchWhichPairs.hxx"
24 #include <AxisItemConverter.hxx>
25 #include <StatisticsItemConverter.hxx>
26 #include <GraphicPropertyItemConverter.hxx>
27 #include <DataPointItemConverter.hxx>
28 #include <ChartModelHelper.hxx>
29 #include <TitleHelper.hxx>
30 #include <TitleItemConverter.hxx>
31 #include <AxisHelper.hxx>
32 #include <chartview/ExplicitValueProvider.hxx>
33 #include <DiagramHelper.hxx>
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::chart2;
37 using ::com::sun::star::uno::Reference;
38 using ::com::sun::star::uno::Sequence;
40 namespace chart { namespace wrapper {
42 AllAxisItemConverter::AllAxisItemConverter(
43 const uno::Reference< frame::XModel > & xChartModel,
44 SfxItemPool& rItemPool,
45 SdrModel& rDrawModel,
46 const awt::Size* pRefSize )
47 : MultipleItemConverter( rItemPool )
49 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
50 Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
51 for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
53 uno::Reference< beans::XPropertySet > xObjectProperties(aElementList[nA], uno::UNO_QUERY);
54 m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter(
55 xObjectProperties, rItemPool, rDrawModel,
56 uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), nullptr, nullptr,
57 pRefSize));
61 AllAxisItemConverter::~AllAxisItemConverter()
65 const sal_uInt16 * AllAxisItemConverter::GetWhichPairs() const
67 // must span all used items!
68 return nAllAxisWhichPairs;
71 AllGridItemConverter::AllGridItemConverter(
72 const uno::Reference< frame::XModel > & xChartModel,
73 SfxItemPool& rItemPool,
74 SdrModel& rDrawModel,
75 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
76 : MultipleItemConverter( rItemPool )
78 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
79 Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) );
80 for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
82 Reference< beans::XPropertySet > xObjectProperties(aElementList[nA]);
83 m_aConverters.push_back( new ::chart::wrapper::GraphicPropertyItemConverter(
84 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
85 ::chart::wrapper::GraphicObjectType::LineProperties ) );
89 AllGridItemConverter::~AllGridItemConverter()
93 const sal_uInt16 * AllGridItemConverter::GetWhichPairs() const
95 // must span all used items!
96 return nGridWhichPairs;
99 AllDataLabelItemConverter::AllDataLabelItemConverter(
100 const uno::Reference< frame::XModel > & xChartModel,
101 SfxItemPool& rItemPool,
102 SdrModel& rDrawModel,
103 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
104 : MultipleItemConverter( rItemPool )
106 std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
107 ::chart::ChartModelHelper::getDataSeries( xChartModel ));
109 for (auto const& series : aSeriesList)
111 uno::Reference< beans::XPropertySet > xObjectProperties(series, uno::UNO_QUERY);
112 uno::Reference< uno::XComponentContext> xContext(nullptr);//do not need Context for label properties
114 sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, series, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel ) );
115 sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
116 xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY));
118 m_aConverters.push_back(
119 new ::chart::wrapper::DataPointItemConverter(
120 xChartModel, xContext, xObjectProperties, series, rItemPool, rDrawModel,
121 xNamedPropertyContainerFactory, GraphicObjectType::FilledDataPoint,
122 nullptr, true, false, 0, true, nNumberFormat, nPercentNumberFormat));
126 AllDataLabelItemConverter::~AllDataLabelItemConverter()
130 const sal_uInt16 * AllDataLabelItemConverter::GetWhichPairs() const
132 // must span all used items!
133 return nDataLabelWhichPairs;
136 AllTitleItemConverter::AllTitleItemConverter(
137 const uno::Reference< frame::XModel > & 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 uno::Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) );
146 if(!xTitle.is())
147 continue;
148 uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY);
149 m_aConverters.push_back(
150 new ::chart::wrapper::TitleItemConverter(
151 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, nullptr));
155 AllTitleItemConverter::~AllTitleItemConverter()
159 const sal_uInt16 * AllTitleItemConverter::GetWhichPairs() const
161 // must span all used items!
162 return nTitleWhichPairs;
165 AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
166 const uno::Reference< frame::XModel > & xChartModel,
167 SfxItemPool& rItemPool )
168 : MultipleItemConverter( rItemPool )
170 std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
171 ::chart::ChartModelHelper::getDataSeries( xChartModel ));
173 for (auto const& series : aSeriesList)
175 uno::Reference< beans::XPropertySet > xObjectProperties(series, uno::UNO_QUERY);
176 m_aConverters.push_back( new ::chart::wrapper::StatisticsItemConverter(
177 xChartModel, xObjectProperties, rItemPool ));
181 AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter()
184 const sal_uInt16 * AllSeriesStatisticsConverter::GetWhichPairs() const
186 // must span all used items!
187 return nStatWhichPairs;
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */