[Libreoffice-commits] .: Branch 'feature/chart_errorbars' - 6 commits - chart2/source xmloff/inc xmloff/source

Rafael Dominguez rdominguez at kemper.freedesktop.org
Sun Apr 8 17:31:28 PDT 2012


 chart2/source/controller/dialogs/DataBrowserModel.cxx |   41 ----
 chart2/source/controller/dialogs/DataBrowserModel.hxx |    2 
 chart2/source/view/charttypes/VSeriesPlotter.cxx      |    7 
 chart2/source/view/inc/VDataSeries.hxx                |    2 
 chart2/source/view/main/VDataSeries.cxx               |   15 +
 xmloff/inc/xmloff/xmltoken.hxx                        |    1 
 xmloff/source/chart/PropertyMap.hxx                   |    8 
 xmloff/source/chart/SchXMLExport.cxx                  |  176 +++++++++++-------
 xmloff/source/core/xmltoken.cxx                       |    2 
 9 files changed, 153 insertions(+), 101 deletions(-)

New commits:
commit 7d56619bba0d8b250f8b0367e2b817b2678b52e0
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Apr 8 19:10:23 2012 -0430

    Export errorbars attributes and styles to XML.
    
    - Instead of exporting the errorbar data to the series in a global way now each errorbar has its own attributes depending on their user settings,
    so we can have different data for each type bar (only when using ODF 1.2 extended) and still keeping it backward compatible with old formats.

diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index ee535b1..06b143c 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -3124,7 +3124,7 @@ void SchXMLExportHelper_Impl::exportErrorBar( const Reference<beans::XPropertySe
     const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
 
     /// Dont export X ErrorBars for older ODF versions.
-    if ( !bYError && nCurrentVersion < SvtSaveOptions::ODFVER_012 )
+    if ( !bYError && nCurrentVersion != SvtSaveOptions::ODFVER_LATEST )
         return;
 
     if (xSeriesProp.is())
@@ -3165,12 +3165,34 @@ void SchXMLExportHelper_Impl::exportErrorBar( const Reference<beans::XPropertySe
         {
             if( bExportContent && nErrorBarStyle == chart::ErrorBarStyle::FROM_DATA )
             {
+                uno::Reference< chart2::XChartDocument > xNewDoc(mrExport.GetModel(), uno::UNO_QUERY);
+
                 // 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 )
                 {
+                    if ( nCurrentVersion == SvtSaveOptions::ODFVER_LATEST )
+                    {
+                        rtl::OUString aRole, aRange;
+                        Reference< beans::XPropertySet > xSeqProp( *aIt, uno::UNO_QUERY_THROW );
+                        xSeqProp->getPropertyValue("Role") >>= aRole;
+
+                        aRange = lcl_ConvertRange((*aIt)->getSourceRangeRepresentation(), xNewDoc );
+
+                        if ( aRole.indexOf("positive") != -1 )
+                        {
+                            if ( bPositive )
+                                mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ERROR_UPPER_RANGE, aRange );
+                        }
+                        else
+                        {
+                            if ( bNegative )
+                                mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ERROR_LOWER_RANGE, aRange );
+                        }
+                    }
+
                     m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, *aIt ));
                 }
             }
commit 45d49253f6b062a320640b660e49a500434d87f5
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Apr 8 19:08:19 2012 -0430

    Map errorbars properties from chart2 API to xml.

diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx
index f241023..15db15f 100644
--- a/xmloff/inc/xmloff/xmltoken.hxx
+++ b/xmloff/inc/xmloff/xmltoken.hxx
@@ -3149,6 +3149,7 @@ namespace xmloff { namespace token {
         XML_HORIZONTAL_BAR,
         XML_VERTICAL_BAR,
 
+        XML_ERROR_STANDARD_WEIGTH, // errorbar standard deviation error weigth
         XML_TOKEN_END
     };
 
diff --git a/xmloff/source/chart/PropertyMap.hxx b/xmloff/source/chart/PropertyMap.hxx
index d0aab8b..f293b79 100644
--- a/xmloff/source/chart/PropertyMap.hxx
+++ b/xmloff/source/chart/PropertyMap.hxx
@@ -94,6 +94,7 @@
 #define MAP_FULL( ApiName, NameSpace, XMLTokenName, XMLType, ContextId, EarliestODFVersionForExport ) { ApiName, sizeof(ApiName)-1, XML_NAMESPACE_##NameSpace, xmloff::token::XMLTokenName, XMLType|XML_TYPE_PROP_CHART, ContextId, EarliestODFVersionForExport }
 #define MAP_ENTRY( a, ns, nm, t )            { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFVER_010 }
 #define MAP_ENTRY_ODF12( a, ns, nm, t )      { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFVER_012 }
+#define MAP_ENTRY_ODF_EXT( a, ns, nm, t )    { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFVER_LATEST }
 #define MAP_CONTEXT( a, ns, nm, t, c )       { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, c, SvtSaveOptions::ODFVER_010 }
 #define MAP_SPECIAL( a, ns, nm, t, c )       { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART | MID_FLAG_SPECIAL_ITEM, c, SvtSaveOptions::ODFVER_010 }
 #define MAP_SPECIAL_ODF12( a, ns, nm, t, c ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART | MID_FLAG_SPECIAL_ITEM, c, SvtSaveOptions::ODFVER_012 }
@@ -193,6 +194,13 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
       MAP_ENTRY_ODF12( "ErrorBarRangePositive", CHART, XML_ERROR_UPPER_RANGE, XML_TYPE_STRING ),
       MAP_ENTRY_ODF12( "ErrorBarRangeNegative", CHART, XML_ERROR_LOWER_RANGE, XML_TYPE_STRING ),
 
+    // errorbars properties (chart2)
+    MAP_ENTRY_ODF_EXT( "PositiveError", CHART, XML_ERROR_LOWER_LIMIT, XML_TYPE_DOUBLE),
+    MAP_ENTRY_ODF_EXT( "NegativeError", CHART, XML_ERROR_UPPER_LIMIT, XML_TYPE_DOUBLE),
+    MAP_ENTRY_ODF_EXT( "Weigth", CHART, XML_ERROR_STANDARD_WEIGTH, XML_TYPE_DOUBLE),
+    MAP_ENTRY_ODF_EXT( "ShowPositiveError", CHART, XML_ERROR_UPPER_INDICATOR, XML_TYPE_BOOL),
+    MAP_ENTRY_ODF_EXT( "ShowNegativeError", CHART, XML_ERROR_LOWER_INDICATOR, XML_TYPE_BOOL),
+
     // series/data-point properties
     MAP_SPECIAL( "DataCaption", CHART, XML_DATA_LABEL_NUMBER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER ),   // convert one constant
     MAP_SPECIAL( "DataCaption", CHART, XML_DATA_LABEL_TEXT, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT ),       // to 'tristate' and two bools
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 7c56037..a0add0e 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3145,6 +3145,8 @@ namespace xmloff { namespace token {
         TOKEN( "horizontal-bar",               XML_HORIZONTAL_BAR ),
         TOKEN( "vertical-bar",                 XML_VERTICAL_BAR ),
 
+        TOKEN( "std-weight", XML_ERROR_STANDARD_WEIGTH ),
+
 #if OSL_DEBUG_LEVEL > 0
         { 0, NULL, NULL,                       XML_TOKEN_END }
 #else
commit fbb767c890a53717510f34be67a8cc318b307794
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Wed Apr 4 09:58:52 2012 -0430

    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.

diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index d175ca8..ee535b1 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 );
                 }
             }
         }
commit 7aeec91c710b15c5c9d1b403216dcf2532bd15ab
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Tue Apr 3 17:41:52 2012 -0430

    Move exporting chart errorbars code to its own method.

diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index f412ab0..d175ca8 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -247,6 +247,10 @@ public:
         const ::com::sun::star::awt::Size & rPageSize,
         sal_Bool bExportContent );
 
+    void exportErrorBar (
+        const ::com::sun::star::uno::Reference<beans::XPropertySet> &xSeriesProp,
+            sal_Bool bExportContent );
+
     /// add svg position as attribute for current element
     void addPosition( const ::com::sun::star::awt::Point & rPosition );
     void addPosition( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape );
@@ -2748,8 +2752,6 @@ void SchXMLExportHelper_Impl::exportSeries(
                     sal_Int32 nAttachedAxis = chart::ChartAxisAssign::PRIMARY_Y;
                     sal_Bool bHasMeanValueLine = false;
                     chart::ChartRegressionCurveType eRegressionType( chart::ChartRegressionCurveType_NONE );
-                    chart::ChartErrorIndicatorType eErrorType( chart::ChartErrorIndicatorType_NONE );
-                    sal_Int32 nErrorBarStyle( chart::ErrorBarStyle::NONE );
                     Reference< beans::XPropertySet > xPropSet;
                     tLabelValuesDataPair aSeriesLabelValuesPair;
 
@@ -2817,14 +2819,6 @@ void SchXMLExportHelper_Impl::exportSeries(
                                     aAny = xPropSet->getPropertyValue(
                                         OUString( RTL_CONSTASCII_USTRINGPARAM( "RegressionCurves" )));
                                     aAny >>= eRegressionType;
-
-                                    aAny = xPropSet->getPropertyValue(
-                                        OUString( RTL_CONSTASCII_USTRINGPARAM( "ErrorIndicator" )));
-                                    aAny >>= eErrorType;
-
-                                    aAny = xPropSet->getPropertyValue(
-                                        OUString( RTL_CONSTASCII_USTRINGPARAM( "ErrorBarStyle" )));
-                                    aAny >>= nErrorBarStyle;
                                 }
                                 catch( const beans::UnknownPropertyException & rEx )
                                 {
@@ -2998,62 +2992,7 @@ void SchXMLExportHelper_Impl::exportSeries(
                         exportRegressionCurve( aSeriesSeq[nSeriesIdx], xPropSet, rPageSize, bExportContent );
                     }
 
-                    if( nErrorBarStyle != chart::ErrorBarStyle::NONE &&
-                        eErrorType != chart::ChartErrorIndicatorType_NONE &&
-                        xPropSet.is() &&
-                        mxExpPropMapper.is() )
-                    {
-                        Reference< beans::XPropertySet > xStatProp;
-                        try
-                        {
-                            Any aPropAny( xPropSet->getPropertyValue(
-                                            OUString( RTL_CONSTASCII_USTRINGPARAM( "DataErrorProperties" ))));
-                            aPropAny >>= xStatProp;
-                        }
-                        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( xStatProp.is() )
-                        {
-                            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( xStatProp ));
-                                for( ::std::vector< Reference< chart2::data::XDataSequence > >::const_iterator aIt(
-                                         aErrorBarSequences.begin()); aIt != aErrorBarSequences.end(); ++aIt )
-                                {
-                                    m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, *aIt ));
-                                }
-                            }
-
-                            aPropertyStates = mxExpPropMapper->Filter( xStatProp );
-
-                            if( !aPropertyStates.empty() )
-                            {
-                                // write element
-                                if( bExportContent )
-                                {
-                                    // 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 );
-                                }
-                            }
-                        }
-                    }
+                    exportErrorBar( xPropSet,bExportContent );
 
                     exportDataPoints(
                         uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ),
@@ -3176,6 +3115,91 @@ void SchXMLExportHelper_Impl::exportRegressionCurve(
     }
 }
 
+void SchXMLExportHelper_Impl::exportErrorBar( const Reference<beans::XPropertySet> &xSeriesProp,
+                                              sal_Bool bExportContent )
+{
+    assert(mxExpPropMapper.is());
+
+    if (xSeriesProp.is())
+    {
+        Any aAny;
+        std::vector< XMLPropertyState > aPropertyStates;
+        sal_Int32 nErrorBarStyle = chart::ErrorBarStyle::NONE;
+        chart::ChartErrorIndicatorType eErrorType = chart::ChartErrorIndicatorType_NONE;
+
+        try
+        {
+            aAny = xSeriesProp->getPropertyValue("ErrorIndicator" );
+            aAny >>= eErrorType;
+
+            aAny = xSeriesProp->getPropertyValue("ErrorBarStyle" );
+            aAny >>= nErrorBarStyle;
+        }
+        catch( const beans::UnknownPropertyException & rEx )
+        {
+            (void)rEx; // avoid warning for pro build
+            OSL_TRACE(
+                OUStringToOString(OUString("Required property not found in DataRowProperties: " ) +
+                    rEx.Message,
+                    RTL_TEXTENCODING_ASCII_US ).getStr());
+        }
+
+        if( nErrorBarStyle != chart::ErrorBarStyle::NONE &&
+            eErrorType != chart::ChartErrorIndicatorType_NONE)
+        {
+            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 )
+                {
+                    // 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 ));
+                    }
+                }
+
+                aPropertyStates = mxExpPropMapper->Filter( xErrorBarProp );
+
+                if( !aPropertyStates.empty() )
+                {
+                    // write element
+                    if( bExportContent )
+                    {
+                        // 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 );
+                    }
+                }
+            }
+        }
+    }
+}
+
 void SchXMLExportHelper_Impl::exportCandleStickSeries(
     const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq,
     const Reference< chart2::XDiagram > & xDiagram,
commit 6f944b66577eeaa4d926c4b91265f27dba9e1679
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Mon Apr 2 19:04:01 2012 -0430

    Calculate correct standard deviation for XErrorBar.
    
    - Add method to calculate X standard deviation.
    - Set correct XErrorBar position when using standard deviation error
    type.

diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 57d0d08..d5522b4 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -832,7 +832,12 @@ void VSeriesPlotter::createErrorBar(
 
         drawing::Position3D aUnscaledLogicPosition(rUnscaledLogicPosition);
         if(nErrorBarStyle==::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION)
-            aUnscaledLogicPosition.PositionY = rVDataSeries.getYMeanValue();
+        {
+            if (bYError)
+                aUnscaledLogicPosition.PositionY = rVDataSeries.getYMeanValue();
+            else
+                aUnscaledLogicPosition.PositionX = rVDataSeries.getXMeanValue();
+        }
 
         bool bCreateNegativeBorder = false;//make a vertical line at the negative end of the error bar
         bool bCreatePositiveBorder = false;//make a vertical line at the positive end of the error bar
diff --git a/chart2/source/view/inc/VDataSeries.hxx b/chart2/source/view/inc/VDataSeries.hxx
index 64679cd..cb10cef 100644
--- a/chart2/source/view/inc/VDataSeries.hxx
+++ b/chart2/source/view/inc/VDataSeries.hxx
@@ -102,6 +102,7 @@ public:
     ::com::sun::star::uno::Sequence< double > getAllX() const;
     ::com::sun::star::uno::Sequence< double > getAllY() const;
 
+    double getXMeanValue() const;
     double getYMeanValue() const;
 
     bool        hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const;
@@ -216,6 +217,7 @@ private: //member
 
     VDataSequence*  m_pValueSequenceForDataLabelNumberFormatDetection;
 
+    mutable double m_fXMeanValue;
     mutable double m_fYMeanValue;
 
     ::com::sun::star::uno::Sequence< sal_Int32 >    m_aAttributedDataPointIndexList;
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index 5cad9ca..6821ccd 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -176,6 +176,7 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries )
     , m_aValues_Bubble_Size()
     , m_pValueSequenceForDataLabelNumberFormatDetection(&m_aValues_Y)
 
+    , m_fXMeanValue(1.0)
     , m_fYMeanValue(1.0)
 
     , m_aAttributedDataPointIndexList()
@@ -207,6 +208,7 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries )
     , m_nMissingValueTreatment(::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
     , m_bAllowPercentValueInDataLabel(false)
 {
+    ::rtl::math::setNan( & m_fXMeanValue );
     ::rtl::math::setNan( & m_fYMeanValue );
 
     uno::Reference<data::XDataSource> xDataSource =
@@ -729,6 +731,19 @@ uno::Sequence< double > VDataSeries::getAllY() const
     return m_aValues_Y.Doubles;
 }
 
+double VDataSeries::getXMeanValue() const
+{
+    if( ::rtl::math::isNan( m_fXMeanValue ) )
+    {
+        uno::Reference< XRegressionCurveCalculator > xCalculator( RegressionCurveHelper::createRegressionCurveCalculatorByServiceName( C2U("com.sun.star.chart2.MeanValueRegressionCurve") ) );
+        uno::Sequence< double > aXValuesDummy;
+        xCalculator->recalculateRegression( aXValuesDummy, getAllX() );
+        double fXDummy = 1.0;
+        m_fXMeanValue = xCalculator->getCurveValue( fXDummy );
+    }
+    return m_fXMeanValue;
+}
+
 double VDataSeries::getYMeanValue() const
 {
     if( ::rtl::math::isNan( m_fYMeanValue ) )
commit 961ea4a51a21a017bee473bfbd9bb24e33de3790
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Mon Apr 2 18:21:51 2012 -0430

    Display correct errorbars columns in chart data browser.

diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx
index 1ec9acf..b9ae25b 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.cxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx
@@ -918,7 +918,10 @@ void DataBrowserModel::updateFromModel()
 
                         // add ranges for error bars if present for a series
                         if( StatisticsHelper::usesErrorBarRanges( aSeries[nSeriesIdx], /* bYError = */ true ))
-                            addErrorBarRanges( aSeries[nSeriesIdx], nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd );
+                            addErrorBarRanges( aSeries[nSeriesIdx], nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, true );
+
+                        if( StatisticsHelper::usesErrorBarRanges( aSeries[nSeriesIdx], /* bYError = */ false ))
+                            addErrorBarRanges( aSeries[nSeriesIdx], nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, false );
 
                         m_aHeaders.push_back(
                             tDataHeader(
@@ -942,59 +945,31 @@ void DataBrowserModel::addErrorBarRanges(
     const Reference< chart2::XDataSeries > & xDataSeries,
     sal_Int32 nNumberFormatKey,
     sal_Int32 & rInOutSequenceIndex,
-    sal_Int32 & rInOutHeaderEnd )
+    sal_Int32 & rInOutHeaderEnd, bool bYError )
 {
     try
     {
         ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aSequences;
 
-        // x error bars
-        // ------------
         Reference< chart2::data::XDataSource > xErrorSource(
-            StatisticsHelper::getErrorBars( xDataSeries, /* bYError = */ false ), uno::UNO_QUERY );
+            StatisticsHelper::getErrorBars( xDataSeries, bYError ), uno::UNO_QUERY );
 
-        // positive x error bars
         Reference< chart2::data::XLabeledDataSequence > xErrorLSequence(
             StatisticsHelper::getErrorLabeledDataSequenceFromDataSource(
                 xErrorSource,
                 /* bPositiveValue = */ true,
-                /* bYError = */ false ));
+                bYError ));
         if( xErrorLSequence.is())
             aSequences.push_back( xErrorLSequence );
 
-        // negative x error bars
         xErrorLSequence.set(
             StatisticsHelper::getErrorLabeledDataSequenceFromDataSource(
                 xErrorSource,
                 /* bPositiveValue = */ false,
-                /* bYError = */ false ));
-        if( xErrorLSequence.is())
-            aSequences.push_back( xErrorLSequence );
-
-        // y error bars
-        // ------------
-        xErrorSource.set(
-            StatisticsHelper::getErrorBars( xDataSeries, /* bYError = */ true ), uno::UNO_QUERY );
-
-        // positive y error bars
-        xErrorLSequence.set(
-            StatisticsHelper::getErrorLabeledDataSequenceFromDataSource(
-                xErrorSource,
-                /* bPositiveValue = */ true,
-                /* bYError = */ true ));
+                bYError ));
         if( xErrorLSequence.is())
             aSequences.push_back( xErrorLSequence );
 
-        // negative y error bars
-        xErrorLSequence.set(
-            StatisticsHelper::getErrorLabeledDataSequenceFromDataSource(
-                xErrorSource,
-                /* bPositiveValue = */ false,
-                /* bYError = */ true ));
-        if( xErrorLSequence.is())
-            aSequences.push_back( xErrorLSequence );
-
-
         for( ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::const_iterator aIt( aSequences.begin());
              aIt != aSequences.end(); ++aIt )
         {
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx
index ee48fa0..7d6e99a 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.hxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx
@@ -159,7 +159,7 @@ private:
             ::com::sun::star::chart2::XDataSeries > & xDataSeries,
         sal_Int32 nNumberFormatKey,
         sal_Int32 & rInOutSequenceIndex,
-        sal_Int32 & rInOutHeaderEnd );
+        sal_Int32 & rInOutHeaderEnd, bool bYError );
 
     sal_Int32 getCategoryColumnCount();
 


More information about the Libreoffice-commits mailing list