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"
22 #include "servicenames_charttypes.hxx"
23 #include "DiagramHelper.hxx"
24 #include "DataSeriesHelper.hxx"
25 #include "ContainerHelper.hxx"
26 #include "PropertyHelper.hxx"
27 #include <com/sun/star/beans/PropertyAttribute.hpp>
28 #include <com/sun/star/drawing/LineStyle.hpp>
32 using namespace ::com::sun::star
;
34 using ::com::sun::star::beans::Property
;
35 using ::com::sun::star::uno::Sequence
;
36 using ::com::sun::star::uno::Reference
;
37 using ::com::sun::star::uno::Any
;
38 using ::osl::MutexGuard
;
45 PROP_AREA_TEMPLATE_DIMENSION
48 void lcl_AddPropertiesToVector(
49 ::std::vector
< Property
> & rOutProperties
)
51 rOutProperties
.push_back(
52 Property( "Dimension",
53 PROP_AREA_TEMPLATE_DIMENSION
,
54 cppu::UnoType
<sal_Int32
>::get(),
55 beans::PropertyAttribute::BOUND
56 | beans::PropertyAttribute::MAYBEDEFAULT
));
59 struct StaticAreaChartTypeTemplateDefaults_Initializer
61 ::chart::tPropertyValueMap
* operator()()
63 static ::chart::tPropertyValueMap aStaticDefaults
;
64 lcl_AddDefaultsToMap( aStaticDefaults
);
65 return &aStaticDefaults
;
68 static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap
& rOutMap
)
70 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_AREA_TEMPLATE_DIMENSION
, 2 );
74 struct StaticAreaChartTypeTemplateDefaults
: public rtl::StaticAggregate
< ::chart::tPropertyValueMap
, StaticAreaChartTypeTemplateDefaults_Initializer
>
78 struct StaticAreaChartTypeTemplateInfoHelper_Initializer
80 ::cppu::OPropertyArrayHelper
* operator()()
82 static ::cppu::OPropertyArrayHelper
aPropHelper( lcl_GetPropertySequence() );
87 static uno::Sequence
< Property
> lcl_GetPropertySequence()
89 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
90 lcl_AddPropertiesToVector( aProperties
);
92 ::std::sort( aProperties
.begin(), aProperties
.end(),
93 ::chart::PropertyNameLess() );
95 return ::chart::ContainerHelper::ContainerToSequence( aProperties
);
100 struct StaticAreaChartTypeTemplateInfoHelper
: public rtl::StaticAggregate
< ::cppu::OPropertyArrayHelper
, StaticAreaChartTypeTemplateInfoHelper_Initializer
>
104 struct StaticAreaChartTypeTemplateInfo_Initializer
106 uno::Reference
< beans::XPropertySetInfo
>* operator()()
108 static uno::Reference
< beans::XPropertySetInfo
> xPropertySetInfo(
109 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAreaChartTypeTemplateInfoHelper::get() ) );
110 return &xPropertySetInfo
;
114 struct StaticAreaChartTypeTemplateInfo
: public rtl::StaticAggregate
< uno::Reference
< beans::XPropertySetInfo
>, StaticAreaChartTypeTemplateInfo_Initializer
>
118 } // anonymous namespace
123 AreaChartTypeTemplate::AreaChartTypeTemplate(
125 uno::XComponentContext
> const & xContext
,
126 const OUString
& rServiceName
,
127 StackMode eStackMode
,
128 sal_Int32 nDim
/* = 2 */ ) :
129 ChartTypeTemplate( xContext
, rServiceName
),
130 ::property::OPropertySet( m_aMutex
),
131 m_eStackMode( eStackMode
)
133 setFastPropertyValue_NoBroadcast( PROP_AREA_TEMPLATE_DIMENSION
, uno::makeAny( nDim
));
136 AreaChartTypeTemplate::~AreaChartTypeTemplate()
139 // ____ OPropertySet ____
140 uno::Any
AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle
) const
141 throw(beans::UnknownPropertyException
)
143 const tPropertyValueMap
& rStaticDefaults
= *StaticAreaChartTypeTemplateDefaults::get();
144 tPropertyValueMap::const_iterator
aFound( rStaticDefaults
.find( nHandle
) );
145 if( aFound
== rStaticDefaults
.end() )
147 return (*aFound
).second
;
150 ::cppu::IPropertyArrayHelper
& SAL_CALL
AreaChartTypeTemplate::getInfoHelper()
152 return *StaticAreaChartTypeTemplateInfoHelper::get();
155 // ____ XPropertySet ____
156 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
AreaChartTypeTemplate::getPropertySetInfo()
157 throw (uno::RuntimeException
, std::exception
)
159 return *StaticAreaChartTypeTemplateInfo::get();
162 sal_Int32
AreaChartTypeTemplate::getDimension() const
167 // note: UNO-methods are never const
168 const_cast< AreaChartTypeTemplate
* >( this )->
169 getFastPropertyValue( PROP_AREA_TEMPLATE_DIMENSION
) >>= nDim
;
171 catch( const beans::UnknownPropertyException
& ex
)
173 ASSERT_EXCEPTION( ex
);
179 StackMode
AreaChartTypeTemplate::getStackMode( sal_Int32
/* nChartTypeIndex */ ) const
184 // ____ XChartTypeTemplate ____
185 void SAL_CALL
AreaChartTypeTemplate::applyStyle(
186 const Reference
< chart2::XDataSeries
>& xSeries
,
187 ::sal_Int32 nChartTypeIndex
,
188 ::sal_Int32 nSeriesIndex
,
189 ::sal_Int32 nSeriesCount
)
190 throw (uno::RuntimeException
, std::exception
)
192 ChartTypeTemplate::applyStyle( xSeries
, nChartTypeIndex
, nSeriesIndex
, nSeriesCount
);
193 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries
, "BorderStyle", uno::makeAny( drawing::LineStyle_NONE
) );
196 void SAL_CALL
AreaChartTypeTemplate::resetStyles( const Reference
< chart2::XDiagram
>& xDiagram
)
197 throw (uno::RuntimeException
, std::exception
)
199 ChartTypeTemplate::resetStyles( xDiagram
);
200 ::std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVec(
201 DiagramHelper::getDataSeriesFromDiagram( xDiagram
));
202 uno::Any
aLineStyleAny( uno::makeAny( drawing::LineStyle_NONE
));
203 for( ::std::vector
< Reference
< chart2::XDataSeries
> >::iterator
aIt( aSeriesVec
.begin());
204 aIt
!= aSeriesVec
.end(); ++aIt
)
206 Reference
< beans::XPropertyState
> xState( *aIt
, uno::UNO_QUERY
);
207 Reference
< beans::XPropertySet
> xProp( *aIt
, uno::UNO_QUERY
);
210 xProp
->getPropertyValue( "BorderStyle") == aLineStyleAny
)
212 xState
->setPropertyToDefault( "BorderStyle");
217 Reference
< chart2::XChartType
> AreaChartTypeTemplate::getChartTypeForIndex( sal_Int32
/*nChartTypeIndex*/ )
219 Reference
< chart2::XChartType
> xResult
;
223 Reference
< lang::XMultiServiceFactory
> xFact(
224 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW
);
225 xResult
.set( xFact
->createInstance(
226 CHART2_SERVICE_NAME_CHARTTYPE_AREA
), uno::UNO_QUERY_THROW
);
228 catch( const uno::Exception
& ex
)
230 ASSERT_EXCEPTION( ex
);
236 Reference
< chart2::XChartType
> SAL_CALL
AreaChartTypeTemplate::getChartTypeForNewSeries(
237 const uno::Sequence
< Reference
< chart2::XChartType
> >& aFormerlyUsedChartTypes
)
238 throw (uno::RuntimeException
, std::exception
)
240 Reference
< chart2::XChartType
> xResult( getChartTypeForIndex( 0 ) );
241 ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes
, xResult
);
245 IMPLEMENT_FORWARD_XINTERFACE2( AreaChartTypeTemplate
, ChartTypeTemplate
, OPropertySet
)
246 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AreaChartTypeTemplate
, ChartTypeTemplate
, OPropertySet
)
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */