vcl/CustomTarget_qt5_moc.mk         |    1 
 vcl/CustomTarget_qt6_moc.mk         |    1 
 vcl/Library_vclplug_qt5.mk          |    1 
 vcl/Library_vclplug_qt6.mk          |    1 
 vcl/inc/qt5/QtBuilder.hxx           |    8 +-
 vcl/inc/qt5/QtInstanceContainer.hxx |    4 -
 vcl/inc/qt5/QtInstanceGrid.hxx      |   33 ++++++++++
 vcl/inc/qt6/QtInstanceGrid.hxx      |   12 +++
 vcl/qt5/QtBuilder.cxx               |   13 ++--
 vcl/qt5/QtInstanceBuilder.cxx       |   23 +++----
 vcl/qt5/QtInstanceContainer.cxx     |    2 
 vcl/qt5/QtInstanceGrid.cxx          |  117 ++++++++++++++++++++++++++++++++++++
 vcl/qt6/QtInstanceGrid.cxx          |   12 +++
 13 files changed, 204 insertions(+), 24 deletions(-)

New commits:
commit 111edc82743369fd1557784566a46c8e03dc4bbd
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 18 20:46:32 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 19 08:28:27 2024 +0100

    tdf#130857 qt weld: Map ID to to parent QWidget for layouts
    
    QBoxLayout (created for "GtkBox" in .ui files) and QGridLayout
    (created for "GtkGrid" in .ui files) are QLayout subclasses,
    not QWidgets.
    
    So far, QtBuilder::m_aChildren was containing QObjects
    that could be either QWidgets or QLayouts.
    
    QtInstanceBuilder::weld_container and QtInstanceBuilder::weld_grid
    were retrieving the corresponding QLayout using QtBuilder::get,
    all other QtInstanceBuilder::weld_* methods the corresponding
    QWidget.
    
    However, for a "GtkBox" or "GtkGrid", it's not only possible
    to call QtInstanceBuilder::weld_container or
    QtInstanceBuilder::weld_grid, but it's also possible
    to just get a pointer to the weld::Widget subclass by calling
    QtInstanceBuilder::weld_widget with the ID of the grid/box.
    
    So far, this would have resulted in QtInstanceBuilder::weld_widget
    calling QtBuilder::get<QWidget>, in which case the latter
    would incorrectly `static_cast` the QLayout to a QWidget.
    
    Since
    
        commit bf42162fc50d0c6f8e567d8765f8b14b96d7cc50
        Author: Michael Weghorn <[email protected]>
        Date:   Mon Nov 4 19:06:15 2024 +0100
    
            tdf#130857 qt weld: Add extra QWidget parents for layouts
    
    , extra parent widgets for the layouts (except for the top-level
    ones in dialogs) are created. Insert these into QtBuilder::m_aChildren
    instead and retrieve them by the ID, which allows to uniformly use
    QWidget. Adjust QtInstanceBuilder::weld_{container,grid} accordingly.
    (Special handling for top-level layouts in containers can
    still be added as needed later.)
    
    This fixes an assert seen in a WIP branch where suport
    for the FontFeaturesDialog (open context menu for paragraph in Writer,
    select "Character" -> "Character" to open the "Character" dialog,
    in the "Font" tab, click on the "Features" button) is declared.
    
    Backtrace, where FontFeaturesDialog::m_xContainer is a weld::Widget
    referring to the "fontentry" GtkGrid in
    cui/uiconfig/ui/fontfragment.ui:
    
        1 __pthread_kill_implementation pthread_kill.c 44 0x7ffff789dc8c
        2 __pthread_kill_internal pthread_kill.c 78 0x7ffff789dcef
        3 __GI_raise raise.c 26 0x7ffff7849c42
        4 __GI_abort abort.c 79 0x7ffff78324f0
        5 __assert_fail_base assert.c 94 0x7ffff7832418
        6 __assert_fail assert.c 103 0x7ffff7842552
        7 QtInstanceGrid::set_child_left_attach(weld::Widget&, 
int)::$_0::operator()() const QtInstanceGrid.cxx 25 0x7fffe438b5e1
        8 std::__invoke_impl<void, 
QtInstanceGrid::set_child_left_attach(weld::Widget&, 
int)::$_0&>(std::__invoke_other, 
QtInstanceGrid::set_child_left_attach(weld::Widget&, int)::$_0&) invoke.h 61 
0x7fffe438b4f5
        9 std::__invoke_r<void, 
QtInstanceGrid::set_child_left_attach(weld::Widget&, 
int)::$_0&>(QtInstanceGrid::set_child_left_attach(weld::Widget&, int)::$_0&) 
invoke.h 111 0x7fffe438b4b5
        10 std::_Function_handler<void(), 
QtInstanceGrid::set_child_left_attach(weld::Widget&, int)::$_0>::_M_invoke 
std_function.h 290 0x7fffe438b39d
        11 std::function<void()>::operator() std_function.h 591 0x7fffe4345aee
        12 QtInstance::RunInMainThread QtInstance.cxx 226 0x7fffe433d67a
        13 QtInstanceGrid::set_child_left_attach QtInstanceGrid.cxx 23 
0x7fffe438aa63
        14 cui::FontFeaturesDialog::fillGrid FontFeaturesDialog.cxx 142 
0x7fff6db25fb1
        15 cui::FontFeaturesDialog::initialize FontFeaturesDialog.cxx 73 
0x7fff6db2541d
        16 cui::FontFeaturesDialog::FontFeaturesDialog FontFeaturesDialog.cxx 
35 0x7fff6db24f61
        17 SvxCharNamePage::FontFeatureButtonClicked chardlg.cxx 1154 
0x7fff6de651d1
        18 SvxCharNamePage::LinkStubFontFeatureButtonClicked chardlg.cxx 1131 
0x7fff6de5fa7d
        19 Link<weld::Button&, void>::Call link.hxx 111 0x7fffeec54551
        20 weld::Button::signal_clicked weld.hxx 1558 0x7fffeec3078c
        21 SalInstanceButton::ClickHdl salvtables.cxx 2955 0x7fffeec018ee
        22 SalInstanceButton::LinkStubClickHdl salvtables.cxx 2943 
0x7fffeec00e2d
        23 Link<Button *, void>::Call link.hxx 111 0x7fffee508da1
        24 Button::Click()::$_0::operator()() const button.cxx 130 
0x7fffee5005f2
        ...
    
    Change-Id: I7901b9085f887acef7b5505eef0baa792816cd0d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178752
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/inc/qt5/QtBuilder.hxx b/vcl/inc/qt5/QtBuilder.hxx
index aaed05ef434e..db4505902380 100644
--- a/vcl/inc/qt5/QtBuilder.hxx
+++ b/vcl/inc/qt5/QtBuilder.hxx
@@ -27,14 +27,14 @@
 class QtBuilder : public WidgetBuilder<QObject, QObject*, QMenu, QMenu*>
 {
 private:
-    QObject* get_by_name(std::u16string_view sID);
+    QWidget* get_by_name(std::u16string_view sID);
     struct WinAndId
     {
         OUString m_sID;
-        QObject* m_pWindow;
-        WinAndId(OUString sId, QObject* pWindow)
+        QWidget* m_pWidget;
+        WinAndId(OUString sId, QWidget* pWidget)
             : m_sID(std::move(sId))
-            , m_pWindow(pWindow)
+            , m_pWidget(pWidget)
         {
         }
     };
diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 85ad02384437..24accdb4203e 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -59,12 +59,12 @@ QtBuilder::QtBuilder(QObject* pParent, std::u16string_view 
sUIRoot, const OUStri
 
 QtBuilder::~QtBuilder() {}
 
-QObject* QtBuilder::get_by_name(std::u16string_view sID)
+QWidget* QtBuilder::get_by_name(std::u16string_view sID)
 {
     for (auto const& child : m_aChildren)
     {
         if (child.m_sID == sID)
-            return child.m_pWindow;
+            return child.m_pWidget;
     }
 
     return nullptr;
@@ -397,7 +397,8 @@ QObject* QtBuilder::makeObject(QObject* pParent, 
std::u16string_view sName, std:
             pParentGridLayout->addLayout(pLayout, 
pParentGridLayout->rowCount(), 0);
     }
 
-    m_aChildren.emplace_back(sID, pObject);
+    if (pWidget)
+        m_aChildren.emplace_back(sID, pWidget);
 
     return pObject;
 }
@@ -492,12 +493,12 @@ void QtBuilder::tweakInsertedChild(QObject* pParent, 
QObject* pCurrentChild, std
 void QtBuilder::setMnemonicWidget(const OUString& rLabelId, const OUString& 
rMnemonicWidgetId)
 {
     QLabel* pLabel = get<QLabel>(rLabelId);
-    QObject* pBuddy = get_by_name(rMnemonicWidgetId);
+    QWidget* pBuddy = get_by_name(rMnemonicWidgetId);
 
-    if (!pLabel || !pBuddy || !pBuddy->isWidgetType())
+    if (!pLabel || !pBuddy)
         return;
 
-    pLabel->setBuddy(static_cast<QWidget*>(pBuddy));
+    pLabel->setBuddy(pBuddy);
 }
 
 void QtBuilder::setRadioButtonGroup(const OUString& rRadioButtonId, const 
OUString& rRadioGroupId)
diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index b76a0ad344d6..b253f53fd6a9 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -136,16 +136,12 @@ std::unique_ptr<weld::Widget> 
QtInstanceBuilder::weld_widget(const OUString& rId
 
 std::unique_ptr<weld::Container> QtInstanceBuilder::weld_container(const 
OUString& rId)
 {
-    QLayout* pLayout = m_xBuilder->get<QLayout>(rId);
-    if (!pLayout)
+    QWidget* pWidget = m_xBuilder->get<QWidget>(rId);
+    if (!pWidget)
         return nullptr;
 
-    QWidget* pParentWidget = pLayout->parentWidget();
-    assert(pParentWidget && pParentWidget == pLayout->parent()
-           && "layout has no direct widget parent");
-    std::unique_ptr<weld::Container> xRet(
-        pParentWidget ? std::make_unique<QtInstanceContainer>(pParentWidget) : 
nullptr);
-    return xRet;
+    assert(pWidget->layout() && "no layout");
+    return std::make_unique<QtInstanceContainer>(pWidget);
 }
 
 std::unique_ptr<weld::Box> QtInstanceBuilder::weld_box(const OUString&)
@@ -156,16 +152,12 @@ std::unique_ptr<weld::Box> 
QtInstanceBuilder::weld_box(const OUString&)
 
 std::unique_ptr<weld::Grid> QtInstanceBuilder::weld_grid(const OUString& rId)
 {
-    QGridLayout* pLayout = m_xBuilder->get<QGridLayout>(rId);
-    if (!pLayout)
+    QWidget* pWidget = m_xBuilder->get<QWidget>(rId);
+    if (!pWidget)
         return nullptr;
 
-    QWidget* pParentWidget = pLayout->parentWidget();
-    assert(pParentWidget && pParentWidget == pLayout->parent()
-           && "layout has no direct widget parent");
-    std::unique_ptr<weld::Grid> xRet(pParentWidget ? 
std::make_unique<QtInstanceGrid>(pParentWidget)
-                                                   : nullptr);
-    return xRet;
+    assert(qobject_cast<QGridLayout*>(pWidget->layout()) && "no grid layout");
+    return std::make_unique<QtInstanceGrid>(pWidget);
 }
 
 std::unique_ptr<weld::Paned> QtInstanceBuilder::weld_paned(const OUString&)
commit fb3f9d72d102dcfde93d32660ebb59a4bb75a5b3
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 18 16:48:13 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 19 08:28:18 2024 +0100

    tdf#130857 qt weld: Introduce QtInstanceGrid
    
    ... as the weld::Grid implementation using
    native Qt widgets.
    
    This adds an implementation of the API
    newly added in
    
        commit 7056ea9c29c7e454c21b525e61cdc1e0c03f7301
        Author: Michael Weghorn <[email protected]>
        Date:   Mon Dec 16 11:02:00 2024 +0100
    
            weld: Add weld::Grid to handle grid child positions
    
    Change-Id: I3db89aa9fe2986dfa7fc617440f530334d029bc6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178733
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk
index 2c6c566fe8ac..5674b2b64ac0 100644
--- a/vcl/CustomTarget_qt5_moc.mk
+++ b/vcl/CustomTarget_qt5_moc.mk
@@ -23,6 +23,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceDrawingArea.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceEntry.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceExpander.moc \
+       $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceGrid.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceIconView.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceImage.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLabel.moc \
diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk
index f0f37b049eef..8a6c4369bd0e 100644
--- a/vcl/CustomTarget_qt6_moc.mk
+++ b/vcl/CustomTarget_qt6_moc.mk
@@ -23,6 +23,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceDrawingArea.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceEntry.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceExpander.moc \
+       $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceGrid.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceIconView.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceImage.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLabel.moc \
diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk
index 38a667c5d896..c2a7a9e292df 100644
--- a/vcl/Library_vclplug_qt5.mk
+++ b/vcl/Library_vclplug_qt5.mk
@@ -109,6 +109,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
     vcl/qt5/QtInstanceEntry \
     vcl/qt5/QtInstanceExpander \
     vcl/qt5/QtInstanceFrame \
+    vcl/qt5/QtInstanceGrid \
     vcl/qt5/QtInstanceIconView \
     vcl/qt5/QtInstanceImage \
     vcl/qt5/QtInstanceLabel \
diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk
index e6d8c893387f..3bf1f72e4058 100644
--- a/vcl/Library_vclplug_qt6.mk
+++ b/vcl/Library_vclplug_qt6.mk
@@ -108,6 +108,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\
     vcl/qt6/QtInstanceEntry \
     vcl/qt6/QtInstanceExpander \
     vcl/qt6/QtInstanceFrame \
+    vcl/qt6/QtInstanceGrid \
     vcl/qt6/QtInstanceIconView \
     vcl/qt6/QtInstanceImage \
     vcl/qt6/QtInstanceLabel \
diff --git a/vcl/inc/qt5/QtInstanceContainer.hxx 
b/vcl/inc/qt5/QtInstanceContainer.hxx
index 8fea34cd8d74..41f7e31438de 100644
--- a/vcl/inc/qt5/QtInstanceContainer.hxx
+++ b/vcl/inc/qt5/QtInstanceContainer.hxx
@@ -28,8 +28,8 @@ public:
 
     virtual void connect_container_focus_changed(const Link<Container&, void>& 
rLink) override;
 
-private:
-    QLayout& getLayout();
+protected:
+    virtual QLayout& getLayout() const;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/inc/qt5/QtInstanceGrid.hxx b/vcl/inc/qt5/QtInstanceGrid.hxx
new file mode 100644
index 000000000000..0e0bed771b6d
--- /dev/null
+++ b/vcl/inc/qt5/QtInstanceGrid.hxx
@@ -0,0 +1,33 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include "QtInstanceContainer.hxx"
+
+#include <QtWidgets/QGridLayout>
+
+class QtInstanceGrid : public QtInstanceContainer, public virtual weld::Grid
+{
+    Q_OBJECT
+
+public:
+    QtInstanceGrid(QWidget* pWidget);
+
+    virtual void set_child_left_attach(weld::Widget& rWidget, int nAttach) 
override;
+    virtual int get_child_left_attach(weld::Widget& rWidget) const override;
+    virtual void set_child_column_span(weld::Widget& rWidget, int nCols) 
override;
+    virtual void set_child_top_attach(weld::Widget& rWidget, int nAttach) 
override;
+    virtual int get_child_top_attach(weld::Widget& rWidget) const override;
+
+protected:
+    virtual QGridLayout& getLayout() const override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/inc/qt6/QtInstanceGrid.hxx b/vcl/inc/qt6/QtInstanceGrid.hxx
new file mode 100644
index 000000000000..2859bdd536bc
--- /dev/null
+++ b/vcl/inc/qt6/QtInstanceGrid.hxx
@@ -0,0 +1,12 @@
+/* -*- 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 "../qt5/QtInstanceGrid.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index 342986862de4..b76a0ad344d6 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -18,6 +18,7 @@
 #include <QtInstanceEntry.hxx>
 #include <QtInstanceExpander.hxx>
 #include <QtInstanceFrame.hxx>
+#include <QtInstanceGrid.hxx>
 #include <QtInstanceImage.hxx>
 #include <QtInstanceLabel.hxx>
 #include <QtInstanceLevelBar.hxx>
@@ -153,10 +154,18 @@ std::unique_ptr<weld::Box> 
QtInstanceBuilder::weld_box(const OUString&)
     return nullptr;
 }
 
-std::unique_ptr<weld::Grid> QtInstanceBuilder::weld_grid(const OUString&)
+std::unique_ptr<weld::Grid> QtInstanceBuilder::weld_grid(const OUString& rId)
 {
-    assert(false && "Not implemented yet");
-    return nullptr;
+    QGridLayout* pLayout = m_xBuilder->get<QGridLayout>(rId);
+    if (!pLayout)
+        return nullptr;
+
+    QWidget* pParentWidget = pLayout->parentWidget();
+    assert(pParentWidget && pParentWidget == pLayout->parent()
+           && "layout has no direct widget parent");
+    std::unique_ptr<weld::Grid> xRet(pParentWidget ? 
std::make_unique<QtInstanceGrid>(pParentWidget)
+                                                   : nullptr);
+    return xRet;
 }
 
 std::unique_ptr<weld::Paned> QtInstanceBuilder::weld_paned(const OUString&)
diff --git a/vcl/qt5/QtInstanceContainer.cxx b/vcl/qt5/QtInstanceContainer.cxx
index 4c2f8001f58f..a3f431444d4c 100644
--- a/vcl/qt5/QtInstanceContainer.cxx
+++ b/vcl/qt5/QtInstanceContainer.cxx
@@ -55,7 +55,7 @@ void 
QtInstanceContainer::connect_container_focus_changed(const Link<Container&,
     weld::Container::connect_container_focus_changed(rLink);
 }
 
-QLayout& QtInstanceContainer::getLayout()
+QLayout& QtInstanceContainer::getLayout() const
 {
     QLayout* pLayout = getQWidget()->layout();
     assert(pLayout);
diff --git a/vcl/qt5/QtInstanceGrid.cxx b/vcl/qt5/QtInstanceGrid.cxx
new file mode 100644
index 000000000000..fd882bea779a
--- /dev/null
+++ b/vcl/qt5/QtInstanceGrid.cxx
@@ -0,0 +1,117 @@
+/* -*- 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 <QtInstanceGrid.hxx>
+#include <QtInstanceGrid.moc>
+
+QtInstanceGrid::QtInstanceGrid(QWidget* pWidget)
+    : QtInstanceContainer(pWidget)
+{
+    assert(qobject_cast<QGridLayout*>(pWidget->layout()) && "no grid layout");
+}
+
+void QtInstanceGrid::set_child_left_attach(weld::Widget& rWidget, int nAttach)
+{
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] {
+        QWidget* pWidget = 
dynamic_cast<QtInstanceWidget&>(rWidget).getQWidget();
+        assert(pWidget && pWidget->parentWidget() == getQWidget()
+               && "widget it is not a grid child");
+        int nRow = 0;
+        int nCol = 0;
+        int nRowSpan = 0;
+        int nColSpan = 0;
+        getLayout().getItemPosition(getLayout().indexOf(pWidget), &nRow, 
&nCol, &nRowSpan,
+                                    &nColSpan);
+        getLayout().removeWidget(pWidget);
+        getLayout().addWidget(pWidget, nRow, nAttach, nRowSpan, nColSpan);
+    });
+}
+
+int QtInstanceGrid::get_child_left_attach(weld::Widget& rWidget) const
+{
+    SolarMutexGuard g;
+
+    int nCol;
+    GetQtInstance().RunInMainThread([&] {
+        QWidget* pWidget = 
dynamic_cast<QtInstanceWidget&>(rWidget).getQWidget();
+        assert(pWidget && pWidget->parentWidget() == getQWidget()
+               && "widget it is not a grid child");
+        int nRow = 0;
+        int nRowSpan = 0;
+        int nColSpan = 0;
+        getLayout().getItemPosition(getLayout().indexOf(pWidget), &nRow, 
&nCol, &nRowSpan,
+                                    &nColSpan);
+    });
+    return nCol;
+}
+
+void QtInstanceGrid::set_child_column_span(weld::Widget& rWidget, int nCols)
+{
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] {
+        QWidget* pWidget = 
dynamic_cast<QtInstanceWidget&>(rWidget).getQWidget();
+        assert(pWidget && pWidget->parentWidget() == getQWidget()
+               && "widget it is not a grid child");
+        int nRow = 0;
+        int nCol = 0;
+        int nRowSpan = 0;
+        int nColSpan = 0;
+        getLayout().getItemPosition(getLayout().indexOf(pWidget), &nRow, 
&nCol, &nRowSpan,
+                                    &nColSpan);
+        getLayout().removeWidget(pWidget);
+        getLayout().addWidget(pWidget, nRow, nCol, nRowSpan, nCols);
+    });
+}
+
+void QtInstanceGrid::set_child_top_attach(weld::Widget& rWidget, int nAttach)
+{
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] {
+        QWidget* pWidget = 
dynamic_cast<QtInstanceWidget&>(rWidget).getQWidget();
+        assert(pWidget && pWidget->parentWidget() == getQWidget()
+               && "widget it is not a grid child");
+        int nRow = 0;
+        int nCol = 0;
+        int nRowSpan = 0;
+        int nColSpan = 0;
+        getLayout().getItemPosition(getLayout().indexOf(pWidget), &nRow, 
&nCol, &nRowSpan,
+                                    &nColSpan);
+        getLayout().removeWidget(pWidget);
+        getLayout().addWidget(pWidget, nAttach, nCol, nRowSpan, nColSpan);
+    });
+}
+
+int QtInstanceGrid::get_child_top_attach(weld::Widget& rWidget) const
+{
+    SolarMutexGuard g;
+
+    int nRow;
+    GetQtInstance().RunInMainThread([&] {
+        QWidget* pWidget = 
dynamic_cast<QtInstanceWidget&>(rWidget).getQWidget();
+        assert(pWidget && pWidget->parentWidget() == getQWidget()
+               && "widget it is not a grid child");
+        int nCol = 0;
+        int nRowSpan = 0;
+        int nColSpan = 0;
+        getLayout().getItemPosition(getLayout().indexOf(pWidget), &nRow, 
&nCol, &nRowSpan,
+                                    &nColSpan);
+    });
+    return nRow;
+}
+
+QGridLayout& QtInstanceGrid::getLayout() const
+{
+    return static_cast<QGridLayout&>(QtInstanceContainer::getLayout());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/qt6/QtInstanceGrid.cxx b/vcl/qt6/QtInstanceGrid.cxx
new file mode 100644
index 000000000000..9f741c22df71
--- /dev/null
+++ b/vcl/qt6/QtInstanceGrid.cxx
@@ -0,0 +1,12 @@
+/* -*- 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 "../qt5/QtInstanceGrid.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */

Reply via email to