xref: /aoo41x/main/sccomp/source/solver/solver.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SOLVER_HXX
29 #define SOLVER_HXX
30 
31 #include <com/sun/star/sheet/XSolver.hpp>
32 #include <com/sun/star/sheet/XSolverDescription.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <cppuhelper/implbase3.hxx>
36 #include <comphelper/broadcasthelper.hxx>
37 #include <comphelper/propertycontainer.hxx>
38 #include <comphelper/proparrhlp.hxx>
39 
40 typedef cppu::WeakImplHelper3<
41                 com::sun::star::sheet::XSolver,
42                 com::sun::star::sheet::XSolverDescription,
43                 com::sun::star::lang::XServiceInfo >
44         SolverComponent_Base;
45 
46 class SolverComponent : public comphelper::OMutexAndBroadcastHelper,
47                         public comphelper::OPropertyContainer,
48                         public comphelper::OPropertyArrayUsageHelper< SolverComponent >,
49                         public SolverComponent_Base
50 {
51     // settings
52     com::sun::star::uno::Reference< com::sun::star::sheet::XSpreadsheetDocument > mxDoc;
53     com::sun::star::table::CellAddress                                            maObjective;
54     com::sun::star::uno::Sequence< com::sun::star::table::CellAddress >           maVariables;
55     com::sun::star::uno::Sequence< com::sun::star::sheet::SolverConstraint >      maConstraints;
56     sal_Bool                                                                      mbMaximize;
57     // set via XPropertySet
58     sal_Bool                                                                      mbNonNegative;
59     sal_Bool                                                                      mbInteger;
60     sal_Int32                                                                     mnTimeout;
61     sal_Int32                                                                     mnEpsilonLevel;
62     sal_Bool                                                                      mbLimitBBDepth;
63     // results
64     sal_Bool                                                                      mbSuccess;
65     double                                                                        mfResultValue;
66     com::sun::star::uno::Sequence< double >                                       maSolution;
67     rtl::OUString                                                                 maStatus;
68 
69 public:
70                             SolverComponent( const com::sun::star::uno::Reference<
71                                     com::sun::star::uno::XComponentContext >& rxMSF );
72     virtual                 ~SolverComponent();
73 
74     DECLARE_XINTERFACE()
75     DECLARE_XTYPEPROVIDER()
76 
77     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
78                                 throw (::com::sun::star::uno::RuntimeException);
79     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();     // from OPropertySetHelper
80     virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;    // from OPropertyArrayUsageHelper
81 
82                             // XSolver
83     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > SAL_CALL getDocument()
84                                 throw(::com::sun::star::uno::RuntimeException);
85     virtual void SAL_CALL   setDocument( const ::com::sun::star::uno::Reference<
86                                     ::com::sun::star::sheet::XSpreadsheetDocument >& _document )
87                                 throw(::com::sun::star::uno::RuntimeException);
88     virtual ::com::sun::star::table::CellAddress SAL_CALL getObjective() throw(::com::sun::star::uno::RuntimeException);
89     virtual void SAL_CALL   setObjective( const ::com::sun::star::table::CellAddress& _objective )
90                                 throw(::com::sun::star::uno::RuntimeException);
91     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::table::CellAddress > SAL_CALL getVariables()
92                                 throw(::com::sun::star::uno::RuntimeException);
93     virtual void SAL_CALL   setVariables( const ::com::sun::star::uno::Sequence<
94                                     ::com::sun::star::table::CellAddress >& _variables )
95                                 throw(::com::sun::star::uno::RuntimeException);
96     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::SolverConstraint > SAL_CALL getConstraints()
97                                 throw(::com::sun::star::uno::RuntimeException);
98     virtual void SAL_CALL   setConstraints( const ::com::sun::star::uno::Sequence<
99                                     ::com::sun::star::sheet::SolverConstraint >& _constraints )
100                                 throw(::com::sun::star::uno::RuntimeException);
101     virtual ::sal_Bool SAL_CALL getMaximize() throw(::com::sun::star::uno::RuntimeException);
102     virtual void SAL_CALL   setMaximize( ::sal_Bool _maximize ) throw(::com::sun::star::uno::RuntimeException);
103 
104     virtual ::sal_Bool SAL_CALL getSuccess() throw(::com::sun::star::uno::RuntimeException);
105     virtual double SAL_CALL getResultValue() throw(::com::sun::star::uno::RuntimeException);
106     virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getSolution()
107                                 throw(::com::sun::star::uno::RuntimeException);
108 
109     virtual void SAL_CALL solve() throw(::com::sun::star::uno::RuntimeException);
110 
111                             // XSolverDescription
112     virtual ::rtl::OUString SAL_CALL getComponentDescription() throw (::com::sun::star::uno::RuntimeException);
113     virtual ::rtl::OUString SAL_CALL getStatusDescription() throw (::com::sun::star::uno::RuntimeException);
114     virtual ::rtl::OUString SAL_CALL getPropertyDescription( const ::rtl::OUString& aPropertyName )
115                                 throw (::com::sun::star::uno::RuntimeException);
116 
117                             // XServiceInfo
118     virtual ::rtl::OUString SAL_CALL getImplementationName()
119                                 throw(::com::sun::star::uno::RuntimeException);
120     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
121                                 throw(::com::sun::star::uno::RuntimeException);
122     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
123                                 throw(::com::sun::star::uno::RuntimeException);
124 };
125 
126 #endif
127 
128