[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sc/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 26 13:59:03 UTC 2020


 sc/source/ui/inc/solveroptions.hxx      |    2 ++
 sc/source/ui/miscdlgs/solveroptions.cxx |   18 ++++++++++++++++++
 2 files changed, 20 insertions(+)

New commits:
commit c7986b21e9b0a9208ab5bb665d25a5385798207b
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Jun 25 20:44:06 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jun 26 15:58:28 2020 +0200

    Related: tdf#134280 set max limits for solver options that show max values
    
    just simply clip to the claimed max
    
    Change-Id: Ie64da80204c9c817c85724abd1fee8c6594967b9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97136
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/inc/solveroptions.hxx b/sc/source/ui/inc/solveroptions.hxx
index 48c58a6e628f..56f450836836 100644
--- a/sc/source/ui/inc/solveroptions.hxx
+++ b/sc/source/ui/inc/solveroptions.hxx
@@ -111,6 +111,7 @@ class ScSolverValueDialog : public weld::GenericDialogController
 {
     std::unique_ptr<weld::Frame> m_xFrame;
     std::unique_ptr<weld::Entry> m_xEdValue;
+    double m_fMaxValue;
 
 public:
     ScSolverValueDialog(weld::Window* pParent);
@@ -118,6 +119,7 @@ public:
 
     void        SetOptionName( const OUString& rName );
     void        SetValue( double fValue );
+    void        SetMax( double fValue );
     double      GetValue() const;
 };
 
diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx b/sc/source/ui/miscdlgs/solveroptions.cxx
index 0a70023950ea..38d14af144e5 100644
--- a/sc/source/ui/miscdlgs/solveroptions.cxx
+++ b/sc/source/ui/miscdlgs/solveroptions.cxx
@@ -250,6 +250,14 @@ void ScSolverOptionsDialog::EditOption()
     {
         m_xValDialog = std::make_shared<ScSolverValueDialog>(m_xDialog.get());
         m_xValDialog->SetOptionName(pStringItem->GetText());
+        if (maProperties[nEntry].Name == "DECR")
+            m_xValDialog->SetMax(1.0);
+        else if (maProperties[nEntry].Name == "DEFactorMax")
+            m_xValDialog->SetMax(1.2);
+        else if (maProperties[nEntry].Name == "DEFactorMin")
+            m_xValDialog->SetMax(1.2);
+        else if (maProperties[nEntry].Name == "PSCL")
+            m_xValDialog->SetMax(0.005);
         m_xValDialog->SetValue(pStringItem->GetDoubleValue());
         weld::DialogController::runAsync(m_xValDialog, [nEntry, pStringItem, this](sal_Int32 nResult){
             if (nResult == RET_OK)
@@ -272,6 +280,8 @@ void ScSolverOptionsDialog::EditOption()
         m_xIntDialog->SetOptionName( pStringItem->GetText() );
         if (maProperties[nEntry].Name == "EpsilonLevel")
             m_xIntDialog->SetMax(3);
+        else if (maProperties[nEntry].Name == "Algorithm")
+            m_xIntDialog->SetMax(1);
         m_xIntDialog->SetValue( pStringItem->GetIntValue() );
         weld::DialogController::runAsync(m_xIntDialog, [nEntry, pStringItem, this](sal_Int32 nResult){
             if (nResult == RET_OK)
@@ -366,6 +376,7 @@ ScSolverValueDialog::ScSolverValueDialog(weld::Window* pParent)
     , m_xFrame(m_xBuilder->weld_frame("frame"))
     , m_xEdValue(m_xBuilder->weld_entry("value"))
 {
+    ::rtl::math::setNan(&m_fMaxValue);
 }
 
 ScSolverValueDialog::~ScSolverValueDialog()
@@ -384,6 +395,11 @@ void ScSolverValueDialog::SetValue( double fValue )
             ScGlobal::getLocaleDataPtr()->getNumDecimalSep()[0], true ) );
 }
 
+void ScSolverValueDialog::SetMax(double fMax)
+{
+    m_fMaxValue = fMax;
+}
+
 double ScSolverValueDialog::GetValue() const
 {
     OUString aInput = m_xEdValue->get_text();
@@ -392,6 +408,8 @@ double ScSolverValueDialog::GetValue() const
     sal_Int32 nParseEnd = 0;
     double fValue = ScGlobal::getLocaleDataPtr()->stringToDouble( aInput, true, &eStatus, &nParseEnd);
     /* TODO: shouldn't there be some error checking? */
+    if (!std::isnan(m_fMaxValue) && fValue > m_fMaxValue)
+        fValue = m_fMaxValue;
     return fValue;
 }
 


More information about the Libreoffice-commits mailing list