[Libreoffice-commits] core.git: 2 commits - unotools/source writerfilter/source
Noel (via logerrit)
logerrit at kemper.freedesktop.org
Tue Feb 23 09:40:18 UTC 2021
unotools/source/config/itemholder1.cxx | 3 ++-
unotools/source/misc/eventlisteneradapter.cxx | 2 +-
unotools/source/misc/mediadescriptor.cxx | 15 ++++++---------
unotools/source/ucbhelper/ucbhelper.cxx | 6 ++----
unotools/source/ucbhelper/ucblockbytes.cxx | 15 +++++++--------
unotools/source/ucbhelper/ucbstreamhelper.cxx | 3 +--
writerfilter/source/ooxml/OOXMLDocumentImpl.cxx | 10 ++++------
writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 4 ++--
8 files changed, 25 insertions(+), 33 deletions(-)
New commits:
commit 137a93776c91765176867157669b1f95cffb8ae8
Author: Noel <noel.grandin at collabora.co.uk>
AuthorDate: Tue Feb 23 10:27:29 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Feb 23 10:39:43 2021 +0100
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 at collabora.co.uk>
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 >(),
commit 68837ab9b40af5425318d43836650840ba16fc17
Author: Noel <noel.grandin at collabora.co.uk>
AuthorDate: Tue Feb 23 10:27:15 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Feb 23 10:39:19 2021 +0100
loplugin:refcounting in writerfilter
Change-Id: I874f0ffc8758754960ab1964df333b3f5d9d9a6f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111375
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index d8b520cb2e1a..9ab9bb937bce 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -93,13 +93,12 @@ void OOXMLDocumentImpl::resolveFastSubStream(Stream & rStreamHandler,
if (xParser.is())
{
uno::Reference<uno::XComponentContext> xContext(mpStream->getContext());
- OOXMLFastDocumentHandler * pDocHandler =
+ rtl::Reference<OOXMLFastDocumentHandler> pDocHandler =
new OOXMLFastDocumentHandler(xContext, &rStreamHandler, this, mnXNoteId);
- uno::Reference<xml::sax::XFastDocumentHandler> xDocumentHandler(pDocHandler);
uno::Reference<xml::sax::XFastTokenHandler> xTokenHandler(mpStream->getFastTokenHandler());
- xParser->setFastDocumentHandler(xDocumentHandler);
+ xParser->setFastDocumentHandler(pDocHandler);
xParser->setTokenHandler(xTokenHandler);
uno::Reference<io::XInputStream> xInputStream = pStream->getDocumentStream();
@@ -462,10 +461,9 @@ void OOXMLDocumentImpl::resolve(Stream & rStream)
uno::Reference<uno::XComponentContext> xContext(mpStream->getContext());
- OOXMLFastDocumentHandler * pDocHandler =
+ rtl::Reference<OOXMLFastDocumentHandler> pDocHandler =
new OOXMLFastDocumentHandler(xContext, &rStream, this, mnXNoteId);
pDocHandler->setIsSubstream( mbIsSubstream );
- uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler(pDocHandler);
uno::Reference < xml::sax::XFastTokenHandler > xTokenHandler(mpStream->getFastTokenHandler());
resolveFastSubStream(rStream, OOXMLStream::SETTINGS);
@@ -484,7 +482,7 @@ void OOXMLDocumentImpl::resolve(Stream & rStream)
resolveFastSubStream(rStream, OOXMLStream::STYLES);
resolveFastSubStream(rStream, OOXMLStream::NUMBERING);
- xParser->setFastDocumentHandler( xDocumentHandler );
+ xParser->setFastDocumentHandler( pDocHandler );
xParser->setTokenHandler( xTokenHandler );
xml::sax::InputSource aParserInput;
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index f04391bd95db..e4bd09130c69 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1794,7 +1794,7 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
uno::Reference<XFastContextHandler> pChildContext =
mrShapeContext->createFastChildContext(Element, Attribs);
- OOXMLFastContextHandlerWrapper * pWrapper =
+ rtl::Reference<OOXMLFastContextHandlerWrapper> pWrapper =
new OOXMLFastContextHandlerWrapper(this,
pChildContext,
this);
@@ -1975,7 +1975,7 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext
}
else if (mxWrappedContext.is() && !bSkipImages)
{
- OOXMLFastContextHandlerWrapper * pWrapper =
+ rtl::Reference<OOXMLFastContextHandlerWrapper> pWrapper =
new OOXMLFastContextHandlerWrapper
(this, mxWrappedContext->createFastChildContext(Element, Attribs),
mxShapeHandler);
More information about the Libreoffice-commits
mailing list