summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-02-23 10:27:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-23 10:39:43 +0100
commit137a93776c91765176867157669b1f95cffb8ae8 (patch)
tree1db2853a579cd989f6fc181bba1a5e040381e6bf /unotools
parent68837ab9b40af5425318d43836650840ba16fc17 (diff)
loplugin:refcounting in unotools
Change-Id: I7c4540a6b2975c590b36332f23d15882a79491a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111376 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/itemholder1.cxx3
-rw-r--r--unotools/source/misc/eventlisteneradapter.cxx2
-rw-r--r--unotools/source/misc/mediadescriptor.cxx15
-rw-r--r--unotools/source/ucbhelper/ucbhelper.cxx6
-rw-r--r--unotools/source/ucbhelper/ucblockbytes.cxx15
-rw-r--r--unotools/source/ucbhelper/ucbstreamhelper.cxx3
6 files changed, 19 insertions, 25 deletions
diff --git a/unotools/source/config/itemholder1.cxx b/unotools/source/config/itemholder1.cxx
index bad26a977108..23149a6af6b8 100644
--- a/unotools/source/config/itemholder1.cxx
+++ b/unotools/source/config/itemholder1.cxx
@@ -37,6 +37,7 @@
#include <unotools/viewoptions.hxx>
#include <unotools/options.hxx>
#include <unotools/syslocaleoptions.hxx>
+#include <rtl/ref.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
#include <tools/diagnose_ex.h>
@@ -74,7 +75,7 @@ ItemHolder1::~ItemHolder1()
void ItemHolder1::holdConfigItem(EItem eItem)
{
- static ItemHolder1* pHolder = new ItemHolder1();
+ static rtl::Reference<ItemHolder1> pHolder = new ItemHolder1();
pHolder->impl_addItem(eItem);
}
diff --git a/unotools/source/misc/eventlisteneradapter.cxx b/unotools/source/misc/eventlisteneradapter.cxx
index d9736905de81..b899db5c0723 100644
--- a/unotools/source/misc/eventlisteneradapter.cxx
+++ b/unotools/source/misc/eventlisteneradapter.cxx
@@ -146,7 +146,7 @@ namespace utl
return;
}
- OEventListenerImpl* pListenerImpl = new OEventListenerImpl(this, _rxComp);
+ rtl::Reference<OEventListenerImpl> pListenerImpl = new OEventListenerImpl(this, _rxComp);
m_pImpl->aListeners.emplace_back(pListenerImpl);
}
diff --git a/unotools/source/misc/mediadescriptor.cxx b/unotools/source/misc/mediadescriptor.cxx
index d73f3c5dd2eb..102aaaa1b3ed 100644
--- a/unotools/source/misc/mediadescriptor.cxx
+++ b/unotools/source/misc/mediadescriptor.cxx
@@ -545,8 +545,7 @@ bool MediaDescriptor::impl_openStreamWithPostData( const css::uno::Reference< cs
MediaDescriptor::PROP_INTERACTIONHANDLER(),
css::uno::Reference< css::task::XInteractionHandler >());
css::uno::Reference< css::ucb::XProgressHandler > xProgress;
- ::ucbhelper::CommandEnvironment* pCommandEnv = new ::ucbhelper::CommandEnvironment(xInteraction, xProgress);
- css::uno::Reference< css::ucb::XCommandEnvironment > xCommandEnv(static_cast< css::ucb::XCommandEnvironment* >(pCommandEnv), css::uno::UNO_QUERY);
+ rtl::Reference<::ucbhelper::CommandEnvironment> xCommandEnv = new ::ucbhelper::CommandEnvironment(xInteraction, xProgress);
// media type
OUString sMediaType = getUnpackedValueOrDefault(MediaDescriptor::PROP_MEDIATYPE(), OUString());
@@ -615,12 +614,10 @@ bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, bool bLockFi
MediaDescriptor::PROP_AUTHENTICATIONHANDLER(),
css::uno::Reference< css::task::XInteractionHandler >());
- comphelper::StillReadWriteInteraction* pInteraction = new comphelper::StillReadWriteInteraction(xOrgInteraction,xAuthenticationInteraction);
- css::uno::Reference< css::task::XInteractionHandler > xInteraction(static_cast< css::task::XInteractionHandler* >(pInteraction), css::uno::UNO_QUERY);
+ rtl::Reference<comphelper::StillReadWriteInteraction> xInteraction = new comphelper::StillReadWriteInteraction(xOrgInteraction,xAuthenticationInteraction);
css::uno::Reference< css::ucb::XProgressHandler > xProgress;
- ::ucbhelper::CommandEnvironment* pCommandEnv = new ::ucbhelper::CommandEnvironment(xInteraction, xProgress);
- css::uno::Reference< css::ucb::XCommandEnvironment > xCommandEnv(static_cast< css::ucb::XCommandEnvironment* >(pCommandEnv), css::uno::UNO_QUERY);
+ rtl::Reference<::ucbhelper::CommandEnvironment> xCommandEnv = new ::ucbhelper::CommandEnvironment(xInteraction, xProgress);
// try to create the content
// no content -> no stream => return immediately with FALSE
@@ -679,7 +676,7 @@ bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, bool bLockFi
// later a second time.
// All other errors must be handled as real error an
// break this method.
- if (!pInteraction->wasWriteError() || bModeRequestedExplicitly)
+ if (!xInteraction->wasWriteError() || bModeRequestedExplicitly)
{
SAL_WARN("unotools.misc","url: '" << sURL << "' " << exceptionToString(ex));
// If the protocol is webdav, then we need to treat the stream as readonly, even if the
@@ -728,8 +725,8 @@ bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, bool bLockFi
if ( bReadOnly )
(*this)[MediaDescriptor::PROP_READONLY()] <<= bReadOnly;
- pInteraction->resetInterceptions();
- pInteraction->resetErrorStates();
+ xInteraction->resetInterceptions();
+ xInteraction->resetErrorStates();
try
{
// all the contents except file-URLs should be opened as usual
diff --git a/unotools/source/ucbhelper/ucbhelper.cxx b/unotools/source/ucbhelper/ucbhelper.cxx
index 7916259f1919..aaf8411e2a38 100644
--- a/unotools/source/ucbhelper/ucbhelper.cxx
+++ b/unotools/source/ucbhelper/ucbhelper.cxx
@@ -123,13 +123,11 @@ css::uno::Reference< css::ucb::XCommandEnvironment > utl::UCBContentHelper::getD
comphelper::getProcessComponentContext(), nullptr ) );
css::uno::Reference< css::ucb::XProgressHandler > xProgress;
- ucbhelper::CommandEnvironment* pCommandEnv =
+ rtl::Reference<ucbhelper::CommandEnvironment> pCommandEnv =
new ::ucbhelper::CommandEnvironment(
new comphelper::SimpleFileAccessInteraction( xIH ), xProgress );
- css::uno::Reference < css::ucb::XCommandEnvironment > xEnv(
- static_cast< css::ucb::XCommandEnvironment* >(pCommandEnv), css::uno::UNO_QUERY );
- return xEnv;
+ return pCommandEnv;
}
bool utl::UCBContentHelper::IsDocument(OUString const & url) {
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx
index 3748b4a8ee80..1eeb47b229d4 100644
--- a/unotools/source/ucbhelper/ucblockbytes.cxx
+++ b/unotools/source/ucbhelper/ucblockbytes.cxx
@@ -735,21 +735,20 @@ static bool UCBOpenContentSync(
aExcep.Message = "server not responding after five seconds";
Any request;
request <<= aExcep;
- ucbhelper::InteractionRequest *ir =
+ rtl::Reference<ucbhelper::InteractionRequest> xIR =
new ucbhelper::InteractionRequest(request);
- Reference<XInteractionRequest> xIR(ir);
Sequence<Reference<XInteractionContinuation> > aSeq(2);
- ucbhelper::InteractionRetry *retryP =
- new ucbhelper::InteractionRetry(ir);
+ rtl::Reference<ucbhelper::InteractionRetry> retryP =
+ new ucbhelper::InteractionRetry(xIR.get());
aSeq[0] = retryP;
- ucbhelper::InteractionAbort *abortP =
- new ucbhelper::InteractionAbort(ir);
+ rtl::Reference<ucbhelper::InteractionAbort> abortP =
+ new ucbhelper::InteractionAbort(xIR.get());
aSeq[1] = abortP;
- ir->setContinuations(aSeq);
+ xIR->setContinuations(aSeq);
xInteract->handle(xIR);
rtl::Reference< ucbhelper::InteractionContinuation > ref
- = ir->getSelection();
+ = xIR->getSelection();
if(ref.is()) {
Reference<XInterface> xInt(ref);
xRet.set(xInt,UNO_QUERY);
diff --git a/unotools/source/ucbhelper/ucbstreamhelper.cxx b/unotools/source/ucbhelper/ucbstreamhelper.cxx
index 6f72c00bc985..ad2d9813d795 100644
--- a/unotools/source/ucbhelper/ucbstreamhelper.cxx
+++ b/unotools/source/ucbhelper/ucbstreamhelper.cxx
@@ -81,8 +81,7 @@ static std::unique_ptr<SvStream> lcl_CreateStream( const OUString& rFileName, St
{
// make sure that the desired file exists before trying to open
SvMemoryStream aStream(0,0);
- ::utl::OInputStreamWrapper* pInput = new ::utl::OInputStreamWrapper( aStream );
- Reference< XInputStream > xInput( pInput );
+ rtl::Reference<::utl::OInputStreamWrapper> xInput = new ::utl::OInputStreamWrapper( aStream );
::ucbhelper::Content aContent(
rFileName, Reference < XCommandEnvironment >(),