https://bugs.documentfoundation.org/show_bug.cgi?id=92770

            Bug ID: 92770
           Summary: thisComponent is not valid during "Open Document" at
                    startup in non-document macro
           Product: LibreOffice
           Version: 5.1.0.0.alpha0+ Master
          Hardware: Other
                OS: All
            Status: UNCONFIRMED
          Keywords: regression
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: libreoffice-bugs@lists.freedesktop.org
          Reporter: lio...@mamane.lu

Created attachment 117261
  --> https://bugs.documentfoundation.org/attachment.cgi?id=117261&action=edit
reproduction case

When:

 - LibreOffice is started with instruction to open document foo.odb
   (for example, type in a shell "/path/to/soffice foo.odb")
AND
 - in foo.odb, the "Open Document" event is bound to a macro "OnOpen"
AND
 - the macro "OnOpen" is not saved in foo.odb, but in "My Macros"
   OR calls (without delay, without a MsgBox before, etc)
      a macro "Go" that is saved in "My Macros"
AND
 - OnOpen/Go tries to use thisComponent

THEN

thisComponent is not set to a valid value. E.g., XRay cannot introspect it, it
doesn't have a supportsService method, ...BUT isEmpty(thisComponent) is
*false*.

Just adding a "wait 5000" solves the problem, which hints at a race condition,
or a wrong order of initialisation (if the wait() makes a Yield/DoEvents).

If the macro OnOpen, saved in the .odb file, uses thisComponent directly, then
it works.
If the macro is executed *after* the document is finished opening, then it
works.
If one first starts LibreOffice and *then* opens the file through the UI, then
it works.

Regression with respect to 5.0 (my GNU/Linux dev tree), 4.4 (Windows TDF build)
and 4.3 (Debian package).


Reproduction steps:

Put in "My Macros" the following (beware bugzilla's word wrap):

Sub showThisComponent
    MsgBox "Macro in ""My Macros"": " & _
           
thisComponent.supportsService("com.sun.star.document.OfficeDocument")
End Sub


Set Macro security to medium or lower.


CLOSE LIBREOFFICE


Open the attached odb file by starting libreoffice with as argument
/path/to/odb_file.
Accept macros if prompted.


Actual result: error message

  BASIC runtime error.
  Property or method not found: supportsService.

Expected result (and actual result with previous versions): message box saying:

  Macro in "My Macros": True

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to