Kaydet (Commit) 4475e4f3 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

more work on getting the error bar export produce valid docs

Change-Id: I19189e6be83dde58b4b3b7b55f40b701818eceed
üst f6bf4933
......@@ -25,7 +25,7 @@
#include "charttoolsdllapi.hxx"
#include "LineProperties.hxx"
#include <cppuhelper/implbase7.hxx>
#include <cppuhelper/implbase8.hxx>
#include <comphelper/uno3.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
......@@ -36,6 +36,7 @@
#include <com/sun/star/chart2/data/XDataSink.hpp>
#include <com/sun/star/chart2/data/XDataSource.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
namespace chart
......@@ -47,14 +48,15 @@ OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::
namespace impl
{
typedef ::cppu::WeakImplHelper7<
typedef ::cppu::WeakImplHelper8<
::com::sun::star::lang::XServiceInfo,
::com::sun::star::util::XCloneable,
::com::sun::star::util::XModifyBroadcaster,
::com::sun::star::util::XModifyListener,
::com::sun::star::chart2::data::XDataSource,
::com::sun::star::chart2::data::XDataSink,
::com::sun::star::beans::XPropertySet >
::com::sun::star::beans::XPropertySet,
::com::sun::star::beans::XPropertyState >
ErrorBar_Base;
}
......@@ -87,18 +89,29 @@ public:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName )
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
// XPropertyState
virtual com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const OUString& rPropName )
throw (com::sun::star::beans::UnknownPropertyException);
virtual com::sun::star::uno::Sequence< com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates(
const com::sun::star::uno::Sequence< OUString >& rPropNames )
throw (com::sun::star::beans::UnknownPropertyException);
virtual void SAL_CALL setPropertyToDefault( const OUString& rPropName )
throw (com::sun::star::beans::UnknownPropertyException);
virtual com::sun::star::uno::Any SAL_CALL getPropertyDefault( const OUString& rPropName )
throw (com::sun::star::beans::UnknownPropertyException, com::sun::star::lang::WrappedTargetException);
protected:
ErrorBar( const ErrorBar & rOther );
......
......@@ -13,12 +13,14 @@
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/util/Color.hpp>
#include <com/sun/star/drawing/LineJoint.hpp>
#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/uno/Any.hxx>
class LineProperties
{
private:
OUString maDashName;
com::sun::star::drawing::LineDash maLineDash;
sal_Int32 mnLineWidth;
com::sun::star::drawing::LineStyle meLineStyle;
com::sun::star::util::Color maLineColor;
......
......@@ -58,14 +58,18 @@ const SfxItemPropertySet* GetErrorBarPropertySet()
{MAP_CHAR_LEN("ShowNegativeError"),1,&getBooleanCppuType(), 0, 0},
{MAP_CHAR_LEN("PositiveError"),2,&getCppuType((const double*)0),0,0},
{MAP_CHAR_LEN("NegativeError"),3,&getCppuType((const double*)0), 0, 0},
{MAP_CHAR_LEN("ErrorBarStyle"),4,&getCppuType((sal_Int32*)0),0,0},
{MAP_CHAR_LEN("Weight"),5,&getCppuType((const double*)0),0,0},
{MAP_CHAR_LEN("LineStyle"),7,&getCppuType((com::sun::star::drawing::LineStyle*)0),0,0},
{MAP_CHAR_LEN("LineDashName"),7,&getCppuType((OUString*)0),0,0},
{MAP_CHAR_LEN("LineWidth"),7,&getCppuType((sal_Int32*)0),0,0},
{MAP_CHAR_LEN("LineColor"),7,&getCppuType((com::sun::star::util::Color*)0),0,0},
{MAP_CHAR_LEN("LineTransparence"),7,&getCppuType((sal_uInt8*)0),0,0},
{MAP_CHAR_LEN("LineJoint"),7,&getCppuType((com::sun::star::drawing::LineJoint*)0),0,0},
{MAP_CHAR_LEN("PercentageError"),4,&getCppuType((const double*)0), 0, 0},
{MAP_CHAR_LEN("ErrorBarStyle"),5,&getCppuType((sal_Int32*)0),0,0},
{MAP_CHAR_LEN("ErrorBarRangePositive"),6,&getCppuType((OUString*)0),0,0}, // read-only for export
{MAP_CHAR_LEN("ErrorBarRangeNegative"),7,&getCppuType((OUString*)0),0,0}, // read-only for export
{MAP_CHAR_LEN("Weight"),8,&getCppuType((const double*)0),0,0},
{MAP_CHAR_LEN("LineStyle"),9,&getCppuType((com::sun::star::drawing::LineStyle*)0),0,0},
{MAP_CHAR_LEN("LineDashName"),10,&getCppuType((OUString*)0),0,0},
{MAP_CHAR_LEN("LineDash"),10,&getCppuType((drawing::LineDash*)0),0,0},
{MAP_CHAR_LEN("LineWidth"),11,&getCppuType((sal_Int32*)0),0,0},
{MAP_CHAR_LEN("LineColor"),12,&getCppuType((com::sun::star::util::Color*)0),0,0},
{MAP_CHAR_LEN("LineTransparence"),13,&getCppuType((sal_uInt8*)0),0,0},
{MAP_CHAR_LEN("LineJoint"),14,&getCppuType((com::sun::star::drawing::LineJoint*)0),0,0},
{0,0,0,0,0,0}
};
static SfxItemPropertySet aPropSet( aErrorBarPropertyMap_Impl );
......@@ -143,18 +147,66 @@ void ErrorBar::setPropertyValue( const OUString& rPropName, const uno::Any& rAny
rAny >>= meStyle;
else if(rPropName == "PositiveError")
rAny >>= mfPositiveError;
else if(rPropName == "PercentageError")
{
rAny >>= mfPositiveError;
rAny >>= mfNegativeError;
}
else if(rPropName == "NegativeError")
rAny >>= mfNegativeError;
else if(rPropName == "ShowPositiveError")
rAny >>= mbShowPositiveError;
else if(rPropName == "ShowNegativeError")
rAny >>= mbShowNegativeError;
else if(rPropName == "ErrorBarRangePositive" || rPropName == "ErrorBarRangeNegative")
throw uno::RuntimeException("read-only property", static_cast< uno::XWeak*>(this));
else
LineProperties::setPropertyValue(rPropName, rAny);
m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
}
namespace {
OUString getSourceRangeStrFromLabeledSequences( uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences, bool bPositive )
{
const OUString aRolePrefix( "error-bars" );
OUString aDirection;
if(bPositive)
aDirection = "positive";
else
aDirection = "negative";
for( sal_Int32 nI=0; nI< aSequences.getLength(); ++nI )
{
try
{
if( aSequences[nI].is())
{
uno::Reference< chart2::data::XDataSequence > xSequence( aSequences[nI]->getValues());
uno::Reference< beans::XPropertySet > xSeqProp( xSequence, uno::UNO_QUERY_THROW );
OUString aRole;
if( ( xSeqProp->getPropertyValue(
OUString( "Role" )) >>= aRole ) &&
aRole.match( aRolePrefix ) && aRole.indexOf(aDirection) >= 0 )
{
return xSequence->getSourceRangeRepresentation();
}
}
}
catch (...)
{
// we can't be sure that this is 100% safe and we don't want to kill the export
// we should at least check why the exception is thrown
SAL_WARN("chart2", "unexpected exception!");
}
}
return OUString();
}
}
uno::Any ErrorBar::getPropertyValue(const OUString& rPropName)
throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
......@@ -165,16 +217,140 @@ uno::Any ErrorBar::getPropertyValue(const OUString& rPropName)
aRet <<= mfPositiveError;
else if(rPropName == "NegativeError")
aRet <<= mfNegativeError;
else if(rPropName == "PercentageError")
aRet <<= mfPositiveError;
else if(rPropName == "ShowPositiveError")
aRet <<= mbShowPositiveError;
else if(rPropName == "ShowNegativeError")
aRet <<= mbShowNegativeError;
else if(rPropName == "ErrorBarRangePositive")
{
OUString aRange;
if(meStyle == com::sun::star::chart::ErrorBarStyle::FROM_DATA)
{
uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences =
getDataSequences();
aRange = getSourceRangeStrFromLabeledSequences( aSequences, true );
}
aRet <<= aRange;
}
else if(rPropName == "ErrorBarRangeNegative")
{
OUString aRange;
if(meStyle == com::sun::star::chart::ErrorBarStyle::FROM_DATA)
{
uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences =
getDataSequences();
aRange = getSourceRangeStrFromLabeledSequences( aSequences, true );
}
aRet <<= aRange;
}
else
aRet = LineProperties::getPropertyValue(rPropName);
SAL_WARN_IF(!aRet.hasValue(), "chart2", "asked for property value: " << rPropName);
return aRet;
}
beans::PropertyState ErrorBar::getPropertyState( const OUString& rPropName )
throw (com::sun::star::beans::UnknownPropertyException)
{
if(rPropName == "ErrorBarStyle")
{
if(meStyle == com::sun::star::chart::ErrorBarStyle::NONE)
return beans::PropertyState_DEFAULT_VALUE;
return beans::PropertyState_DIRECT_VALUE;
}
else if(rPropName == "PositiveError")
{
if(mbShowPositiveError)
{
switch(meStyle)
{
case com::sun::star::chart::ErrorBarStyle::ABSOLUTE:
case com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN:
return beans::PropertyState_DIRECT_VALUE;
default:
break;
}
}
return beans::PropertyState_DEFAULT_VALUE;
}
else if(rPropName == "NegativeError")
{
if(mbShowNegativeError)
{
switch(meStyle)
{
case com::sun::star::chart::ErrorBarStyle::ABSOLUTE:
case com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN:
return beans::PropertyState_DIRECT_VALUE;
default:
break;
}
}
return beans::PropertyState_DEFAULT_VALUE;
}
else if(rPropName == "PercentageError")
{
if(meStyle != com::sun::star::chart::ErrorBarStyle::RELATIVE)
return beans::PropertyState_DEFAULT_VALUE;
return beans::PropertyState_DIRECT_VALUE;
}
else if(rPropName == "ShowPositiveError")
{
// this value should be never default
return beans::PropertyState_DIRECT_VALUE;
}
else if(rPropName == "ShowNegativeError")
{
// this value should be never default
return beans::PropertyState_DIRECT_VALUE;
}
else if(rPropName == "ErrorBarRangePositive")
{
if(meStyle == com::sun::star::chart::ErrorBarStyle::FROM_DATA && mbShowPositiveError)
return beans::PropertyState_DIRECT_VALUE;
return beans::PropertyState_DEFAULT_VALUE;
}
else if(rPropName == "ErrorBarRangeNegative")
{
if(meStyle == com::sun::star::chart::ErrorBarStyle::FROM_DATA && mbShowNegativeError)
return beans::PropertyState_DIRECT_VALUE;
return beans::PropertyState_DEFAULT_VALUE;
}
else
return beans::PropertyState_DIRECT_VALUE;
}
uno::Sequence< beans::PropertyState > ErrorBar::getPropertyStates( const uno::Sequence< OUString >& rPropNames )
throw (com::sun::star::beans::UnknownPropertyException)
{
uno::Sequence< beans::PropertyState > aRet( rPropNames.getLength() );
for(sal_Int32 i = 0; i < rPropNames.getLength(); ++i)
{
aRet[i] = getPropertyState(rPropNames[i]);
}
return aRet;
}
void ErrorBar::setPropertyToDefault( const OUString& )
throw (beans::UnknownPropertyException)
{
//keep them unimplemented for now
}
uno::Any ErrorBar::getPropertyDefault( const OUString& )
throw (beans::UnknownPropertyException, lang::WrappedTargetException)
{
//keep them unimplemented for now
return uno::Any();
}
void ErrorBar::addPropertyChangeListener( const OUString&, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& )
throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
{
......
......@@ -22,6 +22,7 @@ LineProperties::LineProperties():
LineProperties::LineProperties(const LineProperties& r):
maDashName(r.maDashName),
maLineDash(r.maLineDash),
mnLineWidth(r.mnLineWidth),
meLineStyle(r.meLineStyle),
maLineColor(r.maLineColor),
......@@ -33,10 +34,14 @@ LineProperties::LineProperties(const LineProperties& r):
uno::Any LineProperties::getPropertyValue(const OUString& rName)
{
uno::Any aRet;
if(rName == "DashName")
if(rName == "LineDashName")
{
aRet <<= maDashName;
}
else if(rName == "LineDash")
{
aRet <<= maLineDash;
}
else if(rName == "LineWidth")
{
aRet <<= mnLineWidth;
......@@ -62,10 +67,14 @@ uno::Any LineProperties::getPropertyValue(const OUString& rName)
void LineProperties::setPropertyValue(const OUString& rName, const uno::Any& rAny)
{
if(rName == "DashName")
if(rName == "LineDashName")
{
rAny >>= maDashName;
}
else if(rName == "LineDash")
{
rAny >>= maLineDash;
}
else if(rName == "LineWidth")
{
rAny >>= mnLineWidth;
......
......@@ -183,8 +183,8 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
MAP_ENTRY( "ErrorBarStyle", CHART, XML_ERROR_CATEGORY, XML_SCH_TYPE_ERROR_BAR_STYLE ),
MAP_ENTRY( "PercentageError", CHART, XML_ERROR_PERCENTAGE, XML_TYPE_DOUBLE ),
MAP_ENTRY( "RegressionCurves", CHART, XML_REGRESSION_TYPE, XML_SCH_TYPE_REGRESSION_TYPE ),
MAP_ENTRY_ODF12( "ErrorBarRangePositive", CHART, XML_ERROR_UPPER_RANGE, XML_TYPE_STRING ),
MAP_ENTRY_ODF12( "ErrorBarRangeNegative", CHART, XML_ERROR_LOWER_RANGE, XML_TYPE_STRING ),
MAP_ENTRY_ODF12( "ErrorBarRangePositive", CHART, XML_ERROR_UPPER_RANGE, XML_TYPE_STRING ), // export only
MAP_ENTRY_ODF12( "ErrorBarRangeNegative", CHART, XML_ERROR_LOWER_RANGE, XML_TYPE_STRING ), // export only
// errorbars properties (chart2)
MAP_ENTRY_ODF_EXT( "Weigth", CHART, XML_ERROR_STANDARD_WEIGTH, XML_TYPE_DOUBLE),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment