LibreOffice Module chart2 (master) 1
AreaChartTypeTemplate.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
21#include "AreaChartType.hxx"
22#include <Diagram.hxx>
23#include <DiagramHelper.hxx>
24#include <DataSeries.hxx>
25#include <DataSeriesHelper.hxx>
26#include <PropertyHelper.hxx>
27#include <com/sun/star/beans/PropertyAttribute.hpp>
28#include <com/sun/star/drawing/LineStyle.hpp>
29#include <com/sun/star/uno/XComponentContext.hpp>
31
32#include <algorithm>
33
34using namespace ::com::sun::star;
35
36using ::com::sun::star::beans::Property;
37using ::com::sun::star::uno::Sequence;
38using ::com::sun::star::uno::Reference;
39
40namespace
41{
42
43enum
44{
45 PROP_AREA_TEMPLATE_DIMENSION
46};
47
48void lcl_AddPropertiesToVector(
49 std::vector< Property > & rOutProperties )
50{
51 rOutProperties.emplace_back( "Dimension",
52 PROP_AREA_TEMPLATE_DIMENSION,
54 beans::PropertyAttribute::BOUND
55 | beans::PropertyAttribute::MAYBEDEFAULT );
56}
57
58::cppu::OPropertyArrayHelper& StaticAreaChartTypeTemplateInfoHelper()
59{
60 static ::cppu::OPropertyArrayHelper aPropHelper = []()
61 {
62 std::vector< css::beans::Property > aProperties;
63 lcl_AddPropertiesToVector( aProperties );
64
65 std::sort( aProperties.begin(), aProperties.end(),
67
68 return comphelper::containerToSequence( aProperties );
69 }();
70 return aPropHelper;
71};
72
73} // anonymous namespace
74
75namespace chart
76{
77
80 uno::XComponentContext > const & xContext,
81 const OUString & rServiceName,
82 StackMode eStackMode,
83 sal_Int32 nDim /* = 2 */ ) :
84 ChartTypeTemplate( xContext, rServiceName ),
85 m_eStackMode( eStackMode )
86{
87 setFastPropertyValue_NoBroadcast( PROP_AREA_TEMPLATE_DIMENSION, uno::Any( nDim ));
88}
89
91{}
92
93// ____ OPropertySet ____
94void AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
95{
96 static ::chart::tPropertyValueMap aStaticDefaults = []()
97 {
99 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_AREA_TEMPLATE_DIMENSION, 2 );
100 return aTmp;
101 }();
102 tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
103 if( aFound == aStaticDefaults.end() )
104 rAny.clear();
105 else
106 rAny = (*aFound).second;
107}
108
110{
111 return StaticAreaChartTypeTemplateInfoHelper();
112}
113
114// ____ XPropertySet ____
116{
117 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
118 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticAreaChartTypeTemplateInfoHelper() ) );
119 return xPropertySetInfo;
120}
121
123{
124 sal_Int32 nDim = 2;
125 try
126 {
127 // note: UNO-methods are never const
128 const_cast< AreaChartTypeTemplate * >( this )->
129 getFastPropertyValue( PROP_AREA_TEMPLATE_DIMENSION ) >>= nDim;
130 }
131 catch( const beans::UnknownPropertyException & )
132 {
133 DBG_UNHANDLED_EXCEPTION("chart2");
134 }
135
136 return nDim;
137}
138
139StackMode AreaChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
140{
141 return m_eStackMode;
142}
143
144// ____ ChartTypeTemplate ____
146 const rtl::Reference< DataSeries >& xSeries,
147 ::sal_Int32 nChartTypeIndex,
148 ::sal_Int32 nSeriesIndex,
149 ::sal_Int32 nSeriesCount )
150{
151 ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
152 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
153}
154
156{
158 std::vector< rtl::Reference< ::chart::DataSeries > > aSeriesVec(
159 xDiagram->getDataSeries());
160 uno::Any aLineStyleAny( drawing::LineStyle_NONE );
161 for (auto const& series : aSeriesVec)
162 {
163 if( series->getPropertyValue( "BorderStyle") == aLineStyleAny )
164 {
165 series->setPropertyToDefault( "BorderStyle");
166 }
167 }
168}
169
171{
172 return new AreaChartType();
173}
174
176 const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
177{
179 ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
180 return xResult;
181}
182
185
186} // namespace chart
187
188/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const StackMode m_eStackMode
PropertiesInfo aProperties
virtual rtl::Reference< ::chart::ChartType > getChartTypeForIndex(sal_Int32 nChartTypeIndex) override
virtual void resetStyles2(const rtl::Reference< ::chart::Diagram > &xDiagram) override
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
merge XInterface implementations
virtual void applyStyle2(const rtl::Reference< ::chart::DataSeries > &xSeries, ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount) override
virtual StackMode getStackMode(sal_Int32 nChartTypeIndex) const override
returns StackMode::NONE by default.
AreaChartTypeTemplate(css::uno::Reference< css::uno::XComponentContext > const &xContext, const OUString &rServiceName, StackMode eStackMode, sal_Int32 nDim=2)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual sal_Int32 getDimension() const override
returns 2 by default. Supported are 2 and 3
virtual rtl::Reference< ::chart::ChartType > getChartTypeForNewSeries2(const std::vector< rtl::Reference< ::chart::ChartType > > &aFormerlyUsedChartTypes) override
For creating diagrams and modifying existing diagrams.
static void copyPropertiesFromOldToNewCoordinateSystem(const std::vector< rtl::Reference< ChartType > > &rOldChartTypesSeq, const rtl::Reference< ChartType > &xNewChartType)
virtual void applyStyle2(const rtl::Reference< ::chart::DataSeries > &xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount)
virtual void resetStyles2(const rtl::Reference< ::chart::Diagram > &xDiagram)
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
The same as getFastPropertyValue, but return the value through rValue and nHandle is always valid.
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
The same as setFastPropertyValue; nHandle is always valid.
#define DBG_UNHANDLED_EXCEPTION(...)
OOO_DLLPUBLIC_CHARTTOOLS void setPropertyAlsoToAllAttributedDataPoints(const rtl::Reference< ::chart::DataSeries > &xSeries, const OUString &rPropertyName, const css::uno::Any &rPropertyValue)
std::unordered_map< tPropertyValueMapKey, css::uno::Any > tPropertyValueMap
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
sal_Int32 nHandle