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@redhat.com>
diff --git a/sc/source/ui/inc/solveroptions.hxx b/sc/source/ui/inc/solveroptions.hxx
index 48c58a6..56f4508 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 0a70023..38d14af 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;
}