summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-07-26 14:49:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-07-27 09:31:31 +0200
commit877dd9e9d1c1774817fa96f62adda98d5bce0ce8 (patch)
tree484ef7b0ea47d0fd396d73bed5fbce94d3f79d98
parent8d11d68c25baaab08f30d4e0a24753ac43ab90b0 (diff)
Related: rhbz#1602589 fix leaked_storage
no logic change intended Change-Id: Ic4d54965033e518195ef8e76ddec7feca14970c2 Reviewed-on: https://gerrit.libreoffice.org/58125 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sd/source/ui/unoidl/unosrch.cxx71
1 files changed, 24 insertions, 47 deletions
diff --git a/sd/source/ui/unoidl/unosrch.cxx b/sd/source/ui/unoidl/unosrch.cxx
index c46753cfc4b9..7233d37d3b77 100644
--- a/sd/source/ui/unoidl/unosrch.cxx
+++ b/sd/source/ui/unoidl/unosrch.cxx
@@ -54,11 +54,10 @@ class SearchContext_impl
{
uno::Reference< drawing::XShapes > mxShapes;
sal_Int32 mnIndex;
- SearchContext_impl* mpParent;
public:
- SearchContext_impl( uno::Reference< drawing::XShapes > const & xShapes, SearchContext_impl* pParent = nullptr )
- : mxShapes( xShapes ), mnIndex( -1 ), mpParent( pParent ) {}
+ SearchContext_impl(uno::Reference<drawing::XShapes> const& xShapes)
+ : mxShapes( xShapes ), mnIndex( -1 ) {}
uno::Reference< drawing::XShape > firstShape()
{
@@ -76,8 +75,6 @@ public:
}
return xShape;
}
-
- SearchContext_impl* getParent() const { return mpParent; }
};
/* ================================================================= */
@@ -111,7 +108,7 @@ sal_Int32 SAL_CALL SdUnoSearchReplaceShape::replaceAll( const uno::Reference< ut
uno::Reference< drawing::XShapes > xShapes;
uno::Reference< drawing::XShape > xShape;
- SearchContext_impl* pContext = nullptr;
+ std::vector<SearchContext_impl> aContexts;
if(mpPage)
{
uno::Reference< drawing::XDrawPage > xPage( mpPage );
@@ -120,8 +117,8 @@ sal_Int32 SAL_CALL SdUnoSearchReplaceShape::replaceAll( const uno::Reference< ut
if( xShapes.is() && (xShapes->getCount() > 0) )
{
- pContext = new SearchContext_impl( xShapes );
- xShape = pContext->firstShape();
+ aContexts.push_back(SearchContext_impl(xShapes));
+ xShape = aContexts.back().firstShape();
}
else
{
@@ -152,34 +149,24 @@ sal_Int32 SAL_CALL SdUnoSearchReplaceShape::replaceAll( const uno::Reference< ut
uno::Reference< drawing::XShapes > xGroupShape( xShape, uno::UNO_QUERY );
if( xGroupShape.is() && ( xGroupShape->getCount() > 0 ) )
{
- pContext = new SearchContext_impl( xGroupShape, pContext );
- xShape = pContext->firstShape();
+ aContexts.push_back(SearchContext_impl(xGroupShape));
+ xShape = aContexts.back().firstShape();
}
else
{
- if( pContext )
- xShape = pContext->nextShape();
+ if (!aContexts.empty())
+ xShape = aContexts.back().nextShape();
else
xShape = nullptr;
}
// test parent contexts for next shape if none
// is found in the current context
- while( pContext && !xShape.is() )
+ while (!aContexts.empty() && !xShape.is())
{
- if( pContext->getParent() )
- {
- SearchContext_impl* pOldContext = pContext;
- pContext = pContext->getParent();
- delete pOldContext;
- xShape = pContext->nextShape();
- }
- else
- {
- delete pContext;
- pContext = nullptr;
- xShape = nullptr;
- }
+ aContexts.pop_back();
+ if (!aContexts.empty())
+ xShape = aContexts.back().nextShape();
}
}
@@ -208,7 +195,7 @@ uno::Reference< css::container::XIndexAccess > SAL_CALL SdUnoSearchReplaceShape:
uno::Reference< drawing::XShapes > xShapes;
uno::Reference< drawing::XShape > xShape;
- SearchContext_impl* pContext = nullptr;
+ std::vector<SearchContext_impl> aContexts;
if(mpPage)
{
uno::Reference< drawing::XDrawPage > xPage( mpPage );
@@ -216,8 +203,8 @@ uno::Reference< css::container::XIndexAccess > SAL_CALL SdUnoSearchReplaceShape:
if( xShapes.is() && xShapes->getCount() > 0 )
{
- pContext = new SearchContext_impl( xShapes );
- xShape = pContext->firstShape();
+ aContexts.push_back(SearchContext_impl(xShapes));
+ xShape = aContexts.back().firstShape();
}
else
{
@@ -257,34 +244,24 @@ uno::Reference< css::container::XIndexAccess > SAL_CALL SdUnoSearchReplaceShape:
if( xGroupShape.is() && xGroupShape->getCount() > 0 )
{
- pContext = new SearchContext_impl( xGroupShape, pContext );
- xShape = pContext->firstShape();
+ aContexts.push_back(SearchContext_impl(xGroupShape));
+ xShape = aContexts.back().firstShape();
}
else
{
- if( pContext )
- xShape = pContext->nextShape();
+ if (!aContexts.empty())
+ xShape = aContexts.back().nextShape();
else
xShape = nullptr;
}
// test parent contexts for next shape if none
// is found in the current context
- while( pContext && !xShape.is() )
+ while (!aContexts.empty() && !xShape.is())
{
- if( pContext->getParent() )
- {
- SearchContext_impl* pOldContext = pContext;
- pContext = pContext->getParent();
- delete pOldContext;
- xShape = pContext->nextShape();
- }
- else
- {
- delete pContext;
- pContext = nullptr;
- xShape = nullptr;
- }
+ aContexts.pop_back();
+ if (!aContexts.empty())
+ xShape = aContexts.back().nextShape();
}
}