[Solved] Creating a Panel

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ponc
Posts: 86
Joined: Mon Dec 09, 2013 7:34 pm

[Solved] Creating a Panel

Post by ponc »

Hi,

I would like to create a dockable and resizeable panel. (Like the Navigator) I would like to know, if it's possible?
There was the possibility to create a custom tool panel in the task pane,
(https://wiki.openoffice.org/wiki/Framew ... _Internals)
but with the introduction of the new sidebar, it seemes to be outdated.

I also couldn't find any example for a dockable and resizeable panel. Does someone knows one?

Regards,
ponc
 Edit: Sorry, I forgot to mention, that I would like to do it with python, when possible. But if it's somehow easier to do it with java, I would try that. 
Last edited by Hagar Delest on Wed Dec 18, 2013 5:57 pm, edited 1 time in total.
Reason: tagged [Solved].
OO 4.0.1 , LO 4.4.3.2 on win7 // LO 4.4.3.2 on Ubuntu 14.04
https://github.com/XRoemer/Organon
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Creating a Panel

Post by Villeroy »

In 12 years I have never seen any extension with a dockable window like the stylist or navigator. If it is possible at all, it might be extremely difficult. The properties pane of the "Oracle Report Builder" looks like a dockable window but in fact it is docked and I can not undock it. In addition, that extension has several floating windows that are undocked but not dockable.
In theory, the language makes no difference. "Oracle Report Builder" is written in Java.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Creating a Panel

Post by hanya »

Villeroy wrote:The properties pane of the "Oracle Report Builder" looks like a dockable window but in fact it is docked and I can not undock it. In addition, that extension has several floating windows that are undocked but not dockable.
They are the part of core implemented under main/reportdesign module of the source tree. Most of windows of the report builder is the same.
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
ponc
Posts: 86
Joined: Mon Dec 09, 2013 7:34 pm

Re: Creating a Panel

Post by ponc »

Does that mean, they are not reachable by an extension?

I don't know the Oracle Report Builder, but I installed it and couldn't see any icon, menu or window. Does it still work?
OO 4.0.1 , LO 4.4.3.2 on win7 // LO 4.4.3.2 on Ubuntu 14.04
https://github.com/XRoemer/Organon
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Creating a Panel

Post by Villeroy »

Open some database, e.g. hit F4 in Writer, right-click Bibliography>Edit Database...
Go to the reports section and create a new report in design mode.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Creating a Panel

Post by hanya »

I remembered something about Oracle Connector for Alfresco CMS that creates own dockingwindow through UI element mechanism.

I made an example extension for example. If you want to know more, please read factory.py file stored in the extension package. And please refer related documents:
- http://svn.apache.org/viewvc/openoffice ... iew=markup
- http://www.openoffice.org/api/docs/comm ... ctory.html
And also please check configuration files (having .xcu file extension) stored in the package.
Any other way or types are general ways to use of the API of the office or general ways to make extensions.

How to try the attached extension:
- Download the package and remove .zip file extension.
- Install the package through the extension manager.
- Restart your office.
- Create new Writer document.
- Execute the following Basic macro to show the dockingwindow provided by the extension.
- You can make it docked in the container window of the document frame. And you can undock/dock by double clicking on the docking window with Ctrl button pushed.
- The docking window contains one text field and one button. When you push the button on the window, the message box shows the text from the textfield.

Code: Select all

const RESOURCE_URL = "private:resource/dockingwindow/9809"

Sub SwitchDockingWindow
  layoutmgr = ThisComponent.getCurrentController().getFrame().LayoutManager
  if layoutmgr.isElementVisible(RESOURCE_URL) then
    layoutmgr.hideElement(RESOURCE_URL)
  else
    layoutmgr.requestElement(RESOURCE_URL)
  end if
End Sub
Attachments
dockingexample.oxt.zip
Remove .zip file extension before installing it.
(6.64 KiB) Downloaded 283 times
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
ponc
Posts: 86
Joined: Mon Dec 09, 2013 7:34 pm

Re: Creating a Panel

Post by ponc »

Wow, that's exactly what I was looking for! Thanks a lot, you're help is incredible!!

Regards,
ponc
OO 4.0.1 , LO 4.4.3.2 on win7 // LO 4.4.3.2 on Ubuntu 14.04
https://github.com/XRoemer/Organon
ponc
Posts: 86
Joined: Mon Dec 09, 2013 7:34 pm

Re: [Solved] Creating a Panel

Post by ponc »

This example was very helpful. I think I understand now more or less how to add a dialog, create a new tab and how to control the panel dialog from a .xdl file.

Can I achieve the .xdl file from python as well? I would prefer an empty dialog and set all the buttons, labels, controls etc. afterwards from python.
The part of the code where a tab is created look like follows:

Code: Select all

        dialog1 = "vnd.sun.star.extension://mytools.window.DockingWindowTest/Dialog1.xdl"

        tabs = create("com.sun.star.comp.framework.TabWindowService")
        n = tabs.insertTab() # Create new tab, return value is tab id
        # Valid properties are: 
        # Title, ToolTip, PageURL, EventHdl, Image, Disabled.
        v1 = NamedValue("PageURL", dialog1)
        v2 = NamedValue("Title", "Test Tab")
        v3 = NamedValue("EventHdl", ContainerWindowHandler(ctx, frame))
        tabs.setTabProps(n, (v1, v2, v3))
        tabs.activateTab(n) # each page should be activated after the creation
        
        window = tabs.Window # real window
But as v1 asks for an URL, how can I create it from python? I tried several possibilities, but didn't succeed

Regards,
ponc
OO 4.0.1 , LO 4.4.3.2 on win7 // LO 4.4.3.2 on Ubuntu 14.04
https://github.com/XRoemer/Organon
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: [Solved] Creating a Panel

Post by hanya »

I would prefer an empty dialog and set all the buttons, labels, controls etc. afterwards from python.
See ContainerWindowHandler class, callHandlerMethod called with "initalize" value and the instantiated window (dialog), you can get access to the dialog instance.
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
ponc
Posts: 86
Joined: Mon Dec 09, 2013 7:34 pm

Re: [Solved] Creating a Panel

Post by ponc »

I have access to the dialog. Inspecting the dialog I found the buttons and label, which are described as follows:
pyuno object (com.sun.star.awt.XControlModel)0xd57cf2c{implementationName=stardiv.Toolkit.UnoControlButtonModel, ...

So I tried to create the same kind of object:

Code: Select all

btn = dialog.Model.createInstance(
                       "com.sun.star.awt.UnoControlButtonModel")
                     
                    btn.PositionX = 200
                    btn.PositionY  = 30
                    btn.Width = 50;
                    btn.Height = 14;
                    btn.Name = "test";       
                    btn.Label = "test button";

                    dialog.addControl("test",buttonModel1)
But this doesn't work. It creates an interface, not a XControlModel.
What am I doing wrong? Can you give me a little example?

thanks a lot for your help,
ponc
 Edit: Did you mean this with ContainerWindowHandler:
http://www.openoffice.org/api/docs/comm ... ndler.html
How do I use that?
- Sorry for all my newbie questions 
OO 4.0.1 , LO 4.4.3.2 on win7 // LO 4.4.3.2 on Ubuntu 14.04
https://github.com/XRoemer/Organon
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: [Solved] Creating a Panel

Post by hanya »

ponc wrote:

Code: Select all

btn = dialog.Model.createInstance(
                       "com.sun.star.awt.UnoControlButtonModel")

                    dialog.addControl("test",buttonModel1)
But this doesn't work. It creates an interface, not a XControlModel.
Simply, insert it into the container of the dialog model. You can find some examples for it in this forum or
https://wiki.openoffice.org/wiki/Docume ... Interfaces
 Edit: Did you mean this with ContainerWindowHandler:
http://www.openoffice.org/api/docs/comm ... ndler.html
How do I use that? 
See ContainerWindowHandler class defined in factory.py file. The interface have to be implemented and getSupportedMethodNames method returns sequence of supported method names, currently only "external_event" is supported. The callHandlerMethod method is called when some event is happened, with event name in third argument. The first argument is instance of the window or dialog (dialog is a variation of window), so you can access to the GUI component through the value. The second argument is callee dependent and only "initialize" value is passed in this case.
In the case of to implement option dialog, the second argument of callHandlerMethod is one of "initialize", "ok" and "back" that depends on user's interaction on the option 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
ponc
Posts: 86
Joined: Mon Dec 09, 2013 7:34 pm

Re: [Solved] Creating a Panel

Post by ponc »

I replaced the last line with:

Code: Select all

dialog.Model.insertByName("test",btn)
Now it works. Thanks.

I already found the pages about the Graphical User Interface, but even when the concept gets more clear, it's still a lot guessing for me.
OO 4.0.1 , LO 4.4.3.2 on win7 // LO 4.4.3.2 on Ubuntu 14.04
https://github.com/XRoemer/Organon
Post Reply