1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "MultipleChartConverters.hxx"
27
28 #include "chartview/ChartSfxItemIds.hxx"
29 #include "SchWhichPairs.hxx"
30 #include "AxisItemConverter.hxx"
31 #include "StatisticsItemConverter.hxx"
32 #include "GraphicPropertyItemConverter.hxx"
33 #include "DataPointItemConverter.hxx"
34 #include "ChartModelHelper.hxx"
35 #include "TitleHelper.hxx"
36 #include "TitleItemConverter.hxx"
37 #include "AxisHelper.hxx"
38 #include "chartview/ExplicitValueProvider.hxx"
39 #include "DiagramHelper.hxx"
40
41 using namespace ::com::sun::star;
42 using namespace ::com::sun::star::chart2;
43 using ::com::sun::star::uno::Reference;
44 using ::com::sun::star::uno::Sequence;
45
46 namespace chart
47 {
48 namespace wrapper
49 {
50
51 //-----------------------------------------------------------------------------
52
AllAxisItemConverter(const uno::Reference<frame::XModel> & xChartModel,SfxItemPool & rItemPool,SdrModel & rDrawModel,const uno::Reference<lang::XMultiServiceFactory> &,::std::auto_ptr<awt::Size> pRefSize)53 AllAxisItemConverter::AllAxisItemConverter(
54 const uno::Reference< frame::XModel > & xChartModel,
55 SfxItemPool& rItemPool,
56 SdrModel& rDrawModel,
57 const uno::Reference< lang::XMultiServiceFactory > & /*xNamedPropertyContainerFactory*/,
58 ::std::auto_ptr< awt::Size > pRefSize )
59 : MultipleItemConverter( rItemPool )
60 {
61 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
62 Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
63 for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
64 {
65 uno::Reference< beans::XPropertySet > xObjectProperties(aElementList[nA], uno::UNO_QUERY);
66 if( pRefSize.get())
67 m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter(
68 xObjectProperties, rItemPool, rDrawModel,
69 uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0,
70 ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )) ));
71 else
72 m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter(
73 xObjectProperties, rItemPool, rDrawModel,
74 uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0 ) );
75 }
76 }
77
~AllAxisItemConverter()78 AllAxisItemConverter::~AllAxisItemConverter()
79 {
80 }
81
GetWhichPairs() const82 const sal_uInt16 * AllAxisItemConverter::GetWhichPairs() const
83 {
84 // must span all used items!
85 return nAllAxisWhichPairs;
86 }
87
88 //-----------------------------------------------------------------------------
89
AllGridItemConverter(const uno::Reference<frame::XModel> & xChartModel,SfxItemPool & rItemPool,SdrModel & rDrawModel,const uno::Reference<lang::XMultiServiceFactory> & xNamedPropertyContainerFactory)90 AllGridItemConverter::AllGridItemConverter(
91 const uno::Reference< frame::XModel > & xChartModel,
92 SfxItemPool& rItemPool,
93 SdrModel& rDrawModel,
94 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
95 : MultipleItemConverter( rItemPool )
96 {
97 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
98 Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) );
99 for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
100 {
101 Reference< beans::XPropertySet > xObjectProperties(aElementList[nA]);
102 m_aConverters.push_back( new ::chart::wrapper::GraphicPropertyItemConverter(
103 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
104 ::chart::wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES ) );
105 }
106 }
107
~AllGridItemConverter()108 AllGridItemConverter::~AllGridItemConverter()
109 {
110 }
111
GetWhichPairs() const112 const sal_uInt16 * AllGridItemConverter::GetWhichPairs() const
113 {
114 // must span all used items!
115 return nGridWhichPairs;
116 }
117
118 //-----------------------------------------------------------------------------
119
AllDataLabelItemConverter(const uno::Reference<frame::XModel> & xChartModel,SfxItemPool & rItemPool,SdrModel & rDrawModel,const uno::Reference<lang::XMultiServiceFactory> & xNamedPropertyContainerFactory,::std::auto_ptr<awt::Size> pRefSize)120 AllDataLabelItemConverter::AllDataLabelItemConverter(
121 const uno::Reference< frame::XModel > & xChartModel,
122 SfxItemPool& rItemPool,
123 SdrModel& rDrawModel,
124 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
125 ::std::auto_ptr< awt::Size > pRefSize )
126 : MultipleItemConverter( rItemPool )
127 {
128 ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
129 ::chart::ChartModelHelper::getDataSeries( xChartModel ));
130
131 ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt;
132 for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt )
133 {
134 uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
135 uno::Reference< uno::XComponentContext> xContext(0);//do not need Context for label properties
136
137 sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, *aIt, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel ) );
138 sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
139 xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY));
140
141 m_aConverters.push_back( new ::chart::wrapper::DataPointItemConverter(
142 xChartModel, xContext,
143 xObjectProperties, *aIt, rItemPool, rDrawModel, NULL,
144 xNamedPropertyContainerFactory,
145 GraphicPropertyItemConverter::FILLED_DATA_POINT,
146 ::std::auto_ptr< awt::Size >( pRefSize.get() ? new awt::Size( *pRefSize ) : 0),
147 true, /*bDataSeries*/
148 false, /*bUseSpecialFillColor*/
149 0, /*nSpecialFillColor*/
150 true /*bOverwriteLabelsForAttributedDataPointsAlso*/,
151 nNumberFormat, nPercentNumberFormat
152 ));
153 }
154 }
155
~AllDataLabelItemConverter()156 AllDataLabelItemConverter::~AllDataLabelItemConverter()
157 {
158 }
159
GetWhichPairs() const160 const sal_uInt16 * AllDataLabelItemConverter::GetWhichPairs() const
161 {
162 // must span all used items!
163 return nDataLabelWhichPairs;
164 }
165
166 //-----------------------------------------------------------------------------
167
AllTitleItemConverter(const uno::Reference<frame::XModel> & xChartModel,SfxItemPool & rItemPool,SdrModel & rDrawModel,const uno::Reference<lang::XMultiServiceFactory> & xNamedPropertyContainerFactory,::std::auto_ptr<awt::Size> pRefSize)168 AllTitleItemConverter::AllTitleItemConverter(
169 const uno::Reference< frame::XModel > & xChartModel,
170 SfxItemPool& rItemPool,
171 SdrModel& rDrawModel,
172 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
173 ::std::auto_ptr< awt::Size > pRefSize )
174 : MultipleItemConverter( rItemPool )
175 {
176 for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ )
177 {
178 uno::Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) );
179 if(!xTitle.is())
180 continue;
181 uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY);
182 ::std::auto_ptr< awt::Size > pSingleRefSize(0);
183 if( pRefSize.get())
184 pSingleRefSize = ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize ));
185 m_aConverters.push_back( new ::chart::wrapper::TitleItemConverter(
186 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, pSingleRefSize ));
187 }
188 }
189
~AllTitleItemConverter()190 AllTitleItemConverter::~AllTitleItemConverter()
191 {
192 }
193
GetWhichPairs() const194 const sal_uInt16 * AllTitleItemConverter::GetWhichPairs() const
195 {
196 // must span all used items!
197 return nTitleWhichPairs;
198 }
199
200 //-----------------------------------------------------------------------------
201
AllSeriesStatisticsConverter(const uno::Reference<frame::XModel> & xChartModel,SfxItemPool & rItemPool)202 AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
203 const uno::Reference< frame::XModel > & xChartModel,
204 SfxItemPool& rItemPool )
205 : MultipleItemConverter( rItemPool )
206 {
207 ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
208 ::chart::ChartModelHelper::getDataSeries( xChartModel ));
209
210 ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt;
211 for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt )
212 {
213 uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
214 m_aConverters.push_back( new ::chart::wrapper::StatisticsItemConverter(
215 xChartModel, xObjectProperties, rItemPool ));
216 }
217 }
218
~AllSeriesStatisticsConverter()219 AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter()
220 {}
221
GetWhichPairs() const222 const sal_uInt16 * AllSeriesStatisticsConverter::GetWhichPairs() const
223 {
224 // must span all used items!
225 return nStatWhichPairs;
226 }
227
228 } // namespace wrapper
229 } // namespace chart
230