Kaydet (Commit) 6f880246 authored tarafından Eike Rathke's avatar Eike Rathke Kaydeden (comit) Andras Timar

Resolves: rhbz#1255811 implement Edit modify handler

... and disable/enable Apply/Ok buttons for in/valid ranges.

(cherry picked from commit ad1284df)

implement Edit modify handler, rhbz#1255811 related

Same as in ScRandomNumberGeneratorDialog.

(cherry picked from commit da9ecf1a)

implement Edit modify handler, rhbz#1255811 related

Same as in ScSamplingDialog.

(cherry picked from commit a88fecdc)

implement Edit modify handler, rhbz#1255811 related

Same as in ScStatisticsInputOutputDialog.

(cherry picked from commit b2363e98)

1bc9296bfc8b1b2b8f3fc20183e2c626f94dee09
ff709ec2284673efa8824a9b8cfc037e4d6d567a
0e3eb06bc86cf77c405c54f312340c7b2551c1ec

Change-Id: I52b5eae2f34e3fca7c0761b14124477a0d160b01
Reviewed-on: https://gerrit.libreoffice.org/18009Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst db65b271
......@@ -120,6 +120,7 @@ void ScRandomNumberGeneratorDialog::Init()
mpInputRangeEdit->SetLoseFocusHdl ( aLink );
mpInputRangeButton->SetLoseFocusHdl ( aLink );
mpInputRangeEdit->SetModifyHdl( LINK( this, ScRandomNumberGeneratorDialog, InputRangeModified ));
mpParameter1Value->SetModifyHdl( LINK( this, ScRandomNumberGeneratorDialog, Parameter1ValueModified ));
mpParameter2Value->SetModifyHdl( LINK( this, ScRandomNumberGeneratorDialog, Parameter2ValueModified ));
......@@ -170,11 +171,17 @@ void ScRandomNumberGeneratorDialog::SetReference( const ScRange& rReferenceRange
OUString aReferenceString(maInputRange.Format(SCR_ABS_3D, pDoc, pDoc->GetAddressConvention()));
mpInputRangeEdit->SetRefString( aReferenceString );
mpButtonApply->Enable();
mpButtonOk->Enable();
}
}
void ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers()
{
if (!maInputRange.IsValid())
return;
sal_Int16 aSelectedIndex = mpDistributionCombo-> GetSelectEntryPos();
sal_Int64 aSelectedId = reinterpret_cast<sal_Int64>(mpDistributionCombo->GetEntryData(aSelectedIndex));
......@@ -357,6 +364,28 @@ IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, LoseFocusHandler)
return 0;
}
IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, InputRangeModified)
{
ScRangeList aRangeList;
bool bValid = ParseWithNames( aRangeList, mpInputRangeEdit->GetText(), mpDoc);
const ScRange* pRange = (bValid && aRangeList.size() == 1) ? aRangeList[0] : nullptr;
if (pRange)
{
maInputRange = *pRange;
mpButtonApply->Enable();
mpButtonOk->Enable();
// Highlight the resulting range.
mpInputRangeEdit->StartUpdateData();
}
else
{
maInputRange = ScRange( ScAddress::INITIALIZE_INVALID);
mpButtonApply->Disable();
mpButtonOk->Disable();
}
return 0;
}
IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, Parameter1ValueModified)
{
sal_Int16 aSelectedIndex = mpDistributionCombo-> GetSelectEntryPos();
......
......@@ -32,7 +32,9 @@ ScSamplingDialog::ScSamplingDialog(
mpActiveEdit ( NULL ),
mViewData ( pViewData ),
mDocument ( pViewData->GetDocument() ),
mInputRange ( ScAddress::INITIALIZE_INVALID ),
mAddressDetails ( mDocument->GetAddressConvention(), 0, 0 ),
mOutputAddress ( ScAddress::INITIALIZE_INVALID ),
mCurrentAddress ( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ),
mDialogLostFocus( false )
{
......@@ -99,6 +101,10 @@ void ScSamplingDialog::Init()
mpOutputRangeEdit->SetLoseFocusHdl( aLink );
mpOutputRangeButton->SetLoseFocusHdl( aLink );
aLink = LINK( this, ScSamplingDialog, RefInputModifyHandler);
mpInputRangeEdit->SetModifyHdl( aLink);
mpOutputRangeEdit->SetModifyHdl( aLink);
mpSampleSize->SetModifyHdl( LINK( this, ScSamplingDialog, SamplingSizeValueModified ));
mpPeriodicMethodRadio->SetToggleHdl( LINK( this, ScSamplingDialog, ToggleSamplingMethod ) );
......@@ -168,11 +174,12 @@ void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument*
if (aSelectedSampleSize > 1)
mpSampleSize->SetValue(aSelectedSampleSize);
SamplingSizeValueModified(NULL);
// Enable OK, Cancel if output range is set
mpButtonOk->Enable(!mpOutputRangeEdit->GetText().isEmpty());
}
}
// Enable OK if both, input range and output address are set.
if (mInputRange.IsValid() && mOutputAddress.IsValid())
mpButtonOk->Enable();
}
ScRange ScSamplingDialog::PerformPeriodicSampling(ScDocShell* pDocShell)
......@@ -332,4 +339,66 @@ IMPL_LINK_NOARG(ScSamplingDialog, ToggleSamplingMethod)
return 0;
}
IMPL_LINK_NOARG(ScSamplingDialog, RefInputModifyHandler)
{
if ( mpActiveEdit )
{
if ( mpActiveEdit == mpInputRangeEdit )
{
ScRangeList aRangeList;
bool bValid = ParseWithNames( aRangeList, mpInputRangeEdit->GetText(), mDocument);
const ScRange* pRange = (bValid && aRangeList.size() == 1) ? aRangeList[0] : nullptr;
if (pRange)
{
mInputRange = *pRange;
// Highlight the resulting range.
mpInputRangeEdit->StartUpdateData();
}
else
{
mInputRange = ScRange( ScAddress::INITIALIZE_INVALID);
}
}
else if ( mpActiveEdit == mpOutputRangeEdit )
{
ScRangeList aRangeList;
bool bValid = ParseWithNames( aRangeList, mpOutputRangeEdit->GetText(), mDocument);
const ScRange* pRange = (bValid && aRangeList.size() == 1) ? aRangeList[0] : nullptr;
if (pRange)
{
mOutputAddress = pRange->aStart;
// Crop output range to top left address for Edit field.
if (pRange->aStart != pRange->aEnd)
{
sal_uInt16 nFormat = ( mOutputAddress.Tab() == mCurrentAddress.Tab() ) ? SCA_ABS : SCA_ABS_3D;
OUString aReferenceString = mOutputAddress.Format(nFormat, mDocument, mDocument->GetAddressConvention());
mpOutputRangeEdit->SetRefString( aReferenceString );
}
// Change sampling size according to output range selection
sal_Int64 aSelectedSampleSize = pRange->aEnd.Row() - pRange->aStart.Row() + 1;
if (aSelectedSampleSize > 1)
mpSampleSize->SetValue(aSelectedSampleSize);
SamplingSizeValueModified(NULL);
// Highlight the resulting range.
mpOutputRangeEdit->StartUpdateData();
}
else
{
mOutputAddress = ScAddress( ScAddress::INITIALIZE_INVALID);
}
}
}
// Enable OK if both, input range and output address are set.
if (mInputRange.IsValid() && mOutputAddress.IsValid())
mpButtonOk->Enable();
else
mpButtonOk->Disable();
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -59,7 +59,9 @@ ScStatisticsInputOutputDialog::ScStatisticsInputOutputDialog(
ScAnyRefDlg ( pSfxBindings, pChildWindow, pParent, rID, rUIXMLDescription ),
mViewData ( pViewData ),
mDocument ( pViewData->GetDocument() ),
mInputRange ( ScAddress::INITIALIZE_INVALID ),
mAddressDetails ( mDocument->GetAddressConvention(), 0, 0 ),
mOutputAddress ( ScAddress::INITIALIZE_INVALID ),
mGroupedBy ( BY_COLUMN ),
mpActiveEdit ( NULL ),
mCurrentAddress ( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ),
......@@ -123,6 +125,10 @@ void ScStatisticsInputOutputDialog::Init()
mpOutputRangeEdit->SetLoseFocusHdl( aLink );
mpOutputRangeButton->SetLoseFocusHdl( aLink );
aLink = LINK( this, ScStatisticsInputOutputDialog, RefInputModifyHandler);
mpInputRangeEdit->SetModifyHdl( aLink);
mpOutputRangeEdit->SetModifyHdl( aLink);
mpOutputRangeEdit->GrabFocus();
mpGroupByColumnsRadio->SetToggleHdl( LINK( this, ScStatisticsInputOutputDialog, GroupByChanged ) );
......@@ -176,11 +182,14 @@ void ScStatisticsInputOutputDialog::SetReference( const ScRange& rReferenceRange
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());
}
}
// Enable OK if both, input range and output address are set.
if (mInputRange.IsValid() && mOutputAddress.IsValid())
mpButtonOk->Enable();
else
mpButtonOk->Disable();
}
IMPL_LINK( ScStatisticsInputOutputDialog, OkClicked, PushButton*, /*pButton*/ )
......@@ -221,6 +230,62 @@ IMPL_LINK_NOARG( ScStatisticsInputOutputDialog, GroupByChanged )
return 0;
}
IMPL_LINK_NOARG( ScStatisticsInputOutputDialog, RefInputModifyHandler )
{
if ( mpActiveEdit )
{
if ( mpActiveEdit == mpInputRangeEdit )
{
ScRangeList aRangeList;
bool bValid = ParseWithNames( aRangeList, mpInputRangeEdit->GetText(), mDocument);
const ScRange* pRange = (bValid && aRangeList.size() == 1) ? aRangeList[0] : nullptr;
if (pRange)
{
mInputRange = *pRange;
// Highlight the resulting range.
mpInputRangeEdit->StartUpdateData();
}
else
{
mInputRange = ScRange( ScAddress::INITIALIZE_INVALID);
}
}
else if ( mpActiveEdit == mpOutputRangeEdit )
{
ScRangeList aRangeList;
bool bValid = ParseWithNames( aRangeList, mpOutputRangeEdit->GetText(), mDocument);
const ScRange* pRange = (bValid && aRangeList.size() == 1) ? aRangeList[0] : nullptr;
if (pRange)
{
mOutputAddress = pRange->aStart;
// Crop output range to top left address for Edit field.
if (pRange->aStart != pRange->aEnd)
{
sal_uInt16 nFormat = ( mOutputAddress.Tab() == mCurrentAddress.Tab() ) ? SCA_ABS : SCA_ABS_3D;
OUString aReferenceString = mOutputAddress.Format(nFormat, mDocument, mDocument->GetAddressConvention());
mpOutputRangeEdit->SetRefString( aReferenceString );
}
// Highlight the resulting range.
mpOutputRangeEdit->StartUpdateData();
}
else
{
mOutputAddress = ScAddress( ScAddress::INITIALIZE_INVALID);
}
}
}
// Enable OK if both, input range and output address are set.
if (mInputRange.IsValid() && mOutputAddress.IsValid())
mpButtonOk->Enable();
else
mpButtonOk->Disable();
return 0;
}
void ScStatisticsInputOutputDialog::CalculateInputAndWriteToOutput()
{
OUString aUndo(SC_STRLOAD(RID_STATISTICS_DLGS, GetUndoNameId()));
......
......@@ -31,7 +31,10 @@ ScStatisticsTwoVariableDialog::ScStatisticsTwoVariableDialog(
ScAnyRefDlg ( pSfxBindings, pChildWindow, pParent, rID, rUIXMLDescription ),
mViewData ( pViewData ),
mDocument ( pViewData->GetDocument() ),
mVariable1Range ( ScAddress::INITIALIZE_INVALID ),
mVariable2Range ( ScAddress::INITIALIZE_INVALID ),
mAddressDetails ( mDocument->GetAddressConvention(), 0, 0 ),
mOutputAddress ( ScAddress::INITIALIZE_INVALID ),
mGroupedBy ( BY_COLUMN ),
mpActiveEdit ( NULL ),
mCurrentAddress ( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ),
......@@ -108,6 +111,11 @@ void ScStatisticsTwoVariableDialog::Init()
mpOutputRangeEdit->SetLoseFocusHdl( aLink );
mpOutputRangeButton->SetLoseFocusHdl( aLink );
aLink = LINK( this, ScStatisticsTwoVariableDialog, RefInputModifyHandler);
mpVariable1RangeEdit->SetModifyHdl( aLink);
mpVariable2RangeEdit->SetModifyHdl( aLink);
mpOutputRangeEdit->SetModifyHdl( aLink);
mpOutputRangeEdit->GrabFocus();
mpGroupByColumnsRadio->SetToggleHdl( LINK( this, ScStatisticsTwoVariableDialog, GroupByChanged ) );
......@@ -187,11 +195,14 @@ void ScStatisticsTwoVariableDialog::SetReference( const ScRange& rReferenceRange
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());
}
}
// Enable OK if all ranges are set.
if (mVariable1Range.IsValid() && mVariable2Range.IsValid() && mOutputAddress.IsValid())
mpButtonOk->Enable();
else
mpButtonOk->Disable();
}
IMPL_LINK( ScStatisticsTwoVariableDialog, OkClicked, PushButton*, /*pButton*/ )
......@@ -242,6 +253,78 @@ IMPL_LINK_NOARG( ScStatisticsTwoVariableDialog, GroupByChanged )
return 0;
}
IMPL_LINK_NOARG( ScStatisticsTwoVariableDialog, RefInputModifyHandler )
{
if ( mpActiveEdit )
{
if ( mpActiveEdit == mpVariable1RangeEdit )
{
ScRangeList aRangeList;
bool bValid = ParseWithNames( aRangeList, mpVariable1RangeEdit->GetText(), mDocument);
const ScRange* pRange = (bValid && aRangeList.size() == 1) ? aRangeList[0] : nullptr;
if (pRange)
{
mVariable1Range = *pRange;
// Highlight the resulting range.
mpVariable1RangeEdit->StartUpdateData();
}
else
{
mVariable1Range = ScRange( ScAddress::INITIALIZE_INVALID);
}
}
else if ( mpActiveEdit == mpVariable2RangeEdit )
{
ScRangeList aRangeList;
bool bValid = ParseWithNames( aRangeList, mpVariable2RangeEdit->GetText(), mDocument);
const ScRange* pRange = (bValid && aRangeList.size() == 1) ? aRangeList[0] : nullptr;
if (pRange)
{
mVariable2Range = *pRange;
// Highlight the resulting range.
mpVariable2RangeEdit->StartUpdateData();
}
else
{
mVariable2Range = ScRange( ScAddress::INITIALIZE_INVALID);
}
}
else if ( mpActiveEdit == mpOutputRangeEdit )
{
ScRangeList aRangeList;
bool bValid = ParseWithNames( aRangeList, mpOutputRangeEdit->GetText(), mDocument);
const ScRange* pRange = (bValid && aRangeList.size() == 1) ? aRangeList[0] : nullptr;
if (pRange)
{
mOutputAddress = pRange->aStart;
// Crop output range to top left address for Edit field.
if (pRange->aStart != pRange->aEnd)
{
sal_uInt16 nFormat = ( mOutputAddress.Tab() == mCurrentAddress.Tab() ) ? SCA_ABS : SCA_ABS_3D;
OUString aReferenceString = mOutputAddress.Format(nFormat, mDocument, mDocument->GetAddressConvention());
mpOutputRangeEdit->SetRefString( aReferenceString );
}
// Highlight the resulting range.
mpOutputRangeEdit->StartUpdateData();
}
else
{
mOutputAddress = ScAddress( ScAddress::INITIALIZE_INVALID);
}
}
}
// Enable OK if all ranges are set.
if (mVariable1Range.IsValid() && mVariable2Range.IsValid() && mOutputAddress.IsValid())
mpButtonOk->Enable();
else
mpButtonOk->Disable();
return 0;
}
void ScStatisticsTwoVariableDialog::CalculateInputAndWriteToOutput()
{
OUString aUndo(SC_STRLOAD(RID_STATISTICS_DLGS, GetUndoNameId()));
......
......@@ -76,6 +76,7 @@ private:
DECL_LINK( GetFocusHandler, Control* );
DECL_LINK( LoseFocusHandler, void* );
DECL_LINK( InputRangeModified, void* );
DECL_LINK( Parameter1ValueModified, void* );
DECL_LINK( Parameter2ValueModified, void* );
DECL_LINK( DistributionChanged, void* );
......
......@@ -77,6 +77,7 @@ private:
DECL_LINK( LoseFocusHandler, void* );
DECL_LINK( SamplingSizeValueModified, void* );
DECL_LINK( ToggleSamplingMethod, void* );
DECL_LINK( RefInputModifyHandler, void* );
};
#endif
......
......@@ -83,6 +83,7 @@ private:
DECL_LINK( OkClicked, PushButton* );
DECL_LINK( GetFocusHandler, Control* );
DECL_LINK( LoseFocusHandler, void* );
DECL_LINK( RefInputModifyHandler, void* );
};
#endif
......
......@@ -86,6 +86,7 @@ private:
DECL_LINK( OkClicked, PushButton* );
DECL_LINK( GetFocusHandler, Control* );
DECL_LINK( LoseFocusHandler, void* );
DECL_LINK( RefInputModifyHandler, void* );
};
#endif
......
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