1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "AreaChartTypeTemplate.hxx"
21 #include "AreaChartType.hxx"
22 #include <Diagram.hxx>
23 #include <DataSeries.hxx>
24 #include <DataSeriesHelper.hxx>
25 #include <PropertyHelper.hxx>
26 #include <com/sun/star/beans/PropertyAttribute.hpp>
27 #include <com/sun/star/drawing/LineStyle.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <comphelper/diagnose_ex.hxx>
33 using namespace ::com::sun::star
;
35 using ::com::sun::star::beans::Property
;
36 using ::com::sun::star::uno::Sequence
;
37 using ::com::sun::star::uno::Reference
;
44 PROP_AREA_TEMPLATE_DIMENSION
47 void lcl_AddPropertiesToVector(
48 std::vector
< Property
> & rOutProperties
)
50 rOutProperties
.emplace_back( "Dimension",
51 PROP_AREA_TEMPLATE_DIMENSION
,
52 cppu::UnoType
<sal_Int32
>::get(),
53 beans::PropertyAttribute::BOUND
54 | beans::PropertyAttribute::MAYBEDEFAULT
);
57 ::cppu::OPropertyArrayHelper
& StaticAreaChartTypeTemplateInfoHelper()
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
);
72 } // anonymous namespace
77 AreaChartTypeTemplate::AreaChartTypeTemplate(
79 uno::XComponentContext
> const & xContext
,
80 const OUString
& rServiceName
,
82 sal_Int32 nDim
/* = 2 */ ) :
83 ChartTypeTemplate( xContext
, rServiceName
),
84 m_eStackMode( eStackMode
)
86 setFastPropertyValue_NoBroadcast( PROP_AREA_TEMPLATE_DIMENSION
, uno::Any( nDim
));
89 AreaChartTypeTemplate::~AreaChartTypeTemplate()
92 // ____ OPropertySet ____
93 void AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle
, uno::Any
& rAny
) const
95 static ::chart::tPropertyValueMap aStaticDefaults
= []()
97 ::chart::tPropertyValueMap aTmp
;
98 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( aTmp
, PROP_AREA_TEMPLATE_DIMENSION
, 2 );
101 tPropertyValueMap::const_iterator
aFound( aStaticDefaults
.find( nHandle
) );
102 if( aFound
== aStaticDefaults
.end() )
105 rAny
= (*aFound
).second
;
108 ::cppu::IPropertyArrayHelper
& SAL_CALL
AreaChartTypeTemplate::getInfoHelper()
110 return StaticAreaChartTypeTemplateInfoHelper();
113 // ____ XPropertySet ____
114 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
AreaChartTypeTemplate::getPropertySetInfo()
116 static uno::Reference
< beans::XPropertySetInfo
> xPropertySetInfo(
117 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticAreaChartTypeTemplateInfoHelper() ) );
118 return xPropertySetInfo
;
121 sal_Int32
AreaChartTypeTemplate::getDimension() const
126 // note: UNO-methods are never const
127 const_cast< AreaChartTypeTemplate
* >( this )->
128 getFastPropertyValue( PROP_AREA_TEMPLATE_DIMENSION
) >>= nDim
;
130 catch( const beans::UnknownPropertyException
& )
132 DBG_UNHANDLED_EXCEPTION("chart2");
138 StackMode
AreaChartTypeTemplate::getStackMode( sal_Int32
/* nChartTypeIndex */ ) const
143 // ____ ChartTypeTemplate ____
144 void AreaChartTypeTemplate::applyStyle2(
145 const rtl::Reference
< DataSeries
>& xSeries
,
146 ::sal_Int32 nChartTypeIndex
,
147 ::sal_Int32 nSeriesIndex
,
148 ::sal_Int32 nSeriesCount
)
150 ChartTypeTemplate::applyStyle2( xSeries
, nChartTypeIndex
, nSeriesIndex
, nSeriesCount
);
151 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries
, u
"BorderStyle"_ustr
, uno::Any( drawing::LineStyle_NONE
) );
154 void AreaChartTypeTemplate::resetStyles2( const rtl::Reference
< ::chart::Diagram
>& xDiagram
)
156 ChartTypeTemplate::resetStyles2( xDiagram
);
157 std::vector
< rtl::Reference
< ::chart::DataSeries
> > aSeriesVec(
158 xDiagram
->getDataSeries());
159 uno::Any
aLineStyleAny( drawing::LineStyle_NONE
);
160 for (auto const& series
: aSeriesVec
)
162 if( series
->getPropertyValue( u
"BorderStyle"_ustr
) == aLineStyleAny
)
164 series
->setPropertyToDefault( u
"BorderStyle"_ustr
);
169 rtl::Reference
< ChartType
> AreaChartTypeTemplate::getChartTypeForIndex( sal_Int32
/*nChartTypeIndex*/ )
171 return new AreaChartType();
174 rtl::Reference
< ChartType
> AreaChartTypeTemplate::getChartTypeForNewSeries2(
175 const std::vector
< rtl::Reference
< ChartType
> >& aFormerlyUsedChartTypes
)
177 rtl::Reference
< ChartType
> xResult( getChartTypeForIndex( 0 ) );
178 ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes
, xResult
);
182 IMPLEMENT_FORWARD_XINTERFACE2( AreaChartTypeTemplate
, ChartTypeTemplate
, OPropertySet
)
183 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AreaChartTypeTemplate
, ChartTypeTemplate
, OPropertySet
)
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */