include/vcl/weld/Builder.hxx          |   57 ++++++++++++++++++++++++++++++++--
 include/vcl/weld/DialogController.hxx |   32 +++++++++++--------
 vcl/Library_vcl.mk                    |    1 
 vcl/inc/qt5/QtInstanceBuilder.hxx     |    2 -
 vcl/qt5/QtInstanceBuilder.cxx         |    6 ---
 vcl/source/weld/Builder.cxx           |   22 +++++++++++++
 vcl/source/weld/DialogController.cxx  |   35 ++++++++++++++++++++
 vcl/unx/gtk3/gtkinst.cxx              |    5 --
 8 files changed, 132 insertions(+), 28 deletions(-)

New commits:
commit b1b9d73274736472a011ae88309acdface65d643
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Dec 18 14:22:04 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 18 19:45:15 2025 +0100

    weld: Deduplicate Builder::weld_metric_spin_button impls
    
    The implementations in GtkInstanceBuilder and QtInstanceBuilder
    are the same.
    
    Move the logic to be the default implemenation in the base class
    and drop the overrides in those subclasses.
    
    Change-Id: I4547b0731d11acda13a888489a4425b9671b56b8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195846
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/include/vcl/weld/Builder.hxx b/include/vcl/weld/Builder.hxx
index df433f9fe91c..66d58da6f6b7 100644
--- a/include/vcl/weld/Builder.hxx
+++ b/include/vcl/weld/Builder.hxx
@@ -93,8 +93,7 @@ public:
     virtual std::unique_ptr<LinkButton> weld_link_button(const OUString& id) = 
0;
     virtual std::unique_ptr<SpinButton> weld_spin_button(const OUString& id) = 
0;
     virtual std::unique_ptr<MetricSpinButton> weld_metric_spin_button(const 
OUString& id,
-                                                                      
FieldUnit eUnit)
-        = 0;
+                                                                      
FieldUnit eUnit);
     virtual std::unique_ptr<FormattedSpinButton> 
weld_formatted_spin_button(const OUString& id) = 0;
     virtual std::unique_ptr<ComboBox> weld_combo_box(const OUString& id) = 0;
     virtual std::unique_ptr<TreeView> weld_tree_view(const OUString& id) = 0;
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 2a284fcc8087..f82f3bd5a02a 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -582,6 +582,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/uitest/uitest \
     vcl/source/uitest/uno/uiobject_uno \
     vcl/source/uitest/uno/uitest_uno \
+    vcl/source/weld/Builder \
     vcl/source/weld/DialogController \
     vcl/source/weld/EntryTreeView \
     vcl/source/weld/IconView \
diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx 
b/vcl/inc/qt5/QtInstanceBuilder.hxx
index 313019d82fa5..cf71e002c669 100644
--- a/vcl/inc/qt5/QtInstanceBuilder.hxx
+++ b/vcl/inc/qt5/QtInstanceBuilder.hxx
@@ -60,8 +60,6 @@ public:
     virtual std::unique_ptr<weld::Calendar> weld_calendar(const OUString& rId) 
override;
     virtual std::unique_ptr<weld::Entry> weld_entry(const OUString& rId) 
override;
     virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const OUString& 
rId) override;
-    virtual std::unique_ptr<weld::MetricSpinButton>
-    weld_metric_spin_button(const OUString& rId, FieldUnit eUnit) override;
     virtual std::unique_ptr<weld::FormattedSpinButton>
     weld_formatted_spin_button(const OUString& rId) override;
     virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OUString& 
rId) override;
diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index 375f8e3700db..71522e3e6cb8 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -612,12 +612,6 @@ std::unique_ptr<weld::SpinButton> 
QtInstanceBuilder::weld_spin_button(const OUSt
     return xRet;
 }
 
-std::unique_ptr<weld::MetricSpinButton>
-QtInstanceBuilder::weld_metric_spin_button(const OUString& rId, FieldUnit 
eUnit)
-{
-    return std::make_unique<weld::MetricSpinButton>(weld_spin_button(rId), 
eUnit);
-}
-
 std::unique_ptr<weld::FormattedSpinButton>
 QtInstanceBuilder::weld_formatted_spin_button(const OUString& rId)
 {
diff --git a/vcl/source/weld/Builder.cxx b/vcl/source/weld/Builder.cxx
new file mode 100644
index 000000000000..da6a4d773693
--- /dev/null
+++ b/vcl/source/weld/Builder.cxx
@@ -0,0 +1,22 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#include <vcl/weld/Builder.hxx>
+#include <vcl/weld/MetricSpinButton.hxx>
+
+namespace weld
+{
+std::unique_ptr<weld::MetricSpinButton> Builder::weld_metric_spin_button(const 
OUString& id,
+                                                                         
FieldUnit eUnit)
+{
+    return std::make_unique<weld::MetricSpinButton>(weld_spin_button(id), 
eUnit);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 43b96034b50c..ef0e83cfc7ef 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -24455,11 +24455,6 @@ public:
         return std::make_unique<GtkInstanceSpinButton>(pSpinButton, this, 
false);
     }
 
-    virtual std::unique_ptr<weld::MetricSpinButton> 
weld_metric_spin_button(const OUString& id, FieldUnit eUnit) override
-    {
-        return std::make_unique<weld::MetricSpinButton>(weld_spin_button(id), 
eUnit);
-    }
-
     virtual std::unique_ptr<weld::FormattedSpinButton> 
weld_formatted_spin_button(const OUString &id) override
     {
         GtkSpinButton* pSpinButton = 
GTK_SPIN_BUTTON(gtk_builder_get_object(m_pBuilder, OUStringToOString(id, 
RTL_TEXTENCODING_UTF8).getStr()));
commit 95d4a2fb889799b677679ac3828ce7dc6c1f72fd
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Dec 18 14:04:28 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 18 19:45:07 2025 +0100

    weld: Replace includes by fwd-decls in 2 central headers
    
    Builder.hxx and DialogController.hxx are included a lot, either
    directly or indirectly.
    
    No longer include the weld.hxx header for the widget
    classes in them, but use forward-declarations for the
    weld::Widget classes instead.
    
    While everything used to be defined in weld.hxx in the
    past, this will hopefully avoid some recompilations as
    weld::Widget subclasses are moving to their own headers,
    see e.g.
    
        commit 914b0509431b257b39d4c28e2c1fb0a9bfbdd4a5
        Author: Michael Weghorn <[email protected]>
        Date:   Wed Dec 17 10:02:28 2025 +0100
    
            weld: Move weld::IconView to its own header
    
    Move some DialogController logic from the
    header to the source file and include the relevant
    header there instead.
    
    Change-Id: Idb88197364ba17d40ca0661522bd50ed15f79466
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195845
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/include/vcl/weld/Builder.hxx b/include/vcl/weld/Builder.hxx
index 93d6efd9cd1e..df433f9fe91c 100644
--- a/include/vcl/weld/Builder.hxx
+++ b/include/vcl/weld/Builder.hxx
@@ -9,11 +9,63 @@
 
 #pragma once
 
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+#include <tools/fldunit.hxx>
 #include <vcl/dllapi.h>
-#include <vcl/weld/weld.hxx>
+#include <vcl/uitest/factory.hxx>
+
+#include <memory>
+
+namespace comphelper
+{
+class OAccessible;
+}
 
 namespace weld
 {
+class Assistant;
+class Box;
+class Button;
+class Calendar;
+class CheckButton;
+class ComboBox;
+class Container;
+class Dialog;
+class DrawingArea;
+class Entry;
+class EntryTreeView;
+class Expander;
+class FormattedSpinButton;
+class Frame;
+class Grid;
+class IconView;
+class Image;
+class Label;
+class LevelBar;
+class LinkButton;
+class Menu;
+class MenuButton;
+class MessageDialog;
+class MetricSpinButton;
+class Notebook;
+class Paned;
+class Popover;
+class ProgressBar;
+class RadioButton;
+class Scale;
+class Scrollbar;
+class ScrolledWindow;
+class SizeGroup;
+class SpinButton;
+class Spinner;
+class TextView;
+class ToggleButton;
+class Toolbar;
+class TreeView;
+class Widget;
+class Window;
+
 class VCL_DLLPUBLIC Builder
 {
 public:
diff --git a/include/vcl/weld/DialogController.hxx 
b/include/vcl/weld/DialogController.hxx
index eb4ae6e2a6d1..f6e97a009ff7 100644
--- a/include/vcl/weld/DialogController.hxx
+++ b/include/vcl/weld/DialogController.hxx
@@ -9,12 +9,20 @@
 
 #pragma once
 
+#include <rtl/ustring.hxx>
 #include <vcl/dllapi.h>
 #include <vcl/weld/Builder.hxx>
-#include <vcl/weld/weld.hxx>
+
+#include <functional>
 
 namespace weld
 {
+class Assistant;
+class Container;
+class Dialog;
+class MessageDialog;
+class Widget;
+
 class VCL_DLLPUBLIC DialogController : public 
std::enable_shared_from_this<DialogController>
 {
 public:
@@ -23,14 +31,14 @@ public:
     {
         return const_cast<DialogController*>(this)->getDialog();
     }
-    virtual short run() { return getDialog()->run(); }
+    virtual short run();
     static bool runAsync(const std::shared_ptr<DialogController>& rController,
                          const std::function<void(sal_Int32)>&);
-    void set_title(const OUString& rTitle) { getDialog()->set_title(rTitle); }
-    OUString get_title() const { return getConstDialog()->get_title(); }
-    void set_help_id(const OUString& rHelpId) { 
getDialog()->set_help_id(rHelpId); }
-    OUString get_help_id() const { return getConstDialog()->get_help_id(); }
-    void response(int nResponse) { getDialog()->response(nResponse); }
+    void set_title(const OUString& rTitle);
+    OUString get_title() const;
+    void set_help_id(const OUString& rHelpId);
+    OUString get_help_id() const;
+    void response(int nResponse);
     virtual ~DialogController();
 };
 
@@ -71,11 +79,11 @@ public:
                             const OUString& rDialogId, const OUString& 
rRelocateId = {});
     virtual Dialog* getDialog() override;
     virtual ~MessageDialogController() override;
-    void set_primary_text(const OUString& rText) { 
m_xDialog->set_primary_text(rText); }
-    OUString get_primary_text() const { return m_xDialog->get_primary_text(); }
-    void set_secondary_text(const OUString& rText) { 
m_xDialog->set_secondary_text(rText); }
-    OUString get_secondary_text() const { return 
m_xDialog->get_secondary_text(); }
-    void set_default_response(int nResponse) { 
m_xDialog->set_default_response(nResponse); }
+    void set_primary_text(const OUString& rText);
+    OUString get_primary_text() const;
+    void set_secondary_text(const OUString& rText);
+    OUString get_secondary_text() const;
+    void set_default_response(int nResponse);
 };
 
 class VCL_DLLPUBLIC AssistantController : public DialogController
diff --git a/vcl/source/weld/DialogController.cxx 
b/vcl/source/weld/DialogController.cxx
index c3d66114e70a..08192d10cc09 100644
--- a/vcl/source/weld/DialogController.cxx
+++ b/vcl/source/weld/DialogController.cxx
@@ -9,15 +9,28 @@
 
 #include <vcl/svapp.hxx>
 #include <vcl/weld/DialogController.hxx>
+#include <vcl/weld/weld.hxx>
 
 namespace weld
 {
+short DialogController::run() { return getDialog()->run(); }
+
 bool DialogController::runAsync(const std::shared_ptr<DialogController>& 
rController,
                                 const std::function<void(sal_Int32)>& func)
 {
     return rController->getDialog()->runAsync(rController, func);
 }
 
+void DialogController::set_title(const OUString& rTitle) { 
getDialog()->set_title(rTitle); }
+
+OUString DialogController::get_title() const { return 
getConstDialog()->get_title(); }
+
+void DialogController::set_help_id(const OUString& rHelpId) { 
getDialog()->set_help_id(rHelpId); }
+
+OUString DialogController::get_help_id() const { return 
getConstDialog()->get_help_id(); }
+
+void DialogController::response(int nResponse) { 
getDialog()->response(nResponse); }
+
 DialogController::~DialogController() {}
 
 Dialog* GenericDialogController::getDialog() { return m_xDialog.get(); }
@@ -50,6 +63,28 @@ 
MessageDialogController::MessageDialogController(weld::Widget* pParent, const OU
     }
 }
 
+void MessageDialogController::set_primary_text(const OUString& rText)
+{
+    m_xDialog->set_primary_text(rText);
+}
+
+OUString MessageDialogController::get_primary_text() const { return 
m_xDialog->get_primary_text(); }
+
+void MessageDialogController::set_secondary_text(const OUString& rText)
+{
+    m_xDialog->set_secondary_text(rText);
+}
+
+OUString MessageDialogController::get_secondary_text() const
+{
+    return m_xDialog->get_secondary_text();
+}
+
+void MessageDialogController::set_default_response(int nResponse)
+{
+    m_xDialog->set_default_response(nResponse);
+}
+
 MessageDialogController::~MessageDialogController()
 {
     if (m_xRelocate)

Reply via email to