vcl: allow for overriding the default PDF rendering resolution
[LibreOffice.git] / chart2 / source / controller / itemsetwrapper / MultipleChartConverters.cxx
blobaf20548504b80d644442b7b9ebe9289073a3b9bd
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 <TitleHelper.hxx>
29 #include <TitleItemConverter.hxx>
30 #include <AxisHelper.hxx>
31 #include <chartview/ExplicitValueProvider.hxx>
32 #include <com/sun/star/chart2/XChartDocument.hpp>
33 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
34 #include <com/sun/star/chart2/XAxis.hpp>
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::chart2;
38 using ::com::sun::star::uno::Reference;
39 using ::com::sun::star::uno::Sequence;
41 namespace chart { namespace wrapper {
43 AllAxisItemConverter::AllAxisItemConverter(
44 const uno::Reference< frame::XModel > & xChartModel,
45 SfxItemPool& rItemPool,
46 SdrModel& rDrawModel,
47 const awt::Size* pRefSize )
48 : MultipleItemConverter( rItemPool )
50 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
51 Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
52 for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
54 uno::Reference< beans::XPropertySet > xObjectProperties(aElementList[nA], uno::UNO_QUERY);
55 m_aConverters.emplace_back( new ::chart::wrapper::AxisItemConverter(
56 xObjectProperties, rItemPool, rDrawModel,
57 uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), nullptr, nullptr,
58 pRefSize));
62 AllAxisItemConverter::~AllAxisItemConverter()
66 const sal_uInt16 * AllAxisItemConverter::GetWhichPairs() const
68 // must span all used items!
69 return nAllAxisWhichPairs;
72 AllGridItemConverter::AllGridItemConverter(
73 const uno::Reference< frame::XModel > & xChartModel,
74 SfxItemPool& rItemPool,
75 SdrModel& rDrawModel,
76 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
77 : MultipleItemConverter( rItemPool )
79 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
80 Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) );
81 for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
83 Reference< beans::XPropertySet > xObjectProperties(aElementList[nA]);
84 m_aConverters.emplace_back( new ::chart::wrapper::GraphicPropertyItemConverter(
85 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
86 ::chart::wrapper::GraphicObjectType::LineProperties ) );
90 AllGridItemConverter::~AllGridItemConverter()
94 const sal_uInt16 * AllGridItemConverter::GetWhichPairs() const
96 // must span all used items!
97 return nGridWhichPairs;
100 AllDataLabelItemConverter::AllDataLabelItemConverter(
101 const uno::Reference< frame::XModel > & xChartModel,
102 SfxItemPool& rItemPool,
103 SdrModel& rDrawModel,
104 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
105 : MultipleItemConverter( rItemPool )
107 std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
108 ::chart::ChartModelHelper::getDataSeries( xChartModel ));
110 for (auto const& series : aSeriesList)
112 uno::Reference< beans::XPropertySet > xObjectProperties(series, uno::UNO_QUERY);
113 uno::Reference< uno::XComponentContext> xContext;//do not need Context for label properties
115 sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, series, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel ) );
116 sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
117 xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY));
119 m_aConverters.emplace_back(
120 new ::chart::wrapper::DataPointItemConverter(
121 xChartModel, xContext, xObjectProperties, series, rItemPool, rDrawModel,
122 xNamedPropertyContainerFactory, GraphicObjectType::FilledDataPoint,
123 nullptr, true, false, 0, true, nNumberFormat, nPercentNumberFormat));
127 AllDataLabelItemConverter::~AllDataLabelItemConverter()
131 const sal_uInt16 * AllDataLabelItemConverter::GetWhichPairs() const
133 // must span all used items!
134 return nDataLabelWhichPairs;
137 AllTitleItemConverter::AllTitleItemConverter(
138 const uno::Reference< frame::XModel > & xChartModel,
139 SfxItemPool& rItemPool,
140 SdrModel& rDrawModel,
141 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
142 : MultipleItemConverter( rItemPool )
144 for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ )
146 uno::Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) );
147 if(!xTitle.is())
148 continue;
149 uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY);
150 m_aConverters.emplace_back(
151 new ::chart::wrapper::TitleItemConverter(
152 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, nullptr));
156 AllTitleItemConverter::~AllTitleItemConverter()
160 const sal_uInt16 * AllTitleItemConverter::GetWhichPairs() const
162 // must span all used items!
163 return nTitleWhichPairs;
166 AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
167 const uno::Reference< frame::XModel > & xChartModel,
168 SfxItemPool& rItemPool )
169 : MultipleItemConverter( rItemPool )
171 std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
172 ::chart::ChartModelHelper::getDataSeries( xChartModel ));
174 for (auto const& series : aSeriesList)
176 uno::Reference< beans::XPropertySet > xObjectProperties(series, uno::UNO_QUERY);
177 m_aConverters.emplace_back( new ::chart::wrapper::StatisticsItemConverter(
178 xChartModel, xObjectProperties, rItemPool ));
182 AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter()
185 const sal_uInt16 * AllSeriesStatisticsConverter::GetWhichPairs() const
187 // must span all used items!
188 return nStatWhichPairs;
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */