When have made some changes to a Dialog (stored in a Librarie)using Basic and API I trye to make this changes persitent for future use.
The secrets are in the methods off the dialog.model
odialog.model.read( ???)
odialog.model.write(???)
found a confusing explaination in the DSK but nullware any examples how to use this read-write mechanism to make the changes persitent
Thanks for any hint !
Fernand
Make changes to Dialogs persistent
Make changes to Dialogs persistent
Openoffice3.3 Windows XP
Re: Make changes to Dialogs persistent
Hi,
Welcome to the forum.
You can make your control model persistent as follows:
Welcome to the forum.
You can make your control model persistent as follows:
Code: Select all
Sub DialogPersistentTest
DialogLibraries.loadLibrary("Standard")
dlg = CreateUnoDIalog(DialogLibraries.Standard.Dialog15)
url = "file:///home/asuka/Desktop/list_model.out"
list = dlg.getControl("ListBox1")
list_model = list.getModel()
'PersistControl(list_model, url)
RestoreControl(list_model, url)
dlg.execute()
dlg.dispose()
End Sub
' store control properties to file.
Sub PersistControl(ctrl_model as Variant, url as string)
sfa = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
o = sfa.openFileWrite(url)
mos = CreateUnoService("com.sun.star.io.MarkableOutputStream")
oos = CreateUnoService("com.sun.star.io.ObjectOutputStream")
oos.setOutputStream(mos)
mos.setOutputStream(o)
ctrl_model.write(oos)
o.closeOutput()
End Sub
' restore control properties from file.
Sub RestoreControl(ctrl_model as Variant, url as string)
sfa = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
i = sfa.openFileRead(url)
mis = CreateUnoService("com.sun.star.io.MarkableInputStream")
ois = CreateUnoService("com.sun.star.io.ObjectInputStream")
ois.setInputStream(mis)
mis.setInputStream(i)
ctrl_model.read(ois)
i.closeInput()
End Sub
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04
Re: Make changes to Dialogs persistent
hi Hanja,
Thanks for this code,
i tested, no error's but the changes to the control are not persistent even after i did the same procedure for the whole dialog.
for testing :
When executing the dialog we sea that the listbox is labeled "Fernand" but this change is not peristent afterwards ?
Do i have to save/restore the "library" also ?
thanks for any hint
Fernand
Thanks for this code,
i tested, no error's but the changes to the control are not persistent even after i did the same procedure for the whole dialog.
for testing :
Code: Select all
Sub DialogPersistentTest
DialogLibraries.loadLibrary("Standard")
dlg = CreateUnoDIalog(DialogLibraries.Standard.Dialog15)
url = "file:///home/asuka/Desktop/list_model.out"
list = dlg.getControl("ListBox1")
list_model = list.getModel()
list_model.label = "Fernand"
PersistControl(list_model, url)
RestoreControl(list_model, url)
PersistControl(dlg.model url)
RestoreControl(dlg.model, url)
dlg.execute()
'here we sea the label is changed to "Fernand"
dlg.dispose()
nextopening
end sub
sub nextopening
DialogLibraries.loadLibrary("Standard")
dlg = CreateUnoDIalog(DialogLibraries.Standard.Dialog15)
dlg.execute
'here the label is no longer "Fernand"
dlg.dispose
End Sub
Do i have to save/restore the "library" also ?
thanks for any hint
Fernand
Openoffice3.3 Windows XP
Re: Make changes to Dialogs persistent
The exportDialogModel function which is used internally is not exported as any api. If you want to make the control persist with css.io.XPersist interface, you have to store and load yourself. Or modify xdl file of the dialog.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04
Re: Make changes to Dialogs persistent
Hanja,
Something is excaping me ?
If we not can make "changes" persistent to the dialogfile, waths then the purpose of "model.write/read" ?
and please can you explain a bit more how i can do what you propose "you have to store and load yourself"
Thanks any how
Something is excaping me ?
If we not can make "changes" persistent to the dialogfile, waths then the purpose of "model.write/read" ?
and please can you explain a bit more how i can do what you propose "you have to store and load yourself"
Thanks any how
Openoffice3.3 Windows XP
Re: Make changes to Dialogs persistent
You can store the state of your control and you can load the state of the control from the file. Write your own higher level api than the office api using these methods.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04