tdf#39593 Remove DOM::CNode::GetImplementation
Replace with comphelper::getUnoTunnelImplementation.
Change-Id: If98801fd85bf0967c54e1924a04b6de371868942
Reviewed-on: https://gerrit.libreoffice.org/74234
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
diff --git a/unoxml/inc/node.hxx b/unoxml/inc/node.hxx
index 216f80e..e35ab3a 100644
--- a/unoxml/inc/node.hxx
+++ b/unoxml/inc/node.hxx
@@ -119,8 +119,7 @@
virtual ~CNode() override;
static CNode * GetImplementation(css::uno::Reference<
css::uno::XInterface> const& xNode);
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
xmlNodePtr GetNodePtr() { return m_aNodePtr; }
diff --git a/unoxml/source/dom/element.cxx b/unoxml/source/dom/element.cxx
index f7cae19..6ed9ba1 100644
--- a/unoxml/source/dom/element.cxx
+++ b/unoxml/source/dom/element.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/xml/sax/FastToken.hpp>
#include <comphelper/attributelist.hxx>
#include <comphelper/servicehelper.hxx>
#include <node.hxx>
#include "attr.hxx"
@@ -472,7 +473,7 @@
}
::rtl::Reference<CNode> const pCNode(
CNode::GetImplementation(Reference<XNode>(oldAttr.get())));
comphelper::getUnoTunnelImplementation<CNode>(Reference<XNode>(oldAttr.get())));
if (!pCNode.is()) { throw RuntimeException(); }
xmlNodePtr const pNode = pCNode->GetNodePtr();
@@ -532,7 +533,7 @@
// get the implementation
CAttr *const pCAttr = dynamic_cast<CAttr*>(
CNode::GetImplementation(xNewAttr));
comphelper::getUnoTunnelImplementation<CNode>(xNewAttr));
if (!pCAttr) { throw RuntimeException(); }
xmlAttrPtr const pAttr =
reinterpret_cast<xmlAttrPtr>(pCAttr->GetNodePtr());
diff --git a/unoxml/source/dom/node.cxx b/unoxml/source/dom/node.cxx
index f486182..7171e6c 100644
--- a/unoxml/source/dom/node.cxx
+++ b/unoxml/source/dom/node.cxx
@@ -168,15 +168,9 @@
}
}
CNode *
CNode::GetImplementation(uno::Reference<uno::XInterface> const& xNode)
const css::uno::Sequence< sal_Int8 > & CNode::getUnoTunnelId() throw()
{
uno::Reference<lang::XUnoTunnel> const xUnoTunnel(xNode, UNO_QUERY);
if (!xUnoTunnel.is()) { return nullptr; }
CNode *const pCNode( reinterpret_cast< CNode* >(
::sal::static_int_cast< sal_IntPtr >(
xUnoTunnel->getSomething(theCNodeUnoTunnelId::get().getSeq()))));
return pCNode;
return theCNodeUnoTunnelId::get().getSeq();
}
CDocument & CNode::GetOwnerDocument()
@@ -290,7 +284,7 @@
if (nullptr == m_aNodePtr) { return nullptr; }
CNode *const pNewChild(CNode::GetImplementation(xNewChild));
CNode *const pNewChild(comphelper::getUnoTunnelImplementation<CNode>(xNewChild));
if (!pNewChild) { throw RuntimeException(); }
xmlNodePtr const cur = pNewChild->GetNodePtr();
if (!cur) { throw RuntimeException(); }
@@ -645,8 +639,8 @@
::osl::ClearableMutexGuard guard(m_rMutex);
CNode *const pNewNode(CNode::GetImplementation(newChild));
CNode *const pRefNode(CNode::GetImplementation(refChild));
CNode *const pNewNode(comphelper::getUnoTunnelImplementation<CNode>(newChild));
CNode *const pRefNode(comphelper::getUnoTunnelImplementation<CNode>(refChild));
if (!pNewNode || !pRefNode) { throw RuntimeException(); }
xmlNodePtr const pNewChild(pNewNode->GetNodePtr());
xmlNodePtr const pRefChild(pRefNode->GetNodePtr());
@@ -753,7 +747,7 @@
Reference<XNode> xReturn( xOldChild );
::rtl::Reference<CNode> const pOld(CNode::GetImplementation(xOldChild));
::rtl::Reference<CNode> const pOld(comphelper::getUnoTunnelImplementation<CNode>(xOldChild));
if (!pOld.is()) { throw RuntimeException(); }
xmlNodePtr const old = pOld->GetNodePtr();
if (!old) { throw RuntimeException(); }
@@ -825,9 +819,9 @@
::osl::ClearableMutexGuard guard(m_rMutex);
::rtl::Reference<CNode> const pOldNode(
CNode::GetImplementation(xOldChild));
comphelper::getUnoTunnelImplementation<CNode>(xOldChild));
::rtl::Reference<CNode> const pNewNode(
CNode::GetImplementation(xNewChild));
comphelper::getUnoTunnelImplementation<CNode>(xNewChild));
if (!pOldNode.is() || !pNewNode.is()) { throw RuntimeException(); }
xmlNodePtr const pOld = pOldNode->GetNodePtr();
xmlNodePtr const pNew = pNewNode->GetNodePtr();
@@ -1000,7 +994,7 @@
CNode::getSomething(Sequence< ::sal_Int8 > const& rId)
{
if ((rId.getLength() == 16) &&
(0 == memcmp(theCNodeUnoTunnelId::get().getSeq().getConstArray(),
(0 == memcmp(getUnoTunnelId().getConstArray(),
rId.getConstArray(), 16)))
{
return ::sal::static_int_cast< sal_Int64 >(
diff --git a/unoxml/source/xpath/xpathapi.cxx b/unoxml/source/xpath/xpathapi.cxx
index 415f565..874f4e6 100644
--- a/unoxml/source/xpath/xpathapi.cxx
+++ b/unoxml/source/xpath/xpathapi.cxx
@@ -36,6 +36,7 @@
#include <node.hxx>
#include "../dom/document.hxx"
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
using namespace css::io;
@@ -135,7 +136,7 @@
static void lcl_collectNamespaces(
nsmap_t & rNamespaces, Reference< XNode > const& xNamespaceNode)
{
DOM::CNode *const pCNode(DOM::CNode::GetImplementation(xNamespaceNode));
DOM::CNode *const pCNode(comphelper::getUnoTunnelImplementation<DOM::CNode>(xNamespaceNode));
if (!pCNode) { throw RuntimeException(); }
::osl::MutexGuard const g(pCNode->GetOwnerDocument().GetMutex());
@@ -314,11 +315,11 @@
// get the node and document
::rtl::Reference<DOM::CDocument> const pCDoc(
dynamic_cast<DOM::CDocument*>( DOM::CNode::GetImplementation(
dynamic_cast<DOM::CDocument*>( comphelper::getUnoTunnelImplementation<DOM::CNode>(
xContextNode->getOwnerDocument())));
if (!pCDoc.is()) { throw RuntimeException(); }
DOM::CNode *const pCNode = DOM::CNode::GetImplementation(xContextNode);
DOM::CNode *const pCNode = comphelper::getUnoTunnelImplementation<DOM::CNode>(xContextNode);
if (!pCNode) { throw RuntimeException(); }
::osl::MutexGuard const g(pCDoc->GetMutex()); // lock the document!