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: LineChartType.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 "LineChartType.hxx"
34 #include "PropertyHelper.hxx"
36 #include "servicenames_charttypes.hxx"
37 #include "ContainerHelper.hxx"
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/chart2/CurveStyle.hpp>
41 using namespace ::com::sun::star
;
43 using ::rtl::OUString
;
44 using ::com::sun::star::beans::Property
;
45 using ::com::sun::star::uno::Sequence
;
46 using ::com::sun::star::uno::Reference
;
47 using ::com::sun::star::uno::Any
;
48 using ::osl::MutexGuard
;
55 PROP_LINECHARTTYPE_CURVE_STYLE
,
56 PROP_LINECHARTTYPE_CURVE_RESOLUTION
,
57 PROP_LINECHARTTYPE_SPLINE_ORDER
60 void lcl_AddPropertiesToVector(
61 ::std::vector
< Property
> & rOutProperties
)
63 rOutProperties
.push_back(
64 Property( C2U( "CurveStyle" ),
65 PROP_LINECHARTTYPE_CURVE_STYLE
,
66 ::getCppuType( reinterpret_cast< const chart2::CurveStyle
* >(0)),
67 beans::PropertyAttribute::BOUND
68 | beans::PropertyAttribute::MAYBEDEFAULT
));
70 rOutProperties
.push_back(
71 Property( C2U( "CurveResolution" ),
72 PROP_LINECHARTTYPE_CURVE_RESOLUTION
,
73 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
74 beans::PropertyAttribute::BOUND
75 | beans::PropertyAttribute::MAYBEDEFAULT
));
76 rOutProperties
.push_back(
77 Property( C2U( "SplineOrder" ),
78 PROP_LINECHARTTYPE_SPLINE_ORDER
,
79 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
80 beans::PropertyAttribute::BOUND
81 | beans::PropertyAttribute::MAYBEDEFAULT
));
84 void lcl_AddDefaultsToMap(
85 ::chart::tPropertyValueMap
& rOutMap
)
87 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_LINECHARTTYPE_CURVE_STYLE
, ::chart2::CurveStyle_LINES
);
88 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_LINECHARTTYPE_CURVE_RESOLUTION
, 20 );
90 // todo: check whether order 3 means polygons of order 3 or 2. (see
91 // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
92 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_LINECHARTTYPE_SPLINE_ORDER
, 3 );
95 const Sequence
< Property
> & lcl_GetPropertySequence()
97 static Sequence
< Property
> aPropSeq
;
100 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
101 if( 0 == aPropSeq
.getLength() )
104 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
105 lcl_AddPropertiesToVector( aProperties
);
107 // and sort them for access via bsearch
108 ::std::sort( aProperties
.begin(), aProperties
.end(),
109 ::chart::PropertyNameLess() );
111 // transfer result to static Sequence
112 aPropSeq
= ::chart::ContainerHelper::ContainerToSequence( aProperties
);
118 } // anonymous namespace
123 LineChartType::LineChartType(
124 const uno::Reference
< uno::XComponentContext
> & xContext
) :
125 ChartType( xContext
)
129 LineChartType::LineChartType( const LineChartType
& rOther
) :
134 LineChartType::~LineChartType()
137 // ____ XCloneable ____
138 uno::Reference
< util::XCloneable
> SAL_CALL
LineChartType::createClone()
139 throw (uno::RuntimeException
)
141 return uno::Reference
< util::XCloneable
>( new LineChartType( *this ));
144 // ____ XChartType ____
145 ::rtl::OUString SAL_CALL
LineChartType::getChartType()
146 throw (uno::RuntimeException
)
148 return CHART2_SERVICE_NAME_CHARTTYPE_LINE
;
152 // ____ OPropertySet ____
153 uno::Any
LineChartType::GetDefaultValue( sal_Int32 nHandle
) const
154 throw(beans::UnknownPropertyException
)
156 static tPropertyValueMap aStaticDefaults
;
159 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
160 if( 0 == aStaticDefaults
.size() )
162 // initialize defaults
163 lcl_AddDefaultsToMap( aStaticDefaults
);
166 tPropertyValueMap::const_iterator
aFound(
167 aStaticDefaults
.find( nHandle
));
169 if( aFound
== aStaticDefaults
.end())
172 return (*aFound
).second
;
176 ::cppu::IPropertyArrayHelper
& SAL_CALL
LineChartType::getInfoHelper()
178 static ::cppu::OPropertyArrayHelper
aArrayHelper( lcl_GetPropertySequence(),
179 /* bSorted = */ sal_True
);
185 // ____ XPropertySet ____
186 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
187 LineChartType::getPropertySetInfo()
188 throw (uno::RuntimeException
)
190 static uno::Reference
< beans::XPropertySetInfo
> xInfo
;
193 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
196 xInfo
= ::cppu::OPropertySetHelper::createPropertySetInfo(
204 uno::Sequence
< ::rtl::OUString
> LineChartType::getSupportedServiceNames_Static()
206 uno::Sequence
< ::rtl::OUString
> aServices( 3 );
207 aServices
[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_LINE
;
208 aServices
[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
209 aServices
[ 2 ] = C2U( "com.sun.star.beans.PropertySet" );
213 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
214 APPHELPER_XSERVICEINFO_IMPL( LineChartType
,
215 C2U( "com.sun.star.comp.chart.LineChartType" ));