Kaydet (Commit) da9ecf1a authored tarafından Eike Rathke's avatar Eike Rathke

implement Edit modify handler, rhbz#1255811 related

Same as in ScRandomNumberGeneratorDialog.

Change-Id: I1bc9296bfc8b1b2b8f3fc20183e2c626f94dee09
üst ad1284df
...@@ -32,7 +32,9 @@ ScSamplingDialog::ScSamplingDialog( ...@@ -32,7 +32,9 @@ ScSamplingDialog::ScSamplingDialog(
mpActiveEdit ( NULL ), mpActiveEdit ( NULL ),
mViewData ( pViewData ), mViewData ( pViewData ),
mDocument ( pViewData->GetDocument() ), mDocument ( pViewData->GetDocument() ),
mInputRange ( ScAddress::INITIALIZE_INVALID ),
mAddressDetails ( mDocument->GetAddressConvention(), 0, 0 ), mAddressDetails ( mDocument->GetAddressConvention(), 0, 0 ),
mOutputAddress ( ScAddress::INITIALIZE_INVALID ),
mCurrentAddress ( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ), mCurrentAddress ( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ),
mDialogLostFocus( false ) mDialogLostFocus( false )
{ {
...@@ -99,6 +101,10 @@ void ScSamplingDialog::Init() ...@@ -99,6 +101,10 @@ void ScSamplingDialog::Init()
mpOutputRangeEdit->SetLoseFocusHdl( aLink ); mpOutputRangeEdit->SetLoseFocusHdl( aLink );
mpOutputRangeButton->SetLoseFocusHdl( aLink ); mpOutputRangeButton->SetLoseFocusHdl( aLink );
aLink = LINK( this, ScSamplingDialog, RefInputModifyHandler);
mpInputRangeEdit->SetModifyHdl( aLink);
mpOutputRangeEdit->SetModifyHdl( aLink);
mpSampleSize->SetModifyHdl( LINK( this, ScSamplingDialog, SamplingSizeValueModified )); mpSampleSize->SetModifyHdl( LINK( this, ScSamplingDialog, SamplingSizeValueModified ));
mpPeriodicMethodRadio->SetToggleHdl( LINK( this, ScSamplingDialog, ToggleSamplingMethod ) ); mpPeriodicMethodRadio->SetToggleHdl( LINK( this, ScSamplingDialog, ToggleSamplingMethod ) );
...@@ -168,11 +174,12 @@ void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument* ...@@ -168,11 +174,12 @@ void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument*
if (aSelectedSampleSize > 1) if (aSelectedSampleSize > 1)
mpSampleSize->SetValue(aSelectedSampleSize); mpSampleSize->SetValue(aSelectedSampleSize);
SamplingSizeValueModified(NULL); 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) ScRange ScSamplingDialog::PerformPeriodicSampling(ScDocShell* pDocShell)
...@@ -332,4 +339,66 @@ IMPL_LINK_NOARG(ScSamplingDialog, ToggleSamplingMethod) ...@@ -332,4 +339,66 @@ IMPL_LINK_NOARG(ScSamplingDialog, ToggleSamplingMethod)
return 0; 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -77,6 +77,7 @@ private: ...@@ -77,6 +77,7 @@ private:
DECL_LINK( LoseFocusHandler, void* ); DECL_LINK( LoseFocusHandler, void* );
DECL_LINK( SamplingSizeValueModified, void* ); DECL_LINK( SamplingSizeValueModified, void* );
DECL_LINK( ToggleSamplingMethod, void* ); DECL_LINK( ToggleSamplingMethod, void* );
DECL_LINK( RefInputModifyHandler, void* );
}; };
#endif #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