summaryrefslogtreecommitdiff
path: root/sc/source/ui/StatisticsDialogs
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-08-25 23:37:00 +0200
committerEike Rathke <erack@redhat.com>2015-08-26 01:41:08 +0200
commitda9ecf1a59b85eb93004507fe55b92f74c2cdb4c (patch)
tree8199b1f1e46387d4d08f8698f9e51ca301b300f8 /sc/source/ui/StatisticsDialogs
parentad1284df599f3493e7c76c7f8b4230aab1946558 (diff)
implement Edit modify handler, rhbz#1255811 related
Same as in ScRandomNumberGeneratorDialog. Change-Id: I1bc9296bfc8b1b2b8f3fc20183e2c626f94dee09
Diffstat (limited to 'sc/source/ui/StatisticsDialogs')
-rw-r--r--sc/source/ui/StatisticsDialogs/SamplingDialog.cxx75
1 files changed, 72 insertions, 3 deletions
diff --git a/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx b/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx
index 95ce7e55252a..529e9a91e65e 100644
--- a/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx
@@ -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: */