2003-12-11 06:52:55 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 16:06:15 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-12-11 06:52:55 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2003-12-11 06:52:55 -06:00
|
|
|
*
|
2008-04-10 16:06:15 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-12-11 06:52:55 -06:00
|
|
|
*
|
2008-04-10 16:06:15 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-12-11 06:52:55 -06:00
|
|
|
*
|
2008-04-10 16:06:15 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-12-11 06:52:55 -06:00
|
|
|
*
|
2008-04-10 16:06:15 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-12-11 06:52:55 -06:00
|
|
|
*
|
2008-04-10 16:06:15 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-12-11 06:52:55 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 07:24:00 -05:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_chart2.hxx"
|
2003-12-11 06:52:55 -06:00
|
|
|
#include "ErrorBar.hxx"
|
|
|
|
#include "macros.hxx"
|
|
|
|
#include "LineProperties.hxx"
|
2007-05-22 12:58:26 -05:00
|
|
|
#include "ContainerHelper.hxx"
|
2008-03-06 10:40:04 -06:00
|
|
|
#include "EventListenerHelper.hxx"
|
2003-12-11 06:52:55 -06:00
|
|
|
#include "PropertyHelper.hxx"
|
2008-03-06 10:40:04 -06:00
|
|
|
#include "CloneHelper.hxx"
|
|
|
|
|
2003-12-11 06:52:55 -06:00
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
2008-03-06 10:40:04 -06:00
|
|
|
#include <com/sun/star/chart/ErrorBarStyle.hpp>
|
2003-12-11 06:52:55 -06:00
|
|
|
|
|
|
|
#include <rtl/math.hxx>
|
|
|
|
#include <rtl/ustrbuf.hxx>
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
using ::rtl::OUString;
|
|
|
|
using ::rtl::OUStringBuffer;
|
|
|
|
using ::com::sun::star::beans::Property;
|
|
|
|
using ::osl::MutexGuard;
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
static const OUString lcl_aServiceName(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.ErrorBar" ));
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_ERROR_BAR_STYLE,
|
|
|
|
PROP_ERROR_BAR_POS_ERROR,
|
|
|
|
PROP_ERROR_BAR_NEG_ERROR,
|
|
|
|
PROP_ERROR_BAR_WEIGHT,
|
|
|
|
PROP_ERROR_BAR_SHOW_POS_ERROR,
|
|
|
|
PROP_ERROR_BAR_SHOW_NEG_ERROR
|
|
|
|
};
|
|
|
|
|
|
|
|
void lcl_AddPropertiesToVector(
|
|
|
|
::std::vector< Property > & rOutProperties )
|
|
|
|
{
|
|
|
|
rOutProperties.push_back(
|
|
|
|
Property( C2U( "ErrorBarStyle" ),
|
|
|
|
PROP_ERROR_BAR_STYLE,
|
2008-03-06 10:40:04 -06:00
|
|
|
::getCppuType( reinterpret_cast< sal_Int32 * >(0)),
|
2003-12-11 06:52:55 -06:00
|
|
|
beans::PropertyAttribute::BOUND
|
|
|
|
| beans::PropertyAttribute::MAYBEDEFAULT ));
|
|
|
|
|
|
|
|
rOutProperties.push_back(
|
|
|
|
Property( C2U( "PositiveError" ),
|
|
|
|
PROP_ERROR_BAR_POS_ERROR,
|
|
|
|
::getCppuType( reinterpret_cast< const double * >(0)),
|
|
|
|
beans::PropertyAttribute::BOUND
|
|
|
|
| beans::PropertyAttribute::MAYBEDEFAULT ));
|
|
|
|
rOutProperties.push_back(
|
|
|
|
Property( C2U( "NegativeError" ),
|
|
|
|
PROP_ERROR_BAR_NEG_ERROR,
|
|
|
|
::getCppuType( reinterpret_cast< const double * >(0)),
|
|
|
|
beans::PropertyAttribute::BOUND
|
|
|
|
| beans::PropertyAttribute::MAYBEDEFAULT ));
|
|
|
|
|
|
|
|
rOutProperties.push_back(
|
|
|
|
Property( C2U( "Weight" ),
|
|
|
|
PROP_ERROR_BAR_WEIGHT,
|
|
|
|
::getCppuType( reinterpret_cast< const double * >(0)),
|
|
|
|
beans::PropertyAttribute::BOUND
|
|
|
|
| beans::PropertyAttribute::MAYBEDEFAULT ));
|
|
|
|
|
|
|
|
rOutProperties.push_back(
|
|
|
|
Property( C2U( "ShowPositiveError" ),
|
|
|
|
PROP_ERROR_BAR_SHOW_POS_ERROR,
|
|
|
|
::getBooleanCppuType(),
|
|
|
|
beans::PropertyAttribute::BOUND
|
|
|
|
| beans::PropertyAttribute::MAYBEDEFAULT ));
|
|
|
|
rOutProperties.push_back(
|
|
|
|
Property( C2U( "ShowNegativeError" ),
|
|
|
|
PROP_ERROR_BAR_SHOW_NEG_ERROR,
|
|
|
|
::getBooleanCppuType(),
|
|
|
|
beans::PropertyAttribute::BOUND
|
|
|
|
| beans::PropertyAttribute::MAYBEDEFAULT ));
|
|
|
|
}
|
|
|
|
|
2010-10-07 09:21:04 -05:00
|
|
|
struct StaticErrorBarDefaults_Initializer
|
2003-12-11 06:52:55 -06:00
|
|
|
{
|
2010-10-07 09:21:04 -05:00
|
|
|
::chart::tPropertyValueMap* operator()()
|
|
|
|
{
|
|
|
|
static ::chart::tPropertyValueMap aStaticDefaults;
|
|
|
|
lcl_AddDefaultsToMap( aStaticDefaults );
|
|
|
|
return &aStaticDefaults;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
|
|
|
|
{
|
|
|
|
::chart::LineProperties::AddDefaultsToMap( rOutMap );
|
|
|
|
|
|
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_ERROR_BAR_STYLE, ::com::sun::star::chart::ErrorBarStyle::NONE );
|
|
|
|
::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_ERROR_BAR_POS_ERROR, 0.0 );
|
|
|
|
::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_ERROR_BAR_NEG_ERROR, 0.0 );
|
|
|
|
::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_ERROR_BAR_WEIGHT, 1.0 );
|
|
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_ERROR_BAR_SHOW_POS_ERROR, true );
|
|
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_ERROR_BAR_SHOW_NEG_ERROR, true );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StaticErrorBarDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticErrorBarDefaults_Initializer >
|
|
|
|
{
|
|
|
|
};
|
2003-12-11 06:52:55 -06:00
|
|
|
|
2010-10-05 04:10:54 -05:00
|
|
|
struct StaticErrorBarInfoHelper_Initializer
|
2003-12-11 06:52:55 -06:00
|
|
|
{
|
2010-10-05 04:10:54 -05:00
|
|
|
::cppu::OPropertyArrayHelper* operator()()
|
|
|
|
{
|
|
|
|
static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
|
|
|
|
return &aPropHelper;
|
|
|
|
}
|
2003-12-11 06:52:55 -06:00
|
|
|
|
2010-10-05 04:10:54 -05:00
|
|
|
private:
|
|
|
|
uno::Sequence< Property > lcl_GetPropertySequence()
|
2003-12-11 06:52:55 -06:00
|
|
|
{
|
|
|
|
::std::vector< ::com::sun::star::beans::Property > aProperties;
|
|
|
|
lcl_AddPropertiesToVector( aProperties );
|
2007-05-22 12:58:26 -05:00
|
|
|
::chart::LineProperties::AddPropertiesToVector( aProperties );
|
2003-12-11 06:52:55 -06:00
|
|
|
|
|
|
|
::std::sort( aProperties.begin(), aProperties.end(),
|
2007-05-22 12:58:26 -05:00
|
|
|
::chart::PropertyNameLess() );
|
2003-12-11 06:52:55 -06:00
|
|
|
|
2010-10-05 04:10:54 -05:00
|
|
|
return ::chart::ContainerHelper::ContainerToSequence( aProperties );
|
2003-12-11 06:52:55 -06:00
|
|
|
}
|
|
|
|
|
2010-10-05 04:10:54 -05:00
|
|
|
};
|
2003-12-11 06:52:55 -06:00
|
|
|
|
2010-10-05 04:10:54 -05:00
|
|
|
struct StaticErrorBarInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticErrorBarInfoHelper_Initializer >
|
2003-12-11 06:52:55 -06:00
|
|
|
{
|
2010-10-05 04:10:54 -05:00
|
|
|
};
|
2003-12-11 06:52:55 -06:00
|
|
|
|
2010-10-06 06:53:07 -05:00
|
|
|
struct StaticErrorBarInfo_Initializer
|
|
|
|
{
|
|
|
|
uno::Reference< beans::XPropertySetInfo >* operator()()
|
|
|
|
{
|
|
|
|
static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
|
|
|
|
::cppu::OPropertySetHelper::createPropertySetInfo(*StaticErrorBarInfoHelper::get() ) );
|
|
|
|
return &xPropertySetInfo;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StaticErrorBarInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticErrorBarInfo_Initializer >
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2008-03-06 10:40:04 -06:00
|
|
|
bool lcl_isInternalData( const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq )
|
|
|
|
{
|
|
|
|
uno::Reference< lang::XServiceInfo > xServiceInfo( xLSeq, uno::UNO_QUERY );
|
|
|
|
return ( xServiceInfo.is() && xServiceInfo->getImplementationName().equalsAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM("com.sun.star.comp.chart2.LabeledDataSequence")));
|
|
|
|
}
|
|
|
|
|
2003-12-11 06:52:55 -06:00
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
namespace chart
|
|
|
|
{
|
|
|
|
|
2009-06-04 04:41:18 -05:00
|
|
|
uno::Reference< beans::XPropertySet > createErrorBar( const uno::Reference< uno::XComponentContext > & xContext )
|
|
|
|
{
|
|
|
|
return new ErrorBar( xContext );
|
|
|
|
}
|
|
|
|
|
2003-12-11 06:52:55 -06:00
|
|
|
ErrorBar::ErrorBar(
|
|
|
|
uno::Reference< uno::XComponentContext > const & xContext ) :
|
|
|
|
::property::OPropertySet( m_aMutex ),
|
2007-05-22 12:58:26 -05:00
|
|
|
m_xContext( xContext ),
|
2009-06-04 04:41:18 -05:00
|
|
|
m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
|
2007-05-22 12:58:26 -05:00
|
|
|
{}
|
|
|
|
|
|
|
|
ErrorBar::ErrorBar( const ErrorBar & rOther ) :
|
2007-07-25 02:57:00 -05:00
|
|
|
MutexContainer(),
|
|
|
|
impl::ErrorBar_Base(),
|
2007-05-22 12:58:26 -05:00
|
|
|
::property::OPropertySet( rOther, m_aMutex ),
|
|
|
|
m_xContext( rOther.m_xContext ),
|
2009-06-04 04:41:18 -05:00
|
|
|
m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
|
2008-03-06 10:40:04 -06:00
|
|
|
{
|
|
|
|
if( ! rOther.m_aDataSequences.empty())
|
|
|
|
{
|
|
|
|
if( lcl_isInternalData( rOther.m_aDataSequences.front()))
|
|
|
|
CloneHelper::CloneRefVector< tDataSequenceContainer::value_type >(
|
|
|
|
rOther.m_aDataSequences, m_aDataSequences );
|
|
|
|
else
|
|
|
|
m_aDataSequences = rOther.m_aDataSequences;
|
|
|
|
ModifyListenerHelper::addListenerToAllElements( m_aDataSequences, m_xModifyEventForwarder );
|
|
|
|
}
|
|
|
|
}
|
2003-12-11 06:52:55 -06:00
|
|
|
|
|
|
|
ErrorBar::~ErrorBar()
|
|
|
|
{}
|
|
|
|
|
2007-05-22 12:58:26 -05:00
|
|
|
uno::Reference< util::XCloneable > SAL_CALL ErrorBar::createClone()
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return uno::Reference< util::XCloneable >( new ErrorBar( *this ));
|
|
|
|
}
|
|
|
|
|
2003-12-11 06:52:55 -06:00
|
|
|
// ================================================================================
|
|
|
|
|
|
|
|
// ____ OPropertySet ____
|
|
|
|
uno::Any ErrorBar::GetDefaultValue( sal_Int32 nHandle ) const
|
|
|
|
throw(beans::UnknownPropertyException)
|
|
|
|
{
|
2010-10-07 09:21:04 -05:00
|
|
|
const tPropertyValueMap& rStaticDefaults = *StaticErrorBarDefaults::get();
|
|
|
|
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
|
|
|
|
if( aFound == rStaticDefaults.end() )
|
2003-12-11 06:52:55 -06:00
|
|
|
return uno::Any();
|
|
|
|
return (*aFound).second;
|
|
|
|
}
|
|
|
|
|
|
|
|
::cppu::IPropertyArrayHelper & SAL_CALL ErrorBar::getInfoHelper()
|
|
|
|
{
|
2010-10-05 04:10:54 -05:00
|
|
|
return *StaticErrorBarInfoHelper::get();
|
2003-12-11 06:52:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// ____ XPropertySet ____
|
2010-10-06 06:53:07 -05:00
|
|
|
uno::Reference< beans::XPropertySetInfo > SAL_CALL ErrorBar::getPropertySetInfo()
|
2003-12-11 06:52:55 -06:00
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
2010-10-06 06:53:07 -05:00
|
|
|
return *StaticErrorBarInfo::get();
|
2003-12-11 06:52:55 -06:00
|
|
|
}
|
|
|
|
|
2007-05-22 12:58:26 -05:00
|
|
|
// ____ XModifyBroadcaster ____
|
|
|
|
void SAL_CALL ErrorBar::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
|
|
|
|
xBroadcaster->addModifyListener( aListener );
|
|
|
|
}
|
|
|
|
catch( const uno::Exception & ex )
|
|
|
|
{
|
|
|
|
ASSERT_EXCEPTION( ex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ErrorBar::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
|
|
|
|
xBroadcaster->removeModifyListener( aListener );
|
|
|
|
}
|
|
|
|
catch( const uno::Exception & ex )
|
|
|
|
{
|
|
|
|
ASSERT_EXCEPTION( ex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ____ XModifyListener ____
|
|
|
|
void SAL_CALL ErrorBar::modified( const lang::EventObject& aEvent )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
m_xModifyEventForwarder->modified( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ____ XEventListener (base of XModifyListener) ____
|
2007-07-25 02:57:00 -05:00
|
|
|
void SAL_CALL ErrorBar::disposing( const lang::EventObject& /* Source */ )
|
2007-05-22 12:58:26 -05:00
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
// nothing
|
|
|
|
}
|
|
|
|
|
2008-03-06 10:40:04 -06:00
|
|
|
// ____ XDataSink ____
|
|
|
|
void SAL_CALL ErrorBar::setData( const uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > >& aData )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
ModifyListenerHelper::removeListenerFromAllElements( m_aDataSequences, m_xModifyEventForwarder );
|
|
|
|
EventListenerHelper::removeListenerFromAllElements( m_aDataSequences, this );
|
|
|
|
m_aDataSequences = ContainerHelper::SequenceToVector( aData );
|
|
|
|
EventListenerHelper::addListenerToAllElements( m_aDataSequences, this );
|
|
|
|
ModifyListenerHelper::addListenerToAllElements( m_aDataSequences, m_xModifyEventForwarder );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ____ XDataSource ____
|
|
|
|
uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ErrorBar::getDataSequences()
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return ContainerHelper::ContainerToSequence( m_aDataSequences );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ____ XChild ____
|
|
|
|
uno::Reference< uno::XInterface > SAL_CALL ErrorBar::getParent()
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return m_xParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL ErrorBar::setParent(
|
|
|
|
const uno::Reference< uno::XInterface >& Parent )
|
|
|
|
throw (lang::NoSupportException,
|
|
|
|
uno::RuntimeException)
|
|
|
|
{
|
|
|
|
m_xParent.set( Parent );
|
|
|
|
}
|
|
|
|
|
2007-05-22 12:58:26 -05:00
|
|
|
// ____ OPropertySet ____
|
|
|
|
void ErrorBar::firePropertyChangeEvent()
|
|
|
|
{
|
|
|
|
fireModifyEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ErrorBar::fireModifyEvent()
|
|
|
|
{
|
|
|
|
m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
|
|
|
|
}
|
|
|
|
|
2003-12-11 06:52:55 -06:00
|
|
|
// ================================================================================
|
|
|
|
|
|
|
|
uno::Sequence< ::rtl::OUString > ErrorBar::getSupportedServiceNames_Static()
|
|
|
|
{
|
|
|
|
uno::Sequence< ::rtl::OUString > aServices( 2 );
|
|
|
|
aServices[ 0 ] = lcl_aServiceName;
|
2004-01-26 02:13:31 -06:00
|
|
|
aServices[ 1 ] = C2U( "com.sun.star.chart2.ErrorBar" );
|
2003-12-11 06:52:55 -06:00
|
|
|
return aServices;
|
|
|
|
}
|
|
|
|
|
|
|
|
// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
|
|
|
|
APPHELPER_XSERVICEINFO_IMPL( ErrorBar, lcl_aServiceName );
|
|
|
|
|
|
|
|
// needed by MSC compiler
|
|
|
|
using impl::ErrorBar_Base;
|
|
|
|
|
|
|
|
IMPLEMENT_FORWARD_XINTERFACE2( ErrorBar, ErrorBar_Base, OPropertySet )
|
|
|
|
IMPLEMENT_FORWARD_XTYPEPROVIDER2( ErrorBar, ErrorBar_Base, OPropertySet )
|
|
|
|
|
|
|
|
} // namespace chart
|