diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-03-23 16:59:02 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-03-23 16:59:02 +0100 |
commit | 90087ebb40a6cf12c9464da4e4ea7cc8b5f24bc5 (patch) | |
tree | bb3d6cb01c18dd12ae7ec77234cd43a6092d5a4b /unoxml/source/events | |
parent | 5d7d145d411c8974ceb12ac08759e7ccf3bb9b27 (diff) | |
parent | 82c070266d0440348c61c710e0caa89ae1e74b1b (diff) |
Merge commit 'ooo/DEV300_m103'
Conflicts:
binfilter/bf_xmloff/source/forms/formcellbinding.hxx
binfilter/bf_xmloff/source/forms/xmloff_elementexport.cxx
binfilter/bf_xmloff/source/forms/xmloff_formcellbinding.cxx
filter/source/xsltfilter/makefile.mk
unoxml/source/dom/characterdata.cxx
unoxml/source/dom/document.cxx
unoxml/source/dom/documentbuilder.cxx
unoxml/source/dom/element.cxx
unoxml/source/dom/elementlist.cxx
unoxml/source/dom/node.cxx
unoxml/source/dom/node.hxx
unoxml/source/dom/text.cxx
unoxml/source/events/event.cxx
unoxml/source/events/event.hxx
unoxml/source/events/eventdispatcher.cxx
unoxml/source/events/eventdispatcher.hxx
unoxml/source/events/mouseevent.cxx
unoxml/source/events/mouseevent.hxx
unoxml/source/events/mutationevent.cxx
unoxml/source/events/mutationevent.hxx
unoxml/source/events/uievent.cxx
unoxml/source/events/uievent.hxx
unoxml/source/xpath/nodelist.cxx
unoxml/source/xpath/nodelist.hxx
unoxml/source/xpath/xpathobject.cxx
Diffstat (limited to 'unoxml/source/events')
-rw-r--r-- | unoxml/source/events/event.cxx | 61 | ||||
-rw-r--r-- | unoxml/source/events/event.hxx | 55 | ||||
-rw-r--r-- | unoxml/source/events/eventdispatcher.cxx | 143 | ||||
-rw-r--r-- | unoxml/source/events/eventdispatcher.hxx | 80 | ||||
-rw-r--r-- | unoxml/source/events/makefile.mk | 56 | ||||
-rw-r--r-- | unoxml/source/events/mouseevent.cxx | 54 | ||||
-rw-r--r-- | unoxml/source/events/mouseevent.hxx | 53 | ||||
-rw-r--r-- | unoxml/source/events/mutationevent.cxx | 44 | ||||
-rw-r--r-- | unoxml/source/events/mutationevent.hxx | 50 | ||||
-rw-r--r-- | unoxml/source/events/testlistener.cxx | 4 | ||||
-rw-r--r-- | unoxml/source/events/testlistener.hxx | 35 | ||||
-rw-r--r-- | unoxml/source/events/uievent.cxx | 44 | ||||
-rw-r--r-- | unoxml/source/events/uievent.hxx | 51 |
13 files changed, 524 insertions, 206 deletions
diff --git a/unoxml/source/events/event.cxx b/unoxml/source/events/event.cxx index 3f6bcc6515ec..b674156a9560 100644 --- a/unoxml/source/events/event.cxx +++ b/unoxml/source/events/event.cxx @@ -1,60 +1,109 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#include "event.hxx" +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <event.hxx> namespace DOM { namespace events { + CEvent::CEvent() + : m_canceled(sal_False) + , m_phase(PhaseType_CAPTURING_PHASE) + , m_bubbles(sal_False) + , m_cancelable(sal_True) + { + } + CEvent::~CEvent() { } OUString SAL_CALL CEvent::getType() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_eventType; } - Reference< XEventTarget > SAL_CALL CEvent::getTarget() throw (RuntimeException) + Reference< XEventTarget > SAL_CALL + CEvent::getTarget() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_target; } - Reference< XEventTarget > SAL_CALL CEvent::getCurrentTarget() throw (RuntimeException) + Reference< XEventTarget > SAL_CALL + CEvent::getCurrentTarget() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_currentTarget; } PhaseType SAL_CALL CEvent::getEventPhase() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_phase; } sal_Bool SAL_CALL CEvent::getBubbles() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_bubbles; } sal_Bool SAL_CALL CEvent::getCancelable() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_cancelable; } - com::sun::star::util::Time SAL_CALL CEvent::getTimeStamp() throw (RuntimeException) + com::sun::star::util::Time SAL_CALL + CEvent::getTimeStamp() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_time; } void SAL_CALL CEvent::stopPropagation() throw (RuntimeException) { - if (m_cancelable) m_canceled = sal_True; + ::osl::MutexGuard const g(m_Mutex); + if (m_cancelable) { m_canceled = sal_True; } } void SAL_CALL CEvent::preventDefault() throw (RuntimeException) { } - void SAL_CALL CEvent::initEvent(const OUString& eventTypeArg, sal_Bool canBubbleArg, + void SAL_CALL + CEvent::initEvent(OUString const& eventTypeArg, sal_Bool canBubbleArg, sal_Bool cancelableArg) throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); + m_eventType = eventTypeArg; m_bubbles = canBubbleArg; m_cancelable = cancelableArg; diff --git a/unoxml/source/events/event.hxx b/unoxml/source/events/event.hxx index 578be586a5cc..719880bac13d 100644 --- a/unoxml/source/events/event.hxx +++ b/unoxml/source/events/event.hxx @@ -1,20 +1,45 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#ifndef __EVENT_HXX -#define __EVENT_HXX +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef EVENT_EVENT_HXX +#define EVENT_EVENT_HXX #include <sal/types.h> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> #include <com/sun/star/uno/Reference.h> -#include <com/sun/star/uno/Exception.hpp> +#include <com/sun/star/xml/dom/events/XEvent.hpp> #include <com/sun/star/xml/dom/events/XEventTarget.hpp> #include <com/sun/star/util/Time.hpp> +#include <cppuhelper/implbase1.hxx> + #include "../dom/node.hxx" -#include <libxml/tree.h> using namespace com::sun::star::uno; using namespace com::sun::star::xml::dom; @@ -26,23 +51,13 @@ namespace DOM {namespace events class CEvent : public cppu::WeakImplHelper1< XEvent > { friend class CEventDispatcher; -friend class CNode; -friend class CDocument; -friend class CElement; -friend class CText; -friend class CCharacterData; -friend class CAttr; - - -private: - sal_Bool m_canceled; protected: + ::osl::Mutex m_Mutex; + sal_Bool m_canceled; OUString m_eventType; Reference< XEventTarget > m_target; Reference< XEventTarget > m_currentTarget; - //xmlNodePtr m_target; - //xmlNodePtr m_currentTarget; PhaseType m_phase; sal_Bool m_bubbles; sal_Bool m_cancelable; @@ -50,7 +65,7 @@ protected: public: - CEvent() : m_canceled(sal_False){} + explicit CEvent(); virtual ~CEvent(); virtual OUString SAL_CALL getType() throw (RuntimeException); diff --git a/unoxml/source/events/eventdispatcher.cxx b/unoxml/source/events/eventdispatcher.cxx index b08a080cbfdb..be45adb09dce 100644 --- a/unoxml/source/events/eventdispatcher.cxx +++ b/unoxml/source/events/eventdispatcher.cxx @@ -1,20 +1,47 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#include "eventdispatcher.hxx" -#include "event.hxx" -#include "mutationevent.hxx" -#include "uievent.hxx" -#include "mouseevent.hxx" -#include "../dom/node.hxx" +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <eventdispatcher.hxx> + +#include <event.hxx> +#include <mutationevent.hxx> +#include <uievent.hxx> +#include <mouseevent.hxx> + +#include "../dom/document.hxx" -namespace DOM { namespace events { - TypeListenerMap CEventDispatcher::captureListeners; - TypeListenerMap CEventDispatcher::targetListeners; +namespace DOM { namespace events { 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; @@ -32,8 +59,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); @@ -56,14 +83,14 @@ namespace DOM { namespace events { } } - void CEventDispatcher::callListeners(xmlNodePtr pNode, OUString aType, const Reference< XEvent >& xEvent, sal_Bool bCapture) + void CEventDispatcher::callListeners( + TypeListenerMap const& rTMap, + xmlNodePtr const pNode, + OUString aType, Reference< XEvent > const& xEvent) { - TypeListenerMap *pTMap = &targetListeners; - if (bCapture) pTMap = &captureListeners; - // get the multimap for the specified type - TypeListenerMap::const_iterator tIter = pTMap->find(aType); - if (tIter != pTMap->end()) { + TypeListenerMap::const_iterator tIter = rTMap.find(aType); + if (tIter != rTMap.end()) { ListenerMap *pMap = tIter->second; ListenerMap::const_iterator iter = pMap->lower_bound(pNode); ListenerMap::const_iterator ibound = pMap->upper_bound(pNode); @@ -75,12 +102,14 @@ namespace DOM { namespace events { } } - sal_Bool CEventDispatcher::dispatchEvent(xmlNodePtr aNodePtr, const Reference< XEvent >& aEvent) + bool CEventDispatcher::dispatchEvent( + DOM::CDocument & rDocument, ::osl::Mutex & rMutex, + xmlNodePtr const pNode, 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|| @@ -89,7 +118,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 @@ -105,7 +135,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(), @@ -119,7 +149,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(), @@ -135,23 +166,35 @@ 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::get(aNodePtr)); - 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; - xmlNodePtr cur = DOM::CNode::getNodePtr(Reference< XNode >(xEvent->getTarget(), UNO_QUERY_THROW)); - while (cur != NULL) + typedef std::vector< ::std::pair<Reference<XEventTarget>, xmlNodePtr> > + NodeVector_t; + NodeVector_t captureVector; + TypeListenerMap captureListeners; + TypeListenerMap targetListeners; { - captureVector.push_back(cur); - cur = cur->parent; + ::osl::MutexGuard g(rMutex); + + xmlNodePtr cur = pNode; + while (cur != NULL) + { + Reference< XEventTarget > const xRef( + rDocument.GetCNode(cur).get()); + captureVector.push_back(::std::make_pair(xRef, cur)); + cur = cur->parent; + } + captureListeners = m_CaptureListeners; + targetListeners = m_TargetListeners; } // the caputre vector now holds the node path from target to root @@ -159,36 +202,38 @@ namespace DOM { namespace events { // to target. after that, any target listeners have to be called // then bubbeling phase listeners are called in target to root // order - NodeVector::const_iterator inode; - // start at the root - inode = captureVector.end(); - --inode; - if (inode != captureVector.end()) + NodeVector_t::const_reverse_iterator rinode = + const_cast<NodeVector_t const&>(captureVector).rbegin(); + if (rinode != const_cast<NodeVector_t const&>(captureVector).rend()) { // capturing phase: pEvent->m_phase = PhaseType_CAPTURING_PHASE; - while (inode != captureVector.begin()) + while (rinode != + const_cast<NodeVector_t const&>(captureVector).rend()) { - //pEvent->m_currentTarget = *inode; - pEvent->m_currentTarget = Reference< XEventTarget >(DOM::CNode::get(*inode)); - callListeners(*inode, aType, xEvent, sal_True); + pEvent->m_currentTarget = rinode->first; + callListeners(captureListeners, rinode->second, aType, xEvent); if (pEvent->m_canceled) return sal_True; - --inode; + ++rinode; } + NodeVector_t::const_iterator inode = captureVector.begin(); + // target phase pEvent->m_phase = PhaseType_AT_TARGET; - callListeners(*inode, aType, xEvent, sal_False); + pEvent->m_currentTarget = inode->first; + callListeners(targetListeners, inode->second, aType, xEvent); 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()) { - pEvent->m_currentTarget = Reference< XEventTarget >(DOM::CNode::get(*inode)); - callListeners(*inode, aType, xEvent, sal_False); + pEvent->m_currentTarget = inode->first; + callListeners(targetListeners, + inode->second, aType, xEvent); if (pEvent->m_canceled) return sal_True; ++inode; } diff --git a/unoxml/source/events/eventdispatcher.hxx b/unoxml/source/events/eventdispatcher.hxx index cd8f7fd608d6..9fca309035dd 100644 --- a/unoxml/source/events/eventdispatcher.hxx +++ b/unoxml/source/events/eventdispatcher.hxx @@ -1,53 +1,97 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef EVENT_EVENT_DISPATCHER_HXX +#define EVENT_EVENT_DISPATCHER_HXX #include <map> #include <vector> +#include <libxml/tree.h> + +#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> -#include "event.hxx" + using namespace com::sun::star::uno; using namespace com::sun::star::xml::dom; using namespace com::sun::star::xml::dom::events; -namespace DOM { namespace events -{ +namespace DOM { + +class CDocument; + +namespace events { -typedef std::vector< xmlNodePtr > NodeVector; typedef std::multimap< xmlNodePtr, Reference< com::sun::star::xml::dom::events::XEventListener> > ListenerMap; -typedef std::map<OUString, ListenerMap*> TypeListenerMap; +typedef std::map< ::rtl::OUString, ListenerMap*> TypeListenerMap; 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, - OUString aType, + ::rtl::OUString aType, const Reference<com::sun::star::xml::dom::events::XEventListener>& aListener, sal_Bool bCapture); - static void removeListener( + void removeListener( xmlNodePtr pNode, - OUString aType, + ::rtl::OUString aType, const Reference<com::sun::star::xml::dom::events::XEventListener>& aListener, sal_Bool bCapture); static void callListeners( - xmlNodePtr pNode, - OUString aType, - const Reference< XEvent >& xEvent, - sal_Bool bCapture); + TypeListenerMap const& rTMap, + xmlNodePtr const pNode, + ::rtl::OUString aType, + const Reference< XEvent >& xEvent); + + bool dispatchEvent( + DOM::CDocument & rDocument, + ::osl::Mutex & rMutex, + xmlNodePtr const pNode, + Reference<XNode> const& xNode, + Reference< XEvent > const& xEvent) const; }; + }} -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/unoxml/source/events/makefile.mk b/unoxml/source/events/makefile.mk deleted file mode 100644 index 2ec7489e1a8d..000000000000 --- a/unoxml/source/events/makefile.mk +++ /dev/null @@ -1,56 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=../.. - -PRJNAME=unoxml -TARGET=eventsimpl -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -.IF "$(SYSTEM_LIBXML)" == "YES" -CFLAGS+=-DSYSTEM_LIBXML $(LIBXML_CFLAGS) -.ENDIF - -# --- Files -------------------------------------------------------- - -SLOFILES =\ - $(SLO)$/event.obj \ - $(SLO)$/eventdispatcher.obj \ - $(SLO)$/mutationevent.obj \ - $(SLO)$/uievent.obj \ - $(SLO)$/mouseevent.obj \ - $(SLO)$/testlistener.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - - diff --git a/unoxml/source/events/mouseevent.cxx b/unoxml/source/events/mouseevent.cxx index d18d3eaae782..6e60df7fd669 100644 --- a/unoxml/source/events/mouseevent.cxx +++ b/unoxml/source/events/mouseevent.cxx @@ -1,47 +1,97 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#include "mouseevent.hxx" +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <mouseevent.hxx> namespace DOM { namespace events { + CMouseEvent::CMouseEvent() + : CMouseEvent_Base() + , m_screenX(0) + , m_screenY(0) + , m_clientX(0) + , m_clientY(0) + , m_ctrlKey(sal_False) + , m_shiftKey(sal_False) + , m_altKey(sal_False) + , m_metaKey(sal_False) + , m_button(0) + { + } sal_Int32 SAL_CALL CMouseEvent::getScreenX() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_screenX; } sal_Int32 SAL_CALL CMouseEvent::getScreenY() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_screenY; } sal_Int32 SAL_CALL CMouseEvent::getClientX() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_clientX; } sal_Int32 SAL_CALL CMouseEvent::getClientY() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_clientY; } sal_Bool SAL_CALL CMouseEvent::getCtrlKey() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_ctrlKey; } sal_Bool SAL_CALL CMouseEvent::getShiftKey() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_shiftKey; } sal_Bool SAL_CALL CMouseEvent::getAltKey() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_altKey; } sal_Bool SAL_CALL CMouseEvent::getMetaKey() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_metaKey; } sal_Int16 SAL_CALL CMouseEvent::getButton() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_button; } Reference< XEventTarget > SAL_CALL CMouseEvent::getRelatedTarget() throw(RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_relatedTarget; } @@ -63,6 +113,8 @@ namespace DOM { namespace events const Reference< XEventTarget >& /*relatedTargetArg*/) throw(RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); + CUIEvent::initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg); m_screenX = screenXArg; m_screenY = screenYArg; diff --git a/unoxml/source/events/mouseevent.hxx b/unoxml/source/events/mouseevent.hxx index 76b5189edd3d..18090b381126 100644 --- a/unoxml/source/events/mouseevent.hxx +++ b/unoxml/source/events/mouseevent.hxx @@ -1,28 +1,52 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#ifndef __MOUSEEVENT_HXX -#define __MOUSEEVENT_HXX +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef EVENT_MOUSEEVENT_HXX +#define EVENT_MOUSEEVENT_HXX -#include <sal/types.h> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> -#include <com/sun/star/uno/Reference.h> -#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/AttrChangeType.hpp> -#include <com/sun/star/xml/dom/events/XEvent.hpp> -#include <com/sun/star/xml/dom/events/XUIEvent.hpp> #include <com/sun/star/xml/dom/events/XMouseEvent.hpp> -#include "event.hxx" + +#include <cppuhelper/implbase1.hxx> + #include "uievent.hxx" + using ::rtl::OUString; namespace DOM { namespace events { -class CMouseEvent : public cppu::ImplInheritanceHelper1< CUIEvent, XMouseEvent > +typedef ::cppu::ImplInheritanceHelper1< CUIEvent, XMouseEvent > + CMouseEvent_Base; + +class CMouseEvent + : public CMouseEvent_Base { - friend class CEventDispatcher; protected: sal_Int32 m_screenX; sal_Int32 m_screenY; @@ -36,6 +60,7 @@ protected: Reference< XEventTarget > m_relatedTarget; public: + explicit CMouseEvent(); virtual sal_Int32 SAL_CALL getScreenX() throw (RuntimeException); virtual sal_Int32 SAL_CALL getScreenY() throw (RuntimeException); diff --git a/unoxml/source/events/mutationevent.cxx b/unoxml/source/events/mutationevent.cxx index 46cf61162134..a0cf02107e1d 100644 --- a/unoxml/source/events/mutationevent.cxx +++ b/unoxml/source/events/mutationevent.cxx @@ -1,34 +1,72 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#include "mutationevent.hxx" +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <mutationevent.hxx> namespace DOM { namespace events { + CMutationEvent::CMutationEvent() + : CMutationEvent_Base() + , m_attrChangeType(AttrChangeType_MODIFICATION) + { + } + CMutationEvent::~CMutationEvent() { } Reference< XNode > SAL_CALL CMutationEvent::getRelatedNode() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_relatedNode; } OUString SAL_CALL CMutationEvent::getPrevValue() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_prevValue; } OUString SAL_CALL CMutationEvent::getNewValue() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_newValue; } OUString SAL_CALL CMutationEvent::getAttrName() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_attrName; } AttrChangeType SAL_CALL CMutationEvent::getAttrChange() throw (RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_attrChangeType; } @@ -38,7 +76,9 @@ namespace DOM { namespace events const OUString& newValueArg, const OUString& attrNameArg, AttrChangeType attrChangeArg) throw (RuntimeException) { - initEvent(typeArg, canBubbleArg, cancelableArg); + ::osl::MutexGuard const g(m_Mutex); + + CEvent::initEvent(typeArg, canBubbleArg, cancelableArg); m_relatedNode = relatedNodeArg; m_prevValue = prevValueArg; m_newValue = newValueArg; diff --git a/unoxml/source/events/mutationevent.hxx b/unoxml/source/events/mutationevent.hxx index f096dbc178a8..85a8117c17d4 100644 --- a/unoxml/source/events/mutationevent.hxx +++ b/unoxml/source/events/mutationevent.hxx @@ -1,26 +1,57 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#ifndef __MUTATIONEVENT_HXX -#define __MUTATIONEVENT_HXX +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef EVENT_MUTATIONEVENT_HXX +#define EVENT_MUTATIONEVENT_HXX #include <sal/types.h> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> + #include <com/sun/star/uno/Reference.h> -#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/AttrChangeType.hpp> -#include <com/sun/star/xml/dom/events/XEvent.hpp> #include <com/sun/star/xml/dom/events/XMutationEvent.hpp> + +#include <cppuhelper/implbase1.hxx> + #include "event.hxx" + using ::rtl::OUString; namespace DOM { namespace events { -class CMutationEvent : public cppu::ImplInheritanceHelper1< CEvent, XMutationEvent > +typedef ::cppu::ImplInheritanceHelper1< CEvent, XMutationEvent > + CMutationEvent_Base; + +class CMutationEvent + : public CMutationEvent_Base { - friend class CEventDispatcher; protected: Reference< XNode > m_relatedNode; OUString m_prevValue; @@ -29,6 +60,7 @@ protected: AttrChangeType m_attrChangeType; public: + explicit CMutationEvent(); virtual ~CMutationEvent(); diff --git a/unoxml/source/events/testlistener.cxx b/unoxml/source/events/testlistener.cxx index ee307fa27220..0b29277158eb 100644 --- a/unoxml/source/events/testlistener.cxx +++ b/unoxml/source/events/testlistener.cxx @@ -34,6 +34,10 @@ #define U2S(s) OUStringToOString(s, RTL_TEXTENCODING_UTF8).getStr() +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::lang::IllegalArgumentException; + + namespace DOM { namespace events { diff --git a/unoxml/source/events/testlistener.hxx b/unoxml/source/events/testlistener.hxx index 088c8278622a..117fca9c32c5 100644 --- a/unoxml/source/events/testlistener.hxx +++ b/unoxml/source/events/testlistener.hxx @@ -26,47 +26,46 @@ * ************************************************************************/ -#ifndef _TESTLISTENER_HXX -#define _TESTLISTENER_HXX - -#include <map> +#ifndef EVENT_TESTLISTENER_HXX +#define EVENT_TESTLISTENER_HXX #include <sal/types.h> -#include <cppuhelper/implbase3.hxx> + #include <com/sun/star/uno/Reference.h> #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/uno/Exception.hpp> -#include <com/sun/star/xml/dom/XNode.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/xml/dom/events/XEventTarget.hpp> #include <com/sun/star/xml/dom/events/XEventListener.hpp> #include <com/sun/star/xml/dom/events/XEvent.hpp> -#include <com/sun/star/xml/dom/events/EventType.hpp> -#include <com/sun/star/xml/dom/events/XMutationEvent.hpp> -#include "libxml/tree.h" +#include <cppuhelper/implbase3.hxx> + using ::rtl::OUString; using namespace com::sun::star::uno; -using namespace com::sun::star::lang; using namespace com::sun::star::xml::dom; using namespace com::sun::star::xml::dom::events; namespace DOM { namespace events { + typedef ::cppu::WeakImplHelper3 + < ::com::sun::star::xml::dom::events::XEventListener + , ::com::sun::star::lang::XInitialization + , ::com::sun::star::lang::XServiceInfo + > CTestListener_Base; + class CTestListener - : public ::cppu::WeakImplHelper3< com::sun::star::xml::dom::events::XEventListener, XInitialization, XServiceInfo > + : public CTestListener_Base { private: - Reference< XMultiServiceFactory > m_factory; + Reference< ::com::sun::star::lang::XMultiServiceFactory > m_factory; Reference <XEventTarget> m_target; OUString m_type; sal_Bool m_capture; @@ -79,9 +78,13 @@ namespace DOM { namespace events static const char* aSupportedServiceNames[]; static OUString _getImplementationName(); static Sequence< OUString > _getSupportedServiceNames(); - static Reference< XInterface > _getInstance(const Reference< XMultiServiceFactory >& rSMgr); + static Reference< XInterface > _getInstance( + const Reference< ::com::sun::star::lang::XMultiServiceFactory >& + rSMgr); - CTestListener(const Reference< XMultiServiceFactory >& rSMgr) + CTestListener( + const Reference< ::com::sun::star::lang::XMultiServiceFactory >& + rSMgr) : m_factory(rSMgr){}; virtual ~CTestListener(); diff --git a/unoxml/source/events/uievent.cxx b/unoxml/source/events/uievent.cxx index 881d8147aa17..0a87b20482ed 100644 --- a/unoxml/source/events/uievent.cxx +++ b/unoxml/source/events/uievent.cxx @@ -1,17 +1,51 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#include "event.hxx" -#include "uievent.hxx" +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <uievent.hxx> namespace DOM { namespace events { + CUIEvent::CUIEvent() + : CUIEvent_Base() + , m_detail(0) + { + } - Reference< XAbstractView > SAL_CALL CUIEvent::getView() throw(RuntimeException) + Reference< XAbstractView > SAL_CALL + CUIEvent::getView() throw(RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_view; } sal_Int32 SAL_CALL CUIEvent::getDetail() throw(RuntimeException) { + ::osl::MutexGuard const g(m_Mutex); return m_detail; } @@ -21,7 +55,9 @@ namespace DOM { namespace events const Reference< XAbstractView >& viewArg, sal_Int32 detailArg) throw(RuntimeException) { - initEvent(typeArg, canBubbleArg, cancelableArg); + ::osl::MutexGuard const g(m_Mutex); + + CEvent::initEvent(typeArg, canBubbleArg, cancelableArg); m_view = viewArg; m_detail = detailArg; } diff --git a/unoxml/source/events/uievent.hxx b/unoxml/source/events/uievent.hxx index fdfeae5b395f..5ddd90152372 100644 --- a/unoxml/source/events/uievent.hxx +++ b/unoxml/source/events/uievent.hxx @@ -1,33 +1,62 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#ifndef __UIEVENT_HXX -#define __UIEVENT_HXX +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef EVENT_UIEVENT_HXX +#define EVENT_UIEVENT_HXX #include <sal/types.h> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> -#include <com/sun/star/uno/Reference.h> -#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/AttrChangeType.hpp> -#include <com/sun/star/xml/dom/events/XEvent.hpp> #include <com/sun/star/xml/dom/events/XUIEvent.hpp> #include <com/sun/star/xml/dom/views/XAbstractView.hpp> + +#include <cppuhelper/implbase1.hxx> + #include "event.hxx" + using ::rtl::OUString; using namespace com::sun::star::xml::dom::views; namespace DOM { namespace events { -class CUIEvent : public cppu::ImplInheritanceHelper1< CEvent, XUIEvent > +typedef ::cppu::ImplInheritanceHelper1< CEvent, XUIEvent > CUIEvent_Base; + +class CUIEvent + : public CUIEvent_Base { - friend class CEventDispatcher; protected: sal_Int32 m_detail; Reference< XAbstractView > m_view; public: + explicit CUIEvent(); + virtual Reference< XAbstractView > SAL_CALL getView() throw(RuntimeException); virtual sal_Int32 SAL_CALL getDetail() throw(RuntimeException); virtual void SAL_CALL initUIEvent(const OUString& typeArg, |