[Libreoffice-commits] core.git: sw/source

Takeshi Abe tabe at fixedpoint.jp
Mon Jan 20 17:23:41 PST 2014


 sw/source/ui/app/appenv.cxx              |    7 ++++---
 sw/source/ui/app/applab.cxx              |    5 +++--
 sw/source/ui/app/docsh2.cxx              |    5 +++--
 sw/source/ui/app/docst.cxx               |   14 +++++---------
 sw/source/ui/dbui/addresslistdialog.cxx  |   14 ++++++--------
 sw/source/ui/dbui/dbinsdlg.cxx           |    6 ++----
 sw/source/ui/dbui/dbmgr.cxx              |    6 ++----
 sw/source/ui/dbui/mmaddressblockpage.cxx |   10 ++++------
 sw/source/ui/dbui/mmgreetingspage.cxx    |   12 ++++++------
 sw/source/ui/dochdl/swdtflvr.cxx         |    5 +++--
 sw/source/ui/envelp/envfmt.cxx           |    8 ++++----
 sw/source/ui/misc/glossary.cxx           |    8 ++++----
 sw/source/ui/misc/insfnote.cxx           |    7 ++++---
 sw/source/ui/misc/outline.cxx            |    5 +++--
 sw/source/ui/uiview/pview.cxx            |    6 +++---
 sw/source/ui/uiview/view2.cxx            |   23 +++++++++--------------
 sw/source/ui/uiview/viewdlg2.cxx         |   10 +++++-----
 sw/source/ui/uiview/viewling.cxx         |    6 ++----
 18 files changed, 72 insertions(+), 85 deletions(-)

New commits:
commit 276cae1e467af0219ea1a45bac331937d7b9dc63
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Tue Jan 21 10:18:02 2014 +0900

    Use boost::scoped_ptr to avoid resource leaks in case of exception
    
    Change-Id: I05a17a061bfd4c3dbd15fe80c1f1f4f8d8267ea7

diff --git a/sw/source/ui/app/appenv.cxx b/sw/source/ui/app/appenv.cxx
index 5e272f2..ecd7e2a 100644
--- a/sw/source/ui/app/appenv.cxx
+++ b/sw/source/ui/app/appenv.cxx
@@ -69,6 +69,8 @@
 #include "envelp.hrc"
 #include "envimg.hxx"
 
+#include <boost/scoped_ptr.hpp>
+
 #define ENV_NEWDOC      RET_OK
 #define ENV_INSERT      RET_USER
 
@@ -202,7 +204,7 @@ void SwModule::InsertEnv( SfxRequest& rReq )
     }
 
     Window *pParent = pOldSh ? pOldSh->GetWin() : 0;
-    SfxAbstractTabDialog * pDlg=NULL;
+    boost::scoped_ptr<SfxAbstractTabDialog> pDlg;
     short nMode = ENV_INSERT;
 
     SFX_REQUEST_ARG( rReq, pItem, SwEnvItem, FN_ENVELOP, sal_False );
@@ -211,7 +213,7 @@ void SwModule::InsertEnv( SfxRequest& rReq )
         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
         OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
 
-        pDlg = pFact->CreateSwEnvDlg( pParent, aSet, pOldSh, pTempPrinter, !bEnvChange );
+        pDlg.reset(pFact->CreateSwEnvDlg( pParent, aSet, pOldSh, pTempPrinter, !bEnvChange ));
         OSL_ENSURE(pDlg, "Dialogdiet fail!");
         nMode = pDlg->Execute();
     }
@@ -502,7 +504,6 @@ void SwModule::InsertEnv( SfxRequest& rReq )
         if (pOldSh)
             SetView(&pOldSh->GetView());
     }
-    delete pDlg;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/app/applab.cxx b/sw/source/ui/app/applab.cxx
index e264225..735a908 100644
--- a/sw/source/ui/app/applab.cxx
+++ b/sw/source/ui/app/applab.cxx
@@ -73,6 +73,8 @@
 
 #include <IDocumentDeviceAccess.hxx>
 
+#include <boost/scoped_ptr.hpp>
+
 using namespace ::com::sun::star;
 
 // is in appenv.cxx
@@ -169,7 +171,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
     SwAbstractDialogFactory* pDialogFactory = SwAbstractDialogFactory::Create();
     OSL_ENSURE(pDialogFactory, "SwAbstractDialogFactory fail!");
 
-    AbstractSwLabDlg* pDlg = pDialogFactory->CreateSwLabDlg(0, aSet, pNewDBMgr, bLabel);
+    boost::scoped_ptr<AbstractSwLabDlg> pDlg(pDialogFactory->CreateSwLabDlg(0, aSet, pNewDBMgr, bLabel));
     OSL_ENSURE(pDlg, "Dialogdiet fail!");
 
     if ( RET_OK == pDlg->Execute() )
@@ -398,7 +400,6 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
         }
         rReq.SetReturnValue(SfxVoidItem(bLabel ? FN_LABEL : FN_BUSINESS_CARD));
     }
-    delete pDlg;
     delete pNewDBMgr;
 }
 
diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx
index 8b83dda..8074f86 100644
--- a/sw/source/ui/app/docsh2.cxx
+++ b/sw/source/ui/app/docsh2.cxx
@@ -113,6 +113,8 @@
 
 #include <ndtxt.hxx>
 
+#include <boost/scoped_ptr.hpp>
+
 using namespace ::com::sun::star::ui::dialogs;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::uno;
@@ -682,7 +684,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
 
-            AbstractSwInsertAbstractDlg* pDlg = pFact->CreateSwInsertAbstractDlg(0);
+            boost::scoped_ptr<AbstractSwInsertAbstractDlg> pDlg(pFact->CreateSwInsertAbstractDlg(0));
             OSL_ENSURE(pDlg, "Dialogdiet fail!");
             if(RET_OK == pDlg->Execute())
             {
@@ -749,7 +751,6 @@ void SwDocShell::Execute(SfxRequest& rReq)
                 }
 
             }
-            delete pDlg;
         }
         break;
         case FN_OUTLINE_TO_CLIPBOARD:
diff --git a/sw/source/ui/app/docst.cxx b/sw/source/ui/app/docst.cxx
index 8074d43..13041db 100644
--- a/sw/source/ui/app/docst.cxx
+++ b/sw/source/ui/app/docst.cxx
@@ -339,15 +339,13 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
                 {
                     case SID_STYLE_NEW_BY_EXAMPLE:
                     {
-                        SfxNewStyleDlg *pDlg = new SfxNewStyleDlg( 0,
-                                                    *GetStyleSheetPool());
+                        boost::scoped_ptr<SfxNewStyleDlg> pDlg(new SfxNewStyleDlg( 0,
+                                                    *GetStyleSheetPool()));
                         if(RET_OK == pDlg->Execute())
                         {
                             aParam = pDlg->GetName();
                             rReq.AppendItem(SfxStringItem(nSlot, aParam));
                         }
-
-                        delete pDlg;
                     }
                     break;
 
@@ -739,11 +737,11 @@ sal_uInt16 SwDocShell::Edit(
         SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
         assert( pFact );
-        SfxAbstractApplyTabDialog* pDlg = pFact->CreateTemplateDialog(
+        boost::scoped_ptr<SfxAbstractApplyTabDialog> pDlg(pFact->CreateTemplateDialog(
                                                     0, *(xTmp.get()), nFamily, sPage,
-                                                    pActShell ? pActShell : pWrtShell, bNew);
+                                                    pActShell ? pActShell : pWrtShell, bNew));
         assert( pDlg );
-        ApplyStyle aApplyStyleHelper(*this, bNew, pStyle, nRet, xTmp, nFamily, pDlg, mxBasePool, bModified);
+        ApplyStyle aApplyStyleHelper(*this, bNew, pStyle, nRet, xTmp, nFamily, pDlg.get(), mxBasePool, bModified);
         pDlg->SetApplyHdl(LINK(&aApplyStyleHelper, ApplyStyle, ApplyHdl));
 
         if (RET_OK == pDlg->Execute())
@@ -763,8 +761,6 @@ sal_uInt16 SwDocShell::Edit(
         }
 
         nRet = aApplyStyleHelper.getRet();
-
-        delete pDlg;
     }
     else
     {
diff --git a/sw/source/ui/dbui/addresslistdialog.cxx b/sw/source/ui/dbui/addresslistdialog.cxx
index 0cb6363..09e2654 100644
--- a/sw/source/ui/dbui/addresslistdialog.cxx
+++ b/sw/source/ui/dbui/addresslistdialog.cxx
@@ -59,6 +59,7 @@
 #include <helpid.h>
 #include <unomid.h>
 
+#include <boost/scoped_ptr.hpp>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -351,11 +352,11 @@ IMPL_LINK_NOARG(SwAddressListDialog, LoadHdl_Impl)
 IMPL_LINK(SwAddressListDialog, CreateHdl_Impl, PushButton*, pButton)
 {
     OUString sInputURL;
-    SwCreateAddressListDialog* pDlg =
+    boost::scoped_ptr<SwCreateAddressListDialog> pDlg(
             new SwCreateAddressListDialog(
                     pButton,
                     sInputURL,
-                    m_pAddressPage->GetWizard()->GetConfigItem());
+                    m_pAddressPage->GetWizard()->GetConfigItem()));
     if(RET_OK == pDlg->Execute())
     {
         //register the URL a new datasource
@@ -434,7 +435,6 @@ IMPL_LINK(SwAddressListDialog, CreateHdl_Impl, PushButton*, pButton)
         {
         }
     }
-    delete pDlg;
     return 0;
 }
 
@@ -457,15 +457,14 @@ IMPL_LINK(SwAddressListDialog, EditHdl_Impl, PushButton*, pButton)
         pUserData->xColumnsSupplier.clear();
         pUserData->xConnection.clear();
             // will automatically close if it was the las reference
-        SwCreateAddressListDialog* pDlg =
+        boost::scoped_ptr<SwCreateAddressListDialog> pDlg(
                 new SwCreateAddressListDialog(
                         pButton,
                         pUserData->sURL,
-                        m_pAddressPage->GetWizard()->GetConfigItem());
+                        m_pAddressPage->GetWizard()->GetConfigItem()));
         if(RET_OK == pDlg->Execute())
         {
         }
-        delete pDlg;
     }
     return 0;
 };
@@ -578,7 +577,7 @@ void SwAddressListDialog::DetectTablesAndQueries(
             if(nTables > 1 && bWidthDialog)
             {
                 //now call the table select dialog - if more than one table exists
-                SwSelectDBTableDialog* pDlg = new SwSelectDBTableDialog(this, pUserData->xConnection);
+                boost::scoped_ptr<SwSelectDBTableDialog> pDlg(new SwSelectDBTableDialog(this, pUserData->xConnection));
                 OUString sTable = m_pListLB->GetEntryText(pSelect, ITEMID_TABLE - 1);
                 if(!sTable.isEmpty())
                     pDlg->SetSelectedTable(sTable, pUserData->nCommandType == CommandType::TABLE);
@@ -589,7 +588,6 @@ void SwAddressListDialog::DetectTablesAndQueries(
                     m_aDBData.nCommandType = bIsTable ? CommandType::TABLE : CommandType::QUERY;
                     pUserData->nCommandType = m_aDBData.nCommandType;
                 }
-                delete pDlg;
             }
             else if(nTables == 1)
             {
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index 7c4901d..a05ddd5 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -738,7 +738,7 @@ IMPL_LINK( SwInsertDBColAutoPilot, TblFmtHdl, PushButton*, pButton )
     SwAbstractDialogFactory* pFact = swui::GetFactory();
     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
 
-    SfxAbstractTabDialog* pDlg = pFact->CreateSwTableTabDlg(pButton, rSh.GetAttrPool(), pTblSet, &rSh);
+    boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTableTabDlg(pButton, rSh.GetAttrPool(), pTblSet, &rSh));
     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     if( RET_OK == pDlg->Execute() )
         pTblSet->Put( *pDlg->GetOutputItemSet() );
@@ -747,7 +747,6 @@ IMPL_LINK( SwInsertDBColAutoPilot, TblFmtHdl, PushButton*, pButton )
         delete pTblSet, pTblSet = 0;
         delete pRep, pRep = 0;
     }
-    delete pDlg;
 
     return 0;
 }
@@ -757,11 +756,10 @@ IMPL_LINK( SwInsertDBColAutoPilot, AutoFmtHdl, PushButton*, pButton )
     SwAbstractDialogFactory* pFact = swui::GetFactory();
     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
 
-    AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(pButton, pView->GetWrtShellPtr(), sal_False, pTAutoFmt);
+    boost::scoped_ptr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(pButton, pView->GetWrtShellPtr(), sal_False, pTAutoFmt));
     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     if( RET_OK == pDlg->Execute())
         pDlg->FillAutoFmtOfIndex( pTAutoFmt );
-    delete pDlg;
     return 0;
 }
 
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index 3d4c9ed..f1c4b2e 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -2581,10 +2581,10 @@ void SwNewDBMgr::InsertText(SwWrtShell& rSh,
     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
 
-    AbstractSwInsertDBColAutoPilot* pDlg = pFact->CreateSwInsertDBColAutoPilot( rSh.GetView(),
+    boost::scoped_ptr<AbstractSwInsertDBColAutoPilot> pDlg(pFact->CreateSwInsertDBColAutoPilot( rSh.GetView(),
                                                                                 xSource,
                                                                                 xColSupp,
-                                                                                aDBData );
+                                                                                aDBData ));
     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     if( RET_OK == pDlg->Execute() )
     {
@@ -2600,8 +2600,6 @@ void SwNewDBMgr::InsertText(SwWrtShell& rSh,
             OSL_FAIL("exception caught");
         }
     }
-    delete pDlg;
-
 }
 
 SwDbtoolsClient* SwNewDBMgr::pDbtoolsClient = NULL;
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index 57f255e..8705a7e 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -214,8 +214,8 @@ IMPL_LINK(SwMailMergeAddressBlockPage, AssignHdl_Impl, PushButton*, pButton)
     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
     sal_uInt16 nSel = m_aSettingsWIN.GetSelectedAddress();
     const uno::Sequence< OUString> aBlocks = rConfigItem.GetAddressBlocks();
-    SwAssignFieldsDialog* pDlg =
-            new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), aBlocks[nSel], true);
+    boost::scoped_ptr<SwAssignFieldsDialog> pDlg(
+            new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), aBlocks[nSel], true));
     if(RET_OK == pDlg->Execute())
     {
         //preview update
@@ -223,7 +223,6 @@ IMPL_LINK(SwMailMergeAddressBlockPage, AssignHdl_Impl, PushButton*, pButton)
         GetWizard()->UpdateRoadmap();
         GetWizard()->enableButtons(WZB_NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
     }
-    delete pDlg;
     return 0;
 }
 
@@ -443,8 +442,8 @@ IMPL_LINK(SwSelectAddressBlockDialog, NewCustomizeHdl_Impl, PushButton*, pButton
     SwCustomizeAddressBlockDialog::DialogType nType = bCustomize ?
         SwCustomizeAddressBlockDialog::ADDRESSBLOCK_EDIT :
         SwCustomizeAddressBlockDialog::ADDRESSBLOCK_NEW;
-    SwCustomizeAddressBlockDialog *pDlg =
-        new SwCustomizeAddressBlockDialog(pButton,m_rConfig,nType);
+    boost::scoped_ptr<SwCustomizeAddressBlockDialog> pDlg(
+        new SwCustomizeAddressBlockDialog(pButton,m_rConfig,nType));
     if(bCustomize)
     {
         pDlg->SetAddress(m_aAddressBlocks[m_pPreview->GetSelectedAddress()]);
@@ -468,7 +467,6 @@ IMPL_LINK(SwSelectAddressBlockDialog, NewCustomizeHdl_Impl, PushButton*, pButton
         }
         m_pDeletePB->Enable( m_aAddressBlocks.getLength() > 1);
     }
-    delete pDlg;
     return 0;
 }
 
diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx b/sw/source/ui/dbui/mmgreetingspage.cxx
index d6eb05c..5b27528 100644
--- a/sw/source/ui/dbui/mmgreetingspage.cxx
+++ b/sw/source/ui/dbui/mmgreetingspage.cxx
@@ -30,6 +30,8 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <helpid.h>
 
+#include <boost/scoped_ptr.hpp>
+
 using namespace svt;
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -105,11 +107,11 @@ IMPL_LINK_NOARG(SwGreetingsHandler, IndividualHdl_Impl)
 
 IMPL_LINK(SwGreetingsHandler, GreetingHdl_Impl, PushButton*, pButton)
 {
-    SwCustomizeAddressBlockDialog* pDlg =
+    boost::scoped_ptr<SwCustomizeAddressBlockDialog> pDlg(
             new SwCustomizeAddressBlockDialog(pButton, m_pWizard->GetConfigItem(),
                         pButton == m_pMalePB ?
                         SwCustomizeAddressBlockDialog::GREETING_MALE :
-                        SwCustomizeAddressBlockDialog::GREETING_FEMALE );
+                        SwCustomizeAddressBlockDialog::GREETING_FEMALE ));
     if(RET_OK == pDlg->Execute())
     {
         ListBox* pToInsert = pButton == m_pMalePB ? m_pMaleLB : m_pFemaleLB;
@@ -121,7 +123,6 @@ IMPL_LINK(SwGreetingsHandler, GreetingHdl_Impl, PushButton*, pButton)
         }
         UpdatePreview();
     }
-    delete pDlg;
     return 0;
 }
 
@@ -135,15 +136,14 @@ IMPL_LINK(SwMailMergeGreetingsPage, AssignHdl_Impl, PushButton*, pButton)
     OUString sPreview = m_aFemaleLB.GetSelectEntry();
     sPreview += "\n";
     sPreview += m_aMaleLB.GetSelectEntry();
-    SwAssignFieldsDialog* pDlg =
-            new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), sPreview, false);
+    boost::scoped_ptr<SwAssignFieldsDialog> pDlg(
+            new SwAssignFieldsDialog(pButton, m_pWizard->GetConfigItem(), sPreview, false));
     if(RET_OK == pDlg->Execute())
     {
         UpdatePreview();
         m_pWizard->UpdateRoadmap();
         m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
     }
-    delete pDlg;
     return 0;
 }
 
diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx
index 00be9a0..824cfbc 100644
--- a/sw/source/ui/dochdl/swdtflvr.cxx
+++ b/sw/source/ui/dochdl/swdtflvr.cxx
@@ -119,6 +119,8 @@
 #include <vcl/GraphicNativeTransform.hxx>
 #include <vcl/GraphicNativeMetadata.hxx>
 
+#include <boost/scoped_ptr.hpp>
+
 extern bool bFrmDrag;
 extern bool bDDINetAttr;
 extern bool bExecuteDrag;
@@ -2821,7 +2823,7 @@ bool SwTransferable::PasteSpecial( SwWrtShell& rSh, TransferableDataHelper& rDat
 {
     bool nRet = false;
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( &rSh.GetView().GetEditWin() );
+    boost::scoped_ptr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( &rSh.GetView().GetEditWin() ));
 
     DataFlavorExVector aFormats( rData.GetDataFlavorExVector() );
     TransferableObjectDescriptor aDesc;
@@ -2884,7 +2886,6 @@ bool SwTransferable::PasteSpecial( SwWrtShell& rSh, TransferableDataHelper& rDat
     if ( nRet )
         rFormatUsed = nFormat;
 
-    delete pDlg;
     return nRet;
 }
 
diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
index e657234..d90d953 100644
--- a/sw/source/ui/envelp/envfmt.cxx
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -44,6 +44,8 @@
 #include <vector>
 #include <algorithm>
 
+#include <boost/scoped_ptr.hpp>
+
 #include "swabstdlg.hxx"
 #include "chrdlg.hrc"
 
@@ -263,7 +265,7 @@ IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton )
         OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
 
         const OUString sFmtStr = pColl->GetName();
-        SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, DLG_CHAR_ENV, &sFmtStr);
+        boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, DLG_CHAR_ENV, &sFmtStr));
         OSL_ENSURE(pDlg, "Dialogdiet fail!");
         if (pDlg->Execute() == RET_OK)
         {
@@ -271,7 +273,6 @@ IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton )
             ::ConvertAttrGenToChar(aOutputSet, CONV_ATTR_ENV);
             pCollSet->Put(aOutputSet);
         }
-        delete pDlg;
     }
     else if (sIdent == "paragraph")
     {
@@ -302,7 +303,7 @@ IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton )
         ::PrepareBoxInfo( aTmpSet, *pSh );
 
         const OUString sFmtStr = pColl->GetName();
-        SwParaDlg *pDlg = new SwParaDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &sFmtStr);
+        boost::scoped_ptr<SwParaDlg> pDlg(new SwParaDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &sFmtStr));
 
         if ( pDlg->Execute() == RET_OK )
         {
@@ -325,7 +326,6 @@ IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton )
                 pCollSet->Put(*pOutputSet);
             }
         }
-        delete pDlg;
     }
     return 0;
 }
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index ca671fc..22d7f70 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -67,6 +67,8 @@
 #include <swmodule.hxx>
 #include <sfx2/filedlghelper.hxx>
 
+#include <boost/scoped_ptr.hpp>
+
 #include "access.hrc"
 
 using namespace ::com::sun::star;
@@ -620,7 +622,7 @@ IMPL_LINK_NOARG(SwGlossaryDlg, BibHdl)
         if(bIsWritable)
         {
 
-            SwGlossaryGroupDlg *pDlg = new SwGlossaryGroupDlg( this, pGloss->GetPathArray(), pGlossaryHdl );
+            boost::scoped_ptr<SwGlossaryGroupDlg> pDlg(new SwGlossaryGroupDlg( this, pGloss->GetPathArray(), pGlossaryHdl ));
             if ( RET_OK == pDlg->Execute() )
             {
                 Init();
@@ -647,7 +649,6 @@ IMPL_LINK_NOARG(SwGlossaryDlg, BibHdl)
                 }
 
             }
-            delete pDlg;
         }
         else
         {
@@ -1022,7 +1023,7 @@ IMPL_LINK( SwGlossaryDlg, PathHdl, Button *, pBtn )
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     if(pFact)
     {
-        AbstractSvxMultiPathDialog* pDlg = pFact->CreateSvxMultiPathDialog( pBtn );
+        boost::scoped_ptr<AbstractSvxMultiPathDialog> pDlg(pFact->CreateSvxMultiPathDialog( pBtn ));
         OSL_ENSURE(pDlg, "Dialogdiet fail!");
         SvtPathOptions aPathOpt;
         const OUString sGlosPath( aPathOpt.GetAutoTextPath() );
@@ -1037,7 +1038,6 @@ IMPL_LINK( SwGlossaryDlg, PathHdl, Button *, pBtn )
                 Init();
             }
         }
-        delete pDlg;
     }
     return 0;
 }
diff --git a/sw/source/ui/misc/insfnote.cxx b/sw/source/ui/misc/insfnote.cxx
index 52c5c18..765c4af 100644
--- a/sw/source/ui/misc/insfnote.cxx
+++ b/sw/source/ui/misc/insfnote.cxx
@@ -38,6 +38,8 @@
 #include <sfx2/viewfrm.hxx>
 #include <vcl/layout.hxx>
 
+#include <boost/scoped_ptr.hpp>
+
 static sal_Bool bFootnote = sal_True;
 
 /*------------------------------------------------------------------------
@@ -121,8 +123,8 @@ IMPL_LINK_NOARG(SwInsFootNoteDlg, NumberExtCharHdl)
     aAllSet.Put( rFont );
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( this, aAllSet,
-        rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
+    boost::scoped_ptr<SfxAbstractDialog> pDlg(pFact->CreateSfxDialog( this, aAllSet,
+        rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ));
     if (RET_OK == pDlg->Execute())
     {
         SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, sal_False );
@@ -145,7 +147,6 @@ IMPL_LINK_NOARG(SwInsFootNoteDlg, NumberExtCharHdl)
             m_pOkBtn->Enable(!m_pNumberCharEdit->GetText().isEmpty());
         }
     }
-    delete pDlg;
 
     return 0;
 }
diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index 51b9614..6cde196 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -53,6 +53,8 @@
 
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
 
+#include <boost/scoped_ptr.hpp>
+
 using namespace ::com::sun::star;
 
 DBG_NAME(outlinehdl)
@@ -264,7 +266,7 @@ IMPL_LINK( SwOutlineTabDialog, MenuSelectHdl, Menu *, pMenu )
         nLevelNo = 9;
     else if (sIdent == "saveas")
     {
-        SwNumNamesDlg *pDlg = new SwNumNamesDlg(this);
+        boost::scoped_ptr<SwNumNamesDlg> pDlg(new SwNumNamesDlg(this));
         const OUString *aStrArr[SwChapterNumRules::nMaxRules];
         for(sal_uInt16 i = 0; i < SwChapterNumRules::nMaxRules; ++i)
         {
@@ -282,7 +284,6 @@ IMPL_LINK( SwOutlineTabDialog, MenuSelectHdl, Menu *, pMenu )
                     *pNumRule, aName ), pDlg->GetCurEntryPos() );
             pMenu->SetItemText(pMenu->GetItemId(pDlg->GetCurEntryPos()), aName);
         }
-        delete pDlg;
         return 0;
     }
 
diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx
index 99bcc10..72c80c3 100644
--- a/sw/source/ui/uiview/pview.cxx
+++ b/sw/source/ui/uiview/pview.cxx
@@ -77,6 +77,7 @@
 #include <svx/dialogs.hrc>
 #include <osl/mutex.hxx>
 
+#include <boost/scoped_ptr.hpp>
 
 using namespace ::com::sun::star;
 SFX_IMPL_NAMED_VIEWFACTORY(SwPagePreview, "PrintPreview")
@@ -735,7 +736,7 @@ void  SwPagePreview::Execute( SfxRequest &rReq )
         {
             const SfxItemSet *pArgs = rReq.GetArgs();
             const SfxPoolItem* pItem;
-            AbstractSvxZoomDialog *pDlg = 0;
+            boost::scoped_ptr<AbstractSvxZoomDialog> pDlg;
             if(!pArgs)
             {
                 SfxItemSet aCoreSet(GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM);
@@ -754,7 +755,7 @@ void  SwPagePreview::Execute( SfxRequest &rReq )
                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                 if(pFact)
                 {
-                    pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet);
+                    pDlg.reset(pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet));
                     OSL_ENSURE(pDlg, "Dialogdiet fail!");
                 }
 
@@ -777,7 +778,6 @@ void  SwPagePreview::Execute( SfxRequest &rReq )
                 if(USHRT_MAX != nZoomFactor)
                     SetZoom(eType, nZoomFactor);
             }
-            delete pDlg;
         }
         break;
         case SID_ATTR_ZOOMSLIDER :
diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx
index 7b10e68..0e09535 100644
--- a/sw/source/ui/uiview/view2.cxx
+++ b/sw/source/ui/uiview/view2.cxx
@@ -138,6 +138,8 @@
 #include <vcl/GraphicNativeTransform.hxx>
 #include <vcl/GraphicNativeMetadata.hxx>
 
+#include <boost/scoped_ptr.hpp>
+
 const char sStatusDelim[] = " : ";
 const char sStatusComma[] = " , ";
 
@@ -268,9 +270,9 @@ sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq )
     SwDocShell* pDocShell = GetDocShell();
     sal_uInt16 nHtmlMode = ::GetHtmlMode(pDocShell);
     // when in HTML mode insert only as a link
-    FileDialogHelper* pFileDlg = new FileDialogHelper(
+    boost::scoped_ptr<FileDialogHelper> pFileDlg(new FileDialogHelper(
         ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE,
-        SFXWB_GRAPHIC );
+        SFXWB_GRAPHIC ));
     pFileDlg->SetTitle(SW_RESSTR(STR_INSERT_GRAPHIC ));
     pFileDlg->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC );
     uno::Reference < XFilePicker > xFP = pFileDlg->GetFilePicker();
@@ -487,8 +489,6 @@ sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq )
         rSh.EndUndo(); // due to possible change of Shell
     }
 
-    delete pFileDlg;
-
     return bReturn;
 }
 
@@ -508,10 +508,9 @@ void SwView::Execute(SfxRequest &rReq)
         {
             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
             OSL_ENSURE(pFact, "Dialogdiet fail!");
-            VclAbstractDialog* pDlg = pFact->CreateVclSwViewDialog(*this);
+            boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclSwViewDialog(*this));
             OSL_ENSURE(pDlg, "Dialogdiet fail!");
             pDlg->Execute();
-            delete pDlg;
             break;
         }
         case FN_EDIT_LINK_DLG:
@@ -1634,7 +1633,7 @@ void SwView::ExecuteStatusLine(SfxRequest &rReq)
             if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
             {
                 const SfxItemSet *pSet = 0;
-                AbstractSvxZoomDialog *pDlg = 0;
+                boost::scoped_ptr<AbstractSvxZoomDialog> pDlg;
                 if ( pArgs )
                     pSet = pArgs;
                 else
@@ -1664,7 +1663,7 @@ void SwView::ExecuteStatusLine(SfxRequest &rReq)
                     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                     if(pFact)
                     {
-                        pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet);
+                        pDlg.reset(pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet));
                         OSL_ENSURE(pDlg, "Zooming fail!");
                         if (pDlg)
                         {
@@ -1692,8 +1691,6 @@ void SwView::ExecuteStatusLine(SfxRequest &rReq)
                 if ( pItem )
                     rReq.AppendItem( *pItem );
                 rReq.Done();
-
-                delete pDlg;
             }
         }
         break;
@@ -1870,11 +1867,10 @@ void SwView::EditLinkDlg()
 {
     sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb );
+    boost::scoped_ptr<SfxAbstractLinksDialog> pDlg(pFact->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb ));
     if ( pDlg )
     {
         pDlg->Execute();
-        delete pDlg;
     }
 }
 
@@ -2332,9 +2328,8 @@ void SwView::GenerateFormLetter(sal_Bool bUseCurrentDocument)
                     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
                     if ( pFact )
                     {
-                        VclAbstractDialog* pDlg = pFact->CreateVclDialog( NULL, SID_OPTIONS_DATABASES );
+                        boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( NULL, SID_OPTIONS_DATABASES ));
                         pDlg->Execute();
-                        delete pDlg;
                     }
                 }
                 return ;
diff --git a/sw/source/ui/uiview/viewdlg2.cxx b/sw/source/ui/uiview/viewdlg2.cxx
index dcfb833..b029a9b 100644
--- a/sw/source/ui/uiview/viewdlg2.cxx
+++ b/sw/source/ui/uiview/viewdlg2.cxx
@@ -44,6 +44,8 @@
 
 #include "view.hrc"
 
+#include <boost/scoped_ptr.hpp>
+
 void SwView::ExecDlgExt(SfxRequest &rReq)
 {
     Window *pMDI = &GetViewFrame()->GetWindow();
@@ -55,12 +57,11 @@ void SwView::ExecDlgExt(SfxRequest &rReq)
             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
 
-            VclAbstractDialog* pDialog = pFact->CreateSwCaptionDialog( pMDI, *this, DLG_CAPTION );
+            boost::scoped_ptr<VclAbstractDialog> pDialog(pFact->CreateSwCaptionDialog( pMDI, *this, DLG_CAPTION ));
             OSL_ENSURE(pDialog, "Dialogdiet fail!");
             if ( pDialog )
             {
                 pDialog->Execute();
-                delete pDialog;
             }
             break;
         }
@@ -68,14 +69,13 @@ void SwView::ExecDlgExt(SfxRequest &rReq)
         {
             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
             OSL_ENSURE(pFact, "Dialogdiet fail!");
-            AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg(
-                pMDI, *m_pWrtShell, sal_True);
+            boost::scoped_ptr<AbstractInsFootNoteDlg> pDlg(pFact->CreateInsFootNoteDlg(
+                pMDI, *m_pWrtShell, sal_True));
             OSL_ENSURE(pDlg, "Dialogdiet fail!");
 
             pDlg->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE)->GetCommand());
             pDlg->SetText( SW_RESSTR(STR_EDIT_FOOTNOTE) );
             pDlg->Execute();
-            delete pDlg;
             break;
         }
     }
diff --git a/sw/source/ui/uiview/viewling.cxx b/sw/source/ui/uiview/viewling.cxx
index a6129ed..da993813 100644
--- a/sw/source/ui/uiview/viewling.cxx
+++ b/sw/source/ui/uiview/viewling.cxx
@@ -570,26 +570,24 @@ void SwView::StartThesaurus()
     OUString aTmp = GetThesaurusLookUpText( bSelection );
 
     Reference< XThesaurus >  xThes( ::GetThesaurus() );
-    AbstractThesaurusDialog *pDlg = NULL;
 
     if ( !xThes.is() || !xThes->hasLocale( LanguageTag::convertToLocale( eLang ) ) )
         SpellError( eLang );
     else
     {
+        boost::scoped_ptr<AbstractThesaurusDialog> pDlg;
         // create dialog
         {   //Scope for SwWait-Object
             SwWait aWait( *GetDocShell(), true );
             // load library with dialog only on demand ...
             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-            pDlg = pFact->CreateThesaurusDialog( &GetEditWin(), xThes, aTmp, eLang );
+            pDlg.reset(pFact->CreateThesaurusDialog( &GetEditWin(), xThes, aTmp, eLang ));
         }
 
         if ( pDlg->Execute()== RET_OK )
             InsertThesaurusSynonym( pDlg->GetWord(), aTmp, bSelection );
     }
 
-    delete pDlg;
-
     pVOpt->SetIdle( bOldIdle );
 }
 


More information about the Libreoffice-commits mailing list