Bug 67547 - Can't access methods of ScriptProvider from VB
Summary: Can't access methods of ScriptProvider from VB
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version: 3.5.0 Beta0
Hardware: Other Windows (All)
: medium normal
Assignee: Noel Power
QA Contact:
URL:
Whiteboard: target:4.2.0 target:4.1.1 target:4.0.6
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-30 16:12 UTC by Noel Power
Modified: 2013-11-13 15:26 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Excel file containing VBA code to launch libreoffice and attempt to run a macro in another document ( expected to be located at C: ) - will attach also (29.50 KB, application/vnd.ms-excel)
2013-07-30 16:12 UTC, Noel Power
Details
corrosponding data file for the previous document (19.00 KB, application/vnd.ms-excel)
2013-07-30 16:13 UTC, Noel Power
Details
A simpler example, shows the root cause but doesn't test the affected (e.g. olebridge )functionality (8.37 KB, application/vnd.oasis.opendocument.spreadsheet)
2013-07-30 16:27 UTC, Noel Power
Details

Description Noel Power 2013-07-30 16:12:41 UTC
Created attachment 83308 [details]
Excel file containing VBA code to launch libreoffice and attempt to run a macro in another document ( expected to be located at C: ) - will attach also

Can't invoke macros/scripts from VB. All attempts to access the 'getScript' method of the document scriptprovider will fail. I've marked the earliest release as 3.5 ( I'm pretty sure this goes back way further than that, earliest LO I have here is 3.5 )

e.g.

Sub invokeLOMacro()

Dim sURL As String
sURL = "vnd.sun.star.script:VBAProject.Module1.CalledFromImportedXLS?language=Basic&location=document"

Dim loServMgr As Object
Set loServMgr = CreateObject("com.sun.star.ServiceManager")

Dim oDesk As Object
Set oDesk = loServMgr.createInstance("com.sun.star.frame.Desktop")

Dim oDoc As Object
Dim args(1)

Set args(0) = MakePropertyValue("Hidden", False)
Set args(1) = MakePropertyValue("MacroExecutionMode", 4)  ' "4" is com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN

Dim nullArray()
Set oDoc = oDesk.loadComponentFromURL("file:///c:/MacroXLS.xls", "_blank", 0, args()) '

Dim scriptProv As Object
Set scriptProv = oDoc.getScriptProvider()

Dim xScript As Object
Set xScript = scriptProv.getScript(sURL) '<==== will fail here


The net result is it is not possible to invoke libreoffice basic, java, python etc. scripts from VB ( using the scripting framework )
Comment 1 Noel Power 2013-07-30 16:13:22 UTC
Created attachment 83309 [details]
corrosponding data file for the previous document
Comment 2 Noel Power 2013-07-30 16:18:11 UTC
note: the root cause of the problem is in the scripting framework itself where there is a XNameAccess implementation, the XNameAccess implementation is throwing when ole bridge is attempting to figure out if there is a property called "getScript". Apparently ( I had forgotten this ) we treat any named elements in an object ( exposed via XNameAccess ) as properties.
The scripting framework shouldn't throw in this instance ( it thinks the MasterScriptProvider isn't initialised correctly )

Solution is to fix the logic in the MasterScriptProvider implementation
Comment 3 Noel Power 2013-07-30 16:26:23 UTC
well of course this is for me
Comment 4 Noel Power 2013-07-30 16:27:39 UTC
Created attachment 83310 [details]
A simpler example, shows the root cause but doesn't test the affected (e.g. olebridge )functionality
Comment 5 Noel Power 2013-07-30 19:24:08 UTC
also reviews requested for 4.0
https://gerrit.libreoffice.org/#/c/5207/

& 4.1
https://gerrit.libreoffice.org/#/c/5206/
Comment 6 Commit Notification 2013-07-30 19:27:42 UTC
Noel Power committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=92500896a9d0ba873c06a4a2728eb5a1b9d8f68d

fdo#67547 fix access to methods (getScript) of MasterScriptProvider from VB



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2013-07-31 10:01:06 UTC
Noel Power committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=6add3c38a82bbac7e096327277707ba4858bf26a

unit ( slowcheck ) test for fdo#67547



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2013-07-31 15:51:27 UTC
Noel Power committed a patch related to this issue.
It has been pushed to "libreoffice-4-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=6a3c26a46c28ca1bcc26f4cc546b9facafe7030a&h=libreoffice-4-1

fdo#67547 fix access to methods (getScript) of MasterScriptProvider from VB


It will be available in LibreOffice 4.1.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2013-07-31 15:52:31 UTC
Noel Power committed a patch related to this issue.
It has been pushed to "libreoffice-4-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=cba4eda4c9ca1174d7b9f3db821fc3452b4af486&h=libreoffice-4-0

fdo#67547 fix access to methods (getScript) of MasterScriptProvider from VB


It will be available in LibreOffice 4.0.6.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.