Bug 87884 - tabpages not displayed in Java/Python/basic dialog
Summary: tabpages not displayed in Java/Python/basic dialog
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
4.2.7.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Vasily Melenchuk (CIB)
URL:
Whiteboard: target:6.3.0 target:6.1.6 target:6.2.1
Keywords: needsDevAdvice
Depends on:
Blocks:
 
Reported: 2014-12-30 23:47 UTC by Bram Kuijper
Modified: 2019-02-25 07:06 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
source file in which a dialog with tab pages is created (4.36 KB, text/plain)
2014-12-30 23:47 UTC, Bram Kuijper
Details
screenshot of the resulting dialog (249.15 KB, image/png)
2014-12-30 23:49 UTC, Bram Kuijper
Details
Basic script to create a tabpage (2.06 KB, text/plain)
2015-04-03 23:54 UTC, Olivier R.
Details
Basic tabs with button and text on the 2nd (2.74 KB, text/plain)
2019-01-22 14:40 UTC, Jan-Marek Glogowski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bram Kuijper 2014-12-30 23:47:47 UTC
Created attachment 111543 [details]
source file in which a dialog with tab pages is created

When creating a UNO dialog in Java (using Libreoffice SDK 4.2.7.2 coded using the Netbeans Openoffice plugin 4.0.6) adding tab pages to a dialog does not work. 

I am adding tab pages by creating a UnoControlTabPageContainerModel, querying its interface and subsequently adding individual tab pages to it by using the function createTabPage(). However, in Libreoffice it merely shows a dialog window without tab pages. 

However, the same code reportedly works in Openoffice (see user Hanya in https://forum.openoffice.org/en/forum/viewtopic.php?f=44&t=74391&p=336538#p336538) and produces a functional dialog with tab pages.


The important part of the code (full code is attached below):

Object oDialogProvider =m_xMCF.createInstanceWithContext("com.sun.star.awt.DialogProvider", m_xContext);
XDialogProvider xDialogProvider = UnoRuntime.queryInterface(XDialogProvider.class, oDialogProvider);
XDialog xDialog = xDialogProvider.createDialog("vnd.sun.star.script:Standard.Dialog1?location=application");
     
      if (xDialog == null) return;
      XControlModel xDialogModel = UnoRuntime.queryInterface(XControl.class, xDialog).getModel();
      XMultiServiceFactory xMsf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDialogModel);
     
         XNameContainer xNameContainer = UnoRuntime.queryInterface(XNameContainer.class, xDialogModel);
         
         Object tabPagesModel = xMsf.createInstance("com.sun.star.awt.tab.UnoControlTabPageContainerModel");
         xNameContainer.insertByName("tab", tabPagesModel);
         XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, tabPagesModel);
         xPropSet.setPropertyValue("Width", 100);
         xPropSet.setPropertyValue("Height", 100);
         
         XTabPageContainerModel xTabPagesModel = UnoRuntime.queryInterface(XTabPageContainerModel.class, tabPagesModel);
         
         XTabPageModel xTabPageModel1 = xTabPagesModel.createTabPage((short) 1);
         xTabPageModel1.setTitle("Page 1");
         xTabPagesModel.insertByIndex(0, xTabPageModel1);
         XTabPageModel xTabPageModel2 = xTabPagesModel.createTabPage((short) 2);
         xTabPageModel2.setTitle("Page 2");
         xTabPagesModel.insertByIndex(1, xTabPageModel2);
Comment 1 Bram Kuijper 2014-12-30 23:49:12 UTC
Created attachment 111544 [details]
screenshot of the resulting dialog
Comment 2 Julien Nabet 2014-12-31 00:04:57 UTC
Stephan: one for you?
Comment 3 Stephan Bergmann 2015-01-26 10:55:44 UTC
Providing an obvious main() for attachment 111543 [details] and connecting it to a LO instance makes it fail with an IllegalArgumentException from xDialogProvider.createDialog().  Please provide sources for a complete yet as-minimal-as-possible reproducer.
Comment 4 Olivier R. 2015-04-03 23:54:15 UTC
Created attachment 114601 [details]
Basic script to create a tabpage

Here is a Basic script to create a very simple tabpage.
This code works in AOO 4.1.1

In LO 4.4.2, it raises an exception
com.sun.star.beans.UnknownPropertyException

at line:
tabPageModel.insertByName("intab",fixedTextModel)
Comment 5 tommy27 2016-04-16 07:25:07 UTC Comment hidden (obsolete)
Comment 6 QA Administrators 2017-05-22 13:26:33 UTC Comment hidden (obsolete)
Comment 7 Thomas Krumbein 2017-09-08 15:09:44 UTC
It is still not working with LO 5.3, Windows 10

Version: 5.3.1.2 (x64)
Build-ID: e80a0e0fd1875e1696614d24c32df0f95f03deb2
CPU-Threads: 8; BS-Version: Windows 6.19; UI-Render: Standard; Layout-Engine: neu; 
Gebietsschema: de-DE (de_DE); Calc: group

Same error:  com.sun.star.beans.UnknownPropertyException
Comment 8 Volker Lenhardt 2018-02-04 15:11:49 UTC
LO 5.3.0.3 under Linux openSUSE LEAP 42.2:
the same bug as with Windows.

If I try to insert the button controls directly into the tab pages, I don't get an error, but no buttons inside as well. Most likely it's all the same internally. In short:

  oTabPage1 = CreateUnoService("com.sun.star.awt.tab.UnoControlTabPage")
  oTabPage1.setModel(oTabPageModel1)
  oButton1 = CreateUnoService("com.sun.star.awt.UnoControlButton")
  oButton1.setModel(oButtonModel1)
  oTabPage1.addControl("Tab 1", oButton1)

It's a pity.
Comment 9 Volker Lenhardt 2018-02-04 18:02:08 UTC
I was wrong. This is the part of my code showing one tab page (of two), with one button control within:

  oTabContainerModel = oDialogModel.CreateInstance("com.sun.star.awt.tab.UnoControlTabPageContainerModel")

  With oTabContainerModel
    .Name = "Tab"
    .PositionX = 6
    .PositionY = 10
    .Width = 145
    .Height = 100
    .TabIndex = 2
    .Border = 1
    .BackgroundColor =  RGB(255, 255, 255)
  End With
  
  oDialogModel.insertByName("tab", oTabContainerModel)
  oTabPage1 = CreateUnoService("com.sun.star.awt.tab.UnoControlTabPage")

  args = Array(1)
  oTabPageModel1 = oDialogModel.createInstance("com.sun.star.awt.tab.UnoControlTabPageModel")
  oTabPageModel1.initialize(args)
  oTabPageModel1.Title = "Page 1"
  oTabPageModel1.Name = "Tab1"

  oTabPage1.setModel(oTabPageModel1)
  oTabContainerModel.insertByIndex(0, oTabPageModel1)

  oButton1 = CreateUnoService("com.sun.star.awt.UnoControlButton")

  oButtonModel1 = oTabPageModel1.createInstance("com.sun.star.awt.UnoControlButtonModel")
  With oButtonModel1
    .PositionX = 10
    .PositionY = 10
    .Width = 30
    .Height = 15
    .Label = "Button 1"
  End With

  oButton1.setModel(oButtonModel1)
  oTabPage1.addControl("Tab 1", oButton1)
  Print oTabPage1.Controls(0).Model.Label  ' shows "Button 1"

The tab pages are displayed, but not the buttons, even though they are there in the tab pages.
Comment 10 Xisco Faulí 2018-03-15 10:23:16 UTC
Hi Thomas,
Could you please try what Volker is suggesting?
I have set the bug's status to 'NEEDINFO'. Please change it back to
'UNCONFIRMED' once you have retested
Comment 11 Thomas Krumbein 2018-03-16 08:08:42 UTC
hey Xisco,

it is still not working;) Thats even what Volker mentioned. 

He still use the Basic-Script (attachement 3) , but changed some contents. 

His additional codes just show, that all internal models works correct (i.e. his Tab-page label), properties are stored correct, but trying to get it work in a real dialog fails... nothing will be displayed.

result ist equal to sreenshot attatchment 2.

So: API is broken of using tabs (mainly display) - never mind if code is Java or basic.

so, bug is still open.
Comment 12 Arnaud Versini 2018-04-14 12:31:04 UTC
Problem also occurs in Basic, Python. Changing title Basic/Java/Python.

The script provided by Olivier throw an UnknownPropertyException.
Comment 13 Jan-Marek Glogowski 2019-01-22 14:40:02 UTC
Created attachment 148520 [details]
Basic tabs with button and text on the 2nd

Took some time to figure this "workaround" out.

AFAIK com.sun.star.awt.tab.UnoControlTabPageContainerModel currently just works for AOO, but com.sun.star.awt.UnoMultiPageModel does for LO.

Probably some conversation between these models is missing? I didn't check that.

I actually didn't try the other examples and copied code from various forum and wiki and blog posts, even some LO ask.

None of the stuff I found still worked out of the box, which means there is definitely stuff broken :-(

Xray told me some interface and function existed, but Basic complained about it, when trying to set the tabs properties via XSimpleTabController.

I just tested this Basic script on Linux, but I guess it will also work on other platform.
Comment 14 Volker Lenhardt 2019-01-24 14:10:01 UTC
Some remarks to the workaround.

You can create a page model from the tabs container model as well as from the dialog model:

pageModel1 = dialogModel.CreateInstance("com.sun.star.awt.UnoPageModel")

instead of

pageModel1 = tabsModel.CreateInstance("com.sun.star.awt.UnoPageModel")

It seems that the tabs container model inherits from the dialog model.

The next one has a practical relevance. You may want to use the page model's TabPageID property. If you create the page model with CreateInstance, the TabPageID's value is zero for each created page. Nevertheless you can put the focus to a page (e.g. the first one) with

dialog.getControl("tab").activateTab(1)

But there is no effect, if you try it with

dialog.getControl("tab").activateTab(pageModel2.TabPageID)

It is always the first page.

So you'd better create the pages with createInstanceWithArguments and supply the IDs:

pageModel1 = tabsModel.createInstanceWithArguments _
                        ("com.sun.star.awt.UnoPageModel", Array(1))
pageModel2 = tabsModel.createInstanceWithArguments _
                        ("com.sun.star.awt.UnoPageModel", Array(2))

Now you can use the pages' TabPageIDs, but you cannot write to them. This property is read only. The following will succeed:

dialog.getControl("tab").activateTab(pageModel2.TabPageID).
Comment 15 Commit Notification 2019-02-04 10:40:22 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/3deab788199395712b7d4641be5b11623b2ed964%5E%21

tdf#87884: basic: fix for UnknownPropertyException

It will be available in 6.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 Commit Notification 2019-02-04 10:40:29 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/18f2e73f51c0f09c94f1a2b701d8e064adb39bf5%5E%21

tdf#87884: UnoControlTabPageModel is using tabs w/o WB_NOBORDER

It will be available in 6.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 17 Commit Notification 2019-02-06 10:25:03 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

https://git.libreoffice.org/core/+/aa7b71cd17898cd47f4bd7f12cfe5036cd40cb57%5E%21

tdf#87884: basic: fix for UnknownPropertyException

It will be available in 6.1.6.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 18 Commit Notification 2019-02-06 10:25:14 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "libreoffice-6-2":

https://git.libreoffice.org/core/+/954c23f3393fc1d6e06687db8718f072723c8355%5E%21

tdf#87884: basic: fix for UnknownPropertyException

It will be available in 6.2.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 19 Commit Notification 2019-02-06 15:15:28 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "libreoffice-6-2":

https://git.libreoffice.org/core/+/bc08bef01363537eac91daacc37529326d26a2b6%5E%21

tdf#87884: UnoControlTabPageModel is using tabs w/o WB_NOBORDER

It will be available in 6.2.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 20 Commit Notification 2019-02-06 15:15:35 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

https://git.libreoffice.org/core/+/08aa78cc52ea49fea2454096e97875f1d4b4cecc%5E%21

tdf#87884: UnoControlTabPageModel is using tabs w/o WB_NOBORDER

It will be available in 6.1.6.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.