[Libreoffice-commits] core.git: sc/inc sc/qa sc/source sc/uiconfig sc/UIConfig_scalc.mk

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Sun May 12 20:20:28 UTC 2019


 sc/UIConfig_scalc.mk                     |    1 
 sc/inc/scabstdlg.hxx                     |    3 
 sc/qa/unit/screenshots/screenshots.cxx   |    2 
 sc/source/ui/attrdlg/scdlgfact.cxx       |   10 
 sc/source/ui/attrdlg/scdlgfact.hxx       |   12 -
 sc/source/ui/inc/datafdlg.hxx            |   49 ++--
 sc/source/ui/inc/viewfunc.hxx            |   19 +
 sc/source/ui/miscdlgs/datafdlg.cxx       |  176 +++++++---------
 sc/source/ui/vba/vbaworksheet.cxx        |    2 
 sc/source/ui/view/cellsh2.cxx            |    2 
 sc/source/ui/view/viewfun3.cxx           |    6 
 sc/uiconfig/scalc/ui/dataform.ui         |  326 ++++++++++++++++---------------
 sc/uiconfig/scalc/ui/dataformfragment.ui |   21 +
 13 files changed, 337 insertions(+), 292 deletions(-)

New commits:
commit 85d2e68d5c8b1c8351d5062cdf4b32189e6c8254
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun May 12 18:38:15 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun May 12 22:19:09 2019 +0200

    weld ScDataFormDlg
    
    Change-Id: I656a11f5f9c55913cede710cf48543384132129d
    Reviewed-on: https://gerrit.libreoffice.org/72199
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index a091655403b4..a4a8276c7004 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -110,6 +110,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
 	sc/uiconfig/scalc/ui/datafielddialog \
 	sc/uiconfig/scalc/ui/datafieldoptionsdialog \
 	sc/uiconfig/scalc/ui/dataform \
+	sc/uiconfig/scalc/ui/dataformfragment \
 	sc/uiconfig/scalc/ui/datastreams \
 	sc/uiconfig/scalc/ui/dataprovider \
 	sc/uiconfig/scalc/ui/dataproviderdlg \
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index afada832cfa0..02cf139e4e34 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -423,8 +423,7 @@ public:
     virtual VclPtr<AbstractScDeleteCellDlg> CreateScDeleteCellDlg(weld::Window* pParent, bool bDisallowCellMove) = 0 ;
 
     //for dataform
-    virtual VclPtr<AbstractScDataFormDlg> CreateScDataFormDlg(vcl::Window* pParent,
-        ScTabViewShell* pTabViewShell) = 0;
+    virtual VclPtr<AbstractScDataFormDlg> CreateScDataFormDlg(weld::Window* pParent, ScTabViewShell* pTabViewShell) = 0;
 
     virtual VclPtr<AbstractScDeleteContentsDlg> CreateScDeleteContentsDlg(weld::Window* pParent) = 0;
     virtual VclPtr<AbstractScFillSeriesDlg> CreateScFillSeriesDlg(weld::Window*        pParent,
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx
index 8845bc3b54f2..402db2452590 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -217,7 +217,7 @@ VclPtr<VclAbstractDialog> ScScreenshotTest::createDialogByID(sal_uInt32 nID)
         {
             ////FIXME: looks butt-ugly w/ empty file, move it elsewhere, where
             ////we actually have some data
-            pReturnDialog = mpFact->CreateScDataFormDlg(mpViewShell->GetDialogParent(), mpViewShell);
+            pReturnDialog = mpFact->CreateScDataFormDlg(mpViewShell->GetFrameWeld(), mpViewShell);
             break;
         }
 
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index a2b4e4c2b02f..f957e9f9af1e 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -113,7 +113,10 @@ short AbstractScDeleteCellDlg_Impl::Execute()
 }
 
 //for dataform
-IMPL_ABSTDLG_BASE(AbstractScDataFormDlg_Impl);
+short AbstractScDataFormDlg_Impl::Execute()
+{
+    return m_xDlg->run();
+}
 
 short AbstractScDeleteContentsDlg_Impl::Execute()
 {
@@ -797,11 +800,10 @@ VclPtr<AbstractScDeleteCellDlg> ScAbstractDialogFactory_Impl::CreateScDeleteCell
     return VclPtr<AbstractScDeleteCellDlg_Impl>::Create(std::make_unique<ScDeleteCellDlg>(pParent, bDisallowCellMove));
 }
 
-VclPtr<AbstractScDataFormDlg> ScAbstractDialogFactory_Impl::CreateScDataFormDlg(vcl::Window* pParent,
+VclPtr<AbstractScDataFormDlg> ScAbstractDialogFactory_Impl::CreateScDataFormDlg(weld::Window* pParent,
     ScTabViewShell* pTabViewShell)
 {
-    VclPtr<ScDataFormDlg> pDlg = VclPtr<ScDataFormDlg>::Create(pParent, pTabViewShell);
-    return VclPtr<AbstractScDataFormDlg_Impl>::Create(pDlg);
+    return VclPtr<AbstractScDataFormDlg_Impl>::Create(std::make_unique<ScDataFormDlg>(pParent, pTabViewShell));
 }
 
 VclPtr<AbstractScDeleteContentsDlg> ScAbstractDialogFactory_Impl::CreateScDeleteContentsDlg(weld::Window* pParent)
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index dcf1566d60c9..e087ad7dade6 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -204,7 +204,14 @@ public:
 //for dataform
 class AbstractScDataFormDlg_Impl : public AbstractScDataFormDlg
 {
-    DECL_ABSTDLG_BASE(AbstractScDataFormDlg_Impl,ScDataFormDlg);
+    std::unique_ptr<ScDataFormDlg> m_xDlg;
+public:
+    explicit AbstractScDataFormDlg_Impl(std::unique_ptr<ScDataFormDlg> p)
+        : m_xDlg(std::move(p))
+    {
+    }
+    virtual short Execute() override;
+
 };
 
 class AbstractScDeleteContentsDlg_Impl : public AbstractScDeleteContentsDlg
@@ -612,8 +619,7 @@ public:
     virtual VclPtr<AbstractScDeleteCellDlg> CreateScDeleteCellDlg(weld::Window* pParent, bool bDisallowCellMove ) override;
 
     //for dataform
-    virtual VclPtr<AbstractScDataFormDlg> CreateScDataFormDlg(vcl::Window* pParent,
-        ScTabViewShell* pTabViewShell) override;
+    virtual VclPtr<AbstractScDataFormDlg> CreateScDataFormDlg(weld::Window* pParent, ScTabViewShell* pTabViewShell) override;
 
     virtual VclPtr<AbstractScDeleteContentsDlg> CreateScDeleteContentsDlg(weld::Window* pParent) override;
 
diff --git a/sc/source/ui/inc/datafdlg.hxx b/sc/source/ui/inc/datafdlg.hxx
index 6d4c137e650d..c7bd3d0b7610 100644
--- a/sc/source/ui/inc/datafdlg.hxx
+++ b/sc/source/ui/inc/datafdlg.hxx
@@ -10,11 +10,9 @@
 #ifndef INCLUDED_SC_SOURCE_UI_INC_DATAFDLG_HXX
 #define INCLUDED_SC_SOURCE_UI_INC_DATAFDLG_HXX
 
-#include <vcl/dialog.hxx>
-#include <vcl/button.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/layout.hxx>
+#include <vcl/weld.hxx>
 #include <types.hxx>
+#include "viewfunc.hxx"
 
 class ScTabViewShell;
 class ScDocument;
@@ -22,19 +20,9 @@ class ScDocument;
 #define MAX_DATAFORM_COLS   256
 #define MAX_DATAFORM_ROWS   32000
 
-class ScDataFormDlg : public ModalDialog
+class ScDataFormDlg : public weld::GenericDialogController
 {
 private:
-
-    VclPtr<PushButton>     m_pBtnNew;
-    VclPtr<PushButton>     m_pBtnDelete;
-    VclPtr<PushButton>     m_pBtnRestore;
-    VclPtr<PushButton>     m_pBtnPrev;
-    VclPtr<PushButton>     m_pBtnNext;
-    VclPtr<PushButton>     m_pBtnClose;
-    VclPtr<ScrollBar>      m_pSlider;
-    VclPtr<VclGrid>        m_pGrid;
-    VclPtr<FixedText>      m_pFixedText;
     OUString        sNewRecord;
 
     ScTabViewShell* pTabViewShell;
@@ -47,13 +35,20 @@ private:
     SCROW           nEndRow;
     SCTAB           nTab;
 
-    std::vector<VclPtr<FixedText> > maFixedTexts;
-    std::vector<VclPtr<Edit> >      maEdits;
+    std::unique_ptr<weld::Button> m_xBtnNew;
+    std::unique_ptr<weld::Button> m_xBtnDelete;
+    std::unique_ptr<weld::Button> m_xBtnRestore;
+    std::unique_ptr<weld::Button> m_xBtnPrev;
+    std::unique_ptr<weld::Button> m_xBtnNext;
+    std::unique_ptr<weld::Button> m_xBtnClose;
+    std::unique_ptr<weld::ScrolledWindow> m_xSlider;
+    std::unique_ptr<weld::Container> m_xGrid;
+    std::unique_ptr<weld::Label> m_xFixedText;
+    std::vector<std::unique_ptr<ScDataFormFragment>> m_aEntries;
 
 public:
-    ScDataFormDlg( vcl::Window* pParent, ScTabViewShell* pTabViewShell);
+    ScDataFormDlg(weld::Window* pParent, ScTabViewShell* pTabViewShell);
     virtual ~ScDataFormDlg() override;
-    virtual void dispose() override;
 
     void FillCtrls();
 private:
@@ -61,16 +56,16 @@ private:
     void SetButtonState();
 
     // Handler:
-    DECL_LINK(Impl_NewHdl, Button*, void);
-    DECL_LINK(Impl_PrevHdl, Button*, void);
-    DECL_LINK(Impl_NextHdl, Button*, void);
+    DECL_LINK(Impl_NewHdl, weld::Button&, void);
+    DECL_LINK(Impl_PrevHdl, weld::Button&, void);
+    DECL_LINK(Impl_NextHdl, weld::Button&, void);
 
-    DECL_LINK(Impl_RestoreHdl, Button*, void);
-    DECL_LINK(Impl_DeleteHdl, Button*, void);
-    DECL_LINK(Impl_CloseHdl, Button*, void);
+    DECL_LINK(Impl_RestoreHdl, weld::Button&, void);
+    DECL_LINK(Impl_DeleteHdl, weld::Button&, void);
+    DECL_LINK(Impl_CloseHdl, weld::Button&, void);
 
-    DECL_LINK(Impl_ScrollHdl, ScrollBar*, void);
-    DECL_LINK(Impl_DataModifyHdl, Edit&, void);
+    DECL_LINK(Impl_ScrollHdl, weld::ScrolledWindow&, void);
+    DECL_LINK(Impl_DataModifyHdl, weld::Entry&, void);
 };
 #endif // INCLUDED_SC_SOURCE_UI_INC_DATAFDLG_HXX
 
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 963b41f863ec..fd1e05fa1a67 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -59,6 +59,15 @@ struct ColRowSpan;
 
 namespace com { namespace sun { namespace star { namespace datatransfer { class XTransferable; } } } }
 
+struct ScDataFormFragment
+{
+    std::unique_ptr<weld::Builder> m_xBuilder;
+    std::unique_ptr<weld::Label> m_xLabel;
+    std::unique_ptr<weld::Entry> m_xEdit;
+
+    ScDataFormFragment(weld::Container* pGrid, int nLine);
+};
+
 class ScViewFunc : public ScTabView
 {
 private:
@@ -320,11 +329,11 @@ public:
     bool            SelectionEditable( bool* pOnlyNotBecauseOfMatrix = nullptr );
 
     SC_DLLPUBLIC void
-                    DataFormPutData( SCROW nCurrentRow ,
-                                     SCROW nStartRow , SCCOL nStartCol ,
-                                     SCROW nEndRow , SCCOL nEndCol ,
-                                     std::vector<VclPtr<Edit> >& aEdits,
-                                     sal_uInt16 aColLength );
+                    DataFormPutData(SCROW nCurrentRow ,
+                                    SCROW nStartRow , SCCOL nStartCol ,
+                                    SCROW nEndRow , SCCOL nEndCol ,
+                                    std::vector<std::unique_ptr<ScDataFormFragment>>& rEdits,
+                                    sal_uInt16 aColLength);
     void            UpdateSelectionArea( const ScMarkData& rSel, ScPatternAttr* pAttr = nullptr );
 
     void            OnLOKInsertDeleteColumn(SCCOL nStartCol, long nOffset);
diff --git a/sc/source/ui/miscdlgs/datafdlg.cxx b/sc/source/ui/miscdlgs/datafdlg.cxx
index 8f7e4043a6ab..7e1be6f40e00 100644
--- a/sc/source/ui/miscdlgs/datafdlg.cxx
+++ b/sc/source/ui/miscdlgs/datafdlg.cxx
@@ -15,11 +15,12 @@
 #include <tabvwsh.hxx>
 
 #include <rtl/ustrbuf.hxx>
+#include <vcl/svapp.hxx>
 
 #define HDL(hdl)            LINK( this, ScDataFormDlg, hdl )
 
-ScDataFormDlg::ScDataFormDlg(vcl::Window* pParent, ScTabViewShell* pTabViewShellOri)
-    : ModalDialog(pParent, "DataFormDialog", "modules/scalc/ui/dataform.ui")
+ScDataFormDlg::ScDataFormDlg(weld::Window* pParent, ScTabViewShell* pTabViewShellOri)
+    : GenericDialogController(pParent, "modules/scalc/ui/dataform.ui", "DataFormDialog")
     , pTabViewShell(pTabViewShellOri)
     , aColLength(0)
     , nCurrentRow(0)
@@ -28,17 +29,19 @@ ScDataFormDlg::ScDataFormDlg(vcl::Window* pParent, ScTabViewShell* pTabViewShell
     , nStartRow(0)
     , nEndRow(0)
     , nTab(0)
+    , m_xBtnNew(m_xBuilder->weld_button("new"))
+    , m_xBtnDelete(m_xBuilder->weld_button("delete"))
+    , m_xBtnRestore(m_xBuilder->weld_button("restore"))
+    , m_xBtnPrev(m_xBuilder->weld_button("prev"))
+    , m_xBtnNext(m_xBuilder->weld_button("next"))
+    , m_xBtnClose(m_xBuilder->weld_button("close"))
+    , m_xSlider(m_xBuilder->weld_scrolled_window("scrollbar"))
+    , m_xGrid(m_xBuilder->weld_container("grid"))
+    , m_xFixedText(m_xBuilder->weld_label("label"))
 {
-    get(m_pBtnNew, "new");
-    get(m_pBtnDelete, "delete");
-    get(m_pBtnRestore, "restore");
-    get(m_pBtnPrev, "prev");
-    get(m_pBtnNext, "next");
-    get(m_pBtnClose, "close");
-    get(m_pFixedText, "label");
-    sNewRecord = m_pFixedText->GetText();
-    get(m_pSlider, "scrollbar");
-    get(m_pGrid, "grid");
+    m_xSlider->set_user_managed_scrolling();
+
+    sNewRecord = m_xFixedText->get_label();
 
     //read header form current document, and add new controls
     OSL_ENSURE( pTabViewShell, "pTabViewShell is NULL! :-/" );
@@ -142,8 +145,7 @@ ScDataFormDlg::ScDataFormDlg(vcl::Window* pParent, ScTabViewShell* pTabViewShell
         aColLength = nEndCol - nStartCol + 1;
 
         //new the controls
-        maFixedTexts.reserve(aColLength);
-        maEdits.reserve(aColLength);
+        m_aEntries.reserve(aColLength);
 
         sal_Int32 nGridRow = 0;
         for(sal_uInt16 nIndex = 0; nIndex < aColLength; ++nIndex)
@@ -152,92 +154,60 @@ ScDataFormDlg::ScDataFormDlg(vcl::Window* pParent, ScTabViewShell* pTabViewShell
             int nColWidth = pDoc->GetColWidth( nIndex + nStartCol, nTab );
             if (nColWidth)
             {
-                maFixedTexts.push_back( VclPtr<FixedText>::Create(m_pGrid) );
-                maEdits.push_back( VclPtr<Edit>::Create(m_pGrid, WB_BORDER) );
-
-                maFixedTexts[nIndex]->set_grid_left_attach(0);
-                maEdits[nIndex]->set_grid_left_attach(1);
-                maFixedTexts[nIndex]->set_grid_top_attach(nGridRow);
-                maEdits[nIndex]->set_grid_top_attach(nGridRow);
-
-                maEdits[nIndex]->SetWidthInChars(32);
-                maEdits[nIndex]->set_hexpand(true);
+                m_aEntries.emplace_back(new ScDataFormFragment(m_xGrid.get(), nGridRow));
 
                 ++nGridRow;
 
-                maFixedTexts[nIndex]->SetText(aFieldName);
-                maFixedTexts[nIndex]->Show();
-                maEdits[nIndex]->Show();
+                m_aEntries[nIndex]->m_xLabel->set_label(aFieldName);
+                m_aEntries[nIndex]->m_xLabel->show();
+                m_aEntries[nIndex]->m_xEdit->show();
             }
             else
             {
-                maFixedTexts.emplace_back(nullptr );
-                maEdits.emplace_back(nullptr );
+                m_aEntries.emplace_back(nullptr );
+            }
+            if (m_aEntries[nIndex] != nullptr)
+            {
+                m_aEntries[nIndex]->m_xEdit->connect_changed(HDL(Impl_DataModifyHdl));
+                m_aEntries[nIndex]->m_xEdit->save_value();
             }
-            if (maEdits[nIndex] != nullptr)
-                maEdits[nIndex]->SetModifyHdl( HDL(Impl_DataModifyHdl) );
         }
     }
 
     FillCtrls();
 
-    m_pSlider->SetPageSize( 10 );
-    m_pSlider->SetVisibleSize( 1 );
-    m_pSlider->SetLineSize( 1 );
-    m_pSlider->SetRange( Range( 0, nEndRow - nStartRow + 1) );
-    m_pSlider->Show();
+    m_xSlider->vadjustment_configure(0, 0, nEndRow - nStartRow + 1, 1, 10, 1);
 
-    m_pBtnNew->SetClickHdl(HDL(Impl_NewHdl));
-    m_pBtnPrev->SetClickHdl(HDL(Impl_PrevHdl));
-    m_pBtnNext->SetClickHdl(HDL(Impl_NextHdl));
+    m_xBtnNew->connect_clicked(HDL(Impl_NewHdl));
+    m_xBtnPrev->connect_clicked(HDL(Impl_PrevHdl));
+    m_xBtnNext->connect_clicked(HDL(Impl_NextHdl));
 
-    m_pBtnRestore->SetClickHdl(HDL(Impl_RestoreHdl));
-    m_pBtnDelete->SetClickHdl(HDL(Impl_DeleteHdl));
-    m_pBtnClose->SetClickHdl(HDL(Impl_CloseHdl));
+    m_xBtnRestore->connect_clicked(HDL(Impl_RestoreHdl));
+    m_xBtnDelete->connect_clicked(HDL(Impl_DeleteHdl));
+    m_xBtnClose->connect_clicked(HDL(Impl_CloseHdl));
 
-    m_pSlider->SetEndScrollHdl(HDL(Impl_ScrollHdl));
+    m_xSlider->connect_vadjustment_changed(HDL(Impl_ScrollHdl));
 
     SetButtonState();
 }
 
 ScDataFormDlg::~ScDataFormDlg()
 {
-    disposeOnce();
-}
-
-void ScDataFormDlg::dispose()
-{
-    m_pBtnNew.clear();
-    m_pBtnDelete.clear();
-    m_pBtnRestore.clear();
-    m_pBtnPrev.clear();
-    m_pBtnNext.clear();
-    m_pBtnClose.clear();
-    m_pSlider.clear();
-    m_pFixedText.clear();
-    for ( auto& rxFTIter : maFixedTexts )
-        rxFTIter.disposeAndClear();
-    for ( auto& rxEdit : maEdits )
-        rxEdit.disposeAndClear();
-    maFixedTexts.clear();
-    maEdits.clear();
-    m_pGrid.clear();
-    ModalDialog::dispose();
 }
 
 void ScDataFormDlg::FillCtrls()
 {
     for (sal_uInt16 i = 0; i < aColLength; ++i)
     {
-        if (maEdits[i] != nullptr)
+        if (m_aEntries[i])
         {
             if (nCurrentRow<=nEndRow && pDoc)
             {
-                OUString  aFieldName(pDoc->GetString(i + nStartCol, nCurrentRow, nTab));
-                maEdits[i]->SetText(aFieldName);
+                OUString aFieldName(pDoc->GetString(i + nStartCol, nCurrentRow, nTab));
+                m_aEntries[i]->m_xEdit->set_text(aFieldName);
             }
             else
-                maEdits[i]->SetText(OUString());
+                m_aEntries[i]->m_xEdit->set_text(OUString());
         }
     }
 
@@ -247,37 +217,37 @@ void ScDataFormDlg::FillCtrls()
         aBuf.append(static_cast<sal_Int32>(nCurrentRow - nStartRow));
         aBuf.append(" / ");
         aBuf.append(static_cast<sal_Int32>(nEndRow - nStartRow));
-        m_pFixedText->SetText(aBuf.makeStringAndClear());
+        m_xFixedText->set_label(aBuf.makeStringAndClear());
     }
     else
-        m_pFixedText->SetText(sNewRecord);
+        m_xFixedText->set_label(sNewRecord);
 
-    m_pSlider->SetThumbPos(nCurrentRow-nStartRow-1);
+    m_xSlider->vadjustment_set_value(nCurrentRow-nStartRow-1);
 }
 
-IMPL_LINK( ScDataFormDlg, Impl_DataModifyHdl, Edit&, rEdit, void)
+IMPL_LINK( ScDataFormDlg, Impl_DataModifyHdl, weld::Entry&, rEdit, void)
 {
-    if ( rEdit.IsModified() )
-        m_pBtnRestore->Enable();
+    if (rEdit.get_value_changed_from_saved())
+        m_xBtnRestore->set_sensitive(true);
 }
 
-IMPL_LINK_NOARG(ScDataFormDlg, Impl_NewHdl, Button*, void)
+IMPL_LINK_NOARG(ScDataFormDlg, Impl_NewHdl, weld::Button&, void)
 {
     ScViewData& rViewData = pTabViewShell->GetViewData();
     ScDocShell* pDocSh = rViewData.GetDocShell();
     if ( pDoc )
     {
-        bool bHasData = std::any_of(maEdits.begin(), maEdits.end(),
-            [](const VclPtr<Edit>& rxEdit) { return (rxEdit != nullptr) && (!rxEdit->GetText().isEmpty()); });
+        bool bHasData = std::any_of(m_aEntries.begin(), m_aEntries.end(),
+            [](const std::unique_ptr<ScDataFormFragment>& rElem) { return (rElem != nullptr) && (!rElem->m_xEdit->get_text().isEmpty()); });
 
         if ( bHasData )
         {
-            pTabViewShell->DataFormPutData( nCurrentRow , nStartRow , nStartCol , nEndRow , nEndCol , maEdits , aColLength );
+            pTabViewShell->DataFormPutData(nCurrentRow, nStartRow, nStartCol, nEndRow, nEndCol, m_aEntries, aColLength);
             nCurrentRow++;
             if (nCurrentRow >= nEndRow + 2)
             {
-                    nEndRow ++ ;
-                    m_pSlider->SetRange( Range( 0, nEndRow - nStartRow + 1) );
+                nEndRow++;
+                m_xSlider->vadjustment_set_upper(nEndRow - nStartRow + 1);
             }
             SetButtonState();
             FillCtrls();
@@ -287,7 +257,7 @@ IMPL_LINK_NOARG(ScDataFormDlg, Impl_NewHdl, Button*, void)
     }
 }
 
-IMPL_LINK_NOARG(ScDataFormDlg, Impl_PrevHdl, Button*, void)
+IMPL_LINK_NOARG(ScDataFormDlg, Impl_PrevHdl, weld::Button&, void)
 {
     if (pDoc)
     {
@@ -299,7 +269,7 @@ IMPL_LINK_NOARG(ScDataFormDlg, Impl_PrevHdl, Button*, void)
     }
 }
 
-IMPL_LINK_NOARG(ScDataFormDlg, Impl_NextHdl, Button*, void)
+IMPL_LINK_NOARG(ScDataFormDlg, Impl_NextHdl, weld::Button&, void)
 {
     if (pDoc)
     {
@@ -311,7 +281,7 @@ IMPL_LINK_NOARG(ScDataFormDlg, Impl_NextHdl, Button*, void)
     }
 }
 
-IMPL_LINK_NOARG(ScDataFormDlg, Impl_RestoreHdl, Button*, void)
+IMPL_LINK_NOARG(ScDataFormDlg, Impl_RestoreHdl, weld::Button&, void)
 {
     if (pDoc)
     {
@@ -319,7 +289,7 @@ IMPL_LINK_NOARG(ScDataFormDlg, Impl_RestoreHdl, Button*, void)
     }
 }
 
-IMPL_LINK_NOARG(ScDataFormDlg, Impl_DeleteHdl, Button*, void)
+IMPL_LINK_NOARG(ScDataFormDlg, Impl_DeleteHdl, weld::Button&, void)
 {
     ScViewData& rViewData = pTabViewShell->GetViewData();
     ScDocShell* pDocSh = rViewData.GetDocShell();
@@ -338,14 +308,14 @@ IMPL_LINK_NOARG(ScDataFormDlg, Impl_DeleteHdl, Button*, void)
     }
 }
 
-IMPL_LINK_NOARG(ScDataFormDlg, Impl_CloseHdl, Button*, void)
+IMPL_LINK_NOARG(ScDataFormDlg, Impl_CloseHdl, weld::Button&, void)
 {
-    EndDialog( );
+    m_xDialog->response(RET_CANCEL);
 }
 
-IMPL_LINK_NOARG(ScDataFormDlg, Impl_ScrollHdl, ScrollBar*, void)
+IMPL_LINK_NOARG(ScDataFormDlg, Impl_ScrollHdl, weld::ScrolledWindow&, void)
 {
-    long nOffset = m_pSlider->GetThumbPos();
+    auto nOffset = m_xSlider->vadjustment_get_value();
     nCurrentRow = nStartRow + nOffset + 1;
     SetButtonState();
     FillCtrls();
@@ -355,23 +325,35 @@ void ScDataFormDlg::SetButtonState()
 {
     if (nCurrentRow > nEndRow)
     {
-        m_pBtnDelete->Enable( false );
-        m_pBtnNext->Enable( false );
+        m_xBtnDelete->set_sensitive( false );
+        m_xBtnNext->set_sensitive( false );
     }
     else
     {
-        m_pBtnDelete->Enable();
-        m_pBtnNext->Enable();
+        m_xBtnDelete->set_sensitive(true);
+        m_xBtnNext->set_sensitive(true);
     }
 
     if (nCurrentRow == nStartRow + 1)
-        m_pBtnPrev->Enable( false );
+        m_xBtnPrev->set_sensitive( false );
     else
-        m_pBtnPrev->Enable();
+        m_xBtnPrev->set_sensitive(true);
+
+    m_xBtnRestore->set_sensitive( false );
+    if (!m_aEntries.empty() && m_aEntries[0] != nullptr)
+        m_aEntries[0]->m_xEdit->grab_focus();
+}
+
+ScDataFormFragment::ScDataFormFragment(weld::Container* pGrid, int nLine)
+    : m_xBuilder(Application::CreateBuilder(pGrid, "modules/scalc/ui/dataformfragment.ui"))
+    , m_xLabel(m_xBuilder->weld_label("label"))
+    , m_xEdit(m_xBuilder->weld_entry("entry"))
+{
+    m_xLabel->set_grid_left_attach(0);
+    m_xLabel->set_grid_top_attach(nLine);
 
-    m_pBtnRestore->Enable( false );
-    if ( !maEdits.empty() && maEdits[0] != nullptr )
-        maEdits[0]->GrabFocus();
+    m_xEdit->set_grid_left_attach(1);
+    m_xEdit->set_grid_top_attach(nLine);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index ff602c6dbda8..4b222edc8f52 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -887,7 +887,7 @@ ScVbaWorksheet::ShowDataForm( )
 
     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
 
-    ScopedVclPtr<AbstractScDataFormDlg> pDlg(pFact->CreateScDataFormDlg(pTabViewShell->GetDialogParent(),
+    ScopedVclPtr<AbstractScDataFormDlg> pDlg(pFact->CreateScDataFormDlg(pTabViewShell->GetFrameWeld(),
                                                                         pTabViewShell));
 
     pDlg->Execute();
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 9043bd3a4ba9..8f5f587fa9e1 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -362,7 +362,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
 
                 ScopedVclPtr<AbstractScDataFormDlg> pDlg(pFact->CreateScDataFormDlg(
-                    pTabViewShell->GetDialogParent(), pTabViewShell));
+                    pTabViewShell->GetFrameWeld(), pTabViewShell));
 
                 pDlg->Execute();
 
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 2dbc3e9a55a8..46bb690d19b8 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -1934,7 +1934,7 @@ bool ScViewFunc::LinkBlock( const ScRange& rSource, const ScAddress& rDestPos )
 void ScViewFunc::DataFormPutData( SCROW nCurrentRow ,
                                   SCROW nStartRow , SCCOL nStartCol ,
                                   SCROW nEndRow , SCCOL nEndCol ,
-                                  std::vector<VclPtr<Edit> >& aEdits,
+                                  std::vector<std::unique_ptr<ScDataFormFragment>>& rEdits,
                                   sal_uInt16 aColLength )
 {
     ScDocument* pDoc = GetViewData().GetDocument();
@@ -1975,9 +1975,9 @@ void ScViewFunc::DataFormPutData( SCROW nCurrentRow ,
 
         for(sal_uInt16 i = 0; i < aColLength; i++)
         {
-            if (aEdits[i] != nullptr)
+            if (rEdits[i] != nullptr)
             {
-                OUString  aFieldName=aEdits[i]->GetText();
+                OUString aFieldName = rEdits[i]->m_xEdit->get_text();
                 pDoc->SetString( nStartCol + i, nCurrentRow, nTab, aFieldName );
             }
         }
diff --git a/sc/uiconfig/scalc/ui/dataform.ui b/sc/uiconfig/scalc/ui/dataform.ui
index f1295f8d9a5f..e84b2a92ecf1 100644
--- a/sc/uiconfig/scalc/ui/dataform.ui
+++ b/sc/uiconfig/scalc/ui/dataform.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="sc">
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkDialog" id="DataFormDialog">
@@ -7,103 +7,19 @@
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="dataform|DataFormDialog">Data Form</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <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="orientation">vertical</property>
             <property name="homogeneous">True</property>
-            <property name="layout_style">start</property>
-            <child>
-              <object class="GtkLabel" id="label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes" context="dataform|label">New Record</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="new">
-                <property name="label" translatable="yes" context="dataform|new">_New</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="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="delete">
-                <property name="label" translatable="yes" context="dataform|delete">_Delete</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="restore">
-                <property name="label" translatable="yes" context="dataform|restore">_Restore</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">3</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="prev">
-                <property name="label" translatable="yes" context="dataform|prev">_Previous Record</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">4</property>
-                <property name="secondary">True</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="next">
-                <property name="label" translatable="yes" context="dataform|next">Ne_xt Record</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">5</property>
-                <property name="secondary">True</property>
-              </packing>
-            </child>
+            <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="help">
                 <property name="label">gtk-help</property>
@@ -131,7 +47,6 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">7</property>
-                <property name="secondary">True</property>
               </packing>
             </child>
           </object>
@@ -143,84 +58,204 @@
           </packing>
         </child>
         <child>
-          <object class="GtkBox" id="box1">
+          <object class="GtkGrid">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="hexpand">True</property>
-            <property name="vexpand">True</property>
-            <property name="spacing">6</property>
+            <property name="column_spacing">12</property>
             <child>
-              <object class="GtkBox" id="box2">
+              <object class="GtkScrolledWindow" id="scrollbar">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can_focus">True</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <property name="orientation">vertical</property>
+                <property name="hscrollbar_policy">never</property>
+                <property name="vscrollbar_policy">always</property>
+                <property name="shadow_type">in</property>
                 <child>
-                  <object class="GtkGrid" id="grid">
+                  <object class="GtkViewport">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="row_spacing">6</property>
-                    <property name="column_spacing">12</property>
-                    <property name="row_homogeneous">True</property>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
                     <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
+                      <object class="GtkBox" id="box1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkBox" id="box2">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_left">6</property>
+                            <property name="margin_right">6</property>
+                            <property name="margin_top">6</property>
+                            <property name="margin_bottom">6</property>
+                            <property name="hexpand">True</property>
+                            <property name="vexpand">True</property>
+                            <property name="orientation">vertical</property>
+                            <child>
+                              <object class="GtkGrid" id="grid">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="hexpand">True</property>
+                                <property name="row_spacing">6</property>
+                                <property name="column_spacing">12</property>
+                                <property name="row_homogeneous">True</property>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                      </object>
                     </child>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkScrollbar" id="scrollbar">
+              <object class="GtkButtonBox">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="vexpand">True</property>
                 <property name="orientation">vertical</property>
+                <property name="spacing">6</property>
+                <property name="homogeneous">True</property>
+                <property name="layout_style">start</property>
+                <child>
+                  <object class="GtkLabel" id="label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes" context="dataform|label">New Record</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="new">
+                    <property name="label" translatable="yes" context="dataform|new">_New</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="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="delete">
+                    <property name="label" translatable="yes" context="dataform|delete">_Delete</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="restore">
+                    <property name="label" translatable="yes" context="dataform|restore">_Restore</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="prev">
+                    <property name="label" translatable="yes" context="dataform|prev">_Previous Record</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">4</property>
+                    <property name="secondary">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="next">
+                    <property name="label" translatable="yes" context="dataform|next">Ne_xt Record</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">5</property>
+                    <property name="secondary">True</property>
+                  </packing>
+                </child>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
               </packing>
             </child>
           </object>
           <packing>
-            <property name="expand">False</property>
+            <property name="expand">True</property>
             <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
@@ -228,13 +263,8 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">new</action-widget>
-      <action-widget response="0">delete</action-widget>
-      <action-widget response="0">restore</action-widget>
-      <action-widget response="0">prev</action-widget>
-      <action-widget response="0">next</action-widget>
-      <action-widget response="-7">close</action-widget>
       <action-widget response="-11">help</action-widget>
+      <action-widget response="-7">close</action-widget>
     </action-widgets>
   </object>
 </interface>
diff --git a/sc/uiconfig/scalc/ui/dataformfragment.ui b/sc/uiconfig/scalc/ui/dataformfragment.ui
new file mode 100644
index 000000000000..0bdeffa9fc98
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/dataformfragment.ui
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="sw">
+  <requires lib="gtk+" version="3.18"/>
+  <object class="GtkEntry" id="entry">
+    <property name="visible">True</property>
+    <property name="can_focus">True</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">False</property>
+    <property name="activates_default">True</property>
+    <property name="width_chars">32</property>
+  </object>
+  <object class="GtkLabel" id="label">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="halign">end</property>
+    <property name="use_underline">True</property>
+    <property name="mnemonic_widget">entry</property>
+    <property name="xalign">0</property>
+  </object>
+</interface>


More information about the Libreoffice-commits mailing list