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