sc/source/ui/StatisticsDialogs/SamplingDialog.cxx | 305 ++++++++++------------ sc/source/ui/inc/SamplingDialog.hxx | 65 ++-- sc/source/ui/inc/reffact.hxx | 2 sc/source/ui/view/tabvwshc.cxx | 11 sc/uiconfig/scalc/ui/samplingdialog.ui | 14 - solenv/sanitizers/ui/modules/scalc.suppr | 2 6 files changed, 197 insertions(+), 202 deletions(-)
New commits: commit ab181504329e33a31ad23c887d817519374c9797 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Apr 10 09:05:57 2019 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Apr 11 09:52:11 2019 +0200 weld ScSamplingDialog Change-Id: Ifbae09b2d2b6ebf0c56332ef4f87f3045f97f1ad Reviewed-on: https://gerrit.libreoffice.org/70503 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx b/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx index 277485f6b492..59fbb194df9f 100644 --- a/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx @@ -19,43 +19,39 @@ #include <scresid.hxx> #include <strings.hrc> -ScSamplingDialog::ScSamplingDialog( - SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, - vcl::Window* pParent, ScViewData* pViewData ) : - ScAnyRefDlg ( pSfxBindings, pChildWindow, pParent, - "SamplingDialog", "modules/scalc/ui/samplingdialog.ui" ), - mpActiveEdit ( nullptr ), - 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() ), - mnLastSampleSizeValue(1), - mnLastPeriodValue(1), - mDialogLostFocus( false ) +ScSamplingDialog::ScSamplingDialog(SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + weld::Window* pParent, ScViewData* pViewData) + : ScAnyRefDlgController(pSfxBindings, pChildWindow, pParent, + "modules/scalc/ui/samplingdialog.ui", "SamplingDialog") + , mpActiveEdit(nullptr) + , 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()) + , mnLastSampleSizeValue(1) + , mnLastPeriodValue(1) + , mDialogLostFocus(false) + , mxInputRangeLabel(m_xBuilder->weld_label("input-range-label")) + , mxInputRangeEdit(new formula::WeldRefEdit(m_xBuilder->weld_entry("input-range-edit"))) + , mxInputRangeButton(new formula::WeldRefButton(m_xBuilder->weld_button("input-range-button"))) + , mxOutputRangeLabel(m_xBuilder->weld_label("output-range-label")) + , mxOutputRangeEdit(new formula::WeldRefEdit(m_xBuilder->weld_entry("output-range-edit"))) + , mxOutputRangeButton(new formula::WeldRefButton(m_xBuilder->weld_button("output-range-button"))) + , mxSampleSize(m_xBuilder->weld_spin_button("sample-size-spin")) + , mxPeriod(m_xBuilder->weld_spin_button("period-spin")) + , mxRandomMethodRadio(m_xBuilder->weld_radio_button("random-method-radio")) + , mxWithReplacement(m_xBuilder->weld_check_button("with-replacement")) + , mxKeepOrder(m_xBuilder->weld_check_button("keep-order")) + , mxPeriodicMethodRadio(m_xBuilder->weld_radio_button("periodic-method-radio")) + , mxButtonOk(m_xBuilder->weld_button("ok")) { - get(mpInputRangeLabel, "input-range-label"); - get(mpInputRangeEdit, "input-range-edit"); - get(mpInputRangeButton, "input-range-button"); - mpInputRangeEdit->SetReferences(this, mpInputRangeLabel); - mpInputRangeButton->SetReferences(this, mpInputRangeEdit); + mxInputRangeEdit->SetReferences(this, mxInputRangeLabel.get()); + mxInputRangeButton->SetReferences(this, mxInputRangeEdit.get()); - get(mpOutputRangeLabel, "output-range-label"); - get(mpOutputRangeEdit, "output-range-edit"); - get(mpOutputRangeButton, "output-range-button"); - mpOutputRangeEdit->SetReferences(this, mpOutputRangeLabel); - mpOutputRangeButton->SetReferences(this, mpOutputRangeEdit); - - get(mpSampleSize, "sample-size-spin"); - get(mpPeriod, "period-spin"); - - get(mpRandomMethodRadio, "random-method-radio"); - get(mpWithReplacement, "with-replacement"); - get(mpKeepOrder, "keep-order"); - get(mpPeriodicMethodRadio, "periodic-method-radio"); - - get(mpButtonOk, "ok"); + mxOutputRangeEdit->SetReferences(this, mxOutputRangeLabel.get()); + mxOutputRangeButton->SetReferences(this, mxOutputRangeEdit.get()); Init(); GetRangeFromSelection(); @@ -63,60 +59,42 @@ ScSamplingDialog::ScSamplingDialog( ScSamplingDialog::~ScSamplingDialog() { - disposeOnce(); -} - -void ScSamplingDialog::dispose() -{ - mpInputRangeLabel.clear(); - mpInputRangeEdit.clear(); - mpInputRangeButton.clear(); - mpOutputRangeLabel.clear(); - mpOutputRangeEdit.clear(); - mpOutputRangeButton.clear(); - mpSampleSize.clear(); - mpPeriod.clear(); - mpRandomMethodRadio.clear(); - mpWithReplacement.clear(); - mpKeepOrder.clear(); - mpPeriodicMethodRadio.clear(); - mpButtonOk.clear(); - mpActiveEdit.clear(); - ScAnyRefDlg::dispose(); } void ScSamplingDialog::Init() { - mpButtonOk->SetClickHdl( LINK( this, ScSamplingDialog, OkClicked ) ); - mpButtonOk->Enable(false); + mxButtonOk->connect_clicked( LINK( this, ScSamplingDialog, OkClicked ) ); + mxButtonOk->set_sensitive(false); - Link<Control&,void> aLink = LINK( this, ScSamplingDialog, GetFocusHandler ); - mpInputRangeEdit->SetGetFocusHdl( aLink ); - mpInputRangeButton->SetGetFocusHdl( aLink ); - mpOutputRangeEdit->SetGetFocusHdl( aLink ); - mpOutputRangeButton->SetGetFocusHdl( aLink ); + Link<formula::WeldRefEdit&,void> aEditLink = LINK( this, ScSamplingDialog, GetEditFocusHandler ); + mxInputRangeEdit->SetGetFocusHdl( aEditLink ); + mxOutputRangeEdit->SetGetFocusHdl( aEditLink ); + Link<formula::WeldRefButton&,void> aButtonLink = LINK( this, ScSamplingDialog, GetButtonFocusHandler ); + mxInputRangeButton->SetGetFocusHdl( aButtonLink ); + mxOutputRangeButton->SetGetFocusHdl( aButtonLink ); - aLink = LINK( this, ScSamplingDialog, LoseFocusHandler ); - mpInputRangeEdit->SetLoseFocusHdl( aLink ); - mpInputRangeButton->SetLoseFocusHdl( aLink ); - mpOutputRangeEdit->SetLoseFocusHdl( aLink ); - mpOutputRangeButton->SetLoseFocusHdl( aLink ); + aEditLink = LINK( this, ScSamplingDialog, LoseEditFocusHandler ); + mxInputRangeEdit->SetLoseFocusHdl( aEditLink ); + mxOutputRangeEdit->SetLoseFocusHdl( aEditLink ); + aButtonLink = LINK( this, ScSamplingDialog, LoseButtonFocusHandler ); + mxInputRangeButton->SetLoseFocusHdl( aButtonLink ); + mxOutputRangeButton->SetLoseFocusHdl( aButtonLink ); - Link<Edit&,void> aLink2 = LINK( this, ScSamplingDialog, RefInputModifyHandler); - mpInputRangeEdit->SetModifyHdl( aLink2); - mpOutputRangeEdit->SetModifyHdl( aLink2); + Link<formula::WeldRefEdit&,void> aLink2 = LINK( this, ScSamplingDialog, RefInputModifyHandler); + mxInputRangeEdit->SetModifyHdl( aLink2); + mxOutputRangeEdit->SetModifyHdl( aLink2); - mpSampleSize->SetModifyHdl( LINK( this, ScSamplingDialog, SamplingSizeValueModified )); - mpPeriod->SetModifyHdl( LINK( this, ScSamplingDialog, PeriodValueModified )); + mxSampleSize->connect_value_changed( LINK( this, ScSamplingDialog, SamplingSizeValueModified )); + mxPeriod->connect_value_changed( LINK( this, ScSamplingDialog, PeriodValueModified )); - mpPeriodicMethodRadio->SetToggleHdl( LINK( this, ScSamplingDialog, ToggleSamplingMethod ) ); - mpRandomMethodRadio->SetToggleHdl( LINK( this, ScSamplingDialog, ToggleSamplingMethod ) ); + mxPeriodicMethodRadio->connect_toggled( LINK( this, ScSamplingDialog, ToggleSamplingMethod ) ); + mxRandomMethodRadio->connect_toggled( LINK( this, ScSamplingDialog, ToggleSamplingMethod ) ); - mpWithReplacement->SetClickHdl( LINK( this, ScSamplingDialog, CheckHdl)); - mpKeepOrder->SetClickHdl( LINK( this, ScSamplingDialog, CheckHdl)); + mxWithReplacement->connect_clicked( LINK( this, ScSamplingDialog, CheckHdl)); + mxKeepOrder->connect_clicked( LINK( this, ScSamplingDialog, CheckHdl)); - mpOutputRangeEdit->GrabFocus(); - mpPeriodicMethodRadio->Check(); + mxOutputRangeEdit->GrabFocus(); + mxPeriodicMethodRadio->set_active(true); ToggleSamplingMethod(); } @@ -125,7 +103,7 @@ void ScSamplingDialog::GetRangeFromSelection() { mViewData->GetSimpleArea(mInputRange); OUString aCurrentString(mInputRange.Format(ScRefFlags::RANGE_ABS_3D, mDocument, mAddressDetails)); - mpInputRangeEdit->SetText(aCurrentString); + mxInputRangeEdit->SetText(aCurrentString); } void ScSamplingDialog::SetActive() @@ -138,14 +116,14 @@ void ScSamplingDialog::SetActive() } else { - GrabFocus(); + m_xDialog->grab_focus(); } RefInputDone(); } -bool ScSamplingDialog::Close() +void ScSamplingDialog::Close() { - return DoClose( ScSamplingDialogWrapper::GetChildWindowId() ); + DoClose( ScSamplingDialogWrapper::GetChildWindowId() ); } void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument* pDocument ) @@ -157,15 +135,15 @@ void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument* OUString aReferenceString; - if ( mpActiveEdit == mpInputRangeEdit ) + if ( mpActiveEdit == mxInputRangeEdit.get() ) { mInputRange = rReferenceRange; aReferenceString = mInputRange.Format(ScRefFlags::RANGE_ABS_3D, pDocument, mAddressDetails); - mpInputRangeEdit->SetRefString( aReferenceString ); + mxInputRangeEdit->SetRefString( aReferenceString ); LimitSampleSizeAndPeriod(); } - else if ( mpActiveEdit == mpOutputRangeEdit ) + else if ( mpActiveEdit == mxOutputRangeEdit.get() ) { mOutputAddress = rReferenceRange.aStart; @@ -173,22 +151,19 @@ void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument* ScRefFlags::ADDR_ABS : ScRefFlags::ADDR_ABS_3D; aReferenceString = mOutputAddress.Format(nFormat, pDocument, pDocument->GetAddressConvention()); - mpOutputRangeEdit->SetRefString( aReferenceString ); + mxOutputRangeEdit->SetRefString( aReferenceString ); // Change sampling size according to output range selection sal_Int64 aSelectedSampleSize = rReferenceRange.aEnd.Row() - rReferenceRange.aStart.Row() + 1; if (aSelectedSampleSize > 1) - mpSampleSize->SetValue(aSelectedSampleSize); - SamplingSizeValueModified(*mpSampleSize); + mxSampleSize->set_value(aSelectedSampleSize); + SamplingSizeValueModified(*mxSampleSize); } } // Enable OK if both, input range and output address are set. // Disable if at least one is invalid. - if (mInputRange.IsValid() && mOutputAddress.IsValid()) - mpButtonOk->Enable(); - else - mpButtonOk->Enable(false); + mxButtonOk->set_sensitive(mInputRange.IsValid() && mOutputAddress.IsValid()); } ScRange ScSamplingDialog::PerformPeriodicSampling(ScDocShell* pDocShell) @@ -199,7 +174,7 @@ ScRange ScSamplingDialog::PerformPeriodicSampling(ScDocShell* pDocShell) SCTAB outTab = mOutputAddress.Tab(); SCROW outRow = mOutputAddress.Row(); - sal_Int64 aPeriod = mpPeriod->GetValue(); + sal_Int64 aPeriod = mxPeriod->get_value(); for (SCROW inTab = aStart.Tab(); inTab <= aEnd.Tab(); inTab++) { @@ -235,13 +210,13 @@ ScRange ScSamplingDialog::PerformRandomSampling(ScDocShell* pDocShell) SCTAB outTab = mOutputAddress.Tab(); SCROW outRow = mOutputAddress.Row(); - const sal_Int64 nSampleSize = mpSampleSize->GetValue(); + const sal_Int64 nSampleSize = mxSampleSize->get_value(); // This implementation groups by columns. Other options could be grouping // by rows or area. const sal_Int64 nPopulationSize = aEnd.Row() - aStart.Row() + 1; - const bool bWithReplacement = mpWithReplacement->IsEnabled() && mpWithReplacement->IsChecked(); + const bool bWithReplacement = mxWithReplacement->get_sensitive() && mxWithReplacement->get_active(); // WOR (WithOutReplacement) can't draw more than population. Catch that in // the caller. @@ -315,7 +290,7 @@ ScRange ScSamplingDialog::PerformRandomSamplingKeepOrder(ScDocShell* pDocShell) SCROW inRow; - sal_Int64 aSampleSize = mpSampleSize->GetValue(); + sal_Int64 aSampleSize = mxSampleSize->get_value(); for (SCROW inTab = aStart.Tab(); inTab <= aEnd.Tab(); inTab++) { @@ -361,14 +336,14 @@ void ScSamplingDialog::PerformSampling() pUndoManager->EnterListAction( aUndo, aUndo, 0, mViewData->GetViewShell()->GetViewShellId() ); - if (mpRandomMethodRadio->IsChecked()) + if (mxRandomMethodRadio->get_active()) { - if (mpKeepOrder->IsEnabled() && mpKeepOrder->IsChecked()) + if (mxKeepOrder->get_sensitive() && mxKeepOrder->get_active()) aModifiedRange = PerformRandomSamplingKeepOrder(pDocShell); else aModifiedRange = PerformRandomSampling(pDocShell); } - else if (mpPeriodicMethodRadio->IsChecked()) + else if (mxPeriodicMethodRadio->get_active()) { aModifiedRange = PerformPeriodicSampling(pDocShell); } @@ -388,128 +363,147 @@ void ScSamplingDialog::LimitSampleSizeAndPeriod() // than last known value. When enlargening the input population range the // values will be adjusted up to the last known value again. const sal_Int64 nPopulationSize = GetPopulationSize(); - if (nPopulationSize <= mnLastSampleSizeValue && !mpWithReplacement->IsChecked()) - mpSampleSize->SetValue( nPopulationSize); + if (nPopulationSize <= mnLastSampleSizeValue && !mxWithReplacement->get_active()) + mxSampleSize->set_value( nPopulationSize); if (nPopulationSize <= mnLastPeriodValue) - mpPeriod->SetValue( nPopulationSize); + mxPeriod->set_value( nPopulationSize); } -IMPL_LINK_NOARG(ScSamplingDialog, SamplingSizeValueModified, Edit&, void) +IMPL_LINK_NOARG(ScSamplingDialog, SamplingSizeValueModified, weld::SpinButton&, void) { - if (!mpWithReplacement->IsChecked()) + if (!mxWithReplacement->get_active()) { // For all WOR methods limit sample size to population size. const sal_Int64 nPopulationSize = GetPopulationSize(); - if (mpSampleSize->GetValue() > nPopulationSize) - mpSampleSize->SetValue(nPopulationSize); + if (mxSampleSize->get_value() > nPopulationSize) + mxSampleSize->set_value(nPopulationSize); } - mnLastSampleSizeValue = mpSampleSize->GetValue(); + mnLastSampleSizeValue = mxSampleSize->get_value(); } -IMPL_LINK_NOARG(ScSamplingDialog, PeriodValueModified, Edit&, void) +IMPL_LINK_NOARG(ScSamplingDialog, PeriodValueModified, weld::SpinButton&, void) { // Limit period to population size. const sal_Int64 nPopulationSize = GetPopulationSize(); - if (mpPeriod->GetValue() > nPopulationSize) - mpPeriod->SetValue(nPopulationSize); - mnLastPeriodValue = mpPeriod->GetValue(); + if (mxPeriod->get_value() > nPopulationSize) + mxPeriod->set_value(nPopulationSize); + mnLastPeriodValue = mxPeriod->get_value(); } -IMPL_LINK( ScSamplingDialog, GetFocusHandler, Control&, rCtrl, void ) +IMPL_LINK( ScSamplingDialog, GetEditFocusHandler, formula::WeldRefEdit&, rCtrl, void ) { - if ( (&rCtrl == static_cast<Control*>(mpInputRangeEdit)) || (&rCtrl == static_cast<Control*>(mpInputRangeButton))) - mpActiveEdit = mpInputRangeEdit; - else if ((&rCtrl == static_cast<Control*>(mpOutputRangeEdit)) || (&rCtrl == static_cast<Control*>(mpOutputRangeButton))) - mpActiveEdit = mpOutputRangeEdit; + if (&rCtrl == mxInputRangeEdit.get()) + mpActiveEdit = mxInputRangeEdit.get(); + else if (&rCtrl == mxOutputRangeEdit.get()) + mpActiveEdit = mxOutputRangeEdit.get(); else mpActiveEdit = nullptr; if (mpActiveEdit) - mpActiveEdit->SetSelection( Selection( 0, SELECTION_MAX ) ); + mpActiveEdit->SelectAll(); } -IMPL_LINK_NOARG( ScSamplingDialog, OkClicked, Button*, void ) +IMPL_LINK(ScSamplingDialog, GetButtonFocusHandler, formula::WeldRefButton&, rCtrl, void) +{ + if (&rCtrl == mxInputRangeButton.get()) + mpActiveEdit = mxInputRangeEdit.get(); + else if (&rCtrl == mxOutputRangeButton.get()) + mpActiveEdit = mxOutputRangeEdit.get(); + else + mpActiveEdit = nullptr; + + if (mpActiveEdit) + mpActiveEdit->SelectAll(); +} + + +IMPL_LINK_NOARG(ScSamplingDialog, OkClicked, weld::Button&, void) { PerformSampling(); - Close(); + response(RET_OK); } -IMPL_LINK_NOARG(ScSamplingDialog, LoseFocusHandler, Control&, void) +IMPL_LINK_NOARG(ScSamplingDialog, LoseEditFocusHandler, formula::WeldRefEdit&, void) { - mDialogLostFocus = !IsActive(); + mDialogLostFocus = !m_xDialog->has_toplevel_focus(); } -IMPL_LINK_NOARG(ScSamplingDialog, ToggleSamplingMethod, RadioButton&, void) +IMPL_LINK_NOARG(ScSamplingDialog, LoseButtonFocusHandler, formula::WeldRefButton&, void) +{ + mDialogLostFocus = !m_xDialog->has_toplevel_focus(); +} + +IMPL_LINK_NOARG(ScSamplingDialog, ToggleSamplingMethod, weld::ToggleButton&, void) { ToggleSamplingMethod(); } void ScSamplingDialog::ToggleSamplingMethod() { - if (mpRandomMethodRadio->IsChecked()) + if (mxRandomMethodRadio->get_active()) { - mpPeriod->Enable(false); - mpSampleSize->Enable(); - mpWithReplacement->Enable(); - mpKeepOrder->Enable(); + mxPeriod->set_sensitive(false); + mxSampleSize->set_sensitive(true); + mxWithReplacement->set_sensitive(true); + mxKeepOrder->set_sensitive(true); } - else if (mpPeriodicMethodRadio->IsChecked()) + else if (mxPeriodicMethodRadio->get_active()) { // WOR keeping order. - mpPeriod->Enable(); - mpSampleSize->Enable(false); - mpWithReplacement->Check(false); - mpWithReplacement->Enable(false); - mpKeepOrder->Check(); - mpKeepOrder->Enable(false); + mxPeriod->set_sensitive(true); + mxSampleSize->set_sensitive(false); + mxWithReplacement->set_active(false); + mxWithReplacement->set_sensitive(false); + mxKeepOrder->set_active(true); + mxKeepOrder->set_sensitive(false); } } -IMPL_LINK( ScSamplingDialog, CheckHdl, Button*, pBtn, void ) +IMPL_LINK(ScSamplingDialog, CheckHdl, weld::Button&, rBtn, void) { // Keep both checkboxes enabled so user can easily switch between the three // possible combinations (one or the other or none), just uncheck the other // one if one is checked. Otherwise the other checkbox would had to be // disabled until user unchecks the enabled one again, which would force // user to two clicks to switch. - if (pBtn == mpWithReplacement) + if (&rBtn == mxWithReplacement.get()) { - if (static_cast<const CheckBox*>(pBtn)->IsChecked()) + if (mxWithReplacement->get_active()) { // For WR can't keep order. - mpKeepOrder->Check(false); + mxKeepOrder->set_active(false); } else { // For WOR limit sample size to population size. - SamplingSizeValueModified(*mpSampleSize); + SamplingSizeValueModified(*mxSampleSize); } } - else if (pBtn == mpKeepOrder) + else if (&rBtn == mxKeepOrder.get()) { - if (static_cast<const CheckBox*>(pBtn)->IsChecked()) + if (mxKeepOrder->get_active()) { // Keep order is always WOR. - mpWithReplacement->Check(false); - SamplingSizeValueModified(*mpSampleSize); + mxWithReplacement->set_active(false); + SamplingSizeValueModified(*mxSampleSize); } } } -IMPL_LINK_NOARG(ScSamplingDialog, RefInputModifyHandler, Edit&, void) +IMPL_LINK_NOARG(ScSamplingDialog, RefInputModifyHandler, formula::WeldRefEdit&, void) { if ( mpActiveEdit ) { - if ( mpActiveEdit == mpInputRangeEdit ) + if ( mpActiveEdit == mxInputRangeEdit.get() ) { ScRangeList aRangeList; - bool bValid = ParseWithNames( aRangeList, mpInputRangeEdit->GetText(), mDocument); + bool bValid = ParseWithNames( aRangeList, mxInputRangeEdit->GetText(), mDocument); const ScRange* pRange = (bValid && aRangeList.size() == 1) ? &aRangeList[0] : nullptr; if (pRange) { mInputRange = *pRange; // Highlight the resulting range. - mpInputRangeEdit->StartUpdateData(); + mxInputRangeEdit->StartUpdateData(); LimitSampleSizeAndPeriod(); } @@ -518,10 +512,10 @@ IMPL_LINK_NOARG(ScSamplingDialog, RefInputModifyHandler, Edit&, void) mInputRange = ScRange( ScAddress::INITIALIZE_INVALID); } } - else if ( mpActiveEdit == mpOutputRangeEdit ) + else if ( mpActiveEdit == mxOutputRangeEdit.get() ) { ScRangeList aRangeList; - bool bValid = ParseWithNames( aRangeList, mpOutputRangeEdit->GetText(), mDocument); + bool bValid = ParseWithNames( aRangeList, mxOutputRangeEdit->GetText(), mDocument); const ScRange* pRange = (bValid && aRangeList.size() == 1) ? &aRangeList[0] : nullptr; if (pRange) { @@ -534,17 +528,17 @@ IMPL_LINK_NOARG(ScSamplingDialog, RefInputModifyHandler, Edit&, void) ScRefFlags::ADDR_ABS : ScRefFlags::ADDR_ABS_3D; OUString aReferenceString = mOutputAddress.Format(nFormat, mDocument, mDocument->GetAddressConvention()); - mpOutputRangeEdit->SetRefString( aReferenceString ); + mxOutputRangeEdit->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(*mpSampleSize); + mxSampleSize->set_value(aSelectedSampleSize); + SamplingSizeValueModified(*mxSampleSize); // Highlight the resulting range. - mpOutputRangeEdit->StartUpdateData(); + mxOutputRangeEdit->StartUpdateData(); } else { @@ -554,10 +548,7 @@ IMPL_LINK_NOARG(ScSamplingDialog, RefInputModifyHandler, Edit&, void) } // Enable OK if both, input range and output address are set. - if (mInputRange.IsValid() && mOutputAddress.IsValid()) - mpButtonOk->Enable(); - else - mpButtonOk->Disable(); + mxButtonOk->set_sensitive(mInputRange.IsValid() && mOutputAddress.IsValid()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/SamplingDialog.hxx b/sc/source/ui/inc/SamplingDialog.hxx index cf517a2bfa39..7b0751cc4782 100644 --- a/sc/source/ui/inc/SamplingDialog.hxx +++ b/sc/source/ui/inc/SamplingDialog.hxx @@ -17,41 +17,21 @@ #include <vcl/fixed.hxx> -class ScSamplingDialog : public ScAnyRefDlg +class ScSamplingDialog : public ScAnyRefDlgController { public: ScSamplingDialog( SfxBindings* pB, SfxChildWindow* pCW, - vcl::Window* pParent, ScViewData* pViewData ); + weld::Window* pParent, ScViewData* pViewData ); virtual ~ScSamplingDialog() override; - virtual void dispose() override; virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override; virtual void SetActive() override; - virtual bool Close() override; + virtual void Close() override; private: - // Widgets - VclPtr<FixedText> mpInputRangeLabel; - VclPtr<formula::RefEdit> mpInputRangeEdit; - VclPtr<formula::RefButton> mpInputRangeButton; - - VclPtr<FixedText> mpOutputRangeLabel; - VclPtr<formula::RefEdit> mpOutputRangeEdit; - VclPtr<formula::RefButton> mpOutputRangeButton; - - VclPtr<NumericField> mpSampleSize; - VclPtr<NumericField> mpPeriod; - - VclPtr<RadioButton> mpRandomMethodRadio; - VclPtr<CheckBox> mpWithReplacement; - VclPtr<CheckBox> mpKeepOrder; - VclPtr<RadioButton> mpPeriodicMethodRadio; - - VclPtr<OKButton> mpButtonOk; - - VclPtr<formula::RefEdit> mpActiveEdit; + formula::WeldRefEdit* mpActiveEdit; // Data ScViewData* const mViewData; @@ -68,6 +48,25 @@ private: bool mDialogLostFocus; + // Widgets + std::unique_ptr<weld::Label> mxInputRangeLabel; + std::unique_ptr<formula::WeldRefEdit> mxInputRangeEdit; + std::unique_ptr<formula::WeldRefButton> mxInputRangeButton; + + std::unique_ptr<weld::Label> mxOutputRangeLabel; + std::unique_ptr<formula::WeldRefEdit> mxOutputRangeEdit; + std::unique_ptr<formula::WeldRefButton> mxOutputRangeButton; + + std::unique_ptr<weld::SpinButton> mxSampleSize; + std::unique_ptr<weld::SpinButton> mxPeriod; + + std::unique_ptr<weld::RadioButton> mxRandomMethodRadio; + std::unique_ptr<weld::CheckButton> mxWithReplacement; + std::unique_ptr<weld::CheckButton> mxKeepOrder; + std::unique_ptr<weld::RadioButton> mxPeriodicMethodRadio; + + std::unique_ptr<weld::Button> mxButtonOk; + void Init(); void GetRangeFromSelection(); void PerformSampling(); @@ -78,14 +77,16 @@ private: ScRange PerformRandomSamplingKeepOrder(ScDocShell* pDocShell); ScRange PerformPeriodicSampling(ScDocShell* pDocShell); - DECL_LINK( OkClicked, Button*, void ); - DECL_LINK( GetFocusHandler, Control&, void ); - DECL_LINK( LoseFocusHandler, Control&, void ); - DECL_LINK( SamplingSizeValueModified, Edit&, void ); - DECL_LINK( PeriodValueModified, Edit&, void ); - DECL_LINK( ToggleSamplingMethod, RadioButton&, void ); - DECL_LINK( RefInputModifyHandler, Edit&, void ); - DECL_LINK( CheckHdl, Button*, void ); + DECL_LINK( OkClicked, weld::Button&, void ); + DECL_LINK( GetEditFocusHandler, formula::WeldRefEdit&, void ); + DECL_LINK( GetButtonFocusHandler, formula::WeldRefButton&, void ); + DECL_LINK( LoseEditFocusHandler, formula::WeldRefEdit&, void ); + DECL_LINK( LoseButtonFocusHandler, formula::WeldRefButton&, void ); + DECL_LINK( SamplingSizeValueModified, weld::SpinButton&, void ); + DECL_LINK( PeriodValueModified, weld::SpinButton&, void ); + DECL_LINK( ToggleSamplingMethod, weld::ToggleButton&, void ); + DECL_LINK( RefInputModifyHandler, formula::WeldRefEdit&, void ); + DECL_LINK( CheckHdl, weld::Button&, void ); void ToggleSamplingMethod(); }; diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx index 28c42f089a38..a19ef1686d1b 100644 --- a/sc/source/ui/inc/reffact.hxx +++ b/sc/source/ui/inc/reffact.hxx @@ -58,7 +58,7 @@ private: }; class ScSamplingDialogWrapper : - public ChildWindowWrapper<SID_SAMPLING_DIALOG> + public ChildControllerWrapper<SID_SAMPLING_DIALOG> { private: ScSamplingDialogWrapper() = delete; diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index c826234e3da0..6f3a947e7dce 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -330,12 +330,6 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog( } break; - case SID_SAMPLING_DIALOG: - { - pResult = VclPtr<ScSamplingDialog>::Create( pB, pCW, pParent, &GetViewData() ); - } - break; - case SID_DESCRIPTIVE_STATISTICS_DIALOG: { pResult = VclPtr<ScDescriptiveStatisticsDialog>::Create( pB, pCW, pParent, &GetViewData() ); @@ -538,6 +532,11 @@ std::unique_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont xResult.reset(new ScCorrelationDialog(pB, pCW, pParent, &GetViewData())); } break; + case SID_SAMPLING_DIALOG: + { + xResult.reset(new ScSamplingDialog(pB, pCW, pParent, &GetViewData())); + } + break; } if (xResult) diff --git a/sc/uiconfig/scalc/ui/samplingdialog.ui b/sc/uiconfig/scalc/ui/samplingdialog.ui index 033772f8590f..8920406a9c47 100644 --- a/sc/uiconfig/scalc/ui/samplingdialog.ui +++ b/sc/uiconfig/scalc/ui/samplingdialog.ui @@ -2,7 +2,6 @@ <!-- Generated with glade 3.22.1 --> <interface domain="sc"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkAdjustment" id="period-adjustment"> <property name="lower">1</property> <property name="upper">100</property> @@ -20,6 +19,8 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="samplingdialog|SamplingDialog">Sampling</property> <property name="resizable">False</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> <child> <placeholder/> @@ -123,7 +124,7 @@ </packing> </child> <child> - <object class="foruilo-RefEdit" id="input-range-edit"> + <object class="GtkEntry" id="input-range-edit"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="valign">center</property> @@ -136,7 +137,7 @@ </packing> </child> <child> - <object class="foruilo-RefButton" id="input-range-button"> + <object class="GtkButton" id="input-range-button"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -161,7 +162,7 @@ </packing> </child> <child> - <object class="foruilo-RefEdit" id="output-range-edit"> + <object class="GtkEntry" id="output-range-edit"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="valign">center</property> @@ -174,7 +175,7 @@ </packing> </child> <child> - <object class="foruilo-RefButton" id="output-range-button"> + <object class="GtkButton" id="output-range-button"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -266,8 +267,8 @@ <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="xalign">0</property> + <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">periodic-method-radio</property> </object> <packing> <property name="left_attach">0</property> @@ -381,6 +382,7 @@ </child> <action-widgets> <action-widget response="-5">ok</action-widget> + <action-widget response="-6">cancel</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> </object> diff --git a/solenv/sanitizers/ui/modules/scalc.suppr b/solenv/sanitizers/ui/modules/scalc.suppr index c3ae37462c58..c167762cc804 100644 --- a/solenv/sanitizers/ui/modules/scalc.suppr +++ b/solenv/sanitizers/ui/modules/scalc.suppr @@ -164,6 +164,8 @@ sc/uiconfig/scalc/ui/protectsheetdlg.ui://GtkLabel[@id='delete-rows'] orphan-lab sc/uiconfig/scalc/ui/regressiondialog.ui://GtkLabel[@id='error-message'] orphan-label sc/uiconfig/scalc/ui/retypepassdialog.ui://GtkLabel[@id='descLabel'] orphan-label sc/uiconfig/scalc/ui/retypepassdialog.ui://GtkLabel[@id='docStatusLabel'] orphan-label +sc/uiconfig/scalc/ui/samplingdialog.ui://GtkButton[@id='input-range-button'] button-no-label +sc/uiconfig/scalc/ui/samplingdialog.ui://GtkButton[@id='output-range-button'] button-no-label sc/uiconfig/scalc/ui/standardfilterdialog.ui://GtkComboBoxText[@id='connect1'] missing-label-for sc/uiconfig/scalc/ui/standardfilterdialog.ui://GtkComboBoxText[@id='connect2'] missing-label-for sc/uiconfig/scalc/ui/standardfilterdialog.ui://GtkLabel[@id='label2'] orphan-label _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits