loplugin:refcounting in filter

Change-Id: I77323376b7a2b04e50bf3017c00a0eea566da37d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111281
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel
2021-02-21 16:11:14 +01:00
committed by Noel Grandin
parent 7ffb71e759
commit 6b6f9fb71f
11 changed files with 38 additions and 55 deletions
+2 -4
View File
@@ -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);
}
+1 -2
View File
@@ -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);
}
+1 -1
View File
@@ -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
+1 -9
View File
@@ -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() )
{
-1
View File
@@ -70,7 +70,6 @@ namespace
SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) :
mxContext( rxCtx ),
mpSVGDoc( nullptr ),
mpSVGExport( nullptr ),
mpSVGFontExport( nullptr ),
mpSVGWriter( nullptr ),
mbSinglePage( false ),
+1 -1
View File
@@ -178,7 +178,7 @@ private:
Reference< XComponentContext > mxContext;
SvXMLElementExport* mpSVGDoc;
SVGExport* mpSVGExport;
rtl::Reference<SVGExport> mpSVGExport;
SVGFontExport* mpSVGFontExport;
SVGActionWriter* mpSVGWriter;
bool mbSinglePage;
-2
View File
@@ -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)
{
}
+2 -1
View File
@@ -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
@@ -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 );
@@ -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;
+9 -10
View File
@@ -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();