You can’t write and save the document properties unless you unlock the form document for editing. This was just a very quick solution (10 minutes) reading “hard coded” parameters in a form document. For a dynamic solution I got as far as this:
Sub onFormLoad(ev)
frm = ev.Source
doc = getParentObject(frm, "com.sun.star.document.OfficeDocument")
view = doc.CurrentController
win = view.Frame.ContainerWindow
X = frm.getInt(1)
Y = frm.getInt(2)
W = frm.getInt(3)
H = frm.getInt(4)
Z = frm.getInt(5)
view.ViewSettings.ZoomValue = Z
win.setPosSize(X, Y, W, H, 15)
End Sub
Sub onFormUnload(ev)
msgbox "OK"
exit sub
frm = ev.Source
doc = getParentObject(frm, "com.sun.star.document.OfficeDocument")
view = doc.CurrentController
ps = view.Frame.ContainerWindow.getPosSize()
print ps.X, ps.Y, ps.Width, ps.Height
frm.updateLong(1, ps.X)
frm.updateLong(2, ps.Y)
frm.updateLong(3, ps.Width)
frm.updateLong(4, ps.Height)
frm.updateLong(5, view.ViewSettings.ZoomValue)
frm.updateRow()
End Sub
Function getParentObject(byval m, srvName$)
do until m.supportsService(srvName)
m = m.getParent()
loop
getParentObject = m
End Function
It tries to read/write from/to a table through an invisible form (form with no controls). The invisible form is linked to SELECT * FROM WINDOWS WHERE N = ‘Left Half Zoom 80’ and the form’s load/unload events are bound to the above routines.
The name column “N” is a primary key, the other columns are integer X,Y,W,H,Z.
This time the term “form” refers to a logical form on a form document.
Problem: the second routine onForumUnLoad is never called.
Edit:
counter_WinSettings.odb (49.0 KB)