[Libreoffice-commits] core.git: extensions/source stoc/Library_invocation.mk stoc/source

Tor Lillqvist tml at collabora.com
Thu May 31 14:53:35 UTC 2018


 extensions/source/ole/unoconversionutilities.hxx |    3 +
 stoc/Library_invocation.mk                       |    1 
 stoc/source/invocation/invocation.cxx            |   39 +++++++++++++++--------
 3 files changed, 29 insertions(+), 14 deletions(-)

New commits:
commit 2b7690d5a1a2c3064b47bd2648ba2452bf4726af
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu May 31 17:49:11 2018 +0300

    Revert "Simplify: Use AutomationInvokedZone::isActive()"
    
    Can't have the URE library 'stoc' depend on the non-URE library
    'comphelper'.
    
    This reverts commit 3c041720304ec77202741b5d5c8df9b93bc70a70.

diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx
index cbec71299953..f0ef703bd845 100644
--- a/extensions/source/ole/unoconversionutilities.hxx
+++ b/extensions/source/ole/unoconversionutilities.hxx
@@ -1395,8 +1395,9 @@ void UnoConversionUtilities<T>::createUnoObjectWrapper(const Any & rObj, VARIANT
     Reference<XSingleServiceFactory> xInvFactory= getInvocationFactory(rObj);
     if (xInvFactory.is())
     {
-        Sequence<Any> params(1);
+        Sequence<Any> params(2);
         params.getArray()[0] = rObj;
+        params.getArray()[1] = makeAny(OUString("FromOLE"));
         Reference<XInterface> xInt2 = xInvFactory->createInstanceWithArguments(params);
         xInv.set(xInt2, UNO_QUERY);
     }
diff --git a/stoc/Library_invocation.mk b/stoc/Library_invocation.mk
index dc22a2acb51b..42f17556433c 100644
--- a/stoc/Library_invocation.mk
+++ b/stoc/Library_invocation.mk
@@ -16,7 +16,6 @@ $(eval $(call gb_Library_use_udk_api,invocation))
 $(eval $(call gb_Library_use_libraries,invocation,\
     cppu \
     cppuhelper \
-    comphelper \
     sal \
 ))
 
diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx
index 3001993db4e9..68caa503d044 100644
--- a/stoc/source/invocation/invocation.cxx
+++ b/stoc/source/invocation/invocation.cxx
@@ -18,7 +18,6 @@
  */
 
 #include <osl/mutex.hxx>
-#include <comphelper/automationinvokedzone.hxx>
 #include <cppuhelper/queryinterface.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/weak.hxx>
@@ -100,7 +99,8 @@ class Invocation_Impl
 public:
     Invocation_Impl( const Any & rAdapted, const Reference<XTypeConverter> &,
                                            const Reference<XIntrospection> &,
-                                           const Reference<XIdlReflection> & );
+                                           const Reference<XIdlReflection> &,
+                                           bool bFromOLE );
 
     // XInterface
     virtual Any         SAL_CALL queryInterface( const Type & aType) override;
@@ -214,6 +214,8 @@ private:
 
 
     Reference<XExactName>               _xENDirect, _xENIntrospection;
+
+    bool                                mbFromOLE;
 };
 
 
@@ -222,11 +224,13 @@ Invocation_Impl::Invocation_Impl
     const Any & rAdapted,
     const Reference<XTypeConverter> & rTC,
     const Reference<XIntrospection> & rI,
-    const Reference<XIdlReflection> & rCR
+    const Reference<XIdlReflection> & rCR,
+    bool bFromOLE
 )
     : xTypeConverter( rTC )
     , xIntrospection( rI )
     , xCoreReflection( rCR )
+    , mbFromOLE( bFromOLE )
 {
     setMaterial( rAdapted );
 }
@@ -250,7 +254,7 @@ Any SAL_CALL Invocation_Impl::queryInterface( const Type & aType )
     {
         // Invocation does not support XExactName, if direct object supports
         // XInvocation, but not XExactName. Except when called from OLE Automation.
-        if (comphelper::Automation::AutomationInvokedZone::isActive() ||
+        if (mbFromOLE ||
             (_xDirect.is() && _xENDirect.is()) ||
             (!_xDirect.is() && _xENIntrospection.is()))
         {
@@ -304,7 +308,7 @@ Any SAL_CALL Invocation_Impl::queryInterface( const Type & aType )
     {
         // Invocation does not support XInvocation2, if direct object supports
         // XInvocation, but not XInvocation2.
-        if ( comphelper::Automation::AutomationInvokedZone::isActive() ||
+        if ( mbFromOLE ||
              ( _xDirect.is() && _xDirect2.is()) ||
              (!_xDirect.is() && _xIntrospectionAccess.is() ) )
         {
@@ -348,7 +352,7 @@ void Invocation_Impl::setMaterial( const Any& rMaterial )
     // First do this outside the guard
     _xDirect.set( rMaterial, UNO_QUERY );
 
-    if( !comphelper::Automation::AutomationInvokedZone::isActive() && _xDirect.is() )
+    if( !mbFromOLE && _xDirect.is() )
     {
         // Consult object directly
         _xElementAccess.set( _xDirect, UNO_QUERY );
@@ -444,7 +448,7 @@ Reference<XIntrospectionAccess> Invocation_Impl::getIntrospection()
 
 sal_Bool Invocation_Impl::hasMethod( const OUString& Name )
 {
-    if (!comphelper::Automation::AutomationInvokedZone::isActive() && _xDirect.is())
+    if (!mbFromOLE && _xDirect.is())
         return _xDirect->hasMethod( Name );
     if( _xIntrospectionAccess.is() )
         return _xIntrospectionAccess->hasMethod( Name, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
@@ -457,7 +461,7 @@ sal_Bool Invocation_Impl::hasProperty( const OUString& Name )
     if (_xDirect.is())
     {
         bool bRet = _xDirect->hasProperty( Name );
-        if (bRet || !comphelper::Automation::AutomationInvokedZone::isActive())
+        if (bRet || !mbFromOLE)
             return bRet;
     }
     // PropertySet
@@ -480,7 +484,7 @@ Any Invocation_Impl::getValue( const OUString& PropertyName )
     }
     catch (Exception &)
     {
-        if (!comphelper::Automation::AutomationInvokedZone::isActive())
+        if (!mbFromOLE)
             throw;
     }
     try
@@ -524,7 +528,7 @@ void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
     }
     catch (Exception &)
     {
-        if (!comphelper::Automation::AutomationInvokedZone::isActive())
+        if (!mbFromOLE)
             throw;
     }
     try
@@ -598,7 +602,7 @@ void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
 Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& InParams,
                                 Sequence<sal_Int16>& OutIndices, Sequence<Any>& OutParams )
 {
-    if (!comphelper::Automation::AutomationInvokedZone::isActive() && _xDirect.is())
+    if (!mbFromOLE && _xDirect.is())
         return _xDirect->invoke( FunctionName, InParams, OutIndices, OutParams );
 
     if (_xIntrospectionAccess.is())
@@ -1107,11 +1111,22 @@ Reference<XInterface> InvocationService::createInstance()
 Reference<XInterface> InvocationService::createInstanceWithArguments(
     const Sequence<Any>& rArguments )
 {
+    if (rArguments.getLength() == 2)
+    {
+        OUString aArg1;
+        if ((rArguments[1] >>= aArg1) &&
+            aArg1 == "FromOLE")
+        {
+            return Reference< XInterface >
+                ( *new Invocation_Impl( *rArguments.getConstArray(),
+                                        xTypeConverter, xIntrospection, xCoreReflection, true ) );
+        }
+    }
     if (rArguments.getLength() == 1)
     {
         return Reference< XInterface >
             ( *new Invocation_Impl( *rArguments.getConstArray(),
-                                    xTypeConverter, xIntrospection, xCoreReflection ) );
+                                    xTypeConverter, xIntrospection, xCoreReflection, false ) );
     }
 
     //TODO:throw( Exception("no default construction of invocation adapter possible!", *this) );


More information about the Libreoffice-commits mailing list