[Libreoffice-commits] core.git: chart2/Library_chartcore.mk chart2/source officecfg/registry
Winfried Donkers (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 20 10:59:17 UTC 2019
chart2/Library_chartcore.mk | 3
chart2/source/view/charttypes/AreaChart.cxx | 27 +-
chart2/source/view/charttypes/ConfigAccess.cxx | 80 ++++++
chart2/source/view/charttypes/VSeriesPlotter.cxx | 161 ++++++++++++++
chart2/source/view/inc/ConfigAccess.hxx | 40 +++
chart2/source/view/inc/VSeriesPlotter.hxx | 15 +
officecfg/registry/schema/org/openoffice/Office/Chart.xcs | 13 +
7 files changed, 333 insertions(+), 6 deletions(-)
New commits:
commit f6f27ae31a26bf6cecbf9205ef28a6bad3d06864
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
AuthorDate: Sat Feb 2 13:05:03 2019 +0100
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Mon May 20 12:58:31 2019 +0200
tdf#90180 Add option to show errors as rectangles in diagrams with error bars.
The option is saved in registrymodifications.xcu, not yet in the document.
(cherry picked from commit 0fc471e8218b53b8b9e505d2af3e015abf3910f3)
Change-Id: I6facc8d6e456046003f2c38ce79a1fcfc712d027
Reviewed-on: https://gerrit.libreoffice.org/67280
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 86eae1a11941..e671110a753f 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -91,6 +91,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
chart2/source/view/charttypes/BubbleChart \
chart2/source/view/charttypes/CandleStickChart \
chart2/source/view/charttypes/CategoryPositionHelper \
+ chart2/source/view/charttypes/ConfigAccess \
chart2/source/view/charttypes/NetChart \
chart2/source/view/charttypes/PieChart \
chart2/source/view/charttypes/Splines \
@@ -237,5 +238,5 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
chart2/source/tools/WrappedPropertySet \
chart2/source/tools/XMLRangeHelper \
))
-
+
# vim: set noet sw=4 ts=4:
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index 2fa4f4e66dd0..2699121ed357 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -30,6 +30,7 @@
#include <Stripe.hxx>
#include <DateHelper.hxx>
#include <unonames.hxx>
+#include <ConfigAccess.hxx>
#include <com/sun/star/chart2/Symbol.hpp>
#include <com/sun/star/chart/DataLabelPlacement.hpp>
@@ -873,12 +874,28 @@ void AreaChart::createShapes()
//@todo other symbol styles
}
}
- //create error bars
- if (bCreateXErrorBar)
- createErrorBar_X( aUnscaledLogicPosition, *pSeries, nIndex, m_xErrorBarTarget );
+ //create error bars or rectangles, depending on configuration
+ if ( ConfigAccess::getUseErrorRectangle() )
+ {
+ if ( bCreateXErrorBar || bCreateYErrorBar )
+ {
+ createErrorRectangle(
+ aUnscaledLogicPosition,
+ *pSeries,
+ nIndex,
+ m_xErrorBarTarget,
+ bCreateXErrorBar,
+ bCreateYErrorBar );
+ }
+ }
+ else
+ {
+ if (bCreateXErrorBar)
+ createErrorBar_X( aUnscaledLogicPosition, *pSeries, nIndex, m_xErrorBarTarget );
- if (bCreateYErrorBar)
- createErrorBar_Y( aUnscaledLogicPosition, *pSeries, nIndex, m_xErrorBarTarget, nullptr );
+ if (bCreateYErrorBar)
+ createErrorBar_Y( aUnscaledLogicPosition, *pSeries, nIndex, m_xErrorBarTarget, nullptr );
+ }
//create data point label
if( pSeries->getDataPointLabelIfLabel(nIndex) )
diff --git a/chart2/source/view/charttypes/ConfigAccess.cxx b/chart2/source/view/charttypes/ConfigAccess.cxx
new file mode 100644
index 000000000000..bca2b6dd99ef
--- /dev/null
+++ b/chart2/source/view/charttypes/ConfigAccess.cxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <ConfigAccess.hxx>
+
+#include <unotools/syslocale.hxx>
+#include <unotools/configitem.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <o3tl/any.hxx>
+#include <rtl/instance.hxx>
+
+namespace chart
+{
+using namespace ::com::sun::star;
+
+class ChartConfigItem : public ::utl::ConfigItem
+{
+private:
+ virtual void ImplCommit() override;
+
+public:
+ ChartConfigItem();
+
+ bool getUseErrorRectangle();
+ virtual void Notify(const uno::Sequence<OUString>& aPropertyNames) override;
+};
+
+ChartConfigItem::ChartConfigItem()
+ : ConfigItem("Office.Chart/ErrorProperties")
+{
+}
+
+void ChartConfigItem::ImplCommit() {}
+void ChartConfigItem::Notify(const uno::Sequence<OUString>&) {}
+
+bool ChartConfigItem::getUseErrorRectangle()
+{
+ uno::Sequence<OUString> aNames(1);
+ aNames[0] = "ErrorRectangle";
+
+ auto b = o3tl::tryAccess<bool>(GetProperties(aNames)[0]);
+ return b && *b;
+}
+
+namespace
+{
+//a ChartConfigItem Singleton
+struct theChartConfigItem : public rtl::Static<ChartConfigItem, theChartConfigItem>
+{
+};
+}
+
+namespace ConfigAccess
+{
+bool getUseErrorRectangle()
+{
+ bool bResult(theChartConfigItem::get().getUseErrorRectangle());
+ return bResult;
+}
+} //namespace ConfigAccess
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index c7de326f0d8d..17f044654535 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -1070,6 +1070,167 @@ void VSeriesPlotter::createErrorBar(
}
+void VSeriesPlotter::addErrorBorder(
+ const drawing::Position3D& rPos0
+ ,const drawing::Position3D& rPos1
+ ,const uno::Reference< drawing::XShapes >& rTarget
+ ,const uno::Reference< beans::XPropertySet >& rErrorBorderProp )
+{
+ drawing::PolyPolygonShape3D aPoly;
+ sal_Int32 nSequenceIndex = 0;
+ AddPointToPoly( aPoly, rPos0, nSequenceIndex );
+ AddPointToPoly( aPoly, rPos1, nSequenceIndex );
+ uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
+ rTarget, PolyToPointSequence( aPoly) );
+ setMappedProperties( xShape, rErrorBorderProp,
+ PropertyMapper::getPropertyNameMapForLineProperties() );
+}
+
+void VSeriesPlotter::createErrorRectangle(
+ const drawing::Position3D& rUnscaledLogicPosition
+ ,VDataSeries& rVDataSeries
+ ,sal_Int32 nIndex
+ ,const uno::Reference< drawing::XShapes >& rTarget
+ ,bool bUseXErrorData
+ ,bool bUseYErrorData )
+{
+ if ( m_nDimension != 2 )
+ return;
+
+ // error border properties
+ Reference< beans::XPropertySet > xErrorBorderPropX, xErrorBorderPropY;
+ if ( bUseXErrorData )
+ {
+ xErrorBorderPropX = rVDataSeries.getXErrorBarProperties( nIndex );
+ if ( !xErrorBorderPropX.is() )
+ return;
+ }
+ uno::Reference< drawing::XShapes > xErrorBorder_ShapesX(
+ getErrorBarsGroupShape( rVDataSeries, rTarget, false ) );
+
+ if ( bUseYErrorData )
+ {
+ xErrorBorderPropY = rVDataSeries.getYErrorBarProperties( nIndex );
+ if ( !xErrorBorderPropY.is() )
+ return;
+ }
+ uno::Reference< drawing::XShapes > xErrorBorder_ShapesY(
+ getErrorBarsGroupShape( rVDataSeries, rTarget, true ) );
+
+ if( !ChartTypeHelper::isSupportingStatisticProperties( m_xChartTypeModel, m_nDimension ) )
+ return;
+
+ try
+ {
+ bool bShowXPositive = false;
+ bool bShowXNegative = false;
+ bool bShowYPositive = false;
+ bool bShowYNegative = false;
+
+ sal_Int32 nErrorBorderStyleX = css::chart::ErrorBarStyle::VARIANCE;
+ sal_Int32 nErrorBorderStyleY = css::chart::ErrorBarStyle::VARIANCE;
+
+ if ( bUseXErrorData )
+ {
+ xErrorBorderPropX->getPropertyValue( "ErrorBarStyle" ) >>= nErrorBorderStyleX;
+ xErrorBorderPropX->getPropertyValue( "ShowPositiveError") >>= bShowXPositive;
+ xErrorBorderPropX->getPropertyValue( "ShowNegativeError") >>= bShowXNegative;
+ }
+ if ( bUseYErrorData )
+ {
+ xErrorBorderPropY->getPropertyValue( "ErrorBarStyle" ) >>= nErrorBorderStyleY;
+ xErrorBorderPropY->getPropertyValue( "ShowPositiveError") >>= bShowYPositive;
+ xErrorBorderPropY->getPropertyValue( "ShowNegativeError") >>= bShowYNegative;
+ }
+
+ if ( bUseXErrorData && nErrorBorderStyleX == css::chart::ErrorBarStyle::NONE )
+ bUseXErrorData = false;
+ if ( bUseYErrorData && nErrorBorderStyleY == css::chart::ErrorBarStyle::NONE )
+ bUseYErrorData = false;
+
+ if ( !bShowXPositive && !bShowXNegative && !bShowYPositive && !bShowYNegative )
+ return;
+
+ if ( !m_pPosHelper )
+ return;
+
+ drawing::Position3D aUnscaledLogicPosition( rUnscaledLogicPosition );
+ if ( bUseXErrorData && nErrorBorderStyleX == css::chart::ErrorBarStyle::STANDARD_DEVIATION )
+ aUnscaledLogicPosition.PositionX = rVDataSeries.getXMeanValue();
+ if ( bUseYErrorData && nErrorBorderStyleY == css::chart::ErrorBarStyle::STANDARD_DEVIATION )
+ aUnscaledLogicPosition.PositionY = rVDataSeries.getYMeanValue();
+
+ const double fX = aUnscaledLogicPosition.PositionX;
+ const double fY = aUnscaledLogicPosition.PositionY;
+ const double fZ = aUnscaledLogicPosition.PositionZ;
+ double fScaledX = fX;
+ m_pPosHelper->doLogicScaling( &fScaledX, nullptr, nullptr );
+
+ uno::Sequence< double > aDataX( rVDataSeries.getAllX() );
+ uno::Sequence< double > aDataY( rVDataSeries.getAllY() );
+
+ double fPosX = 0.0;
+ double fPosY = 0.0;
+ double fNegX = 0.0;
+ double fNegY = 0.0;
+ if ( bUseXErrorData )
+ {
+ if ( bShowXPositive )
+ fPosX = lcl_getErrorBarLogicLength( aDataX, xErrorBorderPropX,
+ nErrorBorderStyleX, nIndex, true, false );
+ if ( bShowXNegative )
+ fNegX = lcl_getErrorBarLogicLength( aDataX, xErrorBorderPropX,
+ nErrorBorderStyleX, nIndex, false, false );
+ }
+
+ if ( bUseYErrorData )
+ {
+ if ( bShowYPositive )
+ fPosY = lcl_getErrorBarLogicLength( aDataY, xErrorBorderPropY,
+ nErrorBorderStyleY, nIndex, true, true );
+ if ( bShowYNegative )
+ fNegY = lcl_getErrorBarLogicLength( aDataY, xErrorBorderPropY,
+ nErrorBorderStyleY, nIndex, false, true );
+ }
+
+ if ( !( ::rtl::math::isFinite( fPosX ) &&
+ ::rtl::math::isFinite( fPosY ) &&
+ ::rtl::math::isFinite( fNegX ) &&
+ ::rtl::math::isFinite( fNegY ) ) )
+ return;
+
+ drawing::Position3D aBottomLeft( lcl_transformMixedToScene( m_pPosHelper,
+ fX - fNegX, fY - fNegY, fZ ) );
+ drawing::Position3D aTopLeft( lcl_transformMixedToScene( m_pPosHelper,
+ fX - fNegX, fY + fPosY, fZ ) );
+ drawing::Position3D aTopRight( lcl_transformMixedToScene( m_pPosHelper,
+ fX + fPosX, fY + fPosY, fZ ) );
+ drawing::Position3D aBottomRight( lcl_transformMixedToScene( m_pPosHelper,
+ fX + fPosX, fY - fNegY, fZ ) );
+ if ( bUseXErrorData )
+ {
+ // top border
+ addErrorBorder( aTopLeft, aTopRight, xErrorBorder_ShapesX, xErrorBorderPropX );
+
+ // bottom border
+ addErrorBorder( aBottomRight, aBottomLeft, xErrorBorder_ShapesX, xErrorBorderPropX );
+ }
+
+ if ( bUseYErrorData )
+ {
+ // left border
+ addErrorBorder( aBottomLeft, aTopLeft, xErrorBorder_ShapesY, xErrorBorderPropY );
+
+ // right border
+ addErrorBorder( aTopRight, aBottomRight, xErrorBorder_ShapesY, xErrorBorderPropY );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2", "Exception in createErrorRectangle(). ");
+ }
+}
+
void VSeriesPlotter::createErrorBar_X( const drawing::Position3D& rUnscaledLogicPosition
, VDataSeries& rVDataSeries, sal_Int32 nPointIndex
, const uno::Reference< drawing::XShapes >& xTarget )
diff --git a/chart2/source/view/inc/ConfigAccess.hxx b/chart2/source/view/inc/ConfigAccess.hxx
new file mode 100644
index 000000000000..556b371f1d81
--- /dev/null
+++ b/chart2/source/view/inc/ConfigAccess.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_CONFIGACCESS_HXX
+#define INCLUDED_CHART2_SOURCE_VIEW_INC_CONFIGACCESS_HXX
+
+namespace chart
+{
+namespace ConfigAccess
+{
+/** @descr Retrieve the setting for showing errors in charts from the registry
+ settings of the Calc application.
+
+ If this setting is not found, it is set to false (the default setting).
+
+ @return boolean UseErrorRectangle.
+ */
+bool getUseErrorRectangle();
+}
+
+} //namespace chart
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx
index 445411523359..ab6f8a81005b 100644
--- a/chart2/source/view/inc/VSeriesPlotter.hxx
+++ b/chart2/source/view/inc/VSeriesPlotter.hxx
@@ -367,6 +367,21 @@ protected:
, const double* pfScaledLogicX
);
+ void createErrorRectangle(
+ const css::drawing::Position3D& rUnscaledLogicPosition
+ , VDataSeries& rVDataSeries
+ , sal_Int32 nIndex
+ , const css::uno::Reference< css::drawing::XShapes >& rTarget
+ , bool bUseXErrorData
+ , bool bUseYErrorData
+ );
+
+ void addErrorBorder(
+ const css::drawing::Position3D& rPos0
+ , const css::drawing::Position3D& rPos1
+ , const css::uno::Reference< css::drawing::XShapes >& rTarget
+ , const css::uno::Reference< css::beans::XPropertySet >& rErrorBorderProp );
+
void createErrorBar_X( const css::drawing::Position3D& rUnscaledLogicPosition
, VDataSeries& rVDataSeries, sal_Int32 nPointIndex
, const css::uno::Reference< css::drawing::XShapes >& xTarget );
diff --git a/officecfg/registry/schema/org/openoffice/Office/Chart.xcs b/officecfg/registry/schema/org/openoffice/Office/Chart.xcs
index 32deb66e7c65..2b1bdba503ad 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Chart.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Chart.xcs
@@ -39,5 +39,18 @@
<!-- 0x004586 0xff420e 0xffd320 0x579d1c 0x7e0021 0x83caff 0x314004 0xaecf00 0x4b1f6f 0xff950e 0xc5000b 0x0084d1 -->
</prop>
</group>
+ <group oor:name="ErrorProperties">
+ <info>
+ <desc>Specifies properties for error presentation in new charts.</desc>
+ </info>
+ <prop oor:name="ErrorRectangle" oor:type="xs:boolean" oor:nillable="false">
+ <!-- UIHints: Tools - Options - Advanced -->
+ <info>
+ <desc>Option to show errors as rectangles in charts.</desc>
+ <label>Error rectangles</label>
+ </info>
+ <value>false</value>
+ </prop>
+ </group>
</component>
</oor:component-schema>
More information about the Libreoffice-commits
mailing list