diff options
-rw-r--r-- | include/sfx2/tabdlg.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/dialog/tabdlg.cxx | 40 |
2 files changed, 26 insertions, 15 deletions
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"); |