diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2013-11-10 18:05:29 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2013-11-11 23:22:33 +0100 |
commit | 1b4c3fad813a2673f14f88fcb8876e1bef118c6e (patch) | |
tree | 8022e72424df1c0f1f30859bcc976f9d204ea861 /sc/source | |
parent | a025cd4b00a2f6408c5bfbb932d8cee35a62b66a (diff) |
Simplification and better output of statistics dialogs.
Change-Id: Ia21bb07f7721a7697807f8ee98706bd3fc136653
Diffstat (limited to 'sc/source')
14 files changed, 127 insertions, 62 deletions
diff --git a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx index 4257165e6e5d..7c3873be01ba 100644 --- a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx @@ -87,17 +87,20 @@ sal_Bool ScAnalysisOfVarianceDialog::Close() return DoClose( ScAnalysisOfVarianceDialogWrapper::GetChildWindowId() ); } -void ScAnalysisOfVarianceDialog::CalculateInputAndWriteToOutput( ) +sal_Int16 ScAnalysisOfVarianceDialog::GetUndoNameId() { - OUString aUndo( SC_STRLOAD( RID_STATISTICS_DLGS, STR_ANALYSIS_OF_VARIANCE_UNDO_NAME)); - - ScDocShell* pDocShell = mViewData->GetDocShell(); - svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager(); - pUndoManager->EnterListAction( aUndo, aUndo ); + return STR_ANALYSIS_OF_VARIANCE_UNDO_NAME; +} +ScRange ScAnalysisOfVarianceDialog::ApplyOutput(ScDocShell* pDocShell) +{ AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument); FormulaTemplate aTemplate(mDocument, mAddressDetails); + output.writeBoldString("ANOVA - Single Factor"); + output.nextRow(); + output.nextRow(); + // Write labels for(sal_Int32 i = 0; lclBasicStatisticsLabels[i] != NULL; i++) { @@ -114,7 +117,7 @@ void ScAnalysisOfVarianceDialog::CalculateInputAndWriteToOutput( ) else pIterator.reset(new DataRangeByRowIterator(mInputRange)); - // Write statistic formulas for columns + // Write statistic formulas for rows/columns for( ; pIterator->hasNext(); pIterator->next() ) { output.resetColumn(); @@ -124,7 +127,7 @@ void ScAnalysisOfVarianceDialog::CalculateInputAndWriteToOutput( ) else aTemplate.setTemplate(strRowLabelTemplate); - aTemplate.applyString(strWildcardNumber, OUString::number(pIterator->index() + 1)); + aTemplate.applyNumber(strWildcardNumber, pIterator->index() + 1); pDocShell->GetDocFunc().SetStringCell(output.current(), aTemplate.getTemplate(), true); output.nextColumn(); @@ -260,9 +263,7 @@ void ScAnalysisOfVarianceDialog::CalculateInputAndWriteToOutput( ) } output.nextRow(); - ScRange aOutputRange(output.mMinimumAddress, output.mMaximumAddress); - pUndoManager->LeaveListAction(); - pDocShell->PostPaint( aOutputRange, PAINT_GRID ); + return ScRange(output.mMinimumAddress, output.mMaximumAddress); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx index d9a18a002e6f..2fc1b5556f2b 100644 --- a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx @@ -56,7 +56,9 @@ static const StatisticCalculation lclCalcDefinitions[] = }; static const OUString strWildcardRange("%RANGE%"); - +static const OUString strWildcardNumber("%NUMBER%"); +static const OUString strColumnLabelTemplate("Column %NUMBER%"); +static const OUString strRowLabelTemplate("Row %NUMBER%"); } ScDescriptiveStatisticsDialog::ScDescriptiveStatisticsDialog( @@ -75,18 +77,42 @@ sal_Bool ScDescriptiveStatisticsDialog::Close() return DoClose( ScDescriptiveStatisticsDialogWrapper::GetChildWindowId() ); } -void ScDescriptiveStatisticsDialog::CalculateInputAndWriteToOutput( ) +sal_Int16 ScDescriptiveStatisticsDialog::GetUndoNameId() { - OUString aUndo(SC_STRLOAD(RID_STATISTICS_DLGS, STR_DESCRIPTIVE_STATISTICS_UNDO_NAME)); - ScDocShell* pDocShell = mViewData->GetDocShell(); - svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager(); - pUndoManager->EnterListAction( aUndo, aUndo ); + return STR_DESCRIPTIVE_STATISTICS_UNDO_NAME; +} +ScRange ScDescriptiveStatisticsDialog::ApplyOutput(ScDocShell* pDocShell) +{ OUString aReferenceString; AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument); FormulaTemplate aTemplate(mDocument, mAddressDetails); + boost::scoped_ptr<DataRangeIterator> pIterator; + if (mGroupedBy == BY_COLUMN) + pIterator.reset(new DataRangeByColumnIterator(mInputRange)); + else + pIterator.reset(new DataRangeByRowIterator(mInputRange)); + + aOutput.nextColumn(); + + // Write column/row labels + for( ; pIterator->hasNext(); pIterator->next() ) + { + if (mGroupedBy == BY_COLUMN) + aTemplate.setTemplate(strColumnLabelTemplate); + else + aTemplate.setTemplate(strRowLabelTemplate); + aTemplate.applyNumber(strWildcardNumber, pIterator->index() + 1); + aOutput.writeBoldString(aTemplate.getTemplate()); + aOutput.nextColumn(); + } + aOutput.nextRow(); + aOutput.resetColumn(); + aOutput.push(); + + // Write calculation labels for(sal_Int32 i = 0; lclCalcDefinitions[i].aFormula != NULL; i++) { OUString aLabel(SC_STRLOAD(RID_STATISTICS_DLGS, lclCalcDefinitions[i].aCalculationNameId)); @@ -95,11 +121,7 @@ void ScDescriptiveStatisticsDialog::CalculateInputAndWriteToOutput( ) } aOutput.nextColumn(); - boost::scoped_ptr<DataRangeIterator> pIterator; - if (mGroupedBy == BY_COLUMN) - pIterator.reset(new DataRangeByColumnIterator(mInputRange)); - else - pIterator.reset(new DataRangeByRowIterator(mInputRange)); + pIterator->reset(); for( ; pIterator->hasNext(); pIterator->next() ) { @@ -115,9 +137,7 @@ void ScDescriptiveStatisticsDialog::CalculateInputAndWriteToOutput( ) aOutput.nextColumn(); } - pUndoManager->LeaveListAction(); - ScRange aOutputRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress); - pDocShell->PostPaint( aOutputRange, PAINT_GRID ); + return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx b/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx index 34cfcf477e64..9e4cb9bf8978 100644 --- a/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx @@ -45,19 +45,24 @@ sal_Bool ScExponentialSmoothingDialog::Close() return DoClose( ScExponentialSmoothingDialogWrapper::GetChildWindowId() ); } -void ScExponentialSmoothingDialog::CalculateInputAndWriteToOutput( ) +sal_Int16 ScExponentialSmoothingDialog::GetUndoNameId() { - OUString aUndo(SC_STRLOAD(RID_STATISTICS_DLGS, STR_EXPONENTIAL_SMOOTHING_UNDO_NAME)); - ScDocShell* pDocShell = mViewData->GetDocShell(); - svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager(); - pUndoManager->EnterListAction( aUndo, aUndo ); + return STR_EXPONENTIAL_SMOOTHING_UNDO_NAME; +} +ScRange ScExponentialSmoothingDialog::ApplyOutput(ScDocShell* pDocShell) +{ AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument); FormulaTemplate aTemplate(mDocument, mAddressDetails); // Smoothing factor double aSmoothingFactor = mpSmoothingFactor->GetValue() / 100.0; + // Alpha + output.writeBoldString("Alpha"); + output.nextRow(); + + // Alpha Value ScAddress aSmoothingFactorAddress = output.current(); output.writeValue(aSmoothingFactor); output.nextRow(); @@ -77,6 +82,16 @@ void ScExponentialSmoothingDialog::CalculateInputAndWriteToOutput( ) ScRange aCurrentRange = pIterator->get(); + // Write column label + if (mGroupedBy == BY_COLUMN) + aTemplate.setTemplate("Column %NUMBER%"); + else + aTemplate.setTemplate("Row %NUMBER%"); + aTemplate.applyNumber("%NUMBER%", pIterator->index() + 1); + output.writeBoldString(aTemplate.getTemplate()); + output.nextRow(); + + // Initial value if (false) { aTemplate.setTemplate("=AVERAGE(%RANGE%)"); @@ -107,9 +122,7 @@ void ScExponentialSmoothingDialog::CalculateInputAndWriteToOutput( ) output.nextColumn(); } - pUndoManager->LeaveListAction(); - ScRange aOutputRange(output.mMinimumAddress, output.mMaximumAddress); - pDocShell->PostPaint( aOutputRange, PAINT_GRID ); + return ScRange (output.mMinimumAddress, output.mMaximumAddress); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx index b22a66a115d8..07a7589eeeed 100644 --- a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx +++ b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx @@ -71,13 +71,13 @@ ScMatrixComparisonGenerator::ScMatrixComparisonGenerator( ScMatrixComparisonGenerator::~ScMatrixComparisonGenerator() {} -void ScMatrixComparisonGenerator::CalculateInputAndWriteToOutput( ) +sal_Int16 ScMatrixComparisonGenerator::GetUndoNameId() { - OUString aUndo(SC_STRLOAD(RID_STATISTICS_DLGS, STR_CORRELATION_UNDO_NAME)); - ScDocShell* pDocShell = mViewData->GetDocShell(); - svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager(); - pUndoManager->EnterListAction( aUndo, aUndo ); + return STR_CORRELATION_UNDO_NAME; +} +ScRange ScMatrixComparisonGenerator::ApplyOutput(ScDocShell* pDocShell) +{ AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument); FormulaTemplate aTemplate(mDocument, mAddressDetails); @@ -128,9 +128,7 @@ void ScMatrixComparisonGenerator::CalculateInputAndWriteToOutput( ) lclWriteCorrelationFormulas(output, aTemplate, aRangeList, getTemplate()); - ScRange aOutputRange(output.mMinimumAddress, output.mMaximumAddress); - pUndoManager->LeaveListAction(); - pDocShell->PostPaint(aOutputRange, PAINT_GRID); + return ScRange(output.mMinimumAddress, output.mMaximumAddress); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx b/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx index d3af93e5b868..04f424526453 100644 --- a/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx @@ -45,13 +45,13 @@ sal_Bool ScMovingAverageDialog::Close() return DoClose( ScMovingAverageDialogWrapper::GetChildWindowId() ); } -void ScMovingAverageDialog::CalculateInputAndWriteToOutput( ) +sal_Int16 ScMovingAverageDialog::GetUndoNameId() { - OUString aUndo(SC_STRLOAD(RID_STATISTICS_DLGS, STR_MOVING_AVERAGE_UNDO_NAME)); - ScDocShell* pDocShell = mViewData->GetDocShell(); - svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager(); - pUndoManager->EnterListAction( aUndo, aUndo ); + return STR_MOVING_AVERAGE_UNDO_NAME; +} +ScRange ScMovingAverageDialog::ApplyOutput(ScDocShell* pDocShell) +{ AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument); FormulaTemplate aTemplate(mDocument, mAddressDetails); @@ -68,10 +68,13 @@ void ScMovingAverageDialog::CalculateInputAndWriteToOutput( ) { output.resetRow(); - // Write column label - aTemplate.setTemplate("Column %NUMBER%"); + // Write label + if (mGroupedBy == BY_COLUMN) + aTemplate.setTemplate("Column %NUMBER%"); + else + aTemplate.setTemplate("Row %NUMBER%"); aTemplate.applyNumber("%NUMBER%", pIterator->index() + 1); - output.writeString(aTemplate.getTemplate()); + output.writeBoldString(aTemplate.getTemplate()); output.nextRow(); DataCellIterator aDataCellIterator = pIterator->iterateCells(); @@ -102,16 +105,13 @@ void ScMovingAverageDialog::CalculateInputAndWriteToOutput( ) } else { - output.writeString("N/A"); + output.writeFormula("=#N/A"); } output.nextRow(); } output.nextColumn(); } - - pUndoManager->LeaveListAction(); - ScRange aOutputRange(output.mMinimumAddress, output.mMaximumAddress); - pDocShell->PostPaint( aOutputRange, PAINT_GRID ); + return ScRange(output.mMinimumAddress, output.mMaximumAddress); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx index 7374965e2bc3..787f17bb2dc5 100644 --- a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx @@ -22,6 +22,7 @@ #include "scresid.hxx" #include "random.hxx" #include "docfunc.hxx" +#include "strload.hxx" #include "StatisticsInputOutputDialog.hxx" @@ -222,4 +223,17 @@ IMPL_LINK_NOARG( ScStatisticsInputOutputDialog, GroupByChanged ) return 0; } +void ScStatisticsInputOutputDialog::CalculateInputAndWriteToOutput() +{ + OUString aUndo(SC_STRLOAD(RID_STATISTICS_DLGS, GetUndoNameId())); + ScDocShell* pDocShell = mViewData->GetDocShell(); + svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager(); + pUndoManager->EnterListAction( aUndo, aUndo ); + + ScRange aOutputRange = ApplyOutput(pDocShell); + + pUndoManager->LeaveListAction(); + pDocShell->PostPaint( aOutputRange, PAINT_GRID ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx b/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx index a98257d7900a..efd4581e70e0 100644 --- a/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx +++ b/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx @@ -273,6 +273,11 @@ ScRange DataRangeByColumnIterator::get() ); } +void DataRangeByColumnIterator::reset() +{ + mCol = mInputRange.aStart.Col(); +} + DataCellIterator DataRangeByColumnIterator::iterateCells() { return DataCellIterator(get(), false); @@ -304,6 +309,11 @@ ScRange DataRangeByRowIterator::get() ); } +void DataRangeByRowIterator::reset() +{ + mRow = mInputRange.aStart.Row(); +} + DataCellIterator DataRangeByRowIterator::iterateCells() { return DataCellIterator(get(), true); diff --git a/sc/source/ui/inc/AnalysisOfVarianceDialog.hxx b/sc/source/ui/inc/AnalysisOfVarianceDialog.hxx index 552c2b9b5aa6..85ebc3848ba9 100644 --- a/sc/source/ui/inc/AnalysisOfVarianceDialog.hxx +++ b/sc/source/ui/inc/AnalysisOfVarianceDialog.hxx @@ -36,7 +36,8 @@ public: virtual sal_Bool Close(); protected: - virtual void CalculateInputAndWriteToOutput(); + virtual sal_Int16 GetUndoNameId(); + virtual ScRange ApplyOutput(ScDocShell* pDocShell); }; #endif diff --git a/sc/source/ui/inc/DescriptiveStatisticsDialog.hxx b/sc/source/ui/inc/DescriptiveStatisticsDialog.hxx index b2003b6b5191..a31180a31da5 100644 --- a/sc/source/ui/inc/DescriptiveStatisticsDialog.hxx +++ b/sc/source/ui/inc/DescriptiveStatisticsDialog.hxx @@ -33,7 +33,8 @@ public: virtual sal_Bool Close(); protected: - virtual void CalculateInputAndWriteToOutput(); + virtual sal_Int16 GetUndoNameId(); + virtual ScRange ApplyOutput(ScDocShell* pDocShell); }; #endif diff --git a/sc/source/ui/inc/ExponentialSmoothingDialog.hxx b/sc/source/ui/inc/ExponentialSmoothingDialog.hxx index 57ae9977808f..3aa2dd5c39a4 100644 --- a/sc/source/ui/inc/ExponentialSmoothingDialog.hxx +++ b/sc/source/ui/inc/ExponentialSmoothingDialog.hxx @@ -36,7 +36,8 @@ public: virtual sal_Bool Close(); protected: - virtual void CalculateInputAndWriteToOutput(); + virtual sal_Int16 GetUndoNameId(); + virtual ScRange ApplyOutput(ScDocShell* pDocShell); }; #endif diff --git a/sc/source/ui/inc/MatrixComparisonGenerator.hxx b/sc/source/ui/inc/MatrixComparisonGenerator.hxx index 61edd0f4b5e1..88c8f17f64e4 100644 --- a/sc/source/ui/inc/MatrixComparisonGenerator.hxx +++ b/sc/source/ui/inc/MatrixComparisonGenerator.hxx @@ -32,7 +32,8 @@ public: virtual ~ScMatrixComparisonGenerator(); protected: - virtual void CalculateInputAndWriteToOutput(); + virtual sal_Int16 GetUndoNameId(); + virtual ScRange ApplyOutput(ScDocShell* pDocShell); virtual const OUString& getLabel() = 0; virtual const OUString& getTemplate() = 0; diff --git a/sc/source/ui/inc/MovingAverageDialog.hxx b/sc/source/ui/inc/MovingAverageDialog.hxx index ee5b2bfa63d3..ed41600d1f1d 100644 --- a/sc/source/ui/inc/MovingAverageDialog.hxx +++ b/sc/source/ui/inc/MovingAverageDialog.hxx @@ -36,7 +36,8 @@ public: virtual sal_Bool Close(); protected: - virtual void CalculateInputAndWriteToOutput(); + virtual sal_Int16 GetUndoNameId(); + virtual ScRange ApplyOutput(ScDocShell* pDocShell); }; #endif diff --git a/sc/source/ui/inc/StatisticsInputOutputDialog.hxx b/sc/source/ui/inc/StatisticsInputOutputDialog.hxx index b4d83444ba47..8a316b47e45f 100644 --- a/sc/source/ui/inc/StatisticsInputOutputDialog.hxx +++ b/sc/source/ui/inc/StatisticsInputOutputDialog.hxx @@ -38,7 +38,10 @@ public: virtual void SetActive(); protected: - virtual void CalculateInputAndWriteToOutput() = 0; + virtual void CalculateInputAndWriteToOutput(); + + virtual ScRange ApplyOutput(ScDocShell* pDocShell) = 0; + virtual sal_Int16 GetUndoNameId() = 0; // Widgets FixedText* mpInputRangeLabel; diff --git a/sc/source/ui/inc/TableFillingAndNavigationTools.hxx b/sc/source/ui/inc/TableFillingAndNavigationTools.hxx index f3d2f9b06597..9a62b7e24b23 100644 --- a/sc/source/ui/inc/TableFillingAndNavigationTools.hxx +++ b/sc/source/ui/inc/TableFillingAndNavigationTools.hxx @@ -108,6 +108,7 @@ public: virtual bool hasNext() = 0; virtual ScRange get() = 0; virtual void next() = 0; + virtual void reset() = 0; virtual sal_Int32 index(); virtual DataCellIterator iterateCells() = 0; @@ -124,6 +125,7 @@ public: virtual bool hasNext(); virtual void next(); virtual ScRange get(); + virtual void reset(); virtual DataCellIterator iterateCells(); }; @@ -138,11 +140,10 @@ public: virtual bool hasNext(); virtual void next(); virtual ScRange get(); + virtual void reset(); virtual DataCellIterator iterateCells(); }; - - #endif |