[Libreoffice-commits] core.git: sc/source sc/uiconfig solenv/sanitizers

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 11 13:31:24 UTC 2019


 sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx |  315 ++++------
 sc/source/ui/inc/RandomNumberGeneratorDialog.hxx               |   65 +-
 sc/source/ui/inc/reffact.hxx                                   |    2 
 sc/source/ui/view/tabvwshc.cxx                                 |    9 
 sc/uiconfig/scalc/ui/randomnumbergenerator.ui                  |   86 +-
 solenv/sanitizers/ui/modules/scalc.suppr                       |    1 
 6 files changed, 213 insertions(+), 265 deletions(-)

New commits:
commit a683074cc9fd6d3c74477b4228584a159206dada
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Apr 11 11:12:21 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Apr 11 15:31:02 2019 +0200

    weld ScRandomNumberGeneratorDialog
    
    Change-Id: I9ef8dd4ba84f37bb3bec040781766ef779d02ea1
    Reviewed-on: https://gerrit.libreoffice.org/70590
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
index b105e8b29115..6821743fef99 100644
--- a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
@@ -44,35 +44,31 @@ const sal_Int64 DIGITS      = 4;
 
 ScRandomNumberGeneratorDialog::ScRandomNumberGeneratorDialog(
                     SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
-                    vcl::Window* pParent, ScViewData* pViewData ) :
-    ScAnyRefDlg     ( pSfxBindings, pChildWindow, pParent,
-                      "RandomNumberGeneratorDialog", "modules/scalc/ui/randomnumbergenerator.ui" ),
-    mpViewData       ( pViewData ),
-    mpDoc( pViewData->GetDocument() ),
-    mbDialogLostFocus( false )
+                    weld::Window* pParent, ScViewData* pViewData)
+    : ScAnyRefDlgController(pSfxBindings, pChildWindow, pParent,
+                          "modules/scalc/ui/randomnumbergenerator.ui",
+                          "RandomNumberGeneratorDialog")
+    , mpViewData(pViewData)
+    , mpDoc(pViewData->GetDocument())
+    , mbDialogLostFocus(false)
+    , mxInputRangeText(m_xBuilder->weld_label("cell-range-label"))
+    , mxInputRangeEdit(new formula::WeldRefEdit(m_xBuilder->weld_entry("cell-range-edit")))
+    , mxInputRangeButton(new formula::WeldRefButton(m_xBuilder->weld_button("cell-range-button")))
+    , mxDistributionCombo(m_xBuilder->weld_combo_box("distribution-combo"))
+    , mxParameter1Text(m_xBuilder->weld_label("parameter1-label"))
+    , mxParameter1Value(m_xBuilder->weld_spin_button("parameter1-spin"))
+    , mxParameter2Text(m_xBuilder->weld_label("parameter2-label"))
+    , mxParameter2Value(m_xBuilder->weld_spin_button("parameter2-spin"))
+    , mxSeed(m_xBuilder->weld_spin_button("seed-spin"))
+    , mxEnableSeed(m_xBuilder->weld_check_button("enable-seed-check"))
+    , mxDecimalPlaces(m_xBuilder->weld_spin_button("decimal-places-spin"))
+    , mxEnableRounding(m_xBuilder->weld_check_button("enable-rounding-check"))
+    , mxButtonApply(m_xBuilder->weld_button("apply"))
+    , mxButtonOk(m_xBuilder->weld_button("ok"))
+    , mxButtonClose(m_xBuilder->weld_button("close"))
 {
-    get(mpInputRangeText,   "cell-range-label");
-    get(mpInputRangeEdit,   "cell-range-edit");
-    get(mpInputRangeButton, "cell-range-button");
-    mpInputRangeEdit->SetReferences(this, mpInputRangeText);
-    mpInputRangeButton->SetReferences(this, mpInputRangeEdit);
-
-    get(mpParameter1Value, "parameter1-spin");
-    get(mpParameter1Text,  "parameter1-label");
-    get(mpParameter2Value, "parameter2-spin");
-    get(mpParameter2Text,  "parameter2-label");
-
-    get(mpEnableSeed, "enable-seed-check");
-    get(mpSeed,       "seed-spin");
-
-    get(mpEnableRounding, "enable-rounding-check");
-    get(mpDecimalPlaces,  "decimal-places-spin");
-
-    get(mpDistributionCombo, "distribution-combo");
-
-    get(mpButtonOk,     "ok");
-    get(mpButtonApply,  "apply");
-    get(mpButtonClose,  "close");
+    mxInputRangeEdit->SetReferences(this, mxInputRangeText.get());
+    mxInputRangeButton->SetReferences(this, mxInputRangeEdit.get());
 
     Init();
     GetRangeFromSelection();
@@ -80,61 +76,38 @@ ScRandomNumberGeneratorDialog::ScRandomNumberGeneratorDialog(
 
 ScRandomNumberGeneratorDialog::~ScRandomNumberGeneratorDialog()
 {
-    disposeOnce();
-}
-
-void ScRandomNumberGeneratorDialog::dispose()
-{
-    mpInputRangeText.clear();
-    mpInputRangeEdit.clear();
-    mpInputRangeButton.clear();
-    mpDistributionCombo.clear();
-    mpParameter1Text.clear();
-    mpParameter1Value.clear();
-    mpParameter2Text.clear();
-    mpParameter2Value.clear();
-    mpSeed.clear();
-    mpEnableSeed.clear();
-    mpDecimalPlaces.clear();
-    mpEnableRounding.clear();
-    mpButtonApply.clear();
-    mpButtonOk.clear();
-    mpButtonClose.clear();
-    ScAnyRefDlg::dispose();
 }
 
 void ScRandomNumberGeneratorDialog::Init()
 {
-    mpButtonOk->SetClickHdl( LINK( this, ScRandomNumberGeneratorDialog, OkClicked ) );
-    mpButtonClose->SetClickHdl( LINK( this, ScRandomNumberGeneratorDialog, CloseClicked ) );
-    mpButtonApply->SetClickHdl( LINK( this, ScRandomNumberGeneratorDialog, ApplyClicked ) );
+    mxButtonOk->connect_clicked( LINK( this, ScRandomNumberGeneratorDialog, OkClicked ) );
+    mxButtonClose->connect_clicked( LINK( this, ScRandomNumberGeneratorDialog, CloseClicked ) );
+    mxButtonApply->connect_clicked( LINK( this, ScRandomNumberGeneratorDialog, ApplyClicked ) );
 
-    Link<Control&,void> aLink = LINK( this, ScRandomNumberGeneratorDialog, GetFocusHandler );
-    mpInputRangeEdit->SetGetFocusHdl( aLink );
-    mpInputRangeButton->SetGetFocusHdl( aLink );
+    mxInputRangeEdit->SetGetFocusHdl(LINK( this, ScRandomNumberGeneratorDialog, GetEditFocusHandler ));
+    mxInputRangeButton->SetGetFocusHdl(LINK( this, ScRandomNumberGeneratorDialog, GetButtonFocusHandler ));
 
-    aLink = LINK( this, ScRandomNumberGeneratorDialog, LoseFocusHandler );
-    mpInputRangeEdit->SetLoseFocusHdl ( aLink );
-    mpInputRangeButton->SetLoseFocusHdl ( aLink );
+    mxInputRangeEdit->SetLoseFocusHdl (LINK( this, ScRandomNumberGeneratorDialog, LoseEditFocusHandler ));
+    mxInputRangeButton->SetLoseFocusHdl (LINK( this, ScRandomNumberGeneratorDialog, LoseButtonFocusHandler ));
 
-    mpInputRangeEdit->SetModifyHdl( LINK( this, ScRandomNumberGeneratorDialog, InputRangeModified ));
-    mpParameter1Value->SetModifyHdl( LINK( this, ScRandomNumberGeneratorDialog, Parameter1ValueModified ));
-    mpParameter2Value->SetModifyHdl( LINK( this, ScRandomNumberGeneratorDialog, Parameter2ValueModified ));
+    mxInputRangeEdit->SetModifyHdl( LINK( this, ScRandomNumberGeneratorDialog, InputRangeModified ));
+    mxParameter1Value->connect_value_changed( LINK( this, ScRandomNumberGeneratorDialog, Parameter1ValueModified ));
+    mxParameter2Value->connect_value_changed( LINK( this, ScRandomNumberGeneratorDialog, Parameter2ValueModified ));
 
-    mpDistributionCombo->SetSelectHdl( LINK( this, ScRandomNumberGeneratorDialog, DistributionChanged ));
+    mxDistributionCombo->connect_changed( LINK( this, ScRandomNumberGeneratorDialog, DistributionChanged ));
 
-    mpEnableSeed->SetToggleHdl( LINK( this, ScRandomNumberGeneratorDialog, CheckChanged ));
-    mpEnableRounding->SetToggleHdl( LINK( this, ScRandomNumberGeneratorDialog, CheckChanged ));
+    mxEnableSeed->connect_toggled( LINK( this, ScRandomNumberGeneratorDialog, CheckChanged ));
+    mxEnableRounding->connect_toggled( LINK( this, ScRandomNumberGeneratorDialog, CheckChanged ));
 
-    DistributionChanged(*mpDistributionCombo);
-    CheckChanged(*mpEnableSeed);
+    DistributionChanged(*mxDistributionCombo);
+    CheckChanged(*mxEnableSeed);
 }
 
 void ScRandomNumberGeneratorDialog::GetRangeFromSelection()
 {
     mpViewData->GetSimpleArea(maInputRange);
     OUString aCurrentString(maInputRange.Format(ScRefFlags::RANGE_ABS_3D, mpDoc, mpDoc->GetAddressConvention()));
-    mpInputRangeEdit->SetText( aCurrentString );
+    mxInputRangeEdit->SetText( aCurrentString );
 }
 
 void ScRandomNumberGeneratorDialog::SetActive()
@@ -142,35 +115,35 @@ void ScRandomNumberGeneratorDialog::SetActive()
     if ( mbDialogLostFocus )
     {
         mbDialogLostFocus = false;
-        if( mpInputRangeEdit )
-            mpInputRangeEdit->GrabFocus();
+        if( mxInputRangeEdit )
+            mxInputRangeEdit->GrabFocus();
     }
     else
     {
-        GrabFocus();
+        m_xDialog->grab_focus();
     }
     RefInputDone();
 }
 
-bool ScRandomNumberGeneratorDialog::Close()
+void ScRandomNumberGeneratorDialog::Close()
 {
-    return DoClose( ScRandomNumberGeneratorDialogWrapper::GetChildWindowId() );
+    DoClose( ScRandomNumberGeneratorDialogWrapper::GetChildWindowId() );
 }
 
 void ScRandomNumberGeneratorDialog::SetReference( const ScRange& rReferenceRange, ScDocument* pDoc )
 {
-    if ( mpInputRangeEdit->IsEnabled() )
+    if (mxInputRangeEdit->GetWidget()->get_sensitive())
     {
         if ( rReferenceRange.aStart != rReferenceRange.aEnd )
-            RefInputStart( mpInputRangeEdit );
+            RefInputStart(mxInputRangeEdit.get());
 
         maInputRange = rReferenceRange;
 
         OUString aReferenceString(maInputRange.Format(ScRefFlags::RANGE_ABS_3D, pDoc, pDoc->GetAddressConvention()));
-        mpInputRangeEdit->SetRefString( aReferenceString );
+        mxInputRangeEdit->SetRefString( aReferenceString );
 
-        mpButtonApply->Enable();
-        mpButtonOk->Enable();
+        mxButtonApply->set_sensitive(true);
+        mxButtonOk->set_sensitive(true);
     }
 }
 
@@ -179,14 +152,13 @@ void ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers()
     if (!maInputRange.IsValid())
         return;
 
-    sal_Int16 aSelectedIndex = mpDistributionCombo-> GetSelectedEntryPos();
-    sal_Int64 aSelectedId = reinterpret_cast<sal_Int64>(mpDistributionCombo->GetEntryData(aSelectedIndex));
+    sal_Int64 aSelectedId = mxDistributionCombo->get_active_id().toInt64();
 
     sal_uInt32 seedValue;
 
-    if( mpEnableSeed->IsChecked() )
+    if( mxEnableSeed->get_active() )
     {
-        seedValue = mpSeed->GetValue();
+        seedValue = mxSeed->get_value();
     }
     else
     {
@@ -197,16 +169,16 @@ void ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers()
 
     std::mt19937 seed(seedValue);
 
-    sal_Int64 parameterInteger1 = mpParameter1Value->GetValue();
-    sal_Int64 parameterInteger2 = mpParameter2Value->GetValue();
+    sal_Int64 parameterInteger1 = mxParameter1Value->get_value();
+    sal_Int64 parameterInteger2 = mxParameter2Value->get_value();
 
     double parameter1 = parameterInteger1 / static_cast<double>(PRECISION);
     double parameter2 = parameterInteger2 / static_cast<double>(PRECISION);
 
     boost::optional<sal_Int8> aDecimalPlaces;
-    if (mpEnableRounding->IsChecked())
+    if (mxEnableRounding->get_active())
     {
-        aDecimalPlaces = static_cast<sal_Int8>(mpDecimalPlaces->GetValue());
+        aDecimalPlaces = static_cast<sal_Int8>(mxDecimalPlaces->get_value());
     }
 
     switch(aSelectedId)
@@ -323,188 +295,185 @@ void ScRandomNumberGeneratorDialog::GenerateNumbers(RNG& randomGenerator, const
     pDocShell->PostPaint( maInputRange, PaintPartFlags::Grid );
 }
 
-IMPL_LINK_NOARG( ScRandomNumberGeneratorDialog, OkClicked, Button*, void )
+IMPL_LINK_NOARG( ScRandomNumberGeneratorDialog, OkClicked, weld::Button&, void )
 {
-    ApplyClicked(nullptr);
-    CloseClicked(nullptr);
+    ApplyClicked(*mxButtonApply);
+    CloseClicked(*mxButtonClose);
 }
 
-IMPL_LINK_NOARG( ScRandomNumberGeneratorDialog, ApplyClicked, Button*, void )
+IMPL_LINK_NOARG( ScRandomNumberGeneratorDialog, ApplyClicked, weld::Button&, void )
 {
     SelectGeneratorAndGenerateNumbers();
 }
 
-IMPL_LINK_NOARG( ScRandomNumberGeneratorDialog, CloseClicked, Button*, void )
+IMPL_LINK_NOARG( ScRandomNumberGeneratorDialog, CloseClicked, weld::Button&, void )
 {
-    Close();
+    response(RET_CLOSE);
 }
 
-IMPL_LINK( ScRandomNumberGeneratorDialog, GetFocusHandler, Control&, rCtrl, void )
+IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, GetEditFocusHandler, formula::WeldRefEdit&, void)
 {
-    Edit* pEdit = nullptr;
+    mxInputRangeEdit->SelectAll();
+}
 
-    if( (&rCtrl == static_cast<Control*>(mpInputRangeEdit)) || (&rCtrl == static_cast<Control*>(mpInputRangeButton)) )
-        pEdit = mpInputRangeEdit;
+IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, GetButtonFocusHandler, formula::WeldRefButton&, void)
+{
+    mxInputRangeEdit->SelectAll();
+}
 
-    if( pEdit )
-        pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, LoseEditFocusHandler, formula::WeldRefEdit&, void)
+{
+    mbDialogLostFocus = !m_xDialog->has_toplevel_focus();
 }
 
-IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, LoseFocusHandler, Control&, void)
+IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, LoseButtonFocusHandler, formula::WeldRefButton&, void)
 {
-    mbDialogLostFocus = !IsActive();
+    mbDialogLostFocus = !m_xDialog->has_toplevel_focus();
 }
 
-IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, InputRangeModified, Edit&, void)
+IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, InputRangeModified, formula::WeldRefEdit&, void)
 {
     ScRangeList aRangeList;
-    bool bValid = ParseWithNames( aRangeList, mpInputRangeEdit->GetText(), mpDoc);
+    bool bValid = ParseWithNames( aRangeList, mxInputRangeEdit->GetText(), mpDoc);
     const ScRange* pRange = (bValid && aRangeList.size() == 1) ? &aRangeList[0] : nullptr;
     if (pRange)
     {
         maInputRange = *pRange;
-        mpButtonApply->Enable();
-        mpButtonOk->Enable();
+        mxButtonApply->set_sensitive(true);
+        mxButtonOk->set_sensitive(true);
         // Highlight the resulting range.
-        mpInputRangeEdit->StartUpdateData();
+        mxInputRangeEdit->StartUpdateData();
     }
     else
     {
         maInputRange = ScRange( ScAddress::INITIALIZE_INVALID);
-        mpButtonApply->Disable();
-        mpButtonOk->Disable();
+        mxButtonApply->set_sensitive(false);
+        mxButtonOk->set_sensitive(false);
     }
 }
 
-IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, Parameter1ValueModified, Edit&, void)
+IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, Parameter1ValueModified, weld::SpinButton&, void)
 {
-    sal_Int16 aSelectedIndex = mpDistributionCombo-> GetSelectedEntryPos();
-    sal_Int64 aSelectedId = reinterpret_cast<sal_Int64>( mpDistributionCombo->GetEntryData(aSelectedIndex) );
+    sal_Int64 aSelectedId = mxDistributionCombo->get_active_id().toInt64();
     if (aSelectedId == DIST_UNIFORM ||
         aSelectedId == DIST_UNIFORM_INTEGER)
     {
-        sal_Int64 min = mpParameter1Value->GetValue();
-        sal_Int64 max = mpParameter2Value->GetValue();
+        sal_Int64 min = mxParameter1Value->get_value();
+        sal_Int64 max = mxParameter2Value->get_value();
         if(min > max)
         {
-            mpParameter2Value->SetValue(min);
+            mxParameter2Value->set_value(min);
         }
     }
 }
 
-IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, Parameter2ValueModified, Edit&, void)
+IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, Parameter2ValueModified, weld::SpinButton&, void)
 {
-    sal_Int16 aSelectedIndex = mpDistributionCombo-> GetSelectedEntryPos();
-    sal_Int64 aSelectedId = reinterpret_cast<sal_Int64>( mpDistributionCombo->GetEntryData(aSelectedIndex) );
+    sal_Int64 aSelectedId = mxDistributionCombo->get_active_id().toInt64();
     if (aSelectedId == DIST_UNIFORM ||
         aSelectedId == DIST_UNIFORM_INTEGER)
     {
-        sal_Int64 min = mpParameter1Value->GetValue();
-        sal_Int64 max = mpParameter2Value->GetValue();
+        sal_Int64 min = mxParameter1Value->get_value();
+        sal_Int64 max = mxParameter2Value->get_value();
         if(min > max)
         {
-            mpParameter1Value->SetValue(max);
+            mxParameter1Value->set_value(max);
         }
     }
 }
 
-IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, CheckChanged, CheckBox&, void)
+IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, CheckChanged, weld::ToggleButton&, void)
 {
-    mpSeed->Enable(mpEnableSeed->IsChecked());
-    mpDecimalPlaces->Enable(mpEnableRounding->IsChecked());
+    mxSeed->set_sensitive(mxEnableSeed->get_active());
+    mxDecimalPlaces->set_sensitive(mxEnableRounding->get_active());
 }
 
-IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, DistributionChanged, ListBox&, void)
+IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, DistributionChanged, weld::ComboBox&, void)
 {
-    sal_Int16 aSelectedIndex = mpDistributionCombo-> GetSelectedEntryPos();
-    sal_Int64 aSelectedId = reinterpret_cast<sal_Int64>( mpDistributionCombo->GetEntryData(aSelectedIndex) );
+    sal_Int64 aSelectedId = mxDistributionCombo->get_active_id().toInt64();
 
-    mpParameter1Value->SetMin(SAL_MIN_INT64);
-    mpParameter1Value->SetMax(SAL_MAX_INT64);
-    mpParameter2Value->SetMin(SAL_MIN_INT64);
-    mpParameter2Value->SetMax(SAL_MAX_INT64);
+    mxParameter1Value->set_range(SAL_MIN_INT32, SAL_MAX_INT32);
+    mxParameter2Value->set_range(SAL_MIN_INT32, SAL_MAX_INT32);
 
-    mpParameter1Value->SetDecimalDigits(DIGITS);
-    mpParameter1Value->SetSpinSize(PRECISION);
+    mxParameter1Value->set_digits(DIGITS);
+    mxParameter1Value->set_increments(PRECISION, PRECISION * 10);
 
-    mpParameter2Value->SetDecimalDigits(DIGITS);
-    mpParameter2Value->SetSpinSize(PRECISION);
+    mxParameter2Value->set_digits(DIGITS);
+    mxParameter2Value->set_increments(PRECISION, PRECISION * 10);
 
     switch(aSelectedId)
     {
         case DIST_UNIFORM:
         {
-            mpParameter1Text->SetText(ScResId(STR_RNG_PARAMETER_MINIMUM));
-            mpParameter2Text->SetText(ScResId(STR_RNG_PARAMETER_MAXIMUM));
-            mpParameter2Text->Show();
-            mpParameter2Value->Show();
+            mxParameter1Text->set_label(ScResId(STR_RNG_PARAMETER_MINIMUM));
+            mxParameter2Text->set_label(ScResId(STR_RNG_PARAMETER_MAXIMUM));
+            mxParameter2Text->show();
+            mxParameter2Value->show();
             break;
         }
         case DIST_UNIFORM_INTEGER:
         {
-            mpParameter1Text->SetText(ScResId(STR_RNG_PARAMETER_MINIMUM));
-            mpParameter1Value->SetDecimalDigits(0);
-            mpParameter1Value->SetSpinSize(1);
+            mxParameter1Text->set_label(ScResId(STR_RNG_PARAMETER_MINIMUM));
+            mxParameter1Value->set_digits(0);
+            mxParameter1Value->set_increments(1, 10);
 
-            mpParameter2Text->SetText(ScResId(STR_RNG_PARAMETER_MAXIMUM));
-            mpParameter2Value->SetDecimalDigits(0);
-            mpParameter2Value->SetSpinSize(1);
+            mxParameter2Text->set_label(ScResId(STR_RNG_PARAMETER_MAXIMUM));
+            mxParameter2Value->set_digits(0);
+            mxParameter2Value->set_increments(1, 10);
 
-            mpParameter2Text->Show();
-            mpParameter2Value->Show();
+            mxParameter2Text->show();
+            mxParameter2Value->show();
             break;
         }
         case DIST_NORMAL:
         {
-            mpParameter1Text->SetText(ScResId(STR_RNG_PARAMETER_MEAN));
-            mpParameter2Text->SetText(ScResId(STR_RNG_PARAMETER_STANDARD_DEVIATION));
-            mpParameter2Text->Show();
-            mpParameter2Value->Show();
+            mxParameter1Text->set_label(ScResId(STR_RNG_PARAMETER_MEAN));
+            mxParameter2Text->set_label(ScResId(STR_RNG_PARAMETER_STANDARD_DEVIATION));
+            mxParameter2Text->show();
+            mxParameter2Value->show();
             break;
         }
         case DIST_CAUCHY:
         {
-            mpParameter1Text->SetText(ScResId(STR_RNG_PARAMETER_STANDARD_MEDIAN));
-            mpParameter2Text->SetText(ScResId(STR_RNG_PARAMETER_STANDARD_SIGMA));
-            mpParameter2Text->Show();
-            mpParameter2Value->Show();
+            mxParameter1Text->set_label(ScResId(STR_RNG_PARAMETER_STANDARD_MEDIAN));
+            mxParameter2Text->set_label(ScResId(STR_RNG_PARAMETER_STANDARD_SIGMA));
+            mxParameter2Text->show();
+            mxParameter2Value->show();
             break;
         }
         case DIST_BERNOULLI:
         case DIST_GEOMETRIC:
         {
-            mpParameter1Text->SetText(ScResId(STR_RNG_PARAMETER_STANDARD_PROBABILITY));
-            mpParameter1Value->SetMin(         0 );
-            mpParameter1Value->SetMax( PRECISION );
-            mpParameter1Value->SetSpinSize(1000);
+            mxParameter1Text->set_label(ScResId(STR_RNG_PARAMETER_STANDARD_PROBABILITY));
+            mxParameter1Value->set_range(0, PRECISION);
+            mxParameter1Value->set_increments(1000, 10000);
 
-            mpParameter2Text->Hide();
-            mpParameter2Value->Hide();
+            mxParameter2Text->hide();
+            mxParameter2Value->hide();
             break;
         }
         case DIST_BINOMIAL:
         case DIST_NEGATIVE_BINOMIAL:
         {
-            mpParameter1Text->SetText(ScResId(STR_RNG_PARAMETER_STANDARD_PROBABILITY));
-            mpParameter1Value->SetMin(         0 );
-            mpParameter1Value->SetMax( PRECISION );
-            mpParameter1Value->SetSpinSize(1000);
-
-            mpParameter2Text->SetText(ScResId(STR_RNG_PARAMETER_STANDARD_NUMBER_OF_TRIALS));
-            mpParameter2Value->SetDecimalDigits(0);
-            mpParameter2Value->SetSpinSize(1);
-            mpParameter2Value->SetMin(0);
-
-            mpParameter2Text->Show();
-            mpParameter2Value->Show();
+            mxParameter1Text->set_label(ScResId(STR_RNG_PARAMETER_STANDARD_PROBABILITY));
+            mxParameter1Value->set_range(0, PRECISION);
+            mxParameter1Value->set_increments(1000, 10000);
+
+            mxParameter2Text->set_label(ScResId(STR_RNG_PARAMETER_STANDARD_NUMBER_OF_TRIALS));
+            mxParameter2Value->set_digits(0);
+            mxParameter2Value->set_increments(1, 10);
+            mxParameter2Value->set_min(0);
+
+            mxParameter2Text->show();
+            mxParameter2Value->show();
             break;
         }
         case DIST_CHI_SQUARED:
         {
-            mpParameter1Text->SetText(ScResId(STR_RNG_PARAMETER_STANDARD_NU_VALUE));
+            mxParameter1Text->set_label(ScResId(STR_RNG_PARAMETER_STANDARD_NU_VALUE));
 
-            mpParameter2Text->Hide();
-            mpParameter2Value->Hide();
+            mxParameter2Text->hide();
+            mxParameter2Value->hide();
             break;
         }
     }
diff --git a/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx b/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx
index 06854a480d90..a281fb734566 100644
--- a/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx
+++ b/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx
@@ -20,38 +20,20 @@
 
 namespace boost { template <typename T> class optional; }
 
-class ScRandomNumberGeneratorDialog : public ScAnyRefDlg
+class ScRandomNumberGeneratorDialog : public ScAnyRefDlgController
 {
 public:
     ScRandomNumberGeneratorDialog(
         SfxBindings* pB, SfxChildWindow* pCW,
-        vcl::Window* pParent, ScViewData* pViewData );
+        weld::Window* pParent, ScViewData* pViewData );
 
     virtual ~ScRandomNumberGeneratorDialog() 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>          mpInputRangeText;
-    VclPtr<formula::RefEdit>   mpInputRangeEdit;
-    VclPtr<formula::RefButton> mpInputRangeButton;
-    VclPtr<ListBox>            mpDistributionCombo;
-    VclPtr<FixedText>          mpParameter1Text;
-    VclPtr<NumericField>       mpParameter1Value;
-    VclPtr<FixedText>          mpParameter2Text;
-    VclPtr<NumericField>       mpParameter2Value;
-    VclPtr<NumericField>       mpSeed;
-    VclPtr<CheckBox>           mpEnableSeed;
-    VclPtr<NumericField>       mpDecimalPlaces;
-    VclPtr<CheckBox>           mpEnableRounding;
-    VclPtr<PushButton>         mpButtonApply;
-    VclPtr<OKButton>           mpButtonOk;
-    VclPtr<CloseButton>        mpButtonClose;
-
     // Data
     ScViewData* const          mpViewData;
     ScDocument* const          mpDoc;
@@ -60,6 +42,23 @@ private:
 
     bool                mbDialogLostFocus;
 
+    // Widgets
+    std::unique_ptr<weld::Label> mxInputRangeText;
+    std::unique_ptr<formula::WeldRefEdit>   mxInputRangeEdit;
+    std::unique_ptr<formula::WeldRefButton> mxInputRangeButton;
+    std::unique_ptr<weld::ComboBox> mxDistributionCombo;
+    std::unique_ptr<weld::Label> mxParameter1Text;
+    std::unique_ptr<weld::SpinButton> mxParameter1Value;
+    std::unique_ptr<weld::Label> mxParameter2Text;
+    std::unique_ptr<weld::SpinButton> mxParameter2Value;
+    std::unique_ptr<weld::SpinButton> mxSeed;
+    std::unique_ptr<weld::CheckButton> mxEnableSeed;
+    std::unique_ptr<weld::SpinButton> mxDecimalPlaces;
+    std::unique_ptr<weld::CheckButton> mxEnableRounding;
+    std::unique_ptr<weld::Button> mxButtonApply;
+    std::unique_ptr<weld::Button> mxButtonOk;
+    std::unique_ptr<weld::Button> mxButtonClose;
+
     void Init();
     void GetRangeFromSelection();
 
@@ -69,17 +68,19 @@ private:
 
     void SelectGeneratorAndGenerateNumbers();
 
-    DECL_LINK( OkClicked,        Button*, void );
-    DECL_LINK( CloseClicked,     Button*, void );
-    DECL_LINK( ApplyClicked,     Button*, void );
-    DECL_LINK( GetFocusHandler,  Control&, void );
-    DECL_LINK( LoseFocusHandler, Control&, void );
-
-    DECL_LINK( InputRangeModified, Edit&, void );
-    DECL_LINK( Parameter1ValueModified, Edit&, void );
-    DECL_LINK( Parameter2ValueModified, Edit&, void );
-    DECL_LINK( DistributionChanged, ListBox&, void );
-    DECL_LINK( CheckChanged, CheckBox&, void );
+    DECL_LINK( OkClicked, weld::Button&, void );
+    DECL_LINK( CloseClicked, weld::Button&, void );
+    DECL_LINK( ApplyClicked, 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( InputRangeModified, formula::WeldRefEdit&, void );
+    DECL_LINK( Parameter1ValueModified, weld::SpinButton&, void );
+    DECL_LINK( Parameter2ValueModified, weld::SpinButton&, void );
+    DECL_LINK( DistributionChanged, weld::ComboBox&, void );
+    DECL_LINK( CheckChanged, weld::ToggleButton&, void );
 
 };
 
diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx
index f41d5331b066..e874cc9bbb57 100644
--- a/sc/source/ui/inc/reffact.hxx
+++ b/sc/source/ui/inc/reffact.hxx
@@ -76,7 +76,7 @@ private:
 };
 
 class ScRandomNumberGeneratorDialogWrapper :
-    public ChildWindowWrapper<SID_RANDOM_NUMBER_GENERATOR_DIALOG>
+    public ChildControllerWrapper<SID_RANDOM_NUMBER_GENERATOR_DIALOG>
 {
 private:
     ScRandomNumberGeneratorDialogWrapper() = delete;
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index b06ebff57402..8b39b9c7580a 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -277,12 +277,6 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog(
         }
         break;
 
-        case SID_RANDOM_NUMBER_GENERATOR_DIALOG:
-        {
-            pResult = VclPtr<ScRandomNumberGeneratorDialog>::Create( pB, pCW, pParent, &GetViewData() );
-        }
-        break;
-
         case SID_OPENDLG_OPTSOLVER:
         {
             ScViewData& rViewData = GetViewData();
@@ -499,6 +493,9 @@ std::unique_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont
             }
             break;
         }
+        case SID_RANDOM_NUMBER_GENERATOR_DIALOG:
+            xResult.reset(new ScRandomNumberGeneratorDialog(pB, pCW, pParent, &GetViewData()));
+            break;
     }
 
     if (xResult)
diff --git a/sc/uiconfig/scalc/ui/randomnumbergenerator.ui b/sc/uiconfig/scalc/ui/randomnumbergenerator.ui
index 31c20b45b7e9..b4da7678c030 100644
--- a/sc/uiconfig/scalc/ui/randomnumbergenerator.ui
+++ b/sc/uiconfig/scalc/ui/randomnumbergenerator.ui
@@ -1,8 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- 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="adjustment1">
+    <property name="upper">10000000000</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
   <object class="GtkAdjustment" id="decimal-places-adjustment">
     <property name="lower">1</property>
     <property name="upper">255</property>
@@ -10,52 +14,6 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
-  <object class="GtkListStore" id="distribution-liststore">
-    <columns>
-      <!-- column-name value -->
-      <column type="gchararray"/>
-      <!-- column-name id -->
-      <column type="gint"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes" context="randomnumbergenerator|distribution-liststore">Uniform</col>
-        <col id="1">0</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="randomnumbergenerator|distribution-liststore">Uniform Integer</col>
-        <col id="1">8</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="randomnumbergenerator|distribution-liststore">Normal</col>
-        <col id="1">1</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="randomnumbergenerator|distribution-liststore">Cauchy</col>
-        <col id="1">2</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="randomnumbergenerator|distribution-liststore">Bernoulli</col>
-        <col id="1">3</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="randomnumbergenerator|distribution-liststore">Binomial</col>
-        <col id="1">4</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="randomnumbergenerator|distribution-liststore">Chi Squared</col>
-        <col id="1">5</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="randomnumbergenerator|distribution-liststore">Geometric</col>
-        <col id="1">6</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="randomnumbergenerator|distribution-liststore">Negative Binomial</col>
-        <col id="1">7</col>
-      </row>
-    </data>
-  </object>
   <object class="GtkAdjustment" id="parameter1-adjustment">
     <property name="upper">100</property>
     <property name="value">1</property>
@@ -72,7 +30,12 @@
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="randomnumbergenerator|RandomNumberGeneratorDialog">Random Number Generator</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/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
@@ -188,11 +151,12 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="foruilo-RefEdit" id="cell-range-edit">
+                      <object class="GtkEntry" id="cell-range-edit">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="valign">center</property>
                         <property name="hexpand">True</property>
+                        <property name="activates_default">True</property>
                         <property name="width_chars">30</property>
                       </object>
                       <packing>
@@ -202,7 +166,7 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="foruilo-RefButton" id="cell-range-button">
+                      <object class="GtkButton" id="cell-range-button">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
@@ -269,11 +233,22 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkComboBox" id="distribution-combo">
+                      <object class="GtkComboBoxText" id="distribution-combo">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
-                        <property name="model">distribution-liststore</property>
+                        <property name="active">0</property>
+                        <items>
+                          <item id="0" translatable="yes" context="randomnumbergenerator|distribution-liststore">Uniform</item>
+                          <item id="8" translatable="yes" context="randomnumbergenerator|distribution-liststore">Uniform Integer</item>
+                          <item id="1" translatable="yes" context="randomnumbergenerator|distribution-liststore">Normal</item>
+                          <item id="2" translatable="yes" context="randomnumbergenerator|distribution-liststore">Cauchy</item>
+                          <item id="3" translatable="yes" context="randomnumbergenerator|distribution-liststore">Bernoulli</item>
+                          <item id="4" translatable="yes" context="randomnumbergenerator|distribution-liststore">Binomial</item>
+                          <item id="5" translatable="yes" context="randomnumbergenerator|distribution-liststore">Chi Squared</item>
+                          <item id="6" translatable="yes" context="randomnumbergenerator|distribution-liststore">Geometric</item>
+                          <item id="7" translatable="yes" context="randomnumbergenerator|distribution-liststore">Negative Binomial</item>
+                        </items>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -315,6 +290,7 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="hexpand">True</property>
+                        <property name="activates_default">True</property>
                         <property name="text">0,0000</property>
                         <property name="adjustment">parameter2-adjustment</property>
                         <property name="digits">4</property>
@@ -329,6 +305,7 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="hexpand">True</property>
+                        <property name="activates_default">True</property>
                         <property name="text">1,0000</property>
                         <property name="adjustment">parameter1-adjustment</property>
                         <property name="digits">4</property>
@@ -416,6 +393,8 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="hexpand">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="adjustment">adjustment1</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -459,6 +438,7 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="hexpand">True</property>
+                        <property name="activates_default">True</property>
                         <property name="text">1</property>
                         <property name="adjustment">decimal-places-adjustment</property>
                         <property name="value">1</property>
@@ -492,7 +472,7 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">apply</action-widget>
+      <action-widget response="100">apply</action-widget>
       <action-widget response="-5">ok</action-widget>
       <action-widget response="-7">close</action-widget>
       <action-widget response="-11">help</action-widget>
diff --git a/solenv/sanitizers/ui/modules/scalc.suppr b/solenv/sanitizers/ui/modules/scalc.suppr
index 6efb4ac302d3..fdf4d4ac0fed 100644
--- a/solenv/sanitizers/ui/modules/scalc.suppr
+++ b/solenv/sanitizers/ui/modules/scalc.suppr
@@ -175,6 +175,7 @@ sc/uiconfig/scalc/ui/protectsheetdlg.ui://GtkLabel[@id='insert-columns'] orphan-
 sc/uiconfig/scalc/ui/protectsheetdlg.ui://GtkLabel[@id='insert-rows'] orphan-label
 sc/uiconfig/scalc/ui/protectsheetdlg.ui://GtkLabel[@id='delete-columns'] orphan-label
 sc/uiconfig/scalc/ui/protectsheetdlg.ui://GtkLabel[@id='delete-rows'] orphan-label
+sc/uiconfig/scalc/ui/randomnumbergenerator.ui://GtkButton[@id='cell-range-button'] button-no-label
 sc/uiconfig/scalc/ui/regressiondialog.ui://GtkLabel[@id='error-message'] orphan-label
 sc/uiconfig/scalc/ui/regressiondialog.ui://GtkButton[@id='variable1-range-button'] button-no-label
 sc/uiconfig/scalc/ui/regressiondialog.ui://GtkButton[@id='variable2-range-button'] button-no-label


More information about the Libreoffice-commits mailing list