[Solved-Partially] pyuno dialogs

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
hika
Posts: 39
Joined: Tue Apr 17, 2018 12:53 am

[Solved-Partially] pyuno dialogs

Post 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
Last edited by hika on Sun Apr 22, 2018 11:18 am, edited 1 time in total.
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows
JeJe
Volunteer
Posts: 2763
Joined: Wed Mar 09, 2016 2:40 pm

Re: pyuno dialogs

Post by JeJe »

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

Re: pyuno dialogs

Post 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 : viewtopic.php?f=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

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.
Last edited by hubert lambert on Tue Apr 17, 2018 5:56 pm, edited 1 time in total.
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hika
Posts: 39
Joined: Tue Apr 17, 2018 12:53 am

Re: pyuno dialogs

Post 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!
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

Re: pyuno dialogs

Post by hubert lambert »

Sorry for the erroneous link. I've edited the post to correct it.
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hika
Posts: 39
Joined: Tue Apr 17, 2018 12:53 am

Re: pyuno dialogs

Post 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
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows
JeJe
Volunteer
Posts: 2763
Joined: Wed Mar 09, 2016 2:40 pm

Re: pyuno dialogs

Post 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.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
hika
Posts: 39
Joined: Tue Apr 17, 2018 12:53 am

Re: pyuno dialogs

Post 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
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows
hika
Posts: 39
Joined: Tue Apr 17, 2018 12:53 am

Re: [Solved-Partially] pyuno dialogs

Post by hika »

hubert lambert wrote:It's not very clear why this happens, maybe you could have a look at this post : viewtopic.php?f=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

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
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows
Post Reply