diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-02-16 15:47:57 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-16 20:17:39 +0100 |
commit | 9bd827270646be509060ddb92be4eae20b277b91 (patch) | |
tree | f68cb9b3296620ba15fc0efa57787176374abe80 /unoxml | |
parent | 1607033e581ee1fc4aab5564cbf8fa89d7094ec7 (diff) |
loplugin:referencecasting in UnoControls..unoxml
Change-Id: I42f216b6115be693a4e57d70f6cbbf11b62ec185
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110998
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unoxml')
-rw-r--r-- | unoxml/qa/unit/domtest.cxx | 24 | ||||
-rw-r--r-- | unoxml/source/dom/attributesmap.cxx | 12 | ||||
-rw-r--r-- | unoxml/source/dom/childlist.cxx | 3 | ||||
-rw-r--r-- | unoxml/source/dom/document.cxx | 6 | ||||
-rw-r--r-- | unoxml/source/dom/documentbuilder.cxx | 8 | ||||
-rw-r--r-- | unoxml/source/dom/element.cxx | 4 | ||||
-rw-r--r-- | unoxml/source/dom/elementlist.cxx | 4 | ||||
-rw-r--r-- | unoxml/source/dom/node.cxx | 24 | ||||
-rw-r--r-- | unoxml/source/events/eventdispatcher.cxx | 2 | ||||
-rw-r--r-- | unoxml/source/rdf/librdf_repository.cxx | 7 | ||||
-rw-r--r-- | unoxml/source/xpath/nodelist.cxx | 3 |
11 files changed, 35 insertions, 62 deletions
diff --git a/unoxml/qa/unit/domtest.cxx b/unoxml/qa/unit/domtest.cxx index 1b1daa56b1f9..c6501547183c 100644 --- a/unoxml/qa/unit/domtest.cxx +++ b/unoxml/qa/unit/domtest.cxx @@ -207,7 +207,7 @@ struct BasicTest : public test::BootstrapFixture mxValidInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const *>(validTestFile), SAL_N_ELEMENTS(validTestFile))) ); mxWarningInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const *>(warningTestFile), SAL_N_ELEMENTS(warningTestFile))) ); mxErrorInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const *>(errorTestFile), SAL_N_ELEMENTS(errorTestFile))) ); - mxDomBuilder->setErrorHandler(mxErrHandler.get()); + mxDomBuilder->setErrorHandler(mxErrHandler); } void validInputTest() @@ -215,9 +215,7 @@ struct BasicTest : public test::BootstrapFixture try { CPPUNIT_ASSERT_MESSAGE("Valid input file did not result in XDocument #1", - mxDomBuilder->parse( - uno::Reference<io::XInputStream>( - mxValidInStream.get())).is()); + mxDomBuilder->parse(mxValidInStream).is()); CPPUNIT_ASSERT_MESSAGE("Valid input file resulted in parse errors", mxErrHandler->noErrors()); } @@ -233,9 +231,7 @@ struct BasicTest : public test::BootstrapFixture { // We DON'T expect exception here, as mxWarningInStream is valid XML Doc CPPUNIT_ASSERT_MESSAGE("Valid input file did not result in XDocument #2", - mxDomBuilder->parse( - uno::Reference<io::XInputStream>( - mxWarningInStream.get())).is()); + mxDomBuilder->parse(mxWarningInStream).is()); } catch (const css::xml::sax::SAXParseException& ) { @@ -253,9 +249,7 @@ struct BasicTest : public test::BootstrapFixture { // We expect exception here, as mxErrorInStream is invalid XML Doc CPPUNIT_ASSERT_MESSAGE("Invalid input file result in XDocument #2!", - !mxDomBuilder->parse( - uno::Reference<io::XInputStream>( - mxErrorInStream.get())).is()); + !mxDomBuilder->parse(mxErrorInStream).is()); CPPUNIT_ASSERT_MESSAGE("No exception is thrown in unclean input file", false); } catch (const css::xml::sax::SAXParseException&) @@ -295,7 +289,7 @@ struct SerializerTest : public test::BootstrapFixture uno::Reference<XDocumentBuilder> xDB( getMultiServiceFactory()->createInstance("com.sun.star.xml.dom.DocumentBuilder"), uno::UNO_QUERY_THROW ); mxDomBuilder.set( xDB ); mxInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const *>(validTestFile), SAL_N_ELEMENTS(validTestFile))) ); - mxDomBuilder->setErrorHandler(mxErrHandler.get()); + mxDomBuilder->setErrorHandler(mxErrHandler); mxHandler.set( new DocumentHandler ); mxTokHandler.set( new TokenHandler ); @@ -313,9 +307,7 @@ struct SerializerTest : public test::BootstrapFixture try { uno::Reference< xml::dom::XDocument > xDoc = - mxDomBuilder->parse( - uno::Reference<io::XInputStream>( - mxInStream.get())); + mxDomBuilder->parse(mxInStream); CPPUNIT_ASSERT_MESSAGE("Valid input file did not result in XDocument", xDoc.is()); CPPUNIT_ASSERT_MESSAGE("Valid input file resulted in parse errors", @@ -331,8 +323,8 @@ struct SerializerTest : public test::BootstrapFixture CPPUNIT_ASSERT_MESSAGE("XFastSAXSerializable not supported", xSaxSerializer.is()); - xFastSaxSerializer->fastSerialize(mxHandler.get(), - mxTokHandler.get(), + xFastSaxSerializer->fastSerialize(mxHandler, + mxTokHandler, uno::Sequence< beans::StringPair >(), maRegisteredNamespaces); } diff --git a/unoxml/source/dom/attributesmap.cxx b/unoxml/source/dom/attributesmap.cxx index eef8c09f7b0b..575fa96c2ce0 100644 --- a/unoxml/source/dom/attributesmap.cxx +++ b/unoxml/source/dom/attributesmap.cxx @@ -78,8 +78,8 @@ namespace DOM { if( strcmp(reinterpret_cast<char const *>(pName), reinterpret_cast<char const *>(cur->name)) == 0) { - aNode.set( m_pElement->GetOwnerDocument().GetCNode( - reinterpret_cast<xmlNodePtr>(cur)).get() ); + aNode = m_pElement->GetOwnerDocument().GetCNode( + reinterpret_cast<xmlNodePtr>(cur)); break; } cur = cur->next; @@ -113,8 +113,8 @@ namespace DOM if( strcmp(reinterpret_cast<char const *>(pName), reinterpret_cast<char const *>(cur->name)) == 0 && cur->ns == pNs) { - aNode.set( m_pElement->GetOwnerDocument().GetCNode( - reinterpret_cast<xmlNodePtr>(cur)).get() ); + aNode = m_pElement->GetOwnerDocument().GetCNode( + reinterpret_cast<xmlNodePtr>(cur)); break; } cur = cur->next; @@ -141,8 +141,8 @@ namespace DOM { if (count == index) { - aNode.set( m_pElement->GetOwnerDocument().GetCNode( - reinterpret_cast<xmlNodePtr>(cur)).get() ); + aNode = m_pElement->GetOwnerDocument().GetCNode( + reinterpret_cast<xmlNodePtr>(cur)); break; } count++; diff --git a/unoxml/source/dom/childlist.cxx b/unoxml/source/dom/childlist.cxx index ec3811fa9161..6f62f0144dbb 100644 --- a/unoxml/source/dom/childlist.cxx +++ b/unoxml/source/dom/childlist.cxx @@ -75,8 +75,7 @@ namespace DOM while (cur != nullptr) { if (index-- == 0) { - return Reference< XNode >( - m_pNode->GetOwnerDocument().GetCNode(cur).get()); + return m_pNode->GetOwnerDocument().GetCNode(cur); } cur = cur->next; } diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx index 8d56510da81f..db93dcad847a 100644 --- a/unoxml/source/dom/document.cxx +++ b/unoxml/source/dom/document.cxx @@ -249,7 +249,7 @@ namespace DOM if (pCNode != nullptr) { bool const bInserted = m_NodeMap.emplace( pNode, - ::std::make_pair(WeakReference<XNode>(pCNode.get()), pCNode.get()) + ::std::make_pair(WeakReference<XNode>(pCNode), pCNode.get()) ).second; OSL_ASSERT(bInserted); if (!bInserted) { @@ -423,7 +423,7 @@ namespace DOM reinterpret_cast<xmlNodePtr>(pAttr)).get())); if (!pCAttr.is()) { throw RuntimeException(); } pCAttr->m_bUnlinked = true; - return pCAttr.get(); + return pCAttr; }; // Creates an attribute of the given qualified name and namespace URI. @@ -458,7 +458,7 @@ namespace DOM pCAttr->m_pNamespace.reset( new stringpair_t(oUri, oPrefix) ); pCAttr->m_bUnlinked = true; - return pCAttr.get(); + return pCAttr; }; // Creates a CDATASection node whose value is the specified string. diff --git a/unoxml/source/dom/documentbuilder.cxx b/unoxml/source/dom/documentbuilder.cxx index 3a4ddc5fe821..8d42ad5f9b75 100644 --- a/unoxml/source/dom/documentbuilder.cxx +++ b/unoxml/source/dom/documentbuilder.cxx @@ -133,9 +133,7 @@ namespace DOM // create a new document xmlDocPtr pDocument = xmlNewDoc(reinterpret_cast<const xmlChar*>("1.0")); - Reference< XDocument > const xRet( - CDocument::CreateCDocument(pDocument).get()); - return xRet; + return CDocument::CreateCDocument(pDocument); } static OUString make_error_message(xmlParserCtxtPtr ctxt) @@ -361,9 +359,7 @@ namespace DOM if (pDoc == nullptr) { throwEx(pContext.get()); } - Reference< XDocument > const xRet( - CDocument::CreateCDocument(pDoc).get()); - return xRet; + return CDocument::CreateCDocument(pDoc); } Reference< XDocument > SAL_CALL CDocumentBuilder::parseURI(const OUString& sUri) diff --git a/unoxml/source/dom/element.cxx b/unoxml/source/dom/element.cxx index f5dd67304d6b..988d7f1b9c32 100644 --- a/unoxml/source/dom/element.cxx +++ b/unoxml/source/dom/element.cxx @@ -144,7 +144,7 @@ namespace DOM Reference<XFastContextHandler> xParentHandler(i_rContext.mxCurrentHandler); try { - Reference< XFastAttributeList > xAttr( i_rContext.mxAttribList.get() ); + Reference< XFastAttributeList > xAttr( i_rContext.mxAttribList ); if( nElementToken == FastToken::DONTKNOW ) { const OUString aNamespace; @@ -472,7 +472,7 @@ namespace DOM } ::rtl::Reference<CNode> const pCNode( - comphelper::getUnoTunnelImplementation<CNode>(Reference<XNode>(oldAttr.get()))); + comphelper::getUnoTunnelImplementation<CNode>(Reference<XNode>(oldAttr))); if (!pCNode.is()) { throw RuntimeException(); } xmlNodePtr const pNode = pCNode->GetNodePtr(); diff --git a/unoxml/source/dom/elementlist.cxx b/unoxml/source/dom/elementlist.cxx index 290438b2ca28..c0ffb0f87929 100644 --- a/unoxml/source/dom/elementlist.cxx +++ b/unoxml/source/dom/elementlist.cxx @@ -176,9 +176,7 @@ namespace DOM if (m_nodevector.size() <= o3tl::make_unsigned(index)) { throw RuntimeException(); } - Reference< XNode > const xRet( - m_pElement->GetOwnerDocument().GetCNode(m_nodevector[index]).get()); - return xRet; + return m_pElement->GetOwnerDocument().GetCNode(m_nodevector[index]); } // tree mutations can change the list diff --git a/unoxml/source/dom/node.cxx b/unoxml/source/dom/node.cxx index 68a834c1a8b4..8abe73e707b3 100644 --- a/unoxml/source/dom/node.cxx +++ b/unoxml/source/dom/node.cxx @@ -371,7 +371,7 @@ namespace DOM // dispatch subtree modified for this node dispatchSubtreeModified(); - return pNode.get(); + return pNode; } /** @@ -389,7 +389,7 @@ namespace DOM xmlCopyNode(m_aNodePtr, bDeep ? 1 : 0)); if (!pNode.is()) { return nullptr; } pNode->m_bUnlinked = true; // not linked yet - return pNode.get(); + return pNode; } /** @@ -426,9 +426,7 @@ namespace DOM if (nullptr == m_aNodePtr) { return nullptr; } - Reference< XNode > const xNode( - GetOwnerDocument().GetCNode(m_aNodePtr->children).get()); - return xNode; + return GetOwnerDocument().GetCNode(m_aNodePtr->children); } /** @@ -441,9 +439,7 @@ namespace DOM if (nullptr == m_aNodePtr) { return nullptr; } - Reference< XNode > const xNode( - GetOwnerDocument().GetCNode(xmlGetLastChild(m_aNodePtr)).get()); - return xNode; + return GetOwnerDocument().GetCNode(xmlGetLastChild(m_aNodePtr)); } /** @@ -484,9 +480,7 @@ namespace DOM if (nullptr == m_aNodePtr) { return nullptr; } - Reference< XNode > const xNode( - GetOwnerDocument().GetCNode(m_aNodePtr->next).get()); - return xNode; + return GetOwnerDocument().GetCNode(m_aNodePtr->next); } /** @@ -557,9 +551,7 @@ namespace DOM if (nullptr == m_aNodePtr) { return nullptr; } - Reference< XNode > const xNode( - GetOwnerDocument().GetCNode(m_aNodePtr->parent).get()); - return xNode; + return GetOwnerDocument().GetCNode(m_aNodePtr->parent); } /** @@ -592,9 +584,7 @@ namespace DOM if (nullptr == m_aNodePtr) { return nullptr; } - Reference< XNode > const xNode( - GetOwnerDocument().GetCNode(m_aNodePtr->prev).get()); - return xNode; + return GetOwnerDocument().GetCNode(m_aNodePtr->prev); } /** diff --git a/unoxml/source/events/eventdispatcher.cxx b/unoxml/source/events/eventdispatcher.cxx index cc5fb159d3c8..fc396ee9dc76 100644 --- a/unoxml/source/events/eventdispatcher.cxx +++ b/unoxml/source/events/eventdispatcher.cxx @@ -197,7 +197,7 @@ namespace DOM::events { while (cur != nullptr) { Reference< XEventTarget > const xRef( - rDocument.GetCNode(cur).get()); + rDocument.GetCNode(cur)); captureVector.emplace_back(xRef, cur); cur = cur->parent; } diff --git a/unoxml/source/rdf/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx index 13a10b4edb41..85b05260484a 100644 --- a/unoxml/source/rdf/librdf_repository.cxx +++ b/unoxml/source/rdf/librdf_repository.cxx @@ -1057,7 +1057,7 @@ librdf_Repository::importGraph(::sal_Int16 i_Format, "librdf_model_context_add_statements failed", *this); } - return uno::Reference<rdf::XNamedGraph>(pGraph.get()); + return pGraph; } void addChaffWhenEncryptedStorage(const uno::Reference< io::XOutputStream > &rStream, unsigned char* pBuffer, size_t length) @@ -1273,7 +1273,7 @@ librdf_Repository::getGraph(const uno::Reference< rdf::XURI > & i_xGraphName) ::osl::MutexGuard g(m_aMutex); const NamedGraphMap_t::iterator iter( m_NamedGraphs.find(contextU) ); if (iter != m_NamedGraphs.end()) { - return uno::Reference<rdf::XNamedGraph>(iter->second.get()); + return iter->second; } else { return nullptr; } @@ -1306,8 +1306,7 @@ librdf_Repository::createGraph(const uno::Reference< rdf::XURI > & i_xGraphName) } m_NamedGraphs.insert(std::make_pair(contextU, new librdf_NamedGraph(this, i_xGraphName))); - return uno::Reference<rdf::XNamedGraph>( - m_NamedGraphs.find(contextU)->second.get()); + return m_NamedGraphs.find(contextU)->second; } void SAL_CALL diff --git a/unoxml/source/xpath/nodelist.cxx b/unoxml/source/xpath/nodelist.cxx index 1298a5fa82c6..1b306aabc8d7 100644 --- a/unoxml/source/xpath/nodelist.cxx +++ b/unoxml/source/xpath/nodelist.cxx @@ -65,8 +65,7 @@ namespace XPath return nullptr; } xmlNodePtr const pNode = xmlXPathNodeSetItem(m_pNodeSet, index); - Reference< XNode > const xNode(m_pDocument->GetCNode(pNode).get()); - return xNode; + return m_pDocument->GetCNode(pNode); } } |