tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / model / template / LineChartType.cxx
blob4d75a029b94483a609084015c1fff130a15694a1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "LineChartType.hxx"
21 #include <PropertyHelper.hxx>
22 #include <servicenames_charttypes.hxx>
23 #include <unonames.hxx>
24 #include <cppuhelper/supportsservice.hxx>
26 #include <com/sun/star/beans/PropertyAttribute.hpp>
27 #include <com/sun/star/chart2/CurveStyle.hpp>
29 namespace com::sun::star::uno { class XComponentContext; }
31 using namespace ::com::sun::star;
33 using ::com::sun::star::beans::Property;
34 using ::com::sun::star::uno::Sequence;
36 namespace
39 enum
41 PROP_LINECHARTTYPE_CURVE_STYLE,
42 PROP_LINECHARTTYPE_CURVE_RESOLUTION,
43 PROP_LINECHARTTYPE_SPLINE_ORDER
46 ::chart::tPropertyValueMap& StaticLineChartTypeDefaults()
48 static ::chart::tPropertyValueMap aStaticDefaults =
49 []()
51 ::chart::tPropertyValueMap aOutMap;
52 ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES );
53 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 );
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;
63 ::cppu::OPropertyArrayHelper& StaticLineChartTypeInfoHelper()
65 static ::cppu::OPropertyArrayHelper aPropHelper(
66 []()
68 std::vector< css::beans::Property > aProperties {
69 { CHART_UNONAME_CURVE_STYLE,
70 PROP_LINECHARTTYPE_CURVE_STYLE,
71 cppu::UnoType<chart2::CurveStyle>::get(),
72 beans::PropertyAttribute::BOUND
73 | beans::PropertyAttribute::MAYBEDEFAULT },
74 { CHART_UNONAME_CURVE_RESOLUTION,
75 PROP_LINECHARTTYPE_CURVE_RESOLUTION,
76 cppu::UnoType<sal_Int32>::get(),
77 beans::PropertyAttribute::BOUND
78 | beans::PropertyAttribute::MAYBEDEFAULT },
79 { CHART_UNONAME_SPLINE_ORDER,
80 PROP_LINECHARTTYPE_SPLINE_ORDER,
81 cppu::UnoType<sal_Int32>::get(),
82 beans::PropertyAttribute::BOUND
83 | beans::PropertyAttribute::MAYBEDEFAULT } };
85 std::sort( aProperties.begin(), aProperties.end(),
86 ::chart::PropertyNameLess() );
88 return comphelper::containerToSequence( aProperties );
89 }());
90 return aPropHelper;
93 uno::Reference< beans::XPropertySetInfo >& StaticLineChartTypeInfo()
95 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
96 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLineChartTypeInfoHelper() ) );
97 return xPropertySetInfo;
100 } // anonymous namespace
102 namespace chart
105 LineChartType::LineChartType()
109 LineChartType::LineChartType( const LineChartType & rOther ) :
110 ChartType( rOther )
114 LineChartType::~LineChartType()
117 // ____ XCloneable ____
118 uno::Reference< util::XCloneable > SAL_CALL LineChartType::createClone()
120 return uno::Reference< util::XCloneable >( new LineChartType( *this ));
123 rtl::Reference< ChartType > LineChartType::cloneChartType() const
125 return new LineChartType( *this );
128 // ____ XChartType ____
129 OUString SAL_CALL LineChartType::getChartType()
131 return CHART2_SERVICE_NAME_CHARTTYPE_LINE;
134 // ____ OPropertySet ____
135 void LineChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
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;
145 ::cppu::IPropertyArrayHelper & SAL_CALL LineChartType::getInfoHelper()
147 return StaticLineChartTypeInfoHelper();
150 // ____ XPropertySet ____
151 uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartType::getPropertySetInfo()
153 return StaticLineChartTypeInfo();
156 OUString SAL_CALL LineChartType::getImplementationName()
158 return u"com.sun.star.comp.chart.LineChartType"_ustr;
161 sal_Bool SAL_CALL LineChartType::supportsService( const OUString& rServiceName )
163 return cppu::supportsService(this, rServiceName);
166 css::uno::Sequence< OUString > SAL_CALL LineChartType::getSupportedServiceNames()
168 return {
169 CHART2_SERVICE_NAME_CHARTTYPE_LINE,
170 u"com.sun.star.chart2.ChartType"_ustr,
171 u"com.sun.star.beans.PropertySet"_ustr };
174 } // namespace chart
176 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
177 com_sun_star_comp_chart_LineChartType_get_implementation(css::uno::XComponentContext * /*context*/,
178 css::uno::Sequence<css::uno::Any> const &)
180 return cppu::acquire(new ::chart::LineChartType);
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */