summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-07-20 18:26:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-21 08:49:56 +0200
commit7272951c121735a7350fa70840b255b7ef831f1a (patch)
tree52033c5b70c6c2c24ec5c507b7d38eca257356a5
parentd943b42214321c630147176210733399c57e6f19 (diff)
loplugin:referencecasting in unotools..uui
Change-Id: Ia2c991591e65deb00710ab7a5b73bc42ae6b1b46 Reviewed-on: https://gerrit.libreoffice.org/76031 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--unotest/source/cpp/macros_test.cxx4
-rw-r--r--unotools/source/config/configitem.cxx2
-rw-r--r--unotools/source/misc/mediadescriptor.cxx2
-rw-r--r--unoxml/source/dom/attributesmap.cxx16
-rw-r--r--unoxml/source/dom/document.cxx16
-rw-r--r--unoxml/source/dom/element.cxx4
-rw-r--r--unoxml/source/rdf/librdf_repository.cxx25
-rw-r--r--uui/source/iahndl-filter.cxx4
-rw-r--r--uui/source/passwordcontainer.cxx16
9 files changed, 31 insertions, 58 deletions
diff --git a/unotest/source/cpp/macros_test.cxx b/unotest/source/cpp/macros_test.cxx
index f8449367876d..ffc2b970393c 100644
--- a/unotest/source/cpp/macros_test.cxx
+++ b/unotest/source/cpp/macros_test.cxx
@@ -25,8 +25,6 @@ namespace unotest {
uno::Reference<css::lang::XComponent> MacrosTest::loadFromDesktop(const OUString& rURL, const OUString& rDocService, const uno::Sequence<beans::PropertyValue>& rExtraArgs)
{
CPPUNIT_ASSERT_MESSAGE("no desktop", mxDesktop.is());
- uno::Reference<frame::XComponentLoader> xLoader(mxDesktop, uno::UNO_QUERY);
- CPPUNIT_ASSERT_MESSAGE("no loader", xLoader.is());
std::vector<beans::PropertyValue> args;
beans::PropertyValue aMacroValue;
aMacroValue.Name = "MacroExecutionMode";
@@ -47,7 +45,7 @@ uno::Reference<css::lang::XComponent> MacrosTest::loadFromDesktop(const OUString
args.insert(args.end(), rExtraArgs.begin(), rExtraArgs.end());
- uno::Reference<lang::XComponent> xComponent = xLoader->loadComponentFromURL(rURL, "_default", 0, comphelper::containerToSequence(args));
+ uno::Reference<lang::XComponent> xComponent = mxDesktop->loadComponentFromURL(rURL, "_default", 0, comphelper::containerToSequence(args));
OUString sMessage = "loading failed: " + rURL;
CPPUNIT_ASSERT_MESSAGE(OUStringToOString( sMessage, RTL_TEXTENCODING_UTF8 ).getStr( ), xComponent.is());
return xComponent;
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx
index 36cc9b68ed6a..29097d32fd56 100644
--- a/unotools/source/config/configitem.cxx
+++ b/unotools/source/config/configitem.cxx
@@ -351,7 +351,7 @@ Sequence< sal_Bool > ConfigItem::GetReadOnlyStates(const css::uno::Sequence< OUS
}
else
{
- xNode.set( xHierarchyAccess, UNO_QUERY );
+ xNode = xHierarchyAccess;
}
xSet.set(xNode, UNO_QUERY);
diff --git a/unotools/source/misc/mediadescriptor.cxx b/unotools/source/misc/mediadescriptor.cxx
index 98f27fc5bc37..18df713e52d2 100644
--- a/unotools/source/misc/mediadescriptor.cxx
+++ b/unotools/source/misc/mediadescriptor.cxx
@@ -365,7 +365,7 @@ bool MediaDescriptor::isStreamReadOnly() const
css::uno::Reference< css::ucb::XContent > xContent = getUnpackedValueOrDefault(MediaDescriptor::PROP_UCBCONTENT(), css::uno::Reference< css::ucb::XContent >());
if (xContent.is())
{
- css::uno::Reference< css::ucb::XContentIdentifier > xId(xContent->getIdentifier(), css::uno::UNO_QUERY);
+ css::uno::Reference< css::ucb::XContentIdentifier > xId = xContent->getIdentifier();
OUString aScheme;
if (xId.is())
aScheme = xId->getContentProviderScheme();
diff --git a/unoxml/source/dom/attributesmap.cxx b/unoxml/source/dom/attributesmap.cxx
index 4c0a86c17074..9ff0298bdc7b 100644
--- a/unoxml/source/dom/attributesmap.cxx
+++ b/unoxml/source/dom/attributesmap.cxx
@@ -164,9 +164,7 @@ namespace DOM
static_cast<OWeakObject*>(this),
DOMExceptionType_NOT_FOUND_ERR);
}
- Reference< XNode > const xRet(
- m_pElement->removeAttributeNode(xAttr), UNO_QUERY);
- return xRet;
+ return m_pElement->removeAttributeNode(xAttr);
}
/**
@@ -185,9 +183,7 @@ namespace DOM
static_cast<OWeakObject*>(this),
DOMExceptionType_NOT_FOUND_ERR);
}
- Reference< XNode > const xRet(
- m_pElement->removeAttributeNode(xAttr), UNO_QUERY);
- return xRet;
+ return m_pElement->removeAttributeNode(xAttr);
}
/**
@@ -204,9 +200,7 @@ namespace DOM
DOMExceptionType_HIERARCHY_REQUEST_ERR);
}
// no MutexGuard needed: m_pElement is const
- Reference< XNode > const xRet(
- m_pElement->setAttributeNode(xAttr), UNO_QUERY);
- return xRet;
+ return m_pElement->setAttributeNode(xAttr);
}
/**
@@ -223,9 +217,7 @@ namespace DOM
DOMExceptionType_HIERARCHY_REQUEST_ERR);
}
// no MutexGuard needed: m_pElement is const
- Reference< XNode > const xRet(
- m_pElement->setAttributeNodeNS(xAttr), UNO_QUERY);
- return xRet;
+ return m_pElement->setAttributeNodeNS(xAttr);
}
}
diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx
index fc89b8aa4980..4b7d246e867d 100644
--- a/unoxml/source/dom/document.cxx
+++ b/unoxml/source/dom/document.cxx
@@ -726,7 +726,7 @@ namespace DOM
Reference< XAttr > const xNew =
xDocument->createAttribute(xAttr->getName());
xNew->setValue(xAttr->getValue());
- xNode.set(xNew, UNO_QUERY);
+ xNode = xNew;
break;
}
case NodeType_CDATA_SECTION_NODE:
@@ -735,7 +735,7 @@ namespace DOM
UNO_QUERY_THROW);
Reference< XCDATASection > const xNewCData =
xDocument->createCDATASection(xCData->getData());
- xNode.set(xNewCData, UNO_QUERY);
+ xNode = xNewCData;
break;
}
case NodeType_COMMENT_NODE:
@@ -744,7 +744,7 @@ namespace DOM
UNO_QUERY_THROW);
Reference< XComment > const xNewComment =
xDocument->createComment(xComment->getData());
- xNode.set(xNewComment, UNO_QUERY);
+ xNode = xNewComment;
break;
}
case NodeType_DOCUMENT_FRAGMENT_NODE:
@@ -753,7 +753,7 @@ namespace DOM
UNO_QUERY_THROW);
Reference< XDocumentFragment > const xNewFrag =
xDocument->createDocumentFragment();
- xNode.set(xNewFrag, UNO_QUERY);
+ xNode = xNewFrag;
break;
}
case NodeType_ELEMENT_NODE:
@@ -798,7 +798,7 @@ namespace DOM
}
}
}
- xNode.set(xNewElement, UNO_QUERY);
+ xNode = xNewElement;
break;
}
case NodeType_ENTITY_REFERENCE_NODE:
@@ -807,7 +807,7 @@ namespace DOM
UNO_QUERY_THROW);
Reference< XEntityReference > const xNewRef(
xDocument->createEntityReference(xRef->getNodeName()));
- xNode.set(xNewRef, UNO_QUERY);
+ xNode = xNewRef;
break;
}
case NodeType_PROCESSING_INSTRUCTION_NODE:
@@ -817,7 +817,7 @@ namespace DOM
Reference< XProcessingInstruction > const xNewPi(
xDocument->createProcessingInstruction(
xPi->getTarget(), xPi->getData()));
- xNode.set(xNewPi, UNO_QUERY);
+ xNode = xNewPi;
break;
}
case NodeType_TEXT_NODE:
@@ -825,7 +825,7 @@ namespace DOM
Reference< XText > const xText(xImportedNode, UNO_QUERY_THROW);
Reference< XText > const xNewText(
xDocument->createTextNode(xText->getData()));
- xNode.set(xNewText, UNO_QUERY);
+ xNode = xNewText;
break;
}
case NodeType_ENTITY_NODE:
diff --git a/unoxml/source/dom/element.cxx b/unoxml/source/dom/element.cxx
index 6ed9ba1ebd1e..e5e82b2613cd 100644
--- a/unoxml/source/dom/element.cxx
+++ b/unoxml/source/dom/element.cxx
@@ -632,7 +632,7 @@ namespace DOM
"DOMAttrModified"), UNO_QUERY);
event->initMutationEvent("DOMAttrModified",
true, false,
- Reference< XNode >(getAttributeNode(name), UNO_QUERY),
+ getAttributeNode(name),
oldValue, value, name, aChangeType);
guard.clear(); // release mutex before calling event handlers
@@ -713,7 +713,7 @@ namespace DOM
"DOMAttrModified"), UNO_QUERY);
event->initMutationEvent(
"DOMAttrModified", true, false,
- Reference< XNode >(getAttributeNodeNS(namespaceURI, OUString(reinterpret_cast<char const *>(pLName), strlen(reinterpret_cast<char const *>(pLName)), RTL_TEXTENCODING_UTF8)), UNO_QUERY),
+ getAttributeNodeNS(namespaceURI, OUString(reinterpret_cast<char const *>(pLName), strlen(reinterpret_cast<char const *>(pLName)), RTL_TEXTENCODING_UTF8)),
oldValue, value, qualifiedName, aChangeType);
guard.clear(); // release mutex before calling event handlers
diff --git a/unoxml/source/rdf/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx
index 6268da4ff4c9..26f4a950518c 100644
--- a/unoxml/source/rdf/librdf_repository.cxx
+++ b/unoxml/source/rdf/librdf_repository.cxx
@@ -2287,10 +2287,8 @@ librdf_TypeConverter::Statement librdf_TypeConverter::extractStatement_NoLock(
{
std::shared_ptr<Resource> const pSubject(
extractResource_NoLock(i_xSubject));
- const uno::Reference<rdf::XResource> xPredicate(i_xPredicate,
- uno::UNO_QUERY);
std::shared_ptr<URI> const pPredicate(
- std::dynamic_pointer_cast<URI>(extractResource_NoLock(xPredicate)));
+ std::dynamic_pointer_cast<URI>(extractResource_NoLock(i_xPredicate)));
std::shared_ptr<Node> const pObject(extractNode_NoLock(i_xObject));
return Statement(pSubject, pPredicate, pObject);
}
@@ -2381,8 +2379,7 @@ librdf_TypeConverter::convertToXResource(librdf_node* i_pNode) const
OString(reinterpret_cast<const sal_Char*>(label)),
RTL_TEXTENCODING_UTF8) );
try {
- return uno::Reference<rdf::XResource>(
- rdf::BlankNode::create(m_xContext, labelU), uno::UNO_QUERY);
+ return rdf::BlankNode::create(m_xContext, labelU);
} catch (const lang::IllegalArgumentException &) {
css::uno::Any anyEx = cppu::getCaughtException();
throw lang::WrappedTargetRuntimeException(
@@ -2390,8 +2387,7 @@ librdf_TypeConverter::convertToXResource(librdf_node* i_pNode) const
"illegal blank node label", m_rRep, anyEx);
}
} else {
- return uno::Reference<rdf::XResource>(convertToXURI(i_pNode),
- uno::UNO_QUERY);
+ return convertToXURI(i_pNode);
}
}
@@ -2400,8 +2396,7 @@ librdf_TypeConverter::convertToXNode(librdf_node* i_pNode) const
{
if (!i_pNode) return nullptr;
if (!librdf_node_is_literal(i_pNode)) {
- return uno::Reference<rdf::XNode>(convertToXResource(i_pNode),
- uno::UNO_QUERY);
+ return convertToXResource(i_pNode);
}
const unsigned char* value( librdf_node_get_literal_value(i_pNode) );
if (!value) {
@@ -2420,19 +2415,13 @@ librdf_TypeConverter::convertToXNode(librdf_node* i_pNode) const
const OUString langU( OStringToOUString(
OString(reinterpret_cast<const sal_Char*>(lang)),
RTL_TEXTENCODING_UTF8) );
- return uno::Reference<rdf::XNode>(
- rdf::Literal::createWithLanguage(m_xContext, valueU, langU),
- uno::UNO_QUERY);
+ return rdf::Literal::createWithLanguage(m_xContext, valueU, langU);
} else if (pType) {
uno::Reference<rdf::XURI> xType(convertToXURI(pType));
OSL_ENSURE(xType.is(), "convertToXNode: null uri");
- return uno::Reference<rdf::XNode>(
- rdf::Literal::createWithType(m_xContext, valueU, xType),
- uno::UNO_QUERY);
+ return rdf::Literal::createWithType(m_xContext, valueU, xType);
} else {
- return uno::Reference<rdf::XNode>(
- rdf::Literal::create(m_xContext, valueU),
- uno::UNO_QUERY);
+ return rdf::Literal::create(m_xContext, valueU);
}
}
diff --git a/uui/source/iahndl-filter.cxx b/uui/source/iahndl-filter.cxx
index a2cdb255a6d9..25a13a84e275 100644
--- a/uui/source/iahndl-filter.cxx
+++ b/uui/source/iahndl-filter.cxx
@@ -244,9 +244,7 @@ handleFilterOptionsRequest_(
document::XImporter > xImporter(
xFilterDialog, uno::UNO_QUERY );
if( xImporter.is() )
- xImporter->setTargetDocument(
- uno::Reference< lang::XComponent >(
- rRequest.rModel, uno::UNO_QUERY ) );
+ xImporter->setTargetDocument( rRequest.rModel );
xFilterProperties->setPropertyValues(
rRequest.rProperties );
diff --git a/uui/source/passwordcontainer.cxx b/uui/source/passwordcontainer.cxx
index 5335930c1199..7b94a87fd14d 100644
--- a/uui/source/passwordcontainer.cxx
+++ b/uui/source/passwordcontainer.cxx
@@ -123,8 +123,6 @@ bool PasswordContainerHelper::handleAuthenticationRequest(
OUString const & rURL,
uno::Reference< task::XInteractionHandler2 > const & xIH )
{
- uno::Reference< task::XInteractionHandler > xIH1(xIH, uno::UNO_QUERY);
-
// Is continuation even a XInteractionSupplyAuthentication2, which
// is derived from XInteractionSupplyAuthentication?
uno::Reference< ucb::XInteractionSupplyAuthentication2 >
@@ -174,12 +172,12 @@ bool PasswordContainerHelper::handleAuthenticationRequest(
{
task::UrlRecord aRec;
if ( !rURL.isEmpty() )
- aRec = m_xPasswordContainer->find(rURL, xIH1);
+ aRec = m_xPasswordContainer->find(rURL, xIH);
if ( !aRec.UserList.hasElements() )
{
// compat: try server name.
- aRec = m_xPasswordContainer->find(rRequest.ServerName, xIH1);
+ aRec = m_xPasswordContainer->find(rRequest.ServerName, xIH);
}
if ( fillContinuation( false,
@@ -198,13 +196,13 @@ bool PasswordContainerHelper::handleAuthenticationRequest(
task::UrlRecord aRec;
if ( !rURL.isEmpty() )
aRec = m_xPasswordContainer->findForName(
- rURL, rRequest.UserName, xIH1);
+ rURL, rRequest.UserName, xIH);
if ( !aRec.UserList.hasElements() )
{
// compat: try server name.
aRec = m_xPasswordContainer->findForName(
- rRequest.ServerName, rRequest.UserName, xIH1);
+ rRequest.ServerName, rRequest.UserName, xIH);
}
if ( fillContinuation( false,
@@ -233,8 +231,6 @@ bool PasswordContainerHelper::addRecord(
uno::Reference< task::XInteractionHandler2 > const & xIH,
bool bPersist )
{
- uno::Reference< task::XInteractionHandler > xIH1(xIH, uno::UNO_QUERY);
-
try
{
if ( !rUsername.isEmpty() )
@@ -254,13 +250,13 @@ bool PasswordContainerHelper::addRecord(
m_xPasswordContainer->addPersistent( rURL,
rUsername,
rPasswords,
- xIH1 );
+ xIH );
}
else
m_xPasswordContainer->add( rURL,
rUsername,
rPasswords,
- xIH1 );
+ xIH );
}
else
{