diff options
author | Michael Stahl <mst@openoffice.org> | 2011-01-19 20:27:23 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2011-01-19 20:27:23 +0100 |
commit | 8ab417f83b7a6ee8a11deb5f534d6fc6c6fd9899 (patch) | |
tree | 7a6695580f4dfa2c04b64f7cb7e5a04ee5e0a553 /unoxml/source/dom | |
parent | fd40abc5e13078494945f09cf3be58f867d8a936 (diff) |
xmlfix3: #i113682#: unoxml: no more globals in CEventDispatcher:
instead CDocument now has a CEventDispatcher member.
Diffstat (limited to 'unoxml/source/dom')
-rw-r--r-- | unoxml/source/dom/document.cxx | 8 | ||||
-rw-r--r-- | unoxml/source/dom/document.hxx | 10 | ||||
-rw-r--r-- | unoxml/source/dom/node.cxx | 34 | ||||
-rw-r--r-- | unoxml/source/dom/node.hxx | 5 |
4 files changed, 45 insertions, 12 deletions
diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx index eeab43bb4963..404dd9add82d 100644 --- a/unoxml/source/dom/document.cxx +++ b/unoxml/source/dom/document.cxx @@ -45,6 +45,7 @@ #include "../events/mutationevent.hxx" #include "../events/uievent.hxx" #include "../events/mouseevent.hxx" +#include "../events/eventdispatcher.hxx" #include <string.h> @@ -63,9 +64,16 @@ namespace DOM NodeType_DOCUMENT_NODE, reinterpret_cast<xmlNodePtr>(aDocPtr)) , m_aDocPtr(aDocPtr) , m_streamListeners() + , m_pEventDispatcher(new events::CEventDispatcher()) { } + events::CEventDispatcher & CDocument::GetEventDispatcher() + { + return *m_pEventDispatcher; + } + + void SAL_CALL CDocument::saxify( const Reference< XDocumentHandler >& i_xHandler) { i_xHandler->startDocument(); diff --git a/unoxml/source/dom/document.hxx b/unoxml/source/dom/document.hxx index 92793cecc308..2477efa7f26b 100644 --- a/unoxml/source/dom/document.hxx +++ b/unoxml/source/dom/document.hxx @@ -30,6 +30,8 @@ #include <list> #include <set> +#include <memory> + #include <sal/types.h> #include <cppuhelper/implbase6.hxx> #include <com/sun/star/uno/Reference.h> @@ -66,6 +68,10 @@ using namespace com::sun::star::xml::dom::events; namespace DOM { + namespace events { + class CEventDispatcher; + } + typedef ::cppu::ImplInheritanceHelper6< CNode, XDocument, XDocumentEvent, XActiveDataControl, XActiveDataSource, @@ -85,9 +91,13 @@ namespace DOM listenerlist_t m_streamListeners; Reference< XOutputStream > m_rOutputStream; + ::std::auto_ptr<events::CEventDispatcher> const m_pEventDispatcher; + protected: CDocument(xmlDocPtr aDocPtr); + events::CEventDispatcher & GetEventDispatcher(); + public: virtual ~CDocument(); diff --git a/unoxml/source/dom/node.cxx b/unoxml/source/dom/node.cxx index 776158bab190..3554811d8b45 100644 --- a/unoxml/source/dom/node.cxx +++ b/unoxml/source/dom/node.cxx @@ -285,7 +285,7 @@ namespace DOM // keep containing document alive // (but not if this is a document; that would create a leak!) , m_xDocument( (m_aNodePtr->type != XML_DOCUMENT_NODE) - ? getOwnerDocument() : 0 ) + ? GetOwnerDocument_Impl() : 0 ) { OSL_ASSERT(m_aNodePtr); } @@ -308,6 +308,18 @@ namespace DOM invalidate(); } + ::rtl::Reference< CDocument > CNode::GetOwnerDocument_Impl() + { + if (0 == m_aNodePtr) { + return 0; + } + ::rtl::Reference< CDocument > const xDoc( + dynamic_cast<CDocument *>(CNode::getCNode( + reinterpret_cast<xmlNodePtr>(m_aNodePtr->doc)).get())); + return xDoc; + } + + static void _nsexchange(const xmlNodePtr aNode, xmlNsPtr oldNs, xmlNsPtr newNs) { // recursively exchange any references to oldNs with references to newNs @@ -687,13 +699,7 @@ namespace DOM Reference< XDocument > SAL_CALL CNode::getOwnerDocument() throw (RuntimeException) { - if (0 == m_aNodePtr) { - return 0; - } - Reference< XDocument > const xDoc( - static_cast<XNode*>(CNode::getCNode( - reinterpret_cast<xmlNodePtr>(m_aNodePtr->doc)).get()), - UNO_QUERY_THROW); + Reference< XDocument > const xDoc(GetOwnerDocument_Impl().get()); return xDoc; } @@ -1016,7 +1022,9 @@ namespace DOM sal_Bool useCapture) throw (RuntimeException) { - events::CEventDispatcher::addListener(m_aNodePtr, eventType, listener, useCapture); + events::CEventDispatcher & rDispatcher( + m_xDocument->GetEventDispatcher()); + rDispatcher.addListener(m_aNodePtr, eventType, listener, useCapture); } void SAL_CALL CNode::removeEventListener(const OUString& eventType, @@ -1024,13 +1032,17 @@ namespace DOM sal_Bool useCapture) throw (RuntimeException) { - events::CEventDispatcher::removeListener(m_aNodePtr, eventType, listener, useCapture); + events::CEventDispatcher & rDispatcher( + m_xDocument->GetEventDispatcher()); + rDispatcher.removeListener(m_aNodePtr, eventType, listener, useCapture); } sal_Bool SAL_CALL CNode::dispatchEvent(const Reference< XEvent >& evt) throw(RuntimeException, EventException) { - events::CEventDispatcher::dispatchEvent(m_aNodePtr, evt); + events::CEventDispatcher & rDispatcher( + m_xDocument->GetEventDispatcher()); + rDispatcher.dispatchEvent(this, evt); return sal_True; } diff --git a/unoxml/source/dom/node.hxx b/unoxml/source/dom/node.hxx index 1d1ebdca0586..6fc6c5059d6b 100644 --- a/unoxml/source/dom/node.hxx +++ b/unoxml/source/dom/node.hxx @@ -113,6 +113,7 @@ namespace DOM /// add namespaces on this node to context void addNamespaces(Context& io_rContext, xmlNodePtr pNode); + class CDocument; class CNode : public cppu::WeakImplHelper3< XNode, XUnoTunnel, XEventTarget > { @@ -131,7 +132,7 @@ namespace DOM /// libxml node; NB: not const, because invalidate may reset it to 0! xmlNodePtr m_aNodePtr; - Reference< XDocument > const m_xDocument; + ::rtl::Reference< CDocument > const m_xDocument; // for initialization by classes derived through ImplInheritanceHelper CNode(NodeType const& reNodeType, xmlNodePtr const& rpNode); @@ -139,6 +140,8 @@ namespace DOM void dispatchSubtreeModified(); + ::rtl::Reference< CDocument > GetOwnerDocument_Impl(); + public: virtual ~CNode(); |