[Libreoffice-commits] core.git: basctl/source chart2/source cui/source dbaccess/source desktop/source extensions/source formula/source include/vcl sc/source sd/source sfx2/source starmath/source svtools/source svx/source sw/source vcl/source

Michael Meeks michael.meeks at collabora.com
Tue May 12 01:34:04 PDT 2015


 basctl/source/basicide/bastype2.cxx                        |    2 -
 basctl/source/basicide/moduldl2.cxx                        |    2 -
 basctl/source/basicide/moduldlg.cxx                        |    4 --
 chart2/source/controller/dialogs/tp_DataSourceControls.cxx |    2 -
 cui/source/customize/acccfg.cxx                            |    2 -
 cui/source/customize/cfgutil.cxx                           |    4 +-
 cui/source/customize/macropg.cxx                           |    2 -
 cui/source/customize/selector.cxx                          |    4 +-
 cui/source/dialogs/SpellDialog.cxx                         |    2 -
 cui/source/dialogs/colorpicker.cxx                         |    6 +--
 cui/source/dialogs/cuigrfflt.cxx                           |    4 --
 cui/source/dialogs/hlmarkwn.cxx                            |    2 -
 cui/source/options/optcolor.cxx                            |    2 -
 cui/source/tabpages/autocdlg.cxx                           |    2 -
 cui/source/tabpages/backgrnd.cxx                           |    2 -
 cui/source/tabpages/grfpage.cxx                            |    2 -
 dbaccess/source/ui/control/curledit.cxx                    |    2 -
 dbaccess/source/ui/control/tabletree.cxx                   |    2 -
 dbaccess/source/ui/dlg/indexfieldscontrol.cxx              |    2 -
 desktop/source/deployment/gui/dp_gui_dialog2.cxx           |    4 --
 desktop/source/deployment/gui/dp_gui_extlistbox.cxx        |    2 -
 desktop/source/deployment/gui/license_dialog.cxx           |    2 -
 extensions/source/propctrlr/taborder.cxx                   |    3 -
 extensions/source/scanner/sanedlg.cxx                      |    2 -
 formula/source/ui/dlg/funcutl.cxx                          |    2 -
 include/vcl/builder.hxx                                    |    4 +-
 include/vcl/builderfactory.hxx                             |    9 ++--
 sc/source/ui/cctrl/editfield.cxx                           |    2 -
 sc/source/ui/condformat/condformatdlg.cxx                  |    2 -
 sc/source/ui/dbgui/pvfundlg.cxx                            |    2 -
 sc/source/ui/dbgui/validate.cxx                            |    2 -
 sc/source/ui/miscdlgs/tabbgcolordlg.cxx                    |    2 -
 sc/source/ui/pagedlg/tphfedit.cxx                          |    2 -
 sd/source/filter/html/htmlattr.cxx                         |    2 -
 sd/source/ui/dlg/RemoteDialogClientBox.cxx                 |    2 -
 sd/source/ui/dlg/dlgassim.cxx                              |    2 -
 sd/source/ui/dlg/dlgctrls.cxx                              |    2 -
 sd/source/ui/dlg/docprev.cxx                               |    2 -
 sd/source/ui/dlg/sdtreelb.cxx                              |    2 -
 sd/source/ui/table/TableDesignPane.cxx                     |    2 -
 sfx2/source/appl/newhelp.cxx                               |   18 ++++-----
 sfx2/source/control/templateremoteview.cxx                 |    2 -
 sfx2/source/doc/new.cxx                                    |    2 -
 starmath/source/dialog.cxx                                 |    7 +--
 svtools/source/contnr/fileview.cxx                         |    6 ---
 svtools/source/contnr/svtabbx.cxx                          |    2 -
 svtools/source/contnr/treelistbox.cxx                      |    2 -
 svtools/source/control/ctrlbox.cxx                         |   20 +++++-----
 svtools/source/control/inettbc.cxx                         |    4 +-
 svtools/source/control/urlcontrol.cxx                      |    4 +-
 svtools/source/control/valueset.cxx                        |    2 -
 svx/source/dialog/checklbx.cxx                             |    2 -
 svx/source/dialog/connctrl.cxx                             |    2 -
 svx/source/dialog/dlgctrl.cxx                              |   24 ++++++-------
 svx/source/dialog/fntctrl.cxx                              |    3 -
 svx/source/dialog/fontlb.cxx                               |    2 -
 svx/source/dialog/frmdirlbox.cxx                           |    4 +-
 svx/source/dialog/frmsel.cxx                               |    2 -
 svx/source/dialog/graphctl.cxx                             |    2 -
 svx/source/dialog/langbox.cxx                              |    8 ++--
 svx/source/dialog/measctrl.cxx                             |    2 -
 svx/source/dialog/relfld.cxx                               |   15 +++-----
 svx/source/dialog/txencbox.cxx                             |    9 +---
 svx/source/gallery2/galctrl.cxx                            |    2 -
 svx/source/tbxctrls/SvxColorValueSet.cxx                   |    2 -
 sw/source/ui/config/optload.cxx                            |    6 +--
 sw/source/ui/dbui/createaddresslistdialog.cxx              |    2 -
 sw/source/ui/dbui/mmaddressblockpage.cxx                   |    4 +-
 sw/source/ui/fldui/FldRefTreeListBox.cxx                   |    2 -
 sw/source/ui/fldui/fldvar.cxx                              |    5 +-
 sw/source/ui/index/cnttab.cxx                              |    2 -
 sw/source/ui/table/tautofmt.cxx                            |    2 -
 sw/source/uibase/cctrl/actctrl.cxx                         |    2 -
 sw/source/uibase/dbui/dbtree.cxx                           |    2 -
 sw/source/uibase/dbui/mailmergehelper.cxx                  |    2 -
 sw/source/uibase/misc/numberingtypelistbox.cxx             |    4 +-
 sw/source/uibase/utlui/condedit.cxx                        |    2 -
 sw/source/uibase/utlui/numfmtlb.cxx                        |    4 +-
 vcl/source/window/builder.cxx                              |    5 ++
 vcl/source/window/printdlg.cxx                             |    4 +-
 80 files changed, 141 insertions(+), 159 deletions(-)

New commits:
commit 936a49646738452f7331ed9a47ac015db9ee7295
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon May 11 14:02:42 2015 +0100

    Switch VclBuilder constructors to use VclPtr.
    
    Change-Id: Id35a86eb52bbde6ca09a5e61a0b1a79b23be8faf

diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index 27f35d5..de25591 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -202,7 +202,7 @@ VCL_BUILDER_DECL_FACTORY(TreeListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
-    return new TreeListBox(pParent, nWinBits);
+    rRet = VclPtr<TreeListBox>::Create(pParent, nWinBits);
 }
 
 TreeListBox::~TreeListBox ()
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index 32c9280d..012419c 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -152,7 +152,7 @@ VCL_BUILDER_DECL_FACTORY(CheckBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
-    return new CheckBox(pParent, nWinBits);
+    rRet = VclPtr<CheckBox>::Create(pParent, nWinBits);
 }
 
 CheckBox::~CheckBox()
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 712c66c..504545e 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -47,8 +47,6 @@ using namespace ::com::sun::star::resource;
 
 // ExtTreeListBox
 
-
-
 ExtTreeListBox::ExtTreeListBox(vcl::Window* pParent, WinBits nStyle)
     : TreeListBox(pParent, nStyle)
 {
@@ -60,7 +58,7 @@ VCL_BUILDER_DECL_FACTORY(ExtTreeListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
-    return new ExtTreeListBox(pParent, nWinBits);
+    rRet = VclPtr<ExtTreeListBox>::Create(pParent, nWinBits);
 }
 
 bool ExtTreeListBox::EditingEntry( SvTreeListEntry* pEntry, Selection& )
diff --git a/chart2/source/controller/dialogs/tp_DataSourceControls.cxx b/chart2/source/controller/dialogs/tp_DataSourceControls.cxx
index 55eb084..2991f23 100644
--- a/chart2/source/controller/dialogs/tp_DataSourceControls.cxx
+++ b/chart2/source/controller/dialogs/tp_DataSourceControls.cxx
@@ -42,7 +42,7 @@ VCL_BUILDER_DECL_FACTORY(SeriesListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SeriesListBox(pParent, nWinStyle);
+    rRet = VclPtr<SeriesListBox>::Create(pParent, nWinStyle);
 }
 
 SvTreeListEntry* SeriesListBox::CreateEntry() const
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index 42e2f98..45e8ae8 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -661,7 +661,7 @@ VCL_BUILDER_DECL_FACTORY(SfxAccCfgTabListBox)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new SfxAccCfgTabListBox_Impl(pParent, nWinBits);
+    rRet = VclPtr<SfxAccCfgTabListBox_Impl>::Create(pParent, nWinBits);
 }
 
 void SfxAccCfgTabListBox_Impl::InitEntry(SvTreeListEntry* pEntry,
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index c74e0e7..f554062 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -266,7 +266,7 @@ VCL_BUILDER_DECL_FACTORY(SfxConfigFunctionListBox)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new SfxConfigFunctionListBox(pParent, nWinBits);
+    rRet = VclPtr<SfxConfigFunctionListBox>::Create(pParent, nWinBits);
 }
 
 SfxConfigFunctionListBox::~SfxConfigFunctionListBox()
@@ -408,7 +408,7 @@ VCL_BUILDER_DECL_FACTORY(SfxConfigGroupListBox)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new SfxConfigGroupListBox(pParent, nWinBits);
+    rRet = VclPtr<SfxConfigGroupListBox>::Create(pParent, nWinBits);
 }
 
 SfxConfigGroupListBox::~SfxConfigGroupListBox()
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index c50b487..6211bcc 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -161,7 +161,7 @@ VCL_BUILDER_DECL_FACTORY(MacroEventListBox)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new MacroEventListBox(pParent, nWinBits);
+    rRet = VclPtr<MacroEventListBox>::Create(pParent, nWinBits);
 }
 
 Size MacroEventListBox::GetOptimalSize() const
diff --git a/cui/source/customize/selector.cxx b/cui/source/customize/selector.cxx
index ce1cbca..781ddbf 100644
--- a/cui/source/customize/selector.cxx
+++ b/cui/source/customize/selector.cxx
@@ -95,7 +95,7 @@ VCL_BUILDER_DECL_FACTORY(SvxConfigFunctionListBox)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new SvxConfigFunctionListBox(pParent, nWinBits);
+    rRet = VclPtr<SvxConfigFunctionListBox>::Create(pParent, nWinBits);
 }
 
 SvxConfigFunctionListBox::~SvxConfigFunctionListBox()
@@ -228,7 +228,7 @@ VCL_BUILDER_DECL_FACTORY(SvxConfigGroupListBox)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new SvxConfigGroupListBox(pParent, nWinBits);
+    rRet = VclPtr<SvxConfigGroupListBox>::Create(pParent, nWinBits);
 }
 
 SvxConfigGroupListBox::~SvxConfigGroupListBox()
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index a27774c..dad2575 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -1222,7 +1222,7 @@ SentenceEditWindow_Impl::SentenceEditWindow_Impl(vcl::Window * pParent, WinBits
 VCL_BUILDER_DECL_FACTORY(SentenceEditWindow)
 {
     (void)rMap;
-    return new SentenceEditWindow_Impl(pParent, WB_BORDER|WB_VSCROLL|WB_IGNORETAB);
+    rRet = VclPtr<SentenceEditWindow_Impl>::Create(pParent, WB_BORDER|WB_VSCROLL|WB_IGNORETAB);
 }
 
 
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx
index ee90eb7..78aa083a 100644
--- a/cui/source/dialogs/colorpicker.cxx
+++ b/cui/source/dialogs/colorpicker.cxx
@@ -280,7 +280,7 @@ VCL_BUILDER_DECL_FACTORY(ColorPreviewControl)
     if (!sBorder.isEmpty())
         nBits |= WB_BORDER;
 
-    return new ColorPreviewControl(pParent, nBits);
+    rRet = VclPtr<ColorPreviewControl>::Create(pParent, nBits);
 }
 
 void ColorPreviewControl::SetColor( const Color& rCol )
@@ -376,7 +376,7 @@ VCL_BUILDER_DECL_FACTORY(ColorFieldControl)
     if (!sBorder.isEmpty())
         nBits |= WB_BORDER;
 
-    return new ColorFieldControl(pParent, nBits);
+    rRet = VclPtr<ColorFieldControl>::Create(pParent, nBits);
 }
 
 Size ColorFieldControl::GetOptimalSize() const
@@ -769,7 +769,7 @@ VCL_BUILDER_DECL_FACTORY(ColorSliderControl)
     if (!sBorder.isEmpty())
         nBits |= WB_BORDER;
 
-    return new ColorSliderControl(pParent, nBits);
+    rRet = VclPtr<ColorSliderControl>::Create(pParent, nBits);
 }
 
 void ColorSliderControl::UpdateBitmap()
diff --git a/cui/source/dialogs/cuigrfflt.cxx b/cui/source/dialogs/cuigrfflt.cxx
index 2edac2d..43b9493 100644
--- a/cui/source/dialogs/cuigrfflt.cxx
+++ b/cui/source/dialogs/cuigrfflt.cxx
@@ -45,7 +45,7 @@ VCL_BUILDER_DECL_FACTORY(GraphicPreviewWindow)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new GraphicPreviewWindow(pParent, nWinBits);
+    rRet = VclPtr<GraphicPreviewWindow>::Create(pParent, nWinBits);
 }
 
 Size GraphicPreviewWindow::GetOptimalSize() const
@@ -53,8 +53,6 @@ Size GraphicPreviewWindow::GetOptimalSize() const
     return LogicToPixel(Size(81, 73), MAP_APPFONT);
 }
 
-
-
 void GraphicPreviewWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
 {
     Control::Paint(rRenderContext, rRect);
diff --git a/cui/source/dialogs/hlmarkwn.cxx b/cui/source/dialogs/hlmarkwn.cxx
index b65bf8c..40327e9 100644
--- a/cui/source/dialogs/hlmarkwn.cxx
+++ b/cui/source/dialogs/hlmarkwn.cxx
@@ -90,7 +90,7 @@ VCL_BUILDER_DECL_FACTORY(SvxHlmarkTreeLBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SvxHlmarkTreeLBox(pParent, nWinStyle);
+    rRet = VclPtr<SvxHlmarkTreeLBox>::Create(pParent, nWinStyle);
 }
 
 Size SvxHlmarkTreeLBox::GetOptimalSize() const
diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx
index 65064c3..5b1c429 100644
--- a/cui/source/options/optcolor.cxx
+++ b/cui/source/options/optcolor.cxx
@@ -931,7 +931,7 @@ void ColorConfigCtrl_Impl::dispose()
 VCL_BUILDER_DECL_FACTORY(ColorConfigCtrl)
 {
     (void)rMap;
-    return new ColorConfigCtrl_Impl(pParent);
+    rRet = VclPtr<ColorConfigCtrl_Impl>::Create(pParent);
 }
 
 void ColorConfigCtrl_Impl::Update ()
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index 259a28f..7b2698f 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -2463,7 +2463,7 @@ VCL_BUILDER_DECL_FACTORY(AutoCompleteMultiListBox)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new OfaAutoCompleteTabPage::AutoCompleteMultiListBox(pParent, nWinBits);
+    rRet = VclPtr<OfaAutoCompleteTabPage::AutoCompleteMultiListBox>::Create(pParent, nWinBits);
 }
 
 // class OfaSmartTagOptionsTabPage ---------------------------------------------
diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 2c9998e..bc28171 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -219,7 +219,7 @@ BackgroundPreviewImpl::BackgroundPreviewImpl(vcl::Window* pParent)
 VCL_BUILDER_DECL_FACTORY(BackgroundPreview)
 {
     (void)rMap;
-    return new BackgroundPreviewImpl(pParent);
+    rRet = VclPtr<BackgroundPreviewImpl>::Create(pParent);
 }
 
 void BackgroundPreviewImpl::setBmp(bool bBmp)
diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx
index 15c9541..eab3807 100644
--- a/cui/source/tabpages/grfpage.cxx
+++ b/cui/source/tabpages/grfpage.cxx
@@ -796,7 +796,7 @@ VCL_BUILDER_DECL_FACTORY(SvxCropExample)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SvxCropExample(pParent, nWinStyle);
+    rRet = VclPtr<SvxCropExample>::Create(pParent, nWinStyle);
 }
 
 void SvxCropExample::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
diff --git a/dbaccess/source/ui/control/curledit.cxx b/dbaccess/source/ui/control/curledit.cxx
index 35b58d9..483bd41 100644
--- a/dbaccess/source/ui/control/curledit.cxx
+++ b/dbaccess/source/ui/control/curledit.cxx
@@ -37,7 +37,7 @@ OConnectionURLEdit::OConnectionURLEdit(vcl::Window* _pParent, WinBits _nBits,boo
 VCL_BUILDER_DECL_FACTORY(ConnectionURLEdit)
 {
     (void)rMap;
-    return new OConnectionURLEdit(pParent, WB_BORDER, false);
+    rRet = VclPtr<OConnectionURLEdit>::Create(pParent, WB_BORDER, false);
 }
 
 OConnectionURLEdit::~OConnectionURLEdit()
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx
index 8b54d8d..0bce936 100644
--- a/dbaccess/source/ui/control/tabletree.cxx
+++ b/dbaccess/source/ui/control/tabletree.cxx
@@ -81,7 +81,7 @@ VCL_BUILDER_DECL_FACTORY(OTableTreeListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new OTableTreeListBox(pParent, nWinStyle);
+    rRet = VclPtr<OTableTreeListBox>::Create(pParent, nWinStyle);
 }
 
 void OTableTreeListBox::implSetDefaultImages()
diff --git a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
index 50d91c8..dd8f753 100644
--- a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
+++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
@@ -106,7 +106,7 @@ namespace dbaui
     VCL_BUILDER_DECL_FACTORY(DbaIndexFieldsControl)
     {
         (void)rMap;
-        return new IndexFieldsControl (pParent, WB_BORDER | WB_NOTABSTOP);
+        rRet = VclPtr<IndexFieldsControl>::Create(pParent, WB_BORDER | WB_NOTABSTOP);
     }
 
     IndexFieldsControl::~IndexFieldsControl()
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index 37e653e..0102292 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -195,14 +195,12 @@ void ExtBoxWithBtns_Impl::InitFromDialog(ExtMgrDialog *pParentDialog)
     SetScrollHdl( LINK( this, ExtBoxWithBtns_Impl, ScrollHdl ) );
 }
 
-
 VCL_BUILDER_DECL_FACTORY(ExtBoxWithBtns)
 {
     (void)rMap;
-    return new ExtBoxWithBtns_Impl(pParent);
+    rRet = VclPtr<ExtBoxWithBtns_Impl>::Create(pParent);
 }
 
-
 ExtBoxWithBtns_Impl::~ExtBoxWithBtns_Impl()
 {
     disposeOnce();
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
index 26b577e..7988fc9 100644
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
@@ -833,7 +833,7 @@ Size ExtensionBox_Impl::GetOptimalSize() const
 VCL_BUILDER_DECL_FACTORY(ExtensionBox)
 {
     (void)rMap;
-    return new ExtensionBox_Impl(pParent);
+    rRet = VclPtr<ExtensionBox_Impl>::Create(pParent);
 }
 
 long ExtensionBox_Impl::PointToPos( const Point& rPos )
diff --git a/desktop/source/deployment/gui/license_dialog.cxx b/desktop/source/deployment/gui/license_dialog.cxx
index 141d64b..f37082e 100644
--- a/desktop/source/deployment/gui/license_dialog.cxx
+++ b/desktop/source/deployment/gui/license_dialog.cxx
@@ -132,7 +132,7 @@ VCL_BUILDER_DECL_FACTORY(LicenseView)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new LicenseView(pParent, nWinStyle | WB_VSCROLL);
+    rRet = VclPtr<LicenseView>::Create(pParent, nWinStyle | WB_VSCROLL);
 }
 
 LicenseView::~LicenseView()
diff --git a/extensions/source/propctrlr/taborder.cxx b/extensions/source/propctrlr/taborder.cxx
index 63ce93e..08c6670 100644
--- a/extensions/source/propctrlr/taborder.cxx
+++ b/extensions/source/propctrlr/taborder.cxx
@@ -311,10 +311,9 @@ namespace pcr
          OString sBorder = VclBuilder::extractCustomProperty(rMap);
          if (!sBorder.isEmpty())
              nWinStyle |= WB_BORDER;
-         return new TabOrderListBox(pParent, nWinStyle);
+         rRet = VclPtr<TabOrderListBox>::Create(pParent, nWinStyle);
     }
 
-
     TabOrderListBox::~TabOrderListBox()
     {
     }
diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx
index 68f7745..8ebcf69 100644
--- a/extensions/source/scanner/sanedlg.cxx
+++ b/extensions/source/scanner/sanedlg.cxx
@@ -158,7 +158,7 @@ VCL_BUILDER_DECL_FACTORY(ScanPreview)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new ScanPreview(pParent, nWinStyle);
+    rRet = VclPtr<ScanPreview>::Create(pParent, nWinStyle);
 }
 
 SaneDlg::SaneDlg( vcl::Window* pParent, Sane& rSane, bool bScanEnabled ) :
diff --git a/formula/source/ui/dlg/funcutl.cxx b/formula/source/ui/dlg/funcutl.cxx
index 9355b5e..7f3e6f7 100644
--- a/formula/source/ui/dlg/funcutl.cxx
+++ b/formula/source/ui/dlg/funcutl.cxx
@@ -489,7 +489,7 @@ RefEdit::RefEdit( vcl::Window* _pParent,IControlReferenceHandler* pParent,
 VCL_BUILDER_DECL_FACTORY(RefEdit)
 {
     (void)rMap;
-    return new RefEdit(pParent, NULL, WB_BORDER);
+    rRet = VclPtr<RefEdit>::Create(pParent, nullptr, WB_BORDER);
 }
 
 RefEdit::~RefEdit()
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 4b7683d..518d8a8 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -46,8 +46,8 @@ class VCL_DLLPUBLIC VclBuilder
 {
 public:
     typedef std::map<OString, OString> stringmap;
-    /// These functions return a vcl::Window with a reference count of one.
-    typedef vcl::Window* (*customMakeWidget)(vcl::Window *pParent, stringmap &rVec);
+    /// These functions create a new widget with parent @pParent and return it in @rRet
+    typedef void (*customMakeWidget)(VclPtr<vcl::Window> &rRet, VclPtr<vcl::Window> &pParent, stringmap &rVec);
 
 public:
                     VclBuilder(
diff --git a/include/vcl/builderfactory.hxx b/include/vcl/builderfactory.hxx
index b50a557..f2d0c4cf 100644
--- a/include/vcl/builderfactory.hxx
+++ b/include/vcl/builderfactory.hxx
@@ -10,24 +10,25 @@
 #ifndef INCLUDED_VCL_BUILDER_FACTORY_HXX
 #define INCLUDED_VCL_BUILDER_FACTORY_HXX
 
+#include <vcl/vclptr.hxx>
 #include <vcl/builder.hxx>
 
 #define VCL_BUILDER_DECL_FACTORY(typeName) \
-    extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL \
-        make##typeName(vcl::Window *pParent, VclBuilder::stringmap &rMap)
+    extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL \
+        make##typeName(VclPtr<vcl::Window> &rRet, VclPtr<vcl::Window> &pParent, VclBuilder::stringmap &rMap)
 
 #define VCL_BUILDER_FACTORY(typeName) \
     VCL_BUILDER_DECL_FACTORY(typeName) \
     { \
         (void)rMap; \
-        return new typeName(pParent); \
+        rRet = VclPtr<typeName>::Create(pParent); \
     }
 
 #define VCL_BUILDER_FACTORY_ARGS(typeName,arg1) \
     VCL_BUILDER_DECL_FACTORY(typeName) \
     { \
         (void)rMap; \
-        return new typeName(pParent,arg1); \
+        rRet = VclPtr<typeName>::Create(pParent,arg1); \
     }
 
 #endif
diff --git a/sc/source/ui/cctrl/editfield.cxx b/sc/source/ui/cctrl/editfield.cxx
index 78650e6..13419e8 100644
--- a/sc/source/ui/cctrl/editfield.cxx
+++ b/sc/source/ui/cctrl/editfield.cxx
@@ -49,7 +49,7 @@ ScDoubleField::ScDoubleField( vcl::Window* pParent, WinBits nStyle ) :
 VCL_BUILDER_DECL_FACTORY(ScDoubleField)
 {
     VclBuilder::ensureDefaultWidthChars(rMap);
-    return new ScDoubleField(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
+    rRet = VclPtr<ScDoubleField>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
 }
 
 bool ScDoubleField::GetValue( double& rfValue ) const
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 0e2cbf5..2fa4e20 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -151,7 +151,7 @@ VCL_BUILDER_DECL_FACTORY(ScCondFormatList)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new ScCondFormatList(pParent, nWinBits);
+    rRet = VclPtr<ScCondFormatList>::Create(pParent, nWinBits);
 }
 
 Size ScCondFormatList::GetOptimalSize() const
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index 8ef5c95..292a07e 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -163,7 +163,7 @@ VCL_BUILDER_DECL_FACTORY(ScDPFunctionListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new ScDPFunctionListBox(pParent, nWinStyle);
+    rRet = VclPtr<ScDPFunctionListBox>::Create(pParent, nWinStyle);
 }
 
 void ScDPFunctionListBox::SetSelection( sal_uInt16 nFuncMask )
diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx
index 187fefd..54edca1 100644
--- a/sc/source/ui/dbgui/validate.cxx
+++ b/sc/source/ui/dbgui/validate.cxx
@@ -940,7 +940,7 @@ bool ScValidationDlg::RemoveRefDlg( bool bRestoreModal /* = true */ )
 VCL_BUILDER_DECL_FACTORY(ScRefButtonEx)
 {
     (void)rMap;
-    return new ScTPValidationValue::ScRefButtonEx(pParent, 0);
+    rRet = VclPtr<ScTPValidationValue::ScRefButtonEx>::Create(pParent, 0);
 }
 
 void ScTPValidationValue::ScRefButtonEx::Click()
diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
index 55aacef..56541ae 100644
--- a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
+++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
@@ -166,7 +166,7 @@ VCL_BUILDER_DECL_FACTORY(ScTabBgColorValueSet)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new ScTabBgColorDlg::ScTabBgColorValueSet(pParent, nWinBits);
+    rRet = VclPtr<ScTabBgColorDlg::ScTabBgColorValueSet>::Create(pParent, nWinBits);
 }
 
 void ScTabBgColorDlg::ScTabBgColorValueSet::KeyInput( const KeyEvent& rKEvt )
diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx
index 38ed894..a01a89f 100644
--- a/sc/source/ui/pagedlg/tphfedit.cxx
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -139,7 +139,7 @@ void ScEditWindow::dispose()
 VCL_BUILDER_DECL_FACTORY(ScEditWindow)
 {
     (void)rMap;
-    return new ScEditWindow (pParent, WB_BORDER|WB_TABSTOP, Left);
+    rRet = VclPtr<ScEditWindow>::Create(pParent, WB_BORDER|WB_TABSTOP, Left);
 }
 
 void ScEditWindow::SetNumType(SvxNumType eNumType)
diff --git a/sd/source/filter/html/htmlattr.cxx b/sd/source/filter/html/htmlattr.cxx
index 3f4db20..dd1f472 100644
--- a/sd/source/filter/html/htmlattr.cxx
+++ b/sd/source/filter/html/htmlattr.cxx
@@ -35,7 +35,7 @@ VCL_BUILDER_DECL_FACTORY(SdHtmlAttrPreview)
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
 
-    return new SdHtmlAttrPreview(pParent, nWinStyle);
+    rRet = VclPtr<SdHtmlAttrPreview>::Create(pParent, nWinStyle);
 }
 
 SdHtmlAttrPreview::~SdHtmlAttrPreview()
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
index 4c8bcf9..bc95d25 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
@@ -115,7 +115,7 @@ VCL_BUILDER_DECL_FACTORY(ClientBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new ClientBox(pParent, nWinStyle);
+    rRet = VclPtr<ClientBox>::Create(pParent, nWinStyle);
 }
 
 Size ClientBox::GetOptimalSize() const
diff --git a/sd/source/ui/dlg/dlgassim.cxx b/sd/source/ui/dlg/dlgassim.cxx
index 2c308f7..fdbf21c 100644
--- a/sd/source/ui/dlg/dlgassim.cxx
+++ b/sd/source/ui/dlg/dlgassim.cxx
@@ -55,7 +55,7 @@ VCL_BUILDER_DECL_FACTORY(SdPageListControl)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SdPageListControl(pParent, nWinStyle);
+    rRet = VclPtr<SdPageListControl>::Create(pParent, nWinStyle);
 }
 
 IMPL_LINK_NOARG(SdPageListControl, CheckButtonClickHdl)
diff --git a/sd/source/ui/dlg/dlgctrls.cxx b/sd/source/ui/dlg/dlgctrls.cxx
index 3256321..ed3c009 100644
--- a/sd/source/ui/dlg/dlgctrls.cxx
+++ b/sd/source/ui/dlg/dlgctrls.cxx
@@ -81,7 +81,7 @@ VCL_BUILDER_DECL_FACTORY(FadeEffectLB)
     if (bDropdown)
         nBits |= WB_DROPDOWN;
 
-    return new FadeEffectLB(pParent, nBits);
+    rRet = VclPtr<FadeEffectLB>::Create(pParent, nBits);
 }
 
 void FadeEffectLB::applySelected( SdPage* pSlide ) const
diff --git a/sd/source/ui/dlg/docprev.cxx b/sd/source/ui/dlg/docprev.cxx
index e0cba08..a9e2194 100644
--- a/sd/source/ui/dlg/docprev.cxx
+++ b/sd/source/ui/dlg/docprev.cxx
@@ -70,7 +70,7 @@ VCL_BUILDER_DECL_FACTORY(SdDocPreviewWin)
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
 
-    return new SdDocPreviewWin(pParent, nWinStyle);
+    rRet = VclPtr<SdDocPreviewWin>::Create(pParent, nWinStyle);
 }
 
 SdDocPreviewWin::SdDocPreviewWin( vcl::Window* pParent, const WinBits nStyle )
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index 0a3c3f4..d0c7864 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -104,7 +104,7 @@ VCL_BUILDER_DECL_FACTORY(SdPageObjsTLB)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SdPageObjsTLB(pParent, nWinStyle);
+    rRet = VclPtr<SdPageObjsTLB>::Create(pParent, nWinStyle);
 }
 
 SdPageObjsTLB::SdPageObjsTransferable::~SdPageObjsTransferable()
diff --git a/sd/source/ui/table/TableDesignPane.cxx b/sd/source/ui/table/TableDesignPane.cxx
index a4ecc26..aac2f0f 100644
--- a/sd/source/ui/table/TableDesignPane.cxx
+++ b/sd/source/ui/table/TableDesignPane.cxx
@@ -372,7 +372,7 @@ VCL_BUILDER_DECL_FACTORY(TableValueSet)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new TableValueSet(pParent, nWinStyle);
+    rRet = VclPtr<TableValueSet>::Create(pParent, nWinStyle);
 }
 
 void TableDesignWidget::updateControls()
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 3b26172..82fc78d 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -297,7 +297,7 @@ VCL_BUILDER_DECL_FACTORY(ContentListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new ContentListBox_Impl(pParent, nWinStyle);
+    rRet = VclPtr<ContentListBox_Impl>::Create(pParent, nWinStyle);
 }
 
 ContentListBox_Impl::~ContentListBox_Impl()
@@ -490,9 +490,9 @@ VCL_BUILDER_DECL_FACTORY(IndexBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
-    IndexBox_Impl* pListBox = new IndexBox_Impl(pParent, nWinBits);
+    VclPtrInstance<IndexBox_Impl> pListBox(pParent, nWinBits);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 void IndexBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
@@ -875,9 +875,9 @@ VCL_BUILDER_DECL_FACTORY(SearchBox)
 {
     (void)rMap;
     WinBits nWinBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_DROPDOWN;
-    SearchBox_Impl* pComboBox = new SearchBox_Impl(pParent, nWinBits);
+    VclPtrInstance<SearchBox_Impl> pComboBox(pParent, nWinBits);
     pComboBox->EnableAutoSize(true);
-    return pComboBox;
+    rRet = pComboBox;
 }
 
 bool SearchBox_Impl::PreNotify( NotifyEvent& rNEvt )
@@ -910,9 +910,9 @@ VCL_BUILDER_DECL_FACTORY(SearchResultsBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
-    SearchResultsBox_Impl* pListBox = new SearchResultsBox_Impl(pParent, nWinBits);
+    VclPtrInstance<SearchResultsBox_Impl> pListBox(pParent, nWinBits);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 bool SearchResultsBox_Impl::Notify( NotifyEvent& rNEvt )
@@ -1177,9 +1177,9 @@ VCL_BUILDER_DECL_FACTORY(BookmarksBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
-    BookmarksBox_Impl* pListBox = new BookmarksBox_Impl(pParent, nWinBits);
+    VclPtrInstance<BookmarksBox_Impl> pListBox(pParent, nWinBits);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 BookmarksBox_Impl::~BookmarksBox_Impl()
diff --git a/sfx2/source/control/templateremoteview.cxx b/sfx2/source/control/templateremoteview.cxx
index ffc0b7b..310dead 100644
--- a/sfx2/source/control/templateremoteview.cxx
+++ b/sfx2/source/control/templateremoteview.cxx
@@ -57,7 +57,7 @@ TemplateRemoteView::TemplateRemoteView (vcl::Window *pParent, WinBits nWinStyle,
 VCL_BUILDER_DECL_FACTORY(TemplateRemoteView)
 {
     (void)rMap;
-    return new TemplateRemoteView(pParent, WB_VSCROLL, false);
+    rRet = VclPtr<TemplateRemoteView>::Create(pParent, WB_VSCROLL, false);
 }
 
 void TemplateRemoteView::showRootRegion()
diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx
index c9e8a2a..09f0fbe 100644
--- a/sfx2/source/doc/new.cxx
+++ b/sfx2/source/doc/new.cxx
@@ -119,7 +119,7 @@ void SfxPreviewWin_Impl::Paint( vcl::RenderContext& /*rRenderContext*/, const Re
 VCL_BUILDER_DECL_FACTORY(SfxPreviewWin)
 {
     (void)rMap;
-    return new SfxPreviewWin_Impl(pParent, 0);
+    rRet = VclPtr<SfxPreviewWin_Impl>::Create(pParent, 0);
 }
 
 class SfxNewFileDialog_Impl
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 24d2ee4..f48fd37 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -264,7 +264,7 @@ VCL_BUILDER_DECL_FACTORY(SmShowFont)
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
 
-    return new SmShowFont(pParent, nWinStyle);
+    rRet = VclPtr<SmShowFont>::Create(pParent, nWinStyle);
 }
 
 Size SmShowFont::GetOptimalSize() const
@@ -1405,7 +1405,7 @@ VCL_BUILDER_DECL_FACTORY(SmShowSymbol)
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
 
-    return new SmShowSymbol(pParent, nWinStyle);
+    rRet = VclPtr<SmShowSymbol>::Create(pParent, nWinStyle);
 }
 
 void SmShowSymbol::Resize()
@@ -1690,7 +1690,6 @@ const SmSym * SmSymbolDialog::GetSymbol() const
     return bValid ? aSymbolSet[ nSymbolNo ] : NULL;
 }
 
-
 VCL_BUILDER_DECL_FACTORY(SmShowChar)
 {
     WinBits nWinStyle = 0;
@@ -1699,7 +1698,7 @@ VCL_BUILDER_DECL_FACTORY(SmShowChar)
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
 
-    return new SmShowChar(pParent, nWinStyle);
+    rRet = VclPtr<SmShowChar>::Create(pParent, nWinStyle);
 }
 
 void SmShowChar::Paint(vcl::RenderContext& rRenderContext, const Rectangle &rRect)
diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx
index 60e5318..ada14a3 100644
--- a/svtools/source/contnr/fileview.cxx
+++ b/svtools/source/contnr/fileview.cxx
@@ -1130,18 +1130,14 @@ VCL_BUILDER_DECL_FACTORY(SvtFileView)
     if (bDropdown)
         nBits |= WB_DROPDOWN;
 
-    return new SvtFileView(pParent, nBits, true, true);
+    rRet = VclPtr<SvtFileView>::Create(pParent, nBits, true, true);
 }
 
-
-
 Size SvtFileView::GetOptimalSize() const
 {
     return LogicToPixel(Size(208, 50), MAP_APPFONT);
 }
 
-
-
 OUString SvtFileView::GetURL( SvTreeListEntry* pEntry )
 {
     OUString aURL;
diff --git a/svtools/source/contnr/svtabbx.cxx b/svtools/source/contnr/svtabbx.cxx
index 66aa725..a6385ad 100644
--- a/svtools/source/contnr/svtabbx.cxx
+++ b/svtools/source/contnr/svtabbx.cxx
@@ -102,7 +102,7 @@ VCL_BUILDER_DECL_FACTORY(SvTabListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SvTabListBox(pParent, nWinStyle);
+    rRet = VclPtr<SvTabListBox>::Create(pParent, nWinStyle);
 }
 
 SvTabListBox::~SvTabListBox()
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 097aded..5d7ec97 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -440,7 +440,7 @@ VCL_BUILDER_DECL_FACTORY(SvTreeListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SvTreeListBox(pParent, nWinStyle);
+    rRet = VclPtr<SvTreeListBox>::Create(pParent, nWinStyle);
 }
 
 void SvTreeListBox::Clear()
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 2be6e63..96cfd80 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -110,10 +110,10 @@ VCL_BUILDER_DECL_FACTORY(ColorListBox)
     WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
     if (bDropdown)
         nWinBits |= WB_DROPDOWN;
-    ColorListBox *pListBox = new ColorListBox(pParent, nWinBits);
+    VclPtrInstance<ColorListBox> pListBox(pParent, nWinBits);
     if (bDropdown)
         pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 ColorListBox::~ColorListBox()
@@ -742,10 +742,10 @@ VCL_BUILDER_DECL_FACTORY(LineListBox)
     WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
     if (bDropdown)
         nWinBits |= WB_DROPDOWN;
-    LineListBox *pListBox = new LineListBox(pParent, nWinBits);
+    VclPtrInstance<LineListBox> pListBox(pParent, nWinBits);
     if (bDropdown)
         pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 LineListBox::~LineListBox()
@@ -945,10 +945,10 @@ VCL_BUILDER_DECL_FACTORY(FontNameBox)
     WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
     if (bDropdown)
         nWinBits |= WB_DROPDOWN;
-    FontNameBox *pListBox = new FontNameBox(pParent, nWinBits);
+    VclPtrInstance<FontNameBox> pListBox(pParent, nWinBits);
     if (bDropdown)
         pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 FontNameBox::~FontNameBox()
@@ -1333,10 +1333,10 @@ VCL_BUILDER_DECL_FACTORY(FontStyleBox)
     WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
     if (bDropdown)
         nWinBits |= WB_DROPDOWN;
-    FontStyleBox *pListBox = new FontStyleBox(pParent, nWinBits);
+    VclPtrInstance<FontStyleBox> pListBox(pParent, nWinBits);
     if (bDropdown)
         pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 void FontStyleBox::Select()
@@ -1529,10 +1529,10 @@ VCL_BUILDER_DECL_FACTORY(FontSizeBox)
     WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
     if (bDropdown)
         nWinBits |= WB_DROPDOWN;
-    FontSizeBox* pListBox = new FontSizeBox(pParent, nWinBits);
+    VclPtrInstance<FontSizeBox> pListBox(pParent, nWinBits);
     if (bDropdown)
         pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 void FontSizeBox::ImplInit()
diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx
index fe9a3ac..6f669b0 100644
--- a/svtools/source/control/inettbc.cxx
+++ b/svtools/source/control/inettbc.cxx
@@ -868,9 +868,9 @@ VCL_BUILDER_DECL_FACTORY(SvtURLBox)
     (void)rMap;
     WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP|
                        WB_DROPDOWN|WB_AUTOSIZE|WB_AUTOHSCROLL;
-    SvtURLBox* pListBox = new SvtURLBox(pParent, nWinBits, INetProtocol::NotValid, false);
+    VclPtrInstance<SvtURLBox> pListBox(pParent, nWinBits, INetProtocol::NotValid, false);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 
diff --git a/svtools/source/control/urlcontrol.cxx b/svtools/source/control/urlcontrol.cxx
index 8a268d7..0086412 100644
--- a/svtools/source/control/urlcontrol.cxx
+++ b/svtools/source/control/urlcontrol.cxx
@@ -36,9 +36,9 @@ namespace svt
         (void)rMap;
         WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP|
                            WB_DROPDOWN|WB_AUTOSIZE|WB_AUTOHSCROLL;
-        OFileURLControl* pListBox = new OFileURLControl(pParent, nWinBits);
+        VclPtrInstance<OFileURLControl> pListBox(pParent, nWinBits);
         pListBox->EnableAutoSize(true);
-        return pListBox;
+        rRet = pListBox;
     }
 
     bool OFileURLControl::PreNotify( NotifyEvent& _rNEvt )
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 85caf55..ff7351c 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -111,7 +111,7 @@ VCL_BUILDER_DECL_FACTORY(ValueSet)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new ValueSet(pParent, nWinBits);
+    rRet = VclPtr<ValueSet>::Create(pParent, nWinBits);
 }
 
 ValueSet::ValueSet( vcl::Window* pParent, const ResId& rResId, bool bDisableTransientChildren ) :
diff --git a/svx/source/dialog/checklbx.cxx b/svx/source/dialog/checklbx.cxx
index 66527a7..9d131ea 100644
--- a/svx/source/dialog/checklbx.cxx
+++ b/svx/source/dialog/checklbx.cxx
@@ -37,7 +37,7 @@ VCL_BUILDER_DECL_FACTORY(SvxCheckListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SvxCheckListBox(pParent, nWinStyle);
+    rRet = VclPtr<SvxCheckListBox>::Create(pParent, nWinStyle);
 }
 
 void SvxCheckListBox::SetNormalStaticImage(const Image& rNormalStaticImage)
diff --git a/svx/source/dialog/connctrl.cxx b/svx/source/dialog/connctrl.cxx
index a130f9f..7830c5f 100644
--- a/svx/source/dialog/connctrl.cxx
+++ b/svx/source/dialog/connctrl.cxx
@@ -52,7 +52,7 @@ VCL_BUILDER_DECL_FACTORY(SvxXConnectionPreview)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SvxXConnectionPreview(pParent, nWinStyle);
+    rRet = VclPtr<SvxXConnectionPreview>::Create(pParent, nWinStyle);
 }
 
 SvxXConnectionPreview::~SvxXConnectionPreview()
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index ad7c410..3b47422 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -1141,9 +1141,9 @@ VCL_BUILDER_DECL_FACTORY(ColorLB)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinBits |= WB_BORDER;
-    ColorLB *pListBox = new ColorLB(pParent, nWinBits);
+    VclPtrInstance<ColorLB> pListBox(pParent, nWinBits);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 // Fills the Listbox with color and strings
@@ -1193,9 +1193,9 @@ VCL_BUILDER_DECL_FACTORY(HatchingLB)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    HatchingLB *pListBox = new HatchingLB(pParent, nWinStyle);
+    VclPtrInstance<HatchingLB> pListBox(pParent, nWinStyle);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 void HatchingLB::Fill( const XHatchListRef &pList )
@@ -1286,9 +1286,9 @@ VCL_BUILDER_DECL_FACTORY(GradientLB)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    GradientLB *pListBox = new GradientLB(pParent, nWinStyle);
+    VclPtrInstance<GradientLB> pListBox(pParent, nWinStyle);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 void GradientLB::Fill( const XGradientListRef &pList )
@@ -1402,9 +1402,9 @@ VCL_BUILDER_DECL_FACTORY(BitmapLB)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    BitmapLB *pListBox = new BitmapLB(pParent, nWinStyle);
+    VclPtrInstance<BitmapLB> pListBox(pParent, nWinStyle);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 namespace
@@ -1575,9 +1575,9 @@ VCL_BUILDER_DECL_FACTORY(LineLB)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinBits |= WB_BORDER;
-    LineLB *pListBox = new LineLB(pParent, nWinBits);
+    VclPtrInstance<LineLB> pListBox(pParent, nWinBits);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 void LineLB::setAddStandardFields(bool bNew)
@@ -1673,9 +1673,9 @@ VCL_BUILDER_DECL_FACTORY(LineEndLB)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinBits |= WB_BORDER;
-    LineEndLB *pListBox = new LineEndLB(pParent, nWinBits);
+    VclPtrInstance<LineEndLB> pListBox(pParent, nWinBits);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 void LineEndLB::Fill( const XLineEndListRef &pList, bool bStart )
diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx
index a1bb1d4..91c8354 100644
--- a/svx/source/dialog/fntctrl.cxx
+++ b/svx/source/dialog/fntctrl.cxx
@@ -496,8 +496,7 @@ VCL_BUILDER_DECL_FACTORY(SvxFontPrevWindow)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    SvxFontPrevWindow *pWindow = new SvxFontPrevWindow(pParent, nWinStyle);
-    return pWindow;
+    rRet = VclPtr<SvxFontPrevWindow>::Create(pParent, nWinStyle);
 }
 
 SvxFontPrevWindow::~SvxFontPrevWindow()
diff --git a/svx/source/dialog/fontlb.cxx b/svx/source/dialog/fontlb.cxx
index 625bbd3..22720ac 100644
--- a/svx/source/dialog/fontlb.cxx
+++ b/svx/source/dialog/fontlb.cxx
@@ -95,7 +95,7 @@ VCL_BUILDER_DECL_FACTORY(SvxFontListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SvxFontListBox(pParent, nWinStyle);
+    rRet = VclPtr<SvxFontListBox>::Create(pParent, nWinStyle);
 }
 
 void SvxFontListBox::InsertFontEntry( const OUString& rString, const vcl::Font& rFont, const Color* pColor )
diff --git a/svx/source/dialog/frmdirlbox.cxx b/svx/source/dialog/frmdirlbox.cxx
index ef87c9f..3614cff 100644
--- a/svx/source/dialog/frmdirlbox.cxx
+++ b/svx/source/dialog/frmdirlbox.cxx
@@ -45,9 +45,9 @@ FrameDirectionListBox::FrameDirectionListBox( vcl::Window* pParent, WinBits nBit
 VCL_BUILDER_DECL_FACTORY(FrameDirectionListBox)
 {
     (void)rMap;
-    FrameDirectionListBox* pListBox = new FrameDirectionListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_TABSTOP);
+    VclPtrInstance<FrameDirectionListBox> pListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_TABSTOP);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 void FrameDirectionListBox::InsertEntryValue( const OUString& rString, SvxFrameDirection eDirection, sal_Int32 nPos )
diff --git a/svx/source/dialog/frmsel.cxx b/svx/source/dialog/frmsel.cxx
index 567bc36..2ea6265 100644
--- a/svx/source/dialog/frmsel.cxx
+++ b/svx/source/dialog/frmsel.cxx
@@ -799,7 +799,7 @@ FrameSelector::~FrameSelector()
 VCL_BUILDER_DECL_FACTORY(SvxFrameSelector)
 {
     (void)rMap;
-    return new FrameSelector(pParent);
+    rRet = VclPtr<FrameSelector>::Create(pParent);
 }
 
 void FrameSelector::Initialize( FrameSelFlags nFlags )
diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx
index f1b3a9e..1587a70 100644
--- a/svx/source/dialog/graphctl.cxx
+++ b/svx/source/dialog/graphctl.cxx
@@ -80,7 +80,7 @@ VCL_BUILDER_DECL_FACTORY(GraphCtrl)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new GraphCtrl(pParent, nWinStyle);
+    rRet = VclPtr<GraphCtrl>::Create(pParent, nWinStyle);
 }
 
 GraphCtrl::~GraphCtrl()
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index 9311c53..4a4dc6b 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -111,9 +111,9 @@ VCL_BUILDER_DECL_FACTORY(SvxLanguageBox)
         nBits |= WB_DROPDOWN;
     else
         nBits |= WB_BORDER;
-    SvxLanguageBox *pLanguageBox = new SvxLanguageBox(pParent, nBits);
+    VclPtrInstance<SvxLanguageBox> pLanguageBox(pParent, nBits);
     pLanguageBox->EnableAutoSize(true);
-    return pLanguageBox;
+    rRet = pLanguageBox;
 }
 
 VCL_BUILDER_DECL_FACTORY(SvxLanguageComboBox)
@@ -124,9 +124,9 @@ VCL_BUILDER_DECL_FACTORY(SvxLanguageComboBox)
         nBits |= WB_DROPDOWN;
     else
         nBits |= WB_BORDER;
-    SvxLanguageComboBox *pLanguageBox = new SvxLanguageComboBox(pParent, nBits);
+    VclPtrInstance<SvxLanguageComboBox> pLanguageBox(pParent, nBits);
     pLanguageBox->EnableAutoSize(true);
-    return pLanguageBox;
+    rRet = pLanguageBox;
 }
 
 SvxLanguageBoxBase::SvxLanguageBoxBase( bool bCheck )
diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx
index a9c3a9e..e272f4e 100644
--- a/svx/source/dialog/measctrl.cxx
+++ b/svx/source/dialog/measctrl.cxx
@@ -68,7 +68,7 @@ VCL_BUILDER_DECL_FACTORY(SvxXMeasurePreview)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SvxXMeasurePreview(pParent, nWinStyle);
+    rRet = VclPtr<SvxXMeasurePreview>::Create(pParent, nWinStyle);
 }
 
 Size SvxXMeasurePreview::GetOptimalSize() const
diff --git a/svx/source/dialog/relfld.cxx b/svx/source/dialog/relfld.cxx
index 6e177aa..96267d9 100644
--- a/svx/source/dialog/relfld.cxx
+++ b/svx/source/dialog/relfld.cxx
@@ -18,9 +18,7 @@
  */
 
 #include "svx/relfld.hxx"
-#include "vcl/builder.hxx"
-
-
+#include "vcl/builderfactory.hxx"
 
 SvxRelativeField::SvxRelativeField(
         vcl::Window *const pParent, WinBits const nBits, FieldUnit const eUnit)
@@ -39,17 +37,16 @@ SvxRelativeField::SvxRelativeField(
     SetMax( 9999 );
 }
 
-extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL
-makeSvxRelativeField(vcl::Window *const pParent, VclBuilder::stringmap & rMap)
+VCL_BUILDER_DECL_FACTORY(SvxRelativeField)
 {
     OString const custom(VclBuilder::extractCustomProperty(rMap));
     FieldUnit const eUnit(VclBuilder::detectUnit(custom));
-    SvxRelativeField *const pRet = new SvxRelativeField(pParent,
-            WB_BORDER | WB_SPIN | WB_REPEAT | WB_LEFT | WB_GROUP, eUnit);
-    return pRet;
+    rRet = VclPtr<SvxRelativeField>::Create(pParent,
+                                            WB_BORDER | WB_SPIN | WB_REPEAT |
+                                            WB_LEFT | WB_GROUP,
+                                            eUnit);
 }
 
-
 void SvxRelativeField::Modify()
 {
     MetricField::Modify();
diff --git a/svx/source/dialog/txencbox.cxx b/svx/source/dialog/txencbox.cxx
index c038a5d..6d6ff38 100644
--- a/svx/source/dialog/txencbox.cxx
+++ b/svx/source/dialog/txencbox.cxx
@@ -48,15 +48,12 @@ VCL_BUILDER_DECL_FACTORY(SvxTextEncodingBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinBits |= WB_BORDER;
-    SvxTextEncodingBox *pListBox = new SvxTextEncodingBox(pParent, nWinBits);
+    VclPtrInstance<SvxTextEncodingBox> pListBox(pParent, nWinBits);
     if (bDropdown)
         pListBox->EnableAutoSize(true);
-
-    return pListBox;
+    rRet = pListBox;
 }
 
-
-
 SvxTextEncodingBox::~SvxTextEncodingBox()
 {
     disposeOnce();
@@ -68,8 +65,6 @@ void SvxTextEncodingBox::dispose()
     ListBox::dispose();
 }
 
-
-
 sal_Int32 SvxTextEncodingBox::EncodingToPos_Impl( rtl_TextEncoding nEnc ) const
 {
     sal_Int32 nCount = GetEntryCount();
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
index ba1d4b9..1302046 100644
--- a/svx/source/gallery2/galctrl.cxx
+++ b/svx/source/gallery2/galctrl.cxx
@@ -54,7 +54,7 @@ VCL_BUILDER_DECL_FACTORY(GalleryPreview)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinBits |= WB_BORDER;
-    return new GalleryPreview(pParent, nWinBits);
+    rRet = VclPtr<GalleryPreview>::Create(pParent, nWinBits);
 }
 
 Size GalleryPreview::GetOptimalSize() const
diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx
index ef448a4..6d9c108 100644
--- a/svx/source/tbxctrls/SvxColorValueSet.cxx
+++ b/svx/source/tbxctrls/SvxColorValueSet.cxx
@@ -37,7 +37,7 @@ VCL_BUILDER_DECL_FACTORY(SvxColorValueSet)
     if (!sBorder.isEmpty())
        nWinBits |= WB_BORDER;
 
-    return new SvxColorValueSet(pParent, nWinBits);
+    rRet = VclPtr<SvxColorValueSet>::Create(pParent, nWinBits);
 }
 
 sal_uInt32 SvxColorValueSet::getMaxRowCount()
diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx
index 4247606..9f24424 100644
--- a/sw/source/ui/config/optload.cxx
+++ b/sw/source/ui/config/optload.cxx
@@ -394,7 +394,7 @@ VCL_BUILDER_DECL_FACTORY(SwCaptionPreview)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
        nBits |= WB_BORDER;
-    return new SwCaptionPreview(pParent, nBits);
+    rRet = VclPtr<SwCaptionPreview>::Create(pParent, nBits);
 }
 
 void SwCaptionPreview::Init()
@@ -940,9 +940,9 @@ VCL_BUILDER_DECL_FACTORY(CaptionComboBox)
     bool bDropdown = VclBuilder::extractDropdown(rMap);
     if (bDropdown)
         nBits |= WB_DROPDOWN;
-    CaptionComboBox* pComboBox = new CaptionComboBox(pParent, nBits);
+    VclPtrInstance<CaptionComboBox> pComboBox(pParent, nBits);
     pComboBox->EnableAutoSize(true);
-    return pComboBox;
+    rRet = pComboBox;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
index a9c1226..7e9046d 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -111,7 +111,7 @@ SwAddressControl_Impl::SwAddressControl_Impl(vcl::Window* pParent, WinBits nBits
 VCL_BUILDER_DECL_FACTORY(SwAddressControlImpl)
 {
     (void)rMap;
-    return new SwAddressControl_Impl(pParent, WB_BORDER | WB_DIALOGCONTROL);
+    rRet = VclPtr<SwAddressControl_Impl>::Create(pParent, WB_BORDER | WB_DIALOGCONTROL);
 }
 
 SwAddressControl_Impl::~SwAddressControl_Impl()
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index 2c25df2..df9817f 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -1292,7 +1292,7 @@ VCL_BUILDER_DECL_FACTORY(DDListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new DDListBox(pParent, nWinStyle);
+    rRet = VclPtr<DDListBox>::Create(pParent, nWinStyle);
 }
 
 void DDListBox::SetAddressDialog(SwCustomizeAddressBlockDialog *pParent)
@@ -1354,7 +1354,7 @@ VCL_BUILDER_DECL_FACTORY(AddressMultiLineEdit)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new AddressMultiLineEdit(pParent, nWinStyle);
+    rRet = VclPtr<AddressMultiLineEdit>::Create(pParent, nWinStyle);
 }
 
 void AddressMultiLineEdit::SetAddressDialog(SwCustomizeAddressBlockDialog *pParent)
diff --git a/sw/source/ui/fldui/FldRefTreeListBox.cxx b/sw/source/ui/fldui/FldRefTreeListBox.cxx
index c84b5c4..03ed69a 100644
--- a/sw/source/ui/fldui/FldRefTreeListBox.cxx
+++ b/sw/source/ui/fldui/FldRefTreeListBox.cxx
@@ -34,7 +34,7 @@ VCL_BUILDER_DECL_FACTORY(SwFldRefTreeListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SwFldRefTreeListBox(pParent, nWinStyle);
+    rRet = VclPtr<SwFldRefTreeListBox>::Create(pParent, nWinStyle);
 }
 
 void SwFldRefTreeListBox::RequestHelp( const HelpEvent& rHEvt )
diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx
index 8da46a4..615ff1e 100644
--- a/sw/source/ui/fldui/fldvar.cxx
+++ b/sw/source/ui/fldui/fldvar.cxx
@@ -1276,10 +1276,9 @@ VCL_BUILDER_DECL_FACTORY(SelectionListBox)
     if (!sBorder.isEmpty())
        nBits |= WB_BORDER;
 
-    SelectionListBox* pListBox = new SelectionListBox(pParent, nBits|WB_SIMPLEMODE);
+    VclPtrInstance<SelectionListBox> pListBox(pParent, nBits|WB_SIMPLEMODE);
     pListBox->EnableAutoSize(true);
-
-    return pListBox;
+    rRet = pListBox;
 }
 
 bool SelectionListBox::PreNotify( NotifyEvent& rNEvt )
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 2bac0f5..0204ed3 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -1765,7 +1765,7 @@ VCL_BUILDER_DECL_FACTORY(SwIdxTreeListBox)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SwIdxTreeListBox(pParent, nWinStyle);
+    rRet = VclPtr<SwIdxTreeListBox>::Create(pParent, nWinStyle);
 }
 
 void SwIdxTreeListBox::RequestHelp( const HelpEvent& rHEvt )
diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx
index 3332023..96a61e4 100644
--- a/sw/source/ui/table/tautofmt.cxx
+++ b/sw/source/ui/table/tautofmt.cxx
@@ -539,7 +539,7 @@ VCL_BUILDER_DECL_FACTORY(AutoFmtPreview)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new AutoFmtPreview(pParent, nWinStyle);
+    rRet = VclPtr<AutoFmtPreview>::Create(pParent, nWinStyle);
 }
 
 void AutoFmtPreview::Resize()
diff --git a/sw/source/uibase/cctrl/actctrl.cxx b/sw/source/uibase/cctrl/actctrl.cxx
index 119dbb3..a0f1bd7 100644
--- a/sw/source/uibase/cctrl/actctrl.cxx
+++ b/sw/source/uibase/cctrl/actctrl.cxx
@@ -65,7 +65,7 @@ void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
 VCL_BUILDER_DECL_FACTORY(ReturnActionEdit)
 {
     VclBuilder::ensureDefaultWidthChars(rMap);
-    return new ReturnActionEdit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
+    rRet = VclPtr<ReturnActionEdit>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/dbui/dbtree.cxx b/sw/source/uibase/dbui/dbtree.cxx
index 0e9fa0d..72e0e1d 100644
--- a/sw/source/uibase/dbui/dbtree.cxx
+++ b/sw/source/uibase/dbui/dbtree.cxx
@@ -186,7 +186,7 @@ VCL_BUILDER_DECL_FACTORY(SwDBTreeList)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nStyle |= WB_BORDER;
-    return new SwDBTreeList(pParent, nStyle);
+    rRet = VclPtr<SwDBTreeList>::Create(pParent, nStyle);
 }
 
 Size SwDBTreeList::GetOptimalSize() const
diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx
index d827f70..80082ed 100644
--- a/sw/source/uibase/dbui/mailmergehelper.cxx
+++ b/sw/source/uibase/dbui/mailmergehelper.cxx
@@ -213,7 +213,7 @@ VCL_BUILDER_DECL_FACTORY(SwAddressPreview)
     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     if (!sBorder.isEmpty())
         nWinStyle |= WB_BORDER;
-    return new SwAddressPreview(pParent, nWinStyle);
+    rRet = VclPtr<SwAddressPreview>::Create(pParent, nWinStyle);
 }
 
 void SwAddressPreview::positionScrollBar()
diff --git a/sw/source/uibase/misc/numberingtypelistbox.cxx b/sw/source/uibase/misc/numberingtypelistbox.cxx
index 30b6b05..5284760 100644
--- a/sw/source/uibase/misc/numberingtypelistbox.cxx
+++ b/sw/source/uibase/misc/numberingtypelistbox.cxx
@@ -58,9 +58,9 @@ bool SwNumberingTypeListBox::set_property(const OString &rKey, const OString &rV
 VCL_BUILDER_DECL_FACTORY(SwNumberingTypeListBox)
 {
     (void)rMap;
-    SwNumberingTypeListBox *pListBox = new SwNumberingTypeListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_TABSTOP);
+    VclPtrInstance<SwNumberingTypeListBox> pListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_TABSTOP);
     pListBox->EnableAutoSize(true);
-    return pListBox;
+    rRet = pListBox;
 }
 
 SwNumberingTypeListBox::~SwNumberingTypeListBox()
diff --git a/sw/source/uibase/utlui/condedit.cxx b/sw/source/uibase/utlui/condedit.cxx
index 907ac1f..fd11e8a 100644
--- a/sw/source/uibase/utlui/condedit.cxx
+++ b/sw/source/uibase/utlui/condedit.cxx
@@ -37,7 +37,7 @@ ConditionEdit::ConditionEdit(vcl::Window* pParent, WinBits nStyle)
 VCL_BUILDER_DECL_FACTORY(ConditionEdit)
 {
     VclBuilder::ensureDefaultWidthChars(rMap);
-    return new ConditionEdit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
+    rRet = VclPtr<ConditionEdit>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
 }
 
 // Drop possible, respectively format known?
diff --git a/sw/source/uibase/utlui/numfmtlb.cxx b/sw/source/uibase/utlui/numfmtlb.cxx
index 32bab7f..953032b 100644
--- a/sw/source/uibase/utlui/numfmtlb.cxx
+++ b/sw/source/uibase/utlui/numfmtlb.cxx
@@ -80,12 +80,12 @@ VCL_BUILDER_DECL_FACTORY(NumFormatListBox)
     else
         nBits |= WB_BORDER;
 
-    NumFormatListBox* pListBox = new NumFormatListBox(pParent, nBits|WB_SIMPLEMODE);
+    VclPtrInstance<NumFormatListBox> pListBox(pParent, nBits|WB_SIMPLEMODE);
 
     if (bDropdown)
         pListBox->EnableAutoSize(true);
 
-    return pListBox;
+    rRet = pListBox;
 }
 
 void NumFormatListBox::Init(short nFormatType, bool bUsrFmts)
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index d687b60..6453386 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1757,7 +1757,10 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
             customMakeWidget pFunction = reinterpret_cast<customMakeWidget>(osl_getFunctionSymbol((oslModule) RTLD_DEFAULT, sFunction.pData));
 #endif
             if (pFunction)
-                xWindow = VclPtr<vcl::Window>(pFunction(pParent, rMap), SAL_NO_ACQUIRE);
+            {
+                VclPtr<vcl::Window> xParent(pParent);
+                pFunction(xWindow, xParent, rMap);
+            }
         }
     }
     SAL_WARN_IF(!xWindow, "vcl.layout", "probably need to implement " << name.getStr() << " or add a make" << name.getStr() << " function");
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index ecc8d7a..16b76c4 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -55,13 +55,13 @@ using namespace com::sun::star::beans;
 VCL_BUILDER_DECL_FACTORY(PrintPreviewWindow)
 {
     (void)rMap;
-    return new PrintDialog::PrintPreviewWindow(pParent);
+    rRet = VclPtr<PrintDialog::PrintPreviewWindow>::Create(pParent);
 }
 
 VCL_BUILDER_DECL_FACTORY(ShowNupOrderWindow)
 {
     (void)rMap;
-    return new PrintDialog::ShowNupOrderWindow(pParent);
+    rRet = VclPtr<PrintDialog::ShowNupOrderWindow>::Create(pParent);
 }
 
 PrintDialog::PrintPreviewWindow::PrintPreviewWindow( vcl::Window* i_pParent )


More information about the Libreoffice-commits mailing list