From 63058a4f2b0809748d43c7f45dcf85dbcd1dfcb7 Mon Sep 17 00:00:00 2001 From: Noel Date: Fri, 19 Feb 2021 11:26:46 +0200 Subject: loplugin:refcounting in unoxml Change-Id: I979b309271809b64d6f04cbccd14e0ee3b09ec81 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111198 Tested-by: Jenkins Reviewed-by: Noel Grandin --- unoxml/source/dom/document.cxx | 4 ++-- unoxml/source/dom/element.cxx | 5 ++--- unoxml/source/events/eventdispatcher.cxx | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx index db93dcad847a..27db21ebe09b 100644 --- a/unoxml/source/dom/document.cxx +++ b/unoxml/source/dom/document.cxx @@ -937,7 +937,7 @@ namespace DOM Reference< XEvent > SAL_CALL CDocument::createEvent(const OUString& aType) { // does not need mutex currently - events::CEvent *pEvent = nullptr; + rtl::Reference pEvent; if ( aType == "DOMSubtreeModified" || aType == "DOMNodeInserted" || aType == "DOMNodeRemoved" || aType == "DOMNodeRemovedFromDocument" || aType == "DOMNodeInsertedIntoDocument" || aType == "DOMAttrModified" || aType == "DOMCharacterDataModified") @@ -956,7 +956,7 @@ namespace DOM { pEvent = new events::CEvent; } - return Reference< XEvent >(pEvent); + return pEvent; } // css::xml::sax::XSAXSerializable diff --git a/unoxml/source/dom/element.cxx b/unoxml/source/dom/element.cxx index 988d7f1b9c32..e82f2edab4f2 100644 --- a/unoxml/source/dom/element.cxx +++ b/unoxml/source/dom/element.cxx @@ -56,7 +56,7 @@ namespace DOM void CElement::saxify(const Reference< XDocumentHandler >& i_xHandler) { if (!i_xHandler.is()) throw RuntimeException(); - comphelper::AttributeList *pAttrs = + rtl::Reference pAttrs = new comphelper::AttributeList(); OUString type = ""; // add namespace definitions to attributes @@ -90,8 +90,7 @@ namespace DOM OUString name = (prefix.isEmpty()) ? getLocalName() : prefix + ":" + getLocalName(); - Reference< XAttributeList > xAttrList(pAttrs); - i_xHandler->startElement(name, xAttrList); + i_xHandler->startElement(name, pAttrs); // recurse for (xmlNodePtr pChild = m_aNodePtr->children; pChild != nullptr; pChild = pChild->next) { diff --git a/unoxml/source/events/eventdispatcher.cxx b/unoxml/source/events/eventdispatcher.cxx index fc396ee9dc76..201f682f7d66 100644 --- a/unoxml/source/events/eventdispatcher.cxx +++ b/unoxml/source/events/eventdispatcher.cxx @@ -117,7 +117,7 @@ namespace DOM::events { if (captureListeners.empty() && targetListeners.empty()) return; - CEvent *pEvent = nullptr; // pointer to internal event representation + rtl::Reference pEvent; // pointer to internal event representation OUString const aType = i_xEvent->getType(); if (aType == "DOMSubtreeModified" || @@ -133,7 +133,7 @@ namespace DOM::events { // dispatch a mutation event // we need to clone the event in order to have complete control // over the implementation - CMutationEvent* pMEvent = new CMutationEvent; + rtl::Reference pMEvent = new CMutationEvent; pMEvent->initMutationEvent( aType, aMEvent->getBubbles(), aMEvent->getCancelable(), aMEvent->getRelatedNode(), aMEvent->getPrevValue(), @@ -146,7 +146,7 @@ namespace DOM::events { aType == "DOMActivate" ) { Reference< XUIEvent > const aUIEvent(i_xEvent, UNO_QUERY_THROW); - CUIEvent* pUIEvent = new CUIEvent; + rtl::Reference pUIEvent = new CUIEvent; pUIEvent->initUIEvent(aType, aUIEvent->getBubbles(), aUIEvent->getCancelable(), aUIEvent->getView(), aUIEvent->getDetail()); @@ -161,7 +161,7 @@ namespace DOM::events { { Reference< XMouseEvent > const aMouseEvent(i_xEvent, UNO_QUERY_THROW); - CMouseEvent *pMouseEvent = new CMouseEvent; + rtl::Reference pMouseEvent = new CMouseEvent; pMouseEvent->initMouseEvent(aType, aMouseEvent->getBubbles(), aMouseEvent->getCancelable(), aMouseEvent->getView(), aMouseEvent->getDetail(), -- cgit