diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-03-09 15:51:53 +0000 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2021-05-25 12:12:25 +0200 |
commit | 9142876e208d714508984b192eb8ba35af30c100 (patch) | |
tree | e6396edacd73ae0c837038d9e52226061623dbc6 /sw | |
parent | bcde3d560198a834bce8f1f129f1d3c665baa3df (diff) |
register navigator individually in each module that it exists in
instead of globally. This makes the navigators the same
as everything else and easier to deal with.
Change-Id: I882612e73d36485b84161a2d3fbc1188f734c0fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112244
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/app/swmodule.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/inc/navipi.hxx | 18 | ||||
-rw-r--r-- | sw/source/uibase/utlui/navipi.cxx | 64 |
3 files changed, 41 insertions, 44 deletions
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index 9dded8a0b49a..5a64b502b94c 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -294,7 +294,6 @@ void SwDLL::RegisterControls() SwFieldDlgWrapper::RegisterChildWindow( false, pMod ); SwFieldDataOnlyDlgWrapper::RegisterChildWindow( false, pMod ); SvxContourDlgChildWindow::RegisterChildWindow( false, pMod ); - SwNavigationChild::RegisterChildWindowContext( pMod ); SwInputChild::RegisterChildWindow( false, pMod, SfxChildWindowFlags::FORCEDOCK ); SwRedlineAcceptChild::RegisterChildWindow( false, pMod ); SwSyncChildWin::RegisterChildWindow( true, pMod ); @@ -322,6 +321,8 @@ void SwDLL::RegisterControls() ::sfx2::sidebar::SidebarChildWindow::RegisterChildWindow(false, pMod); + SwNavigatorWrapper::RegisterChildWindow(false, pMod, SfxChildWindowFlags::NEVERHIDE); + SwJumpToSpecificPageControl::RegisterControl(SID_JUMP_TO_SPECIFIC_PAGE, pMod); } diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx index 498a8d3da7c5..f5b0096fe567 100644 --- a/sw/source/uibase/inc/navipi.hxx +++ b/sw/source/uibase/inc/navipi.hxx @@ -26,6 +26,7 @@ #include <sfx2/ctrlitem.hxx> #include <sfx2/tbxctrl.hxx> #include <sfx2/sidebar/ControllerItem.hxx> +#include <sfx2/navigat.hxx> #include <sfx2/weldutils.hxx> #include <sfx2/sidebar/PanelLayout.hxx> #include "conttree.hxx" @@ -33,8 +34,6 @@ #include <memory> class SwWrtShell; -class SwNavigationPI; -class SwNavigationChild; class SfxBindings; class SwNavigationConfig; class SwView; @@ -47,7 +46,7 @@ class SwNavigationPI : public PanelLayout , public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface , public SfxListener { - friend class SwNavigationChild; + friend class SwNavigatorWin; friend class SwContentTree; friend class SwGlobalTree; friend class SwNavigationPIUIObject; @@ -162,17 +161,12 @@ public: FactoryFunction GetUITestFactory() const override; }; -class SwNavigationChild : public SfxChildWindowContext +class SwNavigatorWrapper final : public SfxNavigatorWrapper { public: - SwNavigationChild( vcl::Window* , - sal_uInt16 nId, - SfxBindings* ); - - //! soon obsolete ! - static std::unique_ptr<SfxChildWindowContext> CreateImpl(vcl::Window *pParent, - SfxBindings *pBindings, SfxChildWinInfo* pInfo ); - static void RegisterChildWindowContext(SfxModule *pMod); + SwNavigatorWrapper(vcl::Window *pParent, sal_uInt16 nId, + SfxBindings* pBindings, SfxChildWinInfo* pInfo); + SFX_DECL_CHILDWINDOW(SwNavigatorWrapper); }; #endif diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx index 6686fe732d1e..97c210e9065f 100644 --- a/sw/source/uibase/utlui/navipi.cxx +++ b/sw/source/uibase/utlui/navipi.cxx @@ -25,7 +25,6 @@ #include <sot/filelist.hxx> #include <sfx2/event.hxx> #include <sfx2/dispatch.hxx> -#include <sfx2/navigat.hxx> #include <sfx2/viewfrm.hxx> #include <tools/urlobj.hxx> #include <swtypes.hxx> @@ -51,25 +50,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; -//! soon obsolete ! -std::unique_ptr<SfxChildWindowContext> SwNavigationChild::CreateImpl( vcl::Window *pParent, - SfxBindings *pBindings, SfxChildWinInfo* /*pInfo*/ ) -{ - return std::make_unique<SwNavigationChild>(pParent, - /* cast is safe here! */static_cast< sal_uInt16 >(SwView::GetInterfaceId()), - pBindings); -} -void SwNavigationChild::RegisterChildWindowContext(SfxModule* pMod) -{ - auto pFact = std::make_unique<SfxChildWinContextFactory>( - SwNavigationChild::CreateImpl, - /* cast is safe here! */static_cast< sal_uInt16 >(SwView::GetInterfaceId()) ); - SfxChildWindowContext::RegisterChildWindowContext(pMod, SID_NAVIGATOR, std::move(pFact)); -} - - // Filter the control characters out of the Outline-Entry - OUString SwNavigationPI::CleanEntry(const OUString& rEntry) { if (rEntry.isEmpty()) @@ -1114,13 +1095,28 @@ SwView* SwNavigationPI::GetCreateView() const return m_pCreateView; } -SwNavigationChild::SwNavigationChild( vcl::Window* pParent, - sal_uInt16 nId, - SfxBindings* _pBindings ) - : SfxChildWindowContext( nId ) +class SwNavigatorWin : public SfxNavigator +{ +private: + VclPtr<SwNavigationPI> pNavi; +public: + SwNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, vcl::Window* pParent); + virtual void dispose() override + { + pNavi.disposeAndClear(); + SfxNavigator::dispose(); + } + virtual ~SwNavigatorWin() override + { + disposeOnce(); + } +}; + +SwNavigatorWin::SwNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, vcl::Window* pParent) + : SfxNavigator(_pBindings, _pMgr, pParent) { Reference< XFrame > xFrame = _pBindings->GetActiveFrame(); - VclPtr< SwNavigationPI > pNavi = VclPtr< SwNavigationPI >::Create( pParent, xFrame, _pBindings ); + pNavi = VclPtr< SwNavigationPI >::Create( this, xFrame, _pBindings ); _pBindings->Invalidate(SID_NAVIGATOR); SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig(); @@ -1137,15 +1133,21 @@ SwNavigationChild::SwNavigationChild( vcl::Window* pParent, } pNavi->m_xContentTree->SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) ); pNavi->SetRegionDropMode( pNaviConfig->GetRegionMode() ); + pNavi->Show(); - if (SfxNavigator* pNav = dynamic_cast<SfxNavigator*>(pParent)) - { - pNav->SetMinOutputSizePixel(pNavi->GetOptimalSize()); - if (pNaviConfig->IsSmall()) - pNavi->ZoomIn(); - } + SetMinOutputSizePixel(pNavi->GetOptimalSize()); + if (pNaviConfig->IsSmall()) + pNavi->ZoomIn(); +} - SetWindow(pNavi); +SFX_IMPL_DOCKINGWINDOW(SwNavigatorWrapper, SID_NAVIGATOR); + +SwNavigatorWrapper::SwNavigatorWrapper(vcl::Window *_pParent, sal_uInt16 nId, + SfxBindings* pBindings, SfxChildWinInfo* pInfo) + : SfxNavigatorWrapper(_pParent, nId, pBindings, pInfo) +{ + SetWindow(VclPtr<SwNavigatorWin>::Create(pBindings, this, _pParent)); + Initialize(pInfo); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |