Fix build
[LibreOffice.git] / sc / inc / solveruno.hxx
blobcf13777168f6f246942f90b4f9da5bb3037af22b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
11 #pragma once
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
23 class XNamed;
26 namespace sc
28 class SolverSettings;
31 class ScDocument;
32 class ScDocShell;
33 class ScTable;
34 class ScRange;
35 class ScRangeList;
37 class ScSolverSettings final
38 : public ::cppu::WeakImplHelper<css::sheet::XSolverSettings, css::lang::XServiceInfo>
40 private:
41 ScDocShell* m_pDocShell;
42 ScDocument& m_rDoc;
43 css::uno::Reference<css::container::XNamed> m_xSheet;
44 // Status uses constants in css::uno::sheet::SolverStatus
45 sal_Int8 m_nStatus;
46 bool m_bSuppressDialog;
47 OUString m_sErrorMessage;
48 ScTable* m_pTable;
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);
61 public:
62 ScSolverSettings(ScDocShell* pDocSh, css::uno::Reference<css::container::XNamed> xSheet);
63 ~ScSolverSettings();
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;
76 virtual void SAL_CALL
77 setVariableCells(const css::uno::Sequence<css::uno::Any>& aRanges) override;
78 virtual css::uno::Sequence<css::sheet::ModelConstraint> SAL_CALL getConstraints() override;
79 virtual void SAL_CALL
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;
83 virtual void SAL_CALL
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;
95 // XServiceInfo
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;