Update ooo320-m1
[ooovba.git] / chart2 / source / controller / itemsetwrapper / MultipleChartConverters.cxx
blob5cee1be0caa80feefb435a39e5b6d5a8cb5d83ba
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MultipleChartConverters.cxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "MultipleChartConverters.hxx"
35 #include "chartview/ChartSfxItemIds.hxx"
36 #include "SchWhichPairs.hxx"
37 #include "AxisItemConverter.hxx"
38 #include "StatisticsItemConverter.hxx"
39 #include "GraphicPropertyItemConverter.hxx"
40 #include "DataPointItemConverter.hxx"
41 #include "ChartModelHelper.hxx"
42 #include "TitleHelper.hxx"
43 #include "TitleItemConverter.hxx"
44 #include "AxisHelper.hxx"
45 #include "chartview/ExplicitValueProvider.hxx"
46 #include "DiagramHelper.hxx"
48 using namespace ::com::sun::star;
49 using namespace ::com::sun::star::chart2;
50 using ::com::sun::star::uno::Reference;
51 using ::com::sun::star::uno::Sequence;
53 namespace chart
55 namespace wrapper
58 //-----------------------------------------------------------------------------
60 AllAxisItemConverter::AllAxisItemConverter(
61 const uno::Reference< frame::XModel > & xChartModel,
62 SfxItemPool& rItemPool,
63 SdrModel& rDrawModel,
64 const uno::Reference< lang::XMultiServiceFactory > & /*xNamedPropertyContainerFactory*/,
65 ::std::auto_ptr< awt::Size > pRefSize )
66 : MultipleItemConverter( rItemPool )
68 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
69 Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
70 for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
72 uno::Reference< beans::XPropertySet > xObjectProperties(aElementList[nA], uno::UNO_QUERY);
73 if( pRefSize.get())
74 m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter(
75 xObjectProperties, rItemPool, rDrawModel,
76 uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0,
77 ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )) ));
78 else
79 m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter(
80 xObjectProperties, rItemPool, rDrawModel,
81 uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0 ) );
85 AllAxisItemConverter::~AllAxisItemConverter()
89 const USHORT * AllAxisItemConverter::GetWhichPairs() const
91 // must span all used items!
92 return nAllAxisWhichPairs;
95 //-----------------------------------------------------------------------------
97 AllGridItemConverter::AllGridItemConverter(
98 const uno::Reference< frame::XModel > & xChartModel,
99 SfxItemPool& rItemPool,
100 SdrModel& rDrawModel,
101 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
102 : MultipleItemConverter( rItemPool )
104 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
105 Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) );
106 for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
108 Reference< beans::XPropertySet > xObjectProperties(aElementList[nA]);
109 m_aConverters.push_back( new ::chart::wrapper::GraphicPropertyItemConverter(
110 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
111 ::chart::wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES ) );
115 AllGridItemConverter::~AllGridItemConverter()
119 const USHORT * AllGridItemConverter::GetWhichPairs() const
121 // must span all used items!
122 return nGridWhichPairs;
125 //-----------------------------------------------------------------------------
127 AllDataLabelItemConverter::AllDataLabelItemConverter(
128 const uno::Reference< frame::XModel > & xChartModel,
129 SfxItemPool& rItemPool,
130 SdrModel& rDrawModel,
131 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
132 ::std::auto_ptr< awt::Size > pRefSize )
133 : MultipleItemConverter( rItemPool )
135 ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
136 ::chart::ChartModelHelper::getDataSeries( xChartModel ));
138 ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt;
139 for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt )
141 uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
142 uno::Reference< uno::XComponentContext> xContext(0);//do not need Context for label properties
144 sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, *aIt, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel ) );
145 sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
146 xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY));
148 m_aConverters.push_back( new ::chart::wrapper::DataPointItemConverter(
149 xChartModel, xContext,
150 xObjectProperties, *aIt, rItemPool, rDrawModel, NULL,
151 xNamedPropertyContainerFactory,
152 GraphicPropertyItemConverter::FILLED_DATA_POINT,
153 ::std::auto_ptr< awt::Size >( pRefSize.get() ? new awt::Size( *pRefSize ) : 0),
154 true, /*bDataSeries*/
155 false, /*bUseSpecialFillColor*/
156 0, /*nSpecialFillColor*/
157 true /*bOverwriteLabelsForAttributedDataPointsAlso*/,
158 nNumberFormat, nPercentNumberFormat
163 AllDataLabelItemConverter::~AllDataLabelItemConverter()
167 const USHORT * AllDataLabelItemConverter::GetWhichPairs() const
169 // must span all used items!
170 return nDataLabelWhichPairs;
173 //-----------------------------------------------------------------------------
175 AllTitleItemConverter::AllTitleItemConverter(
176 const uno::Reference< frame::XModel > & xChartModel,
177 SfxItemPool& rItemPool,
178 SdrModel& rDrawModel,
179 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
180 ::std::auto_ptr< awt::Size > pRefSize )
181 : MultipleItemConverter( rItemPool )
183 for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ )
185 uno::Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) );
186 if(!xTitle.is())
187 continue;
188 uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY);
189 ::std::auto_ptr< awt::Size > pSingleRefSize(0);
190 if( pRefSize.get())
191 pSingleRefSize = ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize ));
192 m_aConverters.push_back( new ::chart::wrapper::TitleItemConverter(
193 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, pSingleRefSize ));
197 AllTitleItemConverter::~AllTitleItemConverter()
201 const USHORT * AllTitleItemConverter::GetWhichPairs() const
203 // must span all used items!
204 return nTitleWhichPairs;
207 //-----------------------------------------------------------------------------
209 AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
210 const uno::Reference< frame::XModel > & xChartModel,
211 SfxItemPool& rItemPool )
212 : MultipleItemConverter( rItemPool )
214 ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
215 ::chart::ChartModelHelper::getDataSeries( xChartModel ));
217 ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt;
218 for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt )
220 uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
221 m_aConverters.push_back( new ::chart::wrapper::StatisticsItemConverter(
222 xChartModel, xObjectProperties, rItemPool ));
226 AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter()
229 const USHORT * AllSeriesStatisticsConverter::GetWhichPairs() const
231 // must span all used items!
232 return nStatWhichPairs;
235 } // namespace wrapper
236 } // namespace chart