Download it now!
Bug 67547 - Can't access methods of ScriptProvider from VB
Summary: Can't access methods of ScriptProvider from VB
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
3.5.0 Beta0
Hardware: Other Windows (All)
: medium normal
Assignee: Noel Power
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: 2015-06-15 19:20 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


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

Note You need to log in before you can comment on or make changes to this bug.
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.
Comment 10 QA Administrators 2015-04-19 03:21:08 UTC
** Please read this message in its entirety before responding **

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

   *Test to see if the bug is still present on a currently supported version of LibreOffice (4.4.1 or later)
   https://www.libreoffice.org/download/

   *If the bug is present, please leave a comment that includes the version of LibreOffice and your operating system, and any changes you see in the bug behavior
 
   *If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a short comment that includes your version of LibreOffice and Operating System

Please DO NOT

   *Update the version field
   *Reply via email (please reply directly on the bug tracker)
   *Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 

1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3)

http://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug 
3. Leave a comment with your results. 
4a. If the bug was present with 3.3 - set version to "inherited from OOo"; 
4b. If the bug was not present in 3.3 - add "regression" to keyword


Feel free to come ask questions or to say hello in our QA chat: http://webchat.freenode.net/?channels=libreoffice-qa

Thank you for your help!

-- The LibreOffice QA Team This NEW Message was generated on: 2015-04-18
Comment 11 Buovjaga 2015-06-15 19:20:37 UTC
Apparently this should have been marked FIXED.