diff options
author | Michael Stahl <mst@openoffice.org> | 2011-01-19 20:27:25 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2011-01-19 20:27:25 +0100 |
commit | 06ebc79a5d723211d55be7a1c014299e71acfc20 (patch) | |
tree | accfda22c334df1a9d6747a9163108ad4e27ae00 /unoxml | |
parent | dde336f8f0357f39a8547fc8b05c09672df816bf (diff) |
xmlfix3: unoxml: replace CNode XUnoTunnel implementation with something sane
Diffstat (limited to 'unoxml')
-rw-r--r-- | unoxml/source/dom/node.cxx | 59 | ||||
-rw-r--r-- | unoxml/source/dom/node.hxx | 6 |
2 files changed, 54 insertions, 11 deletions
diff --git a/unoxml/source/dom/node.cxx b/unoxml/source/dom/node.cxx index 2b2885778ff4..0aa42d5d6d17 100644 --- a/unoxml/source/dom/node.cxx +++ b/unoxml/source/dom/node.cxx @@ -25,9 +25,21 @@ * ************************************************************************/ +#include <node.hxx> + #include <stdio.h> #include <string.h> -#include "node.hxx" + +#include <algorithm> + +#include <boost/bind.hpp> + +#include <rtl/uuid.h> +#include <rtl/instance.hxx> +#include <osl/mutex.hxx> + +#include <com/sun/star/xml/sax/FastToken.hpp> + #include "element.hxx" #include "text.hxx" #include "cdatasection.hxx" @@ -42,18 +54,28 @@ #include "childlist.hxx" #include "attr.hxx" -#include <com/sun/star/xml/sax/FastToken.hpp> -#include "rtl/instance.hxx" -#include "osl/mutex.hxx" #include "../events/eventdispatcher.hxx" #include "../events/mutationevent.hxx" -#include <boost/bind.hpp> -#include <algorithm> + + +using namespace ::com::sun::star; + namespace { //see CNode::remove struct NodeMutex: public ::rtl::Static<osl::Mutex, NodeMutex> {}; + struct UnoTunnelId + : public ::rtl::StaticWithInit< Sequence<sal_Int8>, UnoTunnelId > + { + Sequence<sal_Int8> operator() () + { + Sequence<sal_Int8> ret(16); + rtl_createUuid( + reinterpret_cast<sal_uInt8*>(ret.getArray()), 0, sal_True); + return ret; + } + }; } namespace DOM @@ -269,7 +291,7 @@ namespace DOM xmlNodePtr CNode::getNodePtr(const Reference< XNode >& aNode) { try { - CNode* pNode=dynamic_cast<CNode*>(aNode.get()); + CNode *const pNode = GetImplementation(aNode); if( pNode ) return pNode->m_aNodePtr; } @@ -308,6 +330,17 @@ namespace DOM invalidate(); } + CNode * + CNode::GetImplementation(uno::Reference<uno::XInterface> const& xNode) + { + uno::Reference<lang::XUnoTunnel> const xUnoTunnel(xNode, UNO_QUERY); + if (!xUnoTunnel.is()) { return 0; } + CNode *const pCNode( reinterpret_cast< CNode* >( + ::sal::static_int_cast< sal_IntPtr >( + xUnoTunnel->getSomething(UnoTunnelId::get())))); + return pCNode; + } + ::rtl::Reference< CDocument > CNode::GetOwnerDocument_Impl() { if (0 == m_aNodePtr) { @@ -1044,10 +1077,18 @@ namespace DOM return sal_True; } - ::sal_Int64 SAL_CALL CNode::getSomething(const Sequence< ::sal_Int8 >& /*aIdentifier*/) + ::sal_Int64 SAL_CALL + CNode::getSomething(Sequence< ::sal_Int8 > const& rId) throw (RuntimeException) { - return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(m_aNodePtr)); + if ((rId.getLength() == 16) && + (0 == rtl_compareMemory(UnoTunnelId::get().getConstArray(), + rId.getConstArray(), 16))) + { + return ::sal::static_int_cast< sal_Int64 >( + reinterpret_cast< sal_IntPtr >(this) ); + } + return 0; } } diff --git a/unoxml/source/dom/node.hxx b/unoxml/source/dom/node.hxx index 6fc6c5059d6b..2ad773b725bb 100644 --- a/unoxml/source/dom/node.hxx +++ b/unoxml/source/dom/node.hxx @@ -156,7 +156,8 @@ namespace DOM // get the libxml node implementation static xmlNodePtr getNodePtr(const Reference< XNode >& aNode); - //static Sequence< sal_Int8 > + static CNode * GetImplementation(::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface> const& xNode); // recursively create SAX events virtual void SAL_CALL saxify( @@ -346,7 +347,8 @@ namespace DOM throw(RuntimeException, EventException); // --- XUnoTunnel - virtual ::sal_Int64 SAL_CALL getSomething(const Sequence< ::sal_Int8 >& aIdentifier) + virtual ::sal_Int64 SAL_CALL + getSomething(Sequence< ::sal_Int8 > const& rId) throw (RuntimeException); }; |