[Libreoffice-commits] core.git: 2 commits - cppuhelper/source sccomp/source sc/source
Matúš Kukan
matus.kukan at collabora.com
Fri Apr 4 06:45:39 PDT 2014
cppuhelper/source/servicemanager.cxx | 7 +--
sc/source/ui/miscdlgs/solverutil.cxx | 72 +++++++------------------------
sccomp/source/solver/CoinMPSolver.cxx | 5 ++
sccomp/source/solver/LpsolveSolver.cxx | 5 ++
sccomp/source/solver/SolverComponent.cxx | 5 --
sccomp/source/solver/SolverComponent.hxx | 2
6 files changed, 32 insertions(+), 64 deletions(-)
New commits:
commit 5f0321b3d0666e2f9011a76e6e0a5e4efaf91c5f
Author: Matúš Kukan <matus.kukan at collabora.com>
Date: Fri Apr 4 09:27:38 2014 +0200
fix creating com.sun.star.sheet.Solver instance
Change-Id: I100d45b8f749ece5496d8e5a0e3343dee96f7138
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index 6a0543c..94d2ec5 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -1246,10 +1246,9 @@ cppuhelper::ServiceManager::createContentEnumeration(
} else if (impl->factory2.is()) {
factories.push_back(css::uno::makeAny(impl->factory2));
} else {
- throw css::uno::DeploymentException(
- ("Implementation " + impl->info->name
- + " does not provide a factory"),
- static_cast< cppu::OWeakObject * >(this));
+ css::uno::Reference< css::lang::XSingleComponentFactory > factory(
+ new ImplementationWrapper(this, *i));
+ factories.push_back(css::uno::makeAny(factory));
}
}
return new ContentEnumeration(factories);
diff --git a/sc/source/ui/miscdlgs/solverutil.cxx b/sc/source/ui/miscdlgs/solverutil.cxx
index a8f401d..bf98592 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;
}
commit 527f5da2f051e32372d9d4d5e808bdf022d18840
Author: Matúš Kukan <matus.kukan at collabora.com>
Date: Fri Apr 4 14:10:42 2014 +0200
sccomp: Fix description of com.sun.star.comp.Calc.CoinMPSolver.
Forgotten in 077bdc73f2bcd625be1030fa8ff630c3dbd83657
Change-Id: Iddf90f1107f05351754830b49344cb24db1e1089
diff --git a/sccomp/source/solver/CoinMPSolver.cxx b/sccomp/source/solver/CoinMPSolver.cxx
index a7127e3..f1ee10b 100644
--- a/sccomp/source/solver/CoinMPSolver.cxx
+++ b/sccomp/source/solver/CoinMPSolver.cxx
@@ -44,6 +44,11 @@ private:
{
return OUString("com.sun.star.comp.Calc.CoinMPSolver");
}
+ virtual OUString SAL_CALL getComponentDescription()
+ throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
+ {
+ return SolverComponent::GetResourceString( RID_COINMP_SOLVER_COMPONENT );
+ }
};
void SAL_CALL CoinMPSolver::solve() throw(uno::RuntimeException, std::exception)
diff --git a/sccomp/source/solver/LpsolveSolver.cxx b/sccomp/source/solver/LpsolveSolver.cxx
index a977f91..817152f 100644
--- a/sccomp/source/solver/LpsolveSolver.cxx
+++ b/sccomp/source/solver/LpsolveSolver.cxx
@@ -77,6 +77,11 @@ private:
{
return OUString("com.sun.star.comp.Calc.LpsolveSolver");
}
+ virtual OUString SAL_CALL getComponentDescription()
+ throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
+ {
+ return SolverComponent::GetResourceString( RID_SOLVER_COMPONENT );
+ }
};
void SAL_CALL LpsolveSolver::solve() throw(uno::RuntimeException, std::exception)
diff --git a/sccomp/source/solver/SolverComponent.cxx b/sccomp/source/solver/SolverComponent.cxx
index bb20cfe..d84fbd4 100644
--- a/sccomp/source/solver/SolverComponent.cxx
+++ b/sccomp/source/solver/SolverComponent.cxx
@@ -139,11 +139,6 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL SolverComponent::getPropertySet
// XSolverDescription
-OUString SAL_CALL SolverComponent::getComponentDescription() throw (uno::RuntimeException, std::exception)
-{
- return SolverComponent::GetResourceString( RID_SOLVER_COMPONENT );
-}
-
OUString SAL_CALL SolverComponent::getStatusDescription() throw (uno::RuntimeException, std::exception)
{
return maStatus;
diff --git a/sccomp/source/solver/SolverComponent.hxx b/sccomp/source/solver/SolverComponent.hxx
index 1d2ceed..b0f9a24 100644
--- a/sccomp/source/solver/SolverComponent.hxx
+++ b/sccomp/source/solver/SolverComponent.hxx
@@ -139,7 +139,7 @@ public:
virtual void SAL_CALL solve() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE = 0;
// XSolverDescription
- virtual OUString SAL_CALL getComponentDescription() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual OUString SAL_CALL getComponentDescription() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE = 0;
virtual OUString SAL_CALL getStatusDescription() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual OUString SAL_CALL getPropertyDescription( const OUString& aPropertyName )
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
More information about the Libreoffice-commits
mailing list