diff options
author | Eike Rathke <erack@redhat.com> | 2015-08-26 01:15:40 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-08-26 01:41:09 +0200 |
commit | b2363e98af7b0281279617e43b8fec5b898b9120 (patch) | |
tree | 63db1cbcb6ac6de492fcd67b4361f91728cddf62 /sc | |
parent | a88fecdcdbf0b3f6a5ba3375f8193a9dc7ba7422 (diff) |
implement Edit modify handler, rhbz#1255811 related
Same as in ScStatisticsInputOutputDialog.
Change-Id: I0e3eb06bc86cf77c405c54f312340c7b2551c1ec
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx | 89 | ||||
-rw-r--r-- | sc/source/ui/inc/StatisticsTwoVariableDialog.hxx | 1 |
2 files changed, 87 insertions, 3 deletions
diff --git a/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx b/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx index b39fb1605bb4..109fda90d6cc 100644 --- a/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx @@ -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())); diff --git a/sc/source/ui/inc/StatisticsTwoVariableDialog.hxx b/sc/source/ui/inc/StatisticsTwoVariableDialog.hxx index b0a48e1dcbc7..ebe8b19ac82a 100644 --- a/sc/source/ui/inc/StatisticsTwoVariableDialog.hxx +++ b/sc/source/ui/inc/StatisticsTwoVariableDialog.hxx @@ -86,6 +86,7 @@ private: DECL_LINK( OkClicked, PushButton* ); DECL_LINK( GetFocusHandler, Control* ); DECL_LINK( LoseFocusHandler, void* ); + DECL_LINK( RefInputModifyHandler, void* ); }; #endif |