summaryrefslogtreecommitdiff
path: root/sc/source/ui/StatisticsDialogs
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-08-26 00:28:10 +0200
committerEike Rathke <erack@redhat.com>2015-08-26 01:41:08 +0200
commita88fecdcdbf0b3f6a5ba3375f8193a9dc7ba7422 (patch)
treed13c8f26394f436c528532c7cf1273d1410538e3 /sc/source/ui/StatisticsDialogs
parentda9ecf1a59b85eb93004507fe55b92f74c2cdb4c (diff)
implement Edit modify handler, rhbz#1255811 related
Same as in ScSamplingDialog. Change-Id: Iff709ec2284673efa8824a9b8cfc037e4d6d567a
Diffstat (limited to 'sc/source/ui/StatisticsDialogs')
-rw-r--r--sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx71
1 files changed, 68 insertions, 3 deletions
diff --git a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx
index 54f13b5af62e..52241feded99 100644
--- a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx
@@ -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()));