From 6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 2 May 2013 10:36:43 +0200 Subject: Use the new type-checking Reference constructor to reduce code noise Also create a Clang compiler plugin to detect such cases. Change-Id: I61ad1a1d6b1c017eeb51f226d2dde0e9bb7f1752 Reviewed-on: https://gerrit.libreoffice.org/4001 Tested-by: LibreOffice gerrit bot Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- sw/source/filter/xml/xmlexp.cxx | 5 ++--- sw/source/filter/xml/xmltbli.cxx | 2 +- sw/source/ui/dbui/dbmgr.cxx | 6 ++---- sw/source/ui/dbui/dbtree.cxx | 9 +++------ 4 files changed, 8 insertions(+), 14 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index e12b3f3631bd..fca627d3af85 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -361,7 +361,7 @@ void SwXMLExport::GetViewSettings(Sequence& aProps) Reference < XIndexContainer > xBox = IndexedPropertyValues::create( comphelper::getProcessComponentContext() ); pValue[nIndex].Name = OUString( "Views"); - pValue[nIndex++].Value <<= Reference < XIndexAccess > ( xBox, UNO_QUERY ); + pValue[nIndex++].Value <<= xBox; SwDoc *pDoc = getDoc(); const Rectangle rRect = @@ -464,9 +464,8 @@ void SwXMLExport::_ExportContent() if (xPage.is()) { // prevent export of form controls which are embedded in mute sections - Reference xIAPage( xPage, UNO_QUERY ); GetTextParagraphExport()->PreventExportOfControlsInMuteSections( - xIAPage, GetFormExport() ); + xPage, GetFormExport() ); // #i36597# if ( GetFormExport()->pageContainsForms( xPage ) || GetFormExport()->documentContainsXForms() ) diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index 5a367cd49bd5..9cc801f5f2f8 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -1403,7 +1403,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, try { - xTextContent = Reference< XTextContent >( xTable, UNO_QUERY ); + xTextContent = xTable; GetImport().GetTextImport()->InsertTextContent( xTextContent ); } catch( IllegalArgumentException& ) diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 51db9f330ce6..ae7a0d6b2ee5 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -2281,7 +2281,6 @@ String SwNewDBMgr::LoadAndRegisterDataSource() { Reference xContext( ::comphelper::getProcessComponentContext() ); Reference xDBContext = DatabaseContext::create(xContext); - Reference xFact( xDBContext, UNO_QUERY); String sNewName = INetURLObject::decode( aURL.getName(), INET_HEX_ESCAPE, @@ -2308,7 +2307,7 @@ String SwNewDBMgr::LoadAndRegisterDataSource() } else { - xNewInstance = xFact->createInstance(); + xNewInstance = xDBContext->createInstance(); Reference xDataProperties(xNewInstance, UNO_QUERY); if(aURLAny.hasValue()) @@ -2346,8 +2345,7 @@ String SwNewDBMgr::LoadAndRegisterDataSource() } xStore->storeAsURL(sTmpName, Sequence< PropertyValue >()); } - Reference xNaming(xDBContext, UNO_QUERY); - xNaming->registerObject( sFind, xNewInstance ); + xDBContext->registerObject( sFind, xNewInstance ); } catch(const Exception&) diff --git a/sw/source/ui/dbui/dbtree.cxx b/sw/source/ui/dbui/dbtree.cxx index 8a5193733c80..77c67718a6d1 100644 --- a/sw/source/ui/dbui/dbtree.cxx +++ b/sw/source/ui/dbui/dbtree.cxx @@ -96,14 +96,13 @@ class SwDBTreeList_Impl : public cppu::WeakImplHelper1 < XContainerListener > SwDBTreeList_Impl::~SwDBTreeList_Impl() { - Reference xContainer(xDBContext, UNO_QUERY); - if(xContainer.is()) + if(xDBContext.is()) { m_refCount++; //block necessary due to solaris' compiler behaviour to //remove temporaries at the block's end { - xContainer->removeContainerListener( this ); + xDBContext->removeContainerListener( this ); } m_refCount--; } @@ -145,9 +144,7 @@ sal_Bool SwDBTreeList_Impl::HasContext() { Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); xDBContext = DatabaseContext::create(xContext); - Reference xContainer(xDBContext, UNO_QUERY); - if(xContainer.is()) - xContainer->addContainerListener( this ); + xDBContext->addContainerListener( this ); } return xDBContext.is(); } -- cgit