XUnoTunnel->dynamic_cast in CNode
Change-Id: Ifcedcb6fc4e20da6351e4ccf035a3fe06d607961 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145507 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include <com/sun/star/uno/Reference.h>
|
#include <com/sun/star/uno/Reference.h>
|
||||||
#include <com/sun/star/uno/Sequence.h>
|
#include <com/sun/star/uno/Sequence.h>
|
||||||
#include <com/sun/star/lang/XUnoTunnel.hpp>
|
|
||||||
#include <com/sun/star/xml/dom/XNode.hpp>
|
#include <com/sun/star/xml/dom/XNode.hpp>
|
||||||
#include <com/sun/star/xml/dom/XNodeList.hpp>
|
#include <com/sun/star/xml/dom/XNodeList.hpp>
|
||||||
#include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
|
#include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
|
||||||
@@ -89,7 +88,8 @@ namespace DOM
|
|||||||
|
|
||||||
class CDocument;
|
class CDocument;
|
||||||
|
|
||||||
class CNode : public cppu::WeakImplHelper< css::xml::dom::XNode, css::lang::XUnoTunnel, css::xml::dom::events::XEventTarget >
|
class SAL_LOPLUGIN_ANNOTATE("crosscast") CNode
|
||||||
|
: public cppu::WeakImplHelper< css::xml::dom::XNode, css::xml::dom::events::XEventTarget >
|
||||||
{
|
{
|
||||||
friend class CDocument;
|
friend class CDocument;
|
||||||
friend class CElement;
|
friend class CElement;
|
||||||
@@ -123,8 +123,6 @@ namespace DOM
|
|||||||
|
|
||||||
virtual ~CNode() override;
|
virtual ~CNode() override;
|
||||||
|
|
||||||
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() noexcept;
|
|
||||||
|
|
||||||
xmlNodePtr GetNodePtr() { return m_aNodePtr; }
|
xmlNodePtr GetNodePtr() { return m_aNodePtr; }
|
||||||
|
|
||||||
virtual CDocument & GetOwnerDocument();
|
virtual CDocument & GetOwnerDocument();
|
||||||
@@ -290,10 +288,6 @@ namespace DOM
|
|||||||
sal_Bool useCapture) override;
|
sal_Bool useCapture) override;
|
||||||
|
|
||||||
virtual sal_Bool SAL_CALL dispatchEvent(const css::uno::Reference< css::xml::dom::events::XEvent >& evt) override;
|
virtual sal_Bool SAL_CALL dispatchEvent(const css::uno::Reference< css::xml::dom::events::XEvent >& evt) override;
|
||||||
|
|
||||||
// --- XUnoTunnel
|
|
||||||
virtual ::sal_Int64 SAL_CALL
|
|
||||||
getSomething(css::uno::Sequence< ::sal_Int8 > const& rId) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// eliminate redundant namespace declarations
|
/// eliminate redundant namespace declarations
|
||||||
|
@@ -470,7 +470,7 @@ namespace DOM
|
|||||||
}
|
}
|
||||||
|
|
||||||
::rtl::Reference<CNode> const pCNode(
|
::rtl::Reference<CNode> const pCNode(
|
||||||
comphelper::getFromUnoTunnel<CNode>(Reference<XNode>(oldAttr)));
|
dynamic_cast<CNode*>(oldAttr.get()));
|
||||||
if (!pCNode.is()) { throw RuntimeException(); }
|
if (!pCNode.is()) { throw RuntimeException(); }
|
||||||
|
|
||||||
xmlNodePtr const pNode = pCNode->GetNodePtr();
|
xmlNodePtr const pNode = pCNode->GetNodePtr();
|
||||||
@@ -529,8 +529,7 @@ namespace DOM
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the implementation
|
// get the implementation
|
||||||
CAttr *const pCAttr = dynamic_cast<CAttr*>(
|
CAttr *const pCAttr = dynamic_cast<CAttr*>(xNewAttr.get());
|
||||||
comphelper::getFromUnoTunnel<CNode>(xNewAttr));
|
|
||||||
if (!pCAttr) { throw RuntimeException(); }
|
if (!pCAttr) { throw RuntimeException(); }
|
||||||
xmlAttrPtr const pAttr =
|
xmlAttrPtr const pAttr =
|
||||||
reinterpret_cast<xmlAttrPtr>(pCAttr->GetNodePtr());
|
reinterpret_cast<xmlAttrPtr>(pCAttr->GetNodePtr());
|
||||||
|
@@ -161,12 +161,6 @@ namespace DOM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const css::uno::Sequence< sal_Int8 > & CNode::getUnoTunnelId() noexcept
|
|
||||||
{
|
|
||||||
static const comphelper::UnoIdInit theCNodeUnoTunnelId;
|
|
||||||
return theCNodeUnoTunnelId.getSeq();
|
|
||||||
}
|
|
||||||
|
|
||||||
CDocument & CNode::GetOwnerDocument()
|
CDocument & CNode::GetOwnerDocument()
|
||||||
{
|
{
|
||||||
OSL_ASSERT(m_xDocument.is());
|
OSL_ASSERT(m_xDocument.is());
|
||||||
@@ -300,7 +294,7 @@ namespace DOM
|
|||||||
|
|
||||||
if (nullptr == m_aNodePtr) { return nullptr; }
|
if (nullptr == m_aNodePtr) { return nullptr; }
|
||||||
|
|
||||||
CNode *const pNewChild(comphelper::getFromUnoTunnel<CNode>(xNewChild));
|
CNode *const pNewChild(dynamic_cast<CNode*>(xNewChild.get()));
|
||||||
if (!pNewChild) { throw RuntimeException(); }
|
if (!pNewChild) { throw RuntimeException(); }
|
||||||
xmlNodePtr const cur = pNewChild->GetNodePtr();
|
xmlNodePtr const cur = pNewChild->GetNodePtr();
|
||||||
if (!cur) { throw RuntimeException(); }
|
if (!cur) { throw RuntimeException(); }
|
||||||
@@ -639,8 +633,8 @@ namespace DOM
|
|||||||
|
|
||||||
::osl::ClearableMutexGuard guard(m_rMutex);
|
::osl::ClearableMutexGuard guard(m_rMutex);
|
||||||
|
|
||||||
CNode *const pNewNode(comphelper::getFromUnoTunnel<CNode>(newChild));
|
CNode *const pNewNode(dynamic_cast<CNode*>(newChild.get()));
|
||||||
CNode *const pRefNode(comphelper::getFromUnoTunnel<CNode>(refChild));
|
CNode *const pRefNode(dynamic_cast<CNode*>(refChild.get()));
|
||||||
if (!pNewNode || !pRefNode) { throw RuntimeException(); }
|
if (!pNewNode || !pRefNode) { throw RuntimeException(); }
|
||||||
xmlNodePtr const pNewChild(pNewNode->GetNodePtr());
|
xmlNodePtr const pNewChild(pNewNode->GetNodePtr());
|
||||||
xmlNodePtr const pRefChild(pRefNode->GetNodePtr());
|
xmlNodePtr const pRefChild(pRefNode->GetNodePtr());
|
||||||
@@ -740,7 +734,7 @@ namespace DOM
|
|||||||
|
|
||||||
Reference<XNode> xReturn( xOldChild );
|
Reference<XNode> xReturn( xOldChild );
|
||||||
|
|
||||||
::rtl::Reference<CNode> const pOld(comphelper::getFromUnoTunnel<CNode>(xOldChild));
|
::rtl::Reference<CNode> const pOld(dynamic_cast<CNode*>(xOldChild.get()));
|
||||||
if (!pOld.is()) { throw RuntimeException(); }
|
if (!pOld.is()) { throw RuntimeException(); }
|
||||||
xmlNodePtr const old = pOld->GetNodePtr();
|
xmlNodePtr const old = pOld->GetNodePtr();
|
||||||
if (!old) { throw RuntimeException(); }
|
if (!old) { throw RuntimeException(); }
|
||||||
@@ -808,10 +802,8 @@ namespace DOM
|
|||||||
|
|
||||||
::osl::ClearableMutexGuard guard(m_rMutex);
|
::osl::ClearableMutexGuard guard(m_rMutex);
|
||||||
|
|
||||||
::rtl::Reference<CNode> const pOldNode(
|
::rtl::Reference<CNode> const pOldNode(dynamic_cast<CNode*>(xOldChild.get()));
|
||||||
comphelper::getFromUnoTunnel<CNode>(xOldChild));
|
::rtl::Reference<CNode> const pNewNode(dynamic_cast<CNode*>(xNewChild.get()));
|
||||||
::rtl::Reference<CNode> const pNewNode(
|
|
||||||
comphelper::getFromUnoTunnel<CNode>(xNewChild));
|
|
||||||
if (!pOldNode.is() || !pNewNode.is()) { throw RuntimeException(); }
|
if (!pOldNode.is() || !pNewNode.is()) { throw RuntimeException(); }
|
||||||
xmlNodePtr const pOld = pOldNode->GetNodePtr();
|
xmlNodePtr const pOld = pOldNode->GetNodePtr();
|
||||||
xmlNodePtr const pNew = pNewNode->GetNodePtr();
|
xmlNodePtr const pNew = pNewNode->GetNodePtr();
|
||||||
@@ -976,12 +968,6 @@ namespace DOM
|
|||||||
pDispatcher->dispatchEvent(*pDocument, m_rMutex, pNode, this, evt);
|
pDispatcher->dispatchEvent(*pDocument, m_rMutex, pNode, this, evt);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
::sal_Int64 SAL_CALL
|
|
||||||
CNode::getSomething(Sequence< ::sal_Int8 > const& rId)
|
|
||||||
{
|
|
||||||
return comphelper::getSomethingImpl(rId, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -109,7 +109,7 @@ namespace XPath
|
|||||||
static void lcl_collectNamespaces(
|
static void lcl_collectNamespaces(
|
||||||
nsmap_t & rNamespaces, Reference< XNode > const& xNamespaceNode)
|
nsmap_t & rNamespaces, Reference< XNode > const& xNamespaceNode)
|
||||||
{
|
{
|
||||||
DOM::CNode *const pCNode(comphelper::getFromUnoTunnel<DOM::CNode>(xNamespaceNode));
|
DOM::CNode *const pCNode(dynamic_cast<DOM::CNode*>(xNamespaceNode.get()));
|
||||||
if (!pCNode) { throw RuntimeException(); }
|
if (!pCNode) { throw RuntimeException(); }
|
||||||
|
|
||||||
::osl::MutexGuard const g(pCNode->GetOwnerDocument().GetMutex());
|
::osl::MutexGuard const g(pCNode->GetOwnerDocument().GetMutex());
|
||||||
@@ -291,11 +291,10 @@ namespace XPath
|
|||||||
|
|
||||||
// get the node and document
|
// get the node and document
|
||||||
::rtl::Reference<DOM::CDocument> const pCDoc(
|
::rtl::Reference<DOM::CDocument> const pCDoc(
|
||||||
dynamic_cast<DOM::CDocument*>( comphelper::getFromUnoTunnel<DOM::CNode>(
|
dynamic_cast<DOM::CDocument*>(xContextNode->getOwnerDocument().get()));
|
||||||
xContextNode->getOwnerDocument())));
|
|
||||||
if (!pCDoc.is()) { throw RuntimeException(); }
|
if (!pCDoc.is()) { throw RuntimeException(); }
|
||||||
|
|
||||||
DOM::CNode *const pCNode = comphelper::getFromUnoTunnel<DOM::CNode>(xContextNode);
|
DOM::CNode *const pCNode = dynamic_cast<DOM::CNode*>(xContextNode.get());
|
||||||
if (!pCNode) { throw RuntimeException(); }
|
if (!pCNode) { throw RuntimeException(); }
|
||||||
|
|
||||||
::osl::MutexGuard const g(pCDoc->GetMutex()); // lock the document!
|
::osl::MutexGuard const g(pCDoc->GetMutex()); // lock the document!
|
||||||
|
Reference in New Issue
Block a user