Page 1 of 1

[Solved-Partially] pyuno dialogs

PostPosted: Tue Apr 17, 2018 1:29 am
by hika
In the past 10+ years I have done a lot of programming in VB, VBA and python.
Early this year I discovered the python UNObridge and I started studying it and I am well on my way to create my own pytonic interpretation.
Early March I started on forms/dialogs and although I have the basics working of a building/sizing system not unlike GTK or what I had build in the past in VB, working, I have come along some things that I do not seem to be able to figure out.

First Titles/Captions of dialogs embedded in a window/frame.

I can only set a title for the frame but that is not the title displayed. If I create a window/frame set it will show as title either openoffice or libreoffice followed by the version number. If I check prior to setting my own title to the frame, it will have either openoffice or libreoffice without the version number and changing the frame title will not change the title displayed.
So my question is where is the actual displayed title located?

Second: Sizing units.

For a window the default sizing units are points.
A dialog uses some arbitrary unit I can not fathom. On both libreoffice and openoffice I see a vertical ratio of 2. With the dialog units being bigger. Vertically I see on libreoffice a ratio of 2.25 and on openoffice of 2.46. Both on the same Gentoosystem with an equal horizontal and vertical DPI of 100.
So my question is what are those units and if possible, where can I change them?

Third: How can I in UNO determine the openoffice/libreoffice version? I can distinguish between the two by looking at the installation path, but there should be an API call to get version specifics.

I have more questions but they are not urgent. Probably in a few months I will publish my first alfa on git.

Hika

Re: pyuno dialogs

PostPosted: Tue Apr 17, 2018 5:08 am
by JeJe

Re: pyuno dialogs

PostPosted: Tue Apr 17, 2018 3:11 pm
by hubert lambert
Hello,

hika wrote:First Titles/Captions of dialogs embedded in a window/frame.

I can only set a title for the frame but that is not the title displayed. If I create a window/frame set it will show as title either openoffice or libreoffice followed by the version number. If I check prior to setting my own title to the frame, it will have either openoffice or libreoffice without the version number and changing the frame title will not change the title displayed.
So my question is where is the actual displayed title located?

It's not very clear why this happens, maybe you could have a look at this post : https://forum.openoffice.org/en/forum/v ... 20&t=42968.

An easy workaround would be to define the WindowServiceName as "dialog", which returns a window object exposing css.awt.XDialog and its setTitle() method. Here you should be able to get the right title shown:
Code: Select all   Expand viewCollapse view
import uno
from com
.sun.star.awt import Rectangle, WindowDescriptor
from com
.sun.star.awt.WindowClass import TOP
from com
.sun.star.awt.WindowAttribute import BORDER, MOVEABLE, SIZEABLE,CLOSEABLE

def createdialog
():
    ctx = uno.getComponentContext()
    smgr = ctx.ServiceManager
    toolkit 
= smgr.createInstance("com.sun.star.awt.Toolkit")
    descriptor = WindowDescriptor()
    descriptor.Type = TOP
    descriptor
.WindowServiceName = "dialog"
    descriptor.ParentIndex = -1
    descriptor
.Parent = None
    descriptor
.Bounds = Rectangle(200, 200, 500, 300)
    descriptor.WindowAttributes = BORDER | MOVEABLE | SIZEABLE | CLOSEABLE
    window 
= toolkit.createWindow(descriptor)
    frame = smgr.createInstance("com.sun.star.frame.Frame")
    frame.initialize(window)
    treeroot = smgr.createInstance("com.sun.star.frame.Desktop")
    childcontainer = treeroot.getFrames()
    childcontainer.append(frame)
    window.setBackground(0x98A9BA)
    window.setTitle("A Dialog with Title")
    window.setVisible(True)


Regards.

Re: pyuno dialogs

PostPosted: Tue Apr 17, 2018 5:14 pm
by hika
Thanks! I have been wondering what those servicenames manage as I have not found anything but a list of available names. I did find that setting it to one of the dialog names would change the backgroundcolor from white to the default dialog backgroundcolor, so I assumed it were layout profiles, but obviously it also manages the available services.

Hika

Oh and the link you gave, gives me a server not found reply!

Re: pyuno dialogs

PostPosted: Tue Apr 17, 2018 5:57 pm
by hubert lambert
Sorry for the erroneous link. I've edited the post to correct it.

Re: pyuno dialogs

PostPosted: Tue Apr 17, 2018 8:23 pm
by hika
JeJe wrote:The measuring unit is the Emu


But then where does the difference between horizontal and vertical step in (and the horizontal difference between openoffice and libreofice)?
If I compare a window with a set width and height of say 100 to a dialog set to a width and height of 100, the dialog is twice as high but 2.25 as wide in libreoffice and as much as 2.46 as wide in openoffice. So aspect ratios change!

Has it to do with title/menubar allotted space?

Hika

Re: pyuno dialogs

PostPosted: Tue Apr 17, 2018 9:42 pm
by JeJe
Apologies, I should have said its the Map AppFont unit - its the document that uses the Emu.

https://wiki.openoffice.org/wiki/Docume ... Properties

You can use getpossize and setpossize to set the dialog in pixels - testing in OOBasic I get identical dialogs in OpenOffice and
LibreOffice. The dialogs will be slightly higher than the width because the client area is set not the outer dimensions which include the
titlebar and the borders.

Re: pyuno dialogs

PostPosted: Tue Apr 17, 2018 11:27 pm
by hika
I yes, it's setting a size or position through the model that gives those weird units. I hadn't noticed I could also use setPosSize on the components. Although I had used that on embedding objects directly into a Window.

Hika

Re: [Solved-Partially] pyuno dialogs

PostPosted: Sun May 27, 2018 1:40 am
by hika
hubert lambert wrote:It's not very clear why this happens, maybe you could have a look at this post : https://forum.openoffice.org/en/forum/v ... 20&t=42968.

Now that I know more I am again looking into that frame/window title issue. To me it looks that at some time the frame title has been rerouted from setting the window title to setting the document title, which in turn is exposed in the window title.
However looking at that old post you gave me, the further links there are outdated and I do not know how to translate them to current links. I tried several things, but...
I'm talking about these two links:
http://openoffice.org/bugzilla/show_bug.cgi?id=91177 and
http://www.oooforum.org/forum/viewtopic.phtml?t=52636
(oops wrong link)

Also I have been looking at their code example:
Code: Select all   Expand viewCollapse view
myDoc = StarDesktop.loadComponentFromURL(Url, "_blank", 0, Dummy())
myDocFrame = myDoc.getCurrentController.getFrame
myDocFrame.Title = "Test"


As far as I understand "Url" must either point to an existing document or must be like 'private:factory/swriter' or 'private:factory/scalc' to open an new document of that type. I see no way to reuse that frame, which if I am right that frame.Title sets the document title, is also useless.

Hika