diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-09-20 20:29:36 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-09-26 09:54:18 +0200 |
commit | a37e559ed123789f6bc8f7972242d6461ce692ab (patch) | |
tree | 7c6304b4541335b2bb706efda58b882132fe3819 /vcl/source | |
parent | b3f249c1351642be6f2774230ff80a6d20bd1401 (diff) |
disinherit OWizardPage and SfxTabPage from vcl TabPage
Now that there's no need to support weld/unwelded mixes of
pages in dialog any more.
inherit from a BuilderPage which contains a Builder and
Toplevel container
BuilderPage Activate and Deactivate replace TabPage ActivatePage and
DeactivatePage, allowing disambiguation wrt SfxTabPage ActivatePage and
DeactivatePage.
Change-Id: I5706e50fd92f712a25328ee9791e054bb9ad9812
Reviewed-on: https://gerrit.libreoffice.org/79317
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 82 | ||||
-rw-r--r-- | vcl/source/app/weldutils.cxx | 107 | ||||
-rw-r--r-- | vcl/source/control/roadmapwizard.cxx | 2 | ||||
-rw-r--r-- | vcl/source/control/wizardmachine.cxx | 99 | ||||
-rw-r--r-- | vcl/source/control/wizimpldata.hxx | 6 |
5 files changed, 153 insertions, 143 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 2063a4e618b9..fdebbc47f05c 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -5973,86 +5973,4 @@ weld::Window* SalFrame::GetFrameWeld() const return m_xFrameWeld.get(); } -namespace weld -{ - bool DialogController::runAsync(const std::shared_ptr<DialogController>& rController, const std::function<void(sal_Int32)>& func) - { - return rController->getDialog()->runAsync(rController, func); - } - - DialogController::~DialogController() COVERITY_NOEXCEPT_FALSE - { - } - - Dialog* GenericDialogController::getDialog() { return m_xDialog.get(); } - - GenericDialogController::GenericDialogController(weld::Widget* pParent, const OUString &rUIFile, const OString& rDialogId) - : m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) - , m_xDialog(m_xBuilder->weld_dialog(rDialogId)) - { - } - - GenericDialogController::~GenericDialogController() COVERITY_NOEXCEPT_FALSE - { - } - - Dialog* MessageDialogController::getDialog() { return m_xDialog.get(); } - - MessageDialogController::MessageDialogController(weld::Widget* pParent, const OUString &rUIFile, const OString& rDialogId, - const OString& rRelocateId) - : m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) - , m_xDialog(m_xBuilder->weld_message_dialog(rDialogId)) - , m_xContentArea(m_xDialog->weld_message_area()) - { - if (!rRelocateId.isEmpty()) - { - m_xRelocate = m_xBuilder->weld_container(rRelocateId); - m_xOrigParent = m_xRelocate->weld_parent(); - //fdo#75121, a bit tricky because the widgets we want to align with - //don't actually exist in the ui description, they're implied - m_xOrigParent->move(m_xRelocate.get(), m_xContentArea.get()); - } - } - - MessageDialogController::~MessageDialogController() - { - if (m_xRelocate) - { - m_xContentArea->move(m_xRelocate.get(), m_xOrigParent.get()); - } - } - - AssistantController::AssistantController(weld::Widget* pParent, const OUString &rUIFile, const OString& rDialogId) - : m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) - , m_xAssistant(m_xBuilder->weld_assistant(rDialogId)) - { - } - - Dialog* AssistantController::getDialog() { return m_xAssistant.get(); } - - AssistantController::~AssistantController() - { - } - - void TriStateEnabled::ButtonToggled(weld::ToggleButton& rToggle) - { - if (bTriStateEnabled) - { - switch (eState) - { - case TRISTATE_INDET: - rToggle.set_state(TRISTATE_FALSE); - break; - case TRISTATE_TRUE: - rToggle.set_state(TRISTATE_INDET); - break; - case TRISTATE_FALSE: - rToggle.set_state(TRISTATE_TRUE); - break; - } - } - eState = rToggle.get_state(); - } -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx new file mode 100644 index 000000000000..11fc208a7836 --- /dev/null +++ b/vcl/source/app/weldutils.cxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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/builderpage.hxx> +#include <vcl/svapp.hxx> + +BuilderPage::BuilderPage(weld::Widget* pParent, weld::DialogController* pController, + const OUString& rUIXMLDescription, const OString& rID) + : m_pDialogController(pController) + , m_xBuilder(Application::CreateBuilder(pParent, rUIXMLDescription)) + , m_xContainer(m_xBuilder->weld_container(rID)) +{ +} + +void BuilderPage::Activate() {} + +void BuilderPage::Deactivate() {} + +BuilderPage::~BuilderPage() {} + +namespace weld +{ +bool DialogController::runAsync(const std::shared_ptr<DialogController>& rController, + const std::function<void(sal_Int32)>& func) +{ + return rController->getDialog()->runAsync(rController, func); +} + +DialogController::~DialogController() COVERITY_NOEXCEPT_FALSE {} + +Dialog* GenericDialogController::getDialog() { return m_xDialog.get(); } + +GenericDialogController::GenericDialogController(weld::Widget* pParent, const OUString& rUIFile, + const OString& rDialogId) + : m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) + , m_xDialog(m_xBuilder->weld_dialog(rDialogId)) +{ +} + +GenericDialogController::~GenericDialogController() COVERITY_NOEXCEPT_FALSE {} + +Dialog* MessageDialogController::getDialog() { return m_xDialog.get(); } + +MessageDialogController::MessageDialogController(weld::Widget* pParent, const OUString& rUIFile, + const OString& rDialogId, + const OString& rRelocateId) + : m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) + , m_xDialog(m_xBuilder->weld_message_dialog(rDialogId)) + , m_xContentArea(m_xDialog->weld_message_area()) +{ + if (!rRelocateId.isEmpty()) + { + m_xRelocate = m_xBuilder->weld_container(rRelocateId); + m_xOrigParent = m_xRelocate->weld_parent(); + //fdo#75121, a bit tricky because the widgets we want to align with + //don't actually exist in the ui description, they're implied + m_xOrigParent->move(m_xRelocate.get(), m_xContentArea.get()); + } +} + +MessageDialogController::~MessageDialogController() +{ + if (m_xRelocate) + { + m_xContentArea->move(m_xRelocate.get(), m_xOrigParent.get()); + } +} + +AssistantController::AssistantController(weld::Widget* pParent, const OUString& rUIFile, + const OString& rDialogId) + : m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) + , m_xAssistant(m_xBuilder->weld_assistant(rDialogId)) +{ +} + +Dialog* AssistantController::getDialog() { return m_xAssistant.get(); } + +AssistantController::~AssistantController() {} + +void TriStateEnabled::ButtonToggled(weld::ToggleButton& rToggle) +{ + if (bTriStateEnabled) + { + switch (eState) + { + case TRISTATE_INDET: + rToggle.set_state(TRISTATE_FALSE); + break; + case TRISTATE_TRUE: + rToggle.set_state(TRISTATE_INDET); + break; + case TRISTATE_FALSE: + rToggle.set_state(TRISTATE_TRUE); + break; + } + } + eState = rToggle.get_state(); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/control/roadmapwizard.cxx b/vcl/source/control/roadmapwizard.cxx index 4ef52d6e9ab5..a046db704de0 100644 --- a/vcl/source/control/roadmapwizard.cxx +++ b/vcl/source/control/roadmapwizard.cxx @@ -478,7 +478,7 @@ namespace vcl // can we advance from the current page? bool bCurrentPageCanAdvance = true; - TabPage* pCurrentPage = GetPage( getCurrentState() ); + BuilderPage* pCurrentPage = GetPage( getCurrentState() ); if ( pCurrentPage ) { const IWizardPageController* pController = getPageController( GetPage( getCurrentState() ) ); diff --git a/vcl/source/control/wizardmachine.cxx b/vcl/source/control/wizardmachine.cxx index fc394da25c77..41cb6b6dd045 100644 --- a/vcl/source/control/wizardmachine.cxx +++ b/vcl/source/control/wizardmachine.cxx @@ -39,38 +39,28 @@ namespace vcl { //= WizardPageImplData OWizardPage::OWizardPage(TabPageParent pParent, const OUString& rUIXMLDescription, const OString& rID) - : TabPage(pParent.pPage ? Application::GetDefDialogParent() : pParent.pParent.get()) //just drag this along hidden in this scenario - , m_xBuilder(pParent.pPage ? Application::CreateBuilder(pParent.pPage, rUIXMLDescription) - : Application::CreateInterimBuilder(this, rUIXMLDescription)) - , m_xContainer(m_xBuilder->weld_container(rID)) + : BuilderPage(pParent.pPage, pParent.pController, rUIXMLDescription, rID) { } OWizardPage::~OWizardPage() { - disposeOnce(); - } - - void OWizardPage::dispose() - { - m_xBuilder.reset(); - TabPage::dispose(); } void OWizardPage::initializePage() { } - void OWizardPage::ActivatePage() + void OWizardPage::Activate() { - TabPage::ActivatePage(); + BuilderPage::Activate(); updateDialogTravelUI(); } void OWizardPage::updateDialogTravelUI() { - RoadmapWizard* pWizardMachine = dynamic_cast<RoadmapWizard*>(GetParent()); - if ( pWizardMachine ) + auto pWizardMachine = dynamic_cast<RoadmapWizardMachine*>(m_pDialogController); + if (pWizardMachine) pWizardMachine->updateTravelUI(); } @@ -1064,6 +1054,7 @@ namespace vcl WizardMachine::WizardMachine(weld::Window* pParent, WizardButtonFlags nButtonFlags) : AssistantController(pParent, "vcl/ui/wizard.ui", "Wizard") + , m_pCurTabPage(nullptr) , m_nCurState(0) , m_pFirstPage(nullptr) , m_xFinish(m_xAssistant->weld_widget_for_response(RET_OK)) @@ -1134,13 +1125,7 @@ namespace vcl if (m_pImpl) { while (m_pFirstPage) - { - VclPtr<TabPage> pPage = m_pFirstPage->mpPage; - RemovePage(m_pFirstPage->mpPage); - if (pPage) - pPage.disposeAndClear(); - } - + RemovePage(m_pFirstPage->mxPage.get()); m_pImpl.reset(); } } @@ -1150,10 +1135,10 @@ namespace vcl OUString sCompleteTitle(m_pImpl->sTitleBase); // append the page title - TabPage* pCurrentPage = GetPage(getCurrentState()); - if ( pCurrentPage && !pCurrentPage->GetText().isEmpty() ) + BuilderPage* pCurrentPage = GetPage(getCurrentState()); + if ( pCurrentPage && !pCurrentPage->GetPageTitle().isEmpty() ) { - sCompleteTitle += " - " + pCurrentPage->GetText(); + sCompleteTitle += " - " + pCurrentPage->GetPageTitle(); } m_xAssistant->set_title(sCompleteTitle); @@ -1165,12 +1150,12 @@ namespace vcl implUpdateTitle(); } - TabPage* WizardMachine::GetOrCreatePage( const WizardTypes::WizardState i_nState ) + BuilderPage* WizardMachine::GetOrCreatePage( const WizardTypes::WizardState i_nState ) { if ( nullptr == GetPage( i_nState ) ) { - VclPtr<TabPage> pNewPage = createPage( i_nState ); - DBG_ASSERT( pNewPage, "WizardMachine::GetOrCreatePage: invalid new page (NULL)!" ); + std::unique_ptr<BuilderPage> xNewPage = createPage( i_nState ); + DBG_ASSERT( xNewPage, "WizardMachine::GetOrCreatePage: invalid new page (NULL)!" ); // fill up the page sequence of our base class (with dummies) while ( m_pImpl->nFirstUnknownPage < i_nState ) @@ -1182,12 +1167,12 @@ namespace vcl if ( m_pImpl->nFirstUnknownPage == i_nState ) { // encountered this page number the first time - AddPage( pNewPage ); + AddPage(std::move(xNewPage)); ++m_pImpl->nFirstUnknownPage; } else // already had this page - just change it - SetPage( i_nState, pNewPage ); + SetPage(i_nState, std::move(xNewPage)); } return GetPage( i_nState ); } @@ -1438,18 +1423,18 @@ namespace vcl { if (DeactivatePage()) { - TabPage* pOldTabPage = m_xCurTabPage; + BuilderPage* pOldTabPage = m_pCurTabPage; m_nCurState = nState; ActivatePage(); if (pOldTabPage) - pOldTabPage->DeactivatePage(); + pOldTabPage->Deactivate(); m_xAssistant->set_current_page(OString::number(nState)); - m_xCurTabPage = GetPage(m_nCurState); - m_xCurTabPage->ActivatePage(); + m_pCurTabPage = GetPage(m_nCurState); + m_pCurTabPage->Activate(); return true; } @@ -1541,9 +1526,9 @@ namespace vcl travelNext(); } - IWizardPageController* WizardMachine::getPageController( TabPage* _pCurrentPage ) const + IWizardPageController* WizardMachine::getPageController(BuilderPage* pCurrentPage) const { - IWizardPageController* pController = dynamic_cast< IWizardPageController* >( _pCurrentPage ); + IWizardPageController* pController = dynamic_cast<IWizardPageController*>(pCurrentPage); return pController; } @@ -1594,8 +1579,8 @@ namespace vcl { if ( DeactivatePage() ) { - if (m_xCurTabPage) - m_xCurTabPage->DeactivatePage(); + if (m_pCurTabPage) + m_pCurTabPage->Deactivate(); m_xAssistant->response(nResult); return true; @@ -1604,37 +1589,37 @@ namespace vcl return false; } - void WizardMachine::AddPage( TabPage* pPage ) + void WizardMachine::AddPage(std::unique_ptr<BuilderPage> xPage) { - ImplWizPageData* pNewPageData = new ImplWizPageData; - pNewPageData->mpNext = nullptr; - pNewPageData->mpPage = pPage; + WizPageData* pNewPageData = new WizPageData; + pNewPageData->mpNext = nullptr; + pNewPageData->mxPage = std::move(xPage); if ( !m_pFirstPage ) m_pFirstPage = pNewPageData; else { - ImplWizPageData* pPageData = m_pFirstPage; + WizPageData* pPageData = m_pFirstPage; while ( pPageData->mpNext ) pPageData = pPageData->mpNext; pPageData->mpNext = pNewPageData; } } - void WizardMachine::RemovePage( TabPage* pPage ) + void WizardMachine::RemovePage(BuilderPage* pPage) { - ImplWizPageData* pPrevPageData = nullptr; - ImplWizPageData* pPageData = m_pFirstPage; + WizPageData* pPrevPageData = nullptr; + WizPageData* pPageData = m_pFirstPage; while ( pPageData ) { - if ( pPageData->mpPage == pPage ) + if (pPageData->mxPage.get() == pPage) { if (pPrevPageData) pPrevPageData->mpNext = pPageData->mpNext; else m_pFirstPage = pPageData->mpNext; - if (pPage == m_xCurTabPage) - m_xCurTabPage.clear(); + if (pPage == m_pCurTabPage) + m_pCurTabPage = nullptr; delete pPageData; return; } @@ -1646,10 +1631,10 @@ namespace vcl OSL_FAIL( "WizardMachine::RemovePage() - Page not in list" ); } - void WizardMachine::SetPage(WizardTypes::WizardState nLevel, TabPage* pPage) + void WizardMachine::SetPage(WizardTypes::WizardState nLevel, std::unique_ptr<BuilderPage> xPage) { sal_uInt16 nTempLevel = 0; - ImplWizPageData* pPageData = m_pFirstPage; + WizPageData* pPageData = m_pFirstPage; while ( pPageData ) { if ( (nTempLevel == nLevel) || !pPageData->mpNext ) @@ -1661,21 +1646,21 @@ namespace vcl if ( pPageData ) { - if ( pPageData->mpPage == m_xCurTabPage ) - m_xCurTabPage = nullptr; - pPageData->mpPage = pPage; + if (pPageData->mxPage.get() == m_pCurTabPage) + m_pCurTabPage = nullptr; + pPageData->mxPage = std::move(xPage); } } - TabPage* WizardMachine::GetPage(WizardTypes::WizardState nLevel) const + BuilderPage* WizardMachine::GetPage(WizardTypes::WizardState nLevel) const { sal_uInt16 nTempLevel = 0; - for (ImplWizPageData* pPageData = m_pFirstPage; pPageData; + for (WizPageData* pPageData = m_pFirstPage; pPageData; pPageData = pPageData->mpNext) { if ( nTempLevel == nLevel ) - return pPageData->mpPage; + return pPageData->mxPage.get(); nTempLevel++; } diff --git a/vcl/source/control/wizimpldata.hxx b/vcl/source/control/wizimpldata.hxx index d61805167576..fdac4baef076 100644 --- a/vcl/source/control/wizimpldata.hxx +++ b/vcl/source/control/wizimpldata.hxx @@ -22,10 +22,10 @@ #include <stack> -struct ImplWizPageData +struct WizPageData { - ImplWizPageData* mpNext; - VclPtr<TabPage> mpPage; + WizPageData* mpNext; + std::unique_ptr<BuilderPage> mxPage; }; struct ImplWizButtonData |