summaryrefslogtreecommitdiffstats
path: root/unoxml/source/events
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2011-01-19 20:27:23 +0100
committerMichael Stahl <mst@openoffice.org>2011-01-19 20:27:23 +0100
commit8ab417f83b7a6ee8a11deb5f534d6fc6c6fd9899 (patch)
tree7a6695580f4dfa2c04b64f7cb7e5a04ee5e0a553 /unoxml/source/events
parentxmlfix3: #i113682#: unoxml: no mutex necessary for CDocument::importNode (diff)
downloadcore-8ab417f83b7a6ee8a11deb5f534d6fc6c6fd9899.tar.gz
core-8ab417f83b7a6ee8a11deb5f534d6fc6c6fd9899.zip
xmlfix3: #i113682#: unoxml: no more globals in CEventDispatcher:
instead CDocument now has a CEventDispatcher member.
Diffstat (limited to 'unoxml/source/events')
-rw-r--r--unoxml/source/events/eventdispatcher.cxx46
-rw-r--r--unoxml/source/events/eventdispatcher.hxx22
2 files changed, 36 insertions, 32 deletions
diff --git a/unoxml/source/events/eventdispatcher.cxx b/unoxml/source/events/eventdispatcher.cxx
index 198e357914ad..c6e5bc4aebf2 100644
--- a/unoxml/source/events/eventdispatcher.cxx
+++ b/unoxml/source/events/eventdispatcher.cxx
@@ -34,13 +34,10 @@
namespace DOM { namespace events {
- TypeListenerMap CEventDispatcher::captureListeners;
- TypeListenerMap CEventDispatcher::targetListeners;
-
void CEventDispatcher::addListener(xmlNodePtr pNode, OUString aType, const Reference<XEventListener>& aListener, sal_Bool bCapture)
{
- TypeListenerMap* pTMap = &targetListeners;
- if (bCapture) pTMap = &captureListeners;
+ TypeListenerMap *const pTMap = (bCapture)
+ ? (& m_CaptureListeners) : (& m_TargetListeners);
// get the multimap for the specified type
ListenerMap *pMap = 0;
@@ -58,8 +55,8 @@ namespace DOM { namespace events {
void CEventDispatcher::removeListener(xmlNodePtr pNode, OUString aType, const Reference<XEventListener>& aListener, sal_Bool bCapture)
{
- TypeListenerMap *pTMap = &targetListeners;
- if (bCapture) pTMap = &captureListeners;
+ TypeListenerMap *const pTMap = (bCapture)
+ ? (& m_CaptureListeners) : (& m_TargetListeners);
// get the multimap for the specified type
TypeListenerMap::const_iterator tIter = pTMap->find(aType);
@@ -82,10 +79,12 @@ namespace DOM { namespace events {
}
}
- void CEventDispatcher::callListeners(xmlNodePtr pNode, OUString aType, const Reference< XEvent >& xEvent, sal_Bool bCapture)
+ void CEventDispatcher::callListeners(xmlNodePtr const pNode,
+ OUString aType, Reference< XEvent > const& xEvent,
+ sal_Bool const bCapture) const
{
- TypeListenerMap *pTMap = &targetListeners;
- if (bCapture) pTMap = &captureListeners;
+ TypeListenerMap const*const pTMap = (bCapture)
+ ? (& m_CaptureListeners) : (& m_TargetListeners);
// get the multimap for the specified type
TypeListenerMap::const_iterator tIter = pTMap->find(aType);
@@ -101,12 +100,12 @@ namespace DOM { namespace events {
}
}
- sal_Bool CEventDispatcher::dispatchEvent(xmlNodePtr aNodePtr, const Reference< XEvent >& aEvent)
+ bool CEventDispatcher::dispatchEvent(Reference<XNode> const& xNode,
+ Reference< XEvent > const& i_xEvent) const
{
CEvent *pEvent = 0; // pointer to internal event representation
- Reference< XEvent > xEvent; // reference to the event being dispatched;
- OUString aType = aEvent->getType();
+ OUString const aType = i_xEvent->getType();
if (aType.compareToAscii("DOMSubtreeModified") == 0||
aType.compareToAscii("DOMNodeInserted") == 0||
aType.compareToAscii("DOMNodeRemoved") == 0||
@@ -115,7 +114,8 @@ namespace DOM { namespace events {
aType.compareToAscii("DOMAttrModified") == 0||
aType.compareToAscii("DOMCharacterDataModified") == 0)
{
- Reference< XMutationEvent > aMEvent(aEvent, UNO_QUERY);
+ Reference< XMutationEvent > const aMEvent(i_xEvent,
+ UNO_QUERY_THROW);
// dispatch a mutation event
// we need to clone the event in order to have complete control
// over the implementation
@@ -131,7 +131,7 @@ namespace DOM { namespace events {
aType.compareToAscii("DOMFocusOut") == 0||
aType.compareToAscii("DOMActivate") == 0)
{
- Reference< XUIEvent > aUIEvent(aEvent, UNO_QUERY);
+ Reference< XUIEvent > const aUIEvent(i_xEvent, UNO_QUERY_THROW);
CUIEvent* pUIEvent = new CUIEvent;
pUIEvent->initUIEvent(aType,
aUIEvent->getBubbles(), aUIEvent->getCancelable(),
@@ -145,7 +145,8 @@ namespace DOM { namespace events {
aType.compareToAscii("mousemove") == 0||
aType.compareToAscii("mouseout") == 0)
{
- Reference< XMouseEvent > aMouseEvent(aEvent, UNO_QUERY);
+ Reference< XMouseEvent > const aMouseEvent(i_xEvent,
+ UNO_QUERY_THROW);
CMouseEvent *pMouseEvent = new CMouseEvent;
pMouseEvent->initMouseEvent(aType,
aMouseEvent->getBubbles(), aMouseEvent->getCancelable(),
@@ -161,16 +162,15 @@ namespace DOM { namespace events {
{
pEvent = new CEvent;
pEvent->initEvent(
- aType, aEvent->getBubbles(), aEvent->getCancelable());
+ aType, i_xEvent->getBubbles(), i_xEvent->getCancelable());
}
- pEvent->m_target =
- Reference< XEventTarget >(DOM::CNode::getCNode(aNodePtr).get());
- pEvent->m_currentTarget = aEvent->getCurrentTarget();
- pEvent->m_time = aEvent->getTimeStamp();
+ pEvent->m_target.set(xNode, UNO_QUERY_THROW);
+ pEvent->m_currentTarget = i_xEvent->getCurrentTarget();
+ pEvent->m_time = i_xEvent->getTimeStamp();
// create the reference to the provate event implementation
// that will be dispatched to the listeners
- xEvent = Reference< XEvent >(pEvent);
+ Reference< XEvent > const xEvent(pEvent);
// build the path from target node to the root
NodeVector captureVector;
@@ -211,7 +211,7 @@ namespace DOM { namespace events {
if (pEvent->m_canceled) return sal_True;
// bubbeling phase
inode++;
- if (aEvent->getBubbles()) {
+ if (i_xEvent->getBubbles()) {
pEvent->m_phase = PhaseType_BUBBLING_PHASE;
while (inode != captureVector.end())
{
diff --git a/unoxml/source/events/eventdispatcher.hxx b/unoxml/source/events/eventdispatcher.hxx
index cd3f9e033c57..5160256ac493 100644
--- a/unoxml/source/events/eventdispatcher.hxx
+++ b/unoxml/source/events/eventdispatcher.hxx
@@ -36,6 +36,7 @@
#include <rtl/ustring.hxx>
#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/xml/dom/XNode.hpp>
#include <com/sun/star/xml/dom/events/EventType.hpp>
#include <com/sun/star/xml/dom/events/PhaseType.hpp>
#include <com/sun/star/xml/dom/events/XEvent.hpp>
@@ -56,30 +57,33 @@ typedef std::vector<ListenerMap::value_type> ListenerPairVector;
class CEventDispatcher
{
private:
- static TypeListenerMap captureListeners;
- static TypeListenerMap targetListeners;
+ TypeListenerMap m_CaptureListeners;
+ TypeListenerMap m_TargetListeners;
public:
- static sal_Bool dispatchEvent(xmlNodePtr aNode, const Reference< XEvent >& aEvent);
-
- static void addListener(
+ void addListener(
xmlNodePtr pNode,
::rtl::OUString aType,
const Reference<com::sun::star::xml::dom::events::XEventListener>& aListener,
sal_Bool bCapture);
- static void removeListener(
+ void removeListener(
xmlNodePtr pNode,
::rtl::OUString aType,
const Reference<com::sun::star::xml::dom::events::XEventListener>& aListener,
sal_Bool bCapture);
- static void callListeners(
- xmlNodePtr pNode,
+ void callListeners(
+ xmlNodePtr const pNode,
::rtl::OUString aType,
const Reference< XEvent >& xEvent,
- sal_Bool bCapture);
+ sal_Bool const bCapture) const;
+
+ bool dispatchEvent(
+ Reference<XNode> const& xNode,
+ Reference< XEvent > const& xEvent) const;
};
+
}}
#endif