1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AreaChartType.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "AreaChartType.hxx"
35 #include "servicenames_charttypes.hxx"
36 #include "PropertyHelper.hxx"
37 #include "ContainerHelper.hxx"
39 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 using namespace ::com::sun::star
;
42 using ::com::sun::star::beans::Property
;
43 using ::com::sun::star::uno::Sequence
;
50 PROP_AREACHARTTYPE_STACKED
,
51 PROP_AREACHARTTYPE_PERCENT
54 void lcl_AddPropertiesToVector(
55 ::std::vector
< Property
> & rOutProperties
)
57 rOutProperties
.push_back(
58 Property( C2U( "Stacked" ),
59 PROP_AREACHARTTYPE_STACKED
,
60 ::getBooleanCppuType(),
61 beans::PropertyAttribute::BOUND
62 | beans::PropertyAttribute::MAYBEDEFAULT
));
63 rOutProperties
.push_back(
64 Property( C2U( "Percent" ),
65 PROP_AREACHARTTYPE_PERCENT
,
66 ::getBooleanCppuType(),
67 beans::PropertyAttribute::BOUND
68 | beans::PropertyAttribute::MAYBEDEFAULT
));
71 void lcl_AddDefaultsToMap(
72 ::chart::tPropertyValueMap
& rOutMap
)
74 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_AREACHARTTYPE_STACKED
, false );
75 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_AREACHARTTYPE_PERCENT
, false );
78 const Sequence
< Property
> & lcl_GetPropertySequence()
80 static Sequence
< Property
> aPropSeq
;
83 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
84 if( 0 == aPropSeq
.getLength() )
87 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
88 lcl_AddPropertiesToVector( aProperties
);
90 // and sort them for access via bsearch
91 ::std::sort( aProperties
.begin(), aProperties
.end(),
92 ::chart::PropertyNameLess() );
94 // transfer result to static Sequence
95 aPropSeq
= ::chart::ContainerHelper::ContainerToSequence( aProperties
);
101 } // anonymous namespace
106 AreaChartType::AreaChartType(
107 const uno::Reference
< uno::XComponentContext
> & xContext
) :
108 ChartType( xContext
)
111 AreaChartType::AreaChartType( const AreaChartType
& rOther
) :
115 AreaChartType::~AreaChartType()
118 // ____ XCloneable ____
119 uno::Reference
< util::XCloneable
> SAL_CALL
AreaChartType::createClone()
120 throw (uno::RuntimeException
)
122 return uno::Reference
< util::XCloneable
>( new AreaChartType( *this ));
125 // ____ XChartType ____
126 ::rtl::OUString SAL_CALL
AreaChartType::getChartType()
127 throw (uno::RuntimeException
)
129 return CHART2_SERVICE_NAME_CHARTTYPE_AREA
;
132 // ____ OPropertySet ____
133 uno::Any
AreaChartType::GetDefaultValue( sal_Int32 nHandle
) const
134 throw(beans::UnknownPropertyException
)
136 static tPropertyValueMap aStaticDefaults
;
139 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
140 if( 0 == aStaticDefaults
.size() )
142 // initialize defaults
143 lcl_AddDefaultsToMap( aStaticDefaults
);
146 tPropertyValueMap::const_iterator
aFound(
147 aStaticDefaults
.find( nHandle
));
149 if( aFound
== aStaticDefaults
.end())
152 return (*aFound
).second
;
156 ::cppu::IPropertyArrayHelper
& SAL_CALL
AreaChartType::getInfoHelper()
158 static ::cppu::OPropertyArrayHelper
aArrayHelper( lcl_GetPropertySequence(),
159 /* bSorted = */ sal_True
);
164 // ____ XPropertySet ____
165 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
AreaChartType::getPropertySetInfo()
166 throw (uno::RuntimeException
)
168 static uno::Reference
< beans::XPropertySetInfo
> xInfo
;
171 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
174 xInfo
= ::cppu::OPropertySetHelper::createPropertySetInfo(
182 uno::Sequence
< ::rtl::OUString
> AreaChartType::getSupportedServiceNames_Static()
184 uno::Sequence
< ::rtl::OUString
> aServices( 2 );
185 aServices
[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_AREA
;
186 aServices
[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
190 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
191 APPHELPER_XSERVICEINFO_IMPL( AreaChartType
,
192 C2U( "com.sun.star.comp.chart.AreaChartType" ));