tdf#130857 Define widgets in Calc "General" options page in order

Switch the order in which the widgets in the .ui file
are defined so that the order better matches the visual appearance
and logical order, which makes sure that tab focus order with the
Qt-based VCL plugins is correct as well when using native Qt
widgets (SAL_VCL_QT_USE_WELDED_WIDGETS=1), where
focus order is (by default) based on widget creation order.

See

    commit 02692566ad
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Thu Oct 24 17:43:35 2024 +0200

        tdf#130857 optnewdictionarydialog.ui: Define focusable widgets in order

for more background.

The tab page can be triggered like this:

* start Calc
* "Tools" -> "Options"
* "LibreOfficeDev Calc" -> "General"

The following local Python script (based on bin/ui-rules-enforcer.py)
was used to reorder the GtkGrid children:

    #!/bin/python3
    # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
    #
    # This file is part of the LibreOffice project.
    #
    # This Source Code Form is subject to the terms of the Mozilla Public
    # License, v. 2.0. If a copy of the MPL was not distributed with this
    # file, You can obtain one at http://mozilla.org/MPL/2.0/.

    import lxml.etree as etree
    import sys

    def sort_it(grid_child):
      if grid_child.tag == "property":
        # define GtkGrid's own properties first
        return -1
      for c in grid_child:
        if c.tag == "packing":
          top_attach = -1
          left_attach = -1
          for packing_child in c:
            name = packing_child.attrib.get("name")
            if name == "left-attach":
              left_attach = int(packing_child.text)
            elif name == "top-attach":
              top_attach = int(packing_child.text)
          assert(top_attach >= 0 and left_attach >= 0 and "Missing top-attach/left-attach")
          # first sort by row, then by column
          return top_attach * 1000 + left_attach

      # have other children (e.g. empty placeholder "child" elements) at the end
      return 100000

    def define_grid_children_in_order(current):
      for child in current:
        define_grid_children_in_order(child)
        if child.get('class') == "GtkGrid":
          grid_children = list(child)
          grid_children.sort(key=lambda x: sort_it(x))
          for c in reversed(grid_children):
            # this doesn't duplicate, but moves the existing child
            child.insert(0, c)

    with open(sys.argv[1], encoding="utf-8") as f:
      header = f.readline()
      f.seek(0)
      # remove_blank_text so pretty-printed input doesn't disrupt pretty-printed
      # output if nodes are added or removed
      parser = etree.XMLParser(remove_blank_text=True)
      tree = etree.parse(f, parser)
      # make sure <property name="label" translatable="no"></property> stays like that
      # and doesn't change to <property name="label" translatable="no"/>
      for status_elem in tree.xpath("//property[@name='label' and string() = '']"):
        status_elem.text = ""
      root = tree.getroot()

    define_grid_children_in_order(root)

    with open(sys.argv[1], 'wb') as o:
      # without encoding='unicode' (and the matching encode("utf8")) we get &#XXXX replacements for non-ascii characters
      # which we don't want to see changed in the output
      o.write(etree.tostring(tree, pretty_print=True, method='xml', encoding='unicode', doctype=header[0:-1]).encode("utf8"))

    # vim: set shiftwidth=4 softtabstop=4 expandtab:

(The result matched the one of manually reordering the elements
to double-check that the the script was working correctly.)

Change-Id: Icc05d037e726c92ba522bd4799517c64af7b265d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207792
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn
2026-07-09 18:13:58 +02:00
parent 00c0e842c8
commit 327679b2fb
+232 -232
View File
@@ -30,6 +30,19 @@
<property name="margin-top">6</property>
<property name="row-spacing">3</property>
<property name="column-spacing">6</property>
<child>
<object class="GtkImage" id="lockunitlb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
@@ -44,6 +57,34 @@
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="unitlb">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="accessible">
<object class="AtkObject" id="unitlb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|unitlb">Defines the unit of measure in spreadsheets.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="locktabmf">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
@@ -76,47 +117,6 @@
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="unitlb">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="accessible">
<object class="AtkObject" id="unitlb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|unitlb">Defines the unit of measure in spreadsheets.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockunitlb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="locktabmf">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
@@ -147,6 +147,19 @@
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImage" id="lockupdatelinks">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
@@ -209,19 +222,6 @@
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockupdatelinks">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
</child>
<child type="label">
@@ -272,63 +272,30 @@
<property name="row-spacing">3</property>
<property name="column-spacing">6</property>
<child>
<object class="GtkCheckButton" id="editmodecb">
<property name="label" translatable="yes" context="scgeneralpage|editmodecb">Press Enter to switch to _edit mode</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="editmodecb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|editmodecb">Allows you to immediately edit the selected cell after pressing the Enter key.</property>
</object>
</child>
<object class="GtkImage" id="lockaligncb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="width">2</property>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="formatcb">
<property name="label" translatable="yes" context="scgeneralpage|formatcb">Expand _formatting</property>
<object class="GtkCheckButton" id="aligncb">
<property name="label" translatable="yes" context="scgeneralpage|aligncb">Press Enter to _move selection</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="formatcb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|formatcb">Specifies whether to automatically apply the formatting attributes of the selected cell to the empty adjacent cells.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="exprefcb">
<property name="label" translatable="yes" context="scgeneralpage|exprefcb">Expand _references when new columns/rows are inserted</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="exprefcb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|exprefcb">Specifies whether to expand references when inserting columns or rows adjacent to the reference range. This is only possible if the reference range, where the column or row is inserted, originally spanned at least two cells in the desired direction.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
<property name="width">2</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
@@ -355,57 +322,49 @@
</packing>
</child>
<child>
<object class="GtkCheckButton" id="aligncb">
<property name="label" translatable="yes" context="scgeneralpage|aligncb">Press Enter to _move selection</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<object class="GtkImage" id="lockeditmodecb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="legacy_cell_selection_cb">
<property name="label" translatable="yes" context="scgeneralpage|legacy_cell_selection_cb">Position cell reference with selection</property>
<object class="GtkCheckButton" id="editmodecb">
<property name="label" translatable="yes" context="scgeneralpage|editmodecb">Press Enter to switch to _edit mode</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="legacy_cell_selection_cb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|legacy_cell_selection_cb">With the option set, expanding a selection (with Ctrl + Shift + Down/Up) jumps to the end of the range in the column that was added as last to the initial selection. When the option is not set, expanding a selection (with Ctrl + Shift + Down/Up) jumps to the end of the range in the column where selecting the cell range was started. The same of course applies when extending a selection on rows, with Ctrl + Shift + Left/Right.</property>
<object class="AtkObject" id="editmodecb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|editmodecb">Allows you to immediately edit the selected cell after pressing the Enter key.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
<property name="top-attach">1</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="replwarncb">
<property name="label" translatable="yes" context="scgeneralpage|replwarncb">Show overwrite _warning when pasting data</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="replwarncb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|replwarncb">Specifies that, when you paste cells from the clipboard to a cell range that is not empty, a warning appears.</property>
</object>
</child>
<object class="GtkImage" id="lockenter_paste">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="width">2</property>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -428,6 +387,112 @@
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockformatcb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="formatcb">
<property name="label" translatable="yes" context="scgeneralpage|formatcb">Expand _formatting</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="formatcb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|formatcb">Specifies whether to automatically apply the formatting attributes of the selected cell to the empty adjacent cells.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockexprefcb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="exprefcb">
<property name="label" translatable="yes" context="scgeneralpage|exprefcb">Expand _references when new columns/rows are inserted</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="exprefcb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|exprefcb">Specifies whether to expand references when inserting columns or rows adjacent to the reference range. This is only possible if the reference range, where the column or row is inserted, originally spanned at least two cells in the desired direction.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="locksortrefupdatecb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="sortrefupdatecb">
<property name="label" translatable="yes" context="scgeneralpage|sortrefupdatecb">Update references when sorting range of cells</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">5</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockmarkhdrcb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="markhdrcb">
<property name="label" translatable="yes" context="scgeneralpage|markhdrcb">Highlight sele_ction in column/row headers</property>
@@ -448,111 +513,6 @@
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="sortrefupdatecb">
<property name="label" translatable="yes" context="scgeneralpage|sortrefupdatecb">Update references when sorting range of cells</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">5</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockaligncb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockeditmodecb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockenter_paste">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockformatcb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockexprefcb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkImage" id="locksortrefupdatecb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockmarkhdrcb">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockreplwarncb">
<property name="can-focus">False</property>
@@ -566,6 +526,26 @@
<property name="top-attach">7</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="replwarncb">
<property name="label" translatable="yes" context="scgeneralpage|replwarncb">Show overwrite _warning when pasting data</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="replwarncb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|replwarncb">Specifies that, when you paste cells from the clipboard to a cell range that is not empty, a warning appears.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="locklegacy_cell">
<property name="can-focus">False</property>
@@ -579,6 +559,26 @@
<property name="top-attach">8</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="legacy_cell_selection_cb">
<property name="label" translatable="yes" context="scgeneralpage|legacy_cell_selection_cb">Position cell reference with selection</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="legacy_cell_selection_cb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|legacy_cell_selection_cb">With the option set, expanding a selection (with Ctrl + Shift + Down/Up) jumps to the end of the range in the column that was added as last to the initial selection. When the option is not set, expanding a selection (with Ctrl + Shift + Down/Up) jumps to the end of the range in the column where selecting the cell range was started. The same of course applies when extending a selection on rows, with Ctrl + Shift + Left/Right.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockwarnactivesheet">
<property name="can-focus">False</property>