xref: /trunk/main/sccomp/source/solver/solver.hxx (revision 5e5eb4d3)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SOLVER_HXX
25 #define SOLVER_HXX
26 
27 #include <com/sun/star/sheet/XSolver.hpp>
28 #include <com/sun/star/sheet/XSolverDescription.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <cppuhelper/implbase3.hxx>
32 #include <comphelper/broadcasthelper.hxx>
33 #include <comphelper/propertycontainer.hxx>
34 #include <comphelper/proparrhlp.hxx>
35 
36 typedef cppu::WeakImplHelper3<
37                 com::sun::star::sheet::XSolver,
38                 com::sun::star::sheet::XSolverDescription,
39                 com::sun::star::lang::XServiceInfo >
40         SolverComponent_Base;
41 
42 class SolverComponent : public comphelper::OMutexAndBroadcastHelper,
43                         public comphelper::OPropertyContainer,
44                         public comphelper::OPropertyArrayUsageHelper< SolverComponent >,
45                         public SolverComponent_Base
46 {
47     // settings
48     com::sun::star::uno::Reference< com::sun::star::sheet::XSpreadsheetDocument > mxDoc;
49     com::sun::star::table::CellAddress                                            maObjective;
50     com::sun::star::uno::Sequence< com::sun::star::table::CellAddress >           maVariables;
51     com::sun::star::uno::Sequence< com::sun::star::sheet::SolverConstraint >      maConstraints;
52     sal_Bool                                                                      mbMaximize;
53     // set via XPropertySet
54     sal_Bool                                                                      mbNonNegative;
55     sal_Bool                                                                      mbInteger;
56     sal_Int32                                                                     mnTimeout;
57     sal_Int32                                                                     mnEpsilonLevel;
58     sal_Bool                                                                      mbLimitBBDepth;
59     sal_Bool                                                                      mbNonLinearTest;
60     // results
61     sal_Bool                                                                      mbSuccess;
62     double                                                                        mfResultValue;
63     com::sun::star::uno::Sequence< double >                                       maSolution;
64     rtl::OUString                                                                 maStatus;
65 
66 public:
67                             SolverComponent( const com::sun::star::uno::Reference<
68                                     com::sun::star::uno::XComponentContext >& rxMSF );
69     virtual                 ~SolverComponent();
70 
71     DECLARE_XINTERFACE()
72     DECLARE_XTYPEPROVIDER()
73 
74     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
75                                 throw (::com::sun::star::uno::RuntimeException);
76     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();     // from OPropertySetHelper
77     virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;    // from OPropertyArrayUsageHelper
78 
79                             // XSolver
80     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > SAL_CALL getDocument()
81                                 throw(::com::sun::star::uno::RuntimeException);
82     virtual void SAL_CALL   setDocument( const ::com::sun::star::uno::Reference<
83                                     ::com::sun::star::sheet::XSpreadsheetDocument >& _document )
84                                 throw(::com::sun::star::uno::RuntimeException);
85     virtual ::com::sun::star::table::CellAddress SAL_CALL getObjective() throw(::com::sun::star::uno::RuntimeException);
86     virtual void SAL_CALL   setObjective( const ::com::sun::star::table::CellAddress& _objective )
87                                 throw(::com::sun::star::uno::RuntimeException);
88     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::table::CellAddress > SAL_CALL getVariables()
89                                 throw(::com::sun::star::uno::RuntimeException);
90     virtual void SAL_CALL   setVariables( const ::com::sun::star::uno::Sequence<
91                                     ::com::sun::star::table::CellAddress >& _variables )
92                                 throw(::com::sun::star::uno::RuntimeException);
93     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::SolverConstraint > SAL_CALL getConstraints()
94                                 throw(::com::sun::star::uno::RuntimeException);
95     virtual void SAL_CALL   setConstraints( const ::com::sun::star::uno::Sequence<
96                                     ::com::sun::star::sheet::SolverConstraint >& _constraints )
97                                 throw(::com::sun::star::uno::RuntimeException);
98     virtual ::sal_Bool SAL_CALL getMaximize() throw(::com::sun::star::uno::RuntimeException);
99     virtual void SAL_CALL   setMaximize( ::sal_Bool _maximize ) throw(::com::sun::star::uno::RuntimeException);
100 
101     virtual ::sal_Bool SAL_CALL getSuccess() throw(::com::sun::star::uno::RuntimeException);
102     virtual double SAL_CALL getResultValue() throw(::com::sun::star::uno::RuntimeException);
103     virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getSolution()
104                                 throw(::com::sun::star::uno::RuntimeException);
105 
106     virtual void SAL_CALL solve() throw(::com::sun::star::uno::RuntimeException);
107 
108                             // XSolverDescription
109     virtual ::rtl::OUString SAL_CALL getComponentDescription() throw (::com::sun::star::uno::RuntimeException);
110     virtual ::rtl::OUString SAL_CALL getStatusDescription() throw (::com::sun::star::uno::RuntimeException);
111     virtual ::rtl::OUString SAL_CALL getPropertyDescription( const ::rtl::OUString& aPropertyName )
112                                 throw (::com::sun::star::uno::RuntimeException);
113 
114                             // XServiceInfo
115     virtual ::rtl::OUString SAL_CALL getImplementationName()
116                                 throw(::com::sun::star::uno::RuntimeException);
117     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
118                                 throw(::com::sun::star::uno::RuntimeException);
119     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
120                                 throw(::com::sun::star::uno::RuntimeException);
121 };
122 
123 #endif
124 
125