tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / model / template / ColumnChartType.cxx
blob378ed35e59d79866be15cb3a0b6c2f5734a162cb
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 "ColumnChartType.hxx"
21 #include <servicenames_charttypes.hxx>
22 #include <PropertyHelper.hxx>
23 #include <com/sun/star/beans/PropertyAttribute.hpp>
24 #include <cppuhelper/supportsservice.hxx>
26 namespace com::sun::star::uno { class XComponentContext; }
28 using namespace ::com::sun::star;
29 using ::com::sun::star::uno::Sequence;
30 using ::com::sun::star::beans::Property;
32 namespace
35 enum
37 PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
38 PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
41 void lcl_AddPropertiesToVector(
42 std::vector< Property > & rOutProperties )
44 rOutProperties.emplace_back( "OverlapSequence",
45 PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
46 cppu::UnoType<Sequence< sal_Int32 >>::get(),
47 beans::PropertyAttribute::BOUND
48 | beans::PropertyAttribute::MAYBEDEFAULT );
50 rOutProperties.emplace_back( "GapwidthSequence",
51 PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE,
52 cppu::UnoType<Sequence< sal_Int32 >>::get(),
53 beans::PropertyAttribute::BOUND
54 | beans::PropertyAttribute::MAYBEDEFAULT );
57 ::cppu::OPropertyArrayHelper & StaticColumnChartTypeInfoHelper()
59 static ::cppu::OPropertyArrayHelper aPropHelper = []()
61 std::vector< css::beans::Property > aProperties;
62 lcl_AddPropertiesToVector( aProperties );
64 std::sort( aProperties.begin(), aProperties.end(),
65 ::chart::PropertyNameLess() );
67 return comphelper::containerToSequence( aProperties );
68 }();
69 return aPropHelper;
72 } // anonymous namespace
74 namespace chart
77 ColumnChartType::ColumnChartType()
80 ColumnChartType::ColumnChartType( const ColumnChartType & rOther ) :
81 ChartType( rOther )
85 ColumnChartType::~ColumnChartType()
88 // ____ XCloneable ____
89 uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone()
91 return uno::Reference< util::XCloneable >( new ColumnChartType( *this ));
94 rtl::Reference< ChartType > ColumnChartType::cloneChartType() const
96 return new ColumnChartType( *this );
99 // ____ XChartType ____
100 OUString SAL_CALL ColumnChartType::getChartType()
102 return CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
105 uno::Sequence< OUString > ColumnChartType::getSupportedPropertyRoles()
107 return { u"FillColor"_ustr, u"BorderColor"_ustr };
110 // ____ OPropertySet ____
111 void ColumnChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
113 static const ::chart::tPropertyValueMap aStaticDefaults = []()
115 ::chart::tPropertyValueMap aTmp;
116 Sequence< sal_Int32 > aSeq{ 0, 0 };
117 ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
118 aSeq = { 100, 100 };
119 ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq );
120 return aTmp;
121 }();
122 tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
123 if( aFound == aStaticDefaults.end() )
124 rAny.clear();
125 else
126 rAny = (*aFound).second;
129 ::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper()
131 return StaticColumnChartTypeInfoHelper();
134 // ____ XPropertySet ____
135 uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo()
137 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
138 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticColumnChartTypeInfoHelper() ) );
139 return xPropertySetInfo;
142 OUString SAL_CALL ColumnChartType::getImplementationName()
144 return u"com.sun.star.comp.chart.ColumnChartType"_ustr;
147 sal_Bool SAL_CALL ColumnChartType::supportsService( const OUString& rServiceName )
149 return cppu::supportsService(this, rServiceName);
152 css::uno::Sequence< OUString > SAL_CALL ColumnChartType::getSupportedServiceNames()
154 return {
155 CHART2_SERVICE_NAME_CHARTTYPE_COLUMN,
156 u"com.sun.star.chart2.ChartType"_ustr };
159 } // namespace chart
161 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
162 com_sun_star_comp_chart_ColumnChartType_get_implementation(css::uno::XComponentContext * /*context*/,
163 css::uno::Sequence<css::uno::Any> const &)
165 return cppu::acquire(new ::chart::ColumnChartType());
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */