diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-04-04 09:27:38 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-04-04 15:44:32 +0200 |
commit | 5f0321b3d0666e2f9011a76e6e0a5e4efaf91c5f (patch) | |
tree | c1ad27874ece1ac60ce5d88c73a11ff3b5809ffc /sc | |
parent | 527f5da2f051e32372d9d4d5e808bdf022d18840 (diff) |
fix creating com.sun.star.sheet.Solver instance
Change-Id: I100d45b8f749ece5496d8e5a0e3343dee96f7138
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/miscdlgs/solverutil.cxx | 72 |
1 files changed, 18 insertions, 54 deletions
diff --git a/sc/source/ui/miscdlgs/solverutil.cxx b/sc/source/ui/miscdlgs/solverutil.cxx index a8f401d4b210..bf9859269962 100644 --- a/sc/source/ui/miscdlgs/solverutil.cxx +++ b/sc/source/ui/miscdlgs/solverutil.cxx @@ -20,10 +20,8 @@ #include "solverutil.hxx" #include <com/sun/star/container/XContentEnumerationAccess.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XSingleComponentFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/sheet/XSolver.hpp> @@ -37,39 +35,6 @@ using namespace com::sun::star; #define SCSOLVER_SERVICE "com.sun.star.sheet.Solver" -static uno::Reference<sheet::XSolver> lcl_CreateSolver( const uno::Reference<uno::XInterface>& xIntFac, - const uno::Reference<uno::XComponentContext>& xCtx ) -{ - uno::Reference<sheet::XSolver> xSolver; - - uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY ); - uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY ); - if ( xCFac.is() ) - { - try - { - uno::Reference<uno::XInterface> xInterface = xCFac->createInstanceWithContext(xCtx); - xSolver = uno::Reference<sheet::XSolver>( xInterface, uno::UNO_QUERY ); - } - catch(uno::Exception&) - { - } - } - if ( !xSolver.is() && xFac.is() ) - { - try - { - uno::Reference<uno::XInterface> xInterface = xFac->createInstance(); - xSolver = uno::Reference<sheet::XSolver>( xInterface, uno::UNO_QUERY ); - } - catch(uno::Exception&) - { - } - } - - return xSolver; -} - void ScSolverUtil::GetImplementations( uno::Sequence<OUString>& rImplNames, uno::Sequence<OUString>& rDescriptions ) { @@ -78,10 +43,9 @@ void ScSolverUtil::GetImplementations( uno::Sequence<OUString>& rImplNames, uno::Reference<uno::XComponentContext> xCtx( comphelper::getProcessComponentContext() ); - uno::Reference<lang::XMultiServiceFactory> xMSF( - xCtx->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY ); + uno::Reference<container::XContentEnumerationAccess> xEnAc( + xCtx->getServiceManager(), uno::UNO_QUERY ); if ( xEnAc.is() ) { uno::Reference<container::XEnumeration> xEnum = @@ -92,17 +56,18 @@ void ScSolverUtil::GetImplementations( uno::Sequence<OUString>& rImplNames, while ( xEnum->hasMoreElements() ) { uno::Any aAny = xEnum->nextElement(); - uno::Reference<uno::XInterface> xIntFac; - aAny >>= xIntFac; - if ( xIntFac.is() ) + uno::Reference<lang::XServiceInfo> xInfo; + aAny >>= xInfo; + if ( xInfo.is() ) { - uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY ); - if ( xInfo.is() ) + uno::Reference<lang::XSingleComponentFactory> xCFac( xInfo, uno::UNO_QUERY ); + if ( xCFac.is() ) { OUString sName = xInfo->getImplementationName(); OUString sDescription; - uno::Reference<sheet::XSolver> xSolver = lcl_CreateSolver( xIntFac, xCtx ); + uno::Reference<sheet::XSolver> xSolver( + xCFac->createInstanceWithContext(xCtx), uno::UNO_QUERY ); uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY ); if ( xDesc.is() ) sDescription = xDesc->getComponentDescription(); @@ -128,10 +93,9 @@ uno::Reference<sheet::XSolver> ScSolverUtil::GetSolver( const OUString& rImplNam uno::Reference<uno::XComponentContext> xCtx( comphelper::getProcessComponentContext() ); - uno::Reference<lang::XMultiServiceFactory> xMSF( - xCtx->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY ); + uno::Reference<container::XContentEnumerationAccess> xEnAc( + xCtx->getServiceManager(), uno::UNO_QUERY ); if ( xEnAc.is() ) { uno::Reference<container::XEnumeration> xEnum = @@ -141,23 +105,23 @@ uno::Reference<sheet::XSolver> ScSolverUtil::GetSolver( const OUString& rImplNam while ( xEnum->hasMoreElements() && !xSolver.is() ) { uno::Any aAny = xEnum->nextElement(); - uno::Reference<uno::XInterface> xIntFac; - aAny >>= xIntFac; - if ( xIntFac.is() ) + uno::Reference<lang::XServiceInfo> xInfo; + aAny >>= xInfo; + if ( xInfo.is() ) { - uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY ); - if ( xInfo.is() ) + uno::Reference<lang::XSingleComponentFactory> xCFac( xInfo, uno::UNO_QUERY ); + if ( xCFac.is() ) { OUString sName = xInfo->getImplementationName(); if ( sName == rImplName ) - xSolver = lcl_CreateSolver( xIntFac, xCtx ); + xSolver.set( xCFac->createInstanceWithContext(xCtx), uno::UNO_QUERY ); } } } } } - OSL_ENSURE( xSolver.is(), "can't get solver" ); + SAL_WARN_IF( !xSolver.is(), "sc.ui", "can't get solver" ); return xSolver; } |