1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 #include <cppuhelper/implbase.hxx>
14 #include <com/sun/star/beans/PropertyValue.hpp>
15 #include <com/sun/star/lang/XServiceInfo.hpp>
16 #include <com/sun/star/sheet/XSolverSettings.hpp>
17 #include <com/sun/star/sheet/SolverObjectiveType.hpp>
18 #include <com/sun/star/sheet/SolverStatus.hpp>
19 #include <com/sun/star/sheet/SolverConstraint.hpp>
21 namespace com::sun::star::container
37 class ScSolverSettings final
38 : public ::cppu::WeakImplHelper
<css::sheet::XSolverSettings
, css::lang::XServiceInfo
>
41 ScDocShell
* m_pDocShell
;
43 css::uno::Reference
<css::container::XNamed
> m_xSheet
;
44 // Status uses constants in css::uno::sheet::SolverStatus
46 bool m_bSuppressDialog
;
47 OUString m_sErrorMessage
;
49 std::shared_ptr
<sc::SolverSettings
> m_pSettings
;
51 // Parses a reference string (named ranges are also parsed)
52 // If bAllowRange is "false" then only single cell ranges are acceptable,
53 // which is the case of the objective cell
54 bool ParseRef(ScRange
& rRange
, const OUString
& rInput
, bool bAllowRange
);
56 // Parses a reference string composed of various ranges
57 bool ParseWithNames(ScRangeList
& rRanges
, std::u16string_view rInput
);
59 static void ShowErrorMessage(const OUString
& rMessage
);
62 ScSolverSettings(ScDocShell
* pDocSh
, css::uno::Reference
<css::container::XNamed
> xSheet
);
65 // XSolverSettings attributes
66 virtual sal_Int8 SAL_CALL
getObjectiveType() override
;
67 virtual void SAL_CALL
setObjectiveType(sal_Int8 aObjType
) override
;
68 virtual css::uno::Any SAL_CALL
getObjectiveCell() override
;
69 virtual void SAL_CALL
setObjectiveCell(const css::uno::Any
& aValue
) override
;
70 virtual css::uno::Any SAL_CALL
getGoalValue() override
;
71 virtual void SAL_CALL
setGoalValue(const css::uno::Any
& aValue
) override
;
72 virtual OUString SAL_CALL
getEngine() override
;
73 virtual void SAL_CALL
setEngine(const OUString
& sEngine
) override
;
74 virtual css::uno::Sequence
<OUString
> SAL_CALL
getAvailableEngines() override
;
75 virtual css::uno::Sequence
<css::uno::Any
> SAL_CALL
getVariableCells() override
;
77 setVariableCells(const css::uno::Sequence
<css::uno::Any
>& aRanges
) override
;
78 virtual css::uno::Sequence
<css::sheet::ModelConstraint
> SAL_CALL
getConstraints() override
;
80 setConstraints(const css::uno::Sequence
<css::sheet::ModelConstraint
>& aConstraints
) override
;
81 virtual sal_Int32 SAL_CALL
getConstraintCount() override
;
82 virtual css::uno::Sequence
<css::beans::PropertyValue
> SAL_CALL
getEngineOptions() override
;
84 setEngineOptions(const css::uno::Sequence
<css::beans::PropertyValue
>& rProps
) override
;
85 virtual sal_Int8 SAL_CALL
getStatus() override
;
86 virtual OUString SAL_CALL
getErrorMessage() override
;
87 virtual sal_Bool SAL_CALL
getSuppressDialog() override
;
88 virtual void SAL_CALL
setSuppressDialog(sal_Bool bSuppress
) override
;
90 // XSolverSettings methods
91 virtual void SAL_CALL
reset() override
;
92 virtual void SAL_CALL
solve() override
;
93 virtual void SAL_CALL
saveToFile() override
;
96 virtual OUString SAL_CALL
getImplementationName() override
;
97 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
98 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;