diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2013-11-03 11:25:21 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2013-11-11 23:22:30 +0100 |
commit | aaa689d94d4fb021fa04ad964495828d901280c4 (patch) | |
tree | 86c6e044efcfe0c73ba85e73a39981d420ca6b2c /sc/source | |
parent | dbd3da10da64ce71c76fc959f280b3d70b382a32 (diff) |
Add GroupedBy: Columns/Rows to Correlation and Covariance.
Change-Id: I7bb3b7151abda8e977cbdbec2d0c356f049d5af2
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx | 149 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx | 148 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx | 201 | ||||
-rw-r--r-- | sc/source/ui/inc/CorrelationDialog.hxx | 29 | ||||
-rw-r--r-- | sc/source/ui/inc/CovarianceDialog.hxx | 28 | ||||
-rw-r--r-- | sc/source/ui/inc/MatrixComparisonGenerator.hxx | 53 |
6 files changed, 341 insertions, 267 deletions
diff --git a/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx b/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx index 336a63f2d057..7655824ac92b 100644 --- a/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx @@ -8,150 +8,61 @@ * */ -#include <sfx2/dispatch.hxx> -#include <svl/zforlist.hxx> -#include <svl/undo.hxx> - -#include "formulacell.hxx" -#include "rangelst.hxx" -#include "scitems.hxx" #include "docsh.hxx" -#include "document.hxx" -#include "uiitems.hxx" #include "reffact.hxx" -#include "strload.hxx" -#include "random.hxx" -#include "docfunc.hxx" -#include "StatisticsDialogs.hrc" #include "CorrelationDialog.hxx" namespace { - -static const OUString lclWildcardColumn1("%COLUMN1%"); -static const OUString lclWildcardColumn2("%COLUMN2%"); -static const OUString lclCorrelTemplate("=CORREL(%COLUMN1%, %COLUMN2%)"); -static const OUString lclWildcardNumber("%NUMBER%"); -static const OUString lclColumnLabelTemplate("Column %NUMBER%"); - + static const OUString strCorrelationLabel("Correlations"); + static const OUString strCorrelationTemplate("=CORREL(%VAR1%; %VAR2%)"); } ScCorrelationDialog::ScCorrelationDialog( - SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, - Window* pParent, ScViewData* pViewData ) : - ScStatisticsInputOutputDialog( + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + Window* pParent, ScViewData* pViewData ) : + ScMatrixComparisonGenerator( pSfxBindings, pChildWindow, pParent, pViewData, - "DescriptiveStatisticsDialog", "modules/scalc/ui/descriptivestatisticsdialog.ui" ) -{} + "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 ) ); -ScCorrelationDialog::~ScCorrelationDialog() -{} + mpGroupByColumnsRadio->Check(true); +} sal_Bool ScCorrelationDialog::Close() { return DoClose( ScCorrelationDialogWrapper::GetChildWindowId() ); } -void ScCorrelationDialog::CalculateInputAndWriteToOutput( ) +const OUString& ScCorrelationDialog::getLabel() { - OUString aUndo( SC_STRLOAD( RID_STATISTICS_DLGS, STR_CORRELATION_UNDO_NAME)); - ScDocShell* pDocShell = mViewData->GetDocShell(); - svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager(); - pUndoManager->EnterListAction( aUndo, aUndo ); - - ScAddress aStart = mInputRange.aStart; - ScAddress aEnd = mInputRange.aEnd; - - SCTAB outTab = mOutputAddress.Tab(); - SCCOL outCol = mOutputAddress.Col(); - SCROW outRow = mOutputAddress.Row(); - - ScAddress aAddress; - SCCOL aMaxCol = 0; - SCROW aMaxRow = 0; - - for (SCTAB inTab = aStart.Tab(); inTab <= aEnd.Tab(); inTab++) - { - ScRangeList aRangeList = MakeColumnRangeList(inTab, aStart, aEnd); - - // column labels - aAddress = ScAddress(outCol, outRow, outTab); - pDocShell->GetDocFunc().SetStringCell(aAddress, OUString("Correlations"), true); - outCol++; - aMaxCol = outCol > aMaxCol ? outCol : aMaxCol; - - // write labels to columns - for (size_t i = 0; i < aRangeList.size(); i++) - { - aAddress = ScAddress(outCol, outRow, outTab); - OUString aColumnLabel = lclColumnLabelTemplate.replaceAll(lclWildcardNumber, OUString::number(i + 1)); - pDocShell->GetDocFunc().SetStringCell(aAddress, aColumnLabel, true); - outCol++; - aMaxCol = outCol > aMaxCol ? outCol : aMaxCol; - } - - // write labels to rows - outCol = mOutputAddress.Col(); - outRow++; - for (size_t i = 0; i < aRangeList.size(); i++) - { - aAddress = ScAddress(outCol, outRow, outTab); - OUString aColumnLabel = lclColumnLabelTemplate.replaceAll(lclWildcardNumber, OUString::number(i + 1)); - pDocShell->GetDocFunc().SetStringCell(aAddress, aColumnLabel, true); - outRow++; - aMaxRow = outRow > aMaxRow ? outRow : aMaxRow; - } - - // write correlation formulas - aAddress = ScAddress( - mOutputAddress.Col() + 1, - mOutputAddress.Row() + 1, - inTab); - - WriteCorrelationFormulas(aAddress, aRangeList); - outTab++; - } - ScAddress aLastAddress = ScAddress( - mOutputAddress.Col() + aMaxCol, - mOutputAddress.Row() + aMaxRow, - outTab); - - ScRange aOutputRange(mOutputAddress, aLastAddress); - pUndoManager->LeaveListAction(); - pDocShell->PostPaint(aOutputRange, PAINT_GRID); + return strCorrelationLabel; } -void ScCorrelationDialog::WriteCorrelationFormulas(ScAddress aOutputAddress, ScRangeList aRangeList) +const OUString& ScCorrelationDialog::getTemplate() { - ScDocShell* pDocShell = mViewData->GetDocShell(); - ScAddress aAddress; - - SCTAB outTab = aOutputAddress.Tab(); - SCCOL outCol = aOutputAddress.Col(); + return strCorrelationTemplate; +} - OUString aFormulaString; +ScMatrixComparisonGenerator::GroupedBy ScCorrelationDialog::getGroupedBy() +{ + return mGroupedBy; +} - for (size_t i = 0; i < aRangeList.size(); i++) - { - SCROW outRow = aOutputAddress.Row(); - for (size_t j = 0; j < aRangeList.size(); j++) - { - if (j >= i) - { - OUString aColumnString1(aRangeList[i]->Format(SCR_ABS, mDocument, mAddressDetails)); - OUString aColumnString2(aRangeList[j]->Format(SCR_ABS, mDocument, mAddressDetails)); +IMPL_LINK_NOARG(ScCorrelationDialog, GroupByChanged) +{ + if (mpGroupByColumnsRadio->IsChecked()) + mGroupedBy = BY_COLUMN; + else if (mpGroupByRowsRadio->IsChecked()) + mGroupedBy = BY_ROW; - aAddress = ScAddress(outCol, outRow, outTab); - aFormulaString = lclCorrelTemplate.replaceAll(lclWildcardColumn1, aColumnString1); - aFormulaString = aFormulaString.replaceAll(lclWildcardColumn2, aColumnString2); - pDocShell->GetDocFunc().SetFormulaCell(aAddress, new ScFormulaCell(mDocument, aAddress, aFormulaString), true); - } - outRow++; - } - outCol++; - } + 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 beade9fa955c..dbcb97f6a592 100644 --- a/sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx @@ -8,149 +8,61 @@ * */ -#include <sfx2/dispatch.hxx> -#include <svl/zforlist.hxx> -#include <svl/undo.hxx> - -#include "formulacell.hxx" -#include "rangelst.hxx" -#include "scitems.hxx" #include "docsh.hxx" -#include "document.hxx" -#include "uiitems.hxx" #include "reffact.hxx" -#include "strload.hxx" -#include "random.hxx" -#include "docfunc.hxx" -#include "StatisticsDialogs.hrc" #include "CovarianceDialog.hxx" namespace { - -static const OUString lclWildcardRow1("%ROW1%"); -static const OUString lclWildcardRow2("%ROW2%"); -static const OUString lclCovarTemplate("=COVAR(%ROW1%, %ROW2%)"); -static const OUString lclWildcardNumber("%NUMBER%"); -static const OUString lclRowLabelTemplate("Row %NUMBER%"); - + static const OUString strCovarianceLabel("Covariances"); + static const OUString strCovarianceTemplate("=COVAR(%VAR1%; %VAR2%)"); } ScCovarianceDialog::ScCovarianceDialog( - SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, - Window* pParent, ScViewData* pViewData ) : - ScStatisticsInputOutputDialog( + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + Window* pParent, ScViewData* pViewData ) : + ScMatrixComparisonGenerator( pSfxBindings, pChildWindow, pParent, pViewData, - "DescriptiveStatisticsDialog", "modules/scalc/ui/descriptivestatisticsdialog.ui" ) -{} + "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 ) ); -ScCovarianceDialog::~ScCovarianceDialog() -{} + mpGroupByColumnsRadio->Check(true); +} sal_Bool ScCovarianceDialog::Close() { return DoClose( ScCovarianceDialogWrapper::GetChildWindowId() ); } -void ScCovarianceDialog::CalculateInputAndWriteToOutput( ) +const OUString& ScCovarianceDialog::getLabel() { - OUString aUndo( SC_STRLOAD( RID_STATISTICS_DLGS, STR_COVARIANCE_UNDO_NAME)); - ScDocShell* pDocShell = mViewData->GetDocShell(); - svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager(); - pUndoManager->EnterListAction( aUndo, aUndo ); - - ScAddress aStart = mInputRange.aStart; - ScAddress aEnd = mInputRange.aEnd; - - SCTAB outTab = mOutputAddress.Tab(); - SCCOL outCol = mOutputAddress.Col(); - SCROW outRow = mOutputAddress.Row(); - - ScAddress aAddress; - SCCOL aMaxCol = 0; - SCROW aMaxRow = 0; - - for (SCTAB inTab = aStart.Tab(); inTab <= aEnd.Tab(); inTab++) - { - ScRangeList aRangeList = MakeRowRangeList(inTab, aStart, aEnd); - - // row labels - aAddress = ScAddress(outCol, outRow, outTab); - pDocShell->GetDocFunc().SetStringCell(aAddress, OUString("Covariances"), true); - outCol++; - aMaxCol = outCol > aMaxCol ? outCol : aMaxCol; - - // write labels to columns - for (size_t i = 0; i < aRangeList.size(); i++) - { - aAddress = ScAddress(outCol, outRow, outTab); - OUString aRowLabel = lclRowLabelTemplate.replaceAll(lclWildcardNumber, OUString::number(i + 1)); - pDocShell->GetDocFunc().SetStringCell(aAddress, aRowLabel, true); - outCol++; - aMaxCol = outCol > aMaxCol ? outCol : aMaxCol; - } - - // write labels to rows - outCol = mOutputAddress.Col(); - outRow++; - for (size_t i = 0; i < aRangeList.size(); i++) - { - aAddress = ScAddress(outCol, outRow, outTab); - OUString aRowLabel = lclRowLabelTemplate.replaceAll(lclWildcardNumber, OUString::number(i + 1)); - pDocShell->GetDocFunc().SetStringCell(aAddress, aRowLabel, true); - outRow++; - aMaxRow = outRow > aMaxRow ? outRow : aMaxRow; - } - - // write correlation formulas - aAddress = ScAddress( - mOutputAddress.Col() + 1, - mOutputAddress.Row() + 1, - inTab); - - WriteCovarianceFormulas(aAddress, aRangeList); - outTab++; - } - ScAddress aLastAddress = ScAddress( - mOutputAddress.Col() + aMaxCol, - mOutputAddress.Row() + aMaxRow, - outTab); - - ScRange aOutputRange(mOutputAddress, aLastAddress); - pUndoManager->LeaveListAction(); - pDocShell->PostPaint(aOutputRange, PAINT_GRID); + return strCovarianceLabel; } -void ScCovarianceDialog::WriteCovarianceFormulas(ScAddress aOutputAddress, ScRangeList aRangeList) +const OUString& ScCovarianceDialog::getTemplate() { - ScDocShell* pDocShell = mViewData->GetDocShell(); - ScAddress aAddress; - - SCTAB outTab = aOutputAddress.Tab(); - SCCOL outCol = aOutputAddress.Col(); + return strCovarianceTemplate; +} - OUString aFormulaString; +ScMatrixComparisonGenerator::GroupedBy ScCovarianceDialog::getGroupedBy() +{ + return mGroupedBy; +} - for (size_t i = 0; i < aRangeList.size(); i++) - { - SCROW outRow = aOutputAddress.Row(); - for (size_t j = 0; j < aRangeList.size(); j++) - { - if (j >= i) - { - OUString aRowString1(aRangeList[i]->Format(SCR_ABS, mDocument, mAddressDetails)); - OUString aRowString2(aRangeList[j]->Format(SCR_ABS, mDocument, mAddressDetails)); +IMPL_LINK_NOARG(ScCovarianceDialog, GroupByChanged) +{ + if (mpGroupByColumnsRadio->IsChecked()) + mGroupedBy = BY_COLUMN; + else if (mpGroupByRowsRadio->IsChecked()) + mGroupedBy = BY_ROW; - aAddress = ScAddress(outCol, outRow, outTab); - aFormulaString = lclCovarTemplate.replaceAll(lclWildcardRow1, aRowString1); - aFormulaString = aFormulaString.replaceAll(lclWildcardRow2, aRowString2); - pDocShell->GetDocFunc().SetFormulaCell(aAddress, new ScFormulaCell(mDocument, aAddress, aFormulaString), true); - } - outRow++; - } - outCol++; - } + return 0; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx new file mode 100644 index 000000000000..d3e22816e04c --- /dev/null +++ b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx @@ -0,0 +1,201 @@ +/* -*- 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/. + * + */ + +#include <sfx2/dispatch.hxx> +#include <svl/zforlist.hxx> +#include <svl/undo.hxx> + +#include "formulacell.hxx" +#include "rangelst.hxx" +#include "scitems.hxx" +#include "docsh.hxx" +#include "document.hxx" +#include "uiitems.hxx" +#include "reffact.hxx" +#include "scresid.hxx" +#include "random.hxx" +#include "docfunc.hxx" +#include "globstr.hrc" +#include "sc.hrc" + +#include "MatrixComparisonGenerator.hxx" + +namespace +{ + static const OUString strWildcard1("%VAR1%"); + static const OUString strWildcard2("%VAR2%"); + + static const OUString strWildcardNumber("%NUMBER%"); + static const OUString strColumnLabelTemplate("Column %NUMBER%"); + static const OUString strRowLabelTemplate("Row %NUMBER%"); +} + +ScMatrixComparisonGenerator::ScMatrixComparisonGenerator( + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + Window* pParent, ScViewData* pViewData, const OString& rID, + const OUString& rUiXmlDescription ) : + ScStatisticsInputOutputDialog(pSfxBindings, pChildWindow, pParent, pViewData, rID, rUiXmlDescription) +{} + +ScMatrixComparisonGenerator::~ScMatrixComparisonGenerator() +{} + +void ScMatrixComparisonGenerator::CalculateInputAndWriteToOutput( ) +{ + OUString aUndo(SC_STRLOAD( RID_STATISTICS_DLGS, STR_CORRELATION_UNDO_NAME)); + ScDocShell* pDocShell = mViewData->GetDocShell(); + svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager(); + pUndoManager->EnterListAction( aUndo, aUndo ); + + ScAddress aStart = mInputRange.aStart; + ScAddress aEnd = mInputRange.aEnd; + + SCTAB outTab = mOutputAddress.Tab(); + SCCOL outCol = mOutputAddress.Col(); + SCROW outRow = mOutputAddress.Row(); + + ScAddress aAddress; + SCCOL aMaxCol = 0; + SCROW aMaxRow = 0; + + SCTAB inTab = aStart.Tab(); + + ScRangeList aRangeList; + + if (getGroupedBy() == BY_COLUMN) + aRangeList = MakeColumnRangeList(inTab, aStart, aEnd); + else + aRangeList = MakeRowRangeList(inTab, aStart, aEnd); + + // labels + aAddress = ScAddress(outCol, outRow, outTab); + pDocShell->GetDocFunc().SetStringCell(aAddress, getLabel(), true); + outCol++; + aMaxCol = outCol > aMaxCol ? outCol : aMaxCol; + + // write labels to columns + for (size_t i = 0; i < aRangeList.size(); i++) + { + aAddress = ScAddress(outCol, outRow, outTab); + OUString aLabel; + if (getGroupedBy() == BY_COLUMN) + aLabel = strColumnLabelTemplate.replaceAll(strWildcardNumber, OUString::number(i + 1)); + else + aLabel = strRowLabelTemplate.replaceAll(strWildcardNumber, OUString::number(i + 1)); + + pDocShell->GetDocFunc().SetStringCell(aAddress, aLabel, true); + outCol++; + aMaxCol = outCol > aMaxCol ? outCol : aMaxCol; + } + + // write labels to rows + outCol = mOutputAddress.Col(); + outRow++; + for (size_t i = 0; i < aRangeList.size(); i++) + { + aAddress = ScAddress(outCol, outRow, outTab); + OUString aLabel; + + if (getGroupedBy() == BY_COLUMN) + aLabel = strColumnLabelTemplate.replaceAll(strWildcardNumber, OUString::number(i + 1)); + else + aLabel = strRowLabelTemplate.replaceAll(strWildcardNumber, OUString::number(i + 1)); + + pDocShell->GetDocFunc().SetStringCell(aAddress, aLabel, true); + outRow++; + aMaxRow = outRow > aMaxRow ? outRow : aMaxRow; + } + + // write correlation formulas + aAddress = ScAddress( + mOutputAddress.Col() + 1, + mOutputAddress.Row() + 1, + inTab); + + if (getGroupedBy() == BY_COLUMN) + writeCorrelationFormulasByColumn(aAddress, aRangeList); + else + writeCorrelationFormulasByRow(aAddress, aRangeList); + + ScAddress aLastAddress = ScAddress( + mOutputAddress.Col() + aMaxCol, + mOutputAddress.Row() + aMaxRow, + outTab); + + ScRange aOutputRange(mOutputAddress, aLastAddress); + pUndoManager->LeaveListAction(); + pDocShell->PostPaint(aOutputRange, PAINT_GRID); +} + +void ScMatrixComparisonGenerator::writeCorrelationFormulasByColumn(ScAddress aOutputAddress, ScRangeList aRangeList) +{ + ScDocShell* pDocShell = mViewData->GetDocShell(); + ScAddress aAddress; + + SCTAB outTab = aOutputAddress.Tab(); + SCCOL outCol = aOutputAddress.Col(); + + OUString aFormulaString; + const OUString& aTemplate = getTemplate(); + + for (size_t i = 0; i < aRangeList.size(); i++) + { + SCROW outRow = aOutputAddress.Row(); + for (size_t j = 0; j < aRangeList.size(); j++) + { + if (j >= i) + { + OUString aString1(aRangeList[i]->Format(SCR_ABS, mDocument, mAddressDetails)); + OUString aString2(aRangeList[j]->Format(SCR_ABS, mDocument, mAddressDetails)); + + aAddress = ScAddress(outCol, outRow, outTab); + aFormulaString = aTemplate.replaceAll(strWildcard1, aString1); + aFormulaString = aFormulaString.replaceAll(strWildcard2, aString2); + pDocShell->GetDocFunc().SetFormulaCell(aAddress, new ScFormulaCell(mDocument, aAddress, aFormulaString), true); + } + outRow++; + } + outCol++; + } +} + +void ScMatrixComparisonGenerator::writeCorrelationFormulasByRow(ScAddress aOutputAddress, ScRangeList aRangeList) +{ + ScDocShell* pDocShell = mViewData->GetDocShell(); + ScAddress aAddress; + + SCTAB outTab = aOutputAddress.Tab(); + SCCOL outCol = aOutputAddress.Col(); + + OUString aFormulaString; + const OUString& aTemplate = getTemplate(); + + for (size_t i = 0; i < aRangeList.size(); i++) + { + SCROW outRow = aOutputAddress.Row(); + for (size_t j = 0; j < aRangeList.size(); j++) + { + if (j >= i) + { + OUString aString1(aRangeList[i]->Format(SCR_ABS, mDocument, mAddressDetails)); + OUString aString2(aRangeList[j]->Format(SCR_ABS, mDocument, mAddressDetails)); + + aAddress = ScAddress(outCol, outRow, outTab); + aFormulaString = aTemplate.replaceAll(strWildcard1, aString1); + aFormulaString = aFormulaString.replaceAll(strWildcard2, aString2); + pDocShell->GetDocFunc().SetFormulaCell(aAddress, new ScFormulaCell(mDocument, aAddress, aFormulaString), true); + } + outRow++; + } + outCol++; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/CorrelationDialog.hxx b/sc/source/ui/inc/CorrelationDialog.hxx index f198175ddbf8..76e94e1eaffb 100644 --- a/sc/source/ui/inc/CorrelationDialog.hxx +++ b/sc/source/ui/inc/CorrelationDialog.hxx @@ -11,32 +11,31 @@ #ifndef CORRELATION_DIALOG_HXX #define CORRELATION_DIALOG_HXX -#include "global.hxx" -#include "address.hxx" -#include "anyrefdg.hxx" +#include "MatrixComparisonGenerator.hxx" -#include <vcl/fixed.hxx> -#include <vcl/group.hxx> -#include <vcl/lstbox.hxx> +class ScCorrelationDialog : public ScMatrixComparisonGenerator +{ +private: + RadioButton* mpGroupByColumnsRadio; + RadioButton* mpGroupByRowsRadio; + GroupedBy mGroupedBy; -#include "StatisticsInputOutputDialog.hxx" + DECL_LINK( GroupByChanged, void* ); -class ScCorrelationDialog : public ScStatisticsInputOutputDialog -{ public: ScCorrelationDialog( - SfxBindings* pB, SfxChildWindow* pCW, - Window* pParent, ScViewData* pViewData ); - - virtual ~ScCorrelationDialog(); + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + Window* pParent, ScViewData* pViewData); virtual sal_Bool Close(); protected: - virtual void CalculateInputAndWriteToOutput(); - void WriteCorrelationFormulas(ScAddress aOutputAddress, ScRangeList aRangeList); + virtual const OUString& getLabel(); + virtual const OUString& getTemplate(); + virtual GroupedBy getGroupedBy(); }; + #endif diff --git a/sc/source/ui/inc/CovarianceDialog.hxx b/sc/source/ui/inc/CovarianceDialog.hxx index 6aa933182543..675f3dbf5a0d 100644 --- a/sc/source/ui/inc/CovarianceDialog.hxx +++ b/sc/source/ui/inc/CovarianceDialog.hxx @@ -11,30 +11,28 @@ #ifndef COVARIANCE_DIALOG_HXX #define COVARIANCE_DIALOG_HXX -#include "global.hxx" -#include "address.hxx" -#include "anyrefdg.hxx" +#include "MatrixComparisonGenerator.hxx" -#include <vcl/fixed.hxx> -#include <vcl/group.hxx> -#include <vcl/lstbox.hxx> +class ScCovarianceDialog : public ScMatrixComparisonGenerator +{ +private: + RadioButton* mpGroupByColumnsRadio; + RadioButton* mpGroupByRowsRadio; + GroupedBy mGroupedBy; -#include "StatisticsInputOutputDialog.hxx" + DECL_LINK( GroupByChanged, void* ); -class ScCovarianceDialog : public ScStatisticsInputOutputDialog -{ public: ScCovarianceDialog( - SfxBindings* pB, SfxChildWindow* pCW, - Window* pParent, ScViewData* pViewData ); - - virtual ~ScCovarianceDialog(); + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + Window* pParent, ScViewData* pViewData); virtual sal_Bool Close(); protected: - virtual void CalculateInputAndWriteToOutput(); - void WriteCovarianceFormulas(ScAddress aOutputAddress, ScRangeList aRangeList); + 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 new file mode 100644 index 000000000000..6a0af4c37a7e --- /dev/null +++ b/sc/source/ui/inc/MatrixComparisonGenerator.hxx @@ -0,0 +1,53 @@ +/* -*- 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/. + * + */ + +#ifndef MATRIX_COMPARISON_GENERATOR_HXX +#define MATRIX_COMPARISON_GENERATOR_HXX + +#include "global.hxx" +#include "address.hxx" +#include "anyrefdg.hxx" + +#include <vcl/fixed.hxx> +#include <vcl/group.hxx> +#include <vcl/lstbox.hxx> + +#include "StatisticsInputOutputDialog.hxx" + +class ScMatrixComparisonGenerator : public ScStatisticsInputOutputDialog +{ +public: + ScMatrixComparisonGenerator( + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + Window* pParent, ScViewData* pViewData, + const OString& rID, const OUString& rUiXmlDescription ); + + 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); +}; + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |