1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "BubbleChartTypeTemplate.hxx"
32 #include "BubbleDataInterpreter.hxx"
33 #include "CartesianCoordinateSystem.hxx"
34 #include "Scaling.hxx"
35 #include "DiagramHelper.hxx"
36 #include "servicenames_charttypes.hxx"
37 #include "ContainerHelper.hxx"
38 #include "DataSeriesHelper.hxx"
39 #include <com/sun/star/chart2/SymbolStyle.hpp>
40 #include <com/sun/star/chart2/Symbol.hpp>
41 #include <com/sun/star/drawing/LineStyle.hpp>
42 #include "PropertyHelper.hxx"
43 #include <com/sun/star/beans/PropertyAttribute.hpp>
47 using namespace ::com::sun::star
;
49 using ::com::sun::star::uno::Reference
;
50 using ::com::sun::star::uno::Sequence
;
51 using ::rtl::OUString
;
52 using ::com::sun::star::beans::Property
;
53 using ::com::sun::star::uno::Reference
;
54 using ::com::sun::star::uno::Any
;
55 using ::osl::MutexGuard
;
60 static const OUString
lcl_aServiceName(
61 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.BubbleChartTypeTemplate" ));
63 void lcl_AddPropertiesToVector(
64 ::std::vector
< Property
> & /*rOutProperties*/ )
68 void lcl_AddDefaultsToMap(
69 ::chart::tPropertyValueMap
& /*rOutMap*/ )
73 const Sequence
< Property
> & lcl_GetPropertySequence()
75 static Sequence
< Property
> aPropSeq
;
78 MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
79 if( 0 == aPropSeq
.getLength() )
82 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
83 lcl_AddPropertiesToVector( aProperties
);
85 // and sort them for access via bsearch
86 ::std::sort( aProperties
.begin(), aProperties
.end(),
87 ::chart::PropertyNameLess() );
89 // transfer result to static Sequence
90 aPropSeq
= ::chart::ContainerHelper::ContainerToSequence( aProperties
);
96 ::cppu::IPropertyArrayHelper
& lcl_getInfoHelper()
98 static ::cppu::OPropertyArrayHelper
aArrayHelper(
99 lcl_GetPropertySequence(),
100 /* bSorted = */ sal_True
);
105 } // anonymous namespace
110 BubbleChartTypeTemplate::BubbleChartTypeTemplate(
112 uno::XComponentContext
> const & xContext
,
113 const OUString
& rServiceName
) :
114 ChartTypeTemplate( xContext
, rServiceName
),
115 ::property::OPropertySet( m_aMutex
)
119 BubbleChartTypeTemplate::~BubbleChartTypeTemplate()
122 // ____ OPropertySet ____
123 uno::Any
BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle
) const
124 throw(beans::UnknownPropertyException
)
126 static tPropertyValueMap aStaticDefaults
;
129 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
130 if( 0 == aStaticDefaults
.size() )
132 // initialize defaults
133 lcl_AddDefaultsToMap( aStaticDefaults
);
136 tPropertyValueMap::const_iterator
aFound(
137 aStaticDefaults
.find( nHandle
));
139 if( aFound
== aStaticDefaults
.end())
142 return (*aFound
).second
;
146 ::cppu::IPropertyArrayHelper
& SAL_CALL
BubbleChartTypeTemplate::getInfoHelper()
148 return lcl_getInfoHelper();
152 // ____ XPropertySet ____
153 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
154 BubbleChartTypeTemplate::getPropertySetInfo()
155 throw (uno::RuntimeException
)
157 static uno::Reference
< beans::XPropertySetInfo
> xInfo
;
160 MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
163 xInfo
= ::cppu::OPropertySetHelper::createPropertySetInfo(
171 sal_Int32
BubbleChartTypeTemplate::getDimension() const
176 StackMode
BubbleChartTypeTemplate::getStackMode( sal_Int32
/* nChartTypeIndex */ ) const
178 return StackMode_NONE
;
181 void SAL_CALL
BubbleChartTypeTemplate::applyStyle(
182 const Reference
< chart2::XDataSeries
>& xSeries
,
183 ::sal_Int32 nChartTypeIndex
,
184 ::sal_Int32 nSeriesIndex
,
185 ::sal_Int32 nSeriesCount
)
186 throw (uno::RuntimeException
)
188 ChartTypeTemplate::applyStyle( xSeries
, nChartTypeIndex
, nSeriesIndex
, nSeriesCount
);
189 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries
, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE
) );
194 catch( uno::Exception
& ex
)
196 ASSERT_EXCEPTION( ex
);
200 // ____ XChartTypeTemplate ____
201 sal_Bool SAL_CALL
BubbleChartTypeTemplate::supportsCategories()
202 throw (uno::RuntimeException
)
207 sal_Bool SAL_CALL
BubbleChartTypeTemplate::matchesTemplate(
208 const Reference
< chart2::XDiagram
>& xDiagram
,
209 sal_Bool bAdaptProperties
)
210 throw (uno::RuntimeException
)
212 sal_Bool bResult
= ChartTypeTemplate::matchesTemplate( xDiagram
, bAdaptProperties
);
216 ::std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVec(
217 DiagramHelper::getDataSeriesFromDiagram( xDiagram
));
219 for( ::std::vector
< Reference
< chart2::XDataSeries
> >::const_iterator aIt
=
220 aSeriesVec
.begin(); aIt
!= aSeriesVec
.end(); ++aIt
)
225 catch( uno::Exception
& ex
)
227 ASSERT_EXCEPTION( ex
);
232 // adapt curve style, spline order and resolution
233 if( bResult
&& bAdaptProperties
)
238 catch( uno::Exception
& ex
)
240 ASSERT_EXCEPTION( ex
);
247 Reference
< chart2::XChartType
> BubbleChartTypeTemplate::getChartTypeForIndex( sal_Int32
/*nChartTypeIndex*/ )
249 Reference
< chart2::XChartType
> xResult
;
253 Reference
< lang::XMultiServiceFactory
> xFact(
254 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW
);
255 xResult
.set( xFact
->createInstance(
256 CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE
), uno::UNO_QUERY_THROW
);
258 catch( uno::Exception
& ex
)
260 ASSERT_EXCEPTION( ex
);
266 Reference
< chart2::XChartType
> SAL_CALL
BubbleChartTypeTemplate::getChartTypeForNewSeries(
267 const uno::Sequence
< Reference
< chart2::XChartType
> >& aFormerlyUsedChartTypes
)
268 throw (uno::RuntimeException
)
270 Reference
< chart2::XChartType
> xResult
;
274 Reference
< lang::XMultiServiceFactory
> xFact(
275 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW
);
276 xResult
.set( xFact
->createInstance(
277 CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE
), uno::UNO_QUERY_THROW
);
279 ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes
, xResult
);
281 catch( uno::Exception
& ex
)
283 ASSERT_EXCEPTION( ex
);
289 Reference
< chart2::XDataInterpreter
> SAL_CALL
BubbleChartTypeTemplate::getDataInterpreter()
290 throw (uno::RuntimeException
)
292 if( ! m_xDataInterpreter
.is())
293 m_xDataInterpreter
.set( new BubbleDataInterpreter( GetComponentContext()) );
295 return m_xDataInterpreter
;
298 // ----------------------------------------
300 Sequence
< OUString
> BubbleChartTypeTemplate::getSupportedServiceNames_Static()
302 Sequence
< OUString
> aServices( 2 );
303 aServices
[ 0 ] = lcl_aServiceName
;
304 aServices
[ 1 ] = C2U( "com.sun.star.chart2.ChartTypeTemplate" );
308 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
309 APPHELPER_XSERVICEINFO_IMPL( BubbleChartTypeTemplate
, lcl_aServiceName
);
311 IMPLEMENT_FORWARD_XINTERFACE2( BubbleChartTypeTemplate
, ChartTypeTemplate
, OPropertySet
)
312 IMPLEMENT_FORWARD_XTYPEPROVIDER2( BubbleChartTypeTemplate
, ChartTypeTemplate
, OPropertySet
)