summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-12-19 16:30:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-12-20 10:56:01 +0100
commit1b7bcaa714f0af45c6a9660d1f0940cb7931ba0f (patch)
tree8623a38ea87f23b549599ba4a1195bb8eaf17a36
parent146f98e7100ae57ced080c7d9fa028f01df99ca8 (diff)
use unique_ptr in svx
Change-Id: Ib0dd1edf05470783da41f08767020a9009f356ad Reviewed-on: https://gerrit.libreoffice.org/65444 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--svx/source/form/datanavi.cxx16
-rw-r--r--svx/source/gallery2/galbrws2.cxx12
-rw-r--r--svx/source/inc/datanavi.hxx2
-rw-r--r--svx/source/sdr/primitive2d/sdrdecompositiontools.cxx45
-rw-r--r--svx/source/sdr/properties/textproperties.cxx6
-rw-r--r--svx/source/svdraw/svdpagv.cxx13
6 files changed, 41 insertions, 53 deletions
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
index 3e7eaeb30ec0..85a4a70eb0cf 100644
--- a/svx/source/form/datanavi.cxx
+++ b/svx/source/form/datanavi.cxx
@@ -512,7 +512,7 @@ namespace svxform
{
DataItemType eType = DITElement;
SvTreeListEntry* pEntry = m_pItemList->FirstSelected();
- ItemNode* pNode = nullptr;
+ std::unique_ptr<ItemNode> pNode;
Reference< css::xml::dom::XNode > xParentNode;
Reference< XPropertySet > xNewBinding;
const char* pResId = nullptr;
@@ -597,7 +597,7 @@ namespace svxform
{
SAL_WARN( "svx.form", "XFormsPage::DoToolBoxAction(): exception while get binding for node" );
}
- pNode = new ItemNode( xNewNode );
+ pNode.reset(new ItemNode( xNewNode ));
}
else
{
@@ -607,7 +607,7 @@ namespace svxform
xNewBinding = xModel->createBinding();
Reference< XSet > xBindings( xModel->getBindings(), UNO_QUERY );
xBindings->insert( makeAny( xNewBinding ) );
- pNode = new ItemNode( xNewBinding );
+ pNode.reset(new ItemNode( xNewBinding ));
eType = DITBinding;
}
catch ( Exception& )
@@ -616,7 +616,7 @@ namespace svxform
}
}
- ScopedVclPtrInstance< AddDataItemDialog > aDlg( this, pNode, m_xUIHelper );
+ ScopedVclPtrInstance< AddDataItemDialog > aDlg( this, pNode.get(), m_xUIHelper );
aDlg->SetText( SvxResId( pResId ) );
aDlg->InitText( eType );
short nReturn = aDlg->Execute();
@@ -624,7 +624,7 @@ namespace svxform
{
if ( RET_OK == nReturn )
{
- SvTreeListEntry* pNewEntry = AddEntry( pNode, bIsElement );
+ SvTreeListEntry* pNewEntry = AddEntry( std::move(pNode), bIsElement );
m_pItemList->MakeVisible( pNewEntry );
m_pItemList->Select( pNewEntry );
bIsDocModified = true;
@@ -639,7 +639,6 @@ namespace svxform
if ( xNode.is() )
xPNode = xNode->getParentNode();
DBG_ASSERT( !xPNode.is(), "XFormsPage::RemoveEntry(): node not removed" );
- delete pNode;
}
catch ( Exception& )
{
@@ -667,7 +666,6 @@ namespace svxform
SAL_WARN( "svx.form", "XFormsPage::DoToolboxAction(): exception caught" );
}
}
- delete pNode;
}
}
}
@@ -787,7 +785,7 @@ namespace svxform
return bHandled;
}
- SvTreeListEntry* XFormsPage::AddEntry( ItemNode* _pNewNode, bool _bIsElement )
+ SvTreeListEntry* XFormsPage::AddEntry( std::unique_ptr<ItemNode> _pNewNode, bool _bIsElement )
{
SvTreeListEntry* pParent = m_pItemList->FirstSelected();
Image aImage(StockImage::Yes, _bIsElement ? OUString(RID_SVXBMP_ELEMENT) : OUString(RID_SVXBMP_ATTRIBUTE));
@@ -802,7 +800,7 @@ namespace svxform
DBG_UNHANDLED_EXCEPTION("svx");
}
return m_pItemList->InsertEntry(
- sName, aImage, aImage, pParent, false, TREELIST_APPEND, _pNewNode );
+ sName, aImage, aImage, pParent, false, TREELIST_APPEND, _pNewNode.release() );
}
SvTreeListEntry* XFormsPage::AddEntry( const Reference< XPropertySet >& _rEntry )
diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx
index 1e89c6cc4801..83b0bead0f04 100644
--- a/svx/source/gallery2/galbrws2.cxx
+++ b/svx/source/gallery2/galbrws2.cxx
@@ -214,14 +214,14 @@ void GalleryThemePopup::Execute(
{
if ( rCmdInfo.Dispatch.is() )
{
- DispatchInfo *pInfo = new DispatchInfo;
+ std::unique_ptr<DispatchInfo> pInfo(new DispatchInfo);
pInfo->TargetURL = rCmdInfo.URL;
pInfo->Arguments = rArguments;
pInfo->Dispatch = rCmdInfo.Dispatch;
if ( !Application::PostUserEvent(
- LINK( nullptr, GalleryBrowser2, AsyncDispatch_Impl), pInfo ) )
- delete pInfo;
+ LINK( nullptr, GalleryBrowser2, AsyncDispatch_Impl), pInfo.get() ) )
+ pInfo.reset();
}
}
@@ -1076,14 +1076,14 @@ void GalleryBrowser2::DispatchAdd(
aArgs[0].Name = SVXGALLERYITEM_ARGNAME;
aArgs[0].Value <<= aSeq;
- DispatchInfo *pInfo = new DispatchInfo;
+ std::unique_ptr<DispatchInfo> pInfo(new DispatchInfo);
pInfo->TargetURL = aURL;
pInfo->Arguments = aArgs;
pInfo->Dispatch = xDispatch;
if ( !Application::PostUserEvent(
- LINK( nullptr, GalleryBrowser2, AsyncDispatch_Impl), pInfo ) )
- delete pInfo;
+ LINK( nullptr, GalleryBrowser2, AsyncDispatch_Impl), pInfo.get() ) )
+ pInfo.reset();
}
void GalleryBrowser2::Execute(const OString &rIdent)
diff --git a/svx/source/inc/datanavi.hxx b/svx/source/inc/datanavi.hxx
index 8a3c89362662..d448f999bd49 100644
--- a/svx/source/inc/datanavi.hxx
+++ b/svx/source/inc/datanavi.hxx
@@ -246,7 +246,7 @@ namespace svxform
void AddChildren(SvTreeListEntry* _pParent,
const css::uno::Reference< css::xml::dom::XNode >& _xNode);
bool DoToolBoxAction( sal_uInt16 _nToolBoxID );
- SvTreeListEntry* AddEntry( ItemNode* _pNewNode, bool _bIsElement );
+ SvTreeListEntry* AddEntry( std::unique_ptr<ItemNode> _pNewNode, bool _bIsElement );
SvTreeListEntry* AddEntry( const css::uno::Reference< css::beans::XPropertySet >& _rPropSet );
void EditEntry( const css::uno::Reference< css::beans::XPropertySet >& _rPropSet );
bool RemoveEntry();
diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
index a1acce939be0..6787e0d5a322 100644
--- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -195,7 +195,7 @@ namespace drawinglayer
bool bWordWrap)
{
basegfx::B2DHomMatrix aAnchorTransform(rObjectTransform);
- SdrTextPrimitive2D* pNew = nullptr;
+ std::unique_ptr<SdrTextPrimitive2D> pNew;
if(rText.isContour())
{
@@ -223,20 +223,20 @@ namespace drawinglayer
0.0 != aScale.getY() ? 1.0 / aScale.getY() : 1.0));
// create with unit polygon
- pNew = new SdrContourTextPrimitive2D(
+ pNew.reset(new SdrContourTextPrimitive2D(
&rText.getSdrText(),
rText.getOutlinerParaObject(),
aScaledUnitPolyPolygon,
- rObjectTransform);
+ rObjectTransform));
}
else
{
// create with unit polygon
- pNew = new SdrContourTextPrimitive2D(
+ pNew.reset(new SdrContourTextPrimitive2D(
&rText.getSdrText(),
rText.getOutlinerParaObject(),
rUnitPolyPolygon,
- rObjectTransform);
+ rObjectTransform));
}
}
else if(!rText.getSdrFormTextAttribute().isDefault())
@@ -244,11 +244,11 @@ namespace drawinglayer
// text on path, use scaled polygon
basegfx::B2DPolyPolygon aScaledPolyPolygon(rUnitPolyPolygon);
aScaledPolyPolygon.transform(rObjectTransform);
- pNew = new SdrPathTextPrimitive2D(
+ pNew.reset(new SdrPathTextPrimitive2D(
&rText.getSdrText(),
rText.getOutlinerParaObject(),
aScaledPolyPolygon,
- rText.getSdrFormTextAttribute());
+ rText.getSdrFormTextAttribute()));
}
else
{
@@ -298,32 +298,32 @@ namespace drawinglayer
if(rText.isFitToSize())
{
// stretched text in range
- pNew = new SdrStretchTextPrimitive2D(
+ pNew.reset(new SdrStretchTextPrimitive2D(
&rText.getSdrText(),
rText.getOutlinerParaObject(),
aAnchorTransform,
- rText.isFixedCellHeight());
+ rText.isFixedCellHeight()));
}
else if(rText.isAutoFit())
{
// isotropically scaled text in range
- pNew = new SdrAutoFitTextPrimitive2D(
+ pNew.reset(new SdrAutoFitTextPrimitive2D(
&rText.getSdrText(),
rText.getOutlinerParaObject(),
aAnchorTransform,
- bWordWrap);
+ bWordWrap));
}
else if( rText.isChainable() && !rText.isInEditMode() )
{
- pNew = new SdrChainedTextPrimitive2D(
+ pNew.reset(new SdrChainedTextPrimitive2D(
&rText.getSdrText(),
rText.getOutlinerParaObject(),
- aAnchorTransform );
+ aAnchorTransform ));
}
else // text in range
{
// build new primitive
- pNew = new SdrBlockTextPrimitive2D(
+ pNew.reset(new SdrBlockTextPrimitive2D(
&rText.getSdrText(),
rText.getOutlinerParaObject(),
aAnchorTransform,
@@ -333,7 +333,7 @@ namespace drawinglayer
rText.isScroll(),
bCellText,
bWordWrap,
- false/*bClipOnBounds*/);
+ false/*bClipOnBounds*/));
}
}
@@ -348,7 +348,7 @@ namespace drawinglayer
if(0.0 != aAnimationList.getDuration())
{
// create content sequence
- const Primitive2DReference xRefA(pNew);
+ const Primitive2DReference xRefA(pNew.release());
const Primitive2DContainer aContent { xRefA };
// create and add animated switch primitive
@@ -357,7 +357,7 @@ namespace drawinglayer
else
{
// add to decomposition
- return Primitive2DReference(pNew);
+ return Primitive2DReference(pNew.release());
}
}
@@ -384,8 +384,7 @@ namespace drawinglayer
// bring the primitive back to scaled only and get scaled range, create new clone for this
std::unique_ptr<SdrTextPrimitive2D> pNew2 = pNew->createTransformedClone(aISRT);
OSL_ENSURE(pNew2, "createTextPrimitive: Could not create transformed clone of text primitive (!)");
- delete pNew;
- pNew = pNew2.release();
+ pNew = std::move(pNew2);
// create neutral geometry::ViewInformation2D for local range and decompose calls. This is okay
// since the decompose is view-independent
@@ -439,7 +438,7 @@ namespace drawinglayer
// pNew to aNewPrimitiveSequence)
Primitive2DContainer aAnimSequence;
pNew->get2DDecomposition(aAnimSequence, aViewInformation2D);
- delete pNew;
+ pNew.reset();
// create a new animatedInterpolatePrimitive and add it
std::vector< basegfx::B2DHomMatrix > aMatrixStack;
@@ -457,7 +456,7 @@ namespace drawinglayer
else
{
// add to decomposition
- return Primitive2DReference(pNew);
+ return Primitive2DReference(pNew.release());
}
}
}
@@ -467,7 +466,7 @@ namespace drawinglayer
// #i97628#
// encapsulate with TextHierarchyEditPrimitive2D to allow renderers
// to suppress actively edited content if needed
- const Primitive2DReference xRefA(pNew);
+ const Primitive2DReference xRefA(pNew.release());
const Primitive2DContainer aContent { xRefA };
// create and add TextHierarchyEditPrimitive2D primitive
@@ -476,7 +475,7 @@ namespace drawinglayer
else
{
// add to decomposition
- return Primitive2DReference(pNew);
+ return Primitive2DReference(pNew.release());
}
}
diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx
index 7aeacdf7e3fc..e65995f92371 100644
--- a/svx/source/sdr/properties/textproperties.cxx
+++ b/svx/source/sdr/properties/textproperties.cxx
@@ -261,13 +261,13 @@ namespace sdr
{
for(sal_Int32 nPara = 0; nPara < nParaCount; nPara++)
{
- SfxItemSet* pTempSet = nullptr;
+ std::unique_ptr<SfxItemSet> pTempSet;
// since setting the stylesheet removes all para attributes
if(bDontRemoveHardAttr)
{
// we need to remember them if we want to keep them
- pTempSet = new SfxItemSet(rOutliner.GetParaAttribs(nPara));
+ pTempSet.reset(new SfxItemSet(rOutliner.GetParaAttribs(nPara)));
}
if(GetStyleSheet())
@@ -333,8 +333,6 @@ namespace sdr
}
}
}
-
- delete pTempSet;
}
std::unique_ptr<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount);
diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index c180fe9b459e..c0499dbe8938 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -239,25 +239,18 @@ void SdrPageView::CompleteRedraw(
if(GetPage())
{
SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow);
- bool bIsTempTarget(false);
+ std::unique_ptr<SdrPageWindow> pTempPageWindow;
if(!pPageWindow)
{
// create temp PageWindow
- pPageWindow = new SdrPageWindow(*this, rPaintWindow);
- bIsTempTarget = true;
+ pTempPageWindow.reset(new SdrPageWindow(*this, rPaintWindow));
+ pPageWindow = pTempPageWindow.get();
}
// do the redraw
pPageWindow->PrepareRedraw(rReg);
pPageWindow->RedrawAll(pRedirector);
-
- // get rid of temp PageWindow
- if(bIsTempTarget)
- {
- delete pPageWindow;
- pPageWindow = nullptr;
- }
}
}