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