Created attachment 99783 [details]
Writer file with the simple test case to reproduce the problem described
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)
-- 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 220.127.116.11 and 18.104.22.168)
-- 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.
-- 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: 22.214.171.124 release
I'm unable to reproduce problem with Version: 126.96.36.199.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?
Works fine on Windows, too.
Win 7 64-bit 188.8.131.52 and Version: 184.108.40.206.alpha1+
Build ID: b7d8a58ff2698ffc6e22943f64aa97c5ea253bd9
TinderBox: Win-x86@42, Branch:master, Time: 2014-11-05_00:40:38