diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2013-11-03 12:10:19 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2013-11-11 23:22:30 +0100 |
commit | b3904220ef855d1cde6aae9e56b270b99405c494 (patch) | |
tree | fd5a9c6ac23ae513f14810ff25bc267965960190 /sc/source/ui | |
parent | aaa689d94d4fb021fa04ad964495828d901280c4 (diff) |
Groupedby for ANOVA and "Descriptive Statistics"
Move the functionallity to superclass, adjust UI
Change-Id: I9770206386aa6d9caaf2d832d4744ac488e3190b
Diffstat (limited to 'sc/source/ui')
9 files changed, 37 insertions, 81 deletions
diff --git a/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx b/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx index 7655824ac92b..4f17a48943db 100644 --- a/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx @@ -25,15 +25,7 @@ ScCorrelationDialog::ScCorrelationDialog( ScMatrixComparisonGenerator( pSfxBindings, pChildWindow, pParent, pViewData, "CorrelationDialog", "modules/scalc/ui/correlationdialog.ui" ) -{ - get(mpGroupByColumnsRadio, "groupedby-columns-radio"); - get(mpGroupByRowsRadio, "groupedby-rows-radio"); - - mpGroupByColumnsRadio->SetToggleHdl( LINK( this, ScCorrelationDialog, GroupByChanged ) ); - mpGroupByRowsRadio->SetToggleHdl( LINK( this, ScCorrelationDialog, GroupByChanged ) ); - - mpGroupByColumnsRadio->Check(true); -} +{} sal_Bool ScCorrelationDialog::Close() { @@ -50,19 +42,4 @@ const OUString& ScCorrelationDialog::getTemplate() return strCorrelationTemplate; } -ScMatrixComparisonGenerator::GroupedBy ScCorrelationDialog::getGroupedBy() -{ - return mGroupedBy; -} - -IMPL_LINK_NOARG(ScCorrelationDialog, GroupByChanged) -{ - if (mpGroupByColumnsRadio->IsChecked()) - mGroupedBy = BY_COLUMN; - else if (mpGroupByRowsRadio->IsChecked()) - mGroupedBy = BY_ROW; - - return 0; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx b/sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx index dbcb97f6a592..3918654d50f6 100644 --- a/sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx @@ -25,15 +25,7 @@ ScCovarianceDialog::ScCovarianceDialog( ScMatrixComparisonGenerator( pSfxBindings, pChildWindow, pParent, pViewData, "CovarianceDialog", "modules/scalc/ui/covariancedialog.ui" ) -{ - get(mpGroupByColumnsRadio, "groupedby-columns-radio"); - get(mpGroupByRowsRadio, "groupedby-rows-radio"); - - mpGroupByColumnsRadio->SetToggleHdl( LINK( this, ScCovarianceDialog, GroupByChanged ) ); - mpGroupByRowsRadio->SetToggleHdl( LINK( this, ScCovarianceDialog, GroupByChanged ) ); - - mpGroupByColumnsRadio->Check(true); -} +{} sal_Bool ScCovarianceDialog::Close() { @@ -50,19 +42,4 @@ const OUString& ScCovarianceDialog::getTemplate() return strCovarianceTemplate; } -ScMatrixComparisonGenerator::GroupedBy ScCovarianceDialog::getGroupedBy() -{ - return mGroupedBy; -} - -IMPL_LINK_NOARG(ScCovarianceDialog, GroupByChanged) -{ - if (mpGroupByColumnsRadio->IsChecked()) - mGroupedBy = BY_COLUMN; - else if (mpGroupByRowsRadio->IsChecked()) - mGroupedBy = BY_ROW; - - return 0; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx index ed9bf1c17eb5..80d1b87c5258 100644 --- a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx @@ -54,7 +54,7 @@ static const StatisticCalculation lclCalcDefinitions[] = { 0, NULL } }; -static const OUString lclWildcardRange("%RANGE%"); +static const OUString strWildcardRange("%RANGE%"); } @@ -120,7 +120,7 @@ void ScDescriptiveStatisticsDialog::CalculateInputAndWriteToOutput( ) { aAddress = ScAddress(outCol, outRow, outTab); aFormulaTemplate = OUString::createFromAscii(lclCalcDefinitions[i].aFormula); - aFormulaString = aFormulaTemplate.replaceAll(lclWildcardRange, aReferenceString); + aFormulaString = aFormulaTemplate.replaceAll(strWildcardRange, aReferenceString); pDocShell->GetDocFunc().SetFormulaCell(aAddress, new ScFormulaCell(mDocument, aAddress, aFormulaString), true); outRow++; } diff --git a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx index d3e22816e04c..ad5f67095539 100644 --- a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx +++ b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx @@ -69,7 +69,7 @@ void ScMatrixComparisonGenerator::CalculateInputAndWriteToOutput( ) ScRangeList aRangeList; - if (getGroupedBy() == BY_COLUMN) + if (mGroupedBy == BY_COLUMN) aRangeList = MakeColumnRangeList(inTab, aStart, aEnd); else aRangeList = MakeRowRangeList(inTab, aStart, aEnd); @@ -85,7 +85,7 @@ void ScMatrixComparisonGenerator::CalculateInputAndWriteToOutput( ) { aAddress = ScAddress(outCol, outRow, outTab); OUString aLabel; - if (getGroupedBy() == BY_COLUMN) + if (mGroupedBy == BY_COLUMN) aLabel = strColumnLabelTemplate.replaceAll(strWildcardNumber, OUString::number(i + 1)); else aLabel = strRowLabelTemplate.replaceAll(strWildcardNumber, OUString::number(i + 1)); @@ -103,7 +103,7 @@ void ScMatrixComparisonGenerator::CalculateInputAndWriteToOutput( ) aAddress = ScAddress(outCol, outRow, outTab); OUString aLabel; - if (getGroupedBy() == BY_COLUMN) + if (mGroupedBy == BY_COLUMN) aLabel = strColumnLabelTemplate.replaceAll(strWildcardNumber, OUString::number(i + 1)); else aLabel = strRowLabelTemplate.replaceAll(strWildcardNumber, OUString::number(i + 1)); @@ -119,7 +119,7 @@ void ScMatrixComparisonGenerator::CalculateInputAndWriteToOutput( ) mOutputAddress.Row() + 1, inTab); - if (getGroupedBy() == BY_COLUMN) + if (mGroupedBy == BY_COLUMN) writeCorrelationFormulasByColumn(aAddress, aRangeList); else writeCorrelationFormulasByRow(aAddress, aRangeList); diff --git a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx index ff431d7cf677..7374965e2bc3 100644 --- a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx @@ -60,6 +60,7 @@ ScStatisticsInputOutputDialog::ScStatisticsInputOutputDialog( mViewData ( pViewData ), mDocument ( pViewData->GetDocument() ), mAddressDetails ( mDocument->GetAddressConvention(), 0, 0 ), + mGroupedBy ( BY_COLUMN ), mCurrentAddress ( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ), mDialogLostFocus( false ) { @@ -79,6 +80,9 @@ ScStatisticsInputOutputDialog::ScStatisticsInputOutputDialog( get(mpButtonApply, "apply"); get(mpButtonClose, "close"); + get(mpGroupByColumnsRadio, "groupedby-columns-radio"); + get(mpGroupByRowsRadio, "groupedby-rows-radio"); + Init(); GetRangeFromSelection(); } @@ -107,6 +111,12 @@ void ScStatisticsInputOutputDialog::Init() mpOutputRangeButton->SetLoseFocusHdl( aLink ); mpOutputRangeEdit->GrabFocus(); + + mpGroupByColumnsRadio->SetToggleHdl( LINK( this, ScStatisticsInputOutputDialog, GroupByChanged ) ); + mpGroupByRowsRadio->SetToggleHdl( LINK( this, ScStatisticsInputOutputDialog, GroupByChanged ) ); + + mpGroupByColumnsRadio->Check(true); + mpGroupByRowsRadio->Check(false); } void ScStatisticsInputOutputDialog::GetRangeFromSelection() @@ -202,4 +212,14 @@ IMPL_LINK_NOARG( ScStatisticsInputOutputDialog, LoseFocusHandler ) return 0; } +IMPL_LINK_NOARG( ScStatisticsInputOutputDialog, GroupByChanged ) +{ + if (mpGroupByColumnsRadio->IsChecked()) + mGroupedBy = BY_COLUMN; + else if (mpGroupByRowsRadio->IsChecked()) + mGroupedBy = BY_ROW; + + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/CorrelationDialog.hxx b/sc/source/ui/inc/CorrelationDialog.hxx index 76e94e1eaffb..4e89cc05897a 100644 --- a/sc/source/ui/inc/CorrelationDialog.hxx +++ b/sc/source/ui/inc/CorrelationDialog.hxx @@ -15,13 +15,6 @@ class ScCorrelationDialog : public ScMatrixComparisonGenerator { -private: - RadioButton* mpGroupByColumnsRadio; - RadioButton* mpGroupByRowsRadio; - GroupedBy mGroupedBy; - - DECL_LINK( GroupByChanged, void* ); - public: ScCorrelationDialog( SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, @@ -32,7 +25,6 @@ public: protected: virtual const OUString& getLabel(); virtual const OUString& getTemplate(); - virtual GroupedBy getGroupedBy(); }; diff --git a/sc/source/ui/inc/CovarianceDialog.hxx b/sc/source/ui/inc/CovarianceDialog.hxx index 675f3dbf5a0d..cd46701dc74d 100644 --- a/sc/source/ui/inc/CovarianceDialog.hxx +++ b/sc/source/ui/inc/CovarianceDialog.hxx @@ -15,13 +15,6 @@ class ScCovarianceDialog : public ScMatrixComparisonGenerator { -private: - RadioButton* mpGroupByColumnsRadio; - RadioButton* mpGroupByRowsRadio; - GroupedBy mGroupedBy; - - DECL_LINK( GroupByChanged, void* ); - public: ScCovarianceDialog( SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, @@ -32,7 +25,6 @@ public: protected: virtual const OUString& getLabel(); virtual const OUString& getTemplate(); - virtual GroupedBy getGroupedBy(); }; #endif diff --git a/sc/source/ui/inc/MatrixComparisonGenerator.hxx b/sc/source/ui/inc/MatrixComparisonGenerator.hxx index 6a0af4c37a7e..6cb32017dd0e 100644 --- a/sc/source/ui/inc/MatrixComparisonGenerator.hxx +++ b/sc/source/ui/inc/MatrixComparisonGenerator.hxx @@ -31,17 +31,11 @@ public: virtual ~ScMatrixComparisonGenerator(); - enum GroupedBy { - BY_COLUMN, - BY_ROW - }; - protected: virtual void CalculateInputAndWriteToOutput(); virtual const OUString& getLabel() = 0; virtual const OUString& getTemplate() = 0; - virtual GroupedBy getGroupedBy() = 0; void writeCorrelationFormulasByColumn(ScAddress aOutputAddress, ScRangeList aRangeList); void writeCorrelationFormulasByRow(ScAddress aOutputAddress, ScRangeList aRangeList); diff --git a/sc/source/ui/inc/StatisticsInputOutputDialog.hxx b/sc/source/ui/inc/StatisticsInputOutputDialog.hxx index a6ad9a72b450..b4d83444ba47 100644 --- a/sc/source/ui/inc/StatisticsInputOutputDialog.hxx +++ b/sc/source/ui/inc/StatisticsInputOutputDialog.hxx @@ -22,6 +22,11 @@ class ScStatisticsInputOutputDialog : public ScAnyRefDlg { public: + enum GroupedBy { + BY_COLUMN, + BY_ROW + }; + ScStatisticsInputOutputDialog( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, ScViewData* pViewData, @@ -51,28 +56,27 @@ protected: ScRange mInputRange; ScAddress::Details mAddressDetails; ScAddress mOutputAddress; + GroupedBy mGroupedBy; static ScRangeList MakeColumnRangeList(SCTAB aTab, ScAddress aStart, ScAddress aEnd); static ScRangeList MakeRowRangeList(SCTAB aTab, ScAddress aStart, ScAddress aEnd); - private: // Widgets PushButton* mpButtonApply; OKButton* mpButtonOk; CloseButton* mpButtonClose; - + RadioButton* mpGroupByColumnsRadio; + RadioButton* mpGroupByRowsRadio; formula::RefEdit* mpActiveEdit; - - ScAddress mCurrentAddress; - bool mDialogLostFocus; void Init(); void GetRangeFromSelection(); + DECL_LINK( GroupByChanged, void* ); DECL_LINK( OkClicked, PushButton* ); DECL_LINK( CloseClicked, PushButton* ); DECL_LINK( ApplyClicked, PushButton* ); |