1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_chart2.hxx" 30 #include "MultipleChartConverters.hxx" 31 32 #include "chartview/ChartSfxItemIds.hxx" 33 #include "SchWhichPairs.hxx" 34 #include "AxisItemConverter.hxx" 35 #include "StatisticsItemConverter.hxx" 36 #include "GraphicPropertyItemConverter.hxx" 37 #include "DataPointItemConverter.hxx" 38 #include "ChartModelHelper.hxx" 39 #include "TitleHelper.hxx" 40 #include "TitleItemConverter.hxx" 41 #include "AxisHelper.hxx" 42 #include "chartview/ExplicitValueProvider.hxx" 43 #include "DiagramHelper.hxx" 44 45 using namespace ::com::sun::star; 46 using namespace ::com::sun::star::chart2; 47 using ::com::sun::star::uno::Reference; 48 using ::com::sun::star::uno::Sequence; 49 50 namespace chart 51 { 52 namespace wrapper 53 { 54 55 //----------------------------------------------------------------------------- 56 57 AllAxisItemConverter::AllAxisItemConverter( 58 const uno::Reference< frame::XModel > & xChartModel, 59 SfxItemPool& rItemPool, 60 SdrModel& rDrawModel, 61 const uno::Reference< lang::XMultiServiceFactory > & /*xNamedPropertyContainerFactory*/, 62 ::std::auto_ptr< awt::Size > pRefSize ) 63 : MultipleItemConverter( rItemPool ) 64 { 65 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); 66 Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); 67 for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ ) 68 { 69 uno::Reference< beans::XPropertySet > xObjectProperties(aElementList[nA], uno::UNO_QUERY); 70 if( pRefSize.get()) 71 m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter( 72 xObjectProperties, rItemPool, rDrawModel, 73 uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0, 74 ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )) )); 75 else 76 m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter( 77 xObjectProperties, rItemPool, rDrawModel, 78 uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0 ) ); 79 } 80 } 81 82 AllAxisItemConverter::~AllAxisItemConverter() 83 { 84 } 85 86 const sal_uInt16 * AllAxisItemConverter::GetWhichPairs() const 87 { 88 // must span all used items! 89 return nAllAxisWhichPairs; 90 } 91 92 //----------------------------------------------------------------------------- 93 94 AllGridItemConverter::AllGridItemConverter( 95 const uno::Reference< frame::XModel > & xChartModel, 96 SfxItemPool& rItemPool, 97 SdrModel& rDrawModel, 98 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) 99 : MultipleItemConverter( rItemPool ) 100 { 101 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); 102 Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) ); 103 for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ ) 104 { 105 Reference< beans::XPropertySet > xObjectProperties(aElementList[nA]); 106 m_aConverters.push_back( new ::chart::wrapper::GraphicPropertyItemConverter( 107 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, 108 ::chart::wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES ) ); 109 } 110 } 111 112 AllGridItemConverter::~AllGridItemConverter() 113 { 114 } 115 116 const sal_uInt16 * AllGridItemConverter::GetWhichPairs() const 117 { 118 // must span all used items! 119 return nGridWhichPairs; 120 } 121 122 //----------------------------------------------------------------------------- 123 124 AllDataLabelItemConverter::AllDataLabelItemConverter( 125 const uno::Reference< frame::XModel > & xChartModel, 126 SfxItemPool& rItemPool, 127 SdrModel& rDrawModel, 128 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, 129 ::std::auto_ptr< awt::Size > pRefSize ) 130 : MultipleItemConverter( rItemPool ) 131 { 132 ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( 133 ::chart::ChartModelHelper::getDataSeries( xChartModel )); 134 135 ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt; 136 for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt ) 137 { 138 uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY); 139 uno::Reference< uno::XComponentContext> xContext(0);//do not need Context for label properties 140 141 sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, *aIt, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel ) ); 142 sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel( 143 xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY)); 144 145 m_aConverters.push_back( new ::chart::wrapper::DataPointItemConverter( 146 xChartModel, xContext, 147 xObjectProperties, *aIt, rItemPool, rDrawModel, NULL, 148 xNamedPropertyContainerFactory, 149 GraphicPropertyItemConverter::FILLED_DATA_POINT, 150 ::std::auto_ptr< awt::Size >( pRefSize.get() ? new awt::Size( *pRefSize ) : 0), 151 true, /*bDataSeries*/ 152 false, /*bUseSpecialFillColor*/ 153 0, /*nSpecialFillColor*/ 154 true /*bOverwriteLabelsForAttributedDataPointsAlso*/, 155 nNumberFormat, nPercentNumberFormat 156 )); 157 } 158 } 159 160 AllDataLabelItemConverter::~AllDataLabelItemConverter() 161 { 162 } 163 164 const sal_uInt16 * AllDataLabelItemConverter::GetWhichPairs() const 165 { 166 // must span all used items! 167 return nDataLabelWhichPairs; 168 } 169 170 //----------------------------------------------------------------------------- 171 172 AllTitleItemConverter::AllTitleItemConverter( 173 const uno::Reference< frame::XModel > & xChartModel, 174 SfxItemPool& rItemPool, 175 SdrModel& rDrawModel, 176 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, 177 ::std::auto_ptr< awt::Size > pRefSize ) 178 : MultipleItemConverter( rItemPool ) 179 { 180 for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ ) 181 { 182 uno::Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) ); 183 if(!xTitle.is()) 184 continue; 185 uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY); 186 ::std::auto_ptr< awt::Size > pSingleRefSize(0); 187 if( pRefSize.get()) 188 pSingleRefSize = ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )); 189 m_aConverters.push_back( new ::chart::wrapper::TitleItemConverter( 190 xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, pSingleRefSize )); 191 } 192 } 193 194 AllTitleItemConverter::~AllTitleItemConverter() 195 { 196 } 197 198 const sal_uInt16 * AllTitleItemConverter::GetWhichPairs() const 199 { 200 // must span all used items! 201 return nTitleWhichPairs; 202 } 203 204 //----------------------------------------------------------------------------- 205 206 AllSeriesStatisticsConverter::AllSeriesStatisticsConverter( 207 const uno::Reference< frame::XModel > & xChartModel, 208 SfxItemPool& rItemPool ) 209 : MultipleItemConverter( rItemPool ) 210 { 211 ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( 212 ::chart::ChartModelHelper::getDataSeries( xChartModel )); 213 214 ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt; 215 for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt ) 216 { 217 uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY); 218 m_aConverters.push_back( new ::chart::wrapper::StatisticsItemConverter( 219 xChartModel, xObjectProperties, rItemPool )); 220 } 221 } 222 223 AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter() 224 {} 225 226 const sal_uInt16 * AllSeriesStatisticsConverter::GetWhichPairs() const 227 { 228 // must span all used items! 229 return nStatWhichPairs; 230 } 231 232 } // namespace wrapper 233 } // namespace chart 234