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"
|
|
|
|
#include "Bitmaps.hrc"
|
|
|
|
#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 );
|
|
|
|
}
|
|
|
|
|
2013-07-03 21:42:39 +02:00
|
|
|
TrendlineResources::TrendlineResources( Window * pParent, const SfxItemSet& rInAttrs ) :
|
|
|
|
m_eTrendLineType( CHREGRESS_LINEAR ),
|
2013-12-02 09:54:21 +01:00
|
|
|
m_bTrendLineUnique( true ),
|
2014-04-21 22:03:23 +02:00
|
|
|
m_pNumFormatter( NULL ),
|
|
|
|
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");
|
|
|
|
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();
|
|
|
|
|
2013-11-24 22:11:56 +01:00
|
|
|
Link aLink = LINK(this, TrendlineResources, SelectTrendLine );
|
|
|
|
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 );
|
|
|
|
|
2013-12-02 09:54:21 +01:00
|
|
|
aLink = LINK(this, TrendlineResources, ChangeValue );
|
2013-11-24 22:11:56 +01:00
|
|
|
m_pNF_Degree->SetModifyHdl( aLink );
|
|
|
|
m_pNF_Period->SetModifyHdl( aLink );
|
2013-12-02 09:54:21 +01:00
|
|
|
m_pFmtFld_InterceptValue->SetModifyHdl( aLink );
|
2013-05-27 08:02:37 +02:00
|
|
|
|
2008-02-18 14:48:09 +00:00
|
|
|
Reset( rInAttrs );
|
|
|
|
UpdateControlStates();
|
|
|
|
}
|
|
|
|
|
|
|
|
TrendlineResources::~TrendlineResources()
|
|
|
|
{}
|
|
|
|
|
|
|
|
IMPL_LINK( TrendlineResources, SelectTrendLine, RadioButton *, pRadioButton )
|
|
|
|
{
|
2013-11-11 15:55:47 +01:00
|
|
|
if( pRadioButton == m_pRB_Linear )
|
2008-02-18 14:48:09 +00:00
|
|
|
m_eTrendLineType = CHREGRESS_LINEAR;
|
2013-11-11 15:55:47 +01:00
|
|
|
else if( pRadioButton == m_pRB_Logarithmic )
|
2008-02-18 14:48:09 +00:00
|
|
|
m_eTrendLineType = CHREGRESS_LOG;
|
2013-11-11 15:55:47 +01:00
|
|
|
else if( pRadioButton == m_pRB_Exponential )
|
2008-02-18 14:48:09 +00:00
|
|
|
m_eTrendLineType = CHREGRESS_EXP;
|
2013-11-11 15:55:47 +01:00
|
|
|
else if( pRadioButton == m_pRB_Power )
|
2008-02-18 14:48:09 +00:00
|
|
|
m_eTrendLineType = CHREGRESS_POWER;
|
2013-11-11 15:55:47 +01:00
|
|
|
else if( pRadioButton == m_pRB_Polynomial )
|
2013-05-27 08:02:37 +02:00
|
|
|
m_eTrendLineType = CHREGRESS_POLYNOMIAL;
|
2013-11-11 15:55:47 +01:00
|
|
|
else if( pRadioButton == m_pRB_MovingAverage )
|
2013-05-27 08:02:37 +02:00
|
|
|
m_eTrendLineType = CHREGRESS_MOVING_AVERAGE;
|
2008-02-18 14:48:09 +00:00
|
|
|
m_bTrendLineUnique = true;
|
|
|
|
|
|
|
|
UpdateControlStates();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
|
|
|
|
{
|
|
|
|
const SfxPoolItem *pPoolItem = NULL;
|
|
|
|
|
2014-02-19 21:49:02 +01:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_CURVE_NAME, true, &pPoolItem ) == SFX_ITEM_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("");
|
|
|
|
}
|
|
|
|
|
2014-02-19 21:49:02 +01:00
|
|
|
SfxItemState aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_TYPE, true, &pPoolItem );
|
2008-02-18 14:48:09 +00:00
|
|
|
m_bTrendLineUnique = ( aState != SFX_ITEM_DONTCARE );
|
|
|
|
if( aState == SFX_ITEM_SET )
|
|
|
|
{
|
|
|
|
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-02-19 21:49:02 +01:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_DEGREE, true, &pPoolItem ) == SFX_ITEM_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-02-19 21:49:02 +01:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_PERIOD, true, &pPoolItem ) == SFX_ITEM_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-02-19 21:49:02 +01:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD, true, &pPoolItem ) == SFX_ITEM_SET )
|
2013-05-27 08:02:37 +02:00
|
|
|
{
|
2013-12-13 07:25:20 +01:00
|
|
|
nValue = ((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-02-19 21:49:02 +01:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, true, &pPoolItem ) == SFX_ITEM_SET )
|
2013-05-27 08:02:37 +02:00
|
|
|
{
|
2013-12-13 07:25:20 +01:00
|
|
|
nValue = ((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-02-19 21:49:02 +01:00
|
|
|
if( rInAttrs.GetItemState( SCHATTR_REGRESSION_INTERCEPT_VALUE, true, &pPoolItem ) == SFX_ITEM_SET )
|
2013-06-28 19:49:25 +02:00
|
|
|
{
|
2013-12-02 09:54:21 +01:00
|
|
|
nValue = ((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 );
|
2013-06-28 19:49:25 +02:00
|
|
|
if( aState == SFX_ITEM_DONTCARE )
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
m_pCB_SetIntercept->EnableTriState( true );
|
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 );
|
2013-06-28 19:49:25 +02:00
|
|
|
if( aState == SFX_ITEM_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 );
|
2008-02-18 14:48:09 +00:00
|
|
|
if( aState == SFX_ITEM_DONTCARE )
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
m_pCB_ShowEquation->EnableTriState( true );
|
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 );
|
2008-02-18 14:48:09 +00:00
|
|
|
if( aState == SFX_ITEM_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 );
|
2008-02-18 14:48:09 +00:00
|
|
|
if( aState == SFX_ITEM_DONTCARE )
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
m_pCB_ShowCorrelationCoeff->EnableTriState( true );
|
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 );
|
2008-02-18 14:48:09 +00:00
|
|
|
if( aState == SFX_ITEM_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 )
|
|
|
|
{
|
|
|
|
case CHREGRESS_LINEAR :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_Linear->Check();
|
2008-02-18 14:48:09 +00:00
|
|
|
break;
|
|
|
|
case CHREGRESS_LOG :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_Logarithmic->Check();
|
2008-02-18 14:48:09 +00:00
|
|
|
break;
|
|
|
|
case CHREGRESS_EXP :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_Exponential->Check();
|
2008-02-18 14:48:09 +00:00
|
|
|
break;
|
|
|
|
case CHREGRESS_POWER :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_Power->Check();
|
2008-02-18 14:48:09 +00:00
|
|
|
break;
|
2013-05-27 08:02:37 +02:00
|
|
|
case CHREGRESS_POLYNOMIAL :
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pRB_Polynomial->Check();
|
2013-05-27 08:02:37 +02:00
|
|
|
break;
|
|
|
|
case CHREGRESS_MOVING_AVERAGE :
|
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));
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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()
|
|
|
|
{
|
2013-11-11 15:55:47 +01:00
|
|
|
m_pFI_Linear->SetImage( Image( SchResId( BMP_REGRESSION_LINEAR ) ) );
|
|
|
|
m_pFI_Logarithmic->SetImage( Image( SchResId( BMP_REGRESSION_LOG ) ) );
|
|
|
|
m_pFI_Exponential->SetImage( Image( SchResId( BMP_REGRESSION_EXP ) ) );
|
|
|
|
m_pFI_Power->SetImage( Image( SchResId( BMP_REGRESSION_POWER ) ) );
|
|
|
|
m_pFI_Polynomial->SetImage( Image( SchResId( BMP_REGRESSION_POLYNOMIAL ) ) );
|
|
|
|
m_pFI_MovingAverage->SetImage(Image( SchResId( 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 );
|
|
|
|
}
|
2013-11-24 22:38:04 +01:00
|
|
|
bool bMovingAverage = ( m_eTrendLineType == CHREGRESS_MOVING_AVERAGE );
|
2013-12-09 07:54:38 +01:00
|
|
|
bool bInterceptAvailable = ( m_eTrendLineType == CHREGRESS_LINEAR ) || ( m_eTrendLineType == CHREGRESS_POLYNOMIAL );
|
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 );
|
2008-02-18 14:48:09 +00:00
|
|
|
}
|
|
|
|
|
2013-12-02 09:54:21 +01:00
|
|
|
IMPL_LINK( TrendlineResources, ChangeValue, void *, pNumericField)
|
2013-11-24 22:11:56 +01:00
|
|
|
{
|
|
|
|
if( pNumericField == m_pNF_Degree )
|
|
|
|
{
|
|
|
|
if( !m_pRB_Polynomial->IsChecked() )
|
|
|
|
{
|
|
|
|
m_pRB_Polynomial->Check();
|
|
|
|
SelectTrendLine(m_pRB_Polynomial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( pNumericField == m_pNF_Period )
|
|
|
|
{
|
|
|
|
if( !m_pRB_MovingAverage->IsChecked() )
|
|
|
|
{
|
|
|
|
m_pRB_MovingAverage->Check();
|
|
|
|
SelectTrendLine(m_pRB_MovingAverage);
|
|
|
|
}
|
|
|
|
}
|
2013-12-02 09:54:21 +01:00
|
|
|
else if( pNumericField == m_pFmtFld_InterceptValue )
|
2013-11-24 22:11:56 +01:00
|
|
|
{
|
|
|
|
if( !m_pCB_SetIntercept->IsChecked() )
|
|
|
|
m_pCB_SetIntercept->Check();
|
|
|
|
}
|
|
|
|
UpdateControlStates();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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: */
|