1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
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 "BubbleChartTypeTemplate.hxx"
35 #include "BubbleDataInterpreter.hxx"
36 #include "CartesianCoordinateSystem.hxx"
37 #include "Scaling.hxx"
38 #include "DiagramHelper.hxx"
39 #include "servicenames_charttypes.hxx"
40 #include "ContainerHelper.hxx"
41 #include "DataSeriesHelper.hxx"
42 #include <com/sun/star/chart2/SymbolStyle.hpp>
43 #include <com/sun/star/chart2/Symbol.hpp>
44 #include <com/sun/star/drawing/LineStyle.hpp>
45 #include "PropertyHelper.hxx"
46 #include <com/sun/star/beans/PropertyAttribute.hpp>
50 using namespace ::com::sun::star
;
52 using ::com::sun::star::uno::Reference
;
53 using ::com::sun::star::uno::Sequence
;
54 using ::rtl::OUString
;
55 using ::com::sun::star::beans::Property
;
56 using ::com::sun::star::uno::Reference
;
57 using ::com::sun::star::uno::Any
;
58 using ::osl::MutexGuard
;
63 static const OUString
lcl_aServiceName(
64 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.BubbleChartTypeTemplate" ));
66 void lcl_AddPropertiesToVector(
67 ::std::vector
< Property
> & /*rOutProperties*/ )
71 void lcl_AddDefaultsToMap(
72 ::chart::tPropertyValueMap
& /*rOutMap*/ )
76 const Sequence
< Property
> & lcl_GetPropertySequence()
78 static Sequence
< Property
> aPropSeq
;
81 MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
82 if( 0 == aPropSeq
.getLength() )
85 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
86 lcl_AddPropertiesToVector( aProperties
);
88 // and sort them for access via bsearch
89 ::std::sort( aProperties
.begin(), aProperties
.end(),
90 ::chart::PropertyNameLess() );
92 // transfer result to static Sequence
93 aPropSeq
= ::chart::ContainerHelper::ContainerToSequence( aProperties
);
99 ::cppu::IPropertyArrayHelper
& lcl_getInfoHelper()
101 static ::cppu::OPropertyArrayHelper
aArrayHelper(
102 lcl_GetPropertySequence(),
103 /* bSorted = */ sal_True
);
108 } // anonymous namespace
113 BubbleChartTypeTemplate::BubbleChartTypeTemplate(
115 uno::XComponentContext
> const & xContext
,
116 const OUString
& rServiceName
) :
117 ChartTypeTemplate( xContext
, rServiceName
),
118 ::property::OPropertySet( m_aMutex
)
122 BubbleChartTypeTemplate::~BubbleChartTypeTemplate()
125 // ____ OPropertySet ____
126 uno::Any
BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle
) const
127 throw(beans::UnknownPropertyException
)
129 static tPropertyValueMap aStaticDefaults
;
132 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
133 if( 0 == aStaticDefaults
.size() )
135 // initialize defaults
136 lcl_AddDefaultsToMap( aStaticDefaults
);
139 tPropertyValueMap::const_iterator
aFound(
140 aStaticDefaults
.find( nHandle
));
142 if( aFound
== aStaticDefaults
.end())
145 return (*aFound
).second
;
149 ::cppu::IPropertyArrayHelper
& SAL_CALL
BubbleChartTypeTemplate::getInfoHelper()
151 return lcl_getInfoHelper();
155 // ____ XPropertySet ____
156 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
157 BubbleChartTypeTemplate::getPropertySetInfo()
158 throw (uno::RuntimeException
)
160 static uno::Reference
< beans::XPropertySetInfo
> xInfo
;
163 MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
166 xInfo
= ::cppu::OPropertySetHelper::createPropertySetInfo(
174 sal_Int32
BubbleChartTypeTemplate::getDimension() const
179 StackMode
BubbleChartTypeTemplate::getStackMode( sal_Int32
/* nChartTypeIndex */ ) const
181 return StackMode_NONE
;
184 bool BubbleChartTypeTemplate::supportsCategories() const
190 void SAL_CALL
BubbleChartTypeTemplate::applyStyle(
191 const Reference
< chart2::XDataSeries
>& xSeries
,
192 ::sal_Int32 nChartTypeIndex
,
193 ::sal_Int32 nSeriesIndex
,
194 ::sal_Int32 nSeriesCount
)
195 throw (uno::RuntimeException
)
197 ChartTypeTemplate::applyStyle( xSeries
, nChartTypeIndex
, nSeriesIndex
, nSeriesCount
);
202 catch( uno::Exception
& ex
)
204 ASSERT_EXCEPTION( ex
);
208 // ____ XChartTypeTemplate ____
209 Sequence
< OUString
> SAL_CALL
BubbleChartTypeTemplate::getAvailableCreationParameterNames()
210 throw (uno::RuntimeException
)
212 return Sequence
< OUString
>();
215 sal_Bool SAL_CALL
BubbleChartTypeTemplate::matchesTemplate(
216 const Reference
< chart2::XDiagram
>& xDiagram
,
217 sal_Bool bAdaptProperties
)
218 throw (uno::RuntimeException
)
220 sal_Bool bResult
= ChartTypeTemplate::matchesTemplate( xDiagram
, bAdaptProperties
);
224 ::std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVec(
225 DiagramHelper::getDataSeriesFromDiagram( xDiagram
));
227 for( ::std::vector
< Reference
< chart2::XDataSeries
> >::const_iterator aIt
=
228 aSeriesVec
.begin(); aIt
!= aSeriesVec
.end(); ++aIt
)
233 catch( uno::Exception
& ex
)
235 ASSERT_EXCEPTION( ex
);
240 // adapt curve style, spline order and resolution
241 if( bResult
&& bAdaptProperties
)
246 catch( uno::Exception
& ex
)
248 ASSERT_EXCEPTION( ex
);
255 Reference
< chart2::XChartType
> BubbleChartTypeTemplate::getChartTypeForIndex( sal_Int32
/*nChartTypeIndex*/ )
257 Reference
< chart2::XChartType
> xResult
;
261 Reference
< lang::XMultiServiceFactory
> xFact(
262 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW
);
263 xResult
.set( xFact
->createInstance(
264 CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE
), uno::UNO_QUERY_THROW
);
266 catch( uno::Exception
& ex
)
268 ASSERT_EXCEPTION( ex
);
274 Reference
< chart2::XChartType
> SAL_CALL
BubbleChartTypeTemplate::getChartTypeForNewSeries(
275 const uno::Sequence
< Reference
< chart2::XChartType
> >& aFormerlyUsedChartTypes
)
276 throw (uno::RuntimeException
)
278 Reference
< chart2::XChartType
> xResult
;
282 Reference
< lang::XMultiServiceFactory
> xFact(
283 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW
);
284 xResult
.set( xFact
->createInstance(
285 CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE
), uno::UNO_QUERY_THROW
);
287 ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes
, xResult
);
289 catch( uno::Exception
& ex
)
291 ASSERT_EXCEPTION( ex
);
297 Reference
< chart2::XDataInterpreter
> SAL_CALL
BubbleChartTypeTemplate::getDataInterpreter()
298 throw (uno::RuntimeException
)
300 if( ! m_xDataInterpreter
.is())
301 m_xDataInterpreter
.set( new BubbleDataInterpreter( GetComponentContext()) );
303 return m_xDataInterpreter
;
306 // ----------------------------------------
308 Sequence
< OUString
> BubbleChartTypeTemplate::getSupportedServiceNames_Static()
310 Sequence
< OUString
> aServices( 2 );
311 aServices
[ 0 ] = lcl_aServiceName
;
312 aServices
[ 1 ] = C2U( "com.sun.star.chart2.ChartTypeTemplate" );
316 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
317 APPHELPER_XSERVICEINFO_IMPL( BubbleChartTypeTemplate
, lcl_aServiceName
);
319 IMPLEMENT_FORWARD_XINTERFACE2( BubbleChartTypeTemplate
, ChartTypeTemplate
, OPropertySet
)
320 IMPLEMENT_FORWARD_XTYPEPROVIDER2( BubbleChartTypeTemplate
, ChartTypeTemplate
, OPropertySet
)