sw/source/ui/misc/pgfnote.cxx | 8 +-- sw/source/ui/misc/srtdlg.cxx | 7 +-- sw/source/ui/table/convert.cxx | 4 - sw/source/ui/table/instable.cxx | 4 - sw/source/ui/table/tautofmt.cxx | 17 +++---- sw/source/uibase/app/docsh2.cxx | 13 ++--- sw/source/uibase/app/docshini.cxx | 13 +++-- sw/source/uibase/dialog/regionsw.cxx | 14 ++---- sw/source/uibase/dochdl/gloshdl.cxx | 12 ++--- sw/source/uibase/dochdl/swdtflvr.cxx | 59 +++++++++++---------------- sw/source/uibase/docvw/DashedLine.cxx | 6 +- sw/source/uibase/docvw/HeaderFooterWin.cxx | 6 +- sw/source/uibase/docvw/PageBreakWin.cxx | 6 +- sw/source/uibase/docvw/PostItMgr.cxx | 5 +- sw/source/uibase/docvw/SidebarTxtControl.cxx | 4 - sw/source/uibase/docvw/SidebarWin.cxx | 7 +-- sw/source/uibase/docvw/edtwin.cxx | 10 ++-- 17 files changed, 91 insertions(+), 104 deletions(-)
New commits: commit e0057072817ccad2a54eca45ffdb84d1c99ee7a7 Author: Takeshi Abe <t...@fixedpoint.jp> Date: Thu Jun 5 14:10:15 2014 +0900 Avoid possible memory leaks in case of exceptions Change-Id: Ia8bc0e24a76dd953000b73806ac21f21db4c4ca3 diff --git a/sw/source/uibase/dialog/regionsw.cxx b/sw/source/uibase/dialog/regionsw.cxx index 299c26c..938c552 100644 --- a/sw/source/uibase/dialog/regionsw.cxx +++ b/sw/source/uibase/dialog/regionsw.cxx @@ -83,12 +83,11 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "Dialogdiet fail!"); - AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( - &GetView().GetViewFrame()->GetWindow(), aSet , rSh); + boost::scoped_ptr<AbstractInsertSectionTabDialog> aTabDlg(pFact->CreateInsertSectionTabDialog( + &GetView().GetViewFrame()->GetWindow(), aSet , rSh)); OSL_ENSURE(aTabDlg, "Dialogdiet fail!"); aTabDlg->Execute(); rReq.Ignore(); - delete aTabDlg; } else { @@ -194,13 +193,11 @@ IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData*, pSect ) aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "Dialogdiet fail!"); - AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( - &pThis->GetView().GetViewFrame()->GetWindow(),aSet , *pThis); + boost::scoped_ptr<AbstractInsertSectionTabDialog> aTabDlg(pFact->CreateInsertSectionTabDialog( + &pThis->GetView().GetViewFrame()->GetWindow(),aSet , *pThis)); OSL_ENSURE(aTabDlg, "Dialogdiet fail!"); aTabDlg->SetSectionData(*xSectionData); aTabDlg->Execute(); - - delete aTabDlg; } return 0; } @@ -222,14 +219,13 @@ void SwBaseShell::EditRegionDialog(SfxRequest& rReq) { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "Dialogdiet fail!"); - AbstractEditRegionDlg* pEditRegionDlg = pFact->CreateEditRegionDlg(pParentWin, rWrtShell); + boost::scoped_ptr<AbstractEditRegionDlg> pEditRegionDlg(pFact->CreateEditRegionDlg(pParentWin, rWrtShell)); OSL_ENSURE(pEditRegionDlg, "Dialogdiet fail!"); if(pItem && pItem->ISA(SfxStringItem)) { pEditRegionDlg->SelectSection(((const SfxStringItem*)pItem)->GetValue()); } pEditRegionDlg->Execute(); - delete pEditRegionDlg; } } break; diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 572f51a..f34c1fa 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -124,6 +124,7 @@ #include <vcl/GraphicNativeTransform.hxx> #include <vcl/GraphicNativeMetadata.hxx> +#include <boost/scoped_array.hpp> #include <boost/scoped_ptr.hpp> extern bool bFrmDrag; @@ -2632,14 +2633,14 @@ bool SwTransferable::_PasteDBData( TransferableDataHelper& rData, } else if( nWh ) { - SfxUsrAnyItem* pConnectionItem = 0; - SfxUsrAnyItem* pCursorItem = 0; - SfxUsrAnyItem* pColumnItem = 0; - SfxUsrAnyItem* pSourceItem = 0; - SfxUsrAnyItem* pCommandItem = 0; - SfxUsrAnyItem* pCommandTypeItem = 0; - SfxUsrAnyItem* pColumnNameItem = 0; - SfxUsrAnyItem* pSelectionItem = 0; + boost::scoped_ptr<SfxUsrAnyItem> pConnectionItem; + boost::scoped_ptr<SfxUsrAnyItem> pCursorItem; + boost::scoped_ptr<SfxUsrAnyItem> pColumnItem; + boost::scoped_ptr<SfxUsrAnyItem> pSourceItem; + boost::scoped_ptr<SfxUsrAnyItem> pCommandItem; + boost::scoped_ptr<SfxUsrAnyItem> pCommandTypeItem; + boost::scoped_ptr<SfxUsrAnyItem> pColumnNameItem; + boost::scoped_ptr<SfxUsrAnyItem> pSelectionItem; bool bDataAvailable = true; ODataAccessDescriptor aDesc; @@ -2652,14 +2653,14 @@ bool SwTransferable::_PasteDBData( TransferableDataHelper& rData, if ( bDataAvailable ) { - pConnectionItem = new SfxUsrAnyItem(FN_DB_CONNECTION_ANY, aDesc[daConnection]); - pColumnItem = new SfxUsrAnyItem(FN_DB_COLUMN_ANY, aDesc[daColumnObject]); - pSourceItem = new SfxUsrAnyItem(FN_DB_DATA_SOURCE_ANY, makeAny(aDesc.getDataSource())); - pCommandItem = new SfxUsrAnyItem(FN_DB_DATA_COMMAND_ANY, aDesc[daCommand]); - pCommandTypeItem = new SfxUsrAnyItem(FN_DB_DATA_COMMAND_TYPE_ANY, aDesc[daCommandType]); - pColumnNameItem = new SfxUsrAnyItem(FN_DB_DATA_COLUMN_NAME_ANY, aDesc[daColumnName]); - pSelectionItem = new SfxUsrAnyItem(FN_DB_DATA_SELECTION_ANY, aDesc[daSelection]); - pCursorItem = new SfxUsrAnyItem(FN_DB_DATA_CURSOR_ANY, aDesc[daCursor]); + pConnectionItem.reset(new SfxUsrAnyItem(FN_DB_CONNECTION_ANY, aDesc[daConnection])); + pColumnItem.reset(new SfxUsrAnyItem(FN_DB_COLUMN_ANY, aDesc[daColumnObject])); + pSourceItem.reset(new SfxUsrAnyItem(FN_DB_DATA_SOURCE_ANY, makeAny(aDesc.getDataSource()))); + pCommandItem.reset(new SfxUsrAnyItem(FN_DB_DATA_COMMAND_ANY, aDesc[daCommand])); + pCommandTypeItem.reset(new SfxUsrAnyItem(FN_DB_DATA_COMMAND_TYPE_ANY, aDesc[daCommandType])); + pColumnNameItem.reset(new SfxUsrAnyItem(FN_DB_DATA_COLUMN_NAME_ANY, aDesc[daColumnName])); + pSelectionItem.reset(new SfxUsrAnyItem(FN_DB_DATA_SELECTION_ANY, aDesc[daSelection])); + pCursorItem.reset(new SfxUsrAnyItem(FN_DB_DATA_CURSOR_ANY, aDesc[daCursor])); } SwView& rView = rSh.GetView(); @@ -2669,17 +2670,9 @@ bool SwTransferable::_PasteDBData( TransferableDataHelper& rData, SfxStringItem aDataDesc( nWh, sTxt ); rView.GetViewFrame()->GetDispatcher()->Execute( nWh, SFX_CALLMODE_ASYNCHRON, &aDataDesc, - pConnectionItem, pColumnItem, - pSourceItem, pCommandItem, pCommandTypeItem, - pColumnNameItem, pSelectionItem, pCursorItem,0L); - delete pConnectionItem; - delete pColumnItem; - delete pSourceItem; - delete pCommandItem; - delete pCommandTypeItem; - delete pColumnNameItem; - delete pSelectionItem; - delete pCursorItem; + pConnectionItem.get(), pColumnItem.get(), + pSourceItem.get(), pCommandItem.get(), pCommandTypeItem.get(), + pColumnNameItem.get(), pSelectionItem.get(), pCursorItem.get(), 0L); } else { @@ -3671,21 +3664,21 @@ bool SwTrnsfrDdeLink::WriteData( SvStream& rStrm ) pDocShell->GetTitle(SFX_TITLE_FULLNAME), eEncoding)); const OString aName(OUStringToOString(sName, eEncoding)); - sal_Char* pMem = new sal_Char[ aAppNm.getLength() + aTopic.getLength() + aName.getLength() + 4 ]; + boost::scoped_array<sal_Char> pMem(new sal_Char[ aAppNm.getLength() + aTopic.getLength() + aName.getLength() + 4 ]); sal_Int32 nLen = aAppNm.getLength(); - memcpy( pMem, aAppNm.getStr(), nLen ); + memcpy( pMem.get(), aAppNm.getStr(), nLen ); pMem[ nLen++ ] = 0; - memcpy( pMem + nLen, aTopic.getStr(), aTopic.getLength() ); + memcpy( pMem.get() + nLen, aTopic.getStr(), aTopic.getLength() ); nLen = nLen + aTopic.getLength(); pMem[ nLen++ ] = 0; - memcpy( pMem + nLen, aName.getStr(), aName.getLength() ); + memcpy( pMem.get() + nLen, aName.getStr(), aName.getLength() ); nLen = nLen + aName.getLength(); pMem[ nLen++ ] = 0; pMem[ nLen++ ] = 0; - rStrm.Write( pMem, nLen ); - delete[] pMem; + rStrm.Write( pMem.get(), nLen ); + pMem.reset(); IDocumentMarkAccess* const pMarkAccess = pDocShell->GetDoc()->getIDocumentMarkAccess(); IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(sName); diff --git a/sw/source/uibase/docvw/DashedLine.cxx b/sw/source/uibase/docvw/DashedLine.cxx index e9e343b3..824e7c3 100644 --- a/sw/source/uibase/docvw/DashedLine.cxx +++ b/sw/source/uibase/docvw/DashedLine.cxx @@ -17,6 +17,7 @@ #include <drawinglayer/processor2d/processorfromoutputdevice.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> +#include <boost/scoped_ptr.hpp> SwDashedLine::SwDashedLine( Window* pParent, Color& ( *pColorFn )() ) : FixedLine( pParent, WB_DIALOGCONTROL | WB_HORZ ), @@ -31,9 +32,9 @@ SwDashedLine::~SwDashedLine( ) void SwDashedLine::Paint( const Rectangle& ) { const drawinglayer::geometry::ViewInformation2D aNewViewInfos; - drawinglayer::processor2d::BaseProcessor2D * pProcessor = + boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor( drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice( - *this, aNewViewInfos ); + *this, aNewViewInfos )); // Compute the start and end points const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) ); @@ -91,7 +92,6 @@ void SwDashedLine::Paint( const Rectangle& ) aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( pLine ); pProcessor->process( aSeq ); - delete pProcessor; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/docvw/HeaderFooterWin.cxx b/sw/source/uibase/docvw/HeaderFooterWin.cxx index b68c59a..17d95ff 100644 --- a/sw/source/uibase/docvw/HeaderFooterWin.cxx +++ b/sw/source/uibase/docvw/HeaderFooterWin.cxx @@ -48,6 +48,7 @@ #include <vcl/menubtn.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> +#include <boost/scoped_ptr.hpp> #define TEXT_PADDING 5 #define BOX_DISTANCE 10 @@ -351,9 +352,9 @@ void SwHeaderFooterWin::Paint( const Rectangle& ) // Create the processor and process the primitives const drawinglayer::geometry::ViewInformation2D aNewViewInfos; - drawinglayer::processor2d::BaseProcessor2D * pProcessor = + boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor( drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice( - *this, aNewViewInfos ); + *this, aNewViewInfos )); // TODO Ghost it all if needed drawinglayer::primitive2d::Primitive2DSequence aGhostedSeq( 1 ); @@ -366,7 +367,6 @@ void SwHeaderFooterWin::Paint( const Rectangle& ) aSeq, aBColorModifier ) ); pProcessor->process( aGhostedSeq ); - delete pProcessor; } bool SwHeaderFooterWin::IsEmptyHeaderFooter( ) diff --git a/sw/source/uibase/docvw/PageBreakWin.cxx b/sw/source/uibase/docvw/PageBreakWin.cxx index 876961a..cba0d11 100644 --- a/sw/source/uibase/docvw/PageBreakWin.cxx +++ b/sw/source/uibase/docvw/PageBreakWin.cxx @@ -41,6 +41,7 @@ #include <svl/stritem.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> +#include <boost/scoped_ptr.hpp> #define BUTTON_WIDTH 30 #define BUTTON_HEIGHT 19 @@ -197,12 +198,11 @@ void SwPageBreakWin::Paint( const Rectangle& ) // Create the processor and process the primitives const drawinglayer::geometry::ViewInformation2D aNewViewInfos; - drawinglayer::processor2d::BaseProcessor2D * pProcessor = + boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor( drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice( - *this, aNewViewInfos ); + *this, aNewViewInfos )); pProcessor->process( aGhostedSeq ); - delete pProcessor; } void SwPageBreakWin::Select( ) diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index e370f79..4b6fd1d 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -78,6 +78,7 @@ #include "swabstdlg.hxx" #include "swevent.hxx" #include "switerator.hxx" +#include <boost/scoped_ptr.hpp> // distance between Anchor Y and initial note position #define POSTIT_INITIAL_ANCHOR_DISTANCE 20 @@ -1270,14 +1271,14 @@ void SwPostItMgr::ExecuteFormatAllDialog(SwView& rView) SfxItemSet aDlgAttr(*pPool, EE_ITEMS_START, EE_ITEMS_END); aDlgAttr.Put(aEditAttr); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg(rView.GetWindow(), rView, aDlgAttr, DLG_CHAR_ANN); + boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(rView.GetWindow(), rView, aDlgAttr, DLG_CHAR_ANN)); sal_uInt16 nRet = pDlg->Execute(); if (RET_OK == nRet) { aDlgAttr.Put(*pDlg->GetOutputItemSet()); FormatAll(aDlgAttr); } - delete pDlg; + pDlg.reset(); SetActiveSidebarWin(pOrigActiveWin); } diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx index 5834c02..4d23b44 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.cxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx @@ -52,6 +52,7 @@ #include <wrtsh.hxx> #include <shellres.hxx> #include <SwRewriter.hxx> +#include <boost/scoped_ptr.hpp> namespace sw { namespace sidebarwindows { @@ -346,7 +347,7 @@ void SidebarTxtControl::Command( const CommandEvent& rCEvt ) } else { - SfxPopupMenuManager* pMgr = mrDocView.GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel()); + boost::scoped_ptr<SfxPopupMenuManager> pMgr(mrDocView.GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel())); ((PopupMenu*)pMgr->GetSVMenu())->SetSelectHdl( LINK(this, SidebarTxtControl, Select) ); { @@ -370,7 +371,6 @@ void SidebarTxtControl::Command( const CommandEvent& rCEvt ) //!! pointer created in the call to Popup. //!! Otherwise we would have a memory leak (see also #i107205#) pMgr->Execute( aPos, this ); - delete pMgr; } } else diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index 34aaa23..3abc911 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -79,6 +79,7 @@ #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/processor2d/processorfromoutputdevice.hxx> #include <drawinglayer/primitive2d/shadowprimitive2d.hxx> +#include <boost/scoped_ptr.hpp> namespace sw { namespace sidebarwindows { @@ -262,15 +263,15 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, s mpSidebarTxtControl->Draw(pDev, rPt, rSz, nInFlags); const drawinglayer::geometry::ViewInformation2D aNewViewInfos; - drawinglayer::processor2d::BaseProcessor2D * pProcessor = + boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor( drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice( - *pDev, aNewViewInfos ); + *pDev, aNewViewInfos )); if (mpAnchor) pProcessor->process(mpAnchor->getOverlayObjectPrimitive2DSequence()); if (mpTextRangeOverlay) pProcessor->process(mpTextRangeOverlay->getOverlayObjectPrimitive2DSequence()); - delete pProcessor; + pProcessor.reset(); if (mpVScrollbar->IsVisible()) { diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index c84e91f..1152150 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -145,6 +145,8 @@ #include "../../core/inc/rootfrm.hxx" #include <unotools/syslocaleoptions.hxx> +#include <boost/scoped_array.hpp> +#include <boost/scoped_ptr.hpp> using namespace sw::mark; using namespace ::com::sun::star; @@ -5099,7 +5101,7 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) if ( m_rView.GetDocShell()->IsReadOnly() ) { - SwReadOnlyPopup* pROPopup = new SwReadOnlyPopup( aDocPos, m_rView ); + boost::scoped_ptr<SwReadOnlyPopup> pROPopup(new SwReadOnlyPopup( aDocPos, m_rView )); ui::ContextMenuExecuteEvent aEvent; aEvent.SourceWindow = VCLUnoHelper::GetInterface( this ); @@ -5118,7 +5120,6 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) else pROPopup->Execute(this, aPixPos); } - delete pROPopup; } else if ( !m_rView.ExecSpellPopup( aDocPos ) ) GetView().GetViewFrame()->GetDispatcher()->ExecutePopup( 0, this, &aPixPos); @@ -5409,7 +5410,7 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) } else { - Rectangle* aRects = new Rectangle[ nSize ]; + boost::scoped_array<Rectangle> aRects(new Rectangle[ nSize ]); int nRectIndex = 0; for ( SwIndex nIndex = rStart.nContent; nIndex < rEnd.nContent; ++nIndex ) { @@ -5419,8 +5420,7 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) aRects[ nRectIndex ] = Rectangle( aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom() ); ++nRectIndex; } - rWin.SetCompositionCharRect( aRects, nSize, bVertical ); - delete[] aRects; + rWin.SetCompositionCharRect( aRects.get(), nSize, bVertical ); } } bCallBase = false; commit e6f8ec366bb9b565bc9fc14989b3c28af9693c0d Author: Takeshi Abe <t...@fixedpoint.jp> Date: Wed Jun 4 22:03:59 2014 +0900 Avoid possible memory leaks in case of exceptions Change-Id: Iaf672463cf51d596148822d9b5effe5ab40f70d4 diff --git a/sw/source/ui/misc/pgfnote.cxx b/sw/source/ui/misc/pgfnote.cxx index 5b71079..2970490 100644 --- a/sw/source/ui/misc/pgfnote.cxx +++ b/sw/source/ui/misc/pgfnote.cxx @@ -40,6 +40,7 @@ #include <globals.hrc> #include <misc.hrc> +#include <boost/scoped_ptr.hpp> using namespace ::com::sun::star; @@ -143,7 +144,7 @@ SfxTabPage* SwFootNotePage::Create(Window *pParent, const SfxItemSet &rSet) void SwFootNotePage::Reset(const SfxItemSet &rSet) { // if no example exists, otherwise Init here in Activate - SwPageFtnInfo* pDefFtnInfo = 0; + boost::scoped_ptr<SwPageFtnInfo> pDefFtnInfo; const SwPageFtnInfo* pFtnInfo; const SfxPoolItem* pItem = SfxTabPage::GetItem(rSet, FN_PARAM_FTN_INFO); if( pItem ) @@ -154,8 +155,8 @@ void SwFootNotePage::Reset(const SfxItemSet &rSet) { // when "standard" is being activated the footnote item is deleted, // that's why a footnote structure has to be created here - pDefFtnInfo = new SwPageFtnInfo(); - pFtnInfo = pDefFtnInfo; + pDefFtnInfo.reset(new SwPageFtnInfo()); + pFtnInfo = pDefFtnInfo.get(); } // footnote area's height SwTwips lHeight = pFtnInfo->GetHeight(); @@ -250,7 +251,6 @@ void SwFootNotePage::Reset(const SfxItemSet &rSet) m_pLineDistEdit->SetValue( m_pLineDistEdit->Normalize(pFtnInfo->GetBottomDist()), FUNIT_TWIP); ActivatePage( rSet ); - delete pDefFtnInfo; } // stuff attributes into the set, when OK diff --git a/sw/source/ui/misc/srtdlg.cxx b/sw/source/ui/misc/srtdlg.cxx index 53dcebb..f5f05dd 100644 --- a/sw/source/ui/misc/srtdlg.cxx +++ b/sw/source/ui/misc/srtdlg.cxx @@ -39,6 +39,7 @@ #include <node.hxx> #include <tblsel.hxx> #include <sfx2/request.hxx> +#include <boost/scoped_ptr.hpp> static bool bCheck1 = true; static bool bCheck2 = false; @@ -368,16 +369,14 @@ IMPL_LINK_NOARG(SwSortDlg, DelimCharHdl) { SfxAllItemSet aSet( rSh.GetAttrPool() ); aSet.Put( SfxInt32Item( SID_ATTR_CHAR, GetDelimChar() ) ); - SfxAbstractDialog* pMap = pFact->CreateSfxDialog( m_pDelimPB, aSet, - rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ); + boost::scoped_ptr<SfxAbstractDialog> pMap(pFact->CreateSfxDialog( m_pDelimPB, aSet, + rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP )); if( RET_OK == pMap->Execute() ) { SFX_ITEMSET_ARG( pMap->GetOutputItemSet(), pItem, SfxInt32Item, SID_ATTR_CHAR, false ); if ( pItem ) m_pDelimEdt->SetText( OUString(pItem->GetValue()) ); } - - delete pMap; } return 0; } diff --git a/sw/source/ui/table/convert.cxx b/sw/source/ui/table/convert.cxx index 96d2ae1..3c52e34 100644 --- a/sw/source/ui/table/convert.cxx +++ b/sw/source/ui/table/convert.cxx @@ -34,6 +34,7 @@ #include "app.hrc" #include "table.hrc" #include "swabstdlg.hxx" +#include <boost/scoped_ptr.hpp> namespace swui { @@ -185,11 +186,10 @@ IMPL_LINK( SwConvertTableDlg, AutoFmtHdl, PushButton*, pButton ) SwAbstractDialogFactory* pFact = swui::GetFactory(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(pButton, pShell, false, pTAutoFmt); + boost::scoped_ptr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(pButton, pShell, 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/table/instable.cxx b/sw/source/ui/table/instable.cxx index fd4f34a..24ffa27 100644 --- a/sw/source/ui/table/instable.cxx +++ b/sw/source/ui/table/instable.cxx @@ -32,6 +32,7 @@ #include "table.hrc" #include "swabstdlg.hxx" +#include <boost/scoped_ptr.hpp> namespace swui { @@ -190,11 +191,10 @@ IMPL_LINK( SwInsTableDlg, AutoFmtHdl, PushButton*, pButton ) SwAbstractDialogFactory* pFact = swui::GetFactory(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(pButton,pShell, false, pTAutoFmt); + boost::scoped_ptr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(pButton,pShell, 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/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx index f3c1188..063a377 100644 --- a/sw/source/ui/table/tautofmt.cxx +++ b/sw/source/ui/table/tautofmt.cxx @@ -38,6 +38,7 @@ #include "tblafmt.hxx" #include "tautofmt.hxx" #include "shellres.hxx" +#include <boost/scoped_ptr.hpp> using namespace com::sun::star; @@ -286,10 +287,10 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, AddHdl) bool bOk = false, bFmtInserted = false; while( !bOk ) { - SwStringInputDlg* pDlg = new SwStringInputDlg( this, + boost::scoped_ptr<SwStringInputDlg> pDlg(new SwStringInputDlg( this, aStrTitle, aStrLabel, - OUString() ); + OUString() )); if( RET_OK == pDlg->Execute() ) { const OUString aFormatName( pDlg->GetInputString() ); @@ -337,7 +338,6 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, AddHdl) } else bOk = true; - delete pDlg; } return 0; } @@ -349,8 +349,8 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, RemoveHdl) aMessage += m_pLbFormat->GetSelectEntry(); aMessage += "\n"; - MessBox* pBox = new MessBox( this, WinBits( WB_OK_CANCEL ), - aStrDelTitle, aMessage); + boost::scoped_ptr<MessBox> pBox(new MessBox( this, WinBits( WB_OK_CANCEL ), + aStrDelTitle, aMessage)); if ( pBox->Execute() == RET_OK ) { @@ -372,7 +372,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, RemoveHdl) bCoreDataChanged = true; } } - delete pBox; + pBox.reset(); SelFmtHdl( 0 ); @@ -384,10 +384,10 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, RenameHdl) bool bOk = false; while( !bOk ) { - SwStringInputDlg* pDlg = new SwStringInputDlg( this, + boost::scoped_ptr<SwStringInputDlg> pDlg(new SwStringInputDlg( this, aStrRenameTitle, m_pLbFormat->GetSelectEntry(), - OUString() ); + OUString() )); if( pDlg->Execute() == RET_OK ) { bool bFmtRenamed = false; @@ -439,7 +439,6 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, RenameHdl) } else bOk = true; - delete pDlg; } return 0; } diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index 4ba1dd0..bf2c429 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -486,8 +486,8 @@ void SwDocShell::Execute(SfxRequest& rReq) if ( aFileName.isEmpty() ) { SvtPathOptions aPathOpt; - SfxNewFileDialog* pNewFileDlg = - new SfxNewFileDialog(&GetView()->GetViewFrame()->GetWindow(), SFXWB_LOAD_TEMPLATE); + boost::scoped_ptr<SfxNewFileDialog> pNewFileDlg( + new SfxNewFileDialog(&GetView()->GetViewFrame()->GetWindow(), SFXWB_LOAD_TEMPLATE)); pNewFileDlg->SetTemplateFlags(nFlags); nRet = pNewFileDlg->Execute(); @@ -551,7 +551,6 @@ void SwDocShell::Execute(SfxRequest& rReq) nFlags = pNewFileDlg->GetTemplateFlags(); rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) ); rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, (long) nFlags ) ); - delete pNewFileDlg; } if( !aFileName.isEmpty() ) @@ -1062,17 +1061,15 @@ void SwDocShell::Execute(SfxRequest& rReq) //search for the view that created the call if(pViewShell->GetObjectShell() == this && pViewShell->GetDispatcher()) { - SfxFrameItem* pFrameItem = new SfxFrameItem( SID_DOCFRAME, - pViewShell->GetViewFrame() ); + boost::scoped_ptr<SfxFrameItem> pFrameItem(new SfxFrameItem( SID_DOCFRAME, + pViewShell->GetViewFrame() )); SfxDispatcher* pDispatch = pViewShell->GetDispatcher(); pDispatch->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aName, &aReferer, - pFrameItem, 0L ); - - delete pFrameItem; + pFrameItem.get(), 0L ); break; } pViewShell = SfxViewShell::GetNext(*pViewShell); diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx index e0d3c77..c7a5130 100644 --- a/sw/source/uibase/app/docshini.cxx +++ b/sw/source/uibase/app/docshini.cxx @@ -84,6 +84,7 @@ // text grid #include <tgrditem.hxx> +#include <boost/scoped_ptr.hpp> using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::lang; @@ -170,7 +171,7 @@ bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) { sal_uInt16 nFontWhich = aFontWhich[i]; sal_uInt16 nFontId = aFontIds[i]; - SvxFontItem* pFontItem = 0; + boost::scoped_ptr<SvxFontItem> pFontItem; const SvxLanguageItem& rLang = (const SvxLanguageItem&)pDoc->GetDefault( aLangTypes[i] ); LanguageType eLanguage = rLang.GetLanguage(); if(!pStdFont->IsFontDefault(nFontId)) @@ -183,8 +184,8 @@ bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) aFont = pPrt->GetFontMetric( aFont ); } - pFontItem = new SvxFontItem(aFont.GetFamily(), aFont.GetName(), - aEmptyOUStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich); + pFontItem.reset(new SvxFontItem(aFont.GetFamily(), aFont.GetName(), + aEmptyOUStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich)); } else { @@ -200,8 +201,8 @@ bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) nFontTypes[i], eLanguage, DEFAULTFONT_FLAGS_ONLYONE ); - pFontItem = new SvxFontItem(aLangDefFont.GetFamily(), aLangDefFont.GetName(), - aEmptyOUStr, aLangDefFont.GetPitch(), aLangDefFont.GetCharSet(), nFontWhich); + pFontItem.reset(new SvxFontItem(aLangDefFont.GetFamily(), aLangDefFont.GetName(), + aEmptyOUStr, aLangDefFont.GetPitch(), aLangDefFont.GetCharSet(), nFontWhich)); } pDoc->SetDefault(*pFontItem); if( !bHTMLTemplSet ) @@ -209,7 +210,7 @@ bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) SwTxtFmtColl *pColl = pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD); pColl->ResetFmtAttr(nFontWhich); } - delete pFontItem; + pFontItem.reset(); sal_Int32 nFontHeight = pStdFont->GetFontHeight( FONT_STANDARD, i, eLanguage ); if(nFontHeight <= 0) nFontHeight = pStdFont->GetDefaultHeightFor( nFontId, eLanguage ); diff --git a/sw/source/uibase/dochdl/gloshdl.cxx b/sw/source/uibase/dochdl/gloshdl.cxx index 571a59e..68e9c6a 100644 --- a/sw/source/uibase/dochdl/gloshdl.cxx +++ b/sw/source/uibase/dochdl/gloshdl.cxx @@ -57,6 +57,7 @@ #include <misc.hrc> #include <IDocumentFieldsAccess.hxx> +#include <boost/scoped_ptr.hpp> using namespace ::com::sun::star; @@ -75,7 +76,7 @@ void SwGlossaryHdl::GlossaryDlg() { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "Dialogdiet fail!"); - AbstractGlossaryDlg* pDlg = pFact->CreateGlossaryDlg(pViewFrame, this, pWrtShell); + boost::scoped_ptr<AbstractGlossaryDlg> pDlg(pFact->CreateGlossaryDlg(pViewFrame, this, pWrtShell)); OSL_ENSURE(pDlg, "Dialogdiet fail!"); OUString sName; OUString sShortName; @@ -86,7 +87,7 @@ void SwGlossaryHdl::GlossaryDlg() sShortName = pDlg->GetCurrShortName(); } - delete pDlg; + pDlg.reset(); DELETEZ(pCurGrp); if(HasGlossaryList()) { @@ -448,7 +449,7 @@ bool SwGlossaryHdl::Expand( const OUString& rShortName, SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - AbstractSwSelGlossaryDlg* pDlg = pFact->CreateSwSelGlossaryDlg(0, aShortName); + boost::scoped_ptr<AbstractSwSelGlossaryDlg> pDlg(pFact->CreateSwSelGlossaryDlg(0, aShortName)); OSL_ENSURE(pDlg, "Dialogdiet fail!"); for(sal_uInt16 i = 0; i < aFoundArr.size(); ++i) { @@ -459,7 +460,7 @@ bool SwGlossaryHdl::Expand( const OUString& rShortName, const sal_Int32 nRet = RET_OK == pDlg->Execute()? pDlg->GetSelectedIdx(): LISTBOX_ENTRY_NOTFOUND; - delete pDlg; + pDlg.reset(); if(LISTBOX_ENTRY_NOTFOUND != nRet) { TextBlockInfo_Impl* pData = &aFoundArr[nRet]; @@ -723,7 +724,7 @@ bool SwGlossaryHdl::ImportGlossaries( const OUString& rName ) if( !rName.isEmpty() ) { const SfxFilter* pFilter = 0; - SfxMedium* pMed = new SfxMedium( rName, STREAM_READ, 0, 0 ); + boost::scoped_ptr<SfxMedium> pMed(new SfxMedium( rName, STREAM_READ, 0, 0 )); SfxFilterMatcher aMatcher( OUString("swriter") ); pMed->UseInteractionHandler( true ); if( !aMatcher.GuessFilter( *pMed, &pFilter, sal_False ) ) @@ -743,7 +744,6 @@ bool SwGlossaryHdl::ImportGlossaries( const OUString& rName ) } } } - DELETEZ(pMed); } return bRet; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits