Page 1 of 1
Macro to store/load a dialogue
Posted: Sat Jan 27, 2018 7:19 pm
by ElFlamencoLoco
Hi folks,
The StarBasic project I'm working on contains some macros to adapt an existing dialogue to a specific situation. The dialogue has been designed in the dialogue editor.
Exporting and importing dialogues is a piece of a cake from within the Basic IDE. But how to achieve the same effect by a macro? How to store a dialogue (in a .xdl file) and later to reload it (from that .xdl file) by a macro?
At this moment the code adapting the dialogue works fine but... a bit slowly. It takes 4-5 seconds before the dialogue pops up. Here some simplified code to illustrate:
Code: Select all
'Creating
oDia = createUnoDialog(DialogLibraries.MyLib.MyDialog)
'Adaption
for n = 1 to 100
oCtrl = oDia.Model.createInstance("com.sun.star.awt.UnoControlFixedTextModel")
'Set position, size, text, textcolor, background color, listeners etc...
...
'Add to dialogue
oDia.Model.insertByName("Ctrl_" + cstr(n), oCtrl)
next n
'Running
action = oDia.Execute
Now what I want to achieve (in pseudocode):
Code: Select all
IF dialogue doesn't (yet) exist THEN
Create dialogue (cfr. supra)
Export dialogue to .xdl file
ELSE
Import dialogue from .xdl file
ENDIF
Run dialogue
Any suggestions? Thanks in advance.
Re: Macro to store/load a dialogue
Posted: Sat Jan 27, 2018 8:07 pm
by RoryOF
Re: Macro to store/load a dialogue
Posted: Sat Jan 27, 2018 10:25 pm
by ElFlamencoLoco
That site contains indeed some very usefull info. But it doesn't mention how to write a macro to save a dialogue as a .xdl file, nor how to load it from a .xdl file.
Other suggestions?
Re: Macro to store/load a dialogue
Posted: Sat Jan 27, 2018 10:48 pm
by RoryOF
Re: Macro to store/load a dialogue
Posted: Sat Jan 27, 2018 11:18 pm
by ElFlamencoLoco
I think I didn't make myself clear enough. Sorry.
The problem is not a filepicker. I don't think I need a filepicker to
export an existing, macrowise generated/adapted dialogue. In pseudocode, I don't need anything more than something like this:
Code: Select all
ExportDialog(oDia, "file:///C:/Users/user/Documents/MyProject/MyDialog.xdl")
And for importing the same dialogue something like this:
Code: Select all
oDia = ImportDialog("file:///C:/Users/user/Documents/MyProject/MyDialog.xdl")
I assume I'll have to search somewhere in the XStorable interface. But I cannot find out whether this interface is linked with the UnoControlDialog service.
I suppose this is somehow possible, since the Basic IDE itself can export and import dialogues. If the IDE can, we should be able to write a macro that also can import and export dialogues.
Re: Macro to store/load a dialogue
Posted: Sat Jan 27, 2018 11:47 pm
by Villeroy
The GUI copies the *.xdl file from some package, directory or document to some other package, directory or document and adds a registration to dialog.xlb of the respective library. The registration can point to any xdl file anywhere on the system. for instance, when you import an extension with a dialog the registration points to some file in a subdirectory of the uno_packages directory
Re: Macro to store/load a dialogue
Posted: Sun Jan 28, 2018 7:32 pm
by Villeroy
Re: Macro to store/load a dialogue
Posted: Mon Jan 29, 2018 7:09 pm
by hubert lambert
Hello,
You can load a dialog directly from a xdl file using the
DialogProvider or
DialogProvider2 service :
Code: Select all
sub load_dlg
dlg_provider = com.sun.star.awt.DialogProvider2.create()
dlg_url = convertToURL("c:\path\to\the\dialog.xdl")
dlg = dlg_provider.createDialog(dlg_url)
dlg.execute()
end sub
Regards.
Re: Macro to store/load a dialogue
Posted: Thu Dec 05, 2024 4:45 pm
by JmCornil
Hello
Did you find a solution for your problem of storing/saving a modified dialog ?
I know that it is an old post but I find no information on this subject
Best Regards
J.M. CORNIL
Re: Macro to store/load a dialogue
Posted: Thu Dec 05, 2024 6:44 pm
by RoryOF
Try
https://wiki.openoffice.org/wiki/Docume ... ganization
If in any perplexity, try the works of Andrew Pitonyak which can be downloaded from
https://www.pitonyak.org/oo.php
Re: Macro to store/load a dialogue
Posted: Thu Dec 05, 2024 8:05 pm
by JmCornil
Thank you for your answer.
But I alredy read this papers and nowhere I found how to save a modified dialog.
Re: Macro to store/load a dialogue
Posted: Thu Dec 05, 2024 10:38 pm
by cwolan
@JmCornil
Are you the author of the
Is it possible to save a modified dialog? topic on the Ask LibreOffice forum?
Re: Macro to store/load a dialogue
Posted: Fri Dec 06, 2024 9:16 am
by JmCornil
Yes, I am.
Re: Macro to store/load a dialogue
Posted: Fri Dec 06, 2024 11:14 am
by RoryOF
I don't think there is a partial or incremental Save; I think you have to reSave the entire library and allow for the prompt that you are overwriting an existing library of the same name.
Re: Macro to store/load a dialogue
Posted: Fri Dec 06, 2024 1:25 pm
by JeJe
Export the library eg
Code: Select all
url = converttourl("C:\tmp\")
thiscomponent.DialogLibraries.exportLibrary( "Standard", url, nothing)
Then delete the files you don't want from the folder that's created.