LibreOffice Module chart2 (master) 1
ColumnChartType.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 "ColumnChartType.hxx"
22#include <PropertyHelper.hxx>
23#include <com/sun/star/beans/PropertyAttribute.hpp>
25
26namespace com::sun::star::uno { class XComponentContext; }
27
28using namespace ::com::sun::star;
29using ::com::sun::star::uno::Sequence;
30using ::com::sun::star::beans::Property;
31
32namespace
33{
34
35enum
36{
37 PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
38 PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
39};
40
41void lcl_AddPropertiesToVector(
42 std::vector< Property > & rOutProperties )
43{
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 );
49
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 );
55}
56
57::cppu::OPropertyArrayHelper & StaticColumnChartTypeInfoHelper()
58{
59 static ::cppu::OPropertyArrayHelper aPropHelper = []()
60 {
61 std::vector< css::beans::Property > aProperties;
62 lcl_AddPropertiesToVector( aProperties );
63
64 std::sort( aProperties.begin(), aProperties.end(),
66
67 return comphelper::containerToSequence( aProperties );
68 }();
69 return aPropHelper;
70};
71
72} // anonymous namespace
73
74namespace chart
75{
76
78{}
79
81 ChartType( rOther )
82{
83}
84
86{}
87
88// ____ XCloneable ____
90{
92}
93
95{
96 return new ColumnChartType( *this );
97}
98
99// ____ XChartType ____
101{
103}
104
106{
107 return { "FillColor", "BorderColor" };
108}
109
110// ____ OPropertySet ____
111void ColumnChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
112{
113 static const ::chart::tPropertyValueMap aStaticDefaults = []()
114 {
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;
127}
128
130{
131 return StaticColumnChartTypeInfoHelper();
132}
133
134// ____ XPropertySet ____
136{
137 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
138 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticColumnChartTypeInfoHelper() ) );
139 return xPropertySetInfo;
140}
141
143{
144 return "com.sun.star.comp.chart.ColumnChartType";
145}
146
147sal_Bool SAL_CALL ColumnChartType::supportsService( const OUString& rServiceName )
148{
149 return cppu::supportsService(this, rServiceName);
150}
151
152css::uno::Sequence< OUString > SAL_CALL ColumnChartType::getSupportedServiceNames()
153{
154 return {
156 "com.sun.star.chart2.ChartType" };
157}
158
159} // namespace chart
160
161extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
162com_sun_star_comp_chart_ColumnChartType_get_implementation(css::uno::XComponentContext * /*context*/,
163 css::uno::Sequence<css::uno::Any> const &)
164{
165 return cppu::acquire(new ::chart::ColumnChartType());
166}
167
168/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_chart_ColumnChartType_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
PropertiesInfo aProperties
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
The InfoHelper table contains all property names and types of this object.
virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any &rAny) const override
implement this method to provide default values for all properties supporting defaults.
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual rtl::Reference< ChartType > cloneChartType() const override
virtual ~ColumnChartType() override
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
virtual OUString SAL_CALL getChartType() override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedPropertyRoles() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
Sequence< sal_Int8 > aSeq
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_COLUMN
unsigned char sal_Bool