Apache OpenOffice (AOO) Bugzilla – Issue 42240
creating dialogs not working first time
Last modified: 2017-05-20 11:31:27 UTC
I use both OOo 1.1.2 and 1.1.3, this occurs on both versions. The first time you create A dialog (in a macro), it gives an "Action not supported. Invalid procedure call.". If you run the macro again, it works fine, until you shutdown and restart open office. There are two ways I have tried it: oDlg = CreateUnoDialog(DialogLibraries.Standard.CriteriaDialog) -- and -- oLib = DialogLibraries.getByName("Standard") dlgDef = oLib.getByName("CriteriaDialog") oDlg = CreateUnoDialog(dlgDef) I did some investigation and found that oLib.getByName() returns Null. This only happens on the first run, if you run it again it works fine.
np->tbe Have you seen this behaviour before?
TBE->GRVAL: I cannot reproduce this task on OOo 1.1.3. Can you please provide a bug doc with the whole macro in order to reproduce this task. In what way do you run the macro? From the Macro dialog or via an event binding? Nevertheless I assume that you don't load the corresponding dialog library. Please see the macro below, this should work. Sub Main() Dim oLibContainer As Object Dim oLib As Object Dim oInputStreamProvider As Object Dim oDialog As Object Const sLibName = "Standard" Const sDialogName = "Dialog1" REM get library and input stream provider oLibContainer = DialogLibraries oLibContainer.loadLibrary( sLibName ) oLib = oLibContainer.getByName( sLibName ) oInputStreamProvider = oLib.getByName( sDialogName ) REM create dialog control oDialog = CreateUnoDialog( oInputStreamProvider ) REM show the dialog oDialog.execute() End Sub
Ok, that code works, but it creates a new problem. I can't access the controls on the dialog. I discovered that my code works if it isn't called from an event. However, if I call it from an event, I get a null dialog container. REM getCriteria REM REM get criteria for report from user REM prefill with values from current report if present REM Sub getCriteria() ' declare objects to reference our date controls from our dialog box Dim asOfDateControl as object dim oLib as object dim dlgDef as object oLib = DialogLibraries.getByName("Standard") dlgDef = oLib.getByName("CriteriaDialog") if IsNull(dlgDef) then msgbox "Dialog not defined." end if oDlg = CreateUnoDialog(dlgDef) asOfDateControl = oDlg.getControl("asOfDate") asOfDateControl.setDate(CDateToISO(now())) ' set From Date control oDlg.execute() ' show dialog box End Sub So I get "Dialog not defined." when calling from a button. The macro and the dialog are both in the documents standard library, so they should be loaded.
TBE->GRVAL: You're right. Only the Standard MODULE library (application + document Basic) is loaded by default. The Standard DIALOG library is NOT loaded by default. Therefore you need the loadLibrary call in your macros in order to work. I will forward this task to AB for further evaluation. Probably it makes sense to load also the Standard dialog library by default.
Created attachment 22575 [details] i42240.sxw (contains two buttons with an event binding to Standard-Module1-Main)
TBE->AB: Please evaluate.
Ah yes, loading the standard dialog library works.
set to NEW, oooqa can do nothing about this
Accepted as OOo 2.01 enhancement, not as defect as it's not specified that the Standard dialog library has to be preloaded. But it would make sense to preload the Standard dialog library because the Basic IDE does it and so forgetting to load the library in the Basic code is not easy to detect.
Per agreement with MBA and AB i set this task to OOo Later.
Reset assigne to the default "issues@openoffice.apache.org".