[Libreoffice-commits] core.git: cui/source dbaccess/source editeng/source include/editeng include/sfx2 include/svx include/vcl sc/source sd/inc sd/source sfx2/source svx/source sw/inc sw/source vcl/source

Noel Grandin noel at peralex.com
Thu Oct 27 06:08:55 UTC 2016


 cui/source/dialogs/insrc.cxx                           |    6 
 cui/source/dialogs/newtabledlg.cxx                     |    6 
 cui/source/dialogs/scriptdlg.cxx                       |    2 
 cui/source/dialogs/splitcelldlg.cxx                    |    6 
 cui/source/factory/dlgfact.cxx                         |  263 ++++++++---------
 cui/source/factory/dlgfact.hxx                         |  134 ++++----
 cui/source/inc/insrc.hxx                               |    1 
 cui/source/inc/newtabledlg.hxx                         |    1 
 cui/source/inc/splitcelldlg.hxx                        |    1 
 dbaccess/source/ui/browser/brwctrlr.cxx                |    4 
 dbaccess/source/ui/querydesign/QTableConnection.cxx    |    3 
 dbaccess/source/ui/querydesign/TableConnection.cxx     |    8 
 dbaccess/source/ui/relationdesign/RTableConnection.cxx |    2 
 editeng/source/misc/hangulhanja.cxx                    |    6 
 include/editeng/edtdlg.hxx                             |    6 
 include/sfx2/sfxdlg.hxx                                |   22 -
 include/svx/SpellDialogChildWindow.hxx                 |    2 
 include/svx/hyperdlg.hxx                               |    2 
 include/svx/svxdlg.hxx                                 |   96 +++---
 include/vcl/abstdlg.hxx                                |   20 -
 include/vcl/outdev.hxx                                 |    7 
 sc/source/ui/app/scdll.cxx                             |    1 
 sc/source/ui/attrdlg/scdlgfact.cxx                     |   82 ++---
 sc/source/ui/dbgui/csvcontrol.cxx                      |    1 
 sc/source/ui/docshell/arealink.cxx                     |    8 
 sc/source/ui/inc/cellsh.hxx                            |    6 
 sc/source/ui/inc/csvtablebox.hxx                       |    3 
 sc/source/ui/inc/redcom.hxx                            |    2 
 sc/source/ui/inc/validate.hxx                          |   13 
 sc/source/ui/miscdlgs/redcom.cxx                       |    2 
 sc/source/ui/view/cellsh.cxx                           |    2 
 sc/source/ui/view/cellsh1.cxx                          |    5 
 sc/source/ui/view/cellsh4.cxx                          |    1 
 sc/source/ui/view/gridwin.cxx                          |    1 
 sd/inc/sdabstdlg.hxx                                   |   48 +--
 sd/source/ui/dlg/sddlgfact.cxx                         |   92 ++---
 sd/source/ui/dlg/sddlgfact.hxx                         |   46 +-
 sd/source/ui/docshell/docshel2.cxx                     |    4 
 sfx2/source/appl/appserv.cxx                           |    8 
 sfx2/source/view/printer.cxx                           |    1 
 svx/source/dialog/SpellDialogChildWindow.cxx           |    7 
 svx/source/gallery2/galbrws1.cxx                       |    4 
 sw/inc/swabstdlg.hxx                                   |  100 +++---
 sw/source/ui/dialog/swdlgfact.cxx                      |  206 ++++++-------
 sw/source/ui/dialog/swdlgfact.hxx                      |  101 +++---
 sw/source/uibase/app/apphdl.cxx                        |   11 
 sw/source/uibase/app/docsh2.cxx                        |    5 
 sw/source/uibase/app/docst.cxx                         |    2 
 sw/source/uibase/dbui/dbmgr.cxx                        |    8 
 sw/source/uibase/dialog/wordcountwrapper.cxx           |    5 
 sw/source/uibase/inc/fldwrap.hxx                       |    4 
 sw/source/uibase/inc/idxmrk.hxx                        |    4 
 sw/source/uibase/inc/wordcountdialog.hxx               |    4 
 sw/source/uibase/wrtsh/wrtsh2.cxx                      |    2 
 vcl/source/window/msgbox.cxx                           |    7 
 vcl/source/window/window.cxx                           |    7 
 56 files changed, 747 insertions(+), 654 deletions(-)

New commits:
commit eca5ea9f79181d45cd7fbabe2313617d3025818a
Author: Noel Grandin <noel at peralex.com>
Date:   Wed Sep 21 14:48:15 2016 +0200

    make the AbstractDialog stuff extend from VclReferenceBase
    
    Because some stuff wants to multiple-inherit from VclAbstractDialog and
    OutputDevice-subclasses, and we'd prefer to keep all the lifetime
    management through a single smart pointer class (VclPtr)
    
    The change in msgbox.cxx and window.cxx is to workaround a bug in
    VS2013 to do with virtual inheritance and delegating constructors.
    
    Change-Id: I178e8983b7d20a7d2790aa283be838dca5d14773
    Reviewed-on: https://gerrit.libreoffice.org/29140
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/cui/source/dialogs/insrc.cxx b/cui/source/dialogs/insrc.cxx
index 13f18c3..a6d6a4b 100644
--- a/cui/source/dialogs/insrc.cxx
+++ b/cui/source/dialogs/insrc.cxx
@@ -47,10 +47,16 @@ SvxInsRowColDlg::SvxInsRowColDlg(vcl::Window* pParent, bool bCol, const OString&
 
 SvxInsRowColDlg::~SvxInsRowColDlg()
 {
+    disposeOnce();
+}
+
+void SvxInsRowColDlg::dispose()
+{
     m_pCountEdit.clear();
     m_pBeforeBtn.clear();
     m_pAfterBtn.clear();
     m_pDialog.disposeAndClear();
+    SvxAbstractInsRowColDlg::dispose();
 }
 
 short SvxInsRowColDlg::Execute()
diff --git a/cui/source/dialogs/newtabledlg.cxx b/cui/source/dialogs/newtabledlg.cxx
index 6c02303..50e7527 100644
--- a/cui/source/dialogs/newtabledlg.cxx
+++ b/cui/source/dialogs/newtabledlg.cxx
@@ -30,9 +30,15 @@ SvxNewTableDialog::SvxNewTableDialog()
 
 SvxNewTableDialog::~SvxNewTableDialog()
 {
+    disposeOnce();
+}
+
+void SvxNewTableDialog::dispose()
+{
     mpNumColumns.clear();
     mpNumRows.clear();
     m_pDialog.disposeAndClear();
+    SvxAbstractNewTableDialog::dispose();
 }
 
 short SvxNewTableDialog::Execute()
diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index 8f7b433..a737b9e 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -71,7 +71,7 @@ using namespace css::document;
 
 void ShowErrorDialog( const Any& aException )
 {
-    std::unique_ptr<SvxScriptErrorDialog> pDlg(new SvxScriptErrorDialog( aException ));
+    ScopedVclPtrInstance<SvxScriptErrorDialog> pDlg( aException );
     pDlg->Execute();
 }
 
diff --git a/cui/source/dialogs/splitcelldlg.cxx b/cui/source/dialogs/splitcelldlg.cxx
index 3fdf3e5..f786644 100644
--- a/cui/source/dialogs/splitcelldlg.cxx
+++ b/cui/source/dialogs/splitcelldlg.cxx
@@ -66,11 +66,17 @@ SvxSplitTableDlg::SvxSplitTableDlg( vcl::Window *pParent, bool bIsTableVertical,
 
 SvxSplitTableDlg::~SvxSplitTableDlg()
 {
+    disposeOnce();
+}
+
+void SvxSplitTableDlg::dispose()
+{
     m_pCountEdit.clear();
     m_pHorzBox.clear();
     m_pVertBox.clear();
     m_pPropCB.clear();
     m_pDialog.disposeAndClear();
+    SvxAbstractSplittTableDialog::dispose();
 }
 
 IMPL_LINK( SvxSplitTableDlg, ClickHdl, Button *, pButton, void )
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 47f4f4c..01e97c7 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -143,7 +143,13 @@ IMPL_ABSTDLG_BASE(AbstractScreenshotAnnotationDlg_Impl);
 // virtual
 VclAbstractDialog2_Impl::~VclAbstractDialog2_Impl()
 {
+    disposeOnce();
+}
+
+void VclAbstractDialog2_Impl::dispose()
+{
     m_pDlg.disposeAndClear();
+    VclAbstractDialog2::dispose();
 }
 
 // virtual
@@ -798,7 +804,7 @@ bool AbstractPasswordToOpenModifyDialog_Impl::IsRecommendToOpenReadonly() const
 }
 
 // Create dialogs with simplest interface
-VclAbstractDialog* AbstractDialogFactory_Impl::CreateVclDialog( vcl::Window* pParent, sal_uInt32 nResId )
+VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateVclDialog( vcl::Window* pParent, sal_uInt32 nResId )
 {
     VclPtr<Dialog> pDlg;
     switch ( nResId )
@@ -834,11 +840,11 @@ VclAbstractDialog* AbstractDialogFactory_Impl::CreateVclDialog( vcl::Window* pPa
     }
 
     if ( pDlg )
-        return new CuiVclAbstractDialog_Impl( pDlg );
+        return VclPtr<CuiVclAbstractDialog_Impl>::Create( pDlg );
     return nullptr;
 }
 
-VclAbstractDialog* AbstractDialogFactory_Impl::CreateFrameDialog( const Reference< frame::XFrame >& rxFrame,
+VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateFrameDialog( const Reference< frame::XFrame >& rxFrame,
     sal_uInt32 nResId, const OUString& rParameter )
 {
     VclPtr<Dialog> pDlg;
@@ -855,19 +861,19 @@ VclAbstractDialog* AbstractDialogFactory_Impl::CreateFrameDialog( const Referenc
     }
 
     if ( pDlg )
-        return new CuiVclAbstractDialog_Impl( pDlg );
+        return VclPtr<CuiVclAbstractDialog_Impl>::Create( pDlg );
     else
         return nullptr;
 }
 
 // TabDialog outside the drawing layer
-SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateAutoCorrTabDialog( const SfxItemSet* pAttrSet )
+VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateAutoCorrTabDialog( const SfxItemSet* pAttrSet )
 {
     VclPtrInstance<OfaAutoCorrDlg> pDlg( nullptr, pAttrSet );
-    return new CuiAbstractTabDialog_Impl( pDlg );
+    return VclPtr<CuiAbstractTabDialog_Impl>::Create( pDlg );
 }
 
-SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateCustomizeTabDialog(
+VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateCustomizeTabDialog(
                                                 const SfxItemSet* pAttrSet,
                                                 const Reference< frame::XFrame >& xViewFrame )
 {
@@ -875,96 +881,95 @@ SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateCustomizeTabDialog(
     VclPtrInstance<SvxConfigDialog> pDlg1( nullptr, pAttrSet );
     pDlg1->SetFrame(xViewFrame);
     pDlg.reset(pDlg1);
-    return new CuiAbstractTabDialog_Impl( pDlg );
+    return VclPtr<CuiAbstractTabDialog_Impl>::Create( pDlg );
 }
 
 // TabDialog that use functionality of the drawing layer
-SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateTextTabDialog( vcl::Window* pParent,
+VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateTextTabDialog( vcl::Window* pParent,
                                             const SfxItemSet* pAttrSet,
                                             SdrView* pView )
 {
     VclPtrInstance<SvxTextTabDialog> pDlg( pParent, pAttrSet, pView );
-    return new CuiAbstractTabDialog_Impl( pDlg );
+    return VclPtr<CuiAbstractTabDialog_Impl>::Create( pDlg );
 }
 
 // TabDialog that use functionality of the drawing layer and add AnchorTypes -- for SvxCaptionTabDialog
-AbstractSvxCaptionDialog*       AbstractDialogFactory_Impl::CreateCaptionDialog( vcl::Window* pParent,
+VclPtr<AbstractSvxCaptionDialog>      AbstractDialogFactory_Impl::CreateCaptionDialog( vcl::Window* pParent,
                                             const SdrView* pView,
                                             SvxAnchorIds nAnchorTypes )
 {
     VclPtrInstance<SvxCaptionTabDialog> pDlg( pParent, pView, nAnchorTypes );
-    return new AbstractSvxCaptionDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxCaptionDialog_Impl>::Create( pDlg );
 }
 
-AbstractSvxDistributeDialog*    AbstractDialogFactory_Impl::CreateSvxDistributeDialog(const SfxItemSet& rAttr)
+VclPtr<AbstractSvxDistributeDialog>    AbstractDialogFactory_Impl::CreateSvxDistributeDialog(const SfxItemSet& rAttr)
 {
     VclPtrInstance<SvxDistributeDialog> pDlg( nullptr, rAttr, SvxDistributeHorizontal::NONE, SvxDistributeVertical::NONE);
-    return new AbstractSvxDistributeDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxDistributeDialog_Impl>::Create( pDlg );
 }
 
-AbstractHangulHanjaConversionDialog* AbstractDialogFactory_Impl::CreateHangulHanjaConversionDialog(vcl::Window* pParent,
+VclPtr<AbstractHangulHanjaConversionDialog> AbstractDialogFactory_Impl::CreateHangulHanjaConversionDialog(vcl::Window* pParent,
                                                                        editeng::HangulHanjaConversion::ConversionDirection _ePrimaryDirection )
 {
     VclPtrInstance<HangulHanjaConversionDialog> pDlg( pParent, _ePrimaryDirection);
-    return new AbstractHangulHanjaConversionDialog_Impl( pDlg );
+    return VclPtr<AbstractHangulHanjaConversionDialog_Impl>::Create( pDlg );
 }
 
-AbstractThesaurusDialog* AbstractDialogFactory_Impl::CreateThesaurusDialog( vcl::Window* pParent,
+VclPtr<AbstractThesaurusDialog> AbstractDialogFactory_Impl::CreateThesaurusDialog( vcl::Window* pParent,
                                 css::uno::Reference< css::linguistic2::XThesaurus >  xThesaurus,
                                 const OUString &rWord, sal_Int16 nLanguage )
 {
     VclPtrInstance<SvxThesaurusDialog> pDlg( pParent, xThesaurus, rWord, nLanguage );
-    return new AbstractThesaurusDialog_Impl( pDlg );
+    return VclPtr<AbstractThesaurusDialog_Impl>::Create( pDlg );
 }
 
-AbstractHyphenWordDialog* AbstractDialogFactory_Impl::CreateHyphenWordDialog( vcl::Window* pParent,
+VclPtr<AbstractHyphenWordDialog> AbstractDialogFactory_Impl::CreateHyphenWordDialog( vcl::Window* pParent,
                                                 const OUString &rWord, LanguageType nLang,
                                                 css::uno::Reference< css::linguistic2::XHyphenator >  &xHyphen,
                                                 SvxSpellWrapper* pWrapper )
 {
     VclPtrInstance<SvxHyphenWordDialog> pDlg( rWord, nLang, pParent, xHyphen, pWrapper );
-    return new AbstractHyphenWordDialog_Impl( pDlg );
+    return VclPtr<AbstractHyphenWordDialog_Impl>::Create( pDlg );
 }
 
-AbstractFmShowColsDialog * AbstractDialogFactory_Impl::CreateFmShowColsDialog()
+VclPtr<AbstractFmShowColsDialog> AbstractDialogFactory_Impl::CreateFmShowColsDialog()
 {
     VclPtrInstance<FmShowColsDialog> pDlg( nullptr );
-    return new AbstractFmShowColsDialog_Impl( pDlg );
+    return VclPtr<AbstractFmShowColsDialog_Impl>::Create( pDlg );
 }
-AbstractSvxZoomDialog * AbstractDialogFactory_Impl::CreateSvxZoomDialog( vcl::Window* pParent,
+
+VclPtr<AbstractSvxZoomDialog> AbstractDialogFactory_Impl::CreateSvxZoomDialog( vcl::Window* pParent,
                                             const SfxItemSet& rCoreSet)
 {
     VclPtrInstance<SvxZoomDialog> pDlg( pParent, rCoreSet);
-    return new AbstractSvxZoomDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxZoomDialog_Impl>::Create( pDlg );
 }
 
-AbstractSpellDialog *  AbstractDialogFactory_Impl::CreateSvxSpellDialog(
+VclPtr<AbstractSpellDialog> AbstractDialogFactory_Impl::CreateSvxSpellDialog(
                         vcl::Window* pParent,
                         SfxBindings* pBindings,
                         svx::SpellDialogChildWindow* pSpellChildWindow )
 {
     VclPtrInstance<svx::SpellDialog> pDlg(pSpellChildWindow, pParent, pBindings);
-    return new AbstractSpellDialog_Impl(pDlg);
+    return VclPtr<AbstractSpellDialog_Impl>::Create(pDlg);
 }
 
-VclAbstractRefreshableDialog * AbstractDialogFactory_Impl::CreateActualizeProgressDialog( vcl::Window* pParent, GalleryTheme* pThm )
+VclPtr<VclAbstractRefreshableDialog> AbstractDialogFactory_Impl::CreateActualizeProgressDialog( vcl::Window* pParent, GalleryTheme* pThm )
 {
    VclPtrInstance<ActualizeProgress> pDlg(pParent, pThm);
-   return new VclAbstractRefreshableDialog_Impl( pDlg );
+   return VclPtr<VclAbstractRefreshableDialog_Impl>::Create( pDlg );
 }
 
-VclAbstractDialog*
-AbstractDialogFactory_Impl::CreateScriptErrorDialog(const css::uno::Any& rException)
+VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateScriptErrorDialog(const css::uno::Any& rException)
 {
-    return new SvxScriptErrorDialog(rException);
+    return VclPtr<SvxScriptErrorDialog>::Create(rException);
 }
 
-AbstractScriptSelectorDialog*
-AbstractDialogFactory_Impl::CreateScriptSelectorDialog(
+VclPtr<AbstractScriptSelectorDialog> AbstractDialogFactory_Impl::CreateScriptSelectorDialog(
     vcl::Window* pParent, const Reference< frame::XFrame >& _rxFrame )
 {
     VclPtrInstance<SvxScriptSelectorDialog> pDlg(pParent, false/*bShowSlots*/, _rxFrame);
-    return new AbstractScriptSelectorDialog_Impl(pDlg);
+    return VclPtr<AbstractScriptSelectorDialog_Impl>::Create(pDlg);
 }
 
 OUString AbstractScriptSelectorDialog_Impl::GetScriptURL() const
@@ -981,72 +986,72 @@ void AbstractScriptSelectorDialog_Impl::SetRunLabel()
     return;
 }
 
-VclAbstractDialog * AbstractDialogFactory_Impl::CreateSvxScriptOrgDialog( vcl::Window* pParent,
+VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateSvxScriptOrgDialog( vcl::Window* pParent,
                                             const OUString& rLanguage)
 {
     VclPtrInstance<SvxScriptOrgDialog> pDlg( pParent, rLanguage);
-    return new CuiVclAbstractDialog_Impl( pDlg );
+    return VclPtr<CuiVclAbstractDialog_Impl>::Create( pDlg );
 }
 
-AbstractTitleDialog * AbstractDialogFactory_Impl::CreateTitleDialog( vcl::Window* pParent,
+VclPtr<AbstractTitleDialog> AbstractDialogFactory_Impl::CreateTitleDialog( vcl::Window* pParent,
                                             const OUString& rOldText)
 {
    VclPtrInstance<TitleDialog> pDlg( pParent, rOldText);
-   return new AbstractTitleDialog_Impl( pDlg );
+   return VclPtr<AbstractTitleDialog_Impl>::Create( pDlg );
 }
 
-AbstractGalleryIdDialog * AbstractDialogFactory_Impl::CreateGalleryIdDialog( vcl::Window* pParent,
+VclPtr<AbstractGalleryIdDialog> AbstractDialogFactory_Impl::CreateGalleryIdDialog( vcl::Window* pParent,
                                             GalleryTheme* pThm )
 {
    VclPtrInstance<GalleryIdDialog> pDlg( pParent, pThm);
-   return new AbstractGalleryIdDialog_Impl( pDlg );
+   return VclPtr<AbstractGalleryIdDialog_Impl>::Create( pDlg );
 }
 
-VclAbstractDialog2 * AbstractDialogFactory_Impl::CreateGalleryThemePropertiesDialog(
+VclPtr<VclAbstractDialog2> AbstractDialogFactory_Impl::CreateGalleryThemePropertiesDialog(
                                             ExchangeData* pData,
                                             SfxItemSet* pItemSet)
 {
     VclPtrInstance<GalleryThemeProperties> pDlg( nullptr, pData, pItemSet);
-    return new VclAbstractDialog2_Impl( pDlg );
+    return VclPtr<VclAbstractDialog2_Impl>::Create( pDlg );
 }
 
-AbstractURLDlg * AbstractDialogFactory_Impl::CreateURLDialog( vcl::Window* pParent,
+VclPtr<AbstractURLDlg> AbstractDialogFactory_Impl::CreateURLDialog( vcl::Window* pParent,
                                             const OUString& rURL, const OUString& rAltText, const OUString& rDescription,
                                             const OUString& rTarget, const OUString& rName,
                                             TargetList& rTargetList )
 {
     VclPtrInstance<URLDlg> pDlg( pParent, rURL, rAltText, rDescription,
                                  rTarget, rName, rTargetList);
-    return new AbstractURLDlg_Impl( pDlg );
+    return VclPtr<AbstractURLDlg_Impl>::Create( pDlg );
 }
 
-SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateTabItemDialog(vcl::Window* pParent,
+VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateTabItemDialog(vcl::Window* pParent,
     const SfxItemSet& rSet)
 {
     VclPtrInstance<SvxSearchFormatDialog> pDlg(pParent, rSet);
-    return new CuiAbstractTabDialog_Impl(pDlg);
+    return VclPtr<CuiAbstractTabDialog_Impl>::Create(pDlg);
 }
 
-VclAbstractDialog*      AbstractDialogFactory_Impl::CreateSvxSearchAttributeDialog( vcl::Window* pParent,
+VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateSvxSearchAttributeDialog( vcl::Window* pParent,
                                             SearchAttrItemList& rLst,
                                             const sal_uInt16* pWhRanges )
 {
     VclPtrInstance<SvxSearchAttributeDialog> pDlg( pParent, rLst, pWhRanges);
-    return new CuiVclAbstractDialog_Impl( pDlg );
+    return VclPtr<CuiVclAbstractDialog_Impl>::Create( pDlg );
 }
 
-AbstractSvxSearchSimilarityDialog * AbstractDialogFactory_Impl::CreateSvxSearchSimilarityDialog( vcl::Window* pParent,
+VclPtr<AbstractSvxSearchSimilarityDialog> AbstractDialogFactory_Impl::CreateSvxSearchSimilarityDialog( vcl::Window* pParent,
                                                             bool bRelax,
                                                             sal_uInt16 nOther,
                                                             sal_uInt16 nShorter,
                                                             sal_uInt16 nLonger)
 {
     VclPtrInstance<SvxSearchSimilarityDialog> pDlg( pParent, bRelax, nOther, nShorter, nLonger );
-    return new AbstractSvxSearchSimilarityDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxSearchSimilarityDialog_Impl>::Create( pDlg );
 }
 
 //UUUU
-SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateSvxBorderBackgroundDlg(
+VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxBorderBackgroundDlg(
     vcl::Window* pParent,
     const SfxItemSet& rCoreSet,
     bool bEnableSelector,
@@ -1058,19 +1063,19 @@ SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateSvxBorderBackgroundDlg(
         bEnableSelector,
         bEnableDrawingLayerFillStyles);
 
-    return new CuiAbstractTabDialog_Impl(pDlg);
+    return VclPtr<CuiAbstractTabDialog_Impl>::Create(pDlg);
 }
 
-AbstractSvxTransformTabDialog* AbstractDialogFactory_Impl::CreateSvxTransformTabDialog( vcl::Window* pParent,
+VclPtr<AbstractSvxTransformTabDialog> AbstractDialogFactory_Impl::CreateSvxTransformTabDialog( vcl::Window* pParent,
                                                                               const SfxItemSet* pAttr,
                                                                                 const SdrView* pView,
                                                                                 SvxAnchorIds nAnchorTypes )
 {
     VclPtrInstance<SvxTransformTabDialog> pDlg( pParent, pAttr,pView, nAnchorTypes);
-    return new AbstractSvxTransformTabDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxTransformTabDialog_Impl>::Create( pDlg );
 }
 
-SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateSchTransformTabDialog( vcl::Window* pParent,
+VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSchTransformTabDialog( vcl::Window* pParent,
                                                                 const SfxItemSet* pAttr,
                                                                 const SdrView* pSdrView,
                                                                 bool bSizeTabPage
@@ -1079,73 +1084,73 @@ SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateSchTransformTabDialog( v
     VclPtrInstance<SvxTransformTabDialog> pDlg( pParent, pAttr,pSdrView, bSizeTabPage ? SvxAnchorIds::NoProtect :  SvxAnchorIds::NoProtect|SvxAnchorIds::NoResize);
     pDlg->RemoveTabPage( "RID_SVXPAGE_ANGLE" );
     pDlg->RemoveTabPage( "RID_SVXPAGE_SLANT" );
-    return new CuiAbstractTabDialog_Impl( pDlg );
+    return VclPtr<CuiAbstractTabDialog_Impl>::Create( pDlg );
 }
 
-AbstractSvxJSearchOptionsDialog * AbstractDialogFactory_Impl::CreateSvxJSearchOptionsDialog( vcl::Window* pParent,
+VclPtr<AbstractSvxJSearchOptionsDialog> AbstractDialogFactory_Impl::CreateSvxJSearchOptionsDialog( vcl::Window* pParent,
                                                             const SfxItemSet& rOptionsSet,
                                                             sal_Int32 nInitialFlags)
 {
     VclPtrInstance<SvxJSearchOptionsDialog> pDlg( pParent, rOptionsSet, nInitialFlags );
-    return new AbstractSvxJSearchOptionsDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxJSearchOptionsDialog_Impl>::Create( pDlg );
 }
 
-AbstractFmInputRecordNoDialog * AbstractDialogFactory_Impl::CreateFmInputRecordNoDialog( )
+VclPtr<AbstractFmInputRecordNoDialog> AbstractDialogFactory_Impl::CreateFmInputRecordNoDialog( )
 {
     VclPtrInstance<FmInputRecordNoDialog> pDlg( nullptr );
-    return new AbstractFmInputRecordNoDialog_Impl( pDlg );
+    return VclPtr<AbstractFmInputRecordNoDialog_Impl>::Create( pDlg );
 }
 
-AbstractSvxNewDictionaryDialog * AbstractDialogFactory_Impl::CreateSvxNewDictionaryDialog( vcl::Window* pParent )
+VclPtr<AbstractSvxNewDictionaryDialog> AbstractDialogFactory_Impl::CreateSvxNewDictionaryDialog( vcl::Window* pParent )
 {
     VclPtrInstance<SvxNewDictionaryDialog> pDlg( pParent );
-    return new AbstractSvxNewDictionaryDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxNewDictionaryDialog_Impl>::Create( pDlg );
 }
 
-VclAbstractDialog*      AbstractDialogFactory_Impl::CreateSvxEditDictionaryDialog( vcl::Window* pParent,
+VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateSvxEditDictionaryDialog( vcl::Window* pParent,
                                             const OUString& rName )
 {
     VclPtrInstance<SvxEditDictionaryDialog> pDlg( pParent, rName );
-    return new CuiVclAbstractDialog_Impl( pDlg );
+    return VclPtr<CuiVclAbstractDialog_Impl>::Create( pDlg );
 }
 
-AbstractSvxNameDialog * AbstractDialogFactory_Impl::CreateSvxNameDialog( vcl::Window* pParent,
+VclPtr<AbstractSvxNameDialog> AbstractDialogFactory_Impl::CreateSvxNameDialog( vcl::Window* pParent,
                                     const OUString& rName, const OUString& rDesc )
 {
     VclPtrInstance<SvxNameDialog> pDlg( pParent, rName, rDesc );
-    return new AbstractSvxNameDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxNameDialog_Impl>::Create( pDlg );
 }
 
-AbstractSvxObjectNameDialog* AbstractDialogFactory_Impl::CreateSvxObjectNameDialog(const OUString& rName )
+VclPtr<AbstractSvxObjectNameDialog> AbstractDialogFactory_Impl::CreateSvxObjectNameDialog(const OUString& rName )
 {
-    return new AbstractSvxObjectNameDialog_Impl(VclPtr<SvxObjectNameDialog>::Create(nullptr, rName));
+    return VclPtr<AbstractSvxObjectNameDialog_Impl>::Create(VclPtr<SvxObjectNameDialog>::Create(nullptr, rName));
 }
 
-AbstractSvxObjectTitleDescDialog* AbstractDialogFactory_Impl::CreateSvxObjectTitleDescDialog(const OUString& rTitle, const OUString& rDescription)
+VclPtr<AbstractSvxObjectTitleDescDialog> AbstractDialogFactory_Impl::CreateSvxObjectTitleDescDialog(const OUString& rTitle, const OUString& rDescription)
 {
-    return new AbstractSvxObjectTitleDescDialog_Impl(VclPtr<SvxObjectTitleDescDialog>::Create(nullptr, rTitle, rDescription));
+    return VclPtr<AbstractSvxObjectTitleDescDialog_Impl>::Create(VclPtr<SvxObjectTitleDescDialog>::Create(nullptr, rTitle, rDescription));
 }
 
-AbstractSvxMultiPathDialog * AbstractDialogFactory_Impl::CreateSvxMultiPathDialog(vcl::Window* pParent)
+VclPtr<AbstractSvxMultiPathDialog> AbstractDialogFactory_Impl::CreateSvxMultiPathDialog(vcl::Window* pParent)
 {
     VclPtrInstance<SvxMultiPathDialog> pDlg(pParent);
-    return new AbstractSvxMultiPathDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxMultiPathDialog_Impl>::Create( pDlg );
 }
 
-AbstractSvxMultiPathDialog * AbstractDialogFactory_Impl::CreateSvxPathSelectDialog(vcl::Window* pParent)
+VclPtr<AbstractSvxMultiPathDialog> AbstractDialogFactory_Impl::CreateSvxPathSelectDialog(vcl::Window* pParent)
 {
     VclPtrInstance<SvxPathSelectDialog> pDlg(pParent);
-    return new AbstractSvxPathSelectDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxPathSelectDialog_Impl>::Create( pDlg );
 }
 
-AbstractSvxHpLinkDlg * AbstractDialogFactory_Impl::CreateSvxHpLinkDlg (vcl::Window* pParent,
+VclPtr<AbstractSvxHpLinkDlg> AbstractDialogFactory_Impl::CreateSvxHpLinkDlg (vcl::Window* pParent,
                                             SfxBindings* pBindings)
 {
     SvxHpLinkDlg* pDlg = VclPtr<SvxHpLinkDlg>::Create( pParent, pBindings );
-    return new AbstractSvxHpLinkDlg_Impl(pDlg);
+    return VclPtr<AbstractSvxHpLinkDlg_Impl>::Create(pDlg);
 }
 
-AbstractFmSearchDialog*  AbstractDialogFactory_Impl::CreateFmSearchDialog(vcl::Window* pParent,
+VclPtr<AbstractFmSearchDialog> AbstractDialogFactory_Impl::CreateFmSearchDialog(vcl::Window* pParent,
                                                         const OUString& strInitialText,
                                                         const ::std::vector< OUString >& _rContexts,
                                                         sal_Int16 nInitialContext,
@@ -1153,70 +1158,70 @@ AbstractFmSearchDialog*  AbstractDialogFactory_Impl::CreateFmSearchDialog(vcl::W
 {
     VclPtrInstance<FmSearchDialog> pDlg( pParent, strInitialText, _rContexts,
                                          nInitialContext, lnkContextSupplier );
-    return new AbstractFmSearchDialog_Impl( pDlg );
+    return VclPtr<AbstractFmSearchDialog_Impl>::Create( pDlg );
 }
 
-AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterEmboss (vcl::Window* pParent,
+VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterEmboss (vcl::Window* pParent,
                                             const Graphic& rGraphic)
 {
     VclPtrInstance<GraphicFilterEmboss> pDlg( pParent, rGraphic, RectPoint::MM );
-    return new AbstractGraphicFilterDialog_Impl( pDlg );
+    return VclPtr<AbstractGraphicFilterDialog_Impl>::Create( pDlg );
 }
 
-AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterPoster(vcl::Window* pParent,
+VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterPoster(vcl::Window* pParent,
                                             const Graphic& rGraphic)
 {
     VclPtrInstance<GraphicFilterPoster> pDlg( pParent, rGraphic, 16 );
-    return new AbstractGraphicFilterDialog_Impl( pDlg );
+    return VclPtr<AbstractGraphicFilterDialog_Impl>::Create( pDlg );
 }
 
-AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterSepia (vcl::Window* pParent,
+VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterSepia (vcl::Window* pParent,
                                             const Graphic& rGraphic)
 {
     VclPtrInstance<GraphicFilterSepia> pDlg( pParent, rGraphic, 10 );
-    return new AbstractGraphicFilterDialog_Impl( pDlg );
+    return VclPtr<AbstractGraphicFilterDialog_Impl>::Create( pDlg );
 }
 
-AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterSmooth(vcl::Window* pParent,
+VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterSmooth(vcl::Window* pParent,
                                             const Graphic& rGraphic, double nRadius)
 {
     VclPtrInstance<GraphicFilterSmooth> pDlg( pParent, rGraphic, nRadius );
-    return new AbstractGraphicFilterDialog_Impl( pDlg );
+    return VclPtr<AbstractGraphicFilterDialog_Impl>::Create( pDlg );
 }
 
-AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterSolarize (vcl::Window* pParent,
+VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterSolarize (vcl::Window* pParent,
                                             const Graphic& rGraphic)
 {
     VclPtrInstance<GraphicFilterSolarize> pDlg( pParent, rGraphic, 128, false/*bInvert*/ );
-    return new AbstractGraphicFilterDialog_Impl( pDlg );
+    return VclPtr<AbstractGraphicFilterDialog_Impl>::Create( pDlg );
 }
 
-AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterMosaic (vcl::Window* pParent,
+VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterMosaic (vcl::Window* pParent,
                                             const Graphic& rGraphic)
 {
     VclPtrInstance<GraphicFilterMosaic> pDlg(pParent, rGraphic, 4, 4, false/*bEnhanceEdges*/);
-    return new AbstractGraphicFilterDialog_Impl( pDlg );
+    return VclPtr<AbstractGraphicFilterDialog_Impl>::Create( pDlg );
 }
 
-AbstractSvxAreaTabDialog* AbstractDialogFactory_Impl::CreateSvxAreaTabDialog( vcl::Window* pParent,
+VclPtr<AbstractSvxAreaTabDialog> AbstractDialogFactory_Impl::CreateSvxAreaTabDialog( vcl::Window* pParent,
                                                             const SfxItemSet* pAttr,
                                                             SdrModel* pModel,
                                                             bool bShadow)
 {
     VclPtrInstance<SvxAreaTabDialog> pDlg( pParent, pAttr, pModel, bShadow );
-    return new AbstractSvxAreaTabDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxAreaTabDialog_Impl>::Create( pDlg );
 }
 
-SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateSvxLineTabDialog( vcl::Window* pParent, const SfxItemSet* pAttr, //add forSvxLineTabDialog
+VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxLineTabDialog( vcl::Window* pParent, const SfxItemSet* pAttr, //add forSvxLineTabDialog
                                                                  SdrModel* pModel,
                                                                  const SdrObject* pObj ,
                                                                  bool bHasObj)
 {
     VclPtrInstance<SvxLineTabDialog> pDlg( pParent, pAttr, pModel,pObj,bHasObj );
-    return new CuiAbstractTabDialog_Impl( pDlg );
+    return VclPtr<CuiAbstractTabDialog_Impl>::Create( pDlg );
 }
 
-SfxAbstractDialog* AbstractDialogFactory_Impl::CreateSfxDialog( vcl::Window* pParent,
+VclPtr<SfxAbstractDialog> AbstractDialogFactory_Impl::CreateSfxDialog( vcl::Window* pParent,
                                                                         const SfxItemSet& rAttr,
                                                                         const Reference< XFrame >& _rxDocumentFrame,
                                                                         sal_uInt32 nResId
@@ -1236,11 +1241,11 @@ SfxAbstractDialog* AbstractDialogFactory_Impl::CreateSfxDialog( vcl::Window* pPa
     }
 
     if ( pDlg )
-        return new CuiAbstractSfxDialog_Impl( pDlg );
+        return VclPtr<CuiAbstractSfxDialog_Impl>::Create( pDlg );
     return nullptr;
 }
 
-SfxAbstractDialog* AbstractDialogFactory_Impl::CreateSfxDialog( vcl::Window* pParent,
+VclPtr<SfxAbstractDialog> AbstractDialogFactory_Impl::CreateSfxDialog( vcl::Window* pParent,
                                                                         const SfxItemSet& rAttr,
                                                                         const SdrView* pView,
                                                                         sal_uInt32 nResId
@@ -1264,17 +1269,17 @@ SfxAbstractDialog* AbstractDialogFactory_Impl::CreateSfxDialog( vcl::Window* pPa
     }
 
     if ( pDlg )
-        return new CuiAbstractSfxDialog_Impl( pDlg );
+        return VclPtr<CuiAbstractSfxDialog_Impl>::Create( pDlg );
 
     return nullptr;
 }
 
-AbstractSvxPostItDialog* AbstractDialogFactory_Impl::CreateSvxPostItDialog( vcl::Window* pParent,
+VclPtr<AbstractSvxPostItDialog> AbstractDialogFactory_Impl::CreateSvxPostItDialog( vcl::Window* pParent,
                                                                         const SfxItemSet& rCoreSet,
                                                                         bool bPrevNext )
 {
     VclPtrInstance<SvxPostItDialog> pDlg( pParent, rCoreSet, bPrevNext );
-    return new AbstractSvxPostItDialog_Impl( pDlg );
+    return VclPtr<AbstractSvxPostItDialog_Impl>::Create( pDlg );
 }
 
 class SvxMacroAssignDialog : public VclAbstractDialog
@@ -1290,10 +1295,11 @@ public:
 
     virtual short Execute() override;
     virtual ~SvxMacroAssignDialog() override;
+    virtual void dispose() override;
 
 private:
     SfxItemSet                              m_aItems;
-    VclPtr< SvxMacroAssignDlg >             m_pDialog;
+    VclPtr<SvxMacroAssignDlg >              m_pDialog;
 };
 
 short SvxMacroAssignDialog::Execute()
@@ -1303,13 +1309,20 @@ short SvxMacroAssignDialog::Execute()
 
 SvxMacroAssignDialog::~SvxMacroAssignDialog()
 {
+    disposeOnce();
+}
+
+void SvxMacroAssignDialog::dispose()
+{
+    m_pDialog.clear();
+    VclAbstractDialog::dispose();
 }
 
-VclAbstractDialog * AbstractDialogFactory_Impl::CreateSvxMacroAssignDlg(
+VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateSvxMacroAssignDlg(
     vcl::Window* _pParent, const Reference< XFrame >& _rxDocumentFrame, const bool _bUnoDialogMode,
     const Reference< XNameReplace >& _rxEvents, const sal_uInt16 _nInitiallySelectedEvent )
 {
-    return new SvxMacroAssignDialog( _pParent, _rxDocumentFrame, _bUnoDialogMode, _rxEvents, _nInitiallySelectedEvent );
+    return VclPtr<SvxMacroAssignDialog>::Create( _pParent, _rxDocumentFrame, _bUnoDialogMode, _rxEvents, _nInitiallySelectedEvent );
 }
 
 // Factories for TabPages
@@ -1450,7 +1463,7 @@ GetTabPageRanges AbstractDialogFactory_Impl::GetTabPageRangesFunc( sal_uInt16 nI
     return nullptr;
 }
 
-SfxAbstractInsertObjectDialog* AbstractDialogFactory_Impl::CreateInsertObjectDialog( vcl::Window* pParent, const OUString& rCommand,
+VclPtr<SfxAbstractInsertObjectDialog> AbstractDialogFactory_Impl::CreateInsertObjectDialog( vcl::Window* pParent, const OUString& rCommand,
             const Reference < css::embed::XStorage >& xStor,
             const SvObjectServerList* pList )
 {
@@ -1463,77 +1476,77 @@ SfxAbstractInsertObjectDialog* AbstractDialogFactory_Impl::CreateInsertObjectDia
     if ( pDlg )
     {
         pDlg->SetHelpId( OUStringToOString( rCommand, RTL_TEXTENCODING_UTF8 ) );
-        return new AbstractInsertObjectDialog_Impl( pDlg );
+        return VclPtr<AbstractInsertObjectDialog_Impl>::Create( pDlg );
     }
     return nullptr;
 }
 
-VclAbstractDialog* AbstractDialogFactory_Impl::CreateEditObjectDialog( const OUString& rCommand,
+VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateEditObjectDialog( const OUString& rCommand,
             const Reference < css::embed::XEmbeddedObject >& xObj )
 {
     if ( rCommand == ".uno:InsertObjectFloatingFrame" )
     {
         VclPtrInstance<SfxInsertFloatingFrameDialog> pDlg( nullptr, xObj );
         pDlg->SetHelpId( OUStringToOString( rCommand, RTL_TEXTENCODING_UTF8 ) );
-        return new CuiVclAbstractDialog_Impl( pDlg );
+        return VclPtr<CuiVclAbstractDialog_Impl>::Create( pDlg );
     }
     return nullptr;
 }
 
 
-SfxAbstractPasteDialog* AbstractDialogFactory_Impl::CreatePasteDialog( vcl::Window* pParent )
+VclPtr<SfxAbstractPasteDialog> AbstractDialogFactory_Impl::CreatePasteDialog( vcl::Window* pParent )
 {
-    return new AbstractPasteDialog_Impl( VclPtr<SvPasteObjectDialog>::Create( pParent ) );
+    return VclPtr<AbstractPasteDialog_Impl>::Create( VclPtr<SvPasteObjectDialog>::Create( pParent ) );
 }
 
-SfxAbstractLinksDialog* AbstractDialogFactory_Impl::CreateLinksDialog( vcl::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML, sfx2::SvBaseLink* p)
+VclPtr<SfxAbstractLinksDialog> AbstractDialogFactory_Impl::CreateLinksDialog( vcl::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML, sfx2::SvBaseLink* p)
 {
     VclPtrInstance<SvBaseLinksDlg> pLinkDlg( pParent, pMgr, bHTML );
     if ( p )
         pLinkDlg->SetActLink(p);
-    return new AbstractLinksDialog_Impl( pLinkDlg );
+    return VclPtr<AbstractLinksDialog_Impl>::Create( pLinkDlg );
 }
 
-SfxAbstractTabDialog* AbstractDialogFactory_Impl::CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* /*pObj*/ )
+VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* /*pObj*/ )
 {
-    return new CuiAbstractTabDialog_Impl( VclPtr<SvxFormatCellsDialog>::Create( nullptr, pAttr, pModel ) );
+    return VclPtr<CuiAbstractTabDialog_Impl>::Create( VclPtr<SvxFormatCellsDialog>::Create( nullptr, pAttr, pModel ) );
 }
 
-SvxAbstractSplittTableDialog* AbstractDialogFactory_Impl::CreateSvxSplittTableDialog( vcl::Window* pParent, bool bIsTableVertical, long nMaxVertical )
+VclPtr<SvxAbstractSplittTableDialog> AbstractDialogFactory_Impl::CreateSvxSplittTableDialog( vcl::Window* pParent, bool bIsTableVertical, long nMaxVertical )
 {
-    return new SvxSplitTableDlg( pParent, bIsTableVertical, nMaxVertical, 99 );
+    return VclPtr<SvxSplitTableDlg>::Create( pParent, bIsTableVertical, nMaxVertical, 99 );
 }
 
-SvxAbstractNewTableDialog* AbstractDialogFactory_Impl::CreateSvxNewTableDialog()
+VclPtr<SvxAbstractNewTableDialog> AbstractDialogFactory_Impl::CreateSvxNewTableDialog()
 {
-    return new SvxNewTableDialog;
+    return VclPtr<SvxNewTableDialog>::Create();
 }
 
-VclAbstractDialog* AbstractDialogFactory_Impl::CreateOptionsDialog(
+VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateOptionsDialog(
     vcl::Window* pParent, const OUString& rExtensionId, const OUString& /*rApplicationContext*/ )
 {
-    return new CuiVclAbstractDialog_Impl( VclPtr<OfaTreeOptionsDialog>::Create( pParent, rExtensionId ) );
+    return VclPtr<CuiVclAbstractDialog_Impl>::Create( VclPtr<OfaTreeOptionsDialog>::Create( pParent, rExtensionId ) );
 }
 
-SvxAbstractInsRowColDlg* AbstractDialogFactory_Impl::CreateSvxInsRowColDlg( vcl::Window* pParent, bool bCol, const OString& sHelpId )
+VclPtr<SvxAbstractInsRowColDlg> AbstractDialogFactory_Impl::CreateSvxInsRowColDlg( vcl::Window* pParent, bool bCol, const OString& sHelpId )
 {
-    return new SvxInsRowColDlg( pParent, bCol, sHelpId );
+    return VclPtr<SvxInsRowColDlg>::Create( pParent, bCol, sHelpId );
 }
 
-AbstractPasswordToOpenModifyDialog * AbstractDialogFactory_Impl::CreatePasswordToOpenModifyDialog(
+VclPtr<AbstractPasswordToOpenModifyDialog> AbstractDialogFactory_Impl::CreatePasswordToOpenModifyDialog(
     vcl::Window * pParent,
     sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify )
 {
     VclPtrInstance<PasswordToOpenModifyDialog> pDlg( pParent, 0, nMaxPasswdLen, bIsPasswordToModify );
-    return new AbstractPasswordToOpenModifyDialog_Impl( pDlg );
+    return VclPtr<AbstractPasswordToOpenModifyDialog_Impl>::Create( pDlg );
 }
 
-AbstractScreenshotAnnotationDlg* AbstractDialogFactory_Impl::CreateScreenshotAnnotationDlg(
+VclPtr<AbstractScreenshotAnnotationDlg> AbstractDialogFactory_Impl::CreateScreenshotAnnotationDlg(
     vcl::Window * pParent,
     Dialog& rParentDialog)
 {
     VclPtrInstance<ScreenshotAnnotationDlg> pDlg(pParent, rParentDialog);
-    return new AbstractScreenshotAnnotationDlg_Impl(pDlg);
+    return VclPtr<AbstractScreenshotAnnotationDlg_Impl>::Create(pDlg);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 510d18e..adf568e 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -82,6 +82,7 @@ class VclAbstractDialog2_Impl : public VclAbstractDialog2
 public:
     explicit        VclAbstractDialog2_Impl( Dialog* p ) : m_pDlg( p ) {}
     virtual         ~VclAbstractDialog2_Impl() override;
+    virtual void    dispose() override;
     virtual void    StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) override;
     virtual long    GetResult() override;
 private:
@@ -454,137 +455,140 @@ class AbstractScreenshotAnnotationDlg_Impl : public AbstractScreenshotAnnotation
 class AbstractDialogFactory_Impl : public SvxAbstractDialogFactory
 {
 public:
-    virtual VclAbstractDialog*          CreateVclDialog( vcl::Window* pParent, sal_uInt32 nResId ) override;
+    virtual VclPtr<VclAbstractDialog>    CreateVclDialog( vcl::Window* pParent, sal_uInt32 nResId ) override;
 
-    virtual SfxAbstractDialog*          CreateSfxDialog( vcl::Window* pParent,
+    virtual VclPtr<SfxAbstractDialog>    CreateSfxDialog( vcl::Window* pParent,
                                             const SfxItemSet& rAttr,
                                             const SdrView* pView,
                                             sal_uInt32 nResId ) override;
-    virtual SfxAbstractDialog*          CreateSfxDialog( vcl::Window* pParent,
+    virtual VclPtr<SfxAbstractDialog>    CreateSfxDialog( vcl::Window* pParent,
                                                              const SfxItemSet& rAttr,
                                                              const css::uno::Reference< css::frame::XFrame >& _rxFrame,
                                                              sal_uInt32 nResId ) override;
-    virtual VclAbstractDialog*          CreateFrameDialog( const css::uno::Reference< css::frame::XFrame >& rxFrame,
+    virtual VclPtr<VclAbstractDialog>    CreateFrameDialog( const css::uno::Reference< css::frame::XFrame >& rxFrame,
                                                            sal_uInt32 nResId,
                                                            const OUString& rParameter ) override;
-    virtual SfxAbstractTabDialog*       CreateAutoCorrTabDialog( const SfxItemSet* pAttrSet ) override;
-    virtual SfxAbstractTabDialog*       CreateCustomizeTabDialog(
+    virtual VclPtr<SfxAbstractTabDialog> CreateAutoCorrTabDialog( const SfxItemSet* pAttrSet ) override;
+    virtual VclPtr<SfxAbstractTabDialog> CreateCustomizeTabDialog(
                                             const SfxItemSet* pAttrSet,
                                             const css::uno::Reference< css::frame::XFrame >& xViewFrame ) override;
-    virtual SfxAbstractTabDialog*       CreateTextTabDialog( vcl::Window* pParent,
+    virtual VclPtr<SfxAbstractTabDialog> CreateTextTabDialog( vcl::Window* pParent,
                                             const SfxItemSet* pAttrSet,
                                             SdrView* pView ) override;
-    virtual SfxAbstractTabDialog*       CreateTabItemDialog(vcl::Window* pParent,
+    virtual VclPtr<SfxAbstractTabDialog> CreateTabItemDialog(vcl::Window* pParent,
                                             const SfxItemSet& rSet) override;
-    virtual AbstractSvxCaptionDialog*   CreateCaptionDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxCaptionDialog>
+                                          CreateCaptionDialog( vcl::Window* pParent,
                                             const SdrView* pView,
                                             SvxAnchorIds nAnchorTypes = SvxAnchorIds::NONE ) override;
-    virtual AbstractSvxDistributeDialog*    CreateSvxDistributeDialog(const SfxItemSet& rAttr) override;
-    virtual SfxAbstractInsertObjectDialog* CreateInsertObjectDialog( vcl::Window* pParent, const OUString& rCommmand,
-            const css::uno::Reference < css::embed::XStorage >& xStor,
-            const SvObjectServerList* pList = nullptr ) override;
-    virtual VclAbstractDialog*          CreateEditObjectDialog( const OUString& rCommmand,
-            const css::uno::Reference < css::embed::XEmbeddedObject >& xObj ) override;
-   virtual  SfxAbstractPasteDialog*         CreatePasteDialog( vcl::Window* pParent ) override;
-   virtual  SfxAbstractLinksDialog*         CreateLinksDialog( vcl::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML = false, sfx2::SvBaseLink* p=nullptr  ) override;
-
-   virtual AbstractHangulHanjaConversionDialog * CreateHangulHanjaConversionDialog( vcl::Window* _pParent,
+    virtual VclPtr<AbstractSvxDistributeDialog>
+                                          CreateSvxDistributeDialog(const SfxItemSet& rAttr) override;
+    virtual VclPtr<SfxAbstractInsertObjectDialog>
+                                           CreateInsertObjectDialog( vcl::Window* pParent, const OUString& rCommmand,
+                                            const css::uno::Reference < css::embed::XStorage >& xStor,
+                                            const SvObjectServerList* pList = nullptr ) override;
+    virtual VclPtr<VclAbstractDialog>      CreateEditObjectDialog( const OUString& rCommmand,
+                                            const css::uno::Reference < css::embed::XEmbeddedObject >& xObj ) override;
+    virtual VclPtr<SfxAbstractPasteDialog> CreatePasteDialog( vcl::Window* pParent ) override;
+    virtual VclPtr<SfxAbstractLinksDialog> CreateLinksDialog( vcl::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML = false, sfx2::SvBaseLink* p=nullptr  ) override;
+
+    virtual VclPtr<AbstractHangulHanjaConversionDialog> CreateHangulHanjaConversionDialog( vcl::Window* _pParent,
                                             editeng::HangulHanjaConversion::ConversionDirection _ePrimaryDirection ) override;
-   virtual AbstractThesaurusDialog*        CreateThesaurusDialog( vcl::Window*, css::uno::Reference< css::linguistic2::XThesaurus >  xThesaurus,
+    virtual VclPtr<AbstractThesaurusDialog>  CreateThesaurusDialog( vcl::Window*, css::uno::Reference< css::linguistic2::XThesaurus >  xThesaurus,
                                                 const OUString &rWord, sal_Int16 nLanguage ) override;
 
-   virtual AbstractHyphenWordDialog*       CreateHyphenWordDialog( vcl::Window*,
+    virtual VclPtr<AbstractHyphenWordDialog> CreateHyphenWordDialog( vcl::Window*,
                                                 const OUString &rWord, LanguageType nLang,
                                                 css::uno::Reference< css::linguistic2::XHyphenator >  &xHyphen,
                                                 SvxSpellWrapper* pWrapper ) override;
 
-   virtual AbstractFmShowColsDialog * CreateFmShowColsDialog() override;
-   virtual AbstractSvxZoomDialog * CreateSvxZoomDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractFmShowColsDialog> CreateFmShowColsDialog() override;
+    virtual VclPtr<AbstractSvxZoomDialog> CreateSvxZoomDialog( vcl::Window* pParent,
                                             const SfxItemSet& rCoreSet) override;
    //UUUU add for SvxBorderBackgroundDlg
-   virtual SfxAbstractTabDialog* CreateSvxBorderBackgroundDlg(
+    virtual VclPtr<SfxAbstractTabDialog> CreateSvxBorderBackgroundDlg(
        vcl::Window* pParent,
        const SfxItemSet& rCoreSet,
        bool bEnableSelector,
        bool bEnableDrawingLayerFillStyles = false) override;
 
-   virtual AbstractSvxTransformTabDialog* CreateSvxTransformTabDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxTransformTabDialog> CreateSvxTransformTabDialog( vcl::Window* pParent,
                                                                 const SfxItemSet* pAttr,
                                                                 const SdrView* pView,
                                                                 SvxAnchorIds nAnchorTypes = SvxAnchorIds::NONE) override ;
-    virtual SfxAbstractTabDialog* CreateSchTransformTabDialog( vcl::Window* pParent,
+    virtual VclPtr<SfxAbstractTabDialog> CreateSchTransformTabDialog( vcl::Window* pParent,
                                                                 const SfxItemSet* pAttr,
                                                                 const SdrView* pSdrView,
                                                                 bool bSizeTabPage
                                                                  ) override;
-    virtual AbstractSpellDialog *  CreateSvxSpellDialog(
+    virtual VclPtr<AbstractSpellDialog>  CreateSvxSpellDialog(
                             vcl::Window* pParent,
                             SfxBindings* pBindings,
                             svx::SpellDialogChildWindow* pSpellChildWindow ) override;
 
-    virtual VclAbstractRefreshableDialog * CreateActualizeProgressDialog( vcl::Window* pParent, GalleryTheme* pThm ) override;
-    virtual AbstractTitleDialog * CreateTitleDialog( vcl::Window* pParent,
+    virtual VclPtr<VclAbstractRefreshableDialog> CreateActualizeProgressDialog( vcl::Window* pParent, GalleryTheme* pThm ) override;
+    virtual VclPtr<AbstractTitleDialog> CreateTitleDialog( vcl::Window* pParent,
                                              const OUString& rOldText) override;
-    virtual AbstractGalleryIdDialog * CreateGalleryIdDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractGalleryIdDialog> CreateGalleryIdDialog( vcl::Window* pParent,
                                             GalleryTheme* pThm) override;
-    virtual VclAbstractDialog2 * CreateGalleryThemePropertiesDialog(
+    virtual VclPtr<VclAbstractDialog2> CreateGalleryThemePropertiesDialog(
                                             ExchangeData* pData,
                                             SfxItemSet* pItemSet) override;
-    virtual AbstractURLDlg * CreateURLDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractURLDlg> CreateURLDialog( vcl::Window* pParent,
                                             const OUString& rURL, const OUString& rAltText, const OUString& rDescription,
                                             const OUString& rTarget, const OUString& rName,
                                             TargetList& rTargetList ) override;
 
-    virtual VclAbstractDialog*      CreateSvxSearchAttributeDialog( vcl::Window* pParent,
+    virtual VclPtr<VclAbstractDialog>      CreateSvxSearchAttributeDialog( vcl::Window* pParent,
                                             SearchAttrItemList& rLst,
                                             const sal_uInt16* pWhRanges) override;
-    virtual AbstractSvxSearchSimilarityDialog * CreateSvxSearchSimilarityDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxSearchSimilarityDialog> CreateSvxSearchSimilarityDialog( vcl::Window* pParent,
                                                             bool bRelax,
                                                             sal_uInt16 nOther,
                                                             sal_uInt16 nShorter,
                                                             sal_uInt16 nLonger) override;
-    virtual AbstractSvxJSearchOptionsDialog * CreateSvxJSearchOptionsDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxJSearchOptionsDialog> CreateSvxJSearchOptionsDialog( vcl::Window* pParent,
                                                             const SfxItemSet& rOptionsSet,
                                                             sal_Int32 nInitialFlags) override;
-    virtual AbstractFmInputRecordNoDialog * CreateFmInputRecordNoDialog() override;
-    virtual AbstractSvxNewDictionaryDialog* CreateSvxNewDictionaryDialog( vcl::Window* pParent ) override;
-    virtual VclAbstractDialog *     CreateSvxEditDictionaryDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractFmInputRecordNoDialog> CreateFmInputRecordNoDialog() override;
+    virtual VclPtr<AbstractSvxNewDictionaryDialog> CreateSvxNewDictionaryDialog( vcl::Window* pParent ) override;
+    virtual VclPtr<VclAbstractDialog>     CreateSvxEditDictionaryDialog( vcl::Window* pParent,
                                             const OUString& rName) override;
-    virtual AbstractSvxNameDialog *     CreateSvxNameDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxNameDialog>     CreateSvxNameDialog( vcl::Window* pParent,
                                             const OUString& rName, const OUString& rDesc ) override;
     // #i68101#
-    virtual AbstractSvxObjectNameDialog* CreateSvxObjectNameDialog(const OUString& rName ) override;
-    virtual AbstractSvxObjectTitleDescDialog* CreateSvxObjectTitleDescDialog(const OUString& rTitle, const OUString& rDescription) override;
+    virtual VclPtr<AbstractSvxObjectNameDialog> CreateSvxObjectNameDialog(const OUString& rName ) override;
+    virtual VclPtr<AbstractSvxObjectTitleDescDialog> CreateSvxObjectTitleDescDialog(const OUString& rTitle, const OUString& rDescription) override;
 
-    virtual AbstractSvxMultiPathDialog *    CreateSvxMultiPathDialog(vcl::Window* pParent) override;
-    virtual AbstractSvxMultiPathDialog *    CreateSvxPathSelectDialog(vcl::Window* pParent) override;
-    virtual AbstractSvxHpLinkDlg *          CreateSvxHpLinkDlg(vcl::Window* pParent, SfxBindings* pBindings) override;
-    virtual AbstractFmSearchDialog*         CreateFmSearchDialog(vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxMultiPathDialog>    CreateSvxMultiPathDialog(vcl::Window* pParent) override;
+    virtual VclPtr<AbstractSvxMultiPathDialog>    CreateSvxPathSelectDialog(vcl::Window* pParent) override;
+    virtual VclPtr<AbstractSvxHpLinkDlg>          CreateSvxHpLinkDlg(vcl::Window* pParent, SfxBindings* pBindings) override;
+    virtual VclPtr<AbstractFmSearchDialog>         CreateFmSearchDialog(vcl::Window* pParent,
                                                         const OUString& strInitialText,
                                                         const ::std::vector< OUString >& _rContexts,
                                                         sal_Int16 nInitialContext,
                                                         const Link<FmSearchContext&,sal_uInt32>& lnkContextSupplier) override;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterEmboss(vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterEmboss(vcl::Window* pParent,
                                                 const Graphic& rGraphic) override;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterPoster(vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterPoster(vcl::Window* pParent,
                                                 const Graphic& rGraphic) override;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterSepia (vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterSepia (vcl::Window* pParent,
                                                 const Graphic& rGraphic) override;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterSmooth (vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterSmooth (vcl::Window* pParent,
                                                 const Graphic& rGraphic, double nRadius) override;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterSolarize (vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>  CreateGraphicFilterSolarize (vcl::Window* pParent,
                                                 const Graphic& rGraphic) override;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterMosaic (vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterMosaic (vcl::Window* pParent,
                                                 const Graphic& rGraphic) override;
-    virtual AbstractSvxAreaTabDialog*       CreateSvxAreaTabDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxAreaTabDialog>       CreateSvxAreaTabDialog( vcl::Window* pParent,
                                                             const SfxItemSet* pAttr,
                                                             SdrModel* pModel,
                                                             bool bShadow ) override;
-    virtual SfxAbstractTabDialog*           CreateSvxLineTabDialog( vcl::Window* pParent, const SfxItemSet* pAttr,
+    virtual VclPtr<SfxAbstractTabDialog>           CreateSvxLineTabDialog( vcl::Window* pParent, const SfxItemSet* pAttr,
                                                                  SdrModel* pModel,
                                                                  const SdrObject* pObj,
                                                                  bool bHasObj = true ) override;
-    virtual AbstractSvxPostItDialog*        CreateSvxPostItDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxPostItDialog>        CreateSvxPostItDialog( vcl::Window* pParent,
                                                                         const SfxItemSet& rCoreSet,
                                                                         bool bPrevNext = false ) override;
 
@@ -593,17 +597,17 @@ public:
 
     virtual GetTabPageRanges            GetTabPageRangesFunc( sal_uInt16 nId ) override;
     virtual DialogGetRanges             GetDialogGetRangesFunc() override;
-    virtual VclAbstractDialog*          CreateSvxScriptOrgDialog( vcl::Window* pParent, const OUString& rLanguage ) override;
+    virtual VclPtr<VclAbstractDialog>   CreateSvxScriptOrgDialog( vcl::Window* pParent, const OUString& rLanguage ) override;
 
-    virtual AbstractScriptSelectorDialog*
+    virtual VclPtr<AbstractScriptSelectorDialog>
         CreateScriptSelectorDialog(
             vcl::Window* pParent,
             const css::uno::Reference< css::frame::XFrame >& _rxFrame
         ) override;
 
-    virtual VclAbstractDialog* CreateScriptErrorDialog(const css::uno::Any& rException) override;
+    virtual VclPtr<VclAbstractDialog> CreateScriptErrorDialog(const css::uno::Any& rException) override;
 
-    virtual VclAbstractDialog*  CreateSvxMacroAssignDlg(
+    virtual VclPtr<VclAbstractDialog>  CreateSvxMacroAssignDlg(
                 vcl::Window* _pParent,
                 const css::uno::Reference< css::frame::XFrame >& _rxDocumentFrame,
                 const bool _bUnoDialogMode,
@@ -611,20 +615,20 @@ public:
                 const sal_uInt16 _nInitiallySelectedEvent
             ) override;
 
-    virtual SfxAbstractTabDialog* CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj ) override;
+    virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj ) override;
 
-    virtual SvxAbstractSplittTableDialog* CreateSvxSplittTableDialog( vcl::Window* pParent, bool bIsTableVertical, long nMaxVertical ) override;
+    virtual VclPtr<SvxAbstractSplittTableDialog> CreateSvxSplittTableDialog( vcl::Window* pParent, bool bIsTableVertical, long nMaxVertical ) override;
 
-    virtual SvxAbstractNewTableDialog* CreateSvxNewTableDialog() override ;
+    virtual VclPtr<SvxAbstractNewTableDialog> CreateSvxNewTableDialog() override ;
 
-    virtual VclAbstractDialog*          CreateOptionsDialog(
+    virtual VclPtr<VclAbstractDialog>          CreateOptionsDialog(
         vcl::Window* pParent, const OUString& rExtensionId, const OUString& rApplicationContext ) override;
 
-    virtual SvxAbstractInsRowColDlg* CreateSvxInsRowColDlg( vcl::Window* pParent, bool bCol, const OString& sHelpId ) override;
+    virtual VclPtr<SvxAbstractInsRowColDlg> CreateSvxInsRowColDlg( vcl::Window* pParent, bool bCol, const OString& sHelpId ) override;
 
-    virtual AbstractPasswordToOpenModifyDialog *    CreatePasswordToOpenModifyDialog(vcl::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify) override;
+    virtual VclPtr<AbstractPasswordToOpenModifyDialog> CreatePasswordToOpenModifyDialog(vcl::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify) override;
 
-    virtual AbstractScreenshotAnnotationDlg* CreateScreenshotAnnotationDlg(vcl::Window * pParent, Dialog& rParentDialog) override;
+    virtual VclPtr<AbstractScreenshotAnnotationDlg> CreateScreenshotAnnotationDlg(vcl::Window * pParent, Dialog& rParentDialog) override;
 };
 
 #endif
diff --git a/cui/source/inc/insrc.hxx b/cui/source/inc/insrc.hxx
index 9739e28..e6fa2a0 100644
--- a/cui/source/inc/insrc.hxx
+++ b/cui/source/inc/insrc.hxx
@@ -45,6 +45,7 @@ class SvxInsRowColDlg : public SvxAbstractInsRowColDlg
 public:
     SvxInsRowColDlg( vcl::Window* pParent, bool bCol, const OString& sHelpId );
     virtual ~SvxInsRowColDlg() override;
+    virtual void dispose() override;
 
     virtual short Execute() override;
 
diff --git a/cui/source/inc/newtabledlg.hxx b/cui/source/inc/newtabledlg.hxx
index 6dd1de1..91de08f 100644
--- a/cui/source/inc/newtabledlg.hxx
+++ b/cui/source/inc/newtabledlg.hxx
@@ -36,6 +36,7 @@ private:
 public:
     SvxNewTableDialog();
     virtual ~SvxNewTableDialog() override;
+    virtual void dispose() override;
 
     virtual short Execute() override;
 
diff --git a/cui/source/inc/splitcelldlg.hxx b/cui/source/inc/splitcelldlg.hxx
index df85c2f..6ff4d0c 100644
--- a/cui/source/inc/splitcelldlg.hxx
+++ b/cui/source/inc/splitcelldlg.hxx
@@ -40,6 +40,7 @@ class SvxSplitTableDlg : public SvxAbstractSplittTableDialog
 public:
     SvxSplitTableDlg(vcl::Window *pParent, bool bIsTableVertical, long nMaxVertical, long nMaxHorizontal );
     virtual ~SvxSplitTableDlg() override;
+    virtual void dispose() override;
 
     DECL_LINK( ClickHdl, Button *, void );
 
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx
index bf6c989..a09fd63 100644
--- a/dbaccess/source/ui/browser/brwctrlr.cxx
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -1837,7 +1837,7 @@ void SbaXDataBrowserController::ExecuteSearch()
     Reference< css::util::XNumberFormatsSupplier >  xNFS(::dbtools::getNumberFormats(::dbtools::getConnection(m_xRowSet), true, getORB()));
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    AbstractFmSearchDialog* pDialog = nullptr;
+    VclPtr<AbstractFmSearchDialog> pDialog;
     if ( pFact )
     {
         ::std::vector< OUString > aContextNames;
@@ -1851,7 +1851,7 @@ void SbaXDataBrowserController::ExecuteSearch()
         pDialog->SetFoundHandler( LINK( this, SbaXDataBrowserController, OnFoundData ) );
         pDialog->SetCanceledNotFoundHdl( LINK( this, SbaXDataBrowserController, OnCanceledNotFound ) );
         pDialog->Execute();
-        delete pDialog;
+        pDialog.disposeAndClear();
     }
 
     // restore the grid's normal operating state
diff --git a/dbaccess/source/ui/querydesign/QTableConnection.cxx b/dbaccess/source/ui/querydesign/QTableConnection.cxx
index 0f54606..4a17b32 100644
--- a/dbaccess/source/ui/querydesign/QTableConnection.cxx
+++ b/dbaccess/source/ui/querydesign/QTableConnection.cxx
@@ -31,7 +31,8 @@ OQueryTableConnection::OQueryTableConnection(OQueryTableView* pContainer, const
 }
 
 OQueryTableConnection::OQueryTableConnection(const OQueryTableConnection& rConn)
-    : OTableConnection( rConn )
+    : VclReferenceBase(),
+      OTableConnection( rConn )
     , m_bVisited(false)
 {
     // no own members, so base class functionality is sufficient
diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx
index ebf2e17..5cd282f 100644
--- a/dbaccess/source/ui/querydesign/TableConnection.cxx
+++ b/dbaccess/source/ui/querydesign/TableConnection.cxx
@@ -42,9 +42,11 @@ namespace dbaui
         Show();
     }
 
-    OTableConnection::OTableConnection( const OTableConnection& _rConn ) : Window(_rConn.m_pParent.get())
-        ,m_pData(_rConn.GetData()->NewInstance())
-        ,m_pParent(nullptr)
+    OTableConnection::OTableConnection( const OTableConnection& _rConn )
+        : VclReferenceBase()
+         ,Window(_rConn.m_pParent.get())
+         ,m_pData(_rConn.GetData()->NewInstance())
+         ,m_pParent(nullptr)
     {
         *this = _rConn;
     }
diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.cxx b/dbaccess/source/ui/relationdesign/RTableConnection.cxx
index 6183423..4b5824a 100644
--- a/dbaccess/source/ui/relationdesign/RTableConnection.cxx
+++ b/dbaccess/source/ui/relationdesign/RTableConnection.cxx
@@ -33,7 +33,7 @@ ORelationTableConnection::ORelationTableConnection( ORelationTableView* pContain
 }
 
 ORelationTableConnection::ORelationTableConnection( const ORelationTableConnection& rConn )
-    : OTableConnection( rConn )
+    : VclReferenceBase(), OTableConnection( rConn )
 {
     // no own members, thus the base class functionality is enough
 }
diff --git a/editeng/source/misc/hangulhanja.cxx b/editeng/source/misc/hangulhanja.cxx
index 41d351a..e6deb82 100644
--- a/editeng/source/misc/hangulhanja.cxx
+++ b/editeng/source/misc/hangulhanja.cxx
@@ -67,7 +67,7 @@ namespace editeng
         static StringMap        m_aRecentlyUsedList;
 
         // general
-        AbstractHangulHanjaConversionDialog*
+        VclPtr<AbstractHangulHanjaConversionDialog>
                                 m_pConversionDialog;    // the dialog to display for user interaction
         VclPtr<vcl::Window>     m_pUIParent;            // the parent window for any UI we raise
         Reference< XComponentContext >
@@ -235,7 +235,7 @@ namespace editeng
                                                             sal_Int32 _nOptions,
                                                             bool _bIsInteractive,
                                                             HangulHanjaConversion* _pAntiImpl )
-        : m_pConversionDialog( nullptr )
+        : m_pConversionDialog()
         , m_pUIParent( _pUIParent )
         , m_xContext( rxContext )
         , m_aSourceLocale( _rSourceLocale )
@@ -673,7 +673,7 @@ namespace editeng
             else
                 implUpdateData();
             m_pConversionDialog->Execute();
-            DELETEZ( m_pConversionDialog );
+            m_pConversionDialog.disposeAndClear();
         }
         else
         {
diff --git a/include/editeng/edtdlg.hxx b/include/editeng/edtdlg.hxx
index ea0c5ec..c4be9fe 100644
--- a/include/editeng/edtdlg.hxx
+++ b/include/editeng/edtdlg.hxx
@@ -84,14 +84,14 @@ class EDITENG_DLLPUBLIC EditAbstractDialogFactory : virtual public VclAbstractDi
 public:
                                         virtual ~EditAbstractDialogFactory() override;   // needed for export of vtable
     static EditAbstractDialogFactory*   Create();
-    virtual AbstractThesaurusDialog*        CreateThesaurusDialog( vcl::Window*, css::uno::Reference< css::linguistic2::XThesaurus >  xThesaurus,
+    virtual VclPtr<AbstractThesaurusDialog>  CreateThesaurusDialog( vcl::Window*, css::uno::Reference< css::linguistic2::XThesaurus >  xThesaurus,
                                                 const OUString &rWord, sal_Int16 nLanguage ) = 0;
 
-    virtual AbstractHyphenWordDialog*       CreateHyphenWordDialog( vcl::Window*,
+    virtual VclPtr<AbstractHyphenWordDialog> CreateHyphenWordDialog( vcl::Window*,
                                                 const OUString &rWord, LanguageType nLang,
                                                 css::uno::Reference< css::linguistic2::XHyphenator >  &xHyphen,
                                                 SvxSpellWrapper* pWrapper ) = 0;
-    virtual AbstractHangulHanjaConversionDialog * CreateHangulHanjaConversionDialog( vcl::Window* _pParent,
+    virtual VclPtr<AbstractHangulHanjaConversionDialog> CreateHangulHanjaConversionDialog( vcl::Window* _pParent,
                                             editeng::HangulHanjaConversion::ConversionDirection _ePrimaryDirection ) = 0;
 };
 
diff --git a/include/sfx2/sfxdlg.hxx b/include/sfx2/sfxdlg.hxx
index 071e3f8..6b80bf8 100644
--- a/include/sfx2/sfxdlg.hxx
+++ b/include/sfx2/sfxdlg.hxx
@@ -115,31 +115,31 @@ class SFX2_DLLPUBLIC SfxAbstractDialogFactory : virtual public VclAbstractDialog
 public:
                                         virtual ~SfxAbstractDialogFactory() override;    // needed for export of vtable
     static SfxAbstractDialogFactory*    Create();
-    virtual VclAbstractDialog*          CreateFrameDialog( const css::uno::Reference< css::frame::XFrame >& rFrame, sal_uInt32 nResId, const rtl::OUString& rParameter ) = 0;
-    virtual SfxAbstractTabDialog*       CreateAutoCorrTabDialog( const SfxItemSet* pAttrSet ) = 0;
-    virtual SfxAbstractTabDialog*       CreateCustomizeTabDialog(
+    virtual VclPtr<VclAbstractDialog>          CreateFrameDialog( const css::uno::Reference< css::frame::XFrame >& rFrame, sal_uInt32 nResId, const rtl::OUString& rParameter ) = 0;
+    virtual VclPtr<SfxAbstractTabDialog>       CreateAutoCorrTabDialog( const SfxItemSet* pAttrSet ) = 0;
+    virtual VclPtr<SfxAbstractTabDialog>       CreateCustomizeTabDialog(
                                             const SfxItemSet* pAttrSet,
                                             const css::uno::Reference< css::frame::XFrame >& xViewFrame ) = 0;
     virtual CreateTabPage               GetTabPageCreatorFunc( sal_uInt16 nId ) = 0;
     virtual GetTabPageRanges            GetTabPageRangesFunc( sal_uInt16 nId ) = 0;
-    virtual SfxAbstractInsertObjectDialog* CreateInsertObjectDialog( vcl::Window* pParent, const OUString& rCommand,
+    virtual VclPtr<SfxAbstractInsertObjectDialog> CreateInsertObjectDialog( vcl::Window* pParent, const OUString& rCommand,
             const css::uno::Reference < css::embed::XStorage >& xStor,
             const SvObjectServerList* pList = nullptr )=0;
-    virtual VclAbstractDialog*          CreateEditObjectDialog( const OUString& rCommand,
+    virtual VclPtr<VclAbstractDialog>          CreateEditObjectDialog( const OUString& rCommand,
             const css::uno::Reference < css::embed::XEmbeddedObject >& xObj )=0;
-    virtual  SfxAbstractPasteDialog*    CreatePasteDialog( vcl::Window* pParent )=0;
-    virtual  SfxAbstractLinksDialog*    CreateLinksDialog( vcl::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML=false, sfx2::SvBaseLink* p=nullptr )=0;
-    virtual VclAbstractDialog *         CreateSvxScriptOrgDialog( vcl::Window* pParent,  const rtl::OUString& rLanguage ) = 0;
+    virtual VclPtr<SfxAbstractPasteDialog>    CreatePasteDialog( vcl::Window* pParent )=0;
+    virtual VclPtr<SfxAbstractLinksDialog>    CreateLinksDialog( vcl::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML=false, sfx2::SvBaseLink* p=nullptr )=0;
+    virtual VclPtr<VclAbstractDialog>         CreateSvxScriptOrgDialog( vcl::Window* pParent,  const rtl::OUString& rLanguage ) = 0;
 
-    virtual AbstractScriptSelectorDialog*
+    virtual VclPtr<AbstractScriptSelectorDialog>
         CreateScriptSelectorDialog(
             vcl::Window* pParent,
             const css::uno::Reference< css::frame::XFrame >& _rxFrame
         ) = 0;
 
-    virtual VclAbstractDialog* CreateScriptErrorDialog( const css::uno::Any& rException ) = 0;
+    virtual VclPtr<VclAbstractDialog> CreateScriptErrorDialog( const css::uno::Any& rException ) = 0;
 
-    virtual VclAbstractDialog*  CreateOptionsDialog(
+    virtual VclPtr<VclAbstractDialog>  CreateOptionsDialog(
         vcl::Window* pParent, const OUString& rExtensionId, const OUString& rApplicationContext ) = 0;
 };
 
diff --git a/include/svx/SpellDialogChildWindow.hxx b/include/svx/SpellDialogChildWindow.hxx
index 9f1b3f2..b3d938c 100644
--- a/include/svx/SpellDialogChildWindow.hxx
+++ b/include/svx/SpellDialogChildWindow.hxx
@@ -46,7 +46,7 @@ class SVX_DLLPUBLIC SpellDialogChildWindow
     : public SfxChildWindow
 {
     friend class SpellDialog;
-    std::unique_ptr<AbstractSpellDialog> m_xAbstractSpellDialog;
+    VclPtr<AbstractSpellDialog> m_xAbstractSpellDialog;
 public:
     SpellDialogChildWindow (
         vcl::Window*pParent,
diff --git a/include/svx/hyperdlg.hxx b/include/svx/hyperdlg.hxx
index c42601d..c0a41a6 100644
--- a/include/svx/hyperdlg.hxx
+++ b/include/svx/hyperdlg.hxx
@@ -34,7 +34,7 @@ class AbstractSvxHpLinkDlg;
 class SVX_DLLPUBLIC SvxHlinkDlgWrapper : public SfxChildWindow
 {
 private:
-    AbstractSvxHpLinkDlg*   mpDlg;
+    VclPtr<AbstractSvxHpLinkDlg>   mpDlg;
 
 public:
     SvxHlinkDlgWrapper( vcl::Window*pParent, sal_uInt16 nId,
diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx
index 20b6b9d..fcbbc43 100644
--- a/include/svx/svxdlg.hxx
+++ b/include/svx/svxdlg.hxx
@@ -276,135 +276,135 @@ public:
 
     virtual                             ~SvxAbstractDialogFactory() override;
 
-    virtual SfxAbstractTabDialog*       CreateTextTabDialog( vcl::Window* pParent,
+    virtual VclPtr<SfxAbstractTabDialog>      CreateTextTabDialog( vcl::Window* pParent,
                                             const SfxItemSet* pAttrSet,
                                             SdrView* pView ) = 0 ;
 
-    virtual AbstractSvxCaptionDialog* CreateCaptionDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxCaptionDialog> CreateCaptionDialog( vcl::Window* pParent,
                                         const SdrView* pView,
                                         SvxAnchorIds nAnchorTypes = SvxAnchorIds::NONE ) = 0;
 
-    virtual AbstractSvxDistributeDialog*    CreateSvxDistributeDialog(
+    virtual VclPtr<AbstractSvxDistributeDialog>    CreateSvxDistributeDialog(
                                             const SfxItemSet& rAttr)= 0;
 
-    virtual AbstractFmShowColsDialog * CreateFmShowColsDialog() = 0;
+    virtual VclPtr<AbstractFmShowColsDialog> CreateFmShowColsDialog() = 0;
 
-    virtual AbstractSvxZoomDialog * CreateSvxZoomDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxZoomDialog> CreateSvxZoomDialog( vcl::Window* pParent,
                                             const SfxItemSet& rCoreSet )=0;
 
-    virtual AbstractSpellDialog *   CreateSvxSpellDialog(vcl::Window* pParent,
+    virtual VclPtr<AbstractSpellDialog>   CreateSvxSpellDialog(vcl::Window* pParent,
                                             SfxBindings* pBindings,
                                             svx::SpellDialogChildWindow* pSpellChildWindow )=0;
 
-    virtual VclAbstractRefreshableDialog * CreateActualizeProgressDialog( vcl::Window* pParent,
+    virtual VclPtr<VclAbstractRefreshableDialog> CreateActualizeProgressDialog( vcl::Window* pParent,
                                             GalleryTheme* pThm ) = 0;
-    virtual AbstractTitleDialog * CreateTitleDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractTitleDialog> CreateTitleDialog( vcl::Window* pParent,
                                              const OUString& rOldText ) = 0;
-    virtual AbstractGalleryIdDialog * CreateGalleryIdDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractGalleryIdDialog> CreateGalleryIdDialog( vcl::Window* pParent,
                                             GalleryTheme* pThm ) = 0;
-    virtual VclAbstractDialog2 * CreateGalleryThemePropertiesDialog(
+    virtual VclPtr<VclAbstractDialog2> CreateGalleryThemePropertiesDialog(
                                             ExchangeData* pData,
                                             SfxItemSet* pItemSet ) = 0;
-    virtual AbstractURLDlg * CreateURLDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractURLDlg> CreateURLDialog( vcl::Window* pParent,
                                             const OUString& rURL, const OUString& rAltText, const OUString& rDescription,
                                             const OUString& rTarget, const OUString& rName,
                                             TargetList& rTargetList ) = 0;
 
-    virtual SfxAbstractTabDialog* CreateTabItemDialog(vcl::Window* pParent,
+    virtual VclPtr<SfxAbstractTabDialog> CreateTabItemDialog(vcl::Window* pParent,
                                             const SfxItemSet& rSet) = 0;
-    virtual VclAbstractDialog*      CreateSvxSearchAttributeDialog( vcl::Window* pParent,
+    virtual VclPtr<VclAbstractDialog>      CreateSvxSearchAttributeDialog( vcl::Window* pParent,
                                             SearchAttrItemList& rLst,
                                             const sal_uInt16* pWhRanges)=0;
-    virtual AbstractSvxSearchSimilarityDialog * CreateSvxSearchSimilarityDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxSearchSimilarityDialog> CreateSvxSearchSimilarityDialog( vcl::Window* pParent,
                                                             bool bRelax,
                                                             sal_uInt16 nOther,
                                                             sal_uInt16 nShorter,
                                                             sal_uInt16 nLonger ) = 0;
     //UUUU add for SvxBorderBackgroundDlg
-    virtual SfxAbstractTabDialog* CreateSvxBorderBackgroundDlg(
+    virtual VclPtr<SfxAbstractTabDialog> CreateSvxBorderBackgroundDlg(
         vcl::Window* pParent,
         const SfxItemSet& rCoreSet,
         bool bEnableSelector,
         bool bEnableDrawingLayerFillStyles = false) = 0;
 
-    virtual AbstractSvxTransformTabDialog* CreateSvxTransformTabDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxTransformTabDialog> CreateSvxTransformTabDialog( vcl::Window* pParent,
                                                                 const SfxItemSet* pAttr,
                                                                 const SdrView* pView,
                                                                 SvxAnchorIds nAnchorTypes = SvxAnchorIds::NONE) = 0;
-    virtual SfxAbstractTabDialog* CreateSchTransformTabDialog( vcl::Window* pParent,
+    virtual VclPtr<SfxAbstractTabDialog> CreateSchTransformTabDialog( vcl::Window* pParent,
                                                                 const SfxItemSet* pAttr,
                                                                 const SdrView* pSdrView,
                                                                 bool bSizeTabPage
                                                                  )=0;
-    virtual AbstractSvxJSearchOptionsDialog * CreateSvxJSearchOptionsDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxJSearchOptionsDialog> CreateSvxJSearchOptionsDialog( vcl::Window* pParent,
                                                             const SfxItemSet& rOptionsSet,
                                                             sal_Int32 nInitialFlags )=0;
-    virtual AbstractFmInputRecordNoDialog * CreateFmInputRecordNoDialog() = 0;
-    virtual AbstractSvxNewDictionaryDialog* CreateSvxNewDictionaryDialog( vcl::Window* pParent ) = 0;
-    virtual VclAbstractDialog *     CreateSvxEditDictionaryDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractFmInputRecordNoDialog> CreateFmInputRecordNoDialog() = 0;
+    virtual VclPtr<AbstractSvxNewDictionaryDialog> CreateSvxNewDictionaryDialog( vcl::Window* pParent ) = 0;
+    virtual VclPtr<VclAbstractDialog>     CreateSvxEditDictionaryDialog( vcl::Window* pParent,
                                             const OUString& rName) = 0;
-    virtual AbstractSvxNameDialog *     CreateSvxNameDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxNameDialog>     CreateSvxNameDialog( vcl::Window* pParent,
                                             const OUString& rName, const OUString& rDesc ) = 0;
 
     // #i68101#
-    virtual AbstractSvxObjectNameDialog* CreateSvxObjectNameDialog(const OUString& rName ) = 0;
-    virtual AbstractSvxObjectTitleDescDialog* CreateSvxObjectTitleDescDialog(const OUString& rTitle, const OUString& rDescription) = 0;
+    virtual VclPtr<AbstractSvxObjectNameDialog> CreateSvxObjectNameDialog(const OUString& rName ) = 0;
+    virtual VclPtr<AbstractSvxObjectTitleDescDialog> CreateSvxObjectTitleDescDialog(const OUString& rTitle, const OUString& rDescription) = 0;
 
-    virtual AbstractSvxMultiPathDialog *    CreateSvxMultiPathDialog(vcl::Window* pParent) = 0 ;
-    virtual AbstractSvxMultiPathDialog *    CreateSvxPathSelectDialog(vcl::Window* pParent) = 0 ;
-    virtual AbstractSvxHpLinkDlg *  CreateSvxHpLinkDlg(vcl::Window* pParent, SfxBindings* pBindings)=0;
-    virtual AbstractFmSearchDialog* CreateFmSearchDialog(vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxMultiPathDialog>    CreateSvxMultiPathDialog(vcl::Window* pParent) = 0 ;
+    virtual VclPtr<AbstractSvxMultiPathDialog>    CreateSvxPathSelectDialog(vcl::Window* pParent) = 0 ;
+    virtual VclPtr<AbstractSvxHpLinkDlg>  CreateSvxHpLinkDlg(vcl::Window* pParent, SfxBindings* pBindings)=0;
+    virtual VclPtr<AbstractFmSearchDialog> CreateFmSearchDialog(vcl::Window* pParent,
                                                         const OUString& strInitialText,
                                                         const ::std::vector< OUString >& _rContexts,
                                                         sal_Int16 nInitialContext,
                                                         const Link<FmSearchContext&,sal_uInt32>& lnkContextSupplier)=0;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterEmboss(vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterEmboss(vcl::Window* pParent,
                                                 const Graphic& rGraphic)=0;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterPoster(vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterPoster(vcl::Window* pParent,
                                                 const Graphic& rGraphic)=0;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterSepia (vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterSepia (vcl::Window* pParent,
                                                 const Graphic& rGraphic)=0;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterSmooth (vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterSmooth (vcl::Window* pParent,
                                                 const Graphic& rGraphic,
                                                 double nRadius)=0;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterSolarize (vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterSolarize (vcl::Window* pParent,
                                                 const Graphic& rGraphic)=0;
-    virtual AbstractGraphicFilterDialog *   CreateGraphicFilterMosaic (vcl::Window* pParent,
+    virtual VclPtr<AbstractGraphicFilterDialog>   CreateGraphicFilterMosaic (vcl::Window* pParent,
                                                 const Graphic& rGraphic)=0;
-    virtual AbstractSvxAreaTabDialog*       CreateSvxAreaTabDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxAreaTabDialog>       CreateSvxAreaTabDialog( vcl::Window* pParent,
                                                             const SfxItemSet* pAttr,
                                                             SdrModel* pModel,
                                                             bool bShadow) = 0 ;
-    virtual SfxAbstractTabDialog*           CreateSvxLineTabDialog( vcl::Window* pParent, const SfxItemSet* pAttr, //add forSvxLineTabDialog
+    virtual VclPtr<SfxAbstractTabDialog>           CreateSvxLineTabDialog( vcl::Window* pParent, const SfxItemSet* pAttr, //add forSvxLineTabDialog
                                                                  SdrModel* pModel,
                                                                  const SdrObject* pObj,
                                                                  bool bHasObj = true )=0;
-    virtual SfxAbstractDialog*              CreateSfxDialog( vcl::Window* pParent,
+    virtual VclPtr<SfxAbstractDialog>       CreateSfxDialog( vcl::Window* pParent,
                                                                         const SfxItemSet& rAttr,
                                                                         const SdrView* pView,
                                                                         sal_uInt32 nResId
                                                                         )=0;
-    virtual SfxAbstractDialog*              CreateSfxDialog( vcl::Window* pParent,
+    virtual VclPtr<SfxAbstractDialog>       CreateSfxDialog( vcl::Window* pParent,
                                                                         const SfxItemSet& rAttr,
                                     const css::uno::Reference< css::frame::XFrame >& _rxFrame,
                                                                         sal_uInt32 nResId
                                                                         )=0;
-    virtual AbstractSvxPostItDialog*        CreateSvxPostItDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxPostItDialog>    CreateSvxPostItDialog( vcl::Window* pParent,
                                                                         const SfxItemSet& rCoreSet,
                                                                         bool bPrevNext = false) = 0;
-    virtual VclAbstractDialog*          CreateSvxScriptOrgDialog( vcl::Window* pParent, const OUString& rLanguage ) override = 0;
+    virtual VclPtr<VclAbstractDialog>          CreateSvxScriptOrgDialog( vcl::Window* pParent, const OUString& rLanguage ) override = 0;
 
-    virtual DialogGetRanges             GetDialogGetRangesFunc() = 0;
+    virtual DialogGetRanges                    GetDialogGetRangesFunc() = 0;
 
-    virtual AbstractScriptSelectorDialog*
+    virtual VclPtr<AbstractScriptSelectorDialog>
         CreateScriptSelectorDialog(
             vcl::Window* pParent,
             const css::uno::Reference< css::frame::XFrame >& _rxFrame
         ) override = 0;
 
-    virtual VclAbstractDialog* CreateScriptErrorDialog(const css::uno::Any& rException) override = 0;
+    virtual VclPtr<VclAbstractDialog> CreateScriptErrorDialog(const css::uno::Any& rException) override = 0;
 
-    virtual VclAbstractDialog*  CreateSvxMacroAssignDlg(
+    virtual VclPtr<VclAbstractDialog> CreateSvxMacroAssignDlg(
                 vcl::Window* _pParent,
                 const css::uno::Reference< css::frame::XFrame >& _rxDocumentFrame,
                 const bool _bUnoDialogMode,
@@ -412,13 +412,13 @@ public:
                 const sal_uInt16 _nInitiallySelectedEvent
             ) = 0;
 
-    virtual SfxAbstractTabDialog* CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj )=0;
+    virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj )=0;
 
-    virtual SvxAbstractSplittTableDialog* CreateSvxSplittTableDialog( vcl::Window* pParent, bool bIsTableVertical, long nMaxVertical )=0;
+    virtual VclPtr<SvxAbstractSplittTableDialog> CreateSvxSplittTableDialog( vcl::Window* pParent, bool bIsTableVertical, long nMaxVertical )=0;
 
-    virtual SvxAbstractNewTableDialog* CreateSvxNewTableDialog() = 0;
+    virtual VclPtr<SvxAbstractNewTableDialog> CreateSvxNewTableDialog() = 0;
 
-    virtual SvxAbstractInsRowColDlg* CreateSvxInsRowColDlg( vcl::Window* pParent, bool bCol, const OString& sHelpId ) = 0;
+    virtual VclPtr<SvxAbstractInsRowColDlg> CreateSvxInsRowColDlg( vcl::Window* pParent, bool bCol, const OString& sHelpId ) = 0;
 };
 
 #endif
diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx
index 1db97cc..6b89f95 100644
--- a/include/vcl/abstdlg.hxx
+++ b/include/vcl/abstdlg.hxx
@@ -22,16 +22,22 @@
 #include <rtl/ustring.hxx>
 #include <tools/link.hxx>
 #include <vcl/dllapi.h>
+#include <vcl/vclreferencebase.hxx>
 #include <vector>
 
 namespace vcl { class Window; }
 class Dialog;
 class Bitmap;
 
-class VCL_DLLPUBLIC VclAbstractDialog
+/**
+* Some things multiple-inherit from VclAbstractDialog and OutputDevice,
+* so we need to use virtual inheritance to keep the referencing counting
+* OK.
+*/
+class VCL_DLLPUBLIC VclAbstractDialog : public virtual VclReferenceBase
 {
 public:
-    virtual             ~VclAbstractDialog();
+    virtual             ~VclAbstractDialog() override;
     virtual short       Execute() = 0;
 
     // Screenshot interface
@@ -41,10 +47,10 @@ public:
     virtual OString GetScreenshotId() const { return OString(); };
 };
 
-class VCL_DLLPUBLIC VclAbstractDialog2
+class VCL_DLLPUBLIC VclAbstractDialog2 : public virtual VclReferenceBase
 {
 public:
-    virtual             ~VclAbstractDialog2();
+    virtual             ~VclAbstractDialog2() override;
 
     virtual void        StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) = 0;
     virtual long        GetResult() = 0;
@@ -80,13 +86,13 @@ public:
     virtual             ~VclAbstractDialogFactory();    // needed for export of vtable
     static VclAbstractDialogFactory* Create();
     // The Id is an implementation detail of the factory
-    virtual VclAbstractDialog* CreateVclDialog(vcl::Window* pParent, sal_uInt32 nId) = 0;
+    virtual VclPtr<VclAbstractDialog> CreateVclDialog(vcl::Window* pParent, sal_uInt32 nId) = 0;
 
     // creates instance of PasswordToOpenModifyDialog from cui
-    virtual AbstractPasswordToOpenModifyDialog* CreatePasswordToOpenModifyDialog( vcl::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify ) = 0;
+    virtual VclPtr<AbstractPasswordToOpenModifyDialog> CreatePasswordToOpenModifyDialog( vcl::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify ) = 0;
 
     // creates instance of ScreenshotAnnotationDlg from cui
-    virtual AbstractScreenshotAnnotationDlg* CreateScreenshotAnnotationDlg(
+    virtual VclPtr<AbstractScreenshotAnnotationDlg> CreateScreenshotAnnotationDlg(
         vcl::Window* pParent,
         Dialog& rParentDialog) = 0;
 };
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 7342f52..e21f0cb 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -313,7 +313,12 @@ namespace vcl {
     typedef OutputDevice RenderContext;
 }
 
-class VCL_DLLPUBLIC OutputDevice :public VclReferenceBase
+/**
+* Some things multiple-inherit from VclAbstractDialog and OutputDevice,
+* so we need to use virtual inheritance to keep the referencing counting
+* OK.
+*/
+class VCL_DLLPUBLIC OutputDevice : public virtual VclReferenceBase
 {
     friend class Printer;
     friend class VirtualDevice;
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index f001bcc..6bec013 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -104,6 +104,7 @@
 #include "dwfunctr.hxx"
 #include "acredlin.hxx"
 #include <o3tl/make_unique.hxx>
+#include "scabstdlg.hxx"
 
 ScResId::ScResId( sal_uInt16 nId ) :
     ResId( nId, *SC_MOD()->GetResMgr() )
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index e2bd407..5f61a0ef 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -601,13 +601,13 @@ AbstractScImportAsciiDlg * ScAbstractDialogFactory_Impl::CreateScImportAsciiDlg
                                                     SvStream* pInStream, ScImportAsciiCall eCall )
 {
     VclPtr<ScImportAsciiDlg> pDlg = VclPtr<ScImportAsciiDlg>::Create( nullptr, aDatName,pInStream, eCall );
-    return new AbstractScImportAsciiDlg_Impl( pDlg );
+    return VclPtr<AbstractScImportAsciiDlg_Impl>::Create( pDlg );
 }
 
 AbstractScTextImportOptionsDlg * ScAbstractDialogFactory_Impl::CreateScTextImportOptionsDlg()
 {
     VclPtr<ScTextImportOptionsDlg> pDlg = VclPtr<ScTextImportOptionsDlg>::Create(nullptr);
-    return new AbstractScTextImportOptionsDlg_Impl(pDlg);
+    return VclPtr<AbstractScTextImportOptionsDlg_Impl>::Create(pDlg);
 }
 
 AbstractScAutoFormatDlg * ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg(vcl::Window* pParent,
@@ -616,7 +616,7 @@ AbstractScAutoFormatDlg * ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg(vc
                                                                 ScViewData *pViewData)
 {
     VclPtr<ScAutoFormatDlg> pDlg = VclPtr<ScAutoFormatDlg>::Create(pParent, pAutoFormat, pSelFormatData, pViewData);
-    return new AbstractScAutoFormatDlg_Impl(pDlg);
+    return VclPtr<AbstractScAutoFormatDlg_Impl>::Create(pDlg);
 }
 
 AbstractScColRowLabelDlg *  ScAbstractDialogFactory_Impl::CreateScColRowLabelDlg(vcl::Window* pParent,
@@ -624,59 +624,59 @@ AbstractScColRowLabelDlg *  ScAbstractDialogFactory_Impl::CreateScColRowLabelDlg
                                                                 bool bRow)
 {
     VclPtr<ScColRowLabelDlg> pDlg = VclPtr<ScColRowLabelDlg>::Create( pParent, bCol,bRow );
-    return new AbstractScColRowLabelDlg_Impl( pDlg );
+    return VclPtr<AbstractScColRowLabelDlg_Impl>::Create( pDlg );
 }
 
 AbstractScSortWarningDlg* ScAbstractDialogFactory_Impl::CreateScSortWarningDlg( vcl::Window* pParent, const OUString& rExtendText, const OUString& rCurrentText )
 {
     VclPtr<ScSortWarningDlg> pDlg = VclPtr<ScSortWarningDlg>::Create(pParent, rExtendText, rCurrentText );
-    return new AbstractScSortWarningDlg_Impl( pDlg );
+    return VclPtr<AbstractScSortWarningDlg_Impl>::Create( pDlg );
 }
 
 AbstractScCondFormatManagerDlg* ScAbstractDialogFactory_Impl::CreateScCondFormatMgrDlg(vcl::Window* pParent, ScDocument* pDoc, const ScConditionalFormatList* pFormatList )
 {
     VclPtr<ScCondFormatManagerDlg> pDlg = VclPtr<ScCondFormatManagerDlg>::Create( pParent, pDoc, pFormatList );
-    return new AbstractScCondFormatManagerDlg_Impl( pDlg );
+    return VclPtr<AbstractScCondFormatManagerDlg_Impl>::Create( pDlg );
 }
 
 AbstractScDataPilotDatabaseDlg *  ScAbstractDialogFactory_Impl::CreateScDataPilotDatabaseDlg(vcl::Window* pParent)
 {
     VclPtr<ScDataPilotDatabaseDlg> pDlg = VclPtr<ScDataPilotDatabaseDlg>::Create( pParent );
-    return new AbstractScDataPilotDatabaseDlg_Impl( pDlg );
+    return VclPtr<AbstractScDataPilotDatabaseDlg_Impl>::Create( pDlg );
 }
 
 AbstractScDataPilotSourceTypeDlg* ScAbstractDialogFactory_Impl::CreateScDataPilotSourceTypeDlg(
     vcl::Window* pParent, bool bEnableExternal)
 {
     VclPtr<ScDataPilotSourceTypeDlg> pDlg = VclPtr<ScDataPilotSourceTypeDlg>::Create(pParent, bEnableExternal);
-    return new AbstractScDataPilotSourceTypeDlg_Impl(pDlg);
+    return VclPtr<AbstractScDataPilotSourceTypeDlg_Impl>::Create(pDlg);
 }
 
 AbstractScDataPilotServiceDlg* ScAbstractDialogFactory_Impl::CreateScDataPilotServiceDlg( vcl::Window* pParent,
                                                                         const std::vector<OUString>& rServices )
 {
     VclPtr<ScDataPilotServiceDlg> pDlg = VclPtr<ScDataPilotServiceDlg>::Create( pParent, rServices );
-    return new AbstractScDataPilotServiceDlg_Impl( pDlg );
+    return VclPtr<AbstractScDataPilotServiceDlg_Impl>::Create( pDlg );
 }
 
 AbstractScDeleteCellDlg* ScAbstractDialogFactory_Impl::CreateScDeleteCellDlg(vcl::Window* pParent,
     bool bDisallowCellMove)
 {
     VclPtr<ScDeleteCellDlg> pDlg = VclPtr<ScDeleteCellDlg>::Create(pParent, bDisallowCellMove);
-    return new AbstractScDeleteCellDlg_Impl( pDlg );
+    return VclPtr<AbstractScDeleteCellDlg_Impl>::Create( pDlg );
 }
 
 AbstractScDataFormDlg* ScAbstractDialogFactory_Impl::CreateScDataFormDlg(vcl::Window* pParent,
     ScTabViewShell* pTabViewShell)
 {
     VclPtr<ScDataFormDlg> pDlg = VclPtr<ScDataFormDlg>::Create(pParent, pTabViewShell);
-    return new AbstractScDataFormDlg_Impl(pDlg);
+    return VclPtr<AbstractScDataFormDlg_Impl>::Create(pDlg);
 }
 
 AbstractScDeleteContentsDlg* ScAbstractDialogFactory_Impl::CreateScDeleteContentsDlg(vcl::Window* pParent)
 {
     VclPtr<ScDeleteContentsDlg> pDlg = VclPtr<ScDeleteContentsDlg>::Create(pParent, InsertDeleteFlags::NONE);
-    return new AbstractScDeleteContentsDlg_Impl( pDlg );
+    return VclPtr<AbstractScDeleteContentsDlg_Impl>::Create( pDlg );
 }
 
 AbstractScFillSeriesDlg* ScAbstractDialogFactory_Impl::CreateScFillSeriesDlg( vcl::Window*       pParent,
@@ -690,48 +690,48 @@ AbstractScFillSeriesDlg* ScAbstractDialogFactory_Impl::CreateScFillSeriesDlg( vc
                                                             sal_uInt16      nPossDir)
 {
     VclPtr<ScFillSeriesDlg> pDlg = VclPtr<ScFillSeriesDlg>::Create( pParent, rDocument,eFillDir, eFillCmd,eFillDateCmd, aStartStr,fStep,fMax,nPossDir);
-    return new AbstractScFillSeriesDlg_Impl( pDlg );
+    return VclPtr<AbstractScFillSeriesDlg_Impl>::Create( pDlg );
 }
 
 AbstractScGroupDlg* ScAbstractDialogFactory_Impl::CreateAbstractScGroupDlg( vcl::Window* pParent,
                                                             bool bUnGroup )
 {
     VclPtr<ScGroupDlg> pDlg = VclPtr<ScGroupDlg>::Create( pParent, bUnGroup, true/*bRows*/);
-    return new AbstractScGroupDlg_Impl( pDlg );
+    return VclPtr<AbstractScGroupDlg_Impl>::Create( pDlg );
 }
 
 AbstractScInsertCellDlg * ScAbstractDialogFactory_Impl::CreateScInsertCellDlg( vcl::Window* pParent,
                                                                 bool bDisallowCellMove )
 {
     VclPtr<ScInsertCellDlg> pDlg = VclPtr<ScInsertCellDlg>::Create( pParent, bDisallowCellMove);
-    return new AbstractScInsertCellDlg_Impl( pDlg );
+    return VclPtr<AbstractScInsertCellDlg_Impl>::Create( pDlg );
 }
 
 AbstractScInsertContentsDlg * ScAbstractDialogFactory_Impl::CreateScInsertContentsDlg( vcl::Window*      pParent,
                                                                                     const OUString* pStrTitle )
 {
     VclPtr<ScInsertContentsDlg> pDlg = VclPtr<ScInsertContentsDlg>::Create(pParent, InsertDeleteFlags::NONE, pStrTitle);
-    return new AbstractScInsertContentsDlg_Impl( pDlg );
+    return VclPtr<AbstractScInsertContentsDlg_Impl>::Create( pDlg );
 }
 
 AbstractScInsertTableDlg * ScAbstractDialogFactory_Impl::CreateScInsertTableDlg(vcl::Window* pParent, ScViewData& rViewData,
     SCTAB nTabCount, bool bFromFile)
 {
     VclPtr<ScInsertTableDlg> pDlg = VclPtr<ScInsertTableDlg>::Create( pParent, rViewData,nTabCount, bFromFile );
-    return new AbstractScInsertTableDlg_Impl( pDlg );
+    return VclPtr<AbstractScInsertTableDlg_Impl>::Create( pDlg );
 }
 
 AbstractScSelEntryDlg * ScAbstractDialogFactory_Impl::CreateScSelEntryDlg ( vcl::Window* pParent,
                                                         const std::vector<OUString> &rEntryList )
 {
     VclPtr<ScSelEntryDlg> pDlg = VclPtr<ScSelEntryDlg>::Create( pParent, rEntryList );
-    return new AbstractScSelEntryDlg_Impl( pDlg );
+    return VclPtr<AbstractScSelEntryDlg_Impl>::Create( pDlg );
 }
 
 AbstractScLinkedAreaDlg * ScAbstractDialogFactory_Impl::CreateScLinkedAreaDlg(vcl::Window* pParent)
 {
     VclPtr<ScLinkedAreaDlg> pDlg = VclPtr<ScLinkedAreaDlg>::Create( pParent );
-    return new AbstractScLinkedAreaDlg_Impl( pDlg );
+    return VclPtr<AbstractScLinkedAreaDlg_Impl>::Create( pDlg );
 }
 
 AbstractScMetricInputDlg * ScAbstractDialogFactory_Impl::CreateScMetricInputDlg (  vcl::Window*      pParent,
@@ -745,33 +745,33 @@ AbstractScMetricInputDlg * ScAbstractDialogFactory_Impl::CreateScMetricInputDlg
 {
     VclPtr<ScMetricInputDlg> pDlg = VclPtr<ScMetricInputDlg>::Create(pParent, sDialogName, nCurrent ,nDefault, eFUnit,
         nDecimals, nMaximum , nMinimum , 1, 100);
-    return new AbstractScMetricInputDlg_Impl( pDlg );
+    return VclPtr<AbstractScMetricInputDlg_Impl>::Create( pDlg );
 }
 
 AbstractScMoveTableDlg * ScAbstractDialogFactory_Impl::CreateScMoveTableDlg(vcl::Window* pParent,
     const OUString& rDefault)
 {
     VclPtr<ScMoveTableDlg> pDlg = VclPtr<ScMoveTableDlg>::Create( pParent, rDefault );
-    return new AbstractScMoveTableDlg_Impl( pDlg );
+    return VclPtr<AbstractScMoveTableDlg_Impl>::Create( pDlg );
 }
 
 AbstractScNameCreateDlg * ScAbstractDialogFactory_Impl::CreateScNameCreateDlg(vcl::Window * pParent, sal_uInt16 nFlags)
 {
     VclPtr<ScNameCreateDlg> pDlg = VclPtr<ScNameCreateDlg>::Create( pParent, nFlags );
-    return new AbstractScNameCreateDlg_Impl( pDlg );
+    return VclPtr<AbstractScNameCreateDlg_Impl>::Create( pDlg );
 }
 
 AbstractScNamePasteDlg * ScAbstractDialogFactory_Impl::CreateScNamePasteDlg ( vcl::Window * pParent, ScDocShell* pShell, bool bInsList )
 {
     VclPtr<ScNamePasteDlg> pDlg = VclPtr<ScNamePasteDlg>::Create( pParent, pShell, bInsList );
-    return new AbstractScNamePasteDlg_Impl( pDlg );
+    return VclPtr<AbstractScNamePasteDlg_Impl>::Create( pDlg );
 }
 
 AbstractScPivotFilterDlg * ScAbstractDialogFactory_Impl::CreateScPivotFilterDlg(vcl::Window* pParent,
     const SfxItemSet& rArgSet, sal_uInt16 nSourceTab)
 {
     VclPtr<ScPivotFilterDlg> pDlg = VclPtr<ScPivotFilterDlg>::Create(pParent, rArgSet, nSourceTab);
-    return new AbstractScPivotFilterDlg_Impl(pDlg);
+    return VclPtr<AbstractScPivotFilterDlg_Impl>::Create(pDlg);
 }
 
 AbstractScDPFunctionDlg * ScAbstractDialogFactory_Impl::CreateScDPFunctionDlg ( vcl::Window* pParent,
@@ -780,7 +780,7 @@ AbstractScDPFunctionDlg * ScAbstractDialogFactory_Impl::CreateScDPFunctionDlg (
                                                                 const ScPivotFuncData& rFuncData )
 {
     VclPtr<ScDPFunctionDlg> pDlg = VclPtr<ScDPFunctionDlg>::Create( pParent, rLabelVec, rLabelData, rFuncData );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list