diff options
24 files changed, 632 insertions, 4 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index e602c133dbd3..1bea73a66acf 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -661,6 +661,22 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:CorrelationDialog" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">~Correlation...</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> + <node oor:name=".uno:CovarianceDialog" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">~Covariance...</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> <node oor:name=".uno:EditHeaderAndFooter" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Headers & Footers...</value> diff --git a/sc/AllLangResTarget_sc.mk b/sc/AllLangResTarget_sc.mk index 88f60ad99dcb..5f43eb35ab05 100644 --- a/sc/AllLangResTarget_sc.mk +++ b/sc/AllLangResTarget_sc.mk @@ -83,6 +83,9 @@ $(eval $(call gb_SrsTarget_add_files,sc/res,\ sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.src \ sc/source/ui/StatisticsDialogs/SamplingDialog.src \ sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.src \ + sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.src \ + sc/source/ui/StatisticsDialogs/CorrelationDialog.src \ + sc/source/ui/StatisticsDialogs/CovarianceDialog.src \ sc/source/core/src/compiler.src \ )) diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 72a83a5cf763..6f559f5bad1e 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -478,6 +478,8 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/ui/StatisticsDialogs/SamplingDialog \ sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog \ sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog \ + sc/source/ui/StatisticsDialogs/CorrelationDialog \ + sc/source/ui/StatisticsDialogs/CovarianceDialog \ sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog \ sc/source/ui/undo/areasave \ sc/source/ui/undo/refundo \ diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index 7a7cf0a0deb9..2f8e56230a6b 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -720,7 +720,10 @@ #define SID_CALC_SUM 585 #define SID_CALC_COUNT 586 -#define STR_DESCRIPTIVE_STATISTICS_UNDO_NAME 587 +#define STR_DESCRIPTIVE_STATISTICS_UNDO_NAME 587 +#define STR_ANALYSIS_OF_VARIANCE_UNDO_NAME 588 +#define STR_CORRELATION_UNDO_NAME 589 +#define STR_COVARIANCE_UNDO_NAME 590 #endif diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 7ee45d0eefdc..8611337444bc 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -256,6 +256,8 @@ #define SID_SAMPLING_DIALOG (SC_MESSAGE_START + 71) #define SID_DESCRIPTIVE_STATISTICS_DIALOG (SC_MESSAGE_START + 72) #define SID_ANALYSIS_OF_VARIANCE_DIALOG (SC_MESSAGE_START + 73) +#define SID_CORRELATION_DIALOG (SC_MESSAGE_START + 74) +#define SID_COVARIANCE_DIALOG (SC_MESSAGE_START + 75) // functions diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index 31ff7f0ebca4..d9e189376236 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -151,6 +151,8 @@ interface CellSelection SID_SAMPLING_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_DESCRIPTIVE_STATISTICS_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_ANALYSIS_OF_VARIANCE_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] + SID_CORRELATION_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] + SID_COVARIANCE_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_MARKDATAAREA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ] SID_MARKARRAYFORMULA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ] SID_SETINPUTMODE [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ] diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 0a7c0ebd0a8e..2f5024ae59dc 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -3038,6 +3038,54 @@ SfxVoidItem AnalysisOfVarianceDialog SID_ANALYSIS_OF_VARIANCE_DIALOG GroupId = GID_OPTIONS; ] +SfxVoidItem CorrelationDialog SID_CORRELATION_DIALOG +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = TRUE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_OPTIONS; +] + +SfxVoidItem CovarianceDialog SID_COVARIANCE_DIALOG +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = TRUE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_OPTIONS; +] + //-------------------------------------------------------------------------- SfxVoidItem SolverDialog SID_OPENDLG_OPTSOLVER () diff --git a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx index 2c7325ab7f81..20d2c8612114 100644 --- a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx @@ -30,6 +30,7 @@ namespace { + static const char* lclBasicStatisticsLabels[] = { "Groups", "Count", "Sum", "Mean", "Variance", NULL @@ -45,6 +46,8 @@ static const char* lclAnovaLabels[] = "Source of Variation", "SS", "df", "MS", "F", "P-value", "F critical", NULL }; +static const OUString lclWildcardNumber("%NUMBER%"); +static const OUString lclColumnLabelTemplate("Column %NUMBER%"); static const OUString lclWildcardRange("%RANGE%"); OUString lclCreateMultiParameterFormula( @@ -87,7 +90,8 @@ sal_Bool ScAnalysisOfVarianceDialog::Close() void ScAnalysisOfVarianceDialog::CalculateInputAndWriteToOutput( ) { - OUString aUndo("Analysis Of Variance"); + OUString aUndo(SC_RESSTR(STR_ANALYSIS_OF_VARIANCE_UNDO_NAME)); + ScDocShell* pDocShell = mViewData->GetDocShell(); svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager(); pUndoManager->EnterListAction( aUndo, aUndo ); @@ -123,7 +127,8 @@ void ScAnalysisOfVarianceDialog::CalculateInputAndWriteToOutput( ) { outCol = mOutputAddress.Col(); aAddress = ScAddress(outCol, outRow, outTab); - OUString aGroupName = OUString("Column ") + OUString::number(inCol - aStart.Col() + 1); + OUString aNumberString = OUString::number(inCol - aStart.Col() + 1); + OUString aGroupName = lclColumnLabelTemplate.replaceAll(lclWildcardNumber, aNumberString); pDocShell->GetDocFunc().SetStringCell(aAddress, aGroupName, true); outCol++; diff --git a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.src b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.src new file mode 100644 index 000000000000..dffcb11dac92 --- /dev/null +++ b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.src @@ -0,0 +1,19 @@ +/* -*- 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 "globstr.hrc" + +String STR_ANALYSIS_OF_VARIANCE_UNDO_NAME +{ + Text [ en-US ] = "Analysis of Variance"; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx b/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx new file mode 100644 index 000000000000..9f26c8c8eec4 --- /dev/null +++ b/sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx @@ -0,0 +1,160 @@ +/* -*- 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 "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%"); + +} + +ScCorrelationDialog::ScCorrelationDialog( + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + Window* pParent, ScViewData* pViewData ) : + ScStatisticsInputOutputDialog( + pSfxBindings, pChildWindow, pParent, pViewData, + "DescriptiveStatisticsDialog", "modules/scalc/ui/descriptivestatisticsdialog.ui" ) +{} + +ScCorrelationDialog::~ScCorrelationDialog() +{} + +sal_Bool ScCorrelationDialog::Close() +{ + return DoClose( ScCorrelationDialogWrapper::GetChildWindowId() ); +} + +void ScCorrelationDialog::CalculateInputAndWriteToOutput( ) +{ + OUString aUndo(SC_RESSTR(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); +} + +void ScCorrelationDialog::WriteCorrelationFormulas(ScAddress aOutputAddress, ScRangeList aRangeList) +{ + ScDocShell* pDocShell = mViewData->GetDocShell(); + OUString aColumnString1; + OUString aColumnString2; + ScAddress aAddress; + + SCTAB outTab = aOutputAddress.Tab(); + SCCOL outCol = aOutputAddress.Col(); + + OUString aFormulaString; + + 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) + { + aRangeList[i]->Format( aColumnString1, SCR_ABS, mDocument, mAddressDetails ); + aRangeList[j]->Format( aColumnString2, SCR_ABS, mDocument, mAddressDetails ); + + 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++; + } +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/CorrelationDialog.src b/sc/source/ui/StatisticsDialogs/CorrelationDialog.src new file mode 100644 index 000000000000..84e7e398a8b2 --- /dev/null +++ b/sc/source/ui/StatisticsDialogs/CorrelationDialog.src @@ -0,0 +1,19 @@ +/* -*- 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 "globstr.hrc" + +String STR_CORRELATION_UNDO_NAME +{ + Text [ en-US ] = "Correlation"; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx b/sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx new file mode 100644 index 000000000000..94a62da7f7e2 --- /dev/null +++ b/sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx @@ -0,0 +1,159 @@ +/* -*- 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 "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%"); + +} + +ScCovarianceDialog::ScCovarianceDialog( + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + Window* pParent, ScViewData* pViewData ) : + ScStatisticsInputOutputDialog( + pSfxBindings, pChildWindow, pParent, pViewData, + "DescriptiveStatisticsDialog", "modules/scalc/ui/descriptivestatisticsdialog.ui" ) +{} + +ScCovarianceDialog::~ScCovarianceDialog() +{} + +sal_Bool ScCovarianceDialog::Close() +{ + return DoClose( ScCovarianceDialogWrapper::GetChildWindowId() ); +} + +void ScCovarianceDialog::CalculateInputAndWriteToOutput( ) +{ + OUString aUndo(SC_RESSTR(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); +} + +void ScCovarianceDialog::WriteCovarianceFormulas(ScAddress aOutputAddress, ScRangeList aRangeList) +{ + ScDocShell* pDocShell = mViewData->GetDocShell(); + OUString aRowString1; + OUString aRowString2; + ScAddress aAddress; + + SCTAB outTab = aOutputAddress.Tab(); + SCCOL outCol = aOutputAddress.Col(); + + OUString aFormulaString; + + 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) + { + aRangeList[i]->Format( aRowString1, SCR_ABS, mDocument, mAddressDetails ); + aRangeList[j]->Format( aRowString2, SCR_ABS, mDocument, mAddressDetails ); + + 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++; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/CovarianceDialog.src b/sc/source/ui/StatisticsDialogs/CovarianceDialog.src new file mode 100644 index 000000000000..f3ca409a3dcf --- /dev/null +++ b/sc/source/ui/StatisticsDialogs/CovarianceDialog.src @@ -0,0 +1,19 @@ +/* -*- 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 "globstr.hrc" + +String STR_COVARIANCE_UNDO_NAME +{ + Text [ en-US ] = "Covariance"; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx index 7a01131d176f..7d868705192f 100644 --- a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx @@ -25,6 +25,34 @@ #include "StatisticsInputOutputDialog.hxx" +ScRangeList ScStatisticsInputOutputDialog::MakeColumnRangeList(SCTAB aTab, ScAddress aStart, ScAddress aEnd) +{ + ScRangeList aRangeList; + for (SCCOL inCol = aStart.Col(); inCol <= aEnd.Col(); inCol++) + { + ScRange aColumnRange ( + ScAddress(inCol, aStart.Row(), aTab), + ScAddress(inCol, aEnd.Row(), aTab) ); + + aRangeList.Append(aColumnRange); + } + return aRangeList; +} + +ScRangeList ScStatisticsInputOutputDialog::MakeRowRangeList(SCTAB aTab, ScAddress aStart, ScAddress aEnd) +{ + ScRangeList aRangeList; + for (SCROW inRow = aStart.Row(); inRow <= aEnd.Row(); inRow++) + { + ScRange aRowRange ( + ScAddress(aStart.Col(), inRow, aTab), + ScAddress(aEnd.Col(), inRow, aTab) ); + + aRangeList.Append(aRowRange); + } + return aRangeList; +} + ScStatisticsInputOutputDialog::ScStatisticsInputOutputDialog( SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, Window* pParent, ScViewData* pViewData, const OString& rID, const OUString& rUIXMLDescription ) : diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx index e0b4489a8744..c2ae6e59ce5a 100644 --- a/sc/source/ui/app/scdll.cxx +++ b/sc/source/ui/app/scdll.cxx @@ -271,6 +271,8 @@ void ScDLL::Init() ScSamplingDialogWrapper ::RegisterChildWindow(false, pMod); ScDescriptiveStatisticsDialogWrapper::RegisterChildWindow(false, pMod); ScAnalysisOfVarianceDialogWrapper ::RegisterChildWindow(false, pMod); + ScCorrelationDialogWrapper ::RegisterChildWindow(false, pMod); + ScCovarianceDialogWrapper ::RegisterChildWindow(false, pMod); // First docking Window for Calc ScFunctionChildWindow ::RegisterChildWindow(false, pMod); diff --git a/sc/source/ui/inc/CorrelationDialog.hxx b/sc/source/ui/inc/CorrelationDialog.hxx new file mode 100644 index 000000000000..f198175ddbf8 --- /dev/null +++ b/sc/source/ui/inc/CorrelationDialog.hxx @@ -0,0 +1,43 @@ +/* -*- 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 CORRELATION_DIALOG_HXX +#define CORRELATION_DIALOG_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 ScCorrelationDialog : public ScStatisticsInputOutputDialog +{ +public: + ScCorrelationDialog( + SfxBindings* pB, SfxChildWindow* pCW, + Window* pParent, ScViewData* pViewData ); + + virtual ~ScCorrelationDialog(); + + virtual sal_Bool Close(); + +protected: + virtual void CalculateInputAndWriteToOutput(); + void WriteCorrelationFormulas(ScAddress aOutputAddress, ScRangeList aRangeList); +}; + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/CovarianceDialog.hxx b/sc/source/ui/inc/CovarianceDialog.hxx new file mode 100644 index 000000000000..6aa933182543 --- /dev/null +++ b/sc/source/ui/inc/CovarianceDialog.hxx @@ -0,0 +1,43 @@ +/* -*- 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 COVARIANCE_DIALOG_HXX +#define COVARIANCE_DIALOG_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 ScCovarianceDialog : public ScStatisticsInputOutputDialog +{ +public: + ScCovarianceDialog( + SfxBindings* pB, SfxChildWindow* pCW, + Window* pParent, ScViewData* pViewData ); + + virtual ~ScCovarianceDialog(); + + virtual sal_Bool Close(); + +protected: + virtual void CalculateInputAndWriteToOutput(); + void WriteCovarianceFormulas(ScAddress aOutputAddress, ScRangeList aRangeList); +}; + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/StatisticsInputOutputDialog.hxx b/sc/source/ui/inc/StatisticsInputOutputDialog.hxx index 4d0c0bbc9533..a6ad9a72b450 100644 --- a/sc/source/ui/inc/StatisticsInputOutputDialog.hxx +++ b/sc/source/ui/inc/StatisticsInputOutputDialog.hxx @@ -52,6 +52,10 @@ protected: ScAddress::Details mAddressDetails; ScAddress mOutputAddress; + static ScRangeList MakeColumnRangeList(SCTAB aTab, ScAddress aStart, ScAddress aEnd); + static ScRangeList MakeRowRangeList(SCTAB aTab, ScAddress aStart, ScAddress aEnd); + + private: // Widgets PushButton* mpButtonApply; diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx index 08d191bcb925..27c0d1368a4c 100644 --- a/sc/source/ui/inc/reffact.hxx +++ b/sc/source/ui/inc/reffact.hxx @@ -81,6 +81,19 @@ private: ScAnalysisOfVarianceDialogWrapper() SAL_DELETED_FUNCTION; }; +class ScCorrelationDialogWrapper : + public ChildWindowWrapper<SID_CORRELATION_DIALOG> +{ +private: + ScCorrelationDialogWrapper() SAL_DELETED_FUNCTION; +}; + +class ScCovarianceDialogWrapper : + public ChildWindowWrapper<SID_COVARIANCE_DIALOG> +{ +private: + ScCovarianceDialogWrapper() SAL_DELETED_FUNCTION; +}; class ScAcceptChgDlgWrapper: public SfxChildWindow { diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index 85a750650ea7..239d1be952f2 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -175,6 +175,8 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet ) case SID_SAMPLING_DIALOG: case SID_DESCRIPTIVE_STATISTICS_DIALOG: case SID_ANALYSIS_OF_VARIANCE_DIALOG: + case SID_CORRELATION_DIALOG: + case SID_COVARIANCE_DIALOG: { bDisable = !bSimpleArea; } diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index e80266f353df..dc6cfa57f838 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -938,6 +938,24 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) pScMod->SetRefDialog( nId, pWnd ? false : sal_True ); } break; + case SID_CORRELATION_DIALOG: + { + sal_uInt16 nId = ScCorrelationDialogWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? false : sal_True ); + } + break; + case SID_COVARIANCE_DIALOG: + { + sal_uInt16 nId = ScCovarianceDialogWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? false : sal_True ); + } + break; // // disposal (Outlines) diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx index 02999e14bc45..dde0afd8fa1c 100644 --- a/sc/source/ui/view/tabvwsh.cxx +++ b/sc/source/ui/view/tabvwsh.cxx @@ -85,6 +85,9 @@ SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL)) SFX_CHILDWINDOW_REGISTRATION(ScSamplingDialogWrapper::GetChildWindowId()); SFX_CHILDWINDOW_REGISTRATION(ScDescriptiveStatisticsDialogWrapper::GetChildWindowId()); SFX_CHILDWINDOW_REGISTRATION(ScAnalysisOfVarianceDialogWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScCorrelationDialogWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScCovarianceDialogWrapper::GetChildWindowId()); + } SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" ) diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index a55d676a2a04..309a3e069bc6 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -65,7 +65,8 @@ #include "SamplingDialog.hxx" #include "DescriptiveStatisticsDialog.hxx" #include "AnalysisOfVarianceDialog.hxx" - +#include "CorrelationDialog.hxx" +#include "CovarianceDialog.hxx" //------------------------------------------------------------------ @@ -341,6 +342,18 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( } break; + case SID_CORRELATION_DIALOG: + { + pResult = new ScCorrelationDialog( pB, pCW, pParent, GetViewData() ); + } + break; + + case SID_COVARIANCE_DIALOG: + { + pResult = new ScCovarianceDialog( pB, pCW, pParent, GetViewData() ); + } + break; + case SID_OPENDLG_OPTSOLVER: { ScViewData* pViewData = GetViewData(); diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index a45cf12d6377..d2bda57b53ad 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -485,6 +485,8 @@ <menu:menuitem menu:id=".uno:SamplingDialog"/> <menu:menuitem menu:id=".uno:DescriptiveStatisticsDialog"/> <menu:menuitem menu:id=".uno:AnalysisOfVarianceDialog"/> + <menu:menuitem menu:id=".uno:CorrelationDialog"/> + <menu:menuitem menu:id=".uno:CovarianceDialog"/> </menu:menupopup> </menu:menu> </menu:menupopup> |