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>
diff --git a/include/sfx2/navigat.hxx b/include/sfx2/navigat.hxx
index 29b7c84..f5fc9ac 100644
--- a/include/sfx2/navigat.hxx
+++ b/include/sfx2/navigat.hxx
@@ -23,30 +23,24 @@
#include <sfx2/childwin.hxx>
#include <sfx2/dockwin.hxx>

class SfxNavigatorWrapper final : public SfxChildWindow
class SFX2_DLLPUBLIC SfxNavigatorWrapper : public SfxChildWindow
{

protected:
    void Initialize(SfxChildWinInfo* pInfo);
public:
                        SfxNavigatorWrapper( vcl::Window* pParent ,
                                                sal_uInt16 nId ,
                                                SfxBindings* pBindings ,
                                                SfxChildWinInfo* pInfo );

                        SFX_DECL_CHILDWINDOW(SfxNavigatorWrapper);
    SfxNavigatorWrapper( vcl::Window* pParent ,
                            sal_uInt16 nId ,
                            SfxBindings* pBindings ,
                            SfxChildWinInfo* pInfo );
};

class SFX2_DLLPUBLIC SfxNavigator final : public SfxDockingWindow
class SFX2_DLLPUBLIC SfxNavigator : public SfxDockingWindow
{
    SfxChildWindow*     pWrapper;

public:
                        SfxNavigator( SfxBindings* pBindings ,
                            SfxChildWindow* pChildWin ,
                            vcl::Window* pParent ,
                            WinBits nBits );
    SfxNavigator(SfxBindings* pBindings, SfxChildWindow* pChildWin,
                 vcl::Window* pParent);

    virtual void        Resize() override;
    virtual bool        Close() override;
    virtual void Resize() override;
};

#endif
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index 56d5e10..548ae02 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -177,7 +177,6 @@ void ScDLL::Init()
    // Child Windows

    ScInputWindowWrapper        ::RegisterChildWindow(true, pMod, SfxChildWindowFlags::TASK|SfxChildWindowFlags::FORCEDOCK);
    ScNavigatorDialogWrapper    ::RegisterChildWindowContext(static_cast<sal_uInt16>(ScTabViewShell::GetInterfaceId()), pMod);
    ScSolverDlgWrapper          ::RegisterChildWindow(false, pMod);
    ScOptSolverDlgWrapper       ::RegisterChildWindow(false, pMod);
    ScXMLSourceDlgWrapper       ::RegisterChildWindow(false, pMod);
@@ -225,6 +224,8 @@ void ScDLL::Init()
    sc::SearchResultsDlgWrapper::RegisterChildWindow(false, pMod);
    ScCondFormatDlgWrapper::RegisterChildWindow(false, pMod);

    ScNavigatorWrapper::RegisterChildWindow(false, pMod, SfxChildWindowFlags::NEVERHIDE);

    // Add 3DObject Factory
    E3dObjFactory();

diff --git a/sc/source/ui/inc/navipi.hxx b/sc/source/ui/inc/navipi.hxx
index fae7821..37f6bff 100644
--- a/sc/source/ui/inc/navipi.hxx
+++ b/sc/source/ui/inc/navipi.hxx
@@ -24,6 +24,7 @@
#include <vcl/idle.hxx>
#include <svl/lstner.hxx>
#include <sfx2/childwin.hxx>
#include <sfx2/navigat.hxx>
#include <sfx2/sidebar/PanelLayout.hxx>
#include "content.hxx"

@@ -85,8 +86,8 @@ private:

class ScNavigatorDlg : public PanelLayout, public SfxListener
{
friend class ScNavigatorWin;
friend class ScNavigatorControllerItem;
friend class ScNavigatorDialogWrapper;
friend class ScContentTree;

private:
@@ -179,18 +180,12 @@ public:
    virtual void StateChanged(StateChangedType nStateChange) override;
};

class ScNavigatorDialogWrapper: public SfxChildWindowContext
class ScNavigatorWrapper final : public SfxNavigatorWrapper
{
public:
            ScNavigatorDialogWrapper( vcl::Window*           pParent,
                                      sal_uInt16            nId,
                                      SfxBindings*      pBindings,
                                      SfxChildWinInfo*  pInfo );

    SFX_DECL_CHILDWINDOWCONTEXT(ScNavigatorDialogWrapper)

private:
    VclPtr<ScNavigatorDlg> pNavigator;
    ScNavigatorWrapper(vcl::Window *pParent, sal_uInt16 nId,
                       SfxBindings* pBindings, SfxChildWinInfo* pInfo);
    SFX_DECL_CHILDWINDOW(ScNavigatorWrapper);
};

#endif // INCLUDED_SC_SOURCE_UI_INC_NAVIPI_HXX
diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx
index eda7cc0..5d813e1 100644
--- a/sc/source/ui/navipi/navipi.cxx
+++ b/sc/source/ui/navipi/navipi.cxx
@@ -309,18 +309,29 @@ ScNavigatorSettings::ScNavigatorSettings()
    maExpandedVec.fill(false);
}

SFX_IMPL_CHILDWINDOWCONTEXT( ScNavigatorDialogWrapper, SID_NAVIGATOR )

ScNavigatorDialogWrapper::ScNavigatorDialogWrapper(vcl::Window* pParent,
                                                   sal_uInt16 nId,
                                                   SfxBindings* pBind,
                                                   SAL_UNUSED_PARAMETER SfxChildWinInfo* /* pInfo */)
    : SfxChildWindowContext(nId)
class ScNavigatorWin : public SfxNavigator
{
    pNavigator = VclPtr<ScNavigatorDlg>::Create(pBind, pParent);
    if (SfxNavigator* pNav = dynamic_cast<SfxNavigator*>(pParent))
        pNav->SetMinOutputSizePixel(pNavigator->GetOptimalSize());
    SetWindow(pNavigator);
private:
    VclPtr<ScNavigatorDlg> pNavigator;
public:
    ScNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* pMgr, vcl::Window* pParent);
    virtual void dispose() override
    {
        pNavigator.disposeAndClear();
        SfxNavigator::dispose();
    }
    virtual ~ScNavigatorWin() override
    {
        disposeOnce();
    }
};

ScNavigatorWin::ScNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, vcl::Window* _pParent)
    : SfxNavigator(_pBindings, _pMgr, _pParent)
{
    pNavigator = VclPtr<ScNavigatorDlg>::Create(_pBindings, this);
    pNavigator->Show();
    SetMinOutputSizePixel(pNavigator->GetOptimalSize());
}

ScNavigatorDlg::ScNavigatorDlg(SfxBindings* pB, vcl::Window* pParent)
@@ -936,4 +947,14 @@ void ScNavigatorDlg::EndOfDataArea()
    }
}

SFX_IMPL_DOCKINGWINDOW(ScNavigatorWrapper, SID_NAVIGATOR);

ScNavigatorWrapper::ScNavigatorWrapper(vcl::Window *_pParent, sal_uInt16 nId,
                                       SfxBindings* pBindings, SfxChildWinInfo* pInfo)
    : SfxNavigatorWrapper(_pParent, nId, pBindings, pInfo)
{
    SetWindow(VclPtr<ScNavigatorWin>::Create(pBindings, this, _pParent));
    Initialize(pInfo);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/app/sddll.cxx b/sd/source/ui/app/sddll.cxx
index 828ab88..cbcd201 100644
--- a/sd/source/ui/app/sddll.cxx
+++ b/sd/source/ui/app/sddll.cxx
@@ -148,8 +148,6 @@ void SdDLL::RegisterControllers(SdModule* pMod)
    SdTbxCtlGlueEscDir::RegisterControl( SID_GLUE_ESCDIR, pMod );

    ::sd::AnimationChildWindow::RegisterChildWindow(false, pMod);
    ::sd::NavigatorChildWindow::RegisterChildWindowContext( static_cast<sal_uInt16>(::sd::DrawViewShell::GetInterfaceId()), pMod );
    ::sd::NavigatorChildWindow::RegisterChildWindowContext( static_cast<sal_uInt16>(::sd::GraphicViewShell::GetInterfaceId()), pMod );

    Svx3DChildWindow::RegisterChildWindow(false, pMod);
    SvxFontWorkChildWindow::RegisterChildWindow(false, pMod);
@@ -169,6 +167,8 @@ void SdDLL::RegisterControllers(SdModule* pMod)
    ::sfx2::sidebar::SidebarChildWindow::RegisterChildWindow(false, pMod);
    DevelopmentToolChildWindow::RegisterChildWindow(false, pMod);

    ::sd::SdNavigatorWrapper::RegisterChildWindow(false, pMod, SfxChildWindowFlags::NEVERHIDE);

    SvxFillToolBoxControl::RegisterControl(0, pMod);
    SvxLineWidthToolBoxControl::RegisterControl(0, pMod);

diff --git a/sd/source/ui/dlg/NavigatorChildWindow.cxx b/sd/source/ui/dlg/NavigatorChildWindow.cxx
index 1773734..804a7cc 100644
--- a/sd/source/ui/dlg/NavigatorChildWindow.cxx
+++ b/sd/source/ui/dlg/NavigatorChildWindow.cxx
@@ -22,14 +22,11 @@
#include <app.hrc>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/navigat.hxx>
#include <sfx2/sfxsids.hrc>
#include <svl/eitem.hxx>

namespace sd {

SFX_IMPL_CHILDWINDOWCONTEXT(NavigatorChildWindow, SID_NAVIGATOR)

static void RequestNavigatorUpdate (SfxBindings const * pBindings)
{
    if (pBindings != nullptr
@@ -43,23 +40,47 @@ static void RequestNavigatorUpdate (SfxBindings const * pBindings)
    }
}

NavigatorChildWindow::NavigatorChildWindow (
    vcl::Window* pParent,
    sal_uInt16 nId,
    SfxBindings* pBindings,
    SfxChildWinInfo* )
    : SfxChildWindowContext( nId )
SdNavigatorFloat::SdNavigatorFloat(SfxBindings* _pBindings, SfxChildWindow* _pMgr, vcl::Window* _pParent)
    : SfxNavigator(_pBindings, _pMgr, _pParent)
{
    VclPtr<SdNavigatorWin> pNavWin = VclPtr<SdNavigatorWin>::Create(
        pParent, pBindings);
    pNavWin = VclPtr<SdNavigatorWin>::Create(this, _pBindings);
    pNavWin->Show();

    pNavWin->SetUpdateRequestFunctor(
        [pBindings] () { return RequestNavigatorUpdate(pBindings); });
        [_pBindings] () { return RequestNavigatorUpdate(_pBindings); });

    if (SfxNavigator* pNav = dynamic_cast<SfxNavigator*>(pParent))
        pNav->SetMinOutputSizePixel(pNavWin->GetOptimalSize());
    SetMinOutputSizePixel(pNavWin->GetOptimalSize());
}

    SetWindow( pNavWin );
void SdNavigatorFloat::InitTreeLB(const SdDrawDocument* pDoc)
{
    pNavWin->InitTreeLB(pDoc);
}

void SdNavigatorFloat::FreshTree(const SdDrawDocument* pDoc)
{
    pNavWin->FreshTree(pDoc);
}

void SdNavigatorFloat::dispose()
{
    pNavWin.disposeAndClear();
    SfxNavigator::dispose();
}

SdNavigatorFloat::~SdNavigatorFloat()
{
    disposeOnce();
}

SFX_IMPL_DOCKINGWINDOW(SdNavigatorWrapper, SID_NAVIGATOR);

SdNavigatorWrapper::SdNavigatorWrapper(vcl::Window *_pParent, sal_uInt16 nId,
                                       SfxBindings* pBindings, SfxChildWinInfo* pInfo)
    : SfxNavigatorWrapper(_pParent, nId, pBindings, pInfo)
{
    SetWindow(VclPtr<SdNavigatorFloat>::Create(pBindings, this, _pParent));
    Initialize(pInfo);
}

} // end of namespace sd
diff --git a/sd/source/ui/inc/NavigatorChildWindow.hxx b/sd/source/ui/inc/NavigatorChildWindow.hxx
index 4654c23..4199cab 100644
--- a/sd/source/ui/inc/NavigatorChildWindow.hxx
+++ b/sd/source/ui/inc/NavigatorChildWindow.hxx
@@ -20,26 +20,19 @@
#pragma once

#include <sfx2/childwin.hxx>
#include <sfx2/navigat.hxx>

namespace vcl { class Window; }
class SfxBindings;

namespace sd {

/**
 * Derivative of SfxChildWindowContext as "container" for navigator
 */
class NavigatorChildWindow
    : public SfxChildWindowContext
class SdNavigatorWrapper final : public SfxNavigatorWrapper
{
public:
    NavigatorChildWindow (
        vcl::Window*,
        sal_uInt16,
        SfxBindings*,
        SfxChildWinInfo*);

    SFX_DECL_CHILDWINDOWCONTEXT(NavigatorChildWindow)
    SdNavigatorWrapper(vcl::Window *pParent, sal_uInt16 nId,
                       SfxBindings* pBindings, SfxChildWinInfo* pInfo);
    SFX_DECL_CHILDWINDOW(SdNavigatorWrapper);
};

} // end of namespace sd
diff --git a/sd/source/ui/inc/navigatr.hxx b/sd/source/ui/inc/navigatr.hxx
index e431756..ece000c 100644
--- a/sd/source/ui/inc/navigatr.hxx
+++ b/sd/source/ui/inc/navigatr.hxx
@@ -22,6 +22,7 @@

#include <sfx2/ctrlitem.hxx>
#include <sfx2/sidebar/PanelLayout.hxx>
#include <sfx2/navigat.hxx>
#include "sdtreelb.hxx"
#include <pres.hxx>

@@ -30,7 +31,7 @@ namespace vcl { class Window; }

namespace sd {
class DrawDocShell;
class NavigatorChildWindow;
class SdNavigatorFloat;
}
class Menu;
class SdNavigatorControllerItem;
@@ -77,6 +78,22 @@ private:
    ::sd::DrawDocShell* mpDocShell;
};

namespace sd {

class SdNavigatorFloat : public SfxNavigator
{
private:
    VclPtr<SdNavigatorWin> pNavWin;
public:
    SdNavigatorFloat(SfxBindings* _pBindings, SfxChildWindow* pMgr, vcl::Window* pParent);
    void InitTreeLB(const SdDrawDocument* pDoc);
    void FreshTree(const SdDrawDocument* pDoc);
    virtual void dispose() override;
    virtual ~SdNavigatorFloat() override;
};

}

class SD_DLLPUBLIC SdNavigatorWin : public PanelLayout
{
public:
@@ -103,7 +120,7 @@ public:
    SdPageObjsTLV&              GetObjects();

private:
    friend class ::sd::NavigatorChildWindow;
    friend class SdNavigatorFloat;
    friend class SdNavigatorControllerItem;
    friend class SdPageNameControllerItem;

diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx
index 74844b8..fa8d967 100644
--- a/sd/source/ui/view/drviews4.cxx
+++ b/sd/source/ui/view/drviews4.cxx
@@ -271,7 +271,7 @@ void DrawViewShell::FreshNavigatrTree()
    SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( SID_NAVIGATOR );
    if( pWindow )
    {
        SdNavigatorWin* pNavWin = static_cast<SdNavigatorWin*>( pWindow->GetContextWindow( SD_MOD() ) );
        SdNavigatorFloat* pNavWin = static_cast<SdNavigatorFloat*>( pWindow->GetWindow() );
        if( pNavWin )
            pNavWin->FreshTree( GetDoc() );
    }
diff --git a/sd/source/ui/view/drviewsd.cxx b/sd/source/ui/view/drviewsd.cxx
index 879051b..763ae13 100644
--- a/sd/source/ui/view/drviewsd.cxx
+++ b/sd/source/ui/view/drviewsd.cxx
@@ -57,7 +57,7 @@ void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
            SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( SID_NAVIGATOR );
            if( pWindow )
            {
                SdNavigatorWin* pNavWin = static_cast<SdNavigatorWin*>( pWindow->GetContextWindow( SD_MOD() ) );
                SdNavigatorFloat* pNavWin = static_cast<SdNavigatorFloat*>(pWindow->GetWindow());
                if( pNavWin )
                    pNavWin->InitTreeLB( GetDoc() );
            }
diff --git a/sfx2/source/appl/appreg.cxx b/sfx2/source/appl/appreg.cxx
index 4e74737..6c9810c 100644
--- a/sfx2/source/appl/appreg.cxx
+++ b/sfx2/source/appl/appreg.cxx
@@ -47,7 +47,6 @@ void SfxApplication::Registrations_Impl()

    // ChildWindows
    SfxRecordingFloatWrapper_Impl::RegisterChildWindow();
    SfxNavigatorWrapper::RegisterChildWindow( false, nullptr, SfxChildWindowFlags::NEVERHIDE );
    SfxPartChildWnd_Impl::RegisterChildWindow();
    SfxDockingWrapper::RegisterChildWindow();
    SfxInfoBarContainerChild::RegisterChildWindow( true, nullptr, SfxChildWindowFlags::NEVERHIDE );
diff --git a/sfx2/source/dialog/navigat.cxx b/sfx2/source/dialog/navigat.cxx
index 0d52109..1487bcb 100644
--- a/sfx2/source/dialog/navigat.cxx
+++ b/sfx2/source/dialog/navigat.cxx
@@ -24,20 +24,20 @@
#include <sfx2/sfxsids.hrc>
#include <sfx2/strings.hrc>
#include <sfx2/sfxresid.hxx>
#include <vcl/layout.hxx>
#include <helpids.h>
#include <tools/debug.hxx>

SFX_IMPL_DOCKINGWINDOW( SfxNavigatorWrapper , SID_NAVIGATOR );

SfxNavigatorWrapper::SfxNavigatorWrapper( vcl::Window* pParentWnd ,
                                                sal_uInt16 nId ,
                                                SfxBindings* pBindings ,
                                                SfxChildWinInfo* pInfo )
                                                SfxBindings* /*pBindings*/ ,
                                                SfxChildWinInfo* /*pInfo*/ )
                    : SfxChildWindow( pParentWnd , nId )
{
    SetWindow( VclPtr<SfxNavigator>::Create( pBindings, this, pParentWnd,
        WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK ) );
}

void SfxNavigatorWrapper::Initialize(SfxChildWinInfo* pInfo)
{
    GetWindow()->SetHelpId ( HID_NAVIGATOR_WINDOW );
    GetWindow()->SetOutputSizePixel( Size( 270, 240 ) );

@@ -47,13 +47,11 @@ SfxNavigatorWrapper::SfxNavigatorWrapper( vcl::Window* pParentWnd ,

SfxNavigator::SfxNavigator( SfxBindings* pBind ,
                            SfxChildWindow* pChildWin ,
                            vcl::Window* pParent ,
                            WinBits nBits )
                            vcl::Window* pParent )
                        : SfxDockingWindow( pBind ,
                                            pChildWin ,
                                            pParent ,
                                            nBits )
                        , pWrapper( pChildWin )
                                            WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK )
{
    SetText(SfxResId(STR_SID_NAVIGATOR));
}
@@ -61,14 +59,8 @@ SfxNavigator::SfxNavigator( SfxBindings* pBind ,
void SfxNavigator::Resize()
{
    SfxDockingWindow::Resize();
    if ( pWrapper->GetContextWindow() )
        pWrapper->GetContextWindow()->SetSizePixel( GetOutputSizePixel() );
}

bool SfxNavigator::Close()
{
    DBG_ASSERT( GetChildWindow_Impl()->GetContext_Impl(), "No Context!" );
    return SfxDockingWindow::Close();
    if (vcl::Window *pChild = GetWindow(GetWindowType::FirstChild))
        VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel());
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index d07ca6a..f8e5c01 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -295,7 +295,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 );
@@ -324,6 +323,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 8f0dd96..0b0d013 100644
--- a/sw/source/uibase/inc/navipi.hxx
+++ b/sw/source/uibase/inc/navipi.hxx
@@ -24,6 +24,7 @@
#include <vcl/transfer.hxx>
#include <sfx2/childwin.hxx>
#include <sfx2/sidebar/ControllerItem.hxx>
#include <sfx2/navigat.hxx>
#include <sfx2/weldutils.hxx>
#include <sfx2/sidebar/PanelLayout.hxx>
#include "conttree.hxx"
@@ -31,7 +32,6 @@
#include <memory>

class SwWrtShell;
class SwNavigationChild;
class SfxBindings;
class SwNavigationConfig;
class SwView;
@@ -43,7 +43,7 @@ class SwNavigationPI : public PanelLayout
                     , public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
                     , public SfxListener
{
    friend class SwNavigationChild;
    friend class SwNavigatorWin;
    friend class SwContentTree;
    friend class SwGlobalTree;

@@ -157,17 +157,12 @@ public:
    SwView*         GetCreateView() const;
};

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 c2a428c..6052eaf 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>
@@ -50,25 +49,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())
@@ -1108,13 +1089,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();
@@ -1131,15 +1127,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: */