[Libreoffice-commits] core.git: 9 commits - extensions/CustomTarget_automationtest.mk extensions/Module_extensions.mk extensions/qa extensions/source oovbaapi/ooo sc/source stoc/Library_invocation.mk stoc/source vbahelper/source

Tor Lillqvist tml at collabora.com
Thu May 31 13:39:03 UTC 2018


 extensions/CustomTarget_automationtest.mk        |   24 ++++
 extensions/Module_extensions.mk                  |    4 
 extensions/qa/ole/automationtest.vbs             |  127 +++++++++++++++++++++++
 extensions/source/ole/servprov.cxx               |    3 
 extensions/source/ole/unoconversionutilities.hxx |    3 
 extensions/source/ole/unoobjw.cxx                |    2 
 oovbaapi/ooo/vba/excel/XApplicationOutgoing.idl  |    1 
 oovbaapi/ooo/vba/excel/XWorkbook.idl             |   11 -
 sc/source/ui/docshell/docsh.cxx                  |   32 +++++
 sc/source/ui/inc/docsh.hxx                       |    6 -
 sc/source/ui/vba/vbaworkbook.cxx                 |   21 +++
 sc/source/ui/vba/vbaworkbook.hxx                 |    2 
 stoc/Library_invocation.mk                       |    1 
 stoc/source/invocation/invocation.cxx            |   43 ++-----
 vbahelper/source/vbahelper/vbahelper.cxx         |    9 +
 15 files changed, 246 insertions(+), 43 deletions(-)

New commits:
commit 7d275e3ab35b3f9bfd7ff16290393ca027c50355
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed May 2 14:57:48 2018 +0300

    Implement NewWorkbook and WorkbookOpen Automation callbacks in Calc
    
    Change-Id: I1ff31d692100695a706bf128c18c4e3ae8b55ce3

diff --git a/oovbaapi/ooo/vba/excel/XApplicationOutgoing.idl b/oovbaapi/ooo/vba/excel/XApplicationOutgoing.idl
index 9e601c5331d6..6ca5b4581d75 100644
--- a/oovbaapi/ooo/vba/excel/XApplicationOutgoing.idl
+++ b/oovbaapi/ooo/vba/excel/XApplicationOutgoing.idl
@@ -25,6 +25,7 @@ module ooo {  module vba {  module excel {
 
 interface XApplicationOutgoing : XInterfaceWithIID
 {
+    void NewWorkbook([in] any Wb);
     void WorkbookOpen([in] any Wb);
     void WorkbookBeforeClose([in] any Wb, [out] any Cancel);
 };
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index d2ae9a945c18..362ddbd0a6e7 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1080,6 +1080,33 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
                 pClipDoc->ClosingClipboardSource();
         }
     }
+
+    if ( const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
+    {
+        switch( pSfxEventHint->GetEventId() )
+        {
+           case SfxEventHintId::CreateDoc:
+                {
+                    uno::Any aWorkbook;
+                    aWorkbook <<= mxAutomationWorkbookObject;
+                    uno::Sequence< uno::Any > aArgs(1);
+                    aArgs[0] = aWorkbook;
+                    SC_MOD()->CallAutomationApplicationEventSinks( "NewWorkbook", aArgs );
+                }
+                break;
+            case SfxEventHintId::OpenDoc:
+                {
+                    uno::Any aWorkbook;
+                    aWorkbook <<= mxAutomationWorkbookObject;
+                    uno::Sequence< uno::Any > aArgs(1);
+                    aArgs[0] = aWorkbook;
+                    SC_MOD()->CallAutomationApplicationEventSinks( "WorkbookOpen", aArgs );
+                }
+                break;
+            default:
+                break;
+        }
+    }
 }
 
 // Load contents for organizer
@@ -3340,6 +3367,11 @@ void ScDocShell::SetIsInUcalc()
     mbUcalcTest = true;
 }
 
+void ScDocShell::RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const& xWorkbook)
+{
+    mxAutomationWorkbookObject = xWorkbook;
+}
+
 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportSLK(SvStream &rStream)
 {
     ScDLL::Init();
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 29fe6de0873d..55cbdb91e652 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -20,8 +20,8 @@
 #ifndef INCLUDED_SC_SOURCE_UI_INC_DOCSH_HXX
 #define INCLUDED_SC_SOURCE_UI_INC_DOCSH_HXX
 
+#include <ooo/vba/excel/XWorkbook.hpp>
 #include <sfx2/objsh.hxx>
-
 #include <sfx2/docfac.hxx>
 #include <sfx2/sfxmodelfactory.hxx>
 #include <sfx2/viewsh.hxx>
@@ -114,6 +114,8 @@ class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, public SfxListener
 
     ScDocShellModificator* pModificator; // #109979#; is used to load XML (created in BeforeXMLLoading and destroyed in AfterXMLLoading)
 
+    css::uno::Reference< ooo::vba::excel::XWorkbook> mxAutomationWorkbookObject;
+
     // Only used by Vba helper functions
     css::uno::Reference<css::script::vba::XVBAScriptListener>   m_xVBAListener;
     css::uno::Reference<css::datatransfer::XTransferable2>      m_xClipData;
@@ -427,6 +429,8 @@ public:
     void SnapVisArea( tools::Rectangle& rRect ) const;
 
     void SetIsInUcalc();
+
+    void RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const& xWorkbook);
 };
 
 void UpdateAcceptChangesDialog();
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index 96ee2bf64a99..93f773838195 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -201,6 +201,9 @@ ScVbaWorkbook::init()
 {
     if ( !ColorData.getLength() )
         ResetColors();
+    uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY );
+    if ( xModel.is() )
+        excel::getDocShell( xModel )->RegisterAutomationWorkbookObject( this );
 }
 
 ScVbaWorkbook::ScVbaWorkbook(   const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::frame::XModel > const & xModel ) : ScVbaWorkbook_BASE( xParent, xContext, xModel )
commit ad57e6d3369b10c181cb644729466512428cc52d
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed May 2 14:48:22 2018 +0300

    Add a SAL_INFO
    
    Change-Id: Ic197a9573968fb252cb52cc5089f9140d5375d3a

diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx
index fb86cee88821..a9c579e1fc23 100644
--- a/extensions/source/ole/unoobjw.cxx
+++ b/extensions/source/ole/unoobjw.cxx
@@ -2272,6 +2272,8 @@ Sink::Call( const OUString& Method, Sequence< Any >& Arguments )
             // have done "compile-time binding" and where the sink would actually be an object with
             // a vtbl corresponding to the outgoing interface. Late binding clients that work like
             // VBScript is all we support.
+            SAL_INFO("extensions.olebridge", "Sink::Call(" << Method << "): Calling Invoke(" << nMemId << ")");
+
             nResult = pDispatch->Invoke(nMemId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &aDispParams, &aVarResult, NULL, &uArgErr);
             SAL_WARN_IF(!SUCCEEDED(nResult), "extensions.olebridge", "Call to " << Method << " failed: " << WindowsErrorStringFromHRESULT(nResult));
 
commit f9365c47c2e77bb939ef712ee9cc8ba46f7d1931
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Apr 25 22:02:06 2018 +0300

    Add a unit test for the Automation client services
    
    Written in VBScript, yay.
    
    Change-Id: Ibbdba804939c2646aef8f8a2bb3781eaf1a6d208

diff --git a/extensions/CustomTarget_automationtest.mk b/extensions/CustomTarget_automationtest.mk
new file mode 100644
index 000000000000..b1984d98d153
--- /dev/null
+++ b/extensions/CustomTarget_automationtest.mk
@@ -0,0 +1,24 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CustomTarget_CustomTarget,extensions/automationtest))
+
+extensions_AUTOMATIONTESTDIR := $(call gb_CustomTarget_get_workdir,extensions/automationtest)
+
+extensions_AUTOMATIONTESTLOG := $(extensions_AUTOMATIONTESTDIR)/automationtest.log
+
+$(call gb_CustomTarget_get_target,extensions/automationtest) : \
+		$(SRCDIR)/extensions/qa/ole/automationtest.vbs \
+		| $(extensions_AUTOMATIONTESTDIR)/.dir
+	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),VBS,1) \
+	$(call gb_Helper_abbreviate_dirs, \
+	cscript -nologo $(SRCDIR)/extensions/qa/ole/automationtest.vbs $(SRCDIR)) >$(extensions_AUTOMATIONTESTLOG) || \
+            (cat $(extensions_AUTOMATIONTESTLOG) && exit 1)
+
+# vim:set shiftwidth=4 tabstop=4 noexpandtab:
diff --git a/extensions/Module_extensions.mk b/extensions/Module_extensions.mk
index 31512ff4045f..0e8dadafea47 100644
--- a/extensions/Module_extensions.mk
+++ b/extensions/Module_extensions.mk
@@ -74,6 +74,10 @@ $(eval $(call gb_Module_add_targets,extensions,\
 	Library_oleautobridge \
 ))
 
+$(eval $(call gb_Module_add_subsequentcheck_targets,extensions,\
+	CustomTarget_automationtest \
+))
+
 endif # WNT
 
 ifeq ($(OS),MACOSX)
diff --git a/extensions/qa/ole/automationtest.vbs b/extensions/qa/ole/automationtest.vbs
new file mode 100644
index 000000000000..efd4b8a60eda
--- /dev/null
+++ b/extensions/qa/ole/automationtest.vbs
@@ -0,0 +1,127 @@
+' -*- tab-width: 4; indent-tabs-mode: nil -*-
+
+If WScript.Arguments.Count <> 1 Then
+   WScript.Echo "Pass $(SRCDIR) as parameter"
+   WScript.Quit(1)
+End If
+
+srcdir = WScript.Arguments.Item(0)
+
+exitStatus = 0
+
+testCounter = 0
+okCounter = 0
+
+Sub ExitWithReport
+    If okCounter <> testCounter Then
+        exitStatus = 1
+    End If
+    WScript.Echo "OK (" + CStr(okCounter) + ")"
+    WScript.Quit(exitstatus)
+End Sub
+
+Sub CheckFatal(expr)
+    testCounter = testCounter + 1
+    If Not Eval(expr) Then
+        WScript.Echo "FAIL: " & expr
+        ExitWithReport
+    Else
+        WScript.Echo "PASS: " & expr
+        okCounter = okCounter + 1
+    End If
+End Sub
+
+Sub Check(expr)
+    testCounter = testCounter + 1
+    If Not Eval(expr) Then
+        WScript.Echo "FAIL: " & expr
+    Else
+        WScript.Echo "PASS: " & expr
+        okCounter = okCounter + 1
+    End If
+End Sub
+
+Sub CheckIfExpected(expr, expected)
+    testCounter = testCounter + 1
+    actual = Eval(expr)
+    If actual <> expected Then
+        WScript.Echo "FAIL: Value of '" & expr & "' was expected to be '" & CStr(expected) & "', but was " & CStr(actual)
+    Else
+        WScript.Echo "PASS: " & expr & " == " & CStr(expected)
+        okCounter = okCounter + 1
+    End If
+End Sub
+
+Sub CheckErrorFatal(test)
+    testCounter = testCounter + 1
+    Execute(test)
+    If Err.Number <> 0 Then
+        WScript.Echo "FAIL: " & test
+        WScript.Echo "ERROR: " & Err.Description
+        ExitWithReport
+    Else
+        WScript.Echo "PASS: " & test
+        okCounter = okCounter + 1
+    End If
+End Sub
+
+Sub CheckError(test)
+    testCounter = testCounter + 1
+    Execute(test)
+    If Err.Number <> 0 Then
+        WScript.Echo "FAIL: " & test
+        WScript.Echo "ERROR: " & Err.Description
+    Else
+        WScript.Echo "PASS: " & test
+        okCounter = okCounter + 1
+    End If
+End Sub
+
+WScript.Echo "Running Automation client tests"
+
+On Error Resume Next
+
+CheckErrorFatal "Set writer = WScript.CreateObject(""Writer.Application"")"
+CheckErrorFatal "writer.Visible = True"
+CheckErrorFatal "writer.Caption = ""=== This is Writer ==="""
+CheckErrorFatal "writer.ShowMe"
+
+CheckErrorFatal "Set documents = writer.Documents"
+
+' Open two randomly chosen documents
+CheckErrorFatal "Set d1 = documents.Open(""" & srcdir & "/sw/qa/extras/ww8export/data/n325936.doc"")"
+CheckErrorFatal "Set d2 = documents.Open(""" & srcdir & "/sw/qa/extras/ww8export/data/bnc636128.doc"")"
+
+CheckErrorFatal "n1 = d1.FullName"
+CheckErrorFatal "n2 = d2.FullName"
+
+CheckIfExpected "n1", "n325936.doc"
+CheckIfExpected "n2", "bnc636128.doc"
+
+CheckErrorFatal "Set c1 = d1.Content"
+CheckErrorFatal "Set c2 = d2.Content"
+
+' The range of characters in these documents
+CheckIfExpected "c1.Start", 0
+CheckIfExpected "c1.End", 4
+CheckIfExpected "c2.Start", 0
+CheckIfExpected "c2.End", 42
+
+' Check number of paragraphs in each document
+CheckErrorFatal "Set p1 = d1.Paragraphs"
+nparas = 0
+For Each i in p1
+    nparas = nparas + 1
+Next
+CheckIfExpected "nparas", 1
+
+CheckErrorFatal "Set p2 = d2.Paragraphs"
+nparas = 0
+For Each i in p2
+    nparas = nparas + 1
+Next
+CheckIfExpected "nparas", 1
+
+CheckErrorFatal "writer.Quit"
+
+ExitWithReport
commit 0cae8eeaae08c9dc4ace44ee026af6f2b335c9c6
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Apr 25 19:29:53 2018 +0300

    Must catch Exception here, not the more specific UnknownPropertyException
    
    Change-Id: I4b0b119af356f38f359f2ba5afa6081533790443

diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx
index 619c6f8942b7..3001993db4e9 100644
--- a/stoc/source/invocation/invocation.cxx
+++ b/stoc/source/invocation/invocation.cxx
@@ -478,7 +478,7 @@ Any Invocation_Impl::getValue( const OUString& PropertyName )
         if (_xDirect.is())
             return _xDirect->getValue( PropertyName );
     }
-    catch (UnknownPropertyException &)
+    catch (Exception &)
     {
         if (!comphelper::Automation::AutomationInvokedZone::isActive())
             throw;
@@ -522,7 +522,7 @@ void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
             return;
         }
     }
-    catch (UnknownPropertyException &)
+    catch (Exception &)
     {
         if (!comphelper::Automation::AutomationInvokedZone::isActive())
             throw;
commit 3c041720304ec77202741b5d5c8df9b93bc70a70
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Apr 25 19:08:42 2018 +0300

    Simplify: Use AutomationInvokedZone::isActive()
    
    Don't need the mbFromOLE boolean flag and the special "FromOLE"
    parameter passed to the InvocationService::
    createInstanceWithArguments().
    
    Change-Id: I05e10a78955d87cb7c37e198c60c3ddcfdbc4275

diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx
index f0ef703bd845..cbec71299953 100644
--- a/extensions/source/ole/unoconversionutilities.hxx
+++ b/extensions/source/ole/unoconversionutilities.hxx
@@ -1395,9 +1395,8 @@ void UnoConversionUtilities<T>::createUnoObjectWrapper(const Any & rObj, VARIANT
     Reference<XSingleServiceFactory> xInvFactory= getInvocationFactory(rObj);
     if (xInvFactory.is())
     {
-        Sequence<Any> params(2);
+        Sequence<Any> params(1);
         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 42f17556433c..dc22a2acb51b 100644
--- a/stoc/Library_invocation.mk
+++ b/stoc/Library_invocation.mk
@@ -16,6 +16,7 @@ $(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 5ffbb9cf586e..619c6f8942b7 100644
--- a/stoc/source/invocation/invocation.cxx
+++ b/stoc/source/invocation/invocation.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <osl/mutex.hxx>
+#include <comphelper/automationinvokedzone.hxx>
 #include <cppuhelper/queryinterface.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/weak.hxx>
@@ -99,8 +100,7 @@ class Invocation_Impl
 public:
     Invocation_Impl( const Any & rAdapted, const Reference<XTypeConverter> &,
                                            const Reference<XIntrospection> &,
-                                           const Reference<XIdlReflection> &,
-                                           bool bFromOLE );
+                                           const Reference<XIdlReflection> & );
 
     // XInterface
     virtual Any         SAL_CALL queryInterface( const Type & aType) override;
@@ -214,8 +214,6 @@ private:
 
 
     Reference<XExactName>               _xENDirect, _xENIntrospection;
-
-    bool                                mbFromOLE;
 };
 
 
@@ -224,13 +222,11 @@ Invocation_Impl::Invocation_Impl
     const Any & rAdapted,
     const Reference<XTypeConverter> & rTC,
     const Reference<XIntrospection> & rI,
-    const Reference<XIdlReflection> & rCR,
-    bool bFromOLE
+    const Reference<XIdlReflection> & rCR
 )
     : xTypeConverter( rTC )
     , xIntrospection( rI )
     , xCoreReflection( rCR )
-    , mbFromOLE( bFromOLE )
 {
     setMaterial( rAdapted );
 }
@@ -254,7 +250,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 (mbFromOLE ||
+        if (comphelper::Automation::AutomationInvokedZone::isActive() ||
             (_xDirect.is() && _xENDirect.is()) ||
             (!_xDirect.is() && _xENIntrospection.is()))
         {
@@ -308,7 +304,7 @@ Any SAL_CALL Invocation_Impl::queryInterface( const Type & aType )
     {
         // Invocation does not support XInvocation2, if direct object supports
         // XInvocation, but not XInvocation2.
-        if ( mbFromOLE ||
+        if ( comphelper::Automation::AutomationInvokedZone::isActive() ||
              ( _xDirect.is() && _xDirect2.is()) ||
              (!_xDirect.is() && _xIntrospectionAccess.is() ) )
         {
@@ -352,7 +348,7 @@ void Invocation_Impl::setMaterial( const Any& rMaterial )
     // First do this outside the guard
     _xDirect.set( rMaterial, UNO_QUERY );
 
-    if( !mbFromOLE && _xDirect.is() )
+    if( !comphelper::Automation::AutomationInvokedZone::isActive() && _xDirect.is() )
     {
         // Consult object directly
         _xElementAccess.set( _xDirect, UNO_QUERY );
@@ -448,7 +444,7 @@ Reference<XIntrospectionAccess> Invocation_Impl::getIntrospection()
 
 sal_Bool Invocation_Impl::hasMethod( const OUString& Name )
 {
-    if (!mbFromOLE && _xDirect.is())
+    if (!comphelper::Automation::AutomationInvokedZone::isActive() && _xDirect.is())
         return _xDirect->hasMethod( Name );
     if( _xIntrospectionAccess.is() )
         return _xIntrospectionAccess->hasMethod( Name, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
@@ -461,7 +457,7 @@ sal_Bool Invocation_Impl::hasProperty( const OUString& Name )
     if (_xDirect.is())
     {
         bool bRet = _xDirect->hasProperty( Name );
-        if (bRet || !mbFromOLE)
+        if (bRet || !comphelper::Automation::AutomationInvokedZone::isActive())
             return bRet;
     }
     // PropertySet
@@ -484,7 +480,7 @@ Any Invocation_Impl::getValue( const OUString& PropertyName )
     }
     catch (UnknownPropertyException &)
     {
-        if (!mbFromOLE)
+        if (!comphelper::Automation::AutomationInvokedZone::isActive())
             throw;
     }
     try
@@ -528,7 +524,7 @@ void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
     }
     catch (UnknownPropertyException &)
     {
-        if (!mbFromOLE)
+        if (!comphelper::Automation::AutomationInvokedZone::isActive())
             throw;
     }
     try
@@ -602,7 +598,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 (!mbFromOLE && _xDirect.is())
+    if (!comphelper::Automation::AutomationInvokedZone::isActive() && _xDirect.is())
         return _xDirect->invoke( FunctionName, InParams, OutIndices, OutParams );
 
     if (_xIntrospectionAccess.is())
@@ -1111,22 +1107,11 @@ 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, false ) );
+                                    xTypeConverter, xIntrospection, xCoreReflection ) );
     }
 
     //TODO:throw( Exception("no default construction of invocation adapter possible!", *this) );
commit bfedeb79937aa5e8bdf01ecf6be25e2bbe8a6db5
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Apr 25 19:07:12 2018 +0300

    Need to enter the AutomationInvokedZone here, too
    
    Change-Id: I2723146f2c549c630dfa0e5da330af228cb305a0

diff --git a/extensions/source/ole/servprov.cxx b/extensions/source/ole/servprov.cxx
index 45e693b20982..de929c621778 100644
--- a/extensions/source/ole/servprov.cxx
+++ b/extensions/source/ole/servprov.cxx
@@ -29,6 +29,7 @@
 #include "oleobjw.hxx"
 
 #include <com/sun/star/script/CannotConvertException.hpp>
+#include <comphelper/automationinvokedzone.hxx>
 #include <comphelper/windowsdebugoutput.hxx>
 #include <cppuhelper/queryinterface.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -139,6 +140,8 @@ STDMETHODIMP OneInstanceOleWrapper::CreateInstance(IUnknown FAR* punkOuter,
                                                    REFIID riid,
                                                    void FAR* FAR* ppv)
 {
+    comphelper::Automation::AutomationInvokedZone aAutomationActive;
+
     SAL_INFO("extensions.olebridge", "OneInstanceOleWrapper::CreateInstance(" << riid << ")");
 
     HRESULT ret = ResultFromScode(E_UNEXPECTED);
commit 034e8bfafadf3dfe930447696b7a686345aa6632
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Apr 25 17:04:49 2018 +0300

    Add Author property to ooo::vba::excel::XWorkbook and implement it
    
    Corresponds to the Author attribute of
    css::document::XDocumentProperties. I.e. the initial creator of the
    document.
    
    Change-Id: I07d3ce9dfb87900948d2bb7af14109b17546fb4c

diff --git a/oovbaapi/ooo/vba/excel/XWorkbook.idl b/oovbaapi/ooo/vba/excel/XWorkbook.idl
index 2c9b5871fdb6..fe310e2adc1a 100644
--- a/oovbaapi/ooo/vba/excel/XWorkbook.idl
+++ b/oovbaapi/ooo/vba/excel/XWorkbook.idl
@@ -32,6 +32,7 @@ interface XWorkbook
     [attribute, readonly] string  CodeName;
     [attribute, readonly] long FileFormat;
     [attribute] boolean  PrecisionAsDisplayed;
+    [attribute] string Author;
 
     any  Worksheets( [in] any Index );
     any  Styles( [in] any Index ) raises (com::sun::star::script::BasicErrorException);
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index de08c8b59114..96ee2bf64a99 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -292,6 +292,24 @@ void SAL_CALL ScVbaWorkbook::setPrecisionAsDisplayed( sal_Bool _precisionAsDispl
     rDoc.SetDocOptions( aOpt );
 }
 
+OUString SAL_CALL ScVbaWorkbook::getAuthor()
+{
+    uno::Reference<document::XDocumentPropertiesSupplier> xDPS( getModel(), uno::UNO_QUERY );
+    if (!xDPS.is())
+        return OUString("?");
+    uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
+    return xDocProps->getAuthor();
+}
+
+void SAL_CALL ScVbaWorkbook::setAuthor( const OUString& _author )
+{
+    uno::Reference<document::XDocumentPropertiesSupplier> xDPS( getModel(), uno::UNO_QUERY );
+    if (!xDPS.is())
+        return;
+    uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
+    xDocProps->setAuthor( _author );
+}
+
 void
 ScVbaWorkbook::SaveCopyAs( const OUString& sFileName )
 {
diff --git a/sc/source/ui/vba/vbaworkbook.hxx b/sc/source/ui/vba/vbaworkbook.hxx
index 25c4b188017c..6efaa938cfa8 100644
--- a/sc/source/ui/vba/vbaworkbook.hxx
+++ b/sc/source/ui/vba/vbaworkbook.hxx
@@ -44,6 +44,8 @@ public:
     virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() override;
     virtual sal_Bool SAL_CALL getPrecisionAsDisplayed() override;
     virtual void SAL_CALL setPrecisionAsDisplayed( sal_Bool _precisionAsDisplayed ) override;
+    virtual OUString SAL_CALL getAuthor() override;
+    virtual void SAL_CALL setAuthor( const OUString& _author ) override;
 
     // Methods
     virtual css::uno::Any SAL_CALL Worksheets( const css::uno::Any& aIndex ) override;
commit b11329eed924483a24f2c05d97c573b9a95b26e8
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Apr 25 17:03:50 2018 +0300

    Can simplify, our IDL compiler is more clever nowadays
    
    Change-Id: Ie62c47a0b60df5b7a7237cce981e850cbbe5aee9

diff --git a/oovbaapi/ooo/vba/excel/XWorkbook.idl b/oovbaapi/ooo/vba/excel/XWorkbook.idl
index 9efbf6ce354c..2c9b5871fdb6 100644
--- a/oovbaapi/ooo/vba/excel/XWorkbook.idl
+++ b/oovbaapi/ooo/vba/excel/XWorkbook.idl
@@ -20,21 +20,11 @@
 #define __ooo_vba_excel_XWorkbook_idl__
 
 #include <com/sun/star/lang/XUnoTunnel.idl>
-#include <ooo/vba/XHelperInterface.idl>
-
-
 
 module ooo {  module vba {  module excel {
 
-
-
-interface XWorksheet;
-interface XWorksheets;
-interface XStyles;
-
 interface XWorkbook
 {
-
     interface ::com::sun::star::lang::XUnoTunnel;
 
     [attribute, readonly] boolean ProtectStructure;
commit 1b55ed02a4c5b7f6d1ff39220af6e7624995f9d3
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Apr 25 16:44:01 2018 +0300

    Avoid a SolarMutex assertion failure in some use cases from Automation
    
    For instance when opening a Calc Document through ooo::vba::excel::
    XWorkbooks::Open(). Instead just let the function return null. It does
    seem that callers are prepared for that.
    
    Change-Id: I7136133155f95a696b5ed3e661a9adb98396c9c5

diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index c34559b769f6..187e88d5713b 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column:100 -*- */
 /*
  * This file is part of the LibreOffice project.
  *
@@ -39,6 +39,7 @@
 
 #include <ooo/vba/msforms/XShape.hpp>
 
+#include <comphelper/automationinvokedzone.hxx>
 #include <comphelper/processfactory.hxx>
 
 #include <sfx2/objsh.hxx>
@@ -1122,6 +1123,12 @@ uno::Reference< XHelperInterface > getUnoDocModule( const OUString& aModName, Sf
     if ( pShell )
     {
         OUString sProj( "Standard" );
+        // GetBasicManager() causes a SolarMutex assertion failure in some use cases from
+        // Automation, at least when opening a Calc Document through ooo::vba::excel::
+        // XWorkbooks::Open(). Let's see if this check is a good way around that. It does seem that
+        // callers are prepared for this to return null?
+        if (comphelper::Automation::AutomationInvokedZone::isActive())
+            return xIf;
         BasicManager* pBasMgr = pShell->GetBasicManager();
         if ( pBasMgr && !pBasMgr->GetName().isEmpty() )
             sProj = pBasMgr->GetName();


More information about the Libreoffice-commits mailing list