1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "MultipleChartConverters.hxx"
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"
35 #include <boost/scoped_ptr.hpp>
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
;
42 namespace chart
{ namespace wrapper
{
44 AllAxisItemConverter::AllAxisItemConverter(
45 const uno::Reference
< frame::XModel
> & xChartModel
,
46 SfxItemPool
& rItemPool
,
48 const uno::Reference
< lang::XMultiServiceFactory
> & /*xNamedPropertyContainerFactory*/,
49 const awt::Size
* pRefSize
)
50 : MultipleItemConverter( rItemPool
)
52 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
53 Sequence
< Reference
< XAxis
> > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram
) );
54 for( sal_Int32 nA
= 0; nA
< aElementList
.getLength(); nA
++ )
56 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,
64 AllAxisItemConverter::~AllAxisItemConverter()
68 const sal_uInt16
* AllAxisItemConverter::GetWhichPairs() const
70 // must span all used items!
71 return nAllAxisWhichPairs
;
74 AllGridItemConverter::AllGridItemConverter(
75 const uno::Reference
< frame::XModel
> & xChartModel
,
76 SfxItemPool
& rItemPool
,
78 const uno::Reference
< lang::XMultiServiceFactory
> & xNamedPropertyContainerFactory
)
79 : MultipleItemConverter( rItemPool
)
81 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
82 Sequence
< Reference
< beans::XPropertySet
> > aElementList( AxisHelper::getAllGrids( xDiagram
) );
83 for( sal_Int32 nA
= 0; nA
< aElementList
.getLength(); nA
++ )
85 Reference
< beans::XPropertySet
> xObjectProperties(aElementList
[nA
]);
86 m_aConverters
.push_back( new ::chart::wrapper::GraphicPropertyItemConverter(
87 xObjectProperties
, rItemPool
, rDrawModel
, xNamedPropertyContainerFactory
,
88 ::chart::wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES
) );
92 AllGridItemConverter::~AllGridItemConverter()
96 const sal_uInt16
* AllGridItemConverter::GetWhichPairs() const
98 // must span all used items!
99 return nGridWhichPairs
;
102 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 : MultipleItemConverter( rItemPool
)
110 ::std::vector
< uno::Reference
< chart2::XDataSeries
> > aSeriesList(
111 ::chart::ChartModelHelper::getDataSeries( xChartModel
));
113 ::std::vector
< uno::Reference
< chart2::XDataSeries
> >::const_iterator aIt
;
114 for( aIt
= aSeriesList
.begin(); aIt
!= aSeriesList
.end(); ++aIt
)
116 uno::Reference
< beans::XPropertySet
> xObjectProperties( *aIt
, uno::UNO_QUERY
);
117 uno::Reference
< uno::XComponentContext
> xContext(0);//do not need Context for label properties
119 sal_Int32 nNumberFormat
=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties
, *aIt
, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel
) );
120 sal_Int32 nPercentNumberFormat
=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
121 xObjectProperties
,uno::Reference
< util::XNumberFormatsSupplier
>(xChartModel
, uno::UNO_QUERY
));
123 m_aConverters
.push_back(
124 new ::chart::wrapper::DataPointItemConverter(
125 xChartModel
, xContext
, xObjectProperties
, *aIt
, rItemPool
, rDrawModel
,
126 xNamedPropertyContainerFactory
, GraphicPropertyItemConverter::FILLED_DATA_POINT
,
127 pRefSize
, true, false, 0, true, nNumberFormat
, nPercentNumberFormat
));
131 AllDataLabelItemConverter::~AllDataLabelItemConverter()
135 const sal_uInt16
* AllDataLabelItemConverter::GetWhichPairs() const
137 // must span all used items!
138 return nDataLabelWhichPairs
;
141 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 : MultipleItemConverter( rItemPool
)
149 for(sal_Int32 nTitle
= TitleHelper::TITLE_BEGIN
; nTitle
< TitleHelper::NORMAL_TITLE_END
; nTitle
++ )
151 uno::Reference
< chart2::XTitle
> xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle
), xChartModel
) );
154 uno::Reference
< beans::XPropertySet
> xObjectProperties( xTitle
, uno::UNO_QUERY
);
155 m_aConverters
.push_back(
156 new ::chart::wrapper::TitleItemConverter(
157 xObjectProperties
, rItemPool
, rDrawModel
, xNamedPropertyContainerFactory
, pRefSize
));
161 AllTitleItemConverter::~AllTitleItemConverter()
165 const sal_uInt16
* AllTitleItemConverter::GetWhichPairs() const
167 // must span all used items!
168 return nTitleWhichPairs
;
171 AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
172 const uno::Reference
< frame::XModel
> & xChartModel
,
173 SfxItemPool
& rItemPool
)
174 : MultipleItemConverter( rItemPool
)
176 ::std::vector
< uno::Reference
< chart2::XDataSeries
> > aSeriesList(
177 ::chart::ChartModelHelper::getDataSeries( xChartModel
));
179 ::std::vector
< uno::Reference
< chart2::XDataSeries
> >::const_iterator aIt
;
180 for( aIt
= aSeriesList
.begin(); aIt
!= aSeriesList
.end(); ++aIt
)
182 uno::Reference
< beans::XPropertySet
> xObjectProperties( *aIt
, uno::UNO_QUERY
);
183 m_aConverters
.push_back( new ::chart::wrapper::StatisticsItemConverter(
184 xChartModel
, xObjectProperties
, rItemPool
));
188 AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter()
191 const sal_uInt16
* AllSeriesStatisticsConverter::GetWhichPairs() const
193 // must span all used items!
194 return nStatWhichPairs
;
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */