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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 26 08:57:11 UTC 2020


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

New commits:
commit efe623fdc2abd3f1bbd09faa70ae1b7f00edb5b5
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 10:56:32 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/+/97185
    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 daad9e3b4220..ff42d9a7d909 100644
--- a/sc/source/ui/miscdlgs/solveroptions.cxx
+++ b/sc/source/ui/miscdlgs/solveroptions.cxx
@@ -248,6 +248,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)
@@ -270,6 +278,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)
@@ -364,6 +374,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()
@@ -382,6 +393,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();
@@ -390,6 +406,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