summaryrefslogtreecommitdiff
path: root/chart2/source/model/template/AreaChartTypeTemplate.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/model/template/AreaChartTypeTemplate.cxx')
-rw-r--r--chart2/source/model/template/AreaChartTypeTemplate.cxx181
1 files changed, 171 insertions, 10 deletions
diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx b/chart2/source/model/template/AreaChartTypeTemplate.cxx
index d84b17d09731..cca9d6f88728 100644
--- a/chart2/source/model/template/AreaChartTypeTemplate.cxx
+++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: AreaChartTypeTemplate.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $
+ * last change: $Author: bm $ $Date: 2003-11-04 12:37:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,29 +60,175 @@
************************************************************************/
#include "AreaChartTypeTemplate.hxx"
#include "AreaChartType.hxx"
+#include "macros.hxx"
+#include "algohelper.hxx"
+
+#ifndef CHART_PROPERTYHELPER_HXX
+#include "PropertyHelper.hxx"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+
+#include <algorithm>
using namespace ::com::sun::star;
using namespace ::drafts::com::sun::star;
+using ::rtl::OUString;
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+using ::osl::MutexGuard;
+
+namespace
+{
+
+static const ::rtl::OUString lcl_aServiceName(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.AreaChartTypeTemplate" ));
+
+enum
+{
+ PROP_AREA_TEMPLATE_DIMENSION
+};
+
+void lcl_AddPropertiesToVector(
+ ::std::vector< Property > & rOutProperties )
+{
+ rOutProperties.push_back(
+ Property( C2U( "Dimension" ),
+ PROP_AREA_TEMPLATE_DIMENSION,
+ ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+}
+
+void lcl_AddDefaultsToMap(
+ ::chart::helper::tPropertyValueMap & rOutMap )
+{
+ OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_AREA_TEMPLATE_DIMENSION ));
+ rOutMap[ PROP_AREA_TEMPLATE_DIMENSION ] =
+ uno::makeAny( sal_Int32( 2 ) );
+}
+
+const uno::Sequence< Property > & lcl_GetPropertySequence()
+{
+ static uno::Sequence< Property > aPropSeq;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aPropSeq.getLength() )
+ {
+ // get properties
+ ::std::vector< ::com::sun::star::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+
+ // and sort them for access via bsearch
+ ::std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::helper::PropertyNameLess() );
+
+ // transfer result to static Sequence
+ aPropSeq = ::chart::helper::VectorToSequence( aProperties );
+ }
+
+ return aPropSeq;
+}
+
+::cppu::IPropertyArrayHelper & lcl_getInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aArrayHelper(
+ lcl_GetPropertySequence(),
+ /* bSorted = */ sal_True );
+
+ return aArrayHelper;
+}
+
+} // anonymous namespace
+
namespace chart
{
AreaChartTypeTemplate::AreaChartTypeTemplate(
uno::Reference<
uno::XComponentContext > const & xContext,
+ const ::rtl::OUString & rServiceName,
chart2::StackMode eStackMode,
sal_Int32 nDim /* = 2 */ ) :
- ChartTypeTemplate( xContext ),
- m_eStackMode( eStackMode ),
- m_nDim( nDim )
-{}
+ ChartTypeTemplate( xContext, rServiceName ),
+ ::property::OPropertySet( m_aMutex ),
+ m_eStackMode( eStackMode )
+{
+ setFastPropertyValue_NoBroadcast( PROP_AREA_TEMPLATE_DIMENSION, uno::makeAny( nDim ));
+}
AreaChartTypeTemplate::~AreaChartTypeTemplate()
{}
+// ____ OPropertySet ____
+uno::Any AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+ throw(beans::UnknownPropertyException)
+{
+ static helper::tPropertyValueMap aStaticDefaults;
+
+ // /--
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aStaticDefaults.size() )
+ {
+ // initialize defaults
+ lcl_AddDefaultsToMap( aStaticDefaults );
+ }
+
+ helper::tPropertyValueMap::const_iterator aFound(
+ aStaticDefaults.find( nHandle ));
+
+ if( aFound == aStaticDefaults.end())
+ return uno::Any();
+
+ return (*aFound).second;
+ // \--
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL AreaChartTypeTemplate::getInfoHelper()
+{
+ return lcl_getInfoHelper();
+}
+
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL
+ AreaChartTypeTemplate::getPropertySetInfo()
+ throw (uno::RuntimeException)
+{
+ static uno::Reference< beans::XPropertySetInfo > xInfo;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !xInfo.is())
+ {
+ xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
+ getInfoHelper());
+ }
+
+ return xInfo;
+ // \--
+}
+
sal_Int32 AreaChartTypeTemplate::getDimension() const
{
- return m_nDim;
+ sal_Int32 nDim = 2;
+ try
+ {
+ // note: UNO-methods are never const
+ const_cast< AreaChartTypeTemplate * >( this )->
+ getFastPropertyValue( PROP_AREA_TEMPLATE_DIMENSION ) >>= nDim;
+ }
+ catch( beans::UnknownPropertyException & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+
+ return nDim;
}
chart2::StackMode AreaChartTypeTemplate::getStackMode() const
@@ -90,11 +236,26 @@ chart2::StackMode AreaChartTypeTemplate::getStackMode() const
return m_eStackMode;
}
-// ____ XChartTypeTemplate ____
-uno::Reference< chart2::XChartType > SAL_CALL AreaChartTypeTemplate::getChartTypeForAdditionalSeries()
+uno::Reference< chart2::XChartType > AreaChartTypeTemplate::getDefaultChartType()
throw (uno::RuntimeException)
{
- return new AreaChartType( m_nDim );
+ return new AreaChartType( getDimension() );
}
+// ----------------------------------------
+
+uno::Sequence< ::rtl::OUString > AreaChartTypeTemplate::getSupportedServiceNames_Static()
+{
+ uno::Sequence< ::rtl::OUString > aServices( 2 );
+ aServices[ 0 ] = lcl_aServiceName;
+ aServices[ 1 ] = C2U( "drafts.com.sun.star.chart2.ChartTypeTemplate" );
+ return aServices;
+}
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+APPHELPER_XSERVICEINFO_IMPL( AreaChartTypeTemplate, lcl_aServiceName );
+
+IMPLEMENT_FORWARD_XINTERFACE2( AreaChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( AreaChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+
} // namespace chart