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 "ColumnChartType.hxx"
22 #include "servicenames_charttypes.hxx"
23 #include "PropertyHelper.hxx"
24 #include "ContainerHelper.hxx"
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <cppuhelper/supportsservice.hxx>
28 using namespace ::com::sun::star
;
29 using ::com::sun::star::uno::Sequence
;
30 using ::com::sun::star::beans::Property
;
37 PROP_BARCHARTTYPE_OVERLAP_SEQUENCE
,
38 PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
41 void lcl_AddPropertiesToVector(
42 ::std::vector
< Property
> & rOutProperties
)
44 rOutProperties
.push_back(
45 Property( "OverlapSequence",
46 PROP_BARCHARTTYPE_OVERLAP_SEQUENCE
,
47 cppu::UnoType
<Sequence
< sal_Int32
>>::get(),
48 beans::PropertyAttribute::BOUND
49 | beans::PropertyAttribute::MAYBEDEFAULT
));
51 rOutProperties
.push_back(
52 Property( "GapwidthSequence",
53 PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
,
54 cppu::UnoType
<Sequence
< sal_Int32
>>::get(),
55 beans::PropertyAttribute::BOUND
56 | beans::PropertyAttribute::MAYBEDEFAULT
));
59 struct StaticColumnChartTypeDefaults_Initializer
61 ::chart::tPropertyValueMap
* operator()()
63 static ::chart::tPropertyValueMap aStaticDefaults
;
64 lcl_AddDefaultsToMap( aStaticDefaults
);
65 return &aStaticDefaults
;
68 static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap
& rOutMap
)
70 Sequence
< sal_Int32
> aSeq(2);
72 aSeq
[0] = aSeq
[1] = 0;
73 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE
, aSeq
);
75 aSeq
[0] = aSeq
[1] = 100;
76 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
, aSeq
);
80 struct StaticColumnChartTypeDefaults
: public rtl::StaticAggregate
< ::chart::tPropertyValueMap
, StaticColumnChartTypeDefaults_Initializer
>
84 struct StaticColumnChartTypeInfoHelper_Initializer
86 ::cppu::OPropertyArrayHelper
* operator()()
88 static ::cppu::OPropertyArrayHelper
aPropHelper( lcl_GetPropertySequence() );
93 static Sequence
< Property
> lcl_GetPropertySequence()
95 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
96 lcl_AddPropertiesToVector( aProperties
);
98 ::std::sort( aProperties
.begin(), aProperties
.end(),
99 ::chart::PropertyNameLess() );
101 return ::chart::ContainerHelper::ContainerToSequence( aProperties
);
106 struct StaticColumnChartTypeInfoHelper
: public rtl::StaticAggregate
< ::cppu::OPropertyArrayHelper
, StaticColumnChartTypeInfoHelper_Initializer
>
110 struct StaticColumnChartTypeInfo_Initializer
112 uno::Reference
< beans::XPropertySetInfo
>* operator()()
114 static uno::Reference
< beans::XPropertySetInfo
> xPropertySetInfo(
115 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnChartTypeInfoHelper::get() ) );
116 return &xPropertySetInfo
;
120 struct StaticColumnChartTypeInfo
: public rtl::StaticAggregate
< uno::Reference
< beans::XPropertySetInfo
>, StaticColumnChartTypeInfo_Initializer
>
124 } // anonymous namespace
129 ColumnChartType::ColumnChartType(
130 const uno::Reference
< uno::XComponentContext
> & xContext
) :
131 ChartType( xContext
)
134 ColumnChartType::ColumnChartType( const ColumnChartType
& rOther
) :
139 ColumnChartType::~ColumnChartType()
142 // ____ XCloneable ____
143 uno::Reference
< util::XCloneable
> SAL_CALL
ColumnChartType::createClone()
144 throw (uno::RuntimeException
, std::exception
)
146 return uno::Reference
< util::XCloneable
>( new ColumnChartType( *this ));
149 // ____ XChartType ____
150 OUString SAL_CALL
ColumnChartType::getChartType()
151 throw (uno::RuntimeException
, std::exception
)
153 return OUString(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN
);
156 uno::Sequence
< OUString
> ColumnChartType::getSupportedPropertyRoles()
157 throw (uno::RuntimeException
, std::exception
)
159 uno::Sequence
< OUString
> aPropRoles(2);
160 aPropRoles
[0] = "FillColor";
161 aPropRoles
[1] = "BorderColor";
166 // ____ OPropertySet ____
167 uno::Any
ColumnChartType::GetDefaultValue( sal_Int32 nHandle
) const
168 throw(beans::UnknownPropertyException
)
170 const tPropertyValueMap
& rStaticDefaults
= *StaticColumnChartTypeDefaults::get();
171 tPropertyValueMap::const_iterator
aFound( rStaticDefaults
.find( nHandle
) );
172 if( aFound
== rStaticDefaults
.end() )
174 return (*aFound
).second
;
177 ::cppu::IPropertyArrayHelper
& SAL_CALL
ColumnChartType::getInfoHelper()
179 return *StaticColumnChartTypeInfoHelper::get();
182 // ____ XPropertySet ____
183 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
ColumnChartType::getPropertySetInfo()
184 throw (uno::RuntimeException
, std::exception
)
186 return *StaticColumnChartTypeInfo::get();
189 uno::Sequence
< OUString
> ColumnChartType::getSupportedServiceNames_Static()
191 uno::Sequence
< OUString
> aServices( 2 );
192 aServices
[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_COLUMN
;
193 aServices
[ 1 ] = "com.sun.star.chart2.ChartType";
197 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
198 OUString SAL_CALL
ColumnChartType::getImplementationName()
199 throw( css::uno::RuntimeException
, std::exception
)
201 return getImplementationName_Static();
204 OUString
ColumnChartType::getImplementationName_Static()
206 return OUString("com.sun.star.comp.chart.ColumnChartType");
209 sal_Bool SAL_CALL
ColumnChartType::supportsService( const OUString
& rServiceName
)
210 throw( css::uno::RuntimeException
, std::exception
)
212 return cppu::supportsService(this, rServiceName
);
215 css::uno::Sequence
< OUString
> SAL_CALL
ColumnChartType::getSupportedServiceNames()
216 throw( css::uno::RuntimeException
, std::exception
)
218 return getSupportedServiceNames_Static();
223 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
224 com_sun_star_comp_chart_ColumnChartType_get_implementation(css::uno::XComponentContext
*context
,
225 css::uno::Sequence
<css::uno::Any
> const &)
227 return cppu::acquire(new ::chart::ColumnChartType(context
));
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */