26#include <rtl/math.hxx>
29#include <osl/diagnose.h>
33#include <com/sun/star/sheet/XSolver.hpp>
34#include <com/sun/star/sheet/XSolverDescription.hpp>
35#include <com/sun/star/beans/PropertyValue.hpp>
43struct ScSolverOptionsEntry
46 OUString aDescription;
48 ScSolverOptionsEntry() : nPosition(0) {}
50 bool operator< (
const ScSolverOptionsEntry& rOther)
const
59 const uno::Sequence<OUString>& rImplNames,
60 const uno::Sequence<OUString>& rDescriptions,
62 const uno::Sequence<beans::PropertyValue>& rProperties )
63 : GenericDialogController(pParent,
"modules/scalc/ui/solveroptionsdialog.ui",
"SolverOptionsDialog")
64 , maImplNames(rImplNames)
65 , maEngine(
std::move(aEngine))
67 , m_xLbEngine(m_xBuilder->weld_combo_box(
"engine"))
68 , m_xLbSettings(m_xBuilder->weld_tree_view(
"settings"))
69 , m_xBtnEdit(m_xBuilder->weld_button(
"edit"))
83 sal_Int32 nSelect = -1;
85 for (sal_Int32 nImpl=0; nImpl<nImplCount; ++nImpl)
88 OUString aDescription( rDescriptions[nImpl] );
130 for (sal_Int32 nEntryPos=0; nEntryPos<nEntryCount; ++nEntryPos)
135 if (pStringItem->IsDouble())
136 rValue <<= pStringItem->GetDoubleValue();
138 rValue <<= pStringItem->GetIntValue();
146 OSL_FAIL(
"wrong count" );
158 std::vector<ScSolverOptionsEntry> aDescriptions(
nCount );
164 aVisName = xDesc->getPropertyDescription(
aPropName );
165 if ( aVisName.isEmpty() )
167 aDescriptions[
nPos].nPosition =
nPos;
168 aDescriptions[
nPos].aDescription = aVisName;
170 std::sort( aDescriptions.begin(), aDescriptions.end() );
174 uno::Sequence<beans::PropertyValue> aNewSeq;
175 aNewSeq.realloc(
nCount );
176 std::transform(aDescriptions.begin(), aDescriptions.end(), aNewSeq.getArray(),
177 [
this](
const ScSolverOptionsEntry& rDescr) -> beans::PropertyValue { return maProperties[ rDescr.nPosition ]; });
187 OUString aVisName = aDescriptions[
nPos].aDescription;
190 uno::TypeClass eClass = aValue.getValueTypeClass();
194 if ( eClass == uno::TypeClass_BOOLEAN )
205 if (eClass == uno::TypeClass_DOUBLE)
207 double fDoubleValue = 0.0;
208 if (aValue >>= fDoubleValue)
209 m_aOptions.back()->SetDoubleValue(fDoubleValue);
211 OUString sTxt = aVisName +
": " +
212 rtl::math::doubleToUString(fDoubleValue,
213 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
220 sal_Int32 nIntValue = 0;
221 if (aValue >>= nIntValue)
224 OUString sTxt = aVisName +
": " + OUString::number(nIntValue);
267 OUString sTxt(pStringItem->
GetText() +
": " +
269 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
303 if (&rBtn == m_xBtnEdit.get())
315 const sal_Int32 nSelectPos = m_xLbEngine->get_active();
316 if ( nSelectPos < maImplNames.getLength() )
318 OUString aNewEngine( maImplNames[nSelectPos] );
319 if ( aNewEngine != maEngine )
321 maEngine = aNewEngine;
330 bool bCheckbox =
false;
332 int nEntry = m_xLbSettings->get_selected_index();
335 ScSolverOptionsString* pStringItem = weld::fromId<ScSolverOptionsString*>(m_xLbSettings->get_id(nEntry));
340 m_xBtnEdit->set_sensitive(!bCheckbox);
344 : GenericDialogController(pParent,
"modules/scalc/ui/integerdialog.ui",
"IntegerDialog")
345 ,
m_xFrame(m_xBuilder->weld_frame(
"frame"))
346 , m_xNfValue(m_xBuilder->weld_spin_button(
"value"))
375 : GenericDialogController(pParent,
"modules/scalc/ui/doubledialog.ui",
"DoubleDialog")
376 ,
m_xFrame(m_xBuilder->weld_frame(
"frame"))
377 , m_xEdValue(m_xBuilder->weld_entry(
"value"))
378 , m_fMaxValue(
std::numeric_limits<double>::quiet_NaN())
393 m_xEdValue->set_text( rtl::math::doubleToUString( fValue,
394 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
407 rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
408 sal_Int32 nParseEnd = 0;
css::uno::Reference< css::lang::XComponent > m_xFrame
double stringToDouble(std::u16string_view aString, bool bUseGroupSep, rtl_math_ConversionStatus *pStatus, sal_Int32 *pParseEnd) const
const OUString & getNumDecimalSep() const
static SC_DLLPUBLIC CollatorWrapper & GetCollator()
case-insensitive collator
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
sal_Int32 GetValue() const
std::unique_ptr< weld::SpinButton > m_xNfValue
void SetValue(sal_Int32 nValue)
virtual ~ScSolverIntegerDialog() override
void SetOptionName(const OUString &rName)
void SetMax(sal_Int32 nValue)
std::unique_ptr< weld::Frame > m_xFrame
ScSolverIntegerDialog(weld::Window *pParent)
css::uno::Sequence< OUString > maImplNames
std::shared_ptr< ScSolverIntegerDialog > m_xIntDialog
std::shared_ptr< ScSolverValueDialog > m_xValDialog
virtual ~ScSolverOptionsDialog() override
std::unique_ptr< weld::Button > m_xBtnEdit
std::unique_ptr< weld::ComboBox > m_xLbEngine
std::unique_ptr< weld::TreeView > m_xLbSettings
const css::uno::Sequence< css::beans::PropertyValue > & GetProperties()
ScSolverOptionsDialog(weld::Window *pParent, const css::uno::Sequence< OUString > &rImplNames, const css::uno::Sequence< OUString > &rDescriptions, OUString aEngine, const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
css::uno::Sequence< css::beans::PropertyValue > maProperties
std::vector< std::unique_ptr< ScSolverOptionsString > > m_aOptions
const OUString & GetText() const
double GetDoubleValue() const
sal_Int32 GetIntValue() const
void SetIntValue(sal_Int32 nNew)
void SetDoubleValue(double fNew)
static css::uno::Sequence< css::beans::PropertyValue > GetDefaults(std::u16string_view rImplName)
static css::uno::Reference< css::sheet::XSolver > GetSolver(std::u16string_view rImplName)
void SetOptionName(const OUString &rName)
virtual ~ScSolverValueDialog() override
std::unique_ptr< weld::Frame > m_xFrame
std::unique_ptr< weld::Entry > m_xEdValue
void SetMax(double fValue)
ScSolverValueDialog(weld::Window *pParent)
void SetValue(double fValue)
static bool GetBoolFromAny(const css::uno::Any &aAny)
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
std::shared_ptr< weld::Dialog > m_xDialog
bool operator<(const ScDPCollection::DBType &left, const ScDPCollection::DBType &right)
#define LINK(Instance, Class, Member)
SvGenericNameContainerMapImpl maProperties
OUString toId(const void *pValue)
IMPL_LINK(ScSolverOptionsDialog, ButtonHdl, weld::Button &, rBtn, void)
IMPL_LINK_NOARG(ScSolverOptionsDialog, SettingsDoubleClickHdl, weld::TreeView &, bool)