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 "ScatterChartType.hxx"
21 #include <PropertyHelper.hxx>
22 #include <servicenames_charttypes.hxx>
23 #include <CartesianCoordinateSystem.hxx>
25 #include <AxisHelper.hxx>
26 #include <AxisIndexDefines.hxx>
27 #include <unonames.hxx>
28 #include <cppuhelper/supportsservice.hxx>
30 #include <com/sun/star/beans/PropertyAttribute.hpp>
31 #include <com/sun/star/chart2/AxisType.hpp>
32 #include <com/sun/star/chart2/CurveStyle.hpp>
34 using namespace ::com::sun::star
;
36 using ::com::sun::star::beans::Property
;
37 using ::com::sun::star::uno::Sequence
;
38 using ::com::sun::star::uno::Reference
;
45 PROP_SCATTERCHARTTYPE_CURVE_STYLE
,
46 PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION
,
47 PROP_SCATTERCHARTTYPE_SPLINE_ORDER
50 ::chart::tPropertyValueMap
& StaticScatterChartTypeDefaults()
52 static ::chart::tPropertyValueMap aStaticDefaults
=
55 ::chart::tPropertyValueMap aOutMap
;
56 ::chart::PropertyHelper::setPropertyValueDefault( aOutMap
, PROP_SCATTERCHARTTYPE_CURVE_STYLE
, chart2::CurveStyle_LINES
);
57 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( aOutMap
, PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION
, 20 );
59 // todo: check whether order 3 means polygons of order 3 or 2. (see
60 // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
61 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( aOutMap
, PROP_SCATTERCHARTTYPE_SPLINE_ORDER
, 3 );
64 return aStaticDefaults
;
67 ::cppu::OPropertyArrayHelper
& StaticScatterChartTypeInfoHelper()
69 static ::cppu::OPropertyArrayHelper
aPropHelper(
72 std::vector
< css::beans::Property
> aProperties
{
73 { CHART_UNONAME_CURVE_STYLE
,
74 PROP_SCATTERCHARTTYPE_CURVE_STYLE
,
75 cppu::UnoType
<chart2::CurveStyle
>::get(),
76 beans::PropertyAttribute::BOUND
77 | beans::PropertyAttribute::MAYBEDEFAULT
},
78 { CHART_UNONAME_CURVE_RESOLUTION
,
79 PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION
,
80 cppu::UnoType
<sal_Int32
>::get(),
81 beans::PropertyAttribute::BOUND
82 | beans::PropertyAttribute::MAYBEDEFAULT
},
83 { CHART_UNONAME_SPLINE_ORDER
,
84 PROP_SCATTERCHARTTYPE_SPLINE_ORDER
,
85 cppu::UnoType
<sal_Int32
>::get(),
86 beans::PropertyAttribute::BOUND
87 | beans::PropertyAttribute::MAYBEDEFAULT
} };
88 std::sort( aProperties
.begin(), aProperties
.end(),
89 ::chart::PropertyNameLess() );
90 return comphelper::containerToSequence( aProperties
);
95 const uno::Reference
< beans::XPropertySetInfo
>& StaticScatterChartTypeInfo()
97 static uno::Reference
< beans::XPropertySetInfo
> xPropertySetInfo(
98 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticScatterChartTypeInfoHelper() ) );
99 return xPropertySetInfo
;
102 } // anonymous namespace
107 ScatterChartType::ScatterChartType()
111 ScatterChartType::ScatterChartType( const ScatterChartType
& rOther
) :
116 ScatterChartType::~ScatterChartType()
119 // ____ XCloneable ____
120 uno::Reference
< util::XCloneable
> SAL_CALL
ScatterChartType::createClone()
122 return uno::Reference
< util::XCloneable
>( new ScatterChartType( *this ));
125 rtl::Reference
< ChartType
> ScatterChartType::cloneChartType() const
127 return new ScatterChartType( *this );
130 // ____ XChartType ____
131 rtl::Reference
< ::chart::BaseCoordinateSystem
>
132 ScatterChartType::createCoordinateSystem2( sal_Int32 DimensionCount
)
134 rtl::Reference
< CartesianCoordinateSystem
> xResult
=
135 new CartesianCoordinateSystem( DimensionCount
);
137 for( sal_Int32 i
=0; i
<DimensionCount
; ++i
)
139 rtl::Reference
< Axis
> xAxis
= xResult
->getAxisByDimension2( i
, MAIN_AXIS_INDEX
);
142 OSL_FAIL("a created coordinate system should have an axis for each dimension");
146 chart2::ScaleData aScaleData
= xAxis
->getScaleData();
147 aScaleData
.Orientation
= chart2::AxisOrientation_MATHEMATICAL
;
148 aScaleData
.Scaling
= AxisHelper::createLinearScaling();
151 aScaleData
.AxisType
= chart2::AxisType::SERIES
;
153 aScaleData
.AxisType
= chart2::AxisType::REALNUMBER
;
155 xAxis
->setScaleData( aScaleData
);
161 OUString SAL_CALL
ScatterChartType::getChartType()
163 return CHART2_SERVICE_NAME_CHARTTYPE_SCATTER
;
166 uno::Sequence
< OUString
> SAL_CALL
ScatterChartType::getSupportedMandatoryRoles()
168 return { u
"label"_ustr
, u
"values-x"_ustr
, u
"values-y"_ustr
};
171 // ____ OPropertySet ____
172 void ScatterChartType::GetDefaultValue( sal_Int32 nHandle
, uno::Any
& rAny
) const
174 const tPropertyValueMap
& rStaticDefaults
= StaticScatterChartTypeDefaults();
175 tPropertyValueMap::const_iterator
aFound( rStaticDefaults
.find( nHandle
) );
176 if( aFound
== rStaticDefaults
.end() )
179 rAny
= (*aFound
).second
;
182 // ____ OPropertySet ____
183 ::cppu::IPropertyArrayHelper
& SAL_CALL
ScatterChartType::getInfoHelper()
185 return StaticScatterChartTypeInfoHelper();
188 // ____ XPropertySet ____
189 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
ScatterChartType::getPropertySetInfo()
191 return StaticScatterChartTypeInfo();
194 OUString SAL_CALL
ScatterChartType::getImplementationName()
196 return u
"com.sun.star.comp.chart.ScatterChartType"_ustr
;
199 sal_Bool SAL_CALL
ScatterChartType::supportsService( const OUString
& rServiceName
)
201 return cppu::supportsService(this, rServiceName
);
204 css::uno::Sequence
< OUString
> SAL_CALL
ScatterChartType::getSupportedServiceNames()
207 CHART2_SERVICE_NAME_CHARTTYPE_SCATTER
,
208 u
"com.sun.star.chart2.ChartType"_ustr
,
209 u
"com.sun.star.beans.PropertySet"_ustr
};
214 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
215 com_sun_star_comp_chart_ScatterChartType_get_implementation(css::uno::XComponentContext
* /*context*/,
216 css::uno::Sequence
<css::uno::Any
> const &)
218 return cppu::acquire(new ::chart::ScatterChartType
);
221 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */