Bug 79217 - IDE: Writer will not support running a Macro from the IDE
Summary: IDE: Writer will not support running a Macro from the IDE
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.2.3.3 release
Hardware: Other All
: medium major
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-25 17:10 UTC by Ewald Anderl
Modified: 2014-11-05 12:24 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Writer file with the simple test case to reproduce the problem described (64.34 KB, application/vnd.oasis.opendocument.text)
2014-05-25 17:10 UTC, Ewald Anderl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ewald Anderl 2014-05-25 17:10:06 UTC
Created attachment 99783 [details]
Writer file with the simple test case to reproduce the problem described

Problem description:
====================
Writer will not support running a Macro from the IDE (or debugging) if the Macro references a dialog. Any calls to event handlers that reference the dialog object cause a run time error.

How to reproduce the problem:
=============================
1. Open the uploaded file “LibreOffice-simple-dialog-test-20140525a.odt”
2. Select Tools --> Macros --> Organize Macros --> LibreOffice Basic ...
3. Select Library TestDialogs, Module TestCase1, Function  RunDlg1
4. Run 'RunDlg1'
5. Push the Start button in the dialog (this fails with a run-time error)
6. Click OK to the run time error and click OK to exit the dialog
7. Select Tools --> Macros --> Run Macros ...
8. Run TestDialogs/TestCase1/RunDlg1 (this works as correctly and puts text in the text box)

Current behavior:
=================
-- This causes a run time error, “Basic Run Time Error! Object Variable Not set”.
-- Any breakpoints (e.g. at beginning of TestDlg1Start) are ignored.
-- The same behavior is observed in both Linux (fc20) and Windows (Win7/64, XP/32) and LibreOffice version 4.2.4.2 and 4.2.3.3)
-- If however the same macro is run using the macro selector, the dialog runs correctly.
-- I have confirmed that the problem is not present in Calc, Impress, Draw, and when the TestDialogs library is imported into [My Macros & Dialogs]. This was verified by exporting the  “TestDialogs” library, and then importing it into a new document (for example Calc), then editing the newly imported library and running  TestDialogs/TestCase1/RunDlg1 in the IDE directly. Breakpoints also worked correctly. Importing into a new Writer document did not work.

Expected behavior:
==================
-- Macro should run with dialog Start button putting text into the text box and the Clear button clearing text from the text box.
-- It should be possible to set breakpoints in the event handlers.

Based on further investigation, it appears as if running the function directly from the IDE (for Writer) creates a separate context when the dialog is running. Creating the dialog with CreateUnoDialog() will create an object in the global variable, but that variable will not be available during the event handlers. Therefor all dialog operations will fail because there is not a valid dialog object available and initialized for their use when referencing the dialog object in a helper function. Further, all global and static variables are separate and can be set and changed independently of one another. Increment a global variable in the event handlers and that change will not be seen once the dialog exits.
            
Operating System: All
Version: 4.2.3.3 release
Comment 1 raal 2014-07-30 12:57:00 UTC
I'm unable to reproduce problem with Version: 4.4.0.0.alpha0+
Build ID: 7d06a0601ddccc50185ea97fddcdf2ea39299096
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:master, Time: 2014-07-28_06:17:50

Please, could you test it with newer version?
Comment 2 Buovjaga 2014-11-05 12:24:38 UTC
Works fine on Windows, too.

Win 7 64-bit 4.3.3.2 and Version: 4.4.0.0.alpha1+
Build ID: b7d8a58ff2698ffc6e22943f64aa97c5ea253bd9
TinderBox: Win-x86@42, Branch:master, Time: 2014-11-05_00:40:38