2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2008-02-18 14:48:09 +00:00
|
|
|
|
|
|
|
#include "res_Trendline.hxx"
|
|
|
|
#include "ResId.hxx"
|
|
|
|
#include "Strings.hrc"
|
2017-04-25 15:35:10 +01:00
|
|
|
#include "bitmaps.hlst"
|
2008-02-18 14:48:09 +00:00
|
|
|
#include "chartview/ChartSfxItemIds.hxx"
|
|
|
|
|
2013-05-27 08:02:37 +02:00
|
|
|
#include <svl/intitem.hxx>
|
2013-11-23 16:06:28 +01:00
|
|
|
#include <svl/stritem.hxx>
|
2013-11-11 15:55:47 +01:00
|
|
|
#include <sfx2/tabdlg.hxx>
|
2013-05-27 08:02:37 +02:00
|
|
|
|
2008-02-18 14:48:09 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
namespace chart
|
|
|
|
{
|
|
|
|
|
2013-12-02 09:54:21 +01:00
|
|
|
void lcl_setValue( FormattedField& rFmtField, double fValue )
|
|
|
|
{
|
|
|
|
rFmtField.SetValue( fValue );
|
|
|
|
rFmtField.SetDefaultValue( fValue );
|
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
TrendlineResources::TrendlineResources( vcl::Window * pParent, const SfxItemSet& rInAttrs ) :
|
2016-08-24 13:21:36 +02:00
|
|
|
m_eTrendLineType( SvxChartRegress::Linear ),
|
2013-12-02 09:54:21 +01:00
|
|
|
m_bTrendLineUnique( true ),
|
2015-11-10 10:11:17 +01:00
|
|
|
m_pNumFormatter( nullptr ),
|
2014-04-21 22:03:23 +02:00
|
|
|
m_nNbPoints( 0 )
|
2008-02-18 14:48:09 +00:00
|
|
|
{
|
2013-11-23 16:06:28 +01:00
|
|
|
SfxTabPage* pTabPage = reinterpret_cast<SfxTabPage*>(pParent);
|
|
|
|
pTabPage->get(m_pRB_Linear,"linear");
|
|
|
|
pTabPage->get(m_pRB_Logarithmic,"logarithmic");
|
|
|
|
pTabPage->get(m_pRB_Exponential,"exponential");
|
|
|
|
pTabPage->get(m_pRB_Power,"power");
|
|
|
|
pTabPage->get(m_pRB_Polynomial,"polynomial");
|
|
|
|
pTabPage->get(m_pRB_MovingAverage,"movingAverage");
|
|
|
|
pTabPage->get(m_pNF_Degree,"degree");
|
|
|
|
pTabPage->get(m_pNF_Period,"period");
|
|
|
|
pTabPage->get(m_pEE_Name,"entry_name");
|
2013-12-13 07:25:20 +01:00
|
|
|
pTabPage->get(m_pFmtFld_ExtrapolateForward,"extrapolateForward");
|
|
|
|
pTabPage->get(m_pFmtFld_ExtrapolateBackward,"extrapolateBackward");
|
2013-11-23 16:06:28 +01:00
|
|
|
pTabPage->get(m_pCB_SetIntercept,"setIntercept");
|
2013-12-02 09:54:21 +01:00
|
|
|
pTabPage->get(m_pFmtFld_InterceptValue,"interceptValue");
|
2013-11-23 16:06:28 +01:00
|
|
|
pTabPage->get(m_pCB_ShowEquation,"showEquation");
|
2016-06-28 23:34:34 +02:00
|
|
|
pTabPage->get(m_pEE_XName,"entry_Xname");
|
|
|
|
pTabPage->get(m_pEE_YName,"entry_Yname");
|
2013-11-23 16:06:28 +01:00
|
|
|
pTabPage->get(m_pCB_ShowCorrelationCoeff,"showCorrelationCoefficient");
|
|
|
|
pTabPage->get(m_pFI_Linear,"imageLinear");
|
|
|
|
pTabPage->get(m_pFI_Logarithmic,"imageLogarithmic");
|
|
|
|
pTabPage->get(m_pFI_Exponential,"imageExponential");
|
|
|
|
pTabPage->get(m_pFI_Power,"imagePower");
|
|
|
|
pTabPage->get(m_pFI_Polynomial,"imagePolynomial");
|
|
|
|
pTabPage->get(m_pFI_MovingAverage,"imageMovingAverage");
|
2008-02-18 14:48:09 +00:00
|
|
|
FillValueSets();
|
|
|
|
|
2015-08-19 09:11:34 +02:00
|
|
|
Link<Button*,void> aLink = LINK(this, TrendlineResources, SelectTrendLine );
|
2013-11-24 22:11:56 +01:00
|
|
|
m_pRB_Linear->SetClickHdl( aLink );
|
|
|
|
m_pRB_Logarithmic->SetClickHdl( aLink );
|
|
|
|
m_pRB_Exponential->SetClickHdl( aLink );
|
|
|
|
m_pRB_Power->SetClickHdl( aLink );
|
|
|
|
m_pRB_Polynomial->SetClickHdl( aLink );
|
|
|
|
m_pRB_MovingAverage->SetClickHdl( aLink );
|
|
|
|
|
2015-10-15 08:13:49 +02:00
|
|
|
Link<Edit&,void> aLink2 = LINK(this, TrendlineResources, ChangeValue );
|
2015-08-19 09:11:34 +02:00
|
|
|
m_pNF_Degree->SetModifyHdl( aLink2 );
|
|
|
|
m_pNF_Period->SetModifyHdl( aLink2 );
|
|
|
|
m_pFmtFld_InterceptValue->SetModifyHdl( aLink2 );
|
2013-05-27 08:02:37 +02:00
|
|
|
|
2016-06-28 23:34:34 +02:00
|
|
|
m_pCB_ShowEquation->SetToggleHdl( LINK(this, TrendlineResources, ShowEquation ) );
|
|
|
|
|
2008-02-18 14:48:09 +00:00
|
|
|
Reset( rInAttrs );
|
|
|
|
UpdateControlStates();
|
|
|
|
}
|
|
|
|
|
|
|
|
TrendlineResources::~TrendlineResources()
|
|
|
|
{}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK( TrendlineResources, SelectTrendLine, Button *, pRadioButton, void )
|
2008-02-18 14:48:09 +00:00
|
|
|
{
|
2013-11-11 15:55:47 +01:00
|
|
|
if( pRadioButton == m_pRB_Linear )
|
2016-08-24 13:21:36 +02:00
|
|
|
m_eTrendLineType = SvxChartRegress::Linear;
|
2013-11-11 15:55:47 +01:00
|
|
|
else if( pRadioButton == m_pRB_Logarithmic )
|
2016-08-24 13:21:36 +02:00
|
|
|
m_eTrendLineType = SvxChartRegress::Log;
|
2013-11-11 15:55:47 +01:00
|
|
|
else if( pRadioButton == m_pRB_Exponential )
|
2016-08-24 13:21:36 +02:00
|
|
|
m_eTrendLineType = SvxChartRegress::Exp;
|
2013-11-11 15:55:47 +01:00
|
|
|
else if( pRadioButton == m_pRB_Power )
|
2016-08-24 13:21:36 +02:00
|
|
|
m_eTrendLineType = SvxChartRegress::Power;
|
2013-11-11 15:55:47 +01:00
|
|
|
else if( pRadioButton == m_pRB_Polynomial )
|
2016-08-24 13:21:36 +02:00
|
|
|
m_eTrendLineType = SvxChartRegress::Polynomial;
|
2013-11-11 15:55:47 +01:00
|
|
|
else if( pRadioButton == m_pRB_MovingAverage )
|
2016-08-24 13:21:36 +02:00
|
|
|
m_eTrendLineType = SvxChartRegress::MovingAverage;
|
2008-02-18 14:48:09 +00:00
|
|
|
m_bTrendLineUnique = true;
|
|
|
|
|
|
|
|
UpdateControlStates();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
|
|
|
|
{
|
2015-11-10 10:11:17 +01:00
|
|
|
const SfxPoolItem *pPoolItem = nullptr;
|
2008-02-18 14:48:09 +00:00
|
|
|
|
2014-09-10 17:53:41 +02:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_CURVE_NAME, true, &pPoolItem ) == SfxItemState::SET )
|
2013-11-23 16:06:28 +01:00
|
|
|
{
|
|
|
|
OUString aName = static_cast< const SfxStringItem* >(pPoolItem)->GetValue();
|
|
|
|
m_pEE_Name->SetText(aName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pEE_Name->SetText("");
|
|
|
|
}
|
2016-06-28 23:34:34 +02:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_XNAME, true, &pPoolItem ) == SfxItemState::SET )
|
|
|
|
{
|
|
|
|
OUString aName = static_cast< const SfxStringItem* >(pPoolItem)->GetValue();
|
|
|
|
m_pEE_XName->SetText(aName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pEE_XName->SetText("x");
|
|
|
|
}
|
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_YNAME, true, &pPoolItem ) == SfxItemState::SET )
|
|
|
|
{
|
|
|
|
OUString aName = static_cast< const SfxStringItem* >(pPoolItem)->GetValue();
|
|
|
|
m_pEE_YName->SetText(aName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pEE_YName->SetText("f(x)");
|
|
|
|
}
|
2013-11-23 16:06:28 +01:00
|
|
|
|
2014-02-19 21:49:02 +01:00
|
|
|
SfxItemState aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_TYPE, true, &pPoolItem );
|
2014-09-10 17:53:41 +02:00
|
|
|
m_bTrendLineUnique = ( aState != SfxItemState::DONTCARE );
|
|
|
|
if( aState == SfxItemState::SET )
|
2008-02-18 14:48:09 +00:00
|
|
|
{
|
|
|
|
const SvxChartRegressItem * pItem = dynamic_cast< const SvxChartRegressItem * >( pPoolItem );
|
|
|
|
if( pItem )
|
2013-05-27 08:02:37 +02:00
|
|
|
{
|
2008-02-18 14:48:09 +00:00
|
|
|
m_eTrendLineType = pItem->GetValue();
|
2013-05-27 08:02:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-10 17:53:41 +02:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_DEGREE, true, &pPoolItem ) == SfxItemState::SET )
|
2013-05-27 08:02:37 +02:00
|
|
|
{
|
|
|
|
sal_Int32 nDegree = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pNF_Degree->SetValue( nDegree );
|
2013-05-27 08:02:37 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pNF_Degree->SetValue( 2 );
|
2013-05-27 08:02:37 +02:00
|
|
|
}
|
|
|
|
|
2014-09-10 17:53:41 +02:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_PERIOD, true, &pPoolItem ) == SfxItemState::SET )
|
2013-05-27 08:02:37 +02:00
|
|
|
{
|
|
|
|
sal_Int32 nPeriod = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pNF_Period->SetValue( nPeriod );
|
2013-05-27 08:02:37 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pNF_Period->SetValue( 2 );
|
2013-05-27 08:02:37 +02:00
|
|
|
}
|
|
|
|
|
2013-12-13 07:25:20 +01:00
|
|
|
double nValue = 0.0;
|
2014-09-10 17:53:41 +02:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD, true, &pPoolItem ) == SfxItemState::SET )
|
2013-05-27 08:02:37 +02:00
|
|
|
{
|
2014-10-21 08:24:48 +02:00
|
|
|
nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ;
|
2013-05-27 08:02:37 +02:00
|
|
|
}
|
2013-12-13 07:25:20 +01:00
|
|
|
lcl_setValue( *m_pFmtFld_ExtrapolateForward, nValue );
|
2013-05-27 08:02:37 +02:00
|
|
|
|
2013-12-13 07:25:20 +01:00
|
|
|
nValue = 0.0;
|
2014-09-10 17:53:41 +02:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, true, &pPoolItem ) == SfxItemState::SET )
|
2013-05-27 08:02:37 +02:00
|
|
|
{
|
2014-10-21 08:24:48 +02:00
|
|
|
nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ;
|
2008-02-18 14:48:09 +00:00
|
|
|
}
|
2013-12-13 07:25:20 +01:00
|
|
|
lcl_setValue( *m_pFmtFld_ExtrapolateBackward, nValue );
|
2008-02-18 14:48:09 +00:00
|
|
|
|
2013-12-13 07:25:20 +01:00
|
|
|
nValue = 0.0;
|
2014-09-10 17:53:41 +02:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_INTERCEPT_VALUE, true, &pPoolItem ) == SfxItemState::SET )
|
2013-06-28 19:49:25 +02:00
|
|
|
{
|
2014-10-21 08:24:48 +02:00
|
|
|
nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ;
|
2013-06-28 19:49:25 +02:00
|
|
|
}
|
2013-12-02 09:54:21 +01:00
|
|
|
lcl_setValue( *m_pFmtFld_InterceptValue, nValue );
|
2013-06-28 19:49:25 +02:00
|
|
|
|
2014-02-19 21:49:02 +01:00
|
|
|
aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SET_INTERCEPT, true, &pPoolItem );
|
2014-09-10 17:53:41 +02:00
|
|
|
if( aState == SfxItemState::DONTCARE )
|
2013-06-28 19:49:25 +02:00
|
|
|
{
|
2015-08-12 15:09:30 +02:00
|
|
|
m_pCB_SetIntercept->EnableTriState();
|
2014-02-24 12:25:02 +01:00
|
|
|
m_pCB_SetIntercept->SetState( TRISTATE_INDET );
|
2013-06-28 19:49:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
m_pCB_SetIntercept->EnableTriState( false );
|
2014-09-10 17:53:41 +02:00
|
|
|
if( aState == SfxItemState::SET )
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pCB_SetIntercept->Check( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue());
|
2013-06-28 19:49:25 +02:00
|
|
|
}
|
|
|
|
|
2014-02-19 21:49:02 +01:00
|
|
|
aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_EQUATION, true, &pPoolItem );
|
2014-09-10 17:53:41 +02:00
|
|
|
if( aState == SfxItemState::DONTCARE )
|
2008-02-18 14:48:09 +00:00
|
|
|
{
|
2015-08-12 15:09:30 +02:00
|
|
|
m_pCB_ShowEquation->EnableTriState();
|
2014-02-24 12:25:02 +01:00
|
|
|
m_pCB_ShowEquation->SetState( TRISTATE_INDET );
|
2008-02-18 14:48:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
m_pCB_ShowEquation->EnableTriState( false );
|
2014-09-10 17:53:41 +02:00
|
|
|
if( aState == SfxItemState::SET )
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pCB_ShowEquation->Check( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue());
|
2008-02-18 14:48:09 +00:00
|
|
|
}
|
|
|
|
|
2014-02-19 21:49:02 +01:00
|
|
|
aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_COEFF, true, &pPoolItem );
|
2014-09-10 17:53:41 +02:00
|
|
|
if( aState == SfxItemState::DONTCARE )
|
2008-02-18 14:48:09 +00:00
|
|
|
{
|
2015-08-12 15:09:30 +02:00
|
|
|
m_pCB_ShowCorrelationCoeff->EnableTriState();
|
2014-02-24 12:25:02 +01:00
|
|
|
m_pCB_ShowCorrelationCoeff->SetState( TRISTATE_INDET );
|
2008-02-18 14:48:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
m_pCB_ShowCorrelationCoeff->EnableTriState( false );
|
2014-09-10 17:53:41 +02:00
|
|
|
if( aState == SfxItemState::SET )
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pCB_ShowCorrelationCoeff->Check( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue());
|
2008-02-18 14:48:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_bTrendLineUnique )
|
|
|
|
{
|
|
|
|
switch( m_eTrendLineType )
|
|
|
|
{
|
2016-08-24 13:21:36 +02:00
|
|
|
case SvxChartRegress::Linear :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_Linear->Check();
|
2008-02-18 14:48:09 +00:00
|
|
|
break;
|
2016-08-24 13:21:36 +02:00
|
|
|
case SvxChartRegress::Log :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_Logarithmic->Check();
|
2008-02-18 14:48:09 +00:00
|
|
|
break;
|
2016-08-24 13:21:36 +02:00
|
|
|
case SvxChartRegress::Exp :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_Exponential->Check();
|
2008-02-18 14:48:09 +00:00
|
|
|
break;
|
2016-08-24 13:21:36 +02:00
|
|
|
case SvxChartRegress::Power :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_Power->Check();
|
2008-02-18 14:48:09 +00:00
|
|
|
break;
|
2016-08-24 13:21:36 +02:00
|
|
|
case SvxChartRegress::Polynomial :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_Polynomial->Check();
|
2013-05-27 08:02:37 +02:00
|
|
|
break;
|
2016-08-24 13:21:36 +02:00
|
|
|
case SvxChartRegress::MovingAverage :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_MovingAverage->Check();
|
2013-05-27 08:02:37 +02:00
|
|
|
break;
|
2013-07-03 21:42:39 +02:00
|
|
|
default:
|
2008-02-18 14:48:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-10 17:23:12 +02:00
|
|
|
bool TrendlineResources::FillItemSet(SfxItemSet* rOutAttrs) const
|
2008-02-18 14:48:09 +00:00
|
|
|
{
|
|
|
|
if( m_bTrendLineUnique )
|
2014-06-10 17:23:12 +02:00
|
|
|
rOutAttrs->Put( SvxChartRegressItem( m_eTrendLineType, SCHATTR_REGRESSION_TYPE ));
|
2013-06-28 19:49:25 +02:00
|
|
|
|
2014-02-24 12:25:02 +01:00
|
|
|
if( m_pCB_ShowEquation->GetState() != TRISTATE_INDET )
|
2014-06-10 17:23:12 +02:00
|
|
|
rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_EQUATION, m_pCB_ShowEquation->IsChecked() ));
|
2013-06-28 19:49:25 +02:00
|
|
|
|
2014-02-24 12:25:02 +01:00
|
|
|
if( m_pCB_ShowCorrelationCoeff->GetState() != TRISTATE_INDET )
|
2014-06-10 17:23:12 +02:00
|
|
|
rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_COEFF, m_pCB_ShowCorrelationCoeff->IsChecked() ));
|
2013-05-27 08:02:37 +02:00
|
|
|
|
2013-11-23 16:06:28 +01:00
|
|
|
OUString aName = m_pEE_Name->GetText();
|
2014-06-10 17:23:12 +02:00
|
|
|
rOutAttrs->Put(SfxStringItem(SCHATTR_REGRESSION_CURVE_NAME, aName));
|
2016-06-28 23:34:34 +02:00
|
|
|
aName = m_pEE_XName->GetText();
|
|
|
|
if ( aName.isEmpty() )
|
|
|
|
aName = "x";
|
|
|
|
rOutAttrs->Put(SfxStringItem(SCHATTR_REGRESSION_XNAME, aName));
|
|
|
|
aName = m_pEE_YName->GetText();
|
|
|
|
if ( aName.isEmpty() )
|
|
|
|
aName = "f(x)";
|
|
|
|
rOutAttrs->Put(SfxStringItem(SCHATTR_REGRESSION_YNAME, aName));
|
2013-11-23 16:06:28 +01:00
|
|
|
|
2013-11-11 15:55:47 +01:00
|
|
|
sal_Int32 aDegree = m_pNF_Degree->GetValue();
|
2014-06-10 17:23:12 +02:00
|
|
|
rOutAttrs->Put(SfxInt32Item( SCHATTR_REGRESSION_DEGREE, aDegree ) );
|
2013-05-27 08:02:37 +02:00
|
|
|
|
2013-11-11 15:55:47 +01:00
|
|
|
sal_Int32 aPeriod = m_pNF_Period->GetValue();
|
2014-06-10 17:23:12 +02:00
|
|
|
rOutAttrs->Put(SfxInt32Item( SCHATTR_REGRESSION_PERIOD, aPeriod ) );
|
2013-05-27 08:02:37 +02:00
|
|
|
|
2013-12-13 07:25:20 +01:00
|
|
|
sal_uInt32 nIndex = 0;
|
|
|
|
double aValue = 0.0;
|
2014-10-10 16:37:37 +01:00
|
|
|
(void)m_pNumFormatter->IsNumberFormat(m_pFmtFld_ExtrapolateForward->GetText(),nIndex,aValue);
|
2014-06-10 17:23:12 +02:00
|
|
|
rOutAttrs->Put(SvxDoubleItem( aValue, SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD ) );
|
2013-05-27 08:02:37 +02:00
|
|
|
|
2013-12-13 07:25:20 +01:00
|
|
|
aValue = 0.0;
|
2014-10-10 16:37:37 +01:00
|
|
|
(void)m_pNumFormatter->IsNumberFormat(m_pFmtFld_ExtrapolateBackward->GetText(),nIndex,aValue);
|
2014-06-10 17:23:12 +02:00
|
|
|
rOutAttrs->Put(SvxDoubleItem( aValue, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD ) );
|
2013-05-27 08:02:37 +02:00
|
|
|
|
2014-02-24 12:25:02 +01:00
|
|
|
if( m_pCB_SetIntercept->GetState() != TRISTATE_INDET )
|
2014-06-10 17:23:12 +02:00
|
|
|
rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SET_INTERCEPT, m_pCB_SetIntercept->IsChecked() ));
|
2013-06-28 19:49:25 +02:00
|
|
|
|
2013-12-13 07:25:20 +01:00
|
|
|
aValue = 0.0;
|
2014-10-05 13:05:04 -05:00
|
|
|
(void)m_pNumFormatter->IsNumberFormat(m_pFmtFld_InterceptValue->GetText(),nIndex,aValue);
|
2014-06-10 17:23:12 +02:00
|
|
|
rOutAttrs->Put(SvxDoubleItem( aValue, SCHATTR_REGRESSION_INTERCEPT_VALUE ) );
|
2013-06-28 19:49:25 +02:00
|
|
|
|
2014-03-26 15:34:49 +02:00
|
|
|
return true;
|
2008-02-18 14:48:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TrendlineResources::FillValueSets()
|
|
|
|
{
|
2017-04-25 15:35:10 +01:00
|
|
|
m_pFI_Linear->SetImage(Image(BitmapEx(BMP_REGRESSION_LINEAR)));
|
|
|
|
m_pFI_Logarithmic->SetImage(Image(BitmapEx(BMP_REGRESSION_LOG)));
|
|
|
|
m_pFI_Exponential->SetImage(Image(BitmapEx(BMP_REGRESSION_EXP)));
|
|
|
|
m_pFI_Power->SetImage(Image(BitmapEx(BMP_REGRESSION_POWER)));
|
|
|
|
m_pFI_Polynomial->SetImage(Image(BitmapEx(BMP_REGRESSION_POLYNOMIAL)));
|
|
|
|
m_pFI_MovingAverage->SetImage(Image(BitmapEx(BMP_REGRESSION_MOVING_AVERAGE)));
|
2008-02-18 14:48:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TrendlineResources::UpdateControlStates()
|
|
|
|
{
|
2014-04-21 22:03:23 +02:00
|
|
|
if( m_nNbPoints > 0 )
|
|
|
|
{
|
|
|
|
sal_Int32 nMaxValue = m_nNbPoints - 1 + ( m_pCB_SetIntercept->IsChecked()?1:0 );
|
|
|
|
// if( nMaxValue > 10) nMaxValue = 10;
|
|
|
|
m_pNF_Degree->SetMax( nMaxValue );
|
|
|
|
m_pNF_Period->SetMax( m_nNbPoints - 1 );
|
|
|
|
}
|
2016-08-24 13:21:36 +02:00
|
|
|
bool bMovingAverage = ( m_eTrendLineType == SvxChartRegress::MovingAverage );
|
|
|
|
bool bInterceptAvailable = ( m_eTrendLineType == SvxChartRegress::Linear )
|
|
|
|
|| ( m_eTrendLineType == SvxChartRegress::Polynomial )
|
|
|
|
|| ( m_eTrendLineType == SvxChartRegress::Exp );
|
2014-04-21 22:03:23 +02:00
|
|
|
m_pFmtFld_ExtrapolateForward->Enable( !bMovingAverage );
|
|
|
|
m_pFmtFld_ExtrapolateBackward->Enable( !bMovingAverage );
|
2013-12-09 07:54:38 +01:00
|
|
|
m_pCB_SetIntercept->Enable( bInterceptAvailable );
|
|
|
|
m_pFmtFld_InterceptValue->Enable( bInterceptAvailable );
|
2014-04-21 22:03:23 +02:00
|
|
|
if( bMovingAverage )
|
2013-11-24 22:38:04 +01:00
|
|
|
{
|
2014-02-24 12:25:02 +01:00
|
|
|
m_pCB_ShowEquation->SetState( TRISTATE_FALSE );
|
|
|
|
m_pCB_ShowCorrelationCoeff->SetState( TRISTATE_FALSE );
|
2013-11-24 22:38:04 +01:00
|
|
|
}
|
2014-04-21 22:03:23 +02:00
|
|
|
m_pCB_ShowEquation->Enable( !bMovingAverage );
|
|
|
|
m_pCB_ShowCorrelationCoeff->Enable( !bMovingAverage );
|
2016-06-28 23:34:34 +02:00
|
|
|
m_pEE_XName->Enable( !bMovingAverage && m_pCB_ShowEquation->IsChecked() );
|
|
|
|
m_pEE_YName->Enable( !bMovingAverage && m_pCB_ShowEquation->IsChecked() );
|
2008-02-18 14:48:09 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK( TrendlineResources, ChangeValue, Edit&, rNumericField, void)
|
2013-11-24 22:11:56 +01:00
|
|
|
{
|
2015-10-15 08:13:49 +02:00
|
|
|
if( &rNumericField == m_pNF_Degree )
|
2013-11-24 22:11:56 +01:00
|
|
|
{
|
|
|
|
if( !m_pRB_Polynomial->IsChecked() )
|
|
|
|
{
|
|
|
|
m_pRB_Polynomial->Check();
|
|
|
|
SelectTrendLine(m_pRB_Polynomial);
|
|
|
|
}
|
|
|
|
}
|
2015-10-15 08:13:49 +02:00
|
|
|
else if( &rNumericField == m_pNF_Period )
|
2013-11-24 22:11:56 +01:00
|
|
|
{
|
|
|
|
if( !m_pRB_MovingAverage->IsChecked() )
|
|
|
|
{
|
|
|
|
m_pRB_MovingAverage->Check();
|
|
|
|
SelectTrendLine(m_pRB_MovingAverage);
|
|
|
|
}
|
|
|
|
}
|
2015-10-15 08:13:49 +02:00
|
|
|
else if( &rNumericField == m_pFmtFld_InterceptValue )
|
2013-11-24 22:11:56 +01:00
|
|
|
{
|
|
|
|
if( !m_pCB_SetIntercept->IsChecked() )
|
|
|
|
m_pCB_SetIntercept->Check();
|
|
|
|
}
|
|
|
|
UpdateControlStates();
|
|
|
|
}
|
|
|
|
|
2013-12-02 09:54:21 +01:00
|
|
|
void TrendlineResources::SetNumFormatter( SvNumberFormatter* pFormatter )
|
|
|
|
{
|
|
|
|
m_pNumFormatter = pFormatter;
|
2013-12-13 07:25:20 +01:00
|
|
|
m_pFmtFld_ExtrapolateForward->SetFormatter( m_pNumFormatter );
|
|
|
|
m_pFmtFld_ExtrapolateBackward->SetFormatter( m_pNumFormatter );
|
2013-12-02 09:54:21 +01:00
|
|
|
m_pFmtFld_InterceptValue->SetFormatter( m_pNumFormatter );
|
|
|
|
}
|
|
|
|
|
2014-04-21 22:03:23 +02:00
|
|
|
void TrendlineResources::SetNbPoints( sal_Int32 nNbPoints )
|
|
|
|
{
|
|
|
|
m_nNbPoints = nNbPoints;
|
|
|
|
UpdateControlStates();
|
|
|
|
}
|
2013-12-02 09:54:21 +01:00
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK( TrendlineResources, ShowEquation, CheckBox&, rCheckBox, void)
|
2016-06-28 23:34:34 +02:00
|
|
|
{
|
|
|
|
if( &rCheckBox == m_pCB_ShowEquation )
|
|
|
|
{
|
|
|
|
m_pEE_XName->Enable( m_pCB_ShowEquation->IsChecked() );
|
|
|
|
m_pEE_YName->Enable( m_pCB_ShowEquation->IsChecked() );
|
|
|
|
}
|
|
|
|
UpdateControlStates();
|
|
|
|
}
|
|
|
|
|
2008-02-18 14:48:09 +00:00
|
|
|
} // namespace chart
|
2010-10-12 15:59:00 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|