LibreOffice Module chart2 (master) 1
LineChartType.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "LineChartType.hxx"
21#include <PropertyHelper.hxx>
23#include <unonames.hxx>
25
26#include <com/sun/star/beans/PropertyAttribute.hpp>
27#include <com/sun/star/chart2/CurveStyle.hpp>
28
29namespace com::sun::star::uno { class XComponentContext; }
30
31using namespace ::com::sun::star;
32
33using ::com::sun::star::beans::Property;
34using ::com::sun::star::uno::Sequence;
35
36namespace
37{
38
39enum
40{
41 PROP_LINECHARTTYPE_CURVE_STYLE,
42 PROP_LINECHARTTYPE_CURVE_RESOLUTION,
43 PROP_LINECHARTTYPE_SPLINE_ORDER
44};
45
46::chart::tPropertyValueMap& StaticLineChartTypeDefaults()
47{
48 static ::chart::tPropertyValueMap aStaticDefaults =
49 []()
50 {
52 ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES );
53 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 );
54
55 // todo: check whether order 3 means polygons of order 3 or 2. (see
56 // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
57 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_SPLINE_ORDER, 3 );
58 return aOutMap;
59 }();
60 return aStaticDefaults;
61}
62
63::cppu::OPropertyArrayHelper& StaticLineChartTypeInfoHelper()
64{
65 static ::cppu::OPropertyArrayHelper aPropHelper(
66 []()
67 {
68 std::vector< css::beans::Property > aProperties {
70 PROP_LINECHARTTYPE_CURVE_STYLE,
72 beans::PropertyAttribute::BOUND
73 | beans::PropertyAttribute::MAYBEDEFAULT },
75 PROP_LINECHARTTYPE_CURVE_RESOLUTION,
77 beans::PropertyAttribute::BOUND
78 | beans::PropertyAttribute::MAYBEDEFAULT },
80 PROP_LINECHARTTYPE_SPLINE_ORDER,
82 beans::PropertyAttribute::BOUND
83 | beans::PropertyAttribute::MAYBEDEFAULT } };
84
85 std::sort( aProperties.begin(), aProperties.end(),
87
88 return comphelper::containerToSequence( aProperties );
89 }());
90 return aPropHelper;
91}
92
93uno::Reference< beans::XPropertySetInfo >& StaticLineChartTypeInfo()
94{
95 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
96 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLineChartTypeInfoHelper() ) );
97 return xPropertySetInfo;
98}
99
100} // anonymous namespace
101
102namespace chart
103{
104
106{
107}
108
110 ChartType( rOther )
111{
112}
113
115{}
116
117// ____ XCloneable ____
119{
121}
122
124{
125 return new LineChartType( *this );
126}
127
128// ____ XChartType ____
130{
132}
133
134// ____ OPropertySet ____
135void LineChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
136{
137 const tPropertyValueMap& rStaticDefaults = StaticLineChartTypeDefaults();
138 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
139 if( aFound == rStaticDefaults.end() )
140 rAny.clear();
141 else
142 rAny = (*aFound).second;
143}
144
146{
147 return StaticLineChartTypeInfoHelper();
148}
149
150// ____ XPropertySet ____
152{
153 return StaticLineChartTypeInfo();
154}
155
157{
158 return "com.sun.star.comp.chart.LineChartType";
159}
160
161sal_Bool SAL_CALL LineChartType::supportsService( const OUString& rServiceName )
162{
163 return cppu::supportsService(this, rServiceName);
164}
165
166css::uno::Sequence< OUString > SAL_CALL LineChartType::getSupportedServiceNames()
167{
168 return {
170 "com.sun.star.chart2.ChartType",
171 "com.sun.star.beans.PropertySet" };
172}
173
174} // namespace chart
175
176extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
177com_sun_star_comp_chart_LineChartType_get_implementation(css::uno::XComponentContext * /*context*/,
178 css::uno::Sequence<css::uno::Any> const &)
179{
180 return cppu::acquire(new ::chart::LineChartType);
181}
182
183/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_chart_LineChartType_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
PropertiesInfo aProperties
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
The InfoHelper table contains all property names and types of this object.
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual OUString SAL_CALL getImplementationName() override
virtual OUString SAL_CALL getChartType() override
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
virtual ~LineChartType() override
virtual rtl::Reference< ChartType > cloneChartType() const override
virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any &rAny) const override
implement this method to provide default values for all properties supporting defaults.
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
css::uno::Type const & get()
void setPropertyValueDefault(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Calls setPropertyValue() but asserts that the given property hasn't been set before.
std::unordered_map< tPropertyValueMapKey, css::uno::Any > tPropertyValueMap
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_Int32 nHandle
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_LINE
unsigned char sal_Bool
constexpr OUStringLiteral CHART_UNONAME_SPLINE_ORDER
Definition: unonames.hxx:16
constexpr OUStringLiteral CHART_UNONAME_CURVE_STYLE
Definition: unonames.hxx:18
constexpr OUStringLiteral CHART_UNONAME_CURVE_RESOLUTION
Definition: unonames.hxx:19