filter/source/config/cache/basecontainer.cxx     |    6 +--
 filter/source/config/cache/filterfactory.cxx     |    3 -
 filter/source/msfilter/eschesdo.cxx              |    2 -
 filter/source/svg/svgexport.cxx                  |   10 -----
 filter/source/svg/svgfilter.cxx                  |    1 
 filter/source/svg/svgfilter.hxx                  |    2 -
 filter/source/t602/t602filter.cxx                |    2 -
 filter/source/t602/t602filter.hxx                |    3 +
 filter/source/xsltdialog/typedetectionexport.cxx |   39 ++++++++++-------------
 filter/source/xsltdialog/typedetectionimport.cxx |    6 +--
 filter/source/xsltfilter/XSLTFilter.cxx          |   19 +++++------
 11 files changed, 38 insertions(+), 55 deletions(-)

New commits:
commit 6b6f9fb71fa1bfcb438b89596e6f19529cfe1eba
Author:     Noel <noel.gran...@collabora.co.uk>
AuthorDate: Sun Feb 21 13:33:30 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Feb 21 16:11:14 2021 +0100

    loplugin:refcounting in filter
    
    Change-Id: I77323376b7a2b04e50bf3017c00a0eea566da37d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111281
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/filter/source/config/cache/basecontainer.cxx 
b/filter/source/config/cache/basecontainer.cxx
index 4f7b4f04ca49..71eb4f931399 100644
--- a/filter/source/config/cache/basecontainer.cxx
+++ b/filter/source/config/cache/basecontainer.cxx
@@ -353,8 +353,7 @@ css::uno::Reference< css::container::XEnumeration > 
SAL_CALL BaseContainer::crea
 {
     OSL_FAIL("not pure virtual ... but not really implemented .-)");
 
-    ::comphelper::OEnumerationByName* pEnum = new 
::comphelper::OEnumerationByName(this, css::uno::Sequence< OUString >());
-    return css::uno::Reference< css::container::XEnumeration >(static_cast< 
css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY);
+    return new ::comphelper::OEnumerationByName(this, css::uno::Sequence< 
OUString >());
 }
 
 
@@ -398,8 +397,7 @@ css::uno::Reference< css::container::XEnumeration > 
SAL_CALL BaseContainer::crea
              instead of checking of NULL returns! */
 
     css::uno::Sequence< OUString > lSubSet = 
comphelper::containerToSequence(lKeys);
-    ::comphelper::OEnumerationByName* pEnum = new 
::comphelper::OEnumerationByName(this, lSubSet);
-    return css::uno::Reference< css::container::XEnumeration >(static_cast< 
css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY);
+    return new ::comphelper::OEnumerationByName(this, lSubSet);
 }
 
 
diff --git a/filter/source/config/cache/filterfactory.cxx 
b/filter/source/config/cache/filterfactory.cxx
index fa26ee7ba580..e499b4bad633 100644
--- a/filter/source/config/cache/filterfactory.cxx
+++ b/filter/source/config/cache/filterfactory.cxx
@@ -182,8 +182,7 @@ css::uno::Reference< css::container::XEnumeration > 
SAL_CALL FilterFactory::crea
     // Attention: Do not return empty reference for empty list!
     // The outside check "hasMoreElements()" should be enough, to detect this 
state :-)
     css::uno::Sequence< OUString > lSet = 
comphelper::containerToSequence(lEnumSet);
-    ::comphelper::OEnumerationByName* pEnum = new 
::comphelper::OEnumerationByName(this, lSet);
-    return css::uno::Reference< css::container::XEnumeration >(static_cast< 
css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY);
+    return new ::comphelper::OEnumerationByName(this, lSet);
 }
 
 
diff --git a/filter/source/msfilter/eschesdo.cxx 
b/filter/source/msfilter/eschesdo.cxx
index d2c85672ca05..7df0a58f7aa4 100644
--- a/filter/source/msfilter/eschesdo.cxx
+++ b/filter/source/msfilter/eschesdo.cxx
@@ -861,7 +861,7 @@ ImplEESdrWriter::~ImplEESdrWriter()
 
 bool ImplEESdrWriter::ImplInitPage( const SdrPage& rPage )
 {
-    SvxDrawPage* pSvxDrawPage;
+    rtl::Reference<SvxDrawPage> pSvxDrawPage;
     if ( mpSdrPage != &rPage || !mXDrawPage.is() )
     {
         // eventually write SolverContainer of current page, deletes the Solver
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index a33fb46f1980..e35a42746216 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -575,10 +575,6 @@ bool SVGFilter::implExportImpressOrDraw( const Reference< 
XOutputStream >& rxOSt
                 // mpSVGExport = new SVGExport( xDocHandler );
                 mpSVGExport = new SVGExport( xContext, xDocHandler, 
maFilterData );
 
-                // xKeepAlive is set up only to manage the life-time of the 
object pointed by mpSVGExport,
-                // and in order to prevent that it is destroyed when passed to 
AnimationExporter.
-                Reference< XInterface > xKeepAlive = static_cast< 
css::document::XFilter* >( mpSVGExport );
-
                 // create an id for each draw page
                 for( const auto& rPage : mSelectedPages )
                     implRegisterInterface( rPage );
@@ -664,10 +660,6 @@ bool SVGFilter::implExportWriterOrCalc( const Reference< 
XOutputStream >& rxOStm
             // mpSVGExport = new SVGExport( xDocHandler );
             mpSVGExport = new SVGExport( xContext, xDocHandler, maFilterData );
 
-            // xKeepAlive is set up only to manage the life-time of the object 
pointed by mpSVGExport,
-            // and in order to prevent that it is destroyed when passed to 
AnimationExporter.
-            Reference< XInterface > xKeepAlive = static_cast< 
css::document::XFilter* >( mpSVGExport );
-
             try
             {
                 mxDefaultPage = mSelectedPages[0];
@@ -1284,7 +1276,7 @@ void SVGFilter::implGenerateMetaData()
             {
                 OUString sElemId = OUStringLiteral(aOOOElemTextField) + "_" + 
OUString::number( i );
                 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sElemId );
-                aFieldSet[i]->elementExport( mpSVGExport );
+                aFieldSet[i]->elementExport( mpSVGExport.get() );
             }
             if( mpSVGExport->IsEmbedFonts() && 
mpSVGExport->IsUsePositionedCharacters() )
             {
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index e4d61b7de1ee..cc4120dbf428 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -70,7 +70,6 @@ namespace
 SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) :
     mxContext( rxCtx ),
     mpSVGDoc( nullptr ),
-    mpSVGExport( nullptr ),
     mpSVGFontExport( nullptr ),
     mpSVGWriter( nullptr ),
     mbSinglePage( false ),
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index 5bce011ba7fb..b761e1768e9c 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -178,7 +178,7 @@ private:
 
     Reference< XComponentContext >      mxContext;
     SvXMLElementExport*                 mpSVGDoc;
-    SVGExport*                          mpSVGExport;
+    rtl::Reference<SVGExport>           mpSVGExport;
     SVGFontExport*                      mpSVGFontExport;
     SVGActionWriter*                    mpSVGWriter;
     bool                                mbSinglePage;
diff --git a/filter/source/t602/t602filter.cxx 
b/filter/source/t602/t602filter.cxx
index 6b8841ac1e77..9f96f18c1a96 100644
--- a/filter/source/t602/t602filter.cxx
+++ b/filter/source/t602/t602filter.cxx
@@ -133,14 +133,12 @@ static inistruct ini;
 
 T602ImportFilter::T602ImportFilter(const 
css::uno::Reference<css::uno::XComponentContext > &r )
     : mxContext(r)
-    , mpAttrList(nullptr)
     , node(tnode::START)
 {
 }
 
 T602ImportFilter::T602ImportFilter(css::uno::Reference<css::io::XInputStream> 
const & xInputStream)
     : mxInputStream(xInputStream)
-    , mpAttrList(nullptr)
     , node(tnode::START)
 {
 }
diff --git a/filter/source/t602/t602filter.hxx 
b/filter/source/t602/t602filter.hxx
index a703da411830..7ac81429a2c2 100644
--- a/filter/source/t602/t602filter.hxx
+++ b/filter/source/t602/t602filter.hxx
@@ -34,6 +34,7 @@
 #include <cppuhelper/implbase.hxx>
 #include <xmloff/attrlist.hxx>
 #include <i18nlangtag/languagetag.hxx>
+#include <rtl/ref.hxx>
 
 namespace T602ImportFilter {
 
@@ -128,7 +129,7 @@ private:
     css::uno::Reference< css::lang::XComponent >         mxDoc;
     css::uno::Reference < css::io::XInputStream >        mxInputStream;
 
-    SvXMLAttributeList *mpAttrList;
+    rtl::Reference<SvXMLAttributeList> mpAttrList;
 
     tnode node;         // START
 
diff --git a/filter/source/xsltdialog/typedetectionexport.cxx 
b/filter/source/xsltdialog/typedetectionexport.cxx
index 8a8f92c772c8..51be4018fef7 100644
--- a/filter/source/xsltdialog/typedetectionexport.cxx
+++ b/filter/source/xsltdialog/typedetectionexport.cxx
@@ -31,6 +31,7 @@
 #include "xmlfiltercommon.hxx"
 
 #include <comphelper/attributelist.hxx>
+#include <rtl/ref.hxx>
 
 using namespace com::sun::star::uno;
 using namespace com::sun::star::io;
@@ -96,30 +97,29 @@ void TypeDetectionExporter::doExport( const Reference< 
XOutputStream >& xOS,  co
         Reference< XWriter > xHandler = Writer::create( mxContext );
         xHandler->setOutputStream( xOS );
 
-        ::comphelper::AttributeList * pAttrList = new 
::comphelper::AttributeList;
+        rtl::Reference<::comphelper::AttributeList> pAttrList = new 
::comphelper::AttributeList;
         pAttrList->AddAttribute ( "xmlns:oor", sCdataAttribute, 
"http://openoffice.org/2001/registry"; );
         pAttrList->AddAttribute ( "xmlns:xs", sCdataAttribute, 
"http://www.w3.org/2001/XMLSchema"; );
         pAttrList->AddAttribute ( sName, sCdataAttribute, "TypeDetection" );
         pAttrList->AddAttribute ( "oor:package", sCdataAttribute, 
"org.openoffice.Office" );
-        Reference < XAttributeList > xAttrList (pAttrList);
 
         xHandler->startDocument();
         xHandler->ignorableWhitespace ( sWhiteSpace );
-        xHandler->startElement( sComponentData, xAttrList );
+        xHandler->startElement( sComponentData, pAttrList );
 
         // export types
         {
-            xAttrList = pAttrList = new ::comphelper::AttributeList;
+            pAttrList = new ::comphelper::AttributeList;
             pAttrList->AddAttribute ( sName, sCdataAttribute, "Types" );
             xHandler->ignorableWhitespace ( sWhiteSpace );
-            xHandler->startElement( sNode, xAttrList );
+            xHandler->startElement( sNode, pAttrList );
 
             for (auto const& filter : rFilters)
             {
-                xAttrList = pAttrList = new ::comphelper::AttributeList;
+                pAttrList = new ::comphelper::AttributeList;
                 pAttrList->AddAttribute( sName, sCdataAttribute, 
filter->maType );
                 xHandler->ignorableWhitespace ( sWhiteSpace );
-                xHandler->startElement( sNode, xAttrList );
+                xHandler->startElement( sNode, pAttrList );
                 OUString sValue = "0" + sComma + sComma;
                 if( !filter->maDocType.isEmpty() )
                 {
@@ -140,17 +140,17 @@ void TypeDetectionExporter::doExport( const Reference< 
XOutputStream >& xOS,  co
 
         // export filters
         {
-            xAttrList = pAttrList = new ::comphelper::AttributeList;
+            pAttrList = new ::comphelper::AttributeList;
             pAttrList->AddAttribute ( sName, sCdataAttribute, "Filters" );
             xHandler->ignorableWhitespace ( sWhiteSpace );
-            xHandler->startElement( sNode, xAttrList );
+            xHandler->startElement( sNode, pAttrList );
 
             for (auto const& filter : rFilters)
             {
-                xAttrList = pAttrList = new ::comphelper::AttributeList;
+                pAttrList = new ::comphelper::AttributeList;
                 pAttrList->AddAttribute( sName, sCdataAttribute, 
filter->maFilterName );
                 xHandler->ignorableWhitespace ( sWhiteSpace );
-                xHandler->startElement( sNode, xAttrList );
+                xHandler->startElement( sNode, pAttrList );
                 addLocaleProperty( xHandler, sUIName, filter->maInterfaceName 
);
 
                 OUStringBuffer sValue("0" +
@@ -213,16 +213,14 @@ void TypeDetectionExporter::addProperty( const Reference< 
XWriter >& xHandler, c
         const OUString sValue( "value" );
         const OUString sWhiteSpace          ( " " );
 
-        ::comphelper::AttributeList * pAttrList = new 
::comphelper::AttributeList;
+        rtl::Reference<::comphelper::AttributeList>pAttrList = new 
::comphelper::AttributeList;
         pAttrList->AddAttribute ( "oor:name", sCdataAttribute, rName );
         pAttrList->AddAttribute ( "oor:type", sCdataAttribute, "xs:string" );
-        Reference < XAttributeList > xAttrList (pAttrList);
 
         xHandler->ignorableWhitespace ( sWhiteSpace );
-        xHandler->startElement( sProp, xAttrList );
-        xAttrList = nullptr;
+        xHandler->startElement( sProp, pAttrList );
         xHandler->ignorableWhitespace ( sWhiteSpace );
-        xHandler->startElement( sValue,xAttrList );
+        xHandler->startElement( sValue, pAttrList );
         xHandler->characters( rValue );
         xHandler->endElement( sValue );
         xHandler->ignorableWhitespace ( sWhiteSpace );
@@ -243,17 +241,16 @@ void TypeDetectionExporter::addLocaleProperty( const 
Reference< XWriter >& xHand
         const OUString sValue( "value" );
         const OUString sWhiteSpace          ( " " );
 
-        ::comphelper::AttributeList * pAttrList = new 
::comphelper::AttributeList;
+        rtl::Reference<::comphelper::AttributeList> pAttrList = new 
::comphelper::AttributeList;
         pAttrList->AddAttribute ( "oor:name", sCdataAttribute, rName );
         pAttrList->AddAttribute ( "oor:type", sCdataAttribute, "xs:string" );
-        Reference < XAttributeList > xAttrList (pAttrList);
 
         xHandler->ignorableWhitespace ( sWhiteSpace );
-        xHandler->startElement( sProp, xAttrList );
-        xAttrList = pAttrList = new ::comphelper::AttributeList;
+        xHandler->startElement( sProp, pAttrList );
+        pAttrList = new ::comphelper::AttributeList;
         pAttrList->AddAttribute ( "xml:lang", sCdataAttribute, "en-US" );
         xHandler->ignorableWhitespace ( sWhiteSpace );
-        xHandler->startElement( sValue, xAttrList );
+        xHandler->startElement( sValue, pAttrList );
         xHandler->characters( rValue );
         xHandler->endElement( sValue );
         xHandler->ignorableWhitespace ( sWhiteSpace );
diff --git a/filter/source/xsltdialog/typedetectionimport.cxx 
b/filter/source/xsltdialog/typedetectionimport.cxx
index 4d785ec152a7..5d4798faa126 100644
--- a/filter/source/xsltdialog/typedetectionimport.cxx
+++ b/filter/source/xsltdialog/typedetectionimport.cxx
@@ -21,6 +21,7 @@
 #include <com/sun/star/xml/sax/Parser.hpp>
 #include <com/sun/star/xml/sax/XAttributeList.hpp>
 #include <tools/diagnose_ex.h>
+#include <rtl/ref.hxx>
 
 #include "typedetectionimport.hxx"
 #include "xmlfiltercommon.hxx"
@@ -48,9 +49,8 @@ void TypeDetectionImporter::doImport( const Reference< 
XComponentContext >& rxCo
     {
         Reference< XParser > xParser = xml::sax::Parser::create( rxContext );
 
-        TypeDetectionImporter* pImporter = new TypeDetectionImporter;
-        Reference < XDocumentHandler > xDocHandler( pImporter );
-        xParser->setDocumentHandler( xDocHandler );
+        rtl::Reference<TypeDetectionImporter> pImporter = new 
TypeDetectionImporter;
+        xParser->setDocumentHandler( pImporter );
 
         InputSource source;
         source.aInputStream = xIS;
diff --git a/filter/source/xsltfilter/XSLTFilter.cxx 
b/filter/source/xsltfilter/XSLTFilter.cxx
index b48a68befc19..1e3f770c2aee 100644
--- a/filter/source/xsltfilter/XSLTFilter.cxx
+++ b/filter/source/xsltfilter/XSLTFilter.cxx
@@ -30,6 +30,7 @@
 #include <tools/urlobj.hxx>
 #include <tools/diagnose_ex.h>
 #include <sal/log.hxx>
+#include <rtl/ref.hxx>
 
 #include <comphelper/interaction.hxx>
 
@@ -385,13 +386,12 @@ namespace XSLT
                                                  excArgs);
                                         Any r;
                                         r <<= exc;
-                                        ::comphelper::OInteractionRequest* 
pRequest = new ::comphelper::OInteractionRequest(r);
-                                        css::uno::Reference< 
XInteractionRequest > xRequest(pRequest);
-                                        ::comphelper::OInteractionRetry* 
pRetry = new ::comphelper::OInteractionRetry;
-                                        ::comphelper::OInteractionAbort* 
pAbort = new ::comphelper::OInteractionAbort;
+                                        
rtl::Reference<::comphelper::OInteractionRequest> pRequest = new 
::comphelper::OInteractionRequest(r);
+                                        
rtl::Reference<::comphelper::OInteractionRetry> pRetry = new 
::comphelper::OInteractionRetry;
+                                        
rtl::Reference<::comphelper::OInteractionAbort> pAbort = new 
::comphelper::OInteractionAbort;
                                         pRequest->addContinuation(pRetry);
                                         pRequest->addContinuation(pAbort);
-                                        xInterActionHandler->handle(xRequest);
+                                        xInterActionHandler->handle(pRequest);
                                         if (pAbort->wasSelected()) {
                                                 m_bError = true;
                                                 m_cTransformed.set();
@@ -524,13 +524,12 @@ namespace XSLT
                                                  excArgs);
                                         Any r;
                                         r <<= exc;
-                                        ::comphelper::OInteractionRequest* 
pRequest = new ::comphelper::OInteractionRequest(r);
-                                        css::uno::Reference< 
XInteractionRequest > xRequest(pRequest);
-                                        ::comphelper::OInteractionRetry* 
pRetry = new ::comphelper::OInteractionRetry;
-                                        ::comphelper::OInteractionAbort* 
pAbort = new ::comphelper::OInteractionAbort;
+                                        
rtl::Reference<::comphelper::OInteractionRequest> pRequest = new 
::comphelper::OInteractionRequest(r);
+                                        
rtl::Reference<::comphelper::OInteractionRetry> pRetry = new 
::comphelper::OInteractionRetry;
+                                        
rtl::Reference<::comphelper::OInteractionAbort> pAbort = new 
::comphelper::OInteractionAbort;
                                         pRequest->addContinuation(pRetry);
                                         pRequest->addContinuation(pAbort);
-                                        xInterActionHandler->handle(xRequest);
+                                        xInterActionHandler->handle(pRequest);
                                         if (pAbort->wasSelected()) {
                                                 m_bError = true;
                                                 m_cTransformed.set();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to