diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2016-08-15 09:19:35 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-08-15 07:49:37 +0000 |
commit | 2b68e03348b3b4009e8bb2af7979de36bd3450c5 (patch) | |
tree | ea337632ae63bc8c19cdb1b72feedbce8302433a /cui | |
parent | 3093732c17d14b0e6eb67868c514448f13bc66d0 (diff) |
tdf#100782 have XPropertyList hold unique_ptr
Change-Id: I928f297e1be76b965898d83cb3dd2e79b23b7974
Reviewed-on: https://gerrit.libreoffice.org/28095
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/options/optchart.cxx | 4 | ||||
-rw-r--r-- | cui/source/tabpages/border.cxx | 2 | ||||
-rw-r--r-- | cui/source/tabpages/chardlg.cxx | 2 | ||||
-rw-r--r-- | cui/source/tabpages/numpages.cxx | 2 | ||||
-rw-r--r-- | cui/source/tabpages/tparea.cxx | 4 | ||||
-rw-r--r-- | cui/source/tabpages/tpbitmap.cxx | 10 | ||||
-rw-r--r-- | cui/source/tabpages/tpcolor.cxx | 2 | ||||
-rw-r--r-- | cui/source/tabpages/tpgradnt.cxx | 14 | ||||
-rw-r--r-- | cui/source/tabpages/tphatch.cxx | 13 | ||||
-rw-r--r-- | cui/source/tabpages/tpline.cxx | 4 | ||||
-rw-r--r-- | cui/source/tabpages/tplnedef.cxx | 17 | ||||
-rw-r--r-- | cui/source/tabpages/tplneend.cxx | 26 | ||||
-rw-r--r-- | cui/source/tabpages/tppattern.cxx | 22 |
13 files changed, 55 insertions, 67 deletions
diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index 38a9d4704ece..7c668a36aaf4 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -149,7 +149,7 @@ void SvxDefaultColorOptPage::FillColorBox() for( long i = 0; i < nCount; i++ ) { - XColorEntry* pColorEntry = pColorList->GetColor( i ); + const XColorEntry* pColorEntry = pColorList->GetColor(i); m_pValSetColorBox->InsertItem( i + 1, pColorEntry->GetColor(), pColorEntry->GetName() ); } } @@ -163,7 +163,7 @@ long SvxDefaultColorOptPage::GetColorIndex( const Color& rCol ) for( long i = nCount - 1; i >= 0; i-- ) // default chart colors are at the end of the table { - XColorEntry* pColorEntry = pColorList->GetColor( i ); + const XColorEntry* pColorEntry = pColorList->GetColor(i); if( pColorEntry && pColorEntry->GetColor() == rCol ) return pColorList->GetIndex( pColorEntry->GetName() ); } diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index 067a26a3207b..c07f7dd9b43b 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -317,7 +317,7 @@ SvxBorderTabPage::SvxBorderTabPage(vcl::Window* pParent, const SfxItemSet& rCore for ( long i = 0; i < pColorTable->Count(); ++i ) { - XColorEntry* pEntry = pColorTable->GetColor(i); + const XColorEntry* pEntry = pColorTable->GetColor(i); m_pLbLineColor->InsertEntry( pEntry->GetColor(), pEntry->GetName() ); } m_pLbLineColor->SetUpdateMode( true ); diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index 3ee76c571dae..2684039e004e 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -1463,7 +1463,7 @@ void SvxCharEffectsPage::Initialize() } for ( long i = 0; i < pColorTable->Count(); i++ ) { - XColorEntry* pEntry = pColorTable->GetColor(i); + const XColorEntry* pEntry = pColorTable->GetColor(i); m_pUnderlineColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() ); m_pOverlineColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() ); m_pFontColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() ); diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index e3795cd3ee40..42e26ef732bc 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -1402,7 +1402,7 @@ void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet ) for ( long i = 0; i < pColorTable->Count(); i++ ) { - XColorEntry* pEntry = pColorTable->GetColor(i); + const XColorEntry* pEntry = pColorTable->GetColor(i); m_pBulColLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() ); } } diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx index 67af95dccb37..1673ae32a891 100644 --- a/cui/source/tabpages/tparea.cxx +++ b/cui/source/tabpages/tparea.cxx @@ -774,7 +774,7 @@ IMPL_LINK_NOARG_TYPED(SvxAreaTabPage, ModifyGradientHdl_Impl, ListBox&, void) if( _nPos != LISTBOX_ENTRY_NOTFOUND ) { // fill ItemSet and pass it on to aCtlXRectPreview - XGradientEntry* pEntry = m_pGradientList->GetGradient( _nPos ); + const XGradientEntry* pEntry = m_pGradientList->GetGradient(_nPos); m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_GRADIENT ) ); m_rXFSet.Put( XFillGradientItem( OUString(), pEntry->GetGradient() ) ); @@ -820,7 +820,7 @@ IMPL_LINK_NOARG_TYPED(SvxAreaTabPage, ModifyHatchingHdl_Impl, ListBox&, void) if( _nPos != LISTBOX_ENTRY_NOTFOUND ) { // fill ItemSet and pass it on to aCtlXRectPreview - XHatchEntry* pEntry = m_pHatchingList->GetHatch( _nPos ); + const XHatchEntry* pEntry = m_pHatchingList->GetHatch(_nPos); m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_HATCH ) ); m_rXFSet.Put( XFillHatchItem( OUString(), pEntry->GetHatch() ) ); diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx index 09012bb26914..2e8705534d91 100644 --- a/cui/source/tabpages/tpbitmap.cxx +++ b/cui/source/tabpages/tpbitmap.cxx @@ -41,6 +41,8 @@ #include <vcl/layout.hxx> #include <svx/svxdlg.hxx> +#include <o3tl/make_unique.hxx> + using namespace com::sun::star; SvxBitmapTabPage::SvxBitmapTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ) : @@ -143,7 +145,7 @@ bool SvxBitmapTabPage::FillItemSet( SfxItemSet* rAttrs ) size_t nPos = m_pBitmapLB->GetSelectItemPos(); if(VALUESET_ITEM_NOTFOUND != nPos) { - const XBitmapEntry* pXBitmapEntry = m_pBitmapList->GetBitmap( static_cast<sal_uInt16>(nPos) ); + const XBitmapEntry* pXBitmapEntry = m_pBitmapList->GetBitmap(nPos); const OUString aString(m_pBitmapLB->GetItemText( m_pBitmapLB->GetSelectItemId() )); rAttrs->Put(XFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject())); bModified = true; @@ -252,8 +254,7 @@ IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickRenameHdl, SvxPresetListBox*, void) if(bValidBitmapName) { bLoop = false; - XBitmapEntry* pEntry = m_pBitmapList->GetBitmap( static_cast<sal_uInt16>(nPos) ); - pEntry->SetName( aName ); + m_pBitmapList->GetBitmap(nPos)->SetName(aName); m_pBitmapLB->SetItemText(nId, aName); m_pBitmapLB->SelectItem( nId ); @@ -354,8 +355,7 @@ IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickImportHdl, Button*, void) if( !nError ) { - XBitmapEntry* pEntry = new XBitmapEntry( aGraphic, aName ); - m_pBitmapList->Insert( pEntry, nCount ); + m_pBitmapList->Insert(o3tl::make_unique<XBitmapEntry>(aGraphic, aName), nCount); sal_Int32 nId = m_pBitmapLB->GetItemId( nCount - 1 ); Bitmap aBitmap = m_pBitmapList->GetBitmapForPreview( nCount, m_pBitmapLB->GetIconSize() ); diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index 4c70df8e38ae..634f2f782a15 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -271,7 +271,7 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& ) if( *pPageType == PT_COLOR && *pPos != LISTBOX_ENTRY_NOTFOUND ) { m_pValSetColorList->SelectItem( m_pValSetColorList->GetItemId( static_cast<size_t>(*pPos) ) ); - XColorEntry* pEntry = pColorList->GetColor( *pPos ); + const XColorEntry* pEntry = pColorList->GetColor(*pPos); aPreviousColor = pEntry->GetColor(); ChangeColor(pEntry->GetColor()); } diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx index d993c3ef5d7a..0125b0fb1ea2 100644 --- a/cui/source/tabpages/tpgradnt.cxx +++ b/cui/source/tabpages/tpgradnt.cxx @@ -41,6 +41,8 @@ #include <svx/dialogs.hrc> #include "paragrph.hrc" +#include <o3tl/make_unique.hxx> + #define DEFAULT_GRADIENTSTEP 64 using namespace com::sun::star; @@ -511,9 +513,8 @@ IMPL_LINK_NOARG_TYPED(SvxGradientTabPage, ClickAddHdl_Impl, Button*, void) (sal_uInt16) m_pMtrBorder->GetValue(), (sal_uInt16) m_pMtrColorFrom->GetValue(), (sal_uInt16) m_pMtrColorTo->GetValue() ); - XGradientEntry* pEntry = new XGradientEntry( aXGradient, aName ); - m_pGradientList->Insert( pEntry, nCount ); + m_pGradientList->Insert(o3tl::make_unique<XGradientEntry>(aXGradient, aName), nCount); sal_Int32 nId = m_pGradientLB->GetItemId(nCount - 1); //calculate the last ID Bitmap aBitmap = m_pGradientList->GetBitmapForPreview( nCount, m_pGradientLB->GetIconSize() ); @@ -551,9 +552,7 @@ IMPL_LINK_NOARG_TYPED(SvxGradientTabPage, ClickModifyHdl_Impl, Button*, void) (sal_uInt16) m_pMtrColorFrom->GetValue(), (sal_uInt16) m_pMtrColorTo->GetValue() ); - XGradientEntry* pEntry = new XGradientEntry( aXGradient, aName ); - - delete m_pGradientList->Replace( pEntry, static_cast<sal_uInt16>(nPos) ); + m_pGradientList->Replace(o3tl::make_unique<XGradientEntry>(aXGradient, aName), nPos); Bitmap aBitmap = m_pGradientList->GetBitmapForPreview( static_cast<sal_uInt16>(nPos), m_pGradientLB->GetIconSize() ); m_pGradientLB->RemoveItem( nId ); @@ -575,7 +574,7 @@ IMPL_LINK_NOARG_TYPED(SvxGradientTabPage, ClickDeleteHdl_Impl, SvxPresetListBox* if ( aQueryBox->Execute() == RET_YES ) { - delete m_pGradientList->Remove( static_cast<sal_uInt16>(nPos) ); + m_pGradientList->Remove(nPos); m_pGradientLB->RemoveItem( nId ); nId = m_pGradientLB->GetItemId( 0 ); m_pGradientLB->SelectItem( nId ); @@ -618,8 +617,7 @@ IMPL_LINK_NOARG_TYPED(SvxGradientTabPage, ClickRenameHdl_Impl, SvxPresetListBox* if( bValidGradientName ) { bLoop = false; - XGradientEntry* pEntry = m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) ); - pEntry->SetName( aName ); + m_pGradientList->GetGradient(nPos)->SetName(aName); m_pGradientLB->SetItemText( nId, aName ); m_pGradientLB->SelectItem( nId ); diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx index f46eaad5aacb..7082fedf80e4 100644 --- a/cui/source/tabpages/tphatch.cxx +++ b/cui/source/tabpages/tphatch.cxx @@ -43,6 +43,7 @@ #include "paragrph.hrc" #include <svx/dialogs.hrc> +#include <o3tl/make_unique.hxx> using namespace com::sun::star; @@ -573,9 +574,8 @@ IMPL_LINK_NOARG_TYPED(SvxHatchTabPage, ClickAddHdl_Impl, Button*, void) (css::drawing::HatchStyle) m_pLbLineType->GetSelectEntryPos(), GetCoreValue( *m_pMtrDistance, m_ePoolUnit ), static_cast<long>(m_pMtrAngle->GetValue() * 10) ); - XHatchEntry* pEntry = new XHatchEntry( aXHatch, aName ); - m_pHatchingList->Insert( pEntry, nCount ); + m_pHatchingList->Insert(o3tl::make_unique<XHatchEntry>(aXHatch, aName), nCount); sal_Int32 nId = m_pHatchLB->GetItemId(nCount - 1); // calculate the last ID Bitmap aBitmap = m_pHatchingList->GetBitmapForPreview( nCount, m_pHatchLB->GetIconSize() ); @@ -604,9 +604,7 @@ IMPL_LINK_NOARG_TYPED(SvxHatchTabPage, ClickModifyHdl_Impl, Button*, void) GetCoreValue( *m_pMtrDistance, m_ePoolUnit ), static_cast<long>(m_pMtrAngle->GetValue() * 10) ); - XHatchEntry* pEntry = new XHatchEntry( aXHatch, aName ); - - delete m_pHatchingList->Replace( pEntry, static_cast<sal_uInt16>(nPos) ); + m_pHatchingList->Replace(o3tl::make_unique<XHatchEntry>(aXHatch, aName), nPos); Bitmap aBitmap = m_pHatchingList->GetBitmapForPreview( static_cast<sal_uInt16>(nPos), m_pHatchLB->GetIconSize() ); m_pHatchLB->RemoveItem( nId ); @@ -635,7 +633,7 @@ IMPL_LINK_NOARG_TYPED(SvxHatchTabPage, ClickDeleteHdl_Impl, SvxPresetListBox*, v if( aQueryBox->Execute() == RET_YES ) { - m_pHatchingList->Remove( static_cast<sal_uInt16>(nPos) ); + m_pHatchingList->Remove(nPos); m_pHatchLB->RemoveItem( nId ); nId = m_pHatchLB->GetItemId(0); m_pHatchLB->SelectItem( nId ); @@ -675,8 +673,7 @@ IMPL_LINK_NOARG_TYPED(SvxHatchTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, v if(bValidHatchName) { bLoop = false; - XHatchEntry* pEntry = m_pHatchingList->GetHatch( static_cast<sal_uInt16>(nPos) ); - pEntry->SetName( aName ); + m_pHatchingList->GetHatch(nPos)->SetName(aName); m_pHatchLB->SetItemText(nId, aName); m_pHatchLB->SelectItem( nId ); diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx index 99417a40dd9a..f3cfa0389441 100644 --- a/cui/source/tabpages/tpline.cxx +++ b/cui/source/tabpages/tpline.cxx @@ -1292,7 +1292,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) for(sal_Int32 a(0);!bSelected && a < m_pLineEndList->Count(); a++) { - XLineEndEntry* pEntry = m_pLineEndList->GetLineEnd(a); + const XLineEndEntry* pEntry = m_pLineEndList->GetLineEnd(a); const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd(); if(rItemPolygon == rEntryPolygon) @@ -1324,7 +1324,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) for(sal_Int32 a(0);!bSelected && a < m_pLineEndList->Count(); a++) { - XLineEndEntry* pEntry = m_pLineEndList->GetLineEnd(a); + const XLineEndEntry* pEntry = m_pLineEndList->GetLineEnd(a); const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd(); if(rItemPolygon == rEntryPolygon) diff --git a/cui/source/tabpages/tplnedef.cxx b/cui/source/tabpages/tplnedef.cxx index d689690cbf5b..701a43fd49ef 100644 --- a/cui/source/tabpages/tplnedef.cxx +++ b/cui/source/tabpages/tplnedef.cxx @@ -42,6 +42,7 @@ #include "svx/dlgutil.hxx" #include <svx/dialmgr.hxx> #include <svx/dialogs.hrc> +#include <o3tl/make_unique.hxx> #define XOUT_WIDTH 150 @@ -535,7 +536,6 @@ IMPL_LINK_NOARG_TYPED(SvxLineDefTabPage, ClickAddHdl_Impl, Button*, void) OUString aNewName( SVX_RES( RID_SVXSTR_LINESTYLE ) ); OUString aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE, rMgr ) ); OUString aName; - XDashEntry* pEntry; long nCount = pDashList->Count(); long j = 1; @@ -573,12 +573,9 @@ IMPL_LINK_NOARG_TYPED(SvxLineDefTabPage, ClickAddHdl_Impl, Button*, void) bLoop = false; FillDash_Impl(); - pEntry = new XDashEntry( aDash, aName ); - long nDashCount = pDashList->Count(); - pDashList->Insert( pEntry, nDashCount ); - const Bitmap aBitmap = pDashList->GetUiBitmap( nDashCount ); - m_pLbLineStyles->Append( *pEntry, pDashList->GetUiBitmap( nDashCount ) ); + pDashList->Insert( o3tl::make_unique<XDashEntry>(aDash, aName), nDashCount ); + m_pLbLineStyles->Append( *pDashList->GetDash(nDashCount), pDashList->GetUiBitmap(nDashCount) ); m_pLbLineStyles->SelectEntryPos( m_pLbLineStyles->GetEntryCount() - 1 ); @@ -651,10 +648,8 @@ IMPL_LINK_NOARG_TYPED(SvxLineDefTabPage, ClickModifyHdl_Impl, Button*, void) bLoop = false; FillDash_Impl(); - XDashEntry* pEntry = new XDashEntry( aDash, aName ); - - delete pDashList->Replace( pEntry, nPos ); - m_pLbLineStyles->Modify( *pEntry, nPos, pDashList->GetUiBitmap( nPos ) ); + pDashList->Replace(o3tl::make_unique<XDashEntry>(aDash, aName), nPos); + m_pLbLineStyles->Modify(*pDashList->GetDash(nPos), nPos, pDashList->GetUiBitmap(nPos)); m_pLbLineStyles->SelectEntryPos( nPos ); @@ -695,7 +690,7 @@ IMPL_LINK_NOARG_TYPED(SvxLineDefTabPage, ClickDeleteHdl_Impl, Button*, void) if ( aQueryBox->Execute() == RET_YES ) { - delete pDashList->Remove( nPos ); + pDashList->Remove(nPos); m_pLbLineStyles->RemoveEntry( nPos ); m_pLbLineStyles->SelectEntryPos( 0 ); diff --git a/cui/source/tabpages/tplneend.cxx b/cui/source/tabpages/tplneend.cxx index c52ebf02134f..8bbe4940c701 100644 --- a/cui/source/tabpages/tplneend.cxx +++ b/cui/source/tabpages/tplneend.cxx @@ -45,6 +45,8 @@ #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <svx/dialogs.hrc> +#include <o3tl/make_unique.hxx> + #define XOUT_WIDTH 150 SvxLineEndDefTabPage::SvxLineEndDefTabPage @@ -223,7 +225,7 @@ bool SvxLineEndDefTabPage::FillItemSet( SfxItemSet* rSet ) CheckChanges_Impl(); long nPos = m_pLbLineEnds->GetSelectEntryPos(); - XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); + const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nPos); rSet->Put( XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ) ); rSet->Put( XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ) ); @@ -242,7 +244,7 @@ void SvxLineEndDefTabPage::Reset( const SfxItemSet* ) { int nPos = m_pLbLineEnds->GetSelectEntryPos(); - XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); + const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nPos); m_pEdtName->SetText( m_pLbLineEnds->GetSelectEntry() ); @@ -283,7 +285,7 @@ IMPL_LINK_NOARG_TYPED(SvxLineEndDefTabPage, SelectLineEndHdl_Impl, ListBox&, voi { int nPos = m_pLbLineEnds->GetSelectEntryPos(); - XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); + const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nPos); m_pEdtName->SetText( m_pLbLineEnds->GetSelectEntry() ); @@ -360,17 +362,16 @@ IMPL_LINK_NOARG_TYPED(SvxLineEndDefTabPage, ClickModifyHdl_Impl, Button*, void) // if not existing, enter the entry if( bDifferent ) { - const XLineEndEntry* pOldEntry = pLineEndList->GetLineEnd( nPos ); + const XLineEndEntry* pOldEntry = pLineEndList->GetLineEnd(nPos); if(pOldEntry) { - // #123497# Need to replace the existing entry with a new one (old returned needs to be deleted) - XLineEndEntry* pEntry = new XLineEndEntry(pOldEntry->GetLineEnd(), aName); - delete pLineEndList->Replace(pEntry, nPos); + // #123497# Need to replace the existing entry with a new one + pLineEndList->Replace(o3tl::make_unique<XLineEndEntry>(pOldEntry->GetLineEnd(), aName), nPos); m_pEdtName->SetText( aName ); - m_pLbLineEnds->Modify( *pEntry, nPos, pLineEndList->GetUiBitmap( nPos ) ); + m_pLbLineEnds->Modify(*pLineEndList->GetLineEnd(nPos), nPos, pLineEndList->GetUiBitmap(nPos)); m_pLbLineEnds->SelectEntryPos( nPos ); // Flag fuer modifiziert setzen @@ -422,8 +423,6 @@ IMPL_LINK_NOARG_TYPED(SvxLineEndDefTabPage, ClickAddHdl_Impl, Button*, void) SdrObject::Free( pConvPolyObj ); - XLineEndEntry* pEntry; - ResMgr& rMgr = CUI_MGR(); OUString aNewName( SVX_RES( RID_SVXSTR_LINEEND ) ); OUString aDesc( ResId( RID_SVXSTR_DESC_LINEEND, rMgr ) ); @@ -463,13 +462,12 @@ IMPL_LINK_NOARG_TYPED(SvxLineEndDefTabPage, ClickAddHdl_Impl, Button*, void) if( bDifferent ) { bLoop = false; - pEntry = new XLineEndEntry( aNewPolyPolygon, aName ); long nLineEndCount = pLineEndList->Count(); - pLineEndList->Insert( pEntry, nLineEndCount ); + pLineEndList->Insert(o3tl::make_unique<XLineEndEntry>(aNewPolyPolygon, aName), nLineEndCount); // add to the ListBox - m_pLbLineEnds->Append( *pEntry, pLineEndList->GetUiBitmap( nLineEndCount ) ); + m_pLbLineEnds->Append(*pLineEndList->GetLineEnd(nLineEndCount), pLineEndList->GetUiBitmap(nLineEndCount)); m_pLbLineEnds->SelectEntryPos( m_pLbLineEnds->GetEntryCount() - 1 ); *pnLineEndListState |= ChangeType::MODIFIED; @@ -510,7 +508,7 @@ IMPL_LINK_NOARG_TYPED(SvxLineEndDefTabPage, ClickDeleteHdl_Impl, Button*, void) if ( aQueryBox->Execute() == RET_YES ) { - delete pLineEndList->Remove( nPos ); + pLineEndList->Remove(nPos); m_pLbLineEnds->RemoveEntry( nPos ); m_pLbLineEnds->SelectEntryPos( 0 ); diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx index 10fcf5d6e86d..92a0edfb96f8 100644 --- a/cui/source/tabpages/tppattern.cxx +++ b/cui/source/tabpages/tppattern.cxx @@ -47,6 +47,8 @@ #include "sfx2/opengrf.hxx" #include "paragrph.hrc" +#include <o3tl/make_unique.hxx> + using namespace com::sun::star; /************************************************************************* @@ -523,12 +525,12 @@ IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ClickAddHdl_Impl, Button*, void) if( !nError ) { - XBitmapEntry* pEntry = nullptr; + std::unique_ptr<XBitmapEntry> pEntry; if( m_pCtlPixel->IsEnabled() ) { const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx()); - pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName); + pEntry.reset(new XBitmapEntry(Graphic(aBitmapEx), aName)); } else // it must be a not existing imported bitmap { @@ -536,15 +538,15 @@ IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ClickAddHdl_Impl, Button*, void) if(SfxItemState::SET == m_rOutAttrs.GetItemState(XATTR_FILLBITMAP, true, &pPoolItem)) { - pEntry = new XBitmapEntry(dynamic_cast< const XFillBitmapItem* >(pPoolItem)->GetGraphicObject(), aName); + pEntry.reset(new XBitmapEntry(dynamic_cast<const XFillBitmapItem*>(pPoolItem)->GetGraphicObject(), aName)); } + else + assert("SvxPatternTabPage::ClickAddHdl_Impl(), XBitmapEntry* pEntry == nullptr ?"); } - assert( pEntry && "SvxPatternTabPage::ClickAddHdl_Impl(), pEntry == 0 ?" ); - if( pEntry ) { - m_pPatternList->Insert( pEntry, nCount ); + m_pPatternList->Insert(std::move(pEntry), nCount); sal_Int32 nId = m_pPatternLB->GetItemId( nCount - 1 ); Bitmap aBitmap = m_pPatternList->GetBitmapForPreview( nCount, m_pPatternLB->GetIconSize() ); m_pPatternLB->InsertItem( nId + 1, Image(aBitmap), aName ); @@ -581,8 +583,7 @@ IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ClickModifyHdl_Impl, Button*, void) const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx()); // #i123497# Need to replace the existing entry with a new one (old returned needs to be deleted) - XBitmapEntry* pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName); - delete m_pPatternList->Replace(pEntry, nPos); + m_pPatternList->Replace(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmapEx), aName), nPos); Bitmap aBitmap = m_pPatternList->GetBitmapForPreview( static_cast<sal_uInt16>( nPos ), m_pPatternLB->GetIconSize() ); m_pPatternLB->RemoveItem(nId); @@ -632,8 +633,7 @@ IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, { bLoop = false; - XBitmapEntry* pEntry = m_pPatternList->GetBitmap( static_cast<sal_uInt16>(nPos) ); - pEntry->SetName( aName ); + m_pPatternList->GetBitmap(nPos)->SetName(aName); m_pPatternLB->SetItemText( nId, aName ); m_pPatternLB->SelectItem( nId ); @@ -666,7 +666,7 @@ IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ClickDeleteHdl_Impl, SvxPresetListBox*, if( aQueryBox->Execute() == RET_YES ) { - delete m_pPatternList->Remove( static_cast<sal_uInt16>(nPos) ); + m_pPatternList->Remove(nPos); m_pPatternLB->RemoveItem( nId ); nId = m_pPatternLB->GetItemId(0); m_pPatternLB->SelectItem( nId ); |