[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Caolán McNamara caolanm at redhat.com
Tue May 29 19:48:51 UTC 2018


 include/sfx2/tabdlg.hxx       |    1 +
 sfx2/source/dialog/tabdlg.cxx |   40 +++++++++++++++++++++++++---------------
 2 files changed, 26 insertions(+), 15 deletions(-)

New commits:
commit ba0408ae9a4ac1b391944b2fdcfd02f86ab2f773
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 29 10:43:11 2018 +0100

    we need to be able to query the ranges before creating the pages
    
    so don't create the pages until the first execute
    
    Change-Id: I5ecc31d5a08bae44c0a912e39b786420f2da86ee
    Reviewed-on: https://gerrit.libreoffice.org/55007
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 9da02d5c371e..a83573d1dfa6 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -249,6 +249,7 @@ private:
     DECL_DLLPRIVATE_LINK(ActivatePageHdl, const OString&, void);
     DECL_DLLPRIVATE_LINK(DeactivatePageHdl, const OString&, bool);
     SAL_DLLPRIVATE void Init_Impl(bool bFmtFlag);
+    SAL_DLLPRIVATE void CreatePages();
 
 protected:
     virtual short               Ok();
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 31be0ca30543..5ccfb377fd0b 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1615,6 +1615,8 @@ IMPL_LINK(SfxTabDialogController, ActivatePageHdl, const OString&, rPage, void)
     }
 
     VclPtr<SfxTabPage> pTabPage = pDataObject->pTabPage;
+    if (!pTabPage)
+        return;
 
     if (pDataObject->bRefresh)
         pTabPage->Reset(m_pSet);
@@ -1935,24 +1937,30 @@ void SfxTabDialogController::AddTabPage
 )
 {
     m_pImpl->aData.push_back(new Data_Impl(m_pImpl->aData.size(), rName, pCreateFunc, pRangesFunc));
-    Data_Impl* pDataObject = m_pImpl->aData.back();
+}
 
-    assert(pDataObject->pTabPage == nullptr && "create TabPage more than once");
-    weld::Container* pPage = m_xTabCtrl->get_page(rName);
-    pDataObject->pTabPage = (pDataObject->fnCreatePage)(pPage, m_pSet);
-    pDataObject->pTabPage->SetDialogController(this);
+void SfxTabDialogController::CreatePages()
+{
+    for (auto pDataObject : m_pImpl->aData)
+    {
+        if (pDataObject->pTabPage)
+           continue;
+        weld::Container* pPage = m_xTabCtrl->get_page(pDataObject->sId);
+        pDataObject->pTabPage = (pDataObject->fnCreatePage)(pPage, m_pSet);
+        pDataObject->pTabPage->SetDialogController(this);
 
-    OUString sConfigId = OStringToOUString(pDataObject->pTabPage->GetConfigId(), RTL_TEXTENCODING_UTF8);
-    SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId);
-    OUString sUserData;
-    Any aUserItem = aPageOpt.GetUserItem(USERITEM_NAME);
-    OUString aTemp;
-    if ( aUserItem >>= aTemp )
-        sUserData = aTemp;
-    pDataObject->pTabPage->SetUserData(sUserData);
+        OUString sConfigId = OStringToOUString(pDataObject->pTabPage->GetConfigId(), RTL_TEXTENCODING_UTF8);
+        SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId);
+        OUString sUserData;
+        Any aUserItem = aPageOpt.GetUserItem(USERITEM_NAME);
+        OUString aTemp;
+        if ( aUserItem >>= aTemp )
+            sUserData = aTemp;
+        pDataObject->pTabPage->SetUserData(sUserData);
 
-    PageCreated(rName, *pDataObject->pTabPage);
-    pDataObject->pTabPage->Reset(m_pSet);
+        PageCreated(pDataObject->sId, *pDataObject->pTabPage);
+        pDataObject->pTabPage->Reset(m_pSet);
+    }
 }
 
 void SfxTabDialogController::RemoveTabPage(const OString& rId)
@@ -1996,6 +2004,8 @@ void SfxTabDialogController::RemoveTabPage(const OString& rId)
 
 void SfxTabDialogController::Start_Impl()
 {
+    CreatePages();
+
     assert(m_pImpl->aData.size() == static_cast<size_t>(m_xTabCtrl->get_n_pages())
             && "not all pages registered");
 


More information about the Libreoffice-commits mailing list