xref: /aoo41x/main/sccomp/source/solver/solver.hxx (revision 925e7d74)
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     // results
60     sal_Bool                                                                      mbSuccess;
61     double                                                                        mfResultValue;
62     com::sun::star::uno::Sequence< double >                                       maSolution;
63     rtl::OUString                                                                 maStatus;
64 
65 public:
66                             SolverComponent( const com::sun::star::uno::Reference<
67                                     com::sun::star::uno::XComponentContext >& rxMSF );
68     virtual                 ~SolverComponent();
69 
70     DECLARE_XINTERFACE()
71     DECLARE_XTYPEPROVIDER()
72 
73     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
74                                 throw (::com::sun::star::uno::RuntimeException);
75     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();     // from OPropertySetHelper
76     virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;    // from OPropertyArrayUsageHelper
77 
78                             // XSolver
79     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > SAL_CALL getDocument()
80                                 throw(::com::sun::star::uno::RuntimeException);
81     virtual void SAL_CALL   setDocument( const ::com::sun::star::uno::Reference<
82                                     ::com::sun::star::sheet::XSpreadsheetDocument >& _document )
83                                 throw(::com::sun::star::uno::RuntimeException);
84     virtual ::com::sun::star::table::CellAddress SAL_CALL getObjective() throw(::com::sun::star::uno::RuntimeException);
85     virtual void SAL_CALL   setObjective( const ::com::sun::star::table::CellAddress& _objective )
86                                 throw(::com::sun::star::uno::RuntimeException);
87     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::table::CellAddress > SAL_CALL getVariables()
88                                 throw(::com::sun::star::uno::RuntimeException);
89     virtual void SAL_CALL   setVariables( const ::com::sun::star::uno::Sequence<
90                                     ::com::sun::star::table::CellAddress >& _variables )
91                                 throw(::com::sun::star::uno::RuntimeException);
92     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::SolverConstraint > SAL_CALL getConstraints()
93                                 throw(::com::sun::star::uno::RuntimeException);
94     virtual void SAL_CALL   setConstraints( const ::com::sun::star::uno::Sequence<
95                                     ::com::sun::star::sheet::SolverConstraint >& _constraints )
96                                 throw(::com::sun::star::uno::RuntimeException);
97     virtual ::sal_Bool SAL_CALL getMaximize() throw(::com::sun::star::uno::RuntimeException);
98     virtual void SAL_CALL   setMaximize( ::sal_Bool _maximize ) throw(::com::sun::star::uno::RuntimeException);
99 
100     virtual ::sal_Bool SAL_CALL getSuccess() throw(::com::sun::star::uno::RuntimeException);
101     virtual double SAL_CALL getResultValue() throw(::com::sun::star::uno::RuntimeException);
102     virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getSolution()
103                                 throw(::com::sun::star::uno::RuntimeException);
104 
105     virtual void SAL_CALL solve() throw(::com::sun::star::uno::RuntimeException);
106 
107                             // XSolverDescription
108     virtual ::rtl::OUString SAL_CALL getComponentDescription() throw (::com::sun::star::uno::RuntimeException);
109     virtual ::rtl::OUString SAL_CALL getStatusDescription() throw (::com::sun::star::uno::RuntimeException);
110     virtual ::rtl::OUString SAL_CALL getPropertyDescription( const ::rtl::OUString& aPropertyName )
111                                 throw (::com::sun::star::uno::RuntimeException);
112 
113                             // XServiceInfo
114     virtual ::rtl::OUString SAL_CALL getImplementationName()
115                                 throw(::com::sun::star::uno::RuntimeException);
116     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
117                                 throw(::com::sun::star::uno::RuntimeException);
118     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
119                                 throw(::com::sun::star::uno::RuntimeException);
120 };
121 
122 #endif
123 
124