summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-02-22 19:45:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-23 08:39:44 +0100
commitd678a580419dda0b2b3d9ef13b027c769ac7b71b (patch)
tree8895491db3ebab670620bc03f6ea555e8d18ca34 /comphelper
parentc2a0896183f33fab5f643400b171b031af5e468e (diff)
loplugin:refcounting in comphelper
Change-Id: Ie3e1fcdbdbd01448a9eea23a899a924e6b626257 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111354 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/docpasswordhelper.cxx5
-rw-r--r--comphelper/source/xml/attributelist.cxx3
-rw-r--r--comphelper/source/xml/ofopxmlhelper.cxx31
3 files changed, 16 insertions, 23 deletions
diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx
index bd8ce5d7de7f..cd7090944dc0 100644
--- a/comphelper/source/misc/docpasswordhelper.cxx
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -494,9 +494,8 @@ OUString DocPasswordHelper::GetOoxHashAsBase64(
PasswordRequestMode eRequestMode = PasswordRequestMode_PASSWORD_ENTER;
while( eResult == DocPasswordVerifierResult::WrongPassword )
{
- DocPasswordRequest* pRequest = new DocPasswordRequest( eRequestType, eRequestMode, rDocumentUrl );
- Reference< XInteractionRequest > xRequest( pRequest );
- rxInteractHandler->handle( xRequest );
+ rtl::Reference<DocPasswordRequest> pRequest = new DocPasswordRequest( eRequestType, eRequestMode, rDocumentUrl );
+ rxInteractHandler->handle( pRequest );
if( pRequest->isPassword() )
{
if( !pRequest->getPassword().isEmpty() )
diff --git a/comphelper/source/xml/attributelist.cxx b/comphelper/source/xml/attributelist.cxx
index d99139c852ea..a02c82f69465 100644
--- a/comphelper/source/xml/attributelist.cxx
+++ b/comphelper/source/xml/attributelist.cxx
@@ -65,8 +65,7 @@ AttributeList::~AttributeList()
css::uno::Reference< css::util::XCloneable > AttributeList::createClone()
{
- AttributeList *p = new AttributeList( *this );
- return css::uno::Reference< css::util::XCloneable > ( static_cast<css::util::XCloneable *>(p) );
+ return new AttributeList( *this );
}
} // namespace comphelper
diff --git a/comphelper/source/xml/ofopxmlhelper.cxx b/comphelper/source/xml/ofopxmlhelper.cxx
index 2da35bdd0a3a..10840368d976 100644
--- a/comphelper/source/xml/ofopxmlhelper.cxx
+++ b/comphelper/source/xml/ofopxmlhelper.cxx
@@ -22,6 +22,7 @@
#include <comphelper/attributelist.hxx>
#include <cppuhelper/implbase.hxx>
+#include <rtl/ref.hxx>
#include <com/sun/star/beans/StringPair.hpp>
#include <com/sun/star/xml/sax/Parser.hpp>
@@ -145,20 +146,18 @@ void WriteRelationsInfoSequence(
OUString aWhiteSpace( " " );
// write the namespace
- AttributeList* pRootAttrList = new AttributeList;
- uno::Reference< css::xml::sax::XAttributeList > xRootAttrList( pRootAttrList );
+ rtl::Reference<AttributeList> pRootAttrList = new AttributeList;
pRootAttrList->AddAttribute(
"xmlns",
aCDATAString,
"http://schemas.openxmlformats.org/package/2006/relationships" );
xWriter->startDocument();
- xWriter->startElement( aRelListElement, xRootAttrList );
+ xWriter->startElement( aRelListElement, pRootAttrList );
for ( const auto & i : aSequence )
{
- AttributeList *pAttrList = new AttributeList;
- uno::Reference< css::xml::sax::XAttributeList > xAttrList( pAttrList );
+ rtl::Reference<AttributeList> pAttrList = new AttributeList;
for( const beans::StringPair & pair : i )
{
if ( !(pair.First == "Id"
@@ -172,7 +171,7 @@ void WriteRelationsInfoSequence(
pAttrList->AddAttribute( pair.First, aCDATAString, pair.Second );
}
- xWriter->startElement( aRelElement, xAttrList );
+ xWriter->startElement( aRelElement, pAttrList );
xWriter->ignorableWhitespace( aWhiteSpace );
xWriter->endElement( aRelElement );
}
@@ -204,36 +203,33 @@ void WriteContentSequence(
static constexpr OUStringLiteral aWhiteSpace(u" ");
// write the namespace
- AttributeList* pRootAttrList = new AttributeList;
- uno::Reference< css::xml::sax::XAttributeList > xRootAttrList( pRootAttrList );
+ rtl::Reference<AttributeList> pRootAttrList = new AttributeList;
pRootAttrList->AddAttribute(
"xmlns",
aCDATAString,
"http://schemas.openxmlformats.org/package/2006/content-types" );
xWriter->startDocument();
- xWriter->startElement( aTypesElement, xRootAttrList );
+ xWriter->startElement( aTypesElement, pRootAttrList );
for ( const beans::StringPair & pair : aDefaultsSequence )
{
- AttributeList *pAttrList = new AttributeList;
- uno::Reference< css::xml::sax::XAttributeList > xAttrList( pAttrList );
+ rtl::Reference<AttributeList> pAttrList = new AttributeList;
pAttrList->AddAttribute( "Extension", aCDATAString, pair.First );
pAttrList->AddAttribute( aContentTypeAttr, aCDATAString, pair.Second );
- xWriter->startElement( aDefaultElement, xAttrList );
+ xWriter->startElement( aDefaultElement, pAttrList );
xWriter->ignorableWhitespace( aWhiteSpace );
xWriter->endElement( aDefaultElement );
}
for ( const beans::StringPair & pair : aOverridesSequence )
{
- AttributeList *pAttrList = new AttributeList;
- uno::Reference< css::xml::sax::XAttributeList > xAttrList( pAttrList );
+ rtl::Reference<AttributeList> pAttrList = new AttributeList;
pAttrList->AddAttribute( "PartName", aCDATAString, pair.First );
pAttrList->AddAttribute( aContentTypeAttr, aCDATAString, pair.Second );
- xWriter->startElement( aOverrideElement, xAttrList );
+ xWriter->startElement( aOverrideElement, pAttrList );
xWriter->ignorableWhitespace( aWhiteSpace );
xWriter->endElement( aOverrideElement );
}
@@ -254,12 +250,11 @@ uno::Sequence< uno::Sequence< beans::StringPair > > ReadSequence_Impl(
uno::Reference< css::xml::sax::XParser > xParser = css::xml::sax::Parser::create( rContext );
- OFOPXMLHelper_Impl *const pHelper = new OFOPXMLHelper_Impl( nFormat );
- uno::Reference< css::xml::sax::XDocumentHandler > xHelper( static_cast< css::xml::sax::XDocumentHandler* >( pHelper ) );
+ rtl::Reference<OFOPXMLHelper_Impl> pHelper = new OFOPXMLHelper_Impl( nFormat );
css::xml::sax::InputSource aParserInput;
aParserInput.aInputStream = xInStream;
aParserInput.sSystemId = aStringID;
- xParser->setDocumentHandler( xHelper );
+ xParser->setDocumentHandler( pHelper );
xParser->parseStream( aParserInput );
xParser->setDocumentHandler( uno::Reference < css::xml::sax::XDocumentHandler > () );