summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2021-02-11 07:53:15 +0100
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2021-02-22 07:36:21 +0100
commit4141533a3fb984fbaefe87b15fceeda7f2082061 (patch)
tree46b7dc9e659033666cdef2275ec283dd2de8fd96
parentColibre: tdf#133038 change some formatting icons for Catalan (diff)
downloadcore-4141533a3fb984fbaefe87b15fceeda7f2082061.tar.gz
core-4141533a3fb984fbaefe87b15fceeda7f2082061.zip
[API CHANGE] tdf#133423 Implement chart:regression-moving-type
Change-Id: Icb967367fbf12e5a1566b7f18ebe5e3d8a3534f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110748 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
-rw-r--r--chart2/qa/extras/chart2_trendcalculators.cxx12
-rw-r--r--chart2/source/controller/dialogs/ObjectNameProvider.cxx5
-rw-r--r--chart2/source/controller/dialogs/res_Trendline.cxx32
-rw-r--r--chart2/source/controller/dialogs/res_Trendline.hxx2
-rw-r--r--chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx13
-rw-r--r--chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx14
-rw-r--r--chart2/source/inc/LinearRegressionCurveCalculator.hxx3
-rw-r--r--chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx4
-rw-r--r--chart2/source/inc/RegressionCurveCalculator.hxx4
-rw-r--r--chart2/source/inc/chartview/ChartSfxItemIds.hxx3
-rw-r--r--chart2/source/tools/LinearRegressionCurveCalculator.cxx6
-rw-r--r--chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx55
-rw-r--r--chart2/source/tools/RegressionCurveCalculator.cxx4
-rw-r--r--chart2/source/tools/RegressionCurveModel.cxx9
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx8
-rw-r--r--chart2/source/view/main/ChartItemPool.cxx2
-rw-r--r--chart2/uiconfig/ui/tp_Trendline.ui95
-rw-r--r--include/xmloff/xmltoken.hxx3
-rw-r--r--offapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/chart2/MovingAverageType.idl35
-rw-r--r--offapi/com/sun/star/chart2/RegressionCurve.idl2
-rw-r--r--offapi/com/sun/star/chart2/XRegressionCurveCalculator.idl7
-rw-r--r--xmloff/source/chart/PropertyMap.hxx5
-rw-r--r--xmloff/source/chart/PropertyMaps.cxx29
-rw-r--r--xmloff/source/core/xmltoken.cxx3
-rw-r--r--xmloff/source/token/tokens.txt3
26 files changed, 305 insertions, 54 deletions
diff --git a/chart2/qa/extras/chart2_trendcalculators.cxx b/chart2/qa/extras/chart2_trendcalculators.cxx
index b8eb367524bb..1eeea5d12e23 100644
--- a/chart2/qa/extras/chart2_trendcalculators.cxx
+++ b/chart2/qa/extras/chart2_trendcalculators.cxx
@@ -110,7 +110,7 @@ void Chart2TrendCalculators::checkCalculator(
void Chart2TrendCalculators::testPotentialRegression1()
{
loadCalculatorFromSheet( SHEET_POTENTIAL1 );
- m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0 );
+ m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0, 0 );
Sequence< double > xValues( 7 );
Sequence< double > yValues( 7 );
for (int i=0; i<7; i++)
@@ -126,7 +126,7 @@ void Chart2TrendCalculators::testPotentialRegression1()
void Chart2TrendCalculators::testPotentialRegression2()
{
loadCalculatorFromSheet( SHEET_POTENTIAL2 );
- m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0 );
+ m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0, 0 );
Sequence< double > xValues( 7 );
Sequence< double > yValues( 7 );
for (int i=0; i<7; i++)
@@ -142,7 +142,7 @@ void Chart2TrendCalculators::testPotentialRegression2()
void Chart2TrendCalculators::testLinearRegression1()
{
loadCalculatorFromSheet( SHEET_LINEAR1 );
- m_xRegressionCurveCalculator->setRegressionProperties( 1, false, 0, 0 );
+ m_xRegressionCurveCalculator->setRegressionProperties( 1, false, 0, 0, 0 );
Sequence< double > xValues( 7 );
Sequence< double > yValues( 7 );
for (int i=0; i<7; i++)
@@ -158,7 +158,7 @@ void Chart2TrendCalculators::testLinearRegression1()
void Chart2TrendCalculators::testPolynomialRegression1()
{
loadCalculatorFromSheet( SHEET_POLYNOMIAL1 );
- m_xRegressionCurveCalculator->setRegressionProperties( 2, false, 0, 0 );
+ m_xRegressionCurveCalculator->setRegressionProperties( 2, false, 0, 0, 0 );
Sequence< double > xValues( 7 );
Sequence< double > yValues( 7 );
for (int i=0; i<7; i++)
@@ -174,7 +174,7 @@ void Chart2TrendCalculators::testPolynomialRegression1()
void Chart2TrendCalculators::testExponentialRegression1()
{
loadCalculatorFromSheet( SHEET_EXPONENTIAL1 );
- m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0 );
+ m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0, 0 );
Sequence< double > xValues( 7 );
Sequence< double > yValues( 7 );
for (int i=0; i<7; i++)
@@ -189,7 +189,7 @@ void Chart2TrendCalculators::testExponentialRegression1()
void Chart2TrendCalculators::testExponentialRegression2()
{
loadCalculatorFromSheet( SHEET_EXPONENTIAL2 );
- m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0 );
+ m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0, 0 );
Sequence< double > xValues( 7 );
Sequence< double > yValues( 7 );
for (int i=0; i<7; i++)
diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
index 56dca8dde908..5eae3853add8 100644
--- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx
+++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
@@ -41,6 +41,7 @@
#include <unotools/localedatawrapper.hxx>
#include <com/sun/star/chart2/XTitle.hpp>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <tools/diagnose_ex.h>
@@ -567,6 +568,7 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe
Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_SET_THROW );
sal_Int32 aDegree = 2;
sal_Int32 aPeriod = 2;
+ sal_Int32 aMovingType = css::chart2::MovingAverageType::Prior;
bool bForceIntercept = false;
double aInterceptValue = 0.0;
OUString aXName ("x"), aYName ("f(x)");
@@ -579,6 +581,7 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe
{
xProperties->getPropertyValue( "PolynomialDegree") >>= aDegree;
xProperties->getPropertyValue( "MovingAveragePeriod") >>= aPeriod;
+ xProperties->getPropertyValue( "MovingAverageType") >>= aMovingType;
xProperties->getPropertyValue( "ForceIntercept") >>= bForceIntercept;
if (bForceIntercept)
xProperties->getPropertyValue( "InterceptValue") >>= aInterceptValue;
@@ -591,7 +594,7 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe
aYName = "f(x)";
}
}
- xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, 2);
+ xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, 2, aMovingType);
xCalculator->setXYNames ( aXName, aYName );
RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel );
diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx
index 11514a19a84a..6d994e13bc6d 100644
--- a/chart2/source/controller/dialogs/res_Trendline.cxx
+++ b/chart2/source/controller/dialogs/res_Trendline.cxx
@@ -21,12 +21,16 @@
#include <bitmaps.hlst>
#include <chartview/ChartSfxItemIds.hxx>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
+
#include <svl/intitem.hxx>
#include <svl/stritem.hxx>
#include <svl/zforlist.hxx>
#include <vcl/formatter.hxx>
#include <vcl/weld.hxx>
+using namespace css::chart2;
+
namespace chart
{
@@ -65,6 +69,7 @@ TrendlineResources::TrendlineResources(weld::Builder& rBuilder, const SfxItemSet
, m_xEE_XName(rBuilder.weld_entry("entry_Xname"))
, m_xEE_YName(rBuilder.weld_entry("entry_Yname"))
, m_xCB_ShowCorrelationCoeff(rBuilder.weld_check_button("showCorrelationCoefficient"))
+ , m_xCB_RegressionMovingType(rBuilder.weld_combo_box("combo_moving_type"))
{
FillValueSets();
@@ -240,6 +245,21 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
m_xCB_ShowCorrelationCoeff->set_active( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue());
}
+ if( rInAttrs.GetItemState( SCHATTR_REGRESSION_MOVING_TYPE, true, &pPoolItem ) == SfxItemState::SET )
+ {
+ sal_Int32 nMovingType = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
+ if (nMovingType == MovingAverageType::Prior)
+ m_xCB_RegressionMovingType->set_active(0);
+ else if (nMovingType == MovingAverageType::Central)
+ m_xCB_RegressionMovingType->set_active(1);
+ else if (nMovingType == MovingAverageType::AveragedAbscissa)
+ m_xCB_RegressionMovingType->set_active(2);
+ }
+ else
+ {
+ m_xCB_RegressionMovingType->set_active(0);
+ }
+
if( !m_bTrendLineUnique )
return;
@@ -273,6 +293,17 @@ void TrendlineResources::FillItemSet(SfxItemSet* rOutAttrs) const
if( m_bTrendLineUnique )
rOutAttrs->Put( SvxChartRegressItem( m_eTrendLineType, SCHATTR_REGRESSION_TYPE ));
+ if (m_eTrendLineType == SvxChartRegress::MovingAverage)
+ {
+ sal_Int32 nType = MovingAverageType::Prior;
+ if (m_xCB_RegressionMovingType->get_active() == 1)
+ nType = MovingAverageType::Central;
+ else if (m_xCB_RegressionMovingType->get_active() == 2)
+ nType = MovingAverageType::AveragedAbscissa;
+
+ rOutAttrs->Put(SfxInt32Item(SCHATTR_REGRESSION_MOVING_TYPE, nType));
+ }
+
if( m_xCB_ShowEquation->get_state() != TRISTATE_INDET )
rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_EQUATION, m_xCB_ShowEquation->get_active() ));
@@ -346,6 +377,7 @@ void TrendlineResources::UpdateControlStates()
}
m_xCB_ShowEquation->set_sensitive( !bMovingAverage );
m_xCB_ShowCorrelationCoeff->set_sensitive( !bMovingAverage );
+ m_xCB_RegressionMovingType->set_sensitive(bMovingAverage);
m_xEE_XName->set_sensitive( !bMovingAverage && m_xCB_ShowEquation->get_active() );
m_xEE_YName->set_sensitive( !bMovingAverage && m_xCB_ShowEquation->get_active() );
}
diff --git a/chart2/source/controller/dialogs/res_Trendline.hxx b/chart2/source/controller/dialogs/res_Trendline.hxx
index 29d916fe068f..2327b05c355d 100644
--- a/chart2/source/controller/dialogs/res_Trendline.hxx
+++ b/chart2/source/controller/dialogs/res_Trendline.hxx
@@ -24,6 +24,7 @@
namespace weld { class Builder; }
namespace weld { class CheckButton; }
+namespace weld { class ComboBox; }
namespace weld { class Entry; }
namespace weld { class FormattedSpinButton; }
namespace weld { class Image; }
@@ -83,6 +84,7 @@ private:
std::unique_ptr<weld::Entry> m_xEE_XName;
std::unique_ptr<weld::Entry> m_xEE_YName;
std::unique_ptr<weld::CheckButton> m_xCB_ShowCorrelationCoeff;
+ std::unique_ptr<weld::ComboBox> m_xCB_RegressionMovingType;
void UpdateControlStates();
DECL_LINK(SelectTrendLine, weld::ToggleButton&, void);
diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index 8859158ac5b8..7fe5d2acad41 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -212,6 +212,13 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
}
break;
+ case SCHATTR_REGRESSION_MOVING_TYPE:
+ {
+ uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+ bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAverageType");
+ }
+ break;
+
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
@@ -304,6 +311,12 @@ void RegressionCurveItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemS
}
break;
+ case SCHATTR_REGRESSION_MOVING_TYPE:
+ {
+ lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAverageType");
+ }
+ break;
+
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "ShowEquation");
diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index c0691daf24cf..d9ec4ea1f534 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -447,6 +447,13 @@ bool StatisticsItemConverter::ApplySpecialItem(
}
break;
+ case SCHATTR_REGRESSION_MOVING_TYPE:
+ {
+ uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
+ bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAverageType");
+ }
+ break;
+
case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
{
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
@@ -729,6 +736,13 @@ void StatisticsItemConverter::FillSpecialItem(
}
break;
+ case SCHATTR_REGRESSION_MOVING_TYPE:
+ {
+ uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
+ lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAverageType");
+ }
+ break;
+
case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
{
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
diff --git a/chart2/source/inc/LinearRegressionCurveCalculator.hxx b/chart2/source/inc/LinearRegressionCurveCalculator.hxx
index accc43c06294..57d85a24f884 100644
--- a/chart2/source/inc/LinearRegressionCurveCalculator.hxx
+++ b/chart2/source/inc/LinearRegressionCurveCalculator.hxx
@@ -34,7 +34,8 @@ private:
sal_Int32 aDegree,
sal_Bool aForceIntercept,
double aInterceptValue,
- sal_Int32 aPeriod) override;
+ sal_Int32 aPeriod,
+ sal_Int32 nMovingType) override;
virtual css::uno::Sequence<css::geometry::RealPoint2D> SAL_CALL getCurveValues(
double min,
diff --git a/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx b/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx
index 0b15ca5e817e..8ba5456c2939 100644
--- a/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx
+++ b/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx
@@ -19,6 +19,7 @@
#pragma once
#include "RegressionCurveCalculator.hxx"
+#include "RegressionCalculationHelper.hxx"
#include <vector>
namespace chart
@@ -51,6 +52,9 @@ private:
const css::uno::Reference<css::chart2::XScaling>& xScalingY,
sal_Bool bMaySkipPointsInCalculation ) override;
+ void calculateValues(RegressionCalculationHelper::tDoubleVectorPair aValues, sal_Int32 nPeriod,
+ bool bUseXAvg);
+
std::vector<double> aYList;
std::vector<double> aXList;
};
diff --git a/chart2/source/inc/RegressionCurveCalculator.hxx b/chart2/source/inc/RegressionCurveCalculator.hxx
index 1914c4effea9..6cf1f2914d5b 100644
--- a/chart2/source/inc/RegressionCurveCalculator.hxx
+++ b/chart2/source/inc/RegressionCurveCalculator.hxx
@@ -62,13 +62,15 @@ protected:
double mInterceptValue;
sal_Int32 mPeriod;
OUString mXName, mYName;
+ sal_Int32 mnMovingType;
// ____ XRegressionCurveCalculator ____
virtual void SAL_CALL setRegressionProperties(
sal_Int32 aDegree,
sal_Bool aForceIntercept,
double aInterceptValue,
- sal_Int32 aPeriod) override;
+ sal_Int32 aPeriod,
+ sal_Int32 nMovingType) override;
virtual void SAL_CALL recalculateRegression(
const css::uno::Sequence< double >& aXValues,
diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx
index 7ed412ce4500..55fec55872f3 100644
--- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx
+++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx
@@ -191,7 +191,8 @@ constexpr TypedWhichId<SvxDoubleItem> SCHATTR_REGRESSION_INTERCEPT_VALUE
constexpr TypedWhichId<SfxStringItem> SCHATTR_REGRESSION_CURVE_NAME (SCHATTR_REGRESSION_START + 9);
constexpr TypedWhichId<SfxStringItem> SCHATTR_REGRESSION_XNAME (SCHATTR_REGRESSION_START + 10);
constexpr TypedWhichId<SfxStringItem> SCHATTR_REGRESSION_YNAME (SCHATTR_REGRESSION_START + 11);
-constexpr sal_uInt16 SCHATTR_REGRESSION_END (SCHATTR_REGRESSION_YNAME);
+constexpr TypedWhichId<SfxInt32Item> SCHATTR_REGRESSION_MOVING_TYPE (SCHATTR_REGRESSION_START + 12);
+constexpr sal_uInt16 SCHATTR_REGRESSION_END (SCHATTR_REGRESSION_MOVING_TYPE);
constexpr sal_uInt16 SCHATTR_END (SCHATTR_REGRESSION_END);
diff --git a/chart2/source/tools/LinearRegressionCurveCalculator.cxx b/chart2/source/tools/LinearRegressionCurveCalculator.cxx
index 9cf3492d8e8e..811381507cb6 100644
--- a/chart2/source/tools/LinearRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/LinearRegressionCurveCalculator.cxx
@@ -35,13 +35,15 @@ void LinearRegressionCurveCalculator::setRegressionProperties(
sal_Int32 /*aDegree*/,
sal_Bool aForceIntercept,
double aInterceptValue,
- sal_Int32 aPeriod )
+ sal_Int32 aPeriod,
+ sal_Int32 /*nMovingType*/)
{
PolynomialRegressionCurveCalculator::setRegressionProperties(
1,
aForceIntercept,
aInterceptValue,
- aPeriod);
+ aPeriod,
+ 0);
}
uno::Sequence< geometry::RealPoint2D > SAL_CALL LinearRegressionCurveCalculator::getCurveValues(
diff --git a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx
index 7774bec02a4f..bca154047935 100644
--- a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx
@@ -24,7 +24,10 @@
#include <rtl/math.hxx>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
+
using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
namespace chart
{
@@ -47,25 +50,59 @@ void SAL_CALL MovingAverageRegressionCurveCalculator::recalculateRegression(
aXValues, aYValues,
RegressionCalculationHelper::isValid()));
- const size_t aSize = aValues.first.size();
-
aYList.clear();
aXList.clear();
- for( size_t i = mPeriod - 1; i < aSize; ++i )
+ switch (mnMovingType)
+ {
+ case MovingAverageType::Central:
+ {
+ sal_Int32 nCentralPeriod = (mPeriod % 2 == 0) ? (mPeriod / 2) : ((mPeriod - 1) / 2);
+ calculateValues(aValues, nCentralPeriod, false);
+ break;
+ }
+
+ case MovingAverageType::AveragedAbscissa:
+ {
+ calculateValues(aValues, mPeriod, true);
+ break;
+ }
+ case MovingAverageType::Prior:
+ default:
+ {
+ calculateValues(aValues, mPeriod, false);
+ break;
+ }
+ }
+}
+
+void MovingAverageRegressionCurveCalculator::calculateValues(
+ RegressionCalculationHelper::tDoubleVectorPair aValues, sal_Int32 nPeriod, bool bUseXAvg)
+{
+ const size_t aSize = aValues.first.size();
+ for (size_t i = nPeriod - 1; i < aSize; ++i)
{
- double yAvg;
- yAvg = 0.0;
+ double xAvg = 0.0;
+ double yAvg = 0.0;
- for (sal_Int32 j = 0; j < mPeriod; j++)
+ for (sal_Int32 j = 0; j < nPeriod; j++)
{
+ xAvg += aValues.first[i - j];
yAvg += aValues.second[i - j];
}
- yAvg /= mPeriod;
+ yAvg /= nPeriod;
+ xAvg /= nPeriod;
- double x = aValues.first[i];
aYList.push_back(yAvg);
- aXList.push_back(x);
+ if (bUseXAvg)
+ {
+ aXList.push_back(xAvg);
+ }
+ else
+ {
+ double x = aValues.first[i];
+ aXList.push_back(x);
+ }
}
}
diff --git a/chart2/source/tools/RegressionCurveCalculator.cxx b/chart2/source/tools/RegressionCurveCalculator.cxx
index ba8a7423c01e..c27a47e502cd 100644
--- a/chart2/source/tools/RegressionCurveCalculator.cxx
+++ b/chart2/source/tools/RegressionCurveCalculator.cxx
@@ -72,12 +72,14 @@ void RegressionCurveCalculator::setRegressionProperties(
sal_Int32 aDegree,
sal_Bool aForceIntercept,
double aInterceptValue,
- sal_Int32 aPeriod )
+ sal_Int32 aPeriod,
+ sal_Int32 nMovingType )
{
mDegree = aDegree;
mForceIntercept = aForceIntercept;
mInterceptValue = aInterceptValue;
mPeriod = aPeriod;
+ mnMovingType = nMovingType;
}
OUString RegressionCurveCalculator::getFormattedString(
diff --git a/chart2/source/tools/RegressionCurveModel.cxx b/chart2/source/tools/RegressionCurveModel.cxx
index 649e93e2702f..0fb7662830af 100644
--- a/chart2/source/tools/RegressionCurveModel.cxx
+++ b/chart2/source/tools/RegressionCurveModel.cxx
@@ -44,7 +44,8 @@ enum
PROPERTY_EXTRAPOLATE_BACKWARD,
PROPERTY_FORCE_INTERCEPT,
PROPERTY_INTERCEPT_VALUE,
- PROPERTY_CURVE_NAME
+ PROPERTY_CURVE_NAME,
+ PROPERTY_MOVING_AVERAGE_TYPE
};
void lcl_AddPropertiesToVector(
@@ -62,6 +63,12 @@ void lcl_AddPropertiesToVector(
beans::PropertyAttribute::BOUND |
beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "MovingAverageType",
+ PROPERTY_MOVING_AVERAGE_TYPE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND |
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
rOutProperties.emplace_back( "ExtrapolateForward",
PROPERTY_EXTRAPOLATE_FORWARD,
cppu::UnoType<double>::get(),
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index c235148a2045..39a97c618a47 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -56,6 +56,7 @@
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <com/sun/star/chart/TimeUnit.hpp>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/container/XChild.hpp>
@@ -1335,6 +1336,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries const & rVDataSer
sal_Int32 aDegree = 2;
sal_Int32 aPeriod = 2;
+ sal_Int32 aMovingAverageType = css::chart2::MovingAverageType::Prior;
double aExtrapolateForward = 0.0;
double aExtrapolateBackward = 0.0;
bool bForceIntercept = false;
@@ -1344,6 +1346,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries const & rVDataSer
{
xProperties->getPropertyValue( "PolynomialDegree") >>= aDegree;
xProperties->getPropertyValue( "MovingAveragePeriod") >>= aPeriod;
+ xProperties->getPropertyValue( "MovingAverageType") >>= aMovingAverageType;
xProperties->getPropertyValue( "ExtrapolateForward") >>= aExtrapolateForward;
xProperties->getPropertyValue( "ExtrapolateBackward") >>= aExtrapolateBackward;
xProperties->getPropertyValue( "ForceIntercept") >>= bForceIntercept;
@@ -1370,8 +1373,9 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries const & rVDataSer
fPointScale = std::min(fPointScale, 1000.0);
}
- xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, aPeriod);
- xCalculator->recalculateRegression( rVDataSeries.getAllX(), rVDataSeries.getAllY() );
+ xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, aPeriod,
+ aMovingAverageType);
+ xCalculator->recalculateRegression(rVDataSeries.getAllX(), rVDataSeries.getAllY());
sal_Int32 nPointCount = 100 * fPointScale;
if ( nPointCount < 2 )
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx
index 7f67cdde45ca..8b5bade3ebc3 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -31,6 +31,7 @@
#include <vector>
#include <com/sun/star/chart2/LegendPosition.hpp>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
namespace chart
{
@@ -165,6 +166,7 @@ ChartItemPool::ChartItemPool():
rPoolDefaults[SCHATTR_REGRESSION_CURVE_NAME - SCHATTR_START] = new SfxStringItem(SCHATTR_REGRESSION_CURVE_NAME, OUString());
rPoolDefaults[SCHATTR_REGRESSION_XNAME - SCHATTR_START] = new SfxStringItem(SCHATTR_REGRESSION_XNAME, "x");
rPoolDefaults[SCHATTR_REGRESSION_YNAME - SCHATTR_START] = new SfxStringItem(SCHATTR_REGRESSION_YNAME, "f(x)");
+ rPoolDefaults[SCHATTR_REGRESSION_MOVING_TYPE - SCHATTR_START] = new SfxInt32Item(SCHATTR_REGRESSION_MOVING_TYPE, css::chart2::MovingAverageType::Prior);
/**************************************************************************
* ItemInfos
diff --git a/chart2/uiconfig/ui/tp_Trendline.ui b/chart2/uiconfig/ui/tp_Trendline.ui
index ed7e4fecf934..486d67e57994 100644
--- a/chart2/uiconfig/ui/tp_Trendline.ui
+++ b/chart2/uiconfig/ui/tp_Trendline.ui
@@ -32,6 +32,23 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkListStore" id="liststore_moving_type">
+ <columns>
+ <!-- column-name moving_type -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes" context="tp_Trendline|liststore_moving_type">Prior</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" context="tp_Trendline|liststore_moving_type">Central</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" context="tp_Trendline|liststore_moving_type">Averaged Abscissa</col>
+ </row>
+ </data>
+ </object>
<object class="GtkBox" id="TP_TRENDLINE">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -47,16 +64,15 @@
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
- <!-- n-columns=1 n-rows=1 -->
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
+ <property name="margin_start">12</property>
+ <property name="margin_top">6</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<property name="row_homogeneous">True</property>
- <property name="margin-start">12</property>
- <property name="margin-top">6</property>
<child>
<object class="GtkRadioButton" id="linear">
<property name="label" translatable="yes" context="tp_Trendline|linear">_Linear</property>
@@ -183,7 +199,6 @@
</packing>
</child>
<child>
- <!-- n-columns=1 n-rows=1 -->
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -211,8 +226,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
+ <property name="truncate_multiline">True</property>
<property name="adjustment">adjustmentDegree</property>
- <property name="truncate-multiline">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="degree-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="tp_Trendline|extended_tip|degree">Degree of polynomial trend line.</property>
@@ -231,7 +246,6 @@
</packing>
</child>
<child>
- <!-- n-columns=1 n-rows=1 -->
<object class="GtkGrid" id="grid3">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -259,8 +273,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
+ <property name="truncate_multiline">True</property>
<property name="adjustment">adjustmentPeriod</property>
- <property name="truncate-multiline">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="period-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="tp_Trendline|extended_tip|period">Number of points to calculate average of moving average trend line.</property>
@@ -282,7 +296,7 @@
<object class="GtkImage" id="imageLinear">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon-name">missing-image</property>
+ <property name="icon_name">missing-image</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -293,7 +307,7 @@
<object class="GtkImage" id="imageLogarithmic">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon-name">missing-image</property>
+ <property name="icon_name">missing-image</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -304,7 +318,7 @@
<object class="GtkImage" id="imageExponential">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon-name">missing-image</property>
+ <property name="icon_name">missing-image</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -315,7 +329,7 @@
<object class="GtkImage" id="imagePower">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon-name">missing-image</property>
+ <property name="icon_name">missing-image</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -326,7 +340,7 @@
<object class="GtkImage" id="imagePolynomial">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon-name">missing-image</property>
+ <property name="icon_name">missing-image</property>
</object>
<packing>
<property name="left_attach">2</property>
@@ -337,7 +351,7 @@
<object class="GtkImage" id="imageMovingAverage">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon-name">missing-image</property>
+ <property name="icon_name">missing-image</property>
</object>
<packing>
<property name="left_attach">2</property>
@@ -376,15 +390,14 @@
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
- <!-- n-columns=1 n-rows=1 -->
<object class="GtkGrid" id="grid5">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="margin_start">12</property>
+ <property name="margin_top">6</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<property name="row_homogeneous">True</property>
- <property name="margin-start">12</property>
- <property name="margin-top">6</property>
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
@@ -428,9 +441,9 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
+ <property name="truncate_multiline">True</property>
<property name="caps_lock_warning">False</property>
<property name="adjustment">adjustmentForwardBackward</property>
- <property name="truncate-multiline">True</property>
<property name="digits">2</property>
</object>
<packing>
@@ -443,8 +456,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
+ <property name="truncate_multiline">True</property>
<property name="adjustment">adjustmentForwardBackward1</property>
- <property name="truncate-multiline">True</property>
<property name="digits">2</property>
</object>
<packing>
@@ -538,7 +551,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
- <property name="truncate-multiline">True</property>
+ <property name="truncate_multiline">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="entry_name-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="tp_Trendline|extended_tip|entry_name">Name of trend line in legend.</property>
@@ -556,6 +569,7 @@
<property name="can_focus">True</property>
<property name="activates_default">True</property>
<property name="text">0</property>
+ <property name="truncate_multiline">True</property>
<property name="caps_lock_warning">False</property>
<property name="input_purpose">number</property>
<property name="adjustment">adjustmentForwardBackward2</property>
@@ -563,7 +577,6 @@
<accessibility>
<relation type="labelled-by" target="setIntercept"/>
</accessibility>
- <property name="truncate-multiline">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="interceptValue-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="tp_Trendline|extended_tip|interceptValue">Value of intercept if it is forced.</property>
@@ -591,7 +604,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
</packing>
</child>
<child>
@@ -599,7 +612,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
- <property name="truncate-multiline">True</property>
+ <property name="truncate_multiline">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="entry_Xname-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="tp_Trendline|extended_tip|entry_Xname">Name of X variable in trend line equation.</property>
@@ -608,7 +621,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
</packing>
</child>
<child>
@@ -627,7 +640,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">8</property>
</packing>
</child>
<child>
@@ -635,7 +648,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
- <property name="truncate-multiline">True</property>
+ <property name="truncate_multiline">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="entry_Yname-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="tp_Trendline|extended_tip|entry_Yname">Name of Y variable in trend line equation.</property>
@@ -644,7 +657,37 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">8</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="tp_Trendline|label10">Moving _Type</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">combo_moving_type</property>
+ <property name="xalign">0</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="label10-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="tp_Trendline|extended_tip|label10">How the trend line is calculated.</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="combo_moving_type">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">liststore_moving_type</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">6</property>
</packing>
</child>
</object>
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 88515ae67e9d..bc18f6230293 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -290,6 +290,7 @@ namespace xmloff::token {
XML_AUTOMATIC_UPDATE,
XML_AUTOSIZE,
XML_AVERAGE,
+ XML_AVERAGED_ABSCISSA,
XML_AXIS,
XML_AXIS_COLOR,
XML_BACK_SCALE,
@@ -397,6 +398,7 @@ namespace xmloff::token {
XML_CELL_RANGE_ADDRESS_LIST,
XML_CELL_RANGE_SOURCE,
XML_CENTER,
+ XML_CENTRAL,
XML_CHAIN_NEXT_NAME,
XML_CHANGE,
XML_CHANGE_DELETION,
@@ -1514,6 +1516,7 @@ namespace xmloff::token {
XML_PRINT_TIME,
XML_PRINTABLE,
XML_PRINTED_BY,
+ XML_PRIOR,
XML_PROCEEDINGS,
XML_PRODUCT,
XML_PROJECTION,
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 5e2384552b5b..020149df1311 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -653,6 +653,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,com/sun/star/chart2,\
GridProperties \
Legend \
LogicTargetModel \
+ MovingAverageType \
PropertyPool \
RegressionCurve \
RegressionCurveEquation \
diff --git a/offapi/com/sun/star/chart2/MovingAverageType.idl b/offapi/com/sun/star/chart2/MovingAverageType.idl
new file mode 100644
index 000000000000..3b2ff6c22ca0
--- /dev/null
+++ b/offapi/com/sun/star/chart2/MovingAverageType.idl
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#ifndef com_sun_star_chart2_MovingAverageType_idl
+#define com_sun_star_chart2_MovingAverageType_idl
+
+module com
+{
+module sun
+{
+module star
+{
+module chart2
+{
+
+constants MovingAverageType {
+ const long Prior = 1;
+ const long Central = 2;
+ const long AveragedAbscissa = 3;
+};
+
+} ; // chart2
+} ; // com
+} ; // sun
+} ; // star
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/offapi/com/sun/star/chart2/RegressionCurve.idl b/offapi/com/sun/star/chart2/RegressionCurve.idl
index 72c2684180cd..3ba881465a6c 100644
--- a/offapi/com/sun/star/chart2/RegressionCurve.idl
+++ b/offapi/com/sun/star/chart2/RegressionCurve.idl
@@ -39,6 +39,8 @@ service RegressionCurve
service ::com::sun::star::drawing::LineProperties;
interface XRegressionCurve;
+
+ [property] long MovingAverageType;
};
} ; // chart2
diff --git a/offapi/com/sun/star/chart2/XRegressionCurveCalculator.idl b/offapi/com/sun/star/chart2/XRegressionCurveCalculator.idl
index 8162b8cfb781..c4313f42b30d 100644
--- a/offapi/com/sun/star/chart2/XRegressionCurveCalculator.idl
+++ b/offapi/com/sun/star/chart2/XRegressionCurveCalculator.idl
@@ -52,11 +52,16 @@ interface XRegressionCurveCalculator : com::sun::star::uno::XInterface
@param interceptValue
Intercept value.
+ @param movingType
+ Only if regression type is "Moving Average"
+ @see ::com::sun::star::chart2::MovingAverageType
+
*/
void setRegressionProperties( [in] long degree,
[in] boolean forceIntercept,
[in] double interceptValue,
- [in] long period);
+ [in] long period,
+ [in] long movingType);
/** recalculates the parameters of the internal regression curve according to
the <i>x</i>- and <i>y</i>-values given.
diff --git a/xmloff/source/chart/PropertyMap.hxx b/xmloff/source/chart/PropertyMap.hxx
index 08c05923e861..c35e34b83dbe 100644
--- a/xmloff/source/chart/PropertyMap.hxx
+++ b/xmloff/source/chart/PropertyMap.hxx
@@ -84,6 +84,7 @@
#define XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE ( XML_SCH_CTF_START + 25 )
#define XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE ( XML_SCH_CTF_START + 26 )
#define XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SERIES ( XML_SCH_CTF_START + 27 )
+#define XML_SCH_CONTEXT_SPECIAL_MOVING_AVERAGE_TYPE ( XML_SCH_CTF_START + 28 )
#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, false }
#define MAP_ENTRY( a, ns, nm, t ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFSVER_010, false }
@@ -214,6 +215,8 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
// regression curve properties
MAP_SPECIAL( "RegressionType", CHART, XML_REGRESSION_TYPE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE ),
+ MAP_SPECIAL_ODF13( "MovingAverageType", LO_EXT, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_MOVING_AVERAGE_TYPE ),
+ MAP_SPECIAL_ODF13( "MovingAverageType", CHART, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_MOVING_AVERAGE_TYPE ),
// ODF 1.3 OFFICE-3958
MAP_ENTRY_ODF13( "CurveName", XML_NAMESPACE_LO_EXT, XML_REGRESSION_CURVE_NAME, XML_TYPE_STRING ),
@@ -228,8 +231,6 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
// ODF 1.3 OFFICE-3959
MAP_ENTRY_ODF13( "MovingAveragePeriod", XML_NAMESPACE_LO_EXT, XML_REGRESSION_PERIOD, XML_TYPE_NUMBER ),
MAP_ENTRY_ODF13( "MovingAveragePeriod", XML_NAMESPACE_CHART, XML_REGRESSION_PERIOD, XML_TYPE_NUMBER ),
- MAP_ENTRY_ODF13( "MovingAverageType", XML_NAMESPACE_LO_EXT, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING ),
- MAP_ENTRY_ODF13( "MovingAverageType", XML_NAMESPACE_CHART, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING ),
MAP_ENTRY_ODF_EXT( "ExtrapolateForward", LO_EXT, XML_REGRESSION_EXTRAPOLATE_FORWARD, XML_TYPE_DOUBLE ),
MAP_ENTRY_ODF_EXT( "ExtrapolateBackward", LO_EXT, XML_REGRESSION_EXTRAPOLATE_BACKWARD, XML_TYPE_DOUBLE ),
diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx
index f93747b93794..f63d04c45fd4 100644
--- a/xmloff/source/chart/PropertyMaps.cxx
+++ b/xmloff/source/chart/PropertyMaps.cxx
@@ -50,6 +50,7 @@
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/chart/ChartAxisMarks.hpp>
#include <com/sun/star/chart/ChartDataCaption.hpp>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
@@ -61,6 +62,7 @@
using namespace com::sun::star;
using namespace ::xmloff::token;
+using namespace css::chart2;
namespace {
@@ -516,6 +518,20 @@ void XMLChartExportPropertyMapper::handleSpecialItem(
}
break;
+ case XML_SCH_CONTEXT_SPECIAL_MOVING_AVERAGE_TYPE:
+ {
+ rProperty.maValue >>= nValue;
+ if (nValue == MovingAverageType::Prior)
+ sValueBuffer.append( GetXMLToken( XML_PRIOR ));
+ else if (nValue == MovingAverageType::Central)
+ sValueBuffer.append( GetXMLToken( XML_CENTRAL ));
+ else if (nValue == MovingAverageType::AveragedAbscissa)
+ sValueBuffer.append( GetXMLToken( XML_AVERAGED_ABSCISSA ));
+ else // default
+ sValueBuffer.append( GetXMLToken( XML_PRIOR ));
+ }
+ break;
+
default:
bHandled = false;
break;
@@ -698,6 +714,19 @@ bool XMLChartImportPropertyMapper::handleSpecialItem(
}
break;
+ case XML_SCH_CONTEXT_SPECIAL_MOVING_AVERAGE_TYPE:
+ {
+ if (IsXMLToken( rValue, XML_PRIOR ))
+ rProperty.maValue <<= MovingAverageType::Prior;
+ else if (IsXMLToken( rValue, XML_CENTRAL))
+ rProperty.maValue <<= MovingAverageType::Central;
+ else if (IsXMLToken( rValue, XML_AVERAGED_ABSCISSA))
+ rProperty.maValue <<= MovingAverageType::AveragedAbscissa;
+ else // default
+ rProperty.maValue <<= MovingAverageType::Prior;
+ }
+ break;
+
default:
bRet = false;
break;
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index d46ec76fb7fa..6264eda43b31 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -295,6 +295,7 @@ namespace xmloff::token {
TOKEN( "automatic-update", XML_AUTOMATIC_UPDATE ),
TOKEN( "autosize", XML_AUTOSIZE ),
TOKEN( "average", XML_AVERAGE ),
+ TOKEN( "averaged-abscissa", XML_AVERAGED_ABSCISSA ),
TOKEN( "axis", XML_AXIS ),
TOKEN( "axis-color", XML_AXIS_COLOR ),
TOKEN( "back-scale", XML_BACK_SCALE ),
@@ -402,6 +403,7 @@ namespace xmloff::token {
TOKEN( "cell-range-address-list", XML_CELL_RANGE_ADDRESS_LIST ),
TOKEN( "cell-range-source", XML_CELL_RANGE_SOURCE ),
TOKEN( "center", XML_CENTER ),
+ TOKEN( "central", XML_CENTRAL ),
TOKEN( "chain-next-name", XML_CHAIN_NEXT_NAME ),
TOKEN( "change", XML_CHANGE ),
TOKEN( "change-deletion", XML_CHANGE_DELETION ),
@@ -1520,6 +1522,7 @@ namespace xmloff::token {
TOKEN( "print-time", XML_PRINT_TIME ),
TOKEN( "printable", XML_PRINTABLE ),
TOKEN( "printed-by", XML_PRINTED_BY ),
+ TOKEN( "prior", XML_PRIOR ),
TOKEN( "proceedings", XML_PROCEEDINGS ),
TOKEN( "product", XML_PRODUCT ),
TOKEN( "projection", XML_PROJECTION ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index dcf905ba40e6..503fadc0cca9 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -210,6 +210,7 @@ automatic-styles
automatic-update
autosize
average
+averaged-abscissa
axis
axis-color
back-scale
@@ -317,6 +318,7 @@ cell-range-address
cell-range-address-list
cell-range-source
center
+central
chain-next-name
change
change-deletion
@@ -1430,6 +1432,7 @@ print-ranges
print-time
printable
printed-by
+prior
proceedings
product
projection