[Libreoffice-bugs] [Bug 132832] New: XLayoutConstrains.calcAdjustedSize doesn't return proper size for multiline checkbox and hyperlink

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Fri May 8 06:25:09 UTC 2020


https://bugs.documentfoundation.org/show_bug.cgi?id=132832

            Bug ID: 132832
           Summary: XLayoutConstrains.calcAdjustedSize doesn't return
                    proper size for multiline checkbox and hyperlink
           Product: LibreOffice
           Version: 6.4.0.0.alpha0+
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: sdk
          Assignee: libreoffice-bugs at lists.freedesktop.org
          Reporter: m.weghorn at posteo.de

Created attachment 160517
  --> https://bugs.documentfoundation.org/attachment.cgi?id=160517&action=edit
Sample Java extension to reproduce the issue

The method calcAdjustedSize() of the UNO interface does not return proper
height/width for mutline checkboxes and hyperlinks.

A sample extension is attached.

# Steps to reproduce:

1) install the attached sample extension "StarterProject.oxt"
2) start LO Writer
3) in the menu, select "Test Extension" -> "Show Dialog" to show the sample
dialog
4) press the "Resize" button, which calls the 'calcAdjustedSize' method (with
value 500 for width and 50 for the height) to calculate the proper size for the
form controls, then resizes to the returned size using 'setPosSize'
5) check the text shown next to the checkbox (second last control) and the
hyperlink (last control)

# Result:

* The text to the checkbox is much wider than the expected width of 500, and
still cut off, since it does not fit into one line.
* The text for the hyperlink control is incomplete, since it is just one line,
but cut off at width 500.

A screenshot will be attached.

# Expected result:

Both, the text for the checkbox and that for the hyperlink control should be
complete, split over multiple lines, and not exceed the width of 500.

# Version used

Version: 7.0.0.0.alpha0+
Build ID: 934fd1c617d1f7fba90f922bf2d526ea3f35f9b7
CPU threads: 4; OS: Linux 5.6; UI render: default; VCL: gtk3; 
Locale: en-GB (en_GB.UTF-8); UI-Language: en-US
Calc: threaded

and the result is similar when using the gen/x11 VCL plugin instead.

# More information/notes

The relevant Java method from the extension to do the resizing looks as follows
(whole extension source code will be attached):

public ActionOneDialog(XComponentContext xContext)
        {
          this.dialog = DialogHelper.createDialog("ActionOneDialog.xdl",
xContext, this);

          XButton button = DialogHelper.getButton(dialog, "Resize");
          button.addActionListener(new XActionListener()
          {

            @Override
            public void disposing(EventObject arg0)
            {
            }

            @Override
            public void actionPerformed(ActionEvent arg0)
            {
              String output = "Control: %s, calculated Width %d, maximum Width
%d, calculated Height %d";
              Size max = new Size(500, 50);
              Size size;
              XLayoutConstrains lc;
              XWindow window;
              Rectangle r = null;

              XFixedText label = DialogHelper.getLabel(dialog, "Label1");
              lc = UnoRuntime.queryInterface(XLayoutConstrains.class, label);
              size = lc.calcAdjustedSize(max);
              System.out.println(String.format(output, "Label1", size.Width,
max.Width, size.Height));
              window = UnoRuntime.queryInterface(XWindow.class, label);
              r = window.getPosSize();
              window.setPosSize(r.X, r.Y, size.Width, size.Height,
PosSize.POSSIZE);

              XTextComponent text = DialogHelper.getEditField(dialog,
"TextField1");
              lc = UnoRuntime.queryInterface(XLayoutConstrains.class, text);
              size = lc.calcAdjustedSize(max);
              System.out.println(String.format(output, "TextField1",
size.Width, max.Width, size.Height));
              window = UnoRuntime.queryInterface(XWindow.class, text);
              r = window.getPosSize();
              window.setPosSize(r.X, r.Y, size.Width, size.Height,
PosSize.POSSIZE);

              XListBox list = DialogHelper.getListBox(dialog, "ListBox1");
              lc = UnoRuntime.queryInterface(XLayoutConstrains.class, list);
              size = lc.calcAdjustedSize(max);
              System.out.println(String.format(output, "ListBox1", size.Width,
max.Width, size.Height));
              window = UnoRuntime.queryInterface(XWindow.class, list);
              r = window.getPosSize();
              window.setPosSize(r.X, r.Y, size.Width, size.Height,
PosSize.POSSIZE);

              XComboBox combo = DialogHelper.getCombobox(dialog, "ComboBox1");
              lc = UnoRuntime.queryInterface(XLayoutConstrains.class, combo);
              size = lc.calcAdjustedSize(max);
              System.out.println(String.format(output, "ComboBox1", size.Width,
max.Width, size.Height));
              window = UnoRuntime.queryInterface(XWindow.class, combo);
              r = window.getPosSize();
              window.setPosSize(r.X, r.Y, size.Width, size.Height,
PosSize.POSSIZE);

              XCheckBox check = DialogHelper.getCheckBox(dialog, "CheckBox1");
              lc = UnoRuntime.queryInterface(XLayoutConstrains.class, check);
              size = lc.calcAdjustedSize(max);
              System.out.println(String.format(output, "CheckBox1", size.Width,
max.Width, size.Height));
              window = UnoRuntime.queryInterface(XWindow.class, check);
              r = window.getPosSize();
              window.setPosSize(r.X, r.Y, size.Width, size.Height,
PosSize.POSSIZE);

              XFixedHyperlink link = DialogHelper.getLink(dialog, "Hyper1");
              lc = UnoRuntime.queryInterface(XLayoutConstrains.class, link);
              size = lc.calcAdjustedSize(max);
              System.out.println(String.format(output, "Hyper1", size.Width,
max.Width, size.Height));
              window = UnoRuntime.queryInterface(XWindow.class, link);
              r = window.getPosSize();
              window.setPosSize(r.X, r.Y, size.Width, size.Height,
PosSize.POSSIZE);
            }
          });

        }

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20200508/d540745f/attachment.htm>


More information about the Libreoffice-bugs mailing list