Kaydet (Commit) 88bece82 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Add t-test Statistics Dialog.

Change-Id: I6c2b478a4ce6976b5f8fe9cde3d8fbd309dff965
üst 8e2d8919
......@@ -699,6 +699,14 @@
<value>1</value>
</prop>
</node>
<node oor:name=".uno:TTestDialog" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~t-test...</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 &amp; Footers...</value>
......
......@@ -486,7 +486,9 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog \
sc/source/ui/StatisticsDialogs/SamplingDialog \
sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog \
sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog \
sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools \
sc/source/ui/StatisticsDialogs/TTestDialog \
sc/source/ui/undo/areasave \
sc/source/ui/undo/refundo \
sc/source/ui/undo/target \
......
......@@ -137,6 +137,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/textimportoptions \
sc/uiconfig/scalc/ui/textimportcsv \
sc/uiconfig/scalc/ui/tpviewpage \
sc/uiconfig/scalc/ui/ttestdialog \
sc/uiconfig/scalc/ui/ungroupdialog \
sc/uiconfig/scalc/ui/validationhelptabpage \
sc/uiconfig/scalc/ui/movecopysheet \
......
......@@ -267,6 +267,7 @@
#define SID_COVARIANCE_DIALOG (SC_MESSAGE_START + 75)
#define SID_EXPONENTIAL_SMOOTHING_DIALOG (SC_MESSAGE_START + 76)
#define SID_MOVING_AVERAGE_DIALOG (SC_MESSAGE_START + 77)
#define SID_TTEST_DIALOG (SC_MESSAGE_START + 78)
// functions
......
......@@ -158,6 +158,7 @@ interface CellSelection
SID_COVARIANCE_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_EXPONENTIAL_SMOOTHING_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_MOVING_AVERAGE_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_TTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_MARKDATAAREA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
SID_MARKARRAYFORMULA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
SID_SETINPUTMODE [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
......
......@@ -3134,6 +3134,30 @@ SfxVoidItem MovingAverageDialog SID_MOVING_AVERAGE_DIALOG
GroupId = GID_OPTIONS;
]
SfxVoidItem TTestDialog SID_TTEST_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
()
......
......@@ -53,5 +53,6 @@
#define STR_COVARIANCE_UNDO_NAME 37
#define STR_EXPONENTIAL_SMOOTHING_UNDO_NAME 38
#define STR_MOVING_AVERAGE_UNDO_NAME 39
#define STR_TTEST_UNDO_NAME 40
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -192,6 +192,11 @@ Resource RID_STATISTICS_DLGS
{
Text [ en-US ] = "Sampling";
};
String STR_TTEST_UNDO_NAME
{
Text [ en-US ] = "t-test";
};
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 "strload.hxx"
#include "StatisticsTwoVariableDialog.hxx"
ScStatisticsTwoVariableDialog::ScStatisticsTwoVariableDialog(
SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
Window* pParent, ScViewData* pViewData, const OString& rID, const OUString& rUIXMLDescription ) :
ScAnyRefDlg ( pSfxBindings, pChildWindow, pParent, rID, rUIXMLDescription ),
mViewData ( pViewData ),
mDocument ( pViewData->GetDocument() ),
mAddressDetails ( mDocument->GetAddressConvention(), 0, 0 ),
mGroupedBy ( BY_COLUMN ),
mCurrentAddress ( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ),
mDialogLostFocus( false )
{
get(mpVariable1RangeLabel, "variable1-range-label");
get(mpVariable1RangeEdit, "variable1-range-edit");
get(mpVariable1RangeButton, "variable1-range-button");
mpVariable1RangeEdit->SetReferences(this, mpVariable1RangeLabel);
mpVariable1RangeButton->SetReferences(this, mpVariable1RangeEdit);
get(mpVariable2RangeLabel, "variable2-range-label");
get(mpVariable2RangeEdit, "variable2-range-edit");
get(mpVariable2RangeButton, "variable2-range-button");
mpVariable2RangeEdit->SetReferences(this, mpVariable2RangeLabel);
mpVariable2RangeButton->SetReferences(this, mpVariable2RangeEdit);
get(mpOutputRangeLabel, "output-range-label");
get(mpOutputRangeEdit, "output-range-edit");
get(mpOutputRangeButton, "output-range-button");
mpOutputRangeEdit->SetReferences(this, mpOutputRangeLabel);
mpOutputRangeButton->SetReferences(this, mpOutputRangeEdit);
get(mpButtonOk, "ok");
get(mpButtonApply, "apply");
get(mpButtonClose, "close");
get(mpGroupByColumnsRadio, "groupedby-columns-radio");
get(mpGroupByRowsRadio, "groupedby-rows-radio");
Init();
GetRangeFromSelection();
}
ScStatisticsTwoVariableDialog::~ScStatisticsTwoVariableDialog()
{}
void ScStatisticsTwoVariableDialog::Init()
{
mpButtonOk->SetClickHdl( LINK( this, ScStatisticsTwoVariableDialog, OkClicked ) );
mpButtonClose->SetClickHdl( LINK( this, ScStatisticsTwoVariableDialog, CloseClicked ) );
mpButtonApply->SetClickHdl( LINK( this, ScStatisticsTwoVariableDialog, ApplyClicked ) );
mpButtonOk->Enable(false);
mpButtonApply->Enable(false);
Link aLink = LINK( this, ScStatisticsTwoVariableDialog, GetFocusHandler );
mpVariable1RangeEdit->SetGetFocusHdl( aLink );
mpVariable1RangeButton->SetGetFocusHdl( aLink );
mpVariable2RangeEdit->SetGetFocusHdl( aLink );
mpVariable2RangeButton->SetGetFocusHdl( aLink );
mpOutputRangeEdit->SetGetFocusHdl( aLink );
mpOutputRangeButton->SetGetFocusHdl( aLink );
aLink = LINK( this, ScStatisticsTwoVariableDialog, LoseFocusHandler );
mpVariable1RangeEdit->SetLoseFocusHdl( aLink );
mpVariable1RangeButton->SetLoseFocusHdl( aLink );
mpVariable2RangeEdit->SetLoseFocusHdl( aLink );
mpVariable2RangeButton->SetLoseFocusHdl( aLink );
mpOutputRangeEdit->SetLoseFocusHdl( aLink );
mpOutputRangeButton->SetLoseFocusHdl( aLink );
mpOutputRangeEdit->GrabFocus();
mpGroupByColumnsRadio->SetToggleHdl( LINK( this, ScStatisticsTwoVariableDialog, GroupByChanged ) );
mpGroupByRowsRadio->SetToggleHdl( LINK( this, ScStatisticsTwoVariableDialog, GroupByChanged ) );
mpGroupByColumnsRadio->Check(true);
mpGroupByRowsRadio->Check(false);
}
void ScStatisticsTwoVariableDialog::GetRangeFromSelection()
{
OUString aCurrentString;
ScRange aCurrentRange;
mViewData->GetSimpleArea(aCurrentRange);
if (aCurrentRange.aEnd.Col() - aCurrentRange.aStart.Col() == 1)
{
mVariable1Range = aCurrentRange;
mVariable1Range.aEnd.SetCol(mVariable1Range.aStart.Col());
aCurrentString = mVariable1Range.Format(SCR_ABS_3D, mDocument, mAddressDetails);
mpVariable1RangeEdit->SetText(aCurrentString);
mVariable2Range = aCurrentRange;
mVariable2Range.aStart.SetCol(mVariable2Range.aEnd.Col());
aCurrentString = mVariable2Range.Format(SCR_ABS_3D, mDocument, mAddressDetails);
mpVariable2RangeEdit->SetText(aCurrentString);
}
else
{
mVariable1Range = aCurrentRange;
aCurrentString = mVariable1Range.Format(SCR_ABS_3D, mDocument, mAddressDetails);
mpVariable1RangeEdit->SetText(aCurrentString);
}
}
void ScStatisticsTwoVariableDialog::SetActive()
{
if ( mDialogLostFocus )
{
mDialogLostFocus = false;
if( mpActiveEdit )
mpActiveEdit->GrabFocus();
}
else
{
GrabFocus();
}
RefInputDone();
}
void ScStatisticsTwoVariableDialog::SetReference( const ScRange& rReferenceRange, ScDocument* pDocument )
{
if ( mpActiveEdit != NULL )
{
if ( rReferenceRange.aStart != rReferenceRange.aEnd )
RefInputStart( mpActiveEdit );
OUString aReferenceString;
if ( mpActiveEdit == mpVariable1RangeEdit )
{
mVariable1Range = rReferenceRange;
aReferenceString = mVariable1Range.Format(SCR_ABS_3D, pDocument, mAddressDetails);
mpVariable1RangeEdit->SetRefString(aReferenceString);
}
else if ( mpActiveEdit == mpVariable2RangeEdit )
{
mVariable2Range = rReferenceRange;
aReferenceString = mVariable2Range.Format(SCR_ABS_3D, pDocument, mAddressDetails);
mpVariable2RangeEdit->SetRefString(aReferenceString);
}
else if ( mpActiveEdit == mpOutputRangeEdit )
{
mOutputAddress = rReferenceRange.aStart;
sal_uInt16 nFormat = ( mOutputAddress.Tab() == mCurrentAddress.Tab() ) ? SCA_ABS : SCA_ABS_3D;
aReferenceString = mOutputAddress.Format(nFormat, pDocument, pDocument->GetAddressConvention());
mpOutputRangeEdit->SetRefString( aReferenceString );
// Enable OK, Cancel if output range is set
mpButtonOk->Enable(!mpOutputRangeEdit->GetText().isEmpty());
mpButtonApply->Enable(!mpOutputRangeEdit->GetText().isEmpty());
}
}
}
IMPL_LINK( ScStatisticsTwoVariableDialog, OkClicked, PushButton*, /*pButton*/ )
{
ApplyClicked(NULL);
CloseClicked(NULL);
return 0;
}
IMPL_LINK( ScStatisticsTwoVariableDialog, ApplyClicked, PushButton*, /*pButton*/ )
{
CalculateInputAndWriteToOutput();
return 0;
}
IMPL_LINK( ScStatisticsTwoVariableDialog, CloseClicked, PushButton*, /*pButton*/ )
{
Close();
return 0;
}
IMPL_LINK( ScStatisticsTwoVariableDialog, GetFocusHandler, Control*, pCtrl )
{
mpActiveEdit = NULL;
if( pCtrl == mpVariable1RangeEdit
|| pCtrl == mpVariable1RangeButton )
{
mpActiveEdit = mpVariable1RangeEdit;
}
else if( pCtrl == mpVariable2RangeEdit
|| pCtrl == mpVariable2RangeButton )
{
mpActiveEdit = mpVariable2RangeEdit;
}
else if( pCtrl == mpOutputRangeEdit
|| pCtrl == mpOutputRangeButton )
{
mpActiveEdit = mpOutputRangeEdit;
}
if( mpActiveEdit )
mpActiveEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
return 0;
}
IMPL_LINK_NOARG( ScStatisticsTwoVariableDialog, LoseFocusHandler )
{
mDialogLostFocus = !IsActive();
return 0;
}
IMPL_LINK_NOARG( ScStatisticsTwoVariableDialog, GroupByChanged )
{
if (mpGroupByColumnsRadio->IsChecked())
mGroupedBy = BY_COLUMN;
else if (mpGroupByRowsRadio->IsChecked())
mGroupedBy = BY_ROW;
return 0;
}
void ScStatisticsTwoVariableDialog::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: */
/* -*- 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 <boost/random.hpp>
#include <boost/scoped_ptr.hpp>
#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 "TableFillingAndNavigationTools.hxx"
#include "TTestDialog.hxx"
namespace
{
static const OUString strWildcardVariable1Range("%VAR1_RANGE%");
static const OUString strWildcardVariable2Range("%VAR2_RANGE%");
}
ScTTestDialog::ScTTestDialog(
SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
Window* pParent, ScViewData* pViewData ) :
ScStatisticsTwoVariableDialog(
pSfxBindings, pChildWindow, pParent, pViewData,
"TTestDialog", "modules/scalc/ui/ttestdialog.ui" )
{}
ScTTestDialog::~ScTTestDialog()
{}
sal_Bool ScTTestDialog::Close()
{
return DoClose( ScTTestDialogWrapper::GetChildWindowId() );
}
sal_Int16 ScTTestDialog::GetUndoNameId()
{
return STR_TTEST_UNDO_NAME;
}
ScRange ScTTestDialog::ApplyOutput(ScDocShell* pDocShell)
{
AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument);
FormulaTemplate aTemplate(mDocument, mAddressDetails);
boost::scoped_ptr<DataRangeIterator> pVariable1Iterator;
if (mGroupedBy == BY_COLUMN)
pVariable1Iterator.reset(new DataRangeByColumnIterator(mVariable1Range));
else
pVariable1Iterator.reset(new DataRangeByRowIterator(mVariable1Range));
boost::scoped_ptr<DataRangeIterator> pVariable2Iterator;
if (mGroupedBy == BY_COLUMN)
pVariable2Iterator.reset(new DataRangeByColumnIterator(mVariable2Range));
else
pVariable2Iterator.reset(new DataRangeByRowIterator(mVariable2Range));
aTemplate.autoReplaceRange(strWildcardVariable1Range, pVariable1Iterator->get());
aTemplate.autoReplaceRange(strWildcardVariable2Range, pVariable2Iterator->get());
aOutput.nextRow();
aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STRID_CALC_MEAN));
aOutput.nextRow();
aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STRID_CALC_VARIANCE));
aOutput.nextRow();
aOutput.writeString("Observations");
aOutput.nextRow();
aOutput.writeString("Pearson Correlation");
aOutput.nextRow();
aOutput.writeString("Hypothesized Mean Difference");
aOutput.nextRow();
aOutput.writeString("Observed Mean Difference");
aOutput.nextRow();
aOutput.writeString("Variance of the Differences");
aOutput.nextRow();
aOutput.writeString("df");
aOutput.nextRow();
aOutput.writeString("t Stat");
aOutput.nextRow();
aOutput.writeString("P (T<=t) one-tail");
aOutput.nextRow();
aOutput.writeString("t Critical one-tail");
aOutput.nextRow();
aOutput.writeString("P (T<=t) two-tail");
aOutput.nextRow();
aOutput.writeString("t Critical two-tail");
aOutput.resetRow();
aOutput.nextColumn();
aOutput.writeString("Variable 1");
aOutput.nextRow();
aTemplate.setTemplate("=AVERAGE(%VAR1_RANGE%)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aTemplate.setTemplate("=VAR(%VAR1_RANGE%)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aTemplate.setTemplate("=COUNT(%VAR1_RANGE%)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aTemplate.setTemplate("=CORREL(%VAR1_RANGE%;%VAR2_RANGE%)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aOutput.writeValue(2);
aTemplate.autoReplaceAddress("%HYPOTHESIZED_MEAN_DIFFERENCE%", aOutput.current());
aOutput.nextRow();
aTemplate.setTemplate("=AVERAGE(IF(ISODD(IF(ISNUMBER(%VAR1_RANGE%); 1; 0) * IF(ISNUMBER(%VAR2_RANGE%); 1; 0)); %VAR1_RANGE% - %VAR2_RANGE%; \"NA\"))");
aOutput.writeMatrixFormula(aTemplate.getTemplate());
aTemplate.autoReplaceAddress("%OBSERVED_MEAN_DIFFERENCE%", aOutput.current());
aOutput.nextRow();
aTemplate.setTemplate("=VAR(IF(ISODD(IF(ISNUMBER(%VAR1_RANGE%); 1; 0) * IF(ISNUMBER(%VAR2_RANGE%); 1; 0)); %VAR1_RANGE% - %VAR2_RANGE%; \"NA\"))");
aOutput.writeMatrixFormula(aTemplate.getTemplate());
aTemplate.autoReplaceAddress("%VARIANCE_OF_DIFFERENCES%", aOutput.current());
aOutput.nextRow();
aTemplate.setTemplate("=SUM(IF(ISNUMBER(%VAR1_RANGE%); 1; 0) * IF(ISNUMBER(%VAR2_RANGE%); 1; 0)) - 1");
aOutput.writeMatrixFormula(aTemplate.getTemplate());
aTemplate.autoReplaceAddress("%DEGREE_OF_FREEDOM%", aOutput.current());
aOutput.nextRow();
aTemplate.setTemplate("=(%OBSERVED_MEAN_DIFFERENCE% - %HYPOTHESIZED_MEAN_DIFFERENCE%) / (%VARIANCE_OF_DIFFERENCES% / ( %DEGREE_OF_FREEDOM% + 1)) ^ 0.5");
aOutput.writeFormula(aTemplate.getTemplate());
aTemplate.autoReplaceAddress("%T_STAT%", aOutput.current());
aOutput.nextRow();
aTemplate.setTemplate("=TDIST(ABS(%T_STAT%); %DEGREE_OF_FREEDOM%; 1)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aTemplate.setTemplate("=TINV(2*0.05; %DEGREE_OF_FREEDOM%)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aTemplate.setTemplate("=TDIST(ABS(%T_STAT%); %DEGREE_OF_FREEDOM%; 2)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aTemplate.setTemplate("=TINV(0.05; %DEGREE_OF_FREEDOM%)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aOutput.resetRow();
aOutput.nextColumn();
aOutput.writeString("Variable 2");
aOutput.nextRow();
aTemplate.setTemplate("=AVERAGE(%VAR2_RANGE%)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aTemplate.setTemplate("=VAR(%VAR2_RANGE%)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aTemplate.setTemplate("=COUNT(%VAR2_RANGE%)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
aOutput.resetRow();
return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -35,9 +35,29 @@ void FormulaTemplate::setTemplate(const char* aTemplate)
OUString& FormulaTemplate::getTemplate()
{
RangeReplacementMap::iterator itRange;
for (itRange = mRangeReplacementMap.begin(); itRange != mRangeReplacementMap.end(); ++itRange)
{
applyRange(itRange->first, itRange->second);
}
AddressReplacementMap::iterator itAddress;
for (itAddress = mAddressReplacementMap.begin(); itAddress != mAddressReplacementMap.end(); ++itAddress)
{
applyAddress(itAddress->first, itAddress->second);
}
return mTemplate;
}
void FormulaTemplate::autoReplaceRange(OUString aVariable, ScRange aRange)
{
mRangeReplacementMap.insert ( std::pair<OUString, ScRange>(aVariable, aRange) );
}
void FormulaTemplate::autoReplaceAddress(OUString aVariable, ScAddress aAddress)
{
mAddressReplacementMap.insert ( std::pair<OUString, ScAddress>(aVariable, aAddress) );
}
void FormulaTemplate::applyRange(OUString aVariable, ScRange aRange)
{
OUString aString = aRange.Format(SCR_ABS, mDocument, mAddressDetails);
......@@ -143,6 +163,14 @@ void AddressWalkerWriter::writeFormula(OUString aFormula)
mpDocShell->GetDocFunc().SetFormulaCell(mCurrentAddress, new ScFormulaCell(mpDocument, mCurrentAddress, aFormula), true);
}
void AddressWalkerWriter::writeMatrixFormula(OUString aFormula)
{
ScRange aRange;
aRange.aStart = mCurrentAddress;
aRange.aEnd = mCurrentAddress;
mpDocShell->GetDocFunc().EnterMatrix(aRange, NULL, NULL, aFormula, false, false, OUString(), formula::FormulaGrammar::GRAM_DEFAULT );
}
void AddressWalkerWriter::writeString(OUString aString)
{
mpDocShell->GetDocFunc().SetStringCell(mCurrentAddress, aString, true);
......
......@@ -274,6 +274,7 @@ void ScDLL::Init()
ScCovarianceDialogWrapper ::RegisterChildWindow(false, pMod);
ScExponentialSmoothingDialogWrapper ::RegisterChildWindow(false, pMod);
ScMovingAverageDialogWrapper ::RegisterChildWindow(false, pMod);
ScTTestDialogWrapper ::RegisterChildWindow(false, pMod);
// First docking Window for Calc
ScFunctionChildWindow ::RegisterChildWindow(false, pMod);
......
/* -*- 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 STATISTICS_TWO_VARIABLE_DIALOG_HXX
#define STATISTICS_TWO_VARIABLE_DIALOG_HXX
#include "global.hxx"
#include "address.hxx"
#include "anyrefdg.hxx"
#include <vcl/fixed.hxx>
#include <vcl/group.hxx>
#include <vcl/lstbox.hxx>
class ScStatisticsTwoVariableDialog : public ScAnyRefDlg
{
public:
enum GroupedBy {
BY_COLUMN,
BY_ROW
};
ScStatisticsTwoVariableDialog(
SfxBindings* pB, SfxChildWindow* pCW,
Window* pParent, ScViewData* pViewData,
const OString& rID, const OUString& rUIXMLDescription );
virtual ~ScStatisticsTwoVariableDialog();
virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
virtual void SetActive();
protected:
virtual void CalculateInputAndWriteToOutput();
virtual ScRange ApplyOutput(ScDocShell* pDocShell) = 0;
virtual sal_Int16 GetUndoNameId() = 0;
// Widgets
FixedText* mpVariable1RangeLabel;
formula::RefEdit* mpVariable1RangeEdit;
formula::RefButton* mpVariable1RangeButton;
FixedText* mpVariable2RangeLabel;
formula::RefEdit* mpVariable2RangeEdit;
formula::RefButton* mpVariable2RangeButton;
FixedText* mpOutputRangeLabel;
formula::RefEdit* mpOutputRangeEdit;
formula::RefButton* mpOutputRangeButton;
// Data
ScViewData* mViewData;
ScDocument* mDocument;
ScRange mVariable1Range;
ScRange mVariable2Range;
ScAddress::Details mAddressDetails;
ScAddress mOutputAddress;
GroupedBy mGroupedBy;
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* );
DECL_LINK( GetFocusHandler, Control* );
DECL_LINK( LoseFocusHandler, void* );
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 T_TEST_DIALOG_HXX
#define T_TEST_DIALOG_HXX
#include "StatisticsTwoVariableDialog.hxx"
class ScTTestDialog : public ScStatisticsTwoVariableDialog
{
public:
ScTTestDialog(
SfxBindings* pB, SfxChildWindow* pCW,
Window* pParent, ScViewData* pViewData );
virtual ~ScTTestDialog();
virtual sal_Bool Close();
protected:
virtual sal_Int16 GetUndoNameId();
virtual ScRange ApplyOutput(ScDocShell* pDocShell);
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -27,17 +27,28 @@ private:
OUString mTemplate;
ScDocument* mDocument;
ScAddress::Details mAddressDetails;
typedef std::map<OUString, ScRange> RangeReplacementMap;
typedef std::map<OUString, ScAddress> AddressReplacementMap;
AddressReplacementMap mAddressReplacementMap;
RangeReplacementMap mRangeReplacementMap;
public:
FormulaTemplate(ScDocument* aDocument, ScAddress::Details aAddressDetails);
void setTemplate(OUString aTemplate);
void setTemplate(const char* aTemplate);
OUString& getTemplate();
void applyRange(OUString aVariable, ScRange aRange);
void applyRangeList(OUString aVariable, ScRangeList aRangeList);
void applyAddress(OUString aVariable, ScAddress aAddress);
void applyString(OUString aVariable, OUString aValue);
void applyNumber(OUString aVariable, sal_Int32 aValue);
void setTemplate(OUString aTemplate);
void setTemplate(const char* aTemplate);
OUString& getTemplate();
void autoReplaceRange(OUString aVariable, ScRange aRange);
void autoReplaceAddress(OUString aVariable, ScAddress aAddress);
void applyRange(OUString aVariable, ScRange aRange);
void applyRangeList(OUString aVariable, ScRangeList aRangeList);
void applyAddress(OUString aVariable, ScAddress aAddress);
void applyString(OUString aVariable, OUString aValue);
void applyNumber(OUString aVariable, sal_Int32 aValue);
};
class AddressWalker
......@@ -71,6 +82,7 @@ public:
AddressWalkerWriter(ScAddress aInitialAddress, ScDocShell* pDocShell, ScDocument* pDocument);
void writeFormula(OUString aFormula);
void writeMatrixFormula(OUString aFormula);
void writeString(OUString aString);
void writeString(const char* aCharArray);
void writeBoldString(OUString aString);
......
......@@ -109,6 +109,12 @@ private:
ScMovingAverageDialogWrapper() SAL_DELETED_FUNCTION;
};
class ScTTestDialogWrapper :
public ChildWindowWrapper<SID_TTEST_DIALOG>
{
private:
ScTTestDialogWrapper() SAL_DELETED_FUNCTION;
};
class ScAcceptChgDlgWrapper: public SfxChildWindow
{
......
......@@ -974,6 +974,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
}
break;
case SID_TTEST_DIALOG:
{
sal_uInt16 nId = ScTTestDialogWrapper::GetChildWindowId();
SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
}
break;
//
// disposal (Outlines)
......
......@@ -89,6 +89,7 @@ SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL))
SFX_CHILDWINDOW_REGISTRATION(ScCovarianceDialogWrapper::GetChildWindowId());
SFX_CHILDWINDOW_REGISTRATION(ScExponentialSmoothingDialogWrapper::GetChildWindowId());
SFX_CHILDWINDOW_REGISTRATION(ScMovingAverageDialogWrapper::GetChildWindowId());
SFX_CHILDWINDOW_REGISTRATION(ScTTestDialogWrapper::GetChildWindowId());
}
......
......@@ -69,6 +69,7 @@
#include "CovarianceDialog.hxx"
#include "ExponentialSmoothingDialog.hxx"
#include "MovingAverageDialog.hxx"
#include "TTestDialog.hxx"
#include <config_orcus.h>
......@@ -370,6 +371,12 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
}
break;
case SID_TTEST_DIALOG:
{
pResult = new ScTTestDialog( pB, pCW, pParent, GetViewData() );
}
break;
case SID_OPENDLG_OPTSOLVER:
{
ScViewData* pViewData = GetViewData();
......
......@@ -491,6 +491,7 @@
<menu:menuitem menu:id=".uno:CovarianceDialog"/>
<menu:menuitem menu:id=".uno:ExponentialSmoothingDialog"/>
<menu:menuitem menu:id=".uno:MovingAverageDialog"/>
<menu:menuitem menu:id=".uno:TTestDialog"/>
</menu:menupopup>
</menu:menu>
</menu:menupopup>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment