1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
35 #include <AxisHelper.hxx>
36 #include <chartview/ExplicitValueProvider.hxx>
37 #include <com/sun/star/chart2/XTitle.hpp>
39 using namespace ::com::sun::star
;
40 using namespace ::com::sun::star::chart2
;
41 using ::com::sun::star::uno::Reference
;
42 using ::com::sun::star::uno::Sequence
;
44 namespace chart::wrapper
{
46 AllAxisItemConverter::AllAxisItemConverter(
47 const rtl::Reference
<::chart::ChartModel
> & xChartModel
,
48 SfxItemPool
& rItemPool
,
50 const awt::Size
* pRefSize
)
51 : MultipleItemConverter( rItemPool
)
53 rtl::Reference
< Diagram
> xDiagram( xChartModel
->getFirstChartDiagram() );
54 const std::vector
< rtl::Reference
< Axis
> > aElementList
= AxisHelper::getAllAxesOfDiagram( xDiagram
);
55 for( rtl::Reference
< Axis
> const & axis
: aElementList
)
57 uno::Reference
< beans::XPropertySet
> xObjectProperties(axis
);
58 m_aConverters
.emplace_back( new ::chart::wrapper::AxisItemConverter(
59 xObjectProperties
, rItemPool
, rDrawModel
,
60 xChartModel
, nullptr, nullptr,
65 AllAxisItemConverter::~AllAxisItemConverter()
69 const WhichRangesContainer
& AllAxisItemConverter::GetWhichPairs() const
71 // must span all used items!
72 return nAllAxisWhichPairs
;
75 AllGridItemConverter::AllGridItemConverter(
76 const rtl::Reference
<::chart::ChartModel
> & xChartModel
,
77 SfxItemPool
& rItemPool
,
79 const uno::Reference
< lang::XMultiServiceFactory
> & xNamedPropertyContainerFactory
)
80 : MultipleItemConverter( rItemPool
)
82 rtl::Reference
< Diagram
> xDiagram( xChartModel
->getFirstChartDiagram() );
83 std::vector
< rtl::Reference
< GridProperties
> > aElementList( AxisHelper::getAllGrids( xDiagram
) );
84 for( rtl::Reference
< GridProperties
> const & xObjectProperties
: aElementList
)
86 m_aConverters
.emplace_back( new ::chart::wrapper::GraphicPropertyItemConverter(
87 xObjectProperties
, rItemPool
, rDrawModel
, xNamedPropertyContainerFactory
,
88 ::chart::wrapper::GraphicObjectType::LineProperties
) );
92 AllGridItemConverter::~AllGridItemConverter()
96 const WhichRangesContainer
& AllGridItemConverter::GetWhichPairs() const
98 // must span all used items!
99 return nGridWhichPairs
;
102 AllDataLabelItemConverter::AllDataLabelItemConverter(
103 const rtl::Reference
<::chart::ChartModel
> & xChartModel
,
104 SfxItemPool
& rItemPool
,
105 SdrModel
& rDrawModel
,
106 const uno::Reference
< lang::XMultiServiceFactory
> & xNamedPropertyContainerFactory
)
107 : MultipleItemConverter( rItemPool
)
109 std::vector
< rtl::Reference
< DataSeries
> > aSeriesList
=
110 ::chart::ChartModelHelper::getDataSeries( xChartModel
);
112 for (auto const& series
: aSeriesList
)
114 uno::Reference
< uno::XComponentContext
> xContext
;//do not need Context for label properties
116 sal_Int32 nNumberFormat
=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( series
);
117 sal_Int32 nPercentNumberFormat
=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
120 m_aConverters
.emplace_back(
121 new ::chart::wrapper::DataPointItemConverter(
122 xChartModel
, xContext
, series
, series
, rItemPool
, rDrawModel
,
123 xNamedPropertyContainerFactory
, GraphicObjectType::FilledDataPoint
,
124 nullptr, true, false, 0, true, nNumberFormat
, nPercentNumberFormat
));
128 AllDataLabelItemConverter::~AllDataLabelItemConverter()
132 const WhichRangesContainer
& AllDataLabelItemConverter::GetWhichPairs() const
134 // must span all used items!
135 return nDataLabelWhichPairs
;
138 AllTitleItemConverter::AllTitleItemConverter(
139 const rtl::Reference
<::chart::ChartModel
> & xChartModel
,
140 SfxItemPool
& rItemPool
,
141 SdrModel
& rDrawModel
,
142 const uno::Reference
< lang::XMultiServiceFactory
> & xNamedPropertyContainerFactory
)
143 : MultipleItemConverter( rItemPool
)
145 for(sal_Int32 nTitle
= TitleHelper::TITLE_BEGIN
; nTitle
< TitleHelper::NORMAL_TITLE_END
; nTitle
++ )
147 rtl::Reference
< Title
> xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle
), xChartModel
) );
150 uno::Reference
< beans::XPropertySet
> xObjectProperties( xTitle
);
151 m_aConverters
.emplace_back(
152 new ::chart::wrapper::TitleItemConverter(
153 xObjectProperties
, rItemPool
, rDrawModel
, xNamedPropertyContainerFactory
, nullptr));
157 AllTitleItemConverter::~AllTitleItemConverter()
161 const WhichRangesContainer
& AllTitleItemConverter::GetWhichPairs() const
163 // must span all used items!
164 return nTitleWhichPairs
;
167 AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
168 const rtl::Reference
<::chart::ChartModel
> & xChartModel
,
169 SfxItemPool
& rItemPool
)
170 : MultipleItemConverter( rItemPool
)
172 std::vector
< rtl::Reference
< DataSeries
> > aSeriesList
=
173 ::chart::ChartModelHelper::getDataSeries( xChartModel
);
175 for (auto const& series
: aSeriesList
)
177 m_aConverters
.emplace_back( new ::chart::wrapper::StatisticsItemConverter(
178 xChartModel
, series
, rItemPool
));
182 AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter()
185 const WhichRangesContainer
& AllSeriesStatisticsConverter::GetWhichPairs() const
187 // must span all used items!
188 return nStatWhichPairs
;
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */