From 530ea91927db14f10b78453accc51e1add7d990b Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Thu, 27 Mar 2014 09:12:06 +0100 Subject: sccomp: Make the source files more similar and fix some problems. Change-Id: I1e3c8aac52e9d2677937e08aac08db4ace5cb2b8 --- sccomp/source/solver/solver-lpsolve.cxx | 2 +- sccomp/source/solver/solver.cxx | 49 ++++++++++++++++----------------- 2 files changed, 24 insertions(+), 27 deletions(-) (limited to 'sccomp/source') diff --git a/sccomp/source/solver/solver-lpsolve.cxx b/sccomp/source/solver/solver-lpsolve.cxx index 9bcf6e514761..0c8e811de128 100644 --- a/sccomp/source/solver/solver-lpsolve.cxx +++ b/sccomp/source/solver/solver-lpsolve.cxx @@ -578,7 +578,7 @@ uno::Sequence< OUString > SolverComponent_getSupportedServiceNames() OUString SolverComponent_getImplementationName() { - return OUString("com.sun.star.comp.Calc.Solver" ); + return OUString("com.sun.star.comp.Calc.Solver"); } OUString SAL_CALL SolverComponent::getImplementationName() throw(uno::RuntimeException, std::exception) diff --git a/sccomp/source/solver/solver.cxx b/sccomp/source/solver/solver.cxx index 5ea871e2c4b2..76ac1af7ae6e 100644 --- a/sccomp/source/solver/solver.cxx +++ b/sccomp/source/solver/solver.cxx @@ -37,13 +37,12 @@ #include #include #include -#include +#include #include using namespace com::sun::star; -#define C2U(constAsciiStr) (::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) )) #define STR_NONNEGATIVE "NonNegative" #define STR_INTEGER "Integer" @@ -51,20 +50,20 @@ using namespace com::sun::star; #define STR_EPSILONLEVEL "EpsilonLevel" #define STR_LIMITBBDEPTH "LimitBBDepth" -// ----------------------------------------------------------------------- + // Resources from tools are used for translated strings static ResMgr* pSolverResMgr = NULL; -OUString lcl_GetResourceString( sal_uInt32 nId ) +static OUString lcl_GetResourceString( sal_uInt32 nId ) { if (!pSolverResMgr) - pSolverResMgr = ResMgr::CreateResMgr( "solver" ); + pSolverResMgr = ResMgr::CreateResMgr("solver"); - return ResId( nId, *pSolverResMgr ); + return ResId(nId, *pSolverResMgr).toString(); } -// ----------------------------------------------------------------------- + namespace { @@ -78,7 +77,7 @@ namespace }; } -// ----------------------------------------------------------------------- + // hash map for the coefficients of a dependent cell (objective or constraint) // The size of each vector is the number of columns (variable cells) plus one, first entry is initial value. @@ -104,11 +103,11 @@ struct ScSolverCellEqual } }; -typedef std::unordered_map< table::CellAddress, std::vector, ScSolverCellHash, ScSolverCellEqual > ScSolverCellHashMap; +typedef boost::unordered_map< table::CellAddress, std::vector, ScSolverCellHash, ScSolverCellEqual > ScSolverCellHashMap; -// ----------------------------------------------------------------------- -uno::Reference lcl_GetCell( const uno::Reference& xDoc, + +static uno::Reference lcl_GetCell( const uno::Reference& xDoc, const table::CellAddress& rPos ) { uno::Reference xSheets( xDoc->getSheets(), uno::UNO_QUERY ); @@ -116,19 +115,19 @@ uno::Reference lcl_GetCell( const uno::ReferencegetCellByPosition( rPos.Column, rPos.Row ); } -void lcl_SetValue( const uno::Reference& xDoc, +static void lcl_SetValue( const uno::Reference& xDoc, const table::CellAddress& rPos, double fValue ) { lcl_GetCell( xDoc, rPos )->setValue( fValue ); } -double lcl_GetValue( const uno::Reference& xDoc, +static double lcl_GetValue( const uno::Reference& xDoc, const table::CellAddress& rPos ) { return lcl_GetCell( xDoc, rPos )->getValue(); } -// ------------------------------------------------------------------------- + SolverComponent::SolverComponent( const uno::Reference& /* rSMgr */ ) : OPropertyContainer( GetBroadcastHelper() ), @@ -142,11 +141,11 @@ SolverComponent::SolverComponent( const uno::Reference& mfResultValue( 0.0 ) { // for XPropertySet implementation: - registerProperty( C2U(STR_NONNEGATIVE), PROP_NONNEGATIVE, 0, &mbNonNegative, getCppuType( &mbNonNegative ) ); - registerProperty( C2U(STR_INTEGER), PROP_INTEGER, 0, &mbInteger, getCppuType( &mbInteger ) ); - registerProperty( C2U(STR_TIMEOUT), PROP_TIMEOUT, 0, &mnTimeout, getCppuType( &mnTimeout ) ); - registerProperty( C2U(STR_EPSILONLEVEL), PROP_EPSILONLEVEL, 0, &mnEpsilonLevel, getCppuType( &mnEpsilonLevel ) ); - registerProperty( C2U(STR_LIMITBBDEPTH), PROP_LIMITBBDEPTH, 0, &mbLimitBBDepth, getCppuType( &mbLimitBBDepth ) ); + registerProperty( STR_NONNEGATIVE, PROP_NONNEGATIVE, 0, &mbNonNegative, getCppuType( &mbNonNegative ) ); + registerProperty( STR_INTEGER, PROP_INTEGER, 0, &mbInteger, getCppuType( &mbInteger ) ); + registerProperty( STR_TIMEOUT, PROP_TIMEOUT, 0, &mnTimeout, getCppuType( &mnTimeout ) ); + registerProperty( STR_EPSILONLEVEL, PROP_EPSILONLEVEL, 0, &mnEpsilonLevel, getCppuType( &mnEpsilonLevel ) ); + registerProperty( STR_LIMITBBDEPTH, PROP_LIMITBBDEPTH, 0, &mbLimitBBDepth, getCppuType( &mbLimitBBDepth ) ); } SolverComponent::~SolverComponent() @@ -289,15 +288,13 @@ uno::Sequence SAL_CALL SolverComponent::getSolution() throw(uno::Runtime return maSolution; } -// ------------------------------------------------------------------------- - void SAL_CALL SolverComponent::solve() throw(uno::RuntimeException, std::exception) { uno::Reference xModel( mxDoc, uno::UNO_QUERY ); if ( !xModel.is() ) throw uno::RuntimeException(); - maStatus = OUString(); + maStatus = ""; mbSuccess = false; xModel->lockControllers(); @@ -374,7 +371,7 @@ void SAL_CALL SolverComponent::solve() throw(uno::RuntimeException, std::excepti xModel->unlockControllers(); - if ( maStatus.getLength() ) + if ( !maStatus.isEmpty() ) return; // @@ -583,13 +580,13 @@ void SAL_CALL SolverComponent::solve() throw(uno::RuntimeException, std::excepti uno::Sequence< OUString > SolverComponent_getSupportedServiceNames() { uno::Sequence< OUString > aServiceNames( 1 ); - aServiceNames[ 0 ] = OUString::createFromAscii( "com.sun.star.sheet.Solver" ); + aServiceNames[ 0 ] = "com.sun.star.sheet.Solver"; return aServiceNames; } OUString SolverComponent_getImplementationName() { - return OUString::createFromAscii( "com.sun.star.comp.Calc.CoinMPSolver" ); + return OUString("com.sun.star.comp.Calc.CoinMPSolver"); } OUString SAL_CALL SolverComponent::getImplementationName() throw(uno::RuntimeException, std::exception) @@ -599,7 +596,7 @@ OUString SAL_CALL SolverComponent::getImplementationName() throw(uno::RuntimeExc sal_Bool SAL_CALL SolverComponent::supportsService( const OUString& rServiceName ) throw(uno::RuntimeException, std::exception) { - return cppu::supportsService( this, rServiceName ); + return cppu::supportsService(this, rServiceName); } uno::Sequence SAL_CALL SolverComponent::getSupportedServiceNames() throw(uno::RuntimeException, std::exception) -- cgit v1.2.3