sw/uiconfig/swriter/ui/rowheight.ui  |   71 ++++++++++++++++-------------------
 vcl/inc/qt5/QtDoubleSpinBox.hxx      |    8 +--
 vcl/inc/qt5/QtInstanceSpinButton.hxx |    5 ++
 vcl/qt5/QtDoubleSpinBox.cxx          |    9 +---
 vcl/qt5/QtInstanceBuilder.cxx        |    1 
 vcl/qt5/QtInstanceSpinButton.cxx     |   15 ++++++-
 6 files changed, 61 insertions(+), 48 deletions(-)

New commits:
commit 7b0bcaf5a1fc48335056c5f62af67bda434e9bc2
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Feb 17 14:15:52 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Feb 18 08:59:18 2025 +0100

    sw: Resave rowheight.ui with glade 3.40
    
    To trigger the dialog:
    
    * start Writer
    * insert table via "Table" -> "Insert
    * move cursor into a table cell
    * "Table" -> "Size" -> "Row Height"
    
    Change-Id: I1bda3b0647b082c048b491978f79da9cf44af4f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181786
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sw/uiconfig/swriter/ui/rowheight.ui 
b/sw/uiconfig/swriter/ui/rowheight.ui
index 23e68e32f1d3..d687412ad40e 100644
--- a/sw/uiconfig/swriter/ui/rowheight.ui
+++ b/sw/uiconfig/swriter/ui/rowheight.ui
@@ -1,39 +1,39 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.36.0 -->
+<!-- Generated with glade 3.40.0 -->
 <interface domain="sw">
   <requires lib="gtk+" version="3.20"/>
   <object class="GtkAdjustment" id="adjustment1">
     <property name="lower">0.01</property>
     <property name="upper">99</property>
     <property name="value">0.01</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
+    <property name="step-increment">1</property>
+    <property name="page-increment">10</property>
   </object>
   <object class="GtkDialog" id="RowHeightDialog">
-    <property name="can_focus">False</property>
-    <property name="border_width">6</property>
+    <property name="can-focus">False</property>
+    <property name="border-width">6</property>
     <property name="title" translatable="yes" 
context="rowheight|RowHeightDialog">Row Height</property>
     <property name="modal">True</property>
-    <property name="default_width">0</property>
-    <property name="default_height">0</property>
-    <property name="type_hint">dialog</property>
+    <property name="default-width">0</property>
+    <property name="default-height">0</property>
+    <property name="type-hint">dialog</property>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">12</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
+            <property name="can-focus">False</property>
+            <property name="layout-style">end</property>
             <child>
               <object class="GtkButton" id="ok">
                 <property name="label" translatable="yes" 
context="stock">_OK</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
+                <property name="can-focus">True</property>
+                <property name="can-default">True</property>
+                <property name="has-default">True</property>
+                <property name="receives-default">True</property>
                 <property name="use-underline">True</property>
               </object>
               <packing>
@@ -46,8 +46,8 @@
               <object class="GtkButton" id="cancel">
                 <property name="label" translatable="yes" 
context="stock">_Cancel</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
                 <property name="use-underline">True</property>
               </object>
               <packing>
@@ -60,8 +60,8 @@
               <object class="GtkButton" id="help">
                 <property name="label" translatable="yes" 
context="stock">_Help</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
                 <property name="use-underline">True</property>
               </object>
               <packing>
@@ -75,33 +75,33 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="pack_type">end</property>
+            <property name="pack-type">end</property>
             <property name="position">0</property>
           </packing>
         </child>
         <child>
           <object class="GtkFrame" id="frame1">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label_xalign">0</property>
-            <property name="shadow_type">none</property>
+            <property name="can-focus">False</property>
+            <property name="label-xalign">0</property>
+            <property name="shadow-type">none</property>
             <child>
               <object class="GtkBox" id="box1">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">6</property>
+                <property name="can-focus">False</property>
                 <property name="margin-start">12</property>
                 <property name="margin-top">6</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">6</property>
                 <child>
                   <object class="GtkSpinButton" id="heightmf">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
+                    <property name="can-focus">True</property>
                     <property name="halign">start</property>
-                    <property name="activates_default">True</property>
+                    <property name="activates-default">True</property>
+                    <property name="truncate-multiline">True</property>
                     <property name="adjustment">adjustment1</property>
                     <property name="digits">2</property>
-                    <property name="truncate-multiline">True</property>
                     <child internal-child="accessible">
                       <object class="AtkObject" id="heightmf-atkobject">
                         <property name="AtkObject::accessible-description" 
translatable="yes" context="rowheight|extended_tip|heightmf">Enter the height 
that you want for the selected row(s).</property>
@@ -118,10 +118,10 @@
                   <object class="GtkCheckButton" id="fit">
                     <property name="label" translatable="yes" 
context="rowheight|fit">_Fit to size</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>
+                    <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="fit-atkobject">
                         <property name="AtkObject::accessible-description" 
translatable="yes" context="rowheight|extended_tip|fit">Automatically adjusts 
the row height to match the contents of the cells.</property>
@@ -139,7 +139,7 @@
             <child type="label">
               <object class="GtkLabel" id="label1">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can-focus">False</property>
                 <property name="label" translatable="yes" 
context="rowheight|label1">Height</property>
                 <attributes>
                   <attribute name="weight" value="bold"/>
@@ -160,9 +160,6 @@
       <action-widget response="-6">cancel</action-widget>
       <action-widget response="-11">help</action-widget>
     </action-widgets>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
     <child internal-child="accessible">
       <object class="AtkObject" id="RowHeightDialog-atkobject">
         <property name="AtkObject::accessible-description" translatable="yes" 
context="rowheight|extended_tip|RowHeightDialog">Changes the height of the 
selected row(s).</property>
commit 8895c5c7447bb1b0eb53846c2f1dbfa69323338c
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Feb 17 14:10:45 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Feb 18 08:59:11 2025 +0100

    tdf#130857 qt weld: Support sw "Row Height" dialog
    
    This means that native Qt widgets are used for that dialog
    now when using the qt5 or qt6 VCL plugin and starting LO with
    environment variable SAL_VCL_QT_USE_WELDED_WIDGETS=1 set.
    
    To trigger the dialog:
    
    * start Writer
    * insert table via "Table" -> "Insert
    * move cursor into a table cell
    * "Table" -> "Size" -> "Row Height"
    
    Change-Id: Ifd69687611919d476ae99f3dc4f6f1c087ca07cf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181784
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index f76dfbe60495..cd6e36fcbc85 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -96,6 +96,7 @@ bool QtInstanceBuilder::IsUIFileSupported(const OUString& 
rUIFile)
         u"modules/swriter/ui/insertbreak.ui"_ustr,
         u"modules/swriter/ui/printoptionspage.ui"_ustr,
         u"modules/swriter/ui/renameobjectdialog.ui"_ustr,
+        u"modules/swriter/ui/rowheight.ui"_ustr,
         u"modules/swriter/ui/splittable.ui"_ustr,
         u"modules/swriter/ui/wordcount.ui"_ustr,
         u"sfx/ui/helpmanual.ui"_ustr,
commit 773c7a4946bd18c1e83c710ee50775065b1fbb4f
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Feb 17 13:52:53 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Feb 18 08:59:05 2025 +0100

    tdf#130857 qt weld: Adjust value <-> text conversion to use double
    
    Until recently, the QtInstanceSpinButton implementation didn't
    take into account that the sal_Int64 values used in the weld::SpinButton
    API cannot simply be used as floating point values as they are, but need
    to be converted first, based on the result of
    `weld::SpinButton::get_digits()`.
    
    With
    
        Change-Id: I31bc2b95b46bae8174388cddc9a383ed61e6763e
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Mon Feb 17 13:10:16 2025 +0100
    
            tdf#130857 Pass double values to/from weld::SpinButton subclasses
    
    in place, the base class now already takes care of that conversion in most
    places.
    
    However, QtDoubleSpinBox::textFromValue and
    QtDoubleSpinBox::valueFromText were still passing/using
    values as they were.
    
    Adjust these to do conversion as well, by implementing
    the required logic in QtInstanceSpinButton (convert
    using weld::SpinButton::convert_value_to_double and
    weld::SpinButton::convert_double_to_value) and passing
    corresponding functions to
    QtDoubleSpinBox::set{FormatValue,ParseText}Function.
    
    Change-Id: Ib498c63f6164054909a260ecb12283182ac8ba98
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181783
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/qt5/QtDoubleSpinBox.hxx b/vcl/inc/qt5/QtDoubleSpinBox.hxx
index 1eaaefe54751..2ebb97c3d1e9 100644
--- a/vcl/inc/qt5/QtDoubleSpinBox.hxx
+++ b/vcl/inc/qt5/QtDoubleSpinBox.hxx
@@ -24,8 +24,8 @@ class QtDoubleSpinBox : public QDoubleSpinBox
 {
     Q_OBJECT
 
-    std::function<std::optional<OUString>(int)> m_aFormatValueFunction;
-    std::function<TriState(const OUString&, int*)> m_aParseTextFunction;
+    std::function<std::optional<OUString>(double)> m_aFormatValueFunction;
+    std::function<std::optional<double>(const QString&)> m_aParseTextFunction;
 
 public:
     QtDoubleSpinBox(QWidget* pParent);
@@ -36,12 +36,12 @@ public:
     virtual QString textFromValue(double fValue) const override;
     virtual double valueFromText(const QString& rText) const override;
 
-    void setFormatValueFunction(std::function<std::optional<OUString>(int)> 
aFunction)
+    void setFormatValueFunction(std::function<std::optional<OUString>(double)> 
aFunction)
     {
         m_aFormatValueFunction = aFunction;
     }
 
-    void setParseTextFunction(std::function<TriState(const OUString&, int*)> 
aFunction)
+    void setParseTextFunction(std::function<std::optional<double>(const 
QString&)> aFunction)
     {
         m_aParseTextFunction = aFunction;
     }
diff --git a/vcl/inc/qt5/QtInstanceSpinButton.hxx 
b/vcl/inc/qt5/QtInstanceSpinButton.hxx
index a4cc48925347..4664a3fcf5c7 100644
--- a/vcl/inc/qt5/QtInstanceSpinButton.hxx
+++ b/vcl/inc/qt5/QtInstanceSpinButton.hxx
@@ -14,6 +14,8 @@
 
 #include <QtWidgets/QSpinBox>
 
+#include <optional>
+
 class QtInstanceSpinButton : public QtInstanceEntry, public virtual 
weld::SpinButton
 {
     Q_OBJECT
@@ -35,6 +37,9 @@ public:
     virtual void set_digits(unsigned int nDigits) override;
     virtual unsigned int get_digits() const override;
 
+private:
+    std::optional<double> convertTextToDouble(const QString& rText);
+
 private Q_SLOTS:
     void handleValueChanged();
 };
diff --git a/vcl/qt5/QtDoubleSpinBox.cxx b/vcl/qt5/QtDoubleSpinBox.cxx
index 8936145984ed..58214e7e05e5 100644
--- a/vcl/qt5/QtDoubleSpinBox.cxx
+++ b/vcl/qt5/QtDoubleSpinBox.cxx
@@ -26,7 +26,7 @@ QString QtDoubleSpinBox::textFromValue(double fValue) const
 {
     if (m_aFormatValueFunction)
     {
-        std::optional<OUString> aText = 
m_aFormatValueFunction(std::round(fValue));
+        std::optional<OUString> aText = m_aFormatValueFunction(fValue);
         if (aText.has_value())
             return toQString(aText.value());
     }
@@ -38,10 +38,9 @@ double QtDoubleSpinBox::valueFromText(const QString& rText) 
const
 {
     if (m_aParseTextFunction)
     {
-        int nValue = 0;
-        TriState eState = m_aParseTextFunction(toOUString(rText), &nValue);
-        if (eState == TRISTATE_TRUE)
-            return nValue;
+        std::optional<double> aValue = m_aParseTextFunction(rText);
+        if (aValue.has_value())
+            return aValue.value();
     }
 
     return QDoubleSpinBox::valueFromText(rText);
diff --git a/vcl/qt5/QtInstanceSpinButton.cxx b/vcl/qt5/QtInstanceSpinButton.cxx
index 2b8331506ca3..fc35b30ebff2 100644
--- a/vcl/qt5/QtInstanceSpinButton.cxx
+++ b/vcl/qt5/QtInstanceSpinButton.cxx
@@ -35,9 +35,10 @@ QtInstanceSpinButton::QtInstanceSpinButton(QtDoubleSpinBox* 
pSpinBox)
             &QtInstanceSpinButton::handleTextChanged);
 
     // set functions to convert between value and formatted text
-    m_pSpinBox->setFormatValueFunction([this](int nValue) { return 
format_value(nValue); });
+    m_pSpinBox->setFormatValueFunction(
+        [this](double fValue) { return 
format_value(convert_double_to_value(fValue)); });
     m_pSpinBox->setParseTextFunction(
-        [this](const OUString& rText, int* pResult) { return parse_text(rText, 
pResult); });
+        [this](const QString& rText) { return convertTextToDouble(rText); });
 }
 
 QWidget* QtInstanceSpinButton::getQWidget() const { return m_pSpinBox; }
@@ -106,6 +107,16 @@ unsigned int QtInstanceSpinButton::get_digits() const
     return nDigits;
 }
 
+std::optional<double> QtInstanceSpinButton::convertTextToDouble(const QString& 
rText)
+{
+    int nValue = 0;
+    TriState eState = parse_text(toOUString(rText), &nValue);
+    if (eState == TRISTATE_TRUE)
+        return std::optional<double>(convert_value_to_double(nValue));
+
+    return {};
+}
+
 void QtInstanceSpinButton::handleValueChanged()
 {
     SolarMutexGuard aGuard;

Reply via email to