summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2012-04-04 09:58:52 -0430
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-04-11 17:55:41 +0200
commitf1c9be8706683075b581f85d34c1eafdd41be9b5 (patch)
treea0b6e2c75cca107911ed291ea8f6af3a68f41cb5 /xmloff
parent181a7d75129017c3107939da8aa8b5972b9d5ca9 (diff)
Export chart X,Y errorbars.
- Remove using older properties to get errorbars data. - Only export X errorbars when using ODF VERSION >= 1.2. - Use the dimension attribute to set errorbar direction.
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx104
1 files changed, 51 insertions, 53 deletions
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index b8d993578b24..0d253d2e7c85 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -248,8 +248,8 @@ public:
sal_Bool bExportContent );
void exportErrorBar (
- const ::com::sun::star::uno::Reference<beans::XPropertySet> &xSeriesProp,
- sal_Bool bExportContent );
+ const ::com::sun::star::uno::Reference<beans::XPropertySet> &xSeriesProp, bool bYError,
+ bool bExportContent );
/// add svg position as attribute for current element
void addPosition( const ::com::sun::star::awt::Point & rPosition );
@@ -2992,7 +2992,8 @@ void SchXMLExportHelper_Impl::exportSeries(
exportRegressionCurve( aSeriesSeq[nSeriesIdx], xPropSet, rPageSize, bExportContent );
}
- exportErrorBar( xPropSet,bExportContent );
+ exportErrorBar( xPropSet,false, bExportContent ); // X ErrorBar
+ exportErrorBar( xPropSet,true, bExportContent ); // Y ErrorBar
exportDataPoints(
uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ),
@@ -3116,24 +3117,40 @@ void SchXMLExportHelper_Impl::exportRegressionCurve(
}
void SchXMLExportHelper_Impl::exportErrorBar( const Reference<beans::XPropertySet> &xSeriesProp,
- sal_Bool bExportContent )
+ bool bYError, bool bExportContent )
{
assert(mxExpPropMapper.is());
+ const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
+
+ /// Dont export X ErrorBars for older ODF versions.
+ if ( !bYError && nCurrentVersion < SvtSaveOptions::ODFVER_012 )
+ return;
+
if (xSeriesProp.is())
{
- Any aAny;
- std::vector< XMLPropertyState > aPropertyStates;
+ bool bNegative = false, bPositive = false;
sal_Int32 nErrorBarStyle = chart::ErrorBarStyle::NONE;
- chart::ChartErrorIndicatorType eErrorType = chart::ChartErrorIndicatorType_NONE;
+ Reference< beans::XPropertySet > xErrorBarProp;
try
{
- aAny = xSeriesProp->getPropertyValue("ErrorIndicator" );
- aAny >>= eErrorType;
+ Any aAny;
- aAny = xSeriesProp->getPropertyValue("ErrorBarStyle" );
- aAny >>= nErrorBarStyle;
+ aAny = xSeriesProp->getPropertyValue( bYError ? "ErrorBarY" : "ErrorBarX" );
+ aAny >>= xErrorBarProp;
+
+ if ( xErrorBarProp.is() )
+ {
+ aAny = xErrorBarProp->getPropertyValue("ShowNegativeError" );
+ aAny >>= bNegative;
+
+ aAny = xErrorBarProp->getPropertyValue("ShowPositiveError" );
+ aAny >>= bPositive;
+
+ aAny = xErrorBarProp->getPropertyValue("ErrorBarStyle" );
+ aAny >>= nErrorBarStyle;
+ }
}
catch( const beans::UnknownPropertyException & rEx )
{
@@ -3144,56 +3161,37 @@ void SchXMLExportHelper_Impl::exportErrorBar( const Reference<beans::XPropertySe
RTL_TEXTENCODING_ASCII_US ).getStr());
}
- if( nErrorBarStyle != chart::ErrorBarStyle::NONE &&
- eErrorType != chart::ChartErrorIndicatorType_NONE)
+ if( nErrorBarStyle != chart::ErrorBarStyle::NONE && (bNegative || bPositive))
{
- Reference< beans::XPropertySet > xErrorBarProp;
- try
- {
- aAny = xSeriesProp->getPropertyValue("DataErrorProperties" );
- aAny >>= xErrorBarProp;
- }
- catch( const uno::Exception & rEx )
- {
- (void)rEx; // avoid warning for pro build
- OSL_TRACE( "Exception caught during Export of series - optional DataErrorProperties not available: %s",
- OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
- }
-
- if( xErrorBarProp.is() )
+ if( bExportContent && nErrorBarStyle == chart::ErrorBarStyle::FROM_DATA )
{
- if( bExportContent &&
- nErrorBarStyle == chart::ErrorBarStyle::FROM_DATA )
+ // register data ranges for error bars for export in local table
+ ::std::vector< Reference< chart2::data::XDataSequence > > aErrorBarSequences(
+ lcl_getErrorBarSequences( xErrorBarProp ));
+ for( ::std::vector< Reference< chart2::data::XDataSequence > >::const_iterator aIt(
+ aErrorBarSequences.begin()); aIt != aErrorBarSequences.end(); ++aIt )
{
- // register data ranges for error bars for export in local table
- ::std::vector< Reference< chart2::data::XDataSequence > > aErrorBarSequences(
- lcl_getErrorBarSequences( xErrorBarProp ));
- for( ::std::vector< Reference< chart2::data::XDataSequence > >::const_iterator aIt(
- aErrorBarSequences.begin()); aIt != aErrorBarSequences.end(); ++aIt )
- {
- m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, *aIt ));
- }
+ m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, *aIt ));
}
+ }
- aPropertyStates = mxExpPropMapper->Filter( xErrorBarProp );
+ std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( xErrorBarProp );
- if( !aPropertyStates.empty() )
+ if( !aPropertyStates.empty() )
+ {
+ // write element
+ if( bExportContent )
{
- // write element
- if( bExportContent )
- {
- // add style name attribute
- AddAutoStyleAttribute( aPropertyStates );
+ // add style name attribute
+ AddAutoStyleAttribute( aPropertyStates );
- const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
- if( nCurrentVersion >= SvtSaveOptions::ODFVER_012 )
- mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Y );//#i114149#
- SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_ERROR_INDICATOR, sal_True, sal_True );
- }
- else // autostyles
- {
- CollectAutoStyle( aPropertyStates );
- }
+ if( nCurrentVersion >= SvtSaveOptions::ODFVER_012 )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, bYError ? XML_Y : XML_X );//#i114149#
+ SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_ERROR_INDICATOR, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
}
}
}