LibreOffice Module chart2 (master) 1
MultipleChartConverters.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 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21
22#include "SchWhichPairs.hxx"
23#include <AxisItemConverter.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>
34#include <Axis.hxx>
35#include <AxisHelper.hxx>
37#include <com/sun/star/chart2/XTitle.hpp>
38
39using namespace ::com::sun::star;
40using namespace ::com::sun::star::chart2;
41using ::com::sun::star::uno::Reference;
42using ::com::sun::star::uno::Sequence;
43
44namespace chart::wrapper {
45
47 const rtl::Reference<::chart::ChartModel> & xChartModel,
48 SfxItemPool& rItemPool,
49 SdrModel& rDrawModel,
50 const awt::Size* pRefSize )
51 : MultipleItemConverter( rItemPool )
52{
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 )
56 {
57 uno::Reference< beans::XPropertySet > xObjectProperties(axis);
58 m_aConverters.emplace_back( new ::chart::wrapper::AxisItemConverter(
59 xObjectProperties, rItemPool, rDrawModel,
60 xChartModel, nullptr, nullptr,
61 pRefSize));
62 }
63}
64
66{
67}
68
70{
71 // must span all used items!
72 return nAllAxisWhichPairs;
73}
74
76 const rtl::Reference<::chart::ChartModel> & xChartModel,
77 SfxItemPool& rItemPool,
78 SdrModel& rDrawModel,
79 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
80 : MultipleItemConverter( rItemPool )
81{
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 )
85 {
86 m_aConverters.emplace_back( new ::chart::wrapper::GraphicPropertyItemConverter(
87 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
88 ::chart::wrapper::GraphicObjectType::LineProperties ) );
89 }
90}
91
93{
94}
95
97{
98 // must span all used items!
99 return nGridWhichPairs;
100}
101
103 const rtl::Reference<::chart::ChartModel> & xChartModel,
104 SfxItemPool& rItemPool,
105 SdrModel& rDrawModel,
106 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
107 : MultipleItemConverter( rItemPool )
108{
109 std::vector< rtl::Reference< DataSeries > > aSeriesList =
111
112 for (auto const& series : aSeriesList)
113 {
114 uno::Reference< uno::XComponentContext> xContext;//do not need Context for label properties
115
116 sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( series );
117 sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
118 series,xChartModel);
119
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));
125 }
126}
127
129{
130}
131
133{
134 // must span all used items!
136}
137
139 const rtl::Reference<::chart::ChartModel> & xChartModel,
140 SfxItemPool& rItemPool,
141 SdrModel& rDrawModel,
142 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
143 : MultipleItemConverter( rItemPool )
144{
145 for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ )
146 {
148 if(!xTitle.is())
149 continue;
150 uno::Reference< beans::XPropertySet > xObjectProperties( xTitle );
151 m_aConverters.emplace_back(
152 new ::chart::wrapper::TitleItemConverter(
153 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, nullptr));
154 }
155}
156
158{
159}
160
162{
163 // must span all used items!
164 return nTitleWhichPairs;
165}
166
168 const rtl::Reference<::chart::ChartModel> & xChartModel,
169 SfxItemPool& rItemPool )
170 : MultipleItemConverter( rItemPool )
171{
172 std::vector< rtl::Reference< DataSeries > > aSeriesList =
174
175 for (auto const& series : aSeriesList)
176 {
177 m_aConverters.emplace_back( new ::chart::wrapper::StatisticsItemConverter(
178 xChartModel, series, rItemPool ));
179 }
180}
181
183{}
184
186{
187 // must span all used items!
188 return nStatWhichPairs;
189}
190
191}
192
193/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const WhichRangesContainer nStatWhichPairs(svl::Items< SCHATTR_STAT_START, SCHATTR_STAT_END, SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END >)
const WhichRangesContainer nGridWhichPairs(svl::Items< XATTR_LINE_FIRST, XATTR_LINE_LAST >)
const WhichRangesContainer nDataLabelWhichPairs(svl::Items< SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE >)
const WhichRangesContainer nAllAxisWhichPairs(svl::Items< SCHATTR_TEXT_START, SCHATTR_TEXT_END, SCHATTR_AXIS_LABEL_START, SCHATTR_AXIS_LABEL_END, XATTR_LINE_FIRST, XATTR_LINE_LAST, EE_ITEMS_START, EE_ITEMS_END, SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING >)
const WhichRangesContainer nTitleWhichPairs(svl::Items< SCHATTR_TEXT_START, SCHATTR_TEXT_END, XATTR_LINE_FIRST, XATTR_LINE_LAST, XATTR_FILL_FIRST, XATTR_FILL_LAST, SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, EE_ITEMS_START, EE_ITEMS_END, SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING >)
static std::vector< rtl::Reference< ::chart::GridProperties > > getAllGrids(const rtl::Reference< ::chart::Diagram > &xDiagram)
Definition: AxisHelper.cxx:824
static std::vector< rtl::Reference< ::chart::Axis > > getAllAxesOfDiagram(const rtl::Reference< ::chart::Diagram > &xDiagram, bool bOnlyVisible=false)
Definition: AxisHelper.cxx:809
static std::vector< rtl::Reference< ::chart::DataSeries > > getDataSeries(const rtl::Reference< ::chart::ChartModel > &xModel)
static rtl::Reference< ::chart::Title > getTitle(eTitleType nTitleIndex, ChartModel &rModel)
AllAxisItemConverter(const rtl::Reference<::chart::ChartModel > &xChartModel, SfxItemPool &rItemPool, SdrModel &rDrawModel, const css::awt::Size *pRefSize)
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
AllDataLabelItemConverter(const rtl::Reference<::chart::ChartModel > &xChartModel, SfxItemPool &rItemPool, SdrModel &rDrawModel, const css::uno::Reference< css::lang::XMultiServiceFactory > &xNamedPropertyContainerFactory)
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
AllGridItemConverter(const rtl::Reference<::chart::ChartModel > &xChartModel, SfxItemPool &rItemPool, SdrModel &rDrawModel, const css::uno::Reference< css::lang::XMultiServiceFactory > &xNamedPropertyContainerFactory)
AllSeriesStatisticsConverter(const rtl::Reference<::chart::ChartModel > &xChartModel, SfxItemPool &rItemPool)
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
AllTitleItemConverter(const rtl::Reference<::chart::ChartModel > &xChartModel, SfxItemPool &rItemPool, SdrModel &rDrawModel, const css::uno::Reference< css::lang::XMultiServiceFactory > &xNamedPropertyContainerFactory)
Note: virtual const sal_uInt16 * GetWhichPairs() const; is still pure virtual.
std::vector< std::unique_ptr< ItemConverter > > m_aConverters