set SfxTabPage parent dialog explicitly

Change-Id: If7813f9f5e35694312b055cc92868638bc3773d5
Reviewed-on: https://gerrit.libreoffice.org/53326
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index e288e07..9b0aa24 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -266,6 +266,7 @@ protected:
        return static_cast<const T*>(GetOldItem(rSet, sal_uInt16(nSlot), bDeep));
    }
    SfxTabDialog*       GetTabDialog() const;
    void                SetTabDialog(SfxTabDialog* pDialog);

    void                AddItemConnection( sfx::ItemConnectionBase* pConnection );

diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index ff5c508..f31e127 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -52,6 +52,7 @@ struct TabPageImpl
{
    bool                        mbStandard;
    sfx::ItemConnectionArray    maItemConn;
    VclPtr<SfxTabDialog>        mxDialog;
    css::uno::Reference< css::frame::XFrame > mxFrame;

    TabPageImpl() : mbStandard( false ) {}
@@ -307,13 +308,20 @@ void SfxTabPage::AddItemConnection( sfx::ItemConnectionBase* pConnection )
    pImpl->maItemConn.AddConnection( pConnection );
}

void SfxTabPage::SetTabDialog(SfxTabDialog* pDialog)
{
    pImpl->mxDialog = pDialog;
}

SfxTabDialog* SfxTabPage::GetTabDialog() const
{
    return dynamic_cast<SfxTabDialog*>(GetParentDialog());
    return pImpl->mxDialog;
}

OString SfxTabPage::GetConfigId() const
{
    if (m_xContainer)
        return m_xContainer->get_help_id();
    OString sId(GetHelpId());
    if (sId.isEmpty() && isLayoutEnabled(this))
        sId = GetWindow(GetWindowType::FirstChild)->GetHelpId();
@@ -1127,12 +1135,12 @@ IMPL_LINK( SfxTabDialog, ActivatePageHdl, TabControl *, pTabCtrl, void )
    if ( !pTabPage )
    {
        if ( m_pSet )
            pTabPage = (pDataObject->fnCreatePage)( static_cast<vcl::Window*>(pTabCtrl), m_pSet );
            pTabPage = (pDataObject->fnCreatePage)(static_cast<vcl::Window*>(pTabCtrl), m_pSet);
        else
            pTabPage = (pDataObject->fnCreatePage)
                            ( pTabCtrl, CreateInputItemSet( nId ) );
            pTabPage = (pDataObject->fnCreatePage)(pTabCtrl, CreateInputItemSet(nId));
        DBG_ASSERT( nullptr == pDataObject->pTabPage, "create TabPage more than once" );
        pDataObject->pTabPage = pTabPage;
        pTabPage->SetTabDialog(this);

        OUString sConfigId = OStringToOUString(pTabPage->GetConfigId(), RTL_TEXTENCODING_UTF8);
        if (sConfigId.isEmpty())
diff --git a/sw/source/ui/envelp/labprt.hxx b/sw/source/ui/envelp/labprt.hxx
index e36ab98..500f2c4 100644
--- a/sw/source/ui/envelp/labprt.hxx
+++ b/sw/source/ui/envelp/labprt.hxx
@@ -45,7 +45,7 @@ class SwLabPrtPage : public SfxTabPage

    DECL_LINK( CountHdl, Button *, void );

    SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetParentDialog());}
    SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());}

    using TabPage::ActivatePage;
    using TabPage::DeactivatePage;
diff --git a/sw/source/ui/envelp/swuilabimp.hxx b/sw/source/ui/envelp/swuilabimp.hxx
index 09e4dcc..b63c30d 100644
--- a/sw/source/ui/envelp/swuilabimp.hxx
+++ b/sw/source/ui/envelp/swuilabimp.hxx
@@ -72,7 +72,7 @@ public:
    virtual bool FillItemSet(SfxItemSet* rSet) override;
    virtual void Reset(const SfxItemSet* rSet) override;

    SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetParentDialog());}
    SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());}

    void    SetToBusinessCard();