Issue 42240 - creating dialogs not working first time
Summary: creating dialogs not working first time
Alias: None
Product: General
Classification: Code
Component: scripting (show other issues)
Version: OOo 1.1.2
Hardware: PC Linux, all
: P3 Trivial (vote)
Target Milestone: AOO Later
Assignee: AOO issues mailing list
QA Contact:
Keywords: oooqa
Depends on:
Reported: 2005-02-07 22:22 UTC by grval
Modified: 2017-05-20 11:31 UTC (History)
2 users (show)

See Also:
Latest Confirmation in: ---
Developer Difficulty: ---

i42240.sxw (contains two buttons with an event binding to Standard-Module1-Main) (10.10 KB, application/vnd.sun.xml.writer)
2005-02-14 09:56 UTC, thomas.benisch
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description grval 2005-02-07 22:22:39 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.
Comment 1 noel.power 2005-02-08 13:55:35 UTC

Have you seen this behaviour before?
Comment 2 thomas.benisch 2005-02-09 10:03:09 UTC
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

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
End Sub

Comment 3 grval 2005-02-11 17:32:08 UTC
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 get criteria for report from user
REM prefill with values from current report if present
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.

Comment 4 thomas.benisch 2005-02-14 09:54:22 UTC
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.
Comment 5 thomas.benisch 2005-02-14 09:56:50 UTC
Created attachment 22575 [details]
i42240.sxw (contains two buttons with an event binding to Standard-Module1-Main)
Comment 6 thomas.benisch 2005-02-14 09:58:14 UTC
TBE->AB: Please evaluate.
Comment 7 grval 2005-02-14 16:19:36 UTC
Ah yes, loading the standard dialog library works.
Comment 8 flibby05 2005-04-03 18:56:33 UTC
set to NEW,
oooqa can do nothing about this
Comment 9 ab 2005-04-05 15:51:18 UTC
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.
Comment 10 joerg.skottke 2005-05-23 14:54:18 UTC
Per agreement with MBA and AB i set this task to OOo Later.
Comment 11 Marcus 2017-05-20 11:31:27 UTC
Reset assigne to the default "".