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 "BubbleChartTypeTemplate.hxx"
22 #include "BubbleDataInterpreter.hxx"
23 #include "CartesianCoordinateSystem.hxx"
24 #include "Scaling.hxx"
25 #include "DiagramHelper.hxx"
26 #include "servicenames_charttypes.hxx"
27 #include "ContainerHelper.hxx"
28 #include "DataSeriesHelper.hxx"
29 #include <com/sun/star/drawing/LineStyle.hpp>
30 #include "PropertyHelper.hxx"
31 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 using namespace ::com::sun::star
;
37 using ::com::sun::star::uno::Reference
;
38 using ::com::sun::star::uno::Sequence
;
39 using ::com::sun::star::beans::Property
;
40 using ::com::sun::star::uno::Any
;
41 using ::osl::MutexGuard
;
46 struct StaticBubbleChartTypeTemplateDefaults_Initializer
48 ::chart::tPropertyValueMap
* operator()()
50 static ::chart::tPropertyValueMap aStaticDefaults
;
51 return &aStaticDefaults
;
55 struct StaticBubbleChartTypeTemplateDefaults
: public rtl::StaticAggregate
< ::chart::tPropertyValueMap
, StaticBubbleChartTypeTemplateDefaults_Initializer
>
59 struct StaticBubbleChartTypeTemplateInfoHelper_Initializer
61 ::cppu::OPropertyArrayHelper
* operator()()
63 static ::cppu::OPropertyArrayHelper
aPropHelper( lcl_GetPropertySequence() );
68 static Sequence
< Property
> lcl_GetPropertySequence()
70 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
72 ::std::sort( aProperties
.begin(), aProperties
.end(),
73 ::chart::PropertyNameLess() );
75 return ::chart::ContainerHelper::ContainerToSequence( aProperties
);
80 struct StaticBubbleChartTypeTemplateInfoHelper
: public rtl::StaticAggregate
< ::cppu::OPropertyArrayHelper
, StaticBubbleChartTypeTemplateInfoHelper_Initializer
>
84 struct StaticBubbleChartTypeTemplateInfo_Initializer
86 uno::Reference
< beans::XPropertySetInfo
>* operator()()
88 static uno::Reference
< beans::XPropertySetInfo
> xPropertySetInfo(
89 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeTemplateInfoHelper::get() ) );
90 return &xPropertySetInfo
;
94 struct StaticBubbleChartTypeTemplateInfo
: public rtl::StaticAggregate
< uno::Reference
< beans::XPropertySetInfo
>, StaticBubbleChartTypeTemplateInfo_Initializer
>
98 } // anonymous namespace
103 BubbleChartTypeTemplate::BubbleChartTypeTemplate(
105 uno::XComponentContext
> const & xContext
,
106 const OUString
& rServiceName
) :
107 ChartTypeTemplate( xContext
, rServiceName
),
108 ::property::OPropertySet( m_aMutex
)
112 BubbleChartTypeTemplate::~BubbleChartTypeTemplate()
115 // ____ OPropertySet ____
116 uno::Any
BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle
) const
117 throw(beans::UnknownPropertyException
)
119 const tPropertyValueMap
& rStaticDefaults
= *StaticBubbleChartTypeTemplateDefaults::get();
120 tPropertyValueMap::const_iterator
aFound( rStaticDefaults
.find( nHandle
) );
121 if( aFound
== rStaticDefaults
.end() )
123 return (*aFound
).second
;
126 ::cppu::IPropertyArrayHelper
& SAL_CALL
BubbleChartTypeTemplate::getInfoHelper()
128 return *StaticBubbleChartTypeTemplateInfoHelper::get();
131 // ____ XPropertySet ____
132 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
BubbleChartTypeTemplate::getPropertySetInfo()
133 throw (uno::RuntimeException
, std::exception
)
135 return *StaticBubbleChartTypeTemplateInfo::get();
138 sal_Int32
BubbleChartTypeTemplate::getDimension() const
143 StackMode
BubbleChartTypeTemplate::getStackMode( sal_Int32
/* nChartTypeIndex */ ) const
145 return StackMode_NONE
;
148 void SAL_CALL
BubbleChartTypeTemplate::applyStyle(
149 const Reference
< chart2::XDataSeries
>& xSeries
,
150 ::sal_Int32 nChartTypeIndex
,
151 ::sal_Int32 nSeriesIndex
,
152 ::sal_Int32 nSeriesCount
)
153 throw (uno::RuntimeException
, std::exception
)
155 ChartTypeTemplate::applyStyle( xSeries
, nChartTypeIndex
, nSeriesIndex
, nSeriesCount
);
156 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries
, "BorderStyle", uno::makeAny( drawing::LineStyle_NONE
) );
159 // ____ XChartTypeTemplate ____
160 sal_Bool SAL_CALL
BubbleChartTypeTemplate::supportsCategories()
161 throw (uno::RuntimeException
, std::exception
)
166 Reference
< chart2::XChartType
> BubbleChartTypeTemplate::getChartTypeForIndex( sal_Int32
/*nChartTypeIndex*/ )
168 Reference
< chart2::XChartType
> xResult
;
172 Reference
< lang::XMultiServiceFactory
> xFact(
173 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW
);
174 xResult
.set( xFact
->createInstance(
175 CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE
), uno::UNO_QUERY_THROW
);
177 catch( const uno::Exception
& ex
)
179 ASSERT_EXCEPTION( ex
);
185 Reference
< chart2::XChartType
> SAL_CALL
BubbleChartTypeTemplate::getChartTypeForNewSeries(
186 const uno::Sequence
< Reference
< chart2::XChartType
> >& aFormerlyUsedChartTypes
)
187 throw (uno::RuntimeException
, std::exception
)
189 Reference
< chart2::XChartType
> xResult
;
193 Reference
< lang::XMultiServiceFactory
> xFact(
194 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW
);
195 xResult
.set( xFact
->createInstance(
196 CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE
), uno::UNO_QUERY_THROW
);
198 ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes
, xResult
);
200 catch( const uno::Exception
& ex
)
202 ASSERT_EXCEPTION( ex
);
208 Reference
< chart2::XDataInterpreter
> SAL_CALL
BubbleChartTypeTemplate::getDataInterpreter()
209 throw (uno::RuntimeException
, std::exception
)
211 if( ! m_xDataInterpreter
.is())
212 m_xDataInterpreter
.set( new BubbleDataInterpreter( GetComponentContext()) );
214 return m_xDataInterpreter
;
217 IMPLEMENT_FORWARD_XINTERFACE2( BubbleChartTypeTemplate
, ChartTypeTemplate
, OPropertySet
)
218 IMPLEMENT_FORWARD_XTYPEPROVIDER2( BubbleChartTypeTemplate
, ChartTypeTemplate
, OPropertySet
)
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */