Kaydet (Commit) 9c5e2c65 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Import/export of polynomial and moving average for old MS XP/2003 format

Also make new services work, so they can be used in filters.

Change-Id: If4ebd86b2b7bc4fc43d36109f05d06d42c531dab
üst c61a0a33
......@@ -144,6 +144,22 @@ static struct ::cppu::ImplementationEntry g_entries_chart2_tools[] =
, 0
, 0
}
,{
::chart::PolynomialRegressionCurve::create
, ::chart::PolynomialRegressionCurve::getImplementationName_Static
, ::chart::PolynomialRegressionCurve::getSupportedServiceNames_Static
, ::cppu::createSingleComponentFactory
, 0
, 0
}
,{
::chart::MovingAverageRegressionCurve::create
, ::chart::MovingAverageRegressionCurve::getImplementationName_Static
, ::chart::MovingAverageRegressionCurve::getSupportedServiceNames_Static
, ::cppu::createSingleComponentFactory
, 0
, 0
}
,{
::chart::RegressionEquation::create
, ::chart::RegressionEquation::getImplementationName_Static
......
......@@ -87,8 +87,10 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/chart2,\
LogarithmicScaling \
LinearRegressionCurve \
LinearScaling \
MovingAverageRegressionCurve \
PolarCoordinateSystem2d \
PolarCoordinateSystem3d \
PolynomialRegressionCurve \
PotentialRegressionCurve \
PowerScaling \
RegressionEquation \
......
/* -*- 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 com_sun_star_chart2_MovingAverageRegressionCurve_idl
#define com_sun_star_chart2_MovingAverageRegressionCurve_idl
#include <com/sun/star/chart2/XRegressionCurve.idl>
module com { module sun { module star { module chart2 {
/**
@since LibreOffice 4.1
*/
service MovingAverageRegressionCurve : com::sun::star::chart2::XRegressionCurve;
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 com_sun_star_chart2_PolynomialRegressionCurve_idl
#define com_sun_star_chart2_PolynomialRegressionCurve_idl
#include <com/sun/star/chart2/XRegressionCurve.idl>
module com { module sun { module star { module chart2 {
/**
@since LibreOffice 4.1
*/
service PolynomialRegressionCurve : com::sun::star::chart2::XRegressionCurve;
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -1698,13 +1698,38 @@ bool XclExpChSerTrendLine::Convert( Reference< XRegressionCurve > xRegCurve, sal
maData.mnOrder = 1;
}
else if( aService == "com.sun.star.chart2.ExponentialRegressionCurve" )
{
maData.mnLineType = EXC_CHSERTREND_EXPONENTIAL;
}
else if( aService == "com.sun.star.chart2.LogarithmicRegressionCurve" )
{
maData.mnLineType = EXC_CHSERTREND_LOGARITHMIC;
}
else if( aService == "com.sun.star.chart2.PotentialRegressionCurve" )
{
maData.mnLineType = EXC_CHSERTREND_POWER;
}
else if( aService == "com.sun.star.chart2.PolynomialRegressionCurve" )
{
maData.mnLineType = EXC_CHSERTREND_POLYNOMIAL;
sal_Int32 aDegree;
aCurveProp.GetProperty(aDegree, EXC_CHPROP_POLYNOMIAL_DEGREE);
maData.mnOrder = static_cast<sal_uInt8> (aDegree);
}
else if( aService == "com.sun.star.chart2.MovingAverageRegressionCurve" )
{
maData.mnLineType = EXC_CHSERTREND_MOVING_AVG;
sal_Int32 aPeriod;
aCurveProp.GetProperty(aPeriod, EXC_CHPROP_MOVING_AVERAGE_PERIOD);
maData.mnOrder = static_cast<sal_uInt8> (aPeriod);
}
else
{
return false;
}
aCurveProp.GetProperty(maData.mfForecastFor, EXC_CHPROP_EXTRAPOLATE_FORWARD);
aCurveProp.GetProperty(maData.mfForecastBack, EXC_CHPROP_EXTRAPOLATE_BACKWARD);
// line formatting
XclChDataPointPos aPointPos( nSeriesIdx );
......
......@@ -44,6 +44,8 @@
#include <com/sun/star/chart2/ExponentialRegressionCurve.hpp>
#include <com/sun/star/chart2/LogarithmicRegressionCurve.hpp>
#include <com/sun/star/chart2/PotentialRegressionCurve.hpp>
#include <com/sun/star/chart2/PolynomialRegressionCurve.hpp>
#include <com/sun/star/chart2/MovingAverageRegressionCurve.hpp>
#include <com/sun/star/chart2/CartesianCoordinateSystem2d.hpp>
#include <com/sun/star/chart2/CartesianCoordinateSystem3d.hpp>
#include <com/sun/star/chart2/FormattedString.hpp>
......@@ -1616,9 +1618,12 @@ Reference< XRegressionCurve > XclImpChSerTrendLine::CreateRegressionCurve() cons
switch( maData.mnLineType )
{
case EXC_CHSERTREND_POLYNOMIAL:
// TODO: only linear trend lines are supported by OOChart (#i20819#)
if( maData.mnOrder == 1 )
{
xRegCurve = LinearRegressionCurve::create( comphelper::getProcessComponentContext() );
} else {
xRegCurve = PolynomialRegressionCurve::create( comphelper::getProcessComponentContext() );
}
break;
case EXC_CHSERTREND_EXPONENTIAL:
xRegCurve = ExponentialRegressionCurve::create( comphelper::getProcessComponentContext() );
......@@ -1629,6 +1634,9 @@ Reference< XRegressionCurve > XclImpChSerTrendLine::CreateRegressionCurve() cons
case EXC_CHSERTREND_POWER:
xRegCurve = PotentialRegressionCurve::create( comphelper::getProcessComponentContext() );
break;
case EXC_CHSERTREND_MOVING_AVG:
xRegCurve = MovingAverageRegressionCurve::create( comphelper::getProcessComponentContext() );
break;
}
// trend line formatting
......@@ -1637,6 +1645,11 @@ Reference< XRegressionCurve > XclImpChSerTrendLine::CreateRegressionCurve() cons
ScfPropertySet aPropSet( xRegCurve );
mxDataFmt->ConvertLine( aPropSet, EXC_CHOBJTYPE_TRENDLINE );
aPropSet.SetProperty(EXC_CHPROP_POLYNOMIAL_DEGREE, static_cast<sal_Int32> (maData.mnOrder) );
aPropSet.SetProperty(EXC_CHPROP_MOVING_AVERAGE_PERIOD, static_cast<sal_Int32> (maData.mnOrder) );
aPropSet.SetProperty(EXC_CHPROP_EXTRAPOLATE_FORWARD, maData.mfForecastFor);
aPropSet.SetProperty(EXC_CHPROP_EXTRAPOLATE_BACKWARD, maData.mfForecastBack);
// #i83100# show equation and correlation coefficient
ScfPropertySet aLabelProp( xRegCurve->getEquationProperties() );
aLabelProp.SetBoolProperty( EXC_CHPROP_SHOWEQUATION, maData.mnShowEquation != 0 );
......
......@@ -83,6 +83,8 @@ class XclRoot;
#define EXC_CHPROP_ERRORBARY "ErrorBarY"
#define EXC_CHPROP_EXPANSION "Expansion"
#define EXC_CHPROP_EXPTIMEINCREMENT "ExplicitTimeIncrement"
#define EXC_CHPROP_EXTRAPOLATE_FORWARD "ExtrapolateForward"
#define EXC_CHPROP_EXTRAPOLATE_BACKWARD "ExtrapolateBackward"
#define EXC_CHPROP_FILLBITMAPMODE "FillBitmapMode"
#define EXC_CHPROP_FILLSTYLE "FillStyle"
#define EXC_CHPROP_GAPWIDTHSEQ "GapwidthSequence"
......@@ -98,6 +100,7 @@ class XclRoot;
#define EXC_CHPROP_MARKPOSITION "MarkPosition"
#define EXC_CHPROP_MINORTICKS "MinorTickmarks"
#define EXC_CHPROP_MISSINGVALUETREATMENT "MissingValueTreatment"
#define EXC_CHPROP_MOVING_AVERAGE_PERIOD "MovingAveragePeriod"
#define EXC_CHPROP_NEGATIVEERROR "NegativeError"
#define EXC_CHPROP_NUMBERFORMAT "NumberFormat"
#define EXC_CHPROP_OFFSET "Offset"
......@@ -106,6 +109,7 @@ class XclRoot;
#define EXC_CHPROP_PERCENTDIAGONAL "PercentDiagonal"
#define EXC_CHPROP_PERSPECTIVE "Perspective"
#define EXC_CHPROP_POSITIVEERROR "PositiveError"
#define EXC_CHPROP_POLYNOMIAL_DEGREE "PolynomialDegree"
#define EXC_CHPROP_RELATIVEPOSITION "RelativePosition"
#define EXC_CHPROP_RELATIVESIZE "RelativeSize"
#define EXC_CHPROP_RIGHTANGLEDAXES "RightAngledAxes"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment