Branch data 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 "AreaChartTypeTemplate.hxx"
21 : : #include "macros.hxx"
22 : : #include "servicenames_charttypes.hxx"
23 : : #include "DiagramHelper.hxx"
24 : : #include "DataSeriesHelper.hxx"
25 : : #include "ContainerHelper.hxx"
26 : : #include "PropertyHelper.hxx"
27 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
28 : : #include <com/sun/star/drawing/LineStyle.hpp>
29 : :
30 : : #include <algorithm>
31 : :
32 : : using namespace ::com::sun::star;
33 : :
34 : : using ::rtl::OUString;
35 : : using ::com::sun::star::beans::Property;
36 : : using ::com::sun::star::uno::Sequence;
37 : : using ::com::sun::star::uno::Reference;
38 : : using ::com::sun::star::uno::Any;
39 : : using ::osl::MutexGuard;
40 : :
41 : : namespace
42 : : {
43 : :
44 : 16 : static const ::rtl::OUString lcl_aServiceName(
45 : : RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.AreaChartTypeTemplate" ));
46 : :
47 : : enum
48 : : {
49 : : PROP_AREA_TEMPLATE_DIMENSION
50 : : };
51 : :
52 : 9 : void lcl_AddPropertiesToVector(
53 : : ::std::vector< Property > & rOutProperties )
54 : : {
55 : : rOutProperties.push_back(
56 : : Property( C2U( "Dimension" ),
57 : : PROP_AREA_TEMPLATE_DIMENSION,
58 [ + - ]: 9 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
59 : : beans::PropertyAttribute::BOUND
60 [ + - ][ + - ]: 9 : | beans::PropertyAttribute::MAYBEDEFAULT ));
61 : 9 : }
62 : :
63 : : struct StaticAreaChartTypeTemplateDefaults_Initializer
64 : : {
65 : 9 : ::chart::tPropertyValueMap* operator()()
66 : : {
67 [ + - ][ + - ]: 9 : static ::chart::tPropertyValueMap aStaticDefaults;
[ + - ][ # # ]
68 : 9 : lcl_AddDefaultsToMap( aStaticDefaults );
69 : 9 : return &aStaticDefaults;
70 : : }
71 : : private:
72 : 9 : void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
73 : : {
74 [ + - ]: 9 : ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AREA_TEMPLATE_DIMENSION, 2 );
75 : 9 : }
76 : : };
77 : :
78 : : struct StaticAreaChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAreaChartTypeTemplateDefaults_Initializer >
79 : : {
80 : : };
81 : :
82 : : struct StaticAreaChartTypeTemplateInfoHelper_Initializer
83 : : {
84 : 9 : ::cppu::OPropertyArrayHelper* operator()()
85 : : {
86 [ + - ][ + - ]: 9 : static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
[ + - ][ + - ]
[ + - ][ # # ]
87 : 9 : return &aPropHelper;
88 : : }
89 : :
90 : : private:
91 : 9 : uno::Sequence< Property > lcl_GetPropertySequence()
92 : : {
93 [ + - ]: 9 : ::std::vector< ::com::sun::star::beans::Property > aProperties;
94 [ + - ]: 9 : lcl_AddPropertiesToVector( aProperties );
95 : :
96 : : ::std::sort( aProperties.begin(), aProperties.end(),
97 [ + - ]: 9 : ::chart::PropertyNameLess() );
98 : :
99 [ + - ]: 9 : return ::chart::ContainerHelper::ContainerToSequence( aProperties );
100 : : }
101 : :
102 : : };
103 : :
104 : : struct StaticAreaChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAreaChartTypeTemplateInfoHelper_Initializer >
105 : : {
106 : : };
107 : :
108 : : struct StaticAreaChartTypeTemplateInfo_Initializer
109 : : {
110 : 0 : uno::Reference< beans::XPropertySetInfo >* operator()()
111 : : {
112 : : static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
113 [ # # ][ # # ]: 0 : ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAreaChartTypeTemplateInfoHelper::get() ) );
[ # # ][ # # ]
[ # # ]
114 : 0 : return &xPropertySetInfo;
115 : : }
116 : : };
117 : :
118 : : struct StaticAreaChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAreaChartTypeTemplateInfo_Initializer >
119 : : {
120 : : };
121 : :
122 : : } // anonymous namespace
123 : :
124 : : namespace chart
125 : : {
126 : :
127 : 217 : AreaChartTypeTemplate::AreaChartTypeTemplate(
128 : : uno::Reference<
129 : : uno::XComponentContext > const & xContext,
130 : : const ::rtl::OUString & rServiceName,
131 : : StackMode eStackMode,
132 : : sal_Int32 nDim /* = 2 */ ) :
133 : : ChartTypeTemplate( xContext, rServiceName ),
134 : : ::property::OPropertySet( m_aMutex ),
135 [ + - ][ + - ]: 217 : m_eStackMode( eStackMode )
136 : : {
137 [ + - ][ + - ]: 217 : setFastPropertyValue_NoBroadcast( PROP_AREA_TEMPLATE_DIMENSION, uno::makeAny( nDim ));
138 : 217 : }
139 : :
140 [ + - ][ + - ]: 217 : AreaChartTypeTemplate::~AreaChartTypeTemplate()
141 [ - + ]: 434 : {}
142 : :
143 : : // ____ OPropertySet ____
144 : 414 : uno::Any AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
145 : : throw(beans::UnknownPropertyException)
146 : : {
147 [ + - ]: 414 : const tPropertyValueMap& rStaticDefaults = *StaticAreaChartTypeTemplateDefaults::get();
148 [ + - ]: 414 : tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
149 [ - + ]: 414 : if( aFound == rStaticDefaults.end() )
150 : 0 : return uno::Any();
151 : 414 : return (*aFound).second;
152 : : }
153 : :
154 : 217 : ::cppu::IPropertyArrayHelper & SAL_CALL AreaChartTypeTemplate::getInfoHelper()
155 : : {
156 : 217 : return *StaticAreaChartTypeTemplateInfoHelper::get();
157 : : }
158 : :
159 : : // ____ XPropertySet ____
160 : 0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL AreaChartTypeTemplate::getPropertySetInfo()
161 : : throw (uno::RuntimeException)
162 : : {
163 : 0 : return *StaticAreaChartTypeTemplateInfo::get();
164 : : }
165 : :
166 : 217 : sal_Int32 AreaChartTypeTemplate::getDimension() const
167 : : {
168 : 217 : sal_Int32 nDim = 2;
169 : : try
170 : : {
171 : : // note: UNO-methods are never const
172 : : const_cast< AreaChartTypeTemplate * >( this )->
173 [ + - ]: 217 : getFastPropertyValue( PROP_AREA_TEMPLATE_DIMENSION ) >>= nDim;
174 : : }
175 [ # # ]: 0 : catch( const beans::UnknownPropertyException & ex )
176 : : {
177 : : ASSERT_EXCEPTION( ex );
178 : : }
179 : :
180 [ # # ]: 217 : return nDim;
181 : : }
182 : :
183 : 0 : StackMode AreaChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
184 : : {
185 : 0 : return m_eStackMode;
186 : : }
187 : :
188 : : // ____ XChartTypeTemplate ____
189 : 0 : void SAL_CALL AreaChartTypeTemplate::applyStyle(
190 : : const Reference< chart2::XDataSeries >& xSeries,
191 : : ::sal_Int32 nChartTypeIndex,
192 : : ::sal_Int32 nSeriesIndex,
193 : : ::sal_Int32 nSeriesCount )
194 : : throw (uno::RuntimeException)
195 : : {
196 : 0 : ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
197 [ # # ][ # # ]: 0 : DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
[ # # ]
198 : 0 : }
199 : :
200 : 0 : void SAL_CALL AreaChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram >& xDiagram )
201 : : throw (uno::RuntimeException)
202 : : {
203 [ # # ]: 0 : ChartTypeTemplate::resetStyles( xDiagram );
204 : : ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
205 [ # # ]: 0 : DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
206 [ # # ]: 0 : uno::Any aLineStyleAny( uno::makeAny( drawing::LineStyle_NONE ));
207 [ # # ][ # # ]: 0 : for( ::std::vector< Reference< chart2::XDataSeries > >::iterator aIt( aSeriesVec.begin());
208 : 0 : aIt != aSeriesVec.end(); ++aIt )
209 : : {
210 [ # # ]: 0 : Reference< beans::XPropertyState > xState( *aIt, uno::UNO_QUERY );
211 [ # # ]: 0 : Reference< beans::XPropertySet > xProp( *aIt, uno::UNO_QUERY );
212 [ # # # # : 0 : if( xState.is() &&
# # ][ # # ]
213 : 0 : xProp.is() &&
214 [ # # ][ # # ]: 0 : xProp->getPropertyValue( C2U("BorderStyle")) == aLineStyleAny )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
215 : : {
216 [ # # ][ # # ]: 0 : xState->setPropertyToDefault( C2U("BorderStyle"));
[ # # ]
217 : : }
218 : 0 : }
219 : 0 : }
220 : :
221 : 217 : Reference< chart2::XChartType > AreaChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
222 : : {
223 : 217 : Reference< chart2::XChartType > xResult;
224 : :
225 : : try
226 : : {
227 : : Reference< lang::XMultiServiceFactory > xFact(
228 [ + - ][ + - ]: 217 : GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
[ + - ][ + - ]
229 [ + - ]: 217 : xResult.set( xFact->createInstance(
230 [ + - ][ + - ]: 217 : CHART2_SERVICE_NAME_CHARTTYPE_AREA ), uno::UNO_QUERY_THROW );
[ + - ][ # # ]
231 : : }
232 [ # # ]: 0 : catch( const uno::Exception & ex )
233 : : {
234 : : ASSERT_EXCEPTION( ex );
235 : : }
236 : :
237 : 217 : return xResult;
238 : : }
239 : :
240 : 217 : Reference< chart2::XChartType > SAL_CALL AreaChartTypeTemplate::getChartTypeForNewSeries(
241 : : const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
242 : : throw (uno::RuntimeException)
243 : : {
244 : 217 : Reference< chart2::XChartType > xResult( getChartTypeForIndex( 0 ) );
245 [ + - ]: 217 : ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes, xResult );
246 : 217 : return xResult;
247 : : }
248 : :
249 : :
250 : : // ----------------------------------------
251 : :
252 : 0 : uno::Sequence< ::rtl::OUString > AreaChartTypeTemplate::getSupportedServiceNames_Static()
253 : : {
254 : 0 : uno::Sequence< ::rtl::OUString > aServices( 2 );
255 [ # # ]: 0 : aServices[ 0 ] = lcl_aServiceName;
256 [ # # ][ # # ]: 0 : aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartTypeTemplate" );
257 : 0 : return aServices;
258 : : }
259 : :
260 : : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
261 [ # # ][ # # ]: 0 : APPHELPER_XSERVICEINFO_IMPL( AreaChartTypeTemplate, lcl_aServiceName );
[ # # ][ # # ]
[ # # ]
262 : :
263 [ - + ][ # # ]: 1736 : IMPLEMENT_FORWARD_XINTERFACE2( AreaChartTypeTemplate, ChartTypeTemplate, OPropertySet )
264 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( AreaChartTypeTemplate, ChartTypeTemplate, OPropertySet )
[ # # ]
265 : :
266 [ + - ][ + - ]: 48 : } // namespace chart
267 : :
268 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|