Line data Source code
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 :
20 : #include "MultipleChartConverters.hxx"
21 :
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"
34 :
35 : #include <boost/scoped_ptr.hpp>
36 :
37 : using namespace ::com::sun::star;
38 : using namespace ::com::sun::star::chart2;
39 : using ::com::sun::star::uno::Reference;
40 : using ::com::sun::star::uno::Sequence;
41 :
42 : namespace chart { namespace wrapper {
43 :
44 0 : AllAxisItemConverter::AllAxisItemConverter(
45 : const uno::Reference< frame::XModel > & xChartModel,
46 : SfxItemPool& rItemPool,
47 : SdrModel& rDrawModel,
48 : const uno::Reference< lang::XMultiServiceFactory > & /*xNamedPropertyContainerFactory*/,
49 : const awt::Size* pRefSize )
50 0 : : MultipleItemConverter( rItemPool )
51 : {
52 0 : Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
53 0 : Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
54 0 : for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
55 : {
56 0 : uno::Reference< beans::XPropertySet > xObjectProperties(aElementList[nA], uno::UNO_QUERY);
57 : m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter(
58 : xObjectProperties, rItemPool, rDrawModel,
59 : uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0,
60 0 : pRefSize));
61 0 : }
62 0 : }
63 :
64 0 : AllAxisItemConverter::~AllAxisItemConverter()
65 : {
66 0 : }
67 :
68 0 : const sal_uInt16 * AllAxisItemConverter::GetWhichPairs() const
69 : {
70 : // must span all used items!
71 0 : return nAllAxisWhichPairs;
72 : }
73 :
74 0 : AllGridItemConverter::AllGridItemConverter(
75 : const uno::Reference< frame::XModel > & xChartModel,
76 : SfxItemPool& rItemPool,
77 : SdrModel& rDrawModel,
78 : const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
79 0 : : MultipleItemConverter( rItemPool )
80 : {
81 0 : Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
82 0 : Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) );
83 0 : for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
84 : {
85 0 : Reference< beans::XPropertySet > xObjectProperties(aElementList[nA]);
86 : m_aConverters.push_back( new ::chart::wrapper::GraphicPropertyItemConverter(
87 : xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
88 0 : ::chart::wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES ) );
89 0 : }
90 0 : }
91 :
92 0 : AllGridItemConverter::~AllGridItemConverter()
93 : {
94 0 : }
95 :
96 0 : const sal_uInt16 * AllGridItemConverter::GetWhichPairs() const
97 : {
98 : // must span all used items!
99 0 : return nGridWhichPairs;
100 : }
101 :
102 0 : AllDataLabelItemConverter::AllDataLabelItemConverter(
103 : const uno::Reference< frame::XModel > & xChartModel,
104 : SfxItemPool& rItemPool,
105 : SdrModel& rDrawModel,
106 : const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
107 : const awt::Size* pRefSize )
108 0 : : MultipleItemConverter( rItemPool )
109 : {
110 : ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
111 0 : ::chart::ChartModelHelper::getDataSeries( xChartModel ));
112 :
113 0 : ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt;
114 0 : for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt )
115 : {
116 0 : uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
117 0 : uno::Reference< uno::XComponentContext> xContext(0);//do not need Context for label properties
118 :
119 0 : sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, *aIt, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel ) );
120 : sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
121 0 : xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY));
122 :
123 : m_aConverters.push_back(
124 : new ::chart::wrapper::DataPointItemConverter(
125 : xChartModel, xContext, xObjectProperties, *aIt, rItemPool, rDrawModel,
126 : xNamedPropertyContainerFactory, GraphicPropertyItemConverter::FILLED_DATA_POINT,
127 0 : pRefSize, true, false, 0, true, nNumberFormat, nPercentNumberFormat));
128 0 : }
129 0 : }
130 :
131 0 : AllDataLabelItemConverter::~AllDataLabelItemConverter()
132 : {
133 0 : }
134 :
135 0 : const sal_uInt16 * AllDataLabelItemConverter::GetWhichPairs() const
136 : {
137 : // must span all used items!
138 0 : return nDataLabelWhichPairs;
139 : }
140 :
141 0 : AllTitleItemConverter::AllTitleItemConverter(
142 : const uno::Reference< frame::XModel > & xChartModel,
143 : SfxItemPool& rItemPool,
144 : SdrModel& rDrawModel,
145 : const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
146 : const awt::Size* pRefSize )
147 0 : : MultipleItemConverter( rItemPool )
148 : {
149 0 : for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ )
150 : {
151 0 : uno::Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) );
152 0 : if(!xTitle.is())
153 0 : continue;
154 0 : uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY);
155 : m_aConverters.push_back(
156 : new ::chart::wrapper::TitleItemConverter(
157 0 : xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, pRefSize));
158 0 : }
159 0 : }
160 :
161 0 : AllTitleItemConverter::~AllTitleItemConverter()
162 : {
163 0 : }
164 :
165 0 : const sal_uInt16 * AllTitleItemConverter::GetWhichPairs() const
166 : {
167 : // must span all used items!
168 0 : return nTitleWhichPairs;
169 : }
170 :
171 0 : AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
172 : const uno::Reference< frame::XModel > & xChartModel,
173 : SfxItemPool& rItemPool )
174 0 : : MultipleItemConverter( rItemPool )
175 : {
176 : ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
177 0 : ::chart::ChartModelHelper::getDataSeries( xChartModel ));
178 :
179 0 : ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt;
180 0 : for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt )
181 : {
182 0 : uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
183 : m_aConverters.push_back( new ::chart::wrapper::StatisticsItemConverter(
184 0 : xChartModel, xObjectProperties, rItemPool ));
185 0 : }
186 0 : }
187 :
188 0 : AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter()
189 0 : {}
190 :
191 0 : const sal_uInt16 * AllSeriesStatisticsConverter::GetWhichPairs() const
192 : {
193 : // must span all used items!
194 0 : return nStatWhichPairs;
195 : }
196 :
197 : }}
198 :
199 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|