Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
efed7968
Kaydet (Commit)
efed7968
authored
Şub 16, 2004
tarafından
Lars Oppermann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
event handling
üst
d2465633
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1170 additions
and
26 deletions
+1170
-26
build.lst
unoxml/prj/build.lst
+1
-0
attr.hxx
unoxml/source/dom/attr.hxx
+3
-3
characterdata.cxx
unoxml/source/dom/characterdata.cxx
+32
-2
characterdata.hxx
unoxml/source/dom/characterdata.hxx
+5
-2
document.cxx
unoxml/source/dom/document.cxx
+26
-2
element.cxx
unoxml/source/dom/element.cxx
+62
-5
node.cxx
unoxml/source/dom/node.cxx
+90
-3
node.hxx
unoxml/source/dom/node.hxx
+21
-4
event.cxx
unoxml/source/events/event.cxx
+62
-0
event.hxx
unoxml/source/events/event.hxx
+67
-0
eventdispatcher.cxx
unoxml/source/events/eventdispatcher.cxx
+160
-0
eventdispatcher.hxx
unoxml/source/events/eventdispatcher.hxx
+51
-0
makefile.mk
unoxml/source/events/makefile.mk
+86
-0
mutationevent.cxx
unoxml/source/events/mutationevent.cxx
+101
-0
mutationevent.hxx
unoxml/source/events/mutationevent.hxx
+65
-0
testlistener.cxx
unoxml/source/events/testlistener.cxx
+175
-0
testlistener.hxx
unoxml/source/events/testlistener.hxx
+140
-0
makefile.mk
unoxml/source/service/makefile.mk
+4
-3
services.cxx
unoxml/source/service/services.cxx
+19
-2
No files found.
unoxml/prj/build.lst
Dosyayı görüntüle @
efed7968
ux unoxml : libxml2 NULL
ux unoxml\source\dom nmake - all ux_dom NULL
ux unoxml\source\xpath nmake - all ux_xpath ux_dom NULL
ux unoxml\source\events nmake - all ux_events ux_dom NULL
ux unoxml\source\service nmake - all ux_service ux_dom ux_xpath NULL
unoxml/source/dom/attr.hxx
Dosyayı görüntüle @
efed7968
...
...
@@ -2,9 +2,9 @@
*
* $RCSfile: attr.hxx,v $
*
* $Revision: 1.
1
$
* $Revision: 1.
2
$
*
* last change: $Author: lo $ $Date: 2004-0
1-28 16:30:51
$
* last change: $Author: lo $ $Date: 2004-0
2-16 16:41:46
$
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
...
...
@@ -234,7 +234,7 @@ namespace DOM
virtual
void
SAL_CALL
setNodeValue
(
const
OUString
&
nodeValue
)
throw
(
RuntimeException
)
{
return
CNode
::
setNode
Value
(
nodeValue
);
return
set
Value
(
nodeValue
);
}
virtual
void
SAL_CALL
setPrefix
(
const
OUString
&
prefix
)
throw
(
RuntimeException
)
...
...
unoxml/source/dom/characterdata.cxx
Dosyayı görüntüle @
efed7968
...
...
@@ -2,9 +2,9 @@
*
* $RCSfile: characterdata.cxx,v $
*
* $Revision: 1.
1
$
* $Revision: 1.
2
$
*
* last change: $Author: lo $ $Date: 2004-0
1-28 16:31:01
$
* last change: $Author: lo $ $Date: 2004-0
2-16 16:41:46
$
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
...
...
@@ -61,12 +61,24 @@
#include "characterdata.hxx"
#include "../events/mutationevent.hxx"
namespace
DOM
{
CCharacterData
::
CCharacterData
()
{}
void
CCharacterData
::
_dispatchEvent
(
const
OUString
&
prevValue
,
const
OUString
&
newValue
)
{
events
::
CMutationEvent
*
pEvent
=
new
events
::
CMutationEvent
;
pEvent
->
initMutationEvent
(
EventType_DOMCharacterDataModified
,
sal_True
,
sal_False
,
Reference
<
XNode
>
(),
prevValue
,
newValue
,
OUString
(),
(
AttrChangeType
)
0
);
pEvent
->
m_target
=
Reference
<
XEventTarget
>
(
this
);
dispatchEvent
(
Reference
<
XEvent
>
(
static_cast
<
events
::
CEvent
*
>
(
pEvent
)));
}
void
CCharacterData
::
init_characterdata
(
const
xmlNodePtr
aNodePtr
)
{
init_node
(
aNodePtr
);
...
...
@@ -80,7 +92,10 @@ namespace DOM
{
if
(
m_aNodePtr
!=
NULL
)
{
OUString
oldValue
((
char
*
)
m_aNodePtr
->
content
,
strlen
((
char
*
)
m_aNodePtr
->
content
),
RTL_TEXTENCODING_UTF8
);
xmlNodeAddContent
(
m_aNodePtr
,
(
const
xmlChar
*
)(
OUStringToOString
(
arg
,
RTL_TEXTENCODING_UTF8
).
getStr
()));
OUString
newValue
((
char
*
)
m_aNodePtr
->
content
,
strlen
((
char
*
)
m_aNodePtr
->
content
),
RTL_TEXTENCODING_UTF8
);
_dispatchEvent
(
oldValue
,
newValue
);
}
}
...
...
@@ -102,7 +117,11 @@ namespace DOM
OUString
tmp2
=
tmp
.
copy
(
0
,
offset
);
tmp2
+=
tmp
.
copy
(
offset
+
count
,
tmp
.
getLength
()
-
(
offset
+
count
));
OUString
oldValue
((
char
*
)
m_aNodePtr
->
content
,
strlen
((
char
*
)
m_aNodePtr
->
content
),
RTL_TEXTENCODING_UTF8
);
xmlNodeSetContent
(
m_aNodePtr
,
(
const
xmlChar
*
)(
OUStringToOString
(
tmp2
,
RTL_TEXTENCODING_UTF8
).
getStr
()));
OUString
newValue
((
char
*
)
m_aNodePtr
->
content
,
strlen
((
char
*
)
m_aNodePtr
->
content
),
RTL_TEXTENCODING_UTF8
);
_dispatchEvent
(
oldValue
,
newValue
);
}
}
...
...
@@ -152,7 +171,11 @@ namespace DOM
OUString
tmp2
=
tmp
.
copy
(
0
,
offset
);
tmp2
+=
arg
;
tmp2
+=
tmp
.
copy
(
offset
,
tmp
.
getLength
()
-
offset
);
OUString
oldValue
((
char
*
)
m_aNodePtr
->
content
,
strlen
((
char
*
)
m_aNodePtr
->
content
),
RTL_TEXTENCODING_UTF8
);
xmlNodeSetContent
(
m_aNodePtr
,
(
const
xmlChar
*
)(
OUStringToOString
(
tmp2
,
RTL_TEXTENCODING_UTF8
).
getStr
()));
OUString
newValue
((
char
*
)
m_aNodePtr
->
content
,
strlen
((
char
*
)
m_aNodePtr
->
content
),
RTL_TEXTENCODING_UTF8
);
_dispatchEvent
(
oldValue
,
newValue
);
}
}
...
...
@@ -177,7 +200,10 @@ namespace DOM
OUString
tmp2
=
tmp
.
copy
(
0
,
offset
);
tmp2
+=
arg
;
tmp2
+=
tmp
.
copy
(
offset
+
count
,
tmp
.
getLength
()
-
(
offset
+
count
));
OUString
oldValue
((
char
*
)
m_aNodePtr
->
content
,
strlen
((
char
*
)
m_aNodePtr
->
content
),
RTL_TEXTENCODING_UTF8
);
xmlNodeSetContent
(
m_aNodePtr
,
(
const
xmlChar
*
)(
OUStringToOString
(
tmp2
,
RTL_TEXTENCODING_UTF8
).
getStr
()));
OUString
newValue
((
char
*
)
m_aNodePtr
->
content
,
strlen
((
char
*
)
m_aNodePtr
->
content
),
RTL_TEXTENCODING_UTF8
);
_dispatchEvent
(
oldValue
,
newValue
);
}
}
...
...
@@ -189,7 +215,11 @@ namespace DOM
{
if
(
m_aNodePtr
!=
NULL
)
{
OUString
oldValue
((
char
*
)
m_aNodePtr
->
content
,
strlen
((
char
*
)
m_aNodePtr
->
content
),
RTL_TEXTENCODING_UTF8
);
xmlNodeSetContent
(
m_aNodePtr
,
(
const
xmlChar
*
)(
OUStringToOString
(
data
,
RTL_TEXTENCODING_UTF8
).
getStr
()));
OUString
newValue
((
char
*
)
m_aNodePtr
->
content
,
strlen
((
char
*
)
m_aNodePtr
->
content
),
RTL_TEXTENCODING_UTF8
);
_dispatchEvent
(
oldValue
,
newValue
);
}
}
...
...
unoxml/source/dom/characterdata.hxx
Dosyayı görüntüle @
efed7968
...
...
@@ -2,9 +2,9 @@
*
* $RCSfile: characterdata.hxx,v $
*
* $Revision: 1.
1
$
* $Revision: 1.
2
$
*
* last change: $Author: lo $ $Date: 2004-0
1-28 16:31:02
$
* last change: $Author: lo $ $Date: 2004-0
2-16 16:41:46
$
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
...
...
@@ -82,9 +82,12 @@ namespace DOM
{
class
CCharacterData
:
public
cppu
::
ImplInheritanceHelper1
<
CNode
,
XCharacterData
>
{
protected
:
CCharacterData
();
void
init_characterdata
(
const
xmlNodePtr
aNodePtr
);
void
_dispatchEvent
(
const
OUString
&
prevValue
,
const
OUString
&
newValue
);
public
:
/**
...
...
unoxml/source/dom/document.cxx
Dosyayı görüntüle @
efed7968
...
...
@@ -2,9 +2,9 @@
*
* $RCSfile: document.cxx,v $
*
* $Revision: 1.
1
$
* $Revision: 1.
2
$
*
* last change: $Author: lo $ $Date: 2004-0
1-28 16:31:09
$
* last change: $Author: lo $ $Date: 2004-0
2-16 16:41:47
$
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
...
...
@@ -73,6 +73,8 @@
#include "elementlist.hxx"
#include "domimplementation.hxx"
#include "../events/mutationevent.hxx"
namespace
DOM
{
...
...
@@ -496,6 +498,28 @@ namespace DOM
aNode
->
appendChild
(
ic
);
}
}
/* DOMNodeInsertedIntoDocument
* Fired when a node is being inserted into a document,
* either through direct insertion of the Node or insertion of a
* subtree in which it is contained. This event is dispatched after
* the insertion has taken place. The target of this event is the node
* being inserted. If the Node is being directly inserted the DOMNodeInserted
* event will fire before the DOMNodeInsertedIntoDocument event.
* Bubbles: No
* Cancelable: No
* Context Info: None
*/
if
(
aNode
.
is
())
{
events
::
CMutationEvent
*
pEvent
=
new
events
::
CMutationEvent
;
pEvent
->
initMutationEvent
(
EventType_DOMNodeInsertedIntoDocument
,
sal_True
,
sal_False
,
Reference
<
XNode
>
(),
OUString
(),
OUString
(),
OUString
(),
(
AttrChangeType
)
0
);
pEvent
->
m_target
=
Reference
<
XEventTarget
>
(
aNode
,
UNO_QUERY
);
dispatchEvent
(
Reference
<
XEvent
>
(
static_cast
<
events
::
CEvent
*
>
(
pEvent
)));
}
return
aNode
;
}
OUString
SAL_CALL
CDocument
::
getNodeName
()
throw
(
RuntimeException
)
...
...
unoxml/source/dom/element.cxx
Dosyayı görüntüle @
efed7968
...
...
@@ -2,9 +2,9 @@
*
* $RCSfile: element.cxx,v $
*
* $Revision: 1.
1
$
* $Revision: 1.
2
$
*
* last change: $Author: lo $ $Date: 2004-0
1-28 16:31:23
$
* last change: $Author: lo $ $Date: 2004-0
2-16 16:41:47
$
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
...
...
@@ -63,6 +63,7 @@
#include "attr.hxx"
#include "elementlist.hxx"
#include "attributesmap.hxx"
#include "../events/mutationevent.hxx"
namespace
DOM
{
...
...
@@ -308,6 +309,18 @@ namespace DOM
// get the new attr node
aAttr
=
Reference
<
XAttr
>
(
static_cast
<
CAttr
*
>
(
CNode
::
get
((
xmlNodePtr
)
res
)));
}
if
(
aAttr
.
is
())
{
// attribute adition event
// dispatch DOMAttrModified event
events
::
CMutationEvent
*
pEvent
=
new
events
::
CMutationEvent
;
pEvent
->
initMutationEvent
(
EventType_DOMAttrModified
,
sal_True
,
sal_False
,
Reference
<
XNode
>
(
aAttr
,
UNO_QUERY
),
OUString
(),
aAttr
->
getValue
(),
aAttr
->
getName
(),
AttrChangeType_ADDITION
);
pEvent
->
m_target
=
Reference
<
XEventTarget
>
(
this
);
dispatchEvent
(
Reference
<
XEvent
>
(
static_cast
<
events
::
CEvent
*
>
(
pEvent
)));
}
return
aAttr
;
}
...
...
@@ -338,8 +351,30 @@ namespace DOM
xmlChar
*
xValue
=
(
xmlChar
*
)
o2
.
getStr
();
if
(
m_aNodePtr
!=
NULL
)
{
xmlNewProp
(
m_aNodePtr
,
xName
,
xValue
);
}
OUString
oldValue
;
AttrChangeType
aChangeType
=
AttrChangeType_MODIFICATION
;
xmlChar
*
xOld
=
xmlGetProp
(
m_aNodePtr
,
xName
);
if
(
xOld
==
NULL
)
{
aChangeType
=
AttrChangeType_ADDITION
;
xmlNewProp
(
m_aNodePtr
,
xName
,
xValue
);
}
else
{
oldValue
=
OUString
((
char
*
)
xOld
,
strlen
((
char
*
)
xOld
),
RTL_TEXTENCODING_UTF8
);
xmlSetProp
(
m_aNodePtr
,
xName
,
xValue
);
}
// dispatch DOMAttrModified event
events
::
CMutationEvent
*
pEvent
=
new
events
::
CMutationEvent
;
pEvent
->
initMutationEvent
(
EventType_DOMAttrModified
,
sal_True
,
sal_False
,
Reference
<
XNode
>
(
getAttributeNode
(
name
),
UNO_QUERY
),
oldValue
,
value
,
name
,
aChangeType
);
pEvent
->
m_target
=
Reference
<
XEventTarget
>
(
this
);
dispatchEvent
(
Reference
<
XEvent
>
(
static_cast
<
events
::
CEvent
*
>
(
pEvent
)));
}
}
/**
...
...
@@ -386,11 +421,33 @@ namespace DOM
if
(
strcmp
((
char
*
)
pNs
->
href
,
(
char
*
)
xURI
)
==
0
)
{
// found namespace matches
xmlNewNsProp
(
m_aNodePtr
,
pNs
,
xLName
,
xValue
);
OUString
oldValue
;
AttrChangeType
aChangeType
=
AttrChangeType_MODIFICATION
;
xmlChar
*
xOld
=
xmlGetNsProp
(
m_aNodePtr
,
xLName
,
pNs
->
href
);
if
(
xOld
==
NULL
)
{
aChangeType
=
AttrChangeType_ADDITION
;
xmlNewNsProp
(
m_aNodePtr
,
pNs
,
xLName
,
xValue
);
}
else
{
oldValue
=
OUString
((
char
*
)
xOld
,
strlen
((
char
*
)
xOld
),
RTL_TEXTENCODING_UTF8
);
xmlSetNsProp
(
m_aNodePtr
,
pNs
,
xLName
,
xValue
);
}
// dispatch DOMAttrModified event
events
::
CMutationEvent
*
pEvent
=
new
events
::
CMutationEvent
;
pEvent
->
initMutationEvent
(
EventType_DOMAttrModified
,
sal_True
,
sal_False
,
Reference
<
XNode
>
(
getAttributeNodeNS
(
namespaceURI
,
OUString
((
char
*
)
xLName
,
strlen
((
char
*
)
xLName
),
RTL_TEXTENCODING_UTF8
)),
UNO_QUERY
),
oldValue
,
value
,
qualifiedName
,
aChangeType
);
pEvent
->
m_target
=
Reference
<
XEventTarget
>
(
this
);
dispatchEvent
(
Reference
<
XEvent
>
(
static_cast
<
events
::
CEvent
*
>
(
pEvent
)));
}
else
{
// ambigious ns prefix
throw
RuntimeException
();
}
}
}
...
...
unoxml/source/dom/node.cxx
Dosyayı görüntüle @
efed7968
...
...
@@ -2,9 +2,9 @@
*
* $RCSfile: node.cxx,v $
*
* $Revision: 1.
1
$
* $Revision: 1.
2
$
*
* last change: $Author: lo $ $Date: 2004-0
1-28 16:31:36
$
* last change: $Author: lo $ $Date: 2004-0
2-16 16:41:47
$
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
...
...
@@ -75,6 +75,9 @@
#include "childlist.hxx"
#include "attr.hxx"
#include "../events/eventdispatcher.hxx"
#include "../events/mutationevent.hxx"
namespace
DOM
{
nodemap_t
CNode
::
theNodeMap
;
...
...
@@ -275,6 +278,20 @@ namespace DOM
Reference
<
XUnoTunnel
>
tun
(
newChild
,
UNO_QUERY
);
xmlNodePtr
cur
=
(
xmlNodePtr
)(
tun
->
getSomething
(
Sequence
<
sal_Int8
>
()));
// error checks:
// from other document
if
(
cur
->
doc
!=
m_aNodePtr
->
doc
)
throw
(
RuntimeException
(
OUString
::
createFromAscii
(
"appended node belongs to other document"
),
Reference
<
XInterface
>
()));
// same node
if
(
cur
==
m_aNodePtr
)
throw
(
RuntimeException
(
OUString
::
createFromAscii
(
"appended node is same as parent"
),
Reference
<
XInterface
>
()));
// already has parant and is not attribute
if
(
cur
->
parent
!=
NULL
&&
cur
->
type
!=
XML_ATTRIBUTE_NODE
)
throw
(
RuntimeException
(
OUString
::
createFromAscii
(
"appended node has other parent"
),
Reference
<
XInterface
>
()));
// check whether this is an attribute node so we remove it's
// carrier node
xmlNodePtr
res
=
NULL
;
...
...
@@ -309,6 +326,19 @@ namespace DOM
aNode
=
Reference
<
XNode
>
(
CNode
::
get
(
res
));
}
//XXX check for errors
// dispatch DOMNodeInserted event, target is the new node
// this node is the related node
// does bubble
if
(
aNode
.
is
())
{
events
::
CMutationEvent
*
pEvent
=
new
events
::
CMutationEvent
;
pEvent
->
initMutationEvent
(
EventType_DOMNodeInserted
,
sal_True
,
sal_False
,
Reference
<
XNode
>
(
CNode
::
get
(
m_aNodePtr
)),
OUString
(),
OUString
(),
OUString
(),
(
AttrChangeType
)
0
);
pEvent
->
m_target
=
Reference
<
XEventTarget
>
(
aNode
,
UNO_QUERY
);
dispatchEvent
(
Reference
<
XEvent
>
(
static_cast
<
events
::
CEvent
*
>
(
pEvent
)));
}
return
aNode
;
}
...
...
@@ -643,6 +673,24 @@ namespace DOM
}
cur
=
cur
->
next
;
}
/*DOMNodeRemoved
* Fired when a node is being removed from its parent node.
* This event is dispatched before the node is removed from the tree.
* The target of this event is the node being removed.
* Bubbles: Yes
* Cancelable: No
* Context Info: relatedNode holds the parent node
*/
if
(
oldChild
.
is
())
{
events
::
CMutationEvent
*
pEvent
=
new
events
::
CMutationEvent
;
pEvent
->
initMutationEvent
(
EventType_DOMNodeRemoved
,
sal_True
,
sal_False
,
Reference
<
XNode
>
(
CNode
::
get
(
m_aNodePtr
)),
OUString
(),
OUString
(),
OUString
(),
(
AttrChangeType
)
0
);
pEvent
->
m_target
=
Reference
<
XEventTarget
>
(
oldChild
,
UNO_QUERY
);
dispatchEvent
(
Reference
<
XEvent
>
(
static_cast
<
events
::
CEvent
*
>
(
pEvent
)));
}
return
oldChild
;
}
...
...
@@ -656,6 +704,10 @@ namespace DOM
{
// XXX check node types
Reference
<
XNode
>
aNode
=
removeChild
(
oldChild
);
appendChild
(
newChild
);
/*
Reference< XUnoTunnel > tOld(oldChild, UNO_QUERY);
xmlNodePtr pOld = (xmlNodePtr)tOld->getSomething(Sequence< sal_Int8>());
Reference< XUnoTunnel > tNew(newChild, UNO_QUERY);
...
...
@@ -678,7 +730,17 @@ namespace DOM
}
cur = cur->next;
}
return
oldChild
;
*/
// dispatch DOMSubtreeModified
// target is _this_ node
events
::
CMutationEvent
*
pEvent
=
new
events
::
CMutationEvent
;
pEvent
->
initMutationEvent
(
EventType_DOMSubtreeModified
,
sal_True
,
sal_False
,
Reference
<
XNode
>
(),
OUString
(),
OUString
(),
OUString
(),
(
AttrChangeType
)
0
);
pEvent
->
m_target
=
Reference
<
XEventTarget
>
(
this
);
dispatchEvent
(
Reference
<
XEvent
>
(
static_cast
<
events
::
CEvent
*
>
(
pEvent
)));
return
aNode
;
}
/**
...
...
@@ -718,5 +780,30 @@ namespace DOM
// XXX check ID
return
(
sal_Int64
)
m_aNodePtr
;
}
// --- XEventTarget
void
SAL_CALL
CNode
::
addEventListener
(
EventType
eventType
,
const
Reference
<
XEventListener
>&
listener
,
sal_Bool
useCapture
)
throw
(
RuntimeException
)
{
events
::
CEventDispatcher
::
addListener
(
m_aNodePtr
,
eventType
,
listener
,
useCapture
);
}
void
SAL_CALL
CNode
::
removeEventListener
(
EventType
eventType
,
const
Reference
<
XEventListener
>&
listener
,
sal_Bool
useCapture
)
throw
(
RuntimeException
)
{
events
::
CEventDispatcher
::
removeListener
(
m_aNodePtr
,
eventType
,
listener
,
useCapture
);
}
sal_Bool
SAL_CALL
CNode
::
dispatchEvent
(
const
Reference
<
XEvent
>&
evt
)
throw
(
EventException
)
{
events
::
CEventDispatcher
::
dispatchEvent
(
m_aNodePtr
,
evt
);
return
sal_True
;
}
}
unoxml/source/dom/node.hxx
Dosyayı görüntüle @
efed7968
...
...
@@ -2,9 +2,9 @@
*
* $RCSfile: node.hxx,v $
*
* $Revision: 1.
1
$
* $Revision: 1.
2
$
*
* last change: $Author: lo $ $Date: 2004-0
1-28 16:31:3
7 $
* last change: $Author: lo $ $Date: 2004-0
2-16 16:41:4
7 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
...
...
@@ -66,21 +66,24 @@
#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/XNode.hpp>
#include <com/sun/star/xml/dom/XNodeList.hpp>
#include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
#include <com/sun/star/xml/dom/NodeType.hpp>
#include <com/sun/star/xml/dom/events/XEventTarget.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/uno/Sequence.h>
#include <com/sun/star/xml/dom/events/XEventTarget.hpp>
#include <libxml/tree.h>
using
namespace
rtl
;
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
{
...
...
@@ -88,7 +91,7 @@ namespace DOM
typedef
std
::
map
<
const
xmlNodePtr
,
CNode
*
>
nodemap_t
;
class
CNode
:
public
cppu
::
WeakImplHelper
2
<
XNode
,
XUnoTunnel
>
class
CNode
:
public
cppu
::
WeakImplHelper
3
<
XNode
,
XUnoTunnel
,
XEventTarget
>
{
friend
class
CDocument
;
friend
class
CElement
;
...
...
@@ -290,6 +293,20 @@ namespace DOM
// --- XUnoTunnel
virtual
sal_Int64
SAL_CALL
getSomething
(
const
Sequence
<
sal_Int8
>&
id
)
throw
(
RuntimeException
);
// --- XEventTarget
virtual
void
SAL_CALL
addEventListener
(
EventType
eventType
,
const
Reference
<
XEventListener
>&
listener
,
sal_Bool
useCapture
)
throw
(
RuntimeException
);
virtual
void
SAL_CALL
removeEventListener
(
EventType
eventType
,
const
Reference
<
XEventListener
>&
listener
,
sal_Bool
useCapture
)
throw
(
RuntimeException
);
virtual
sal_Bool
SAL_CALL
dispatchEvent
(
const
Reference
<
XEvent
>&
evt
)
throw
(
EventException
);
};
}
...
...
unoxml/source/events/event.cxx
0 → 100644
Dosyayı görüntüle @
efed7968
#include "event.hxx"
namespace
DOM
{
namespace
events
{
CEvent
::~
CEvent
()
{
}
EventType
SAL_CALL
CEvent
::
getType
()
throw
(
RuntimeException
)
{
return
m_eventType
;
}
Reference
<
XEventTarget
>
SAL_CALL
CEvent
::
getTarget
()
throw
(
RuntimeException
)
{
return
m_target
;
}
Reference
<
XEventTarget
>
SAL_CALL
CEvent
::
getCurrentTarget
()
throw
(
RuntimeException
)
{
return
m_currentTarget
;
}
PhaseType
SAL_CALL
CEvent
::
getEventPhase
()
throw
(
RuntimeException
)
{
return
m_phase
;
}
sal_Bool
SAL_CALL
CEvent
::
getBubbles
()
throw
(
RuntimeException
)
{
return
m_bubbles
;
}
sal_Bool
SAL_CALL
CEvent
::
getCancelable
()
throw
(
RuntimeException
)
{
return
m_cancelable
;
}
com
::
sun
::
star
::
util
::
Time
SAL_CALL
CEvent
::
getTimeStamp
()
throw
(
RuntimeException
)
{
return
m_time
;
}
void
SAL_CALL
CEvent
::
stopPropagation
()
throw
(
RuntimeException
)
{
}
void
SAL_CALL
CEvent
::
preventDefault
()
throw
(
RuntimeException
)
{
}
void
SAL_CALL
CEvent
::
initEvent
(
EventType
eventTypeArg
,
sal_Bool
canBubbleArg
,
sal_Bool
cancelableArg
)
throw
(
RuntimeException
)
{
m_eventType
=
eventTypeArg
;
m_bubbles
=
canBubbleArg
;
m_cancelable
=
cancelableArg
;
}
}}
\ No newline at end of file
unoxml/source/events/event.hxx
0 → 100644
Dosyayı görüntüle @
efed7968
#ifndef __EVENT_HXX
#define __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/XEventTarget.hpp>
#include <com/sun/star/util/Time.hpp>
#include "../dom/node.hxx"
#include <libxml/tree.h>
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
{
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
;
protected
:
EventType
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
;
com
::
sun
::
star
::
util
::
Time
m_time
;
public
:
virtual
~
CEvent
();
virtual
EventType
SAL_CALL
getType
()
throw
(
RuntimeException
);
virtual
Reference
<
XEventTarget
>
SAL_CALL
getTarget
()
throw
(
RuntimeException
);
virtual
Reference
<
XEventTarget
>
SAL_CALL
getCurrentTarget
()
throw
(
RuntimeException
);
virtual
PhaseType
SAL_CALL
getEventPhase
()
throw
(
RuntimeException
);
virtual
sal_Bool
SAL_CALL
getBubbles
()
throw
(
RuntimeException
);
virtual
sal_Bool
SAL_CALL
getCancelable
()
throw
(
RuntimeException
);
virtual
com
::
sun
::
star
::
util
::
Time
SAL_CALL
getTimeStamp
()
throw
(
RuntimeException
);
virtual
void
SAL_CALL
stopPropagation
()
throw
(
RuntimeException
);
virtual
void
SAL_CALL
preventDefault
()
throw
(
RuntimeException
);
virtual
void
SAL_CALL
initEvent
(
EventType
eventTypeArg
,
sal_Bool
canBubbleArg
,
sal_Bool
cancelableArg
)
throw
(
RuntimeException
);
};
}}
#endif
unoxml/source/events/eventdispatcher.cxx
0 → 100644
Dosyayı görüntüle @
efed7968
#include "eventdispatcher.hxx"
#include "mutationevent.hxx"
#include "../dom/node.hxx"
namespace
DOM
{
namespace
events
{
TypeListenerMap
CEventDispatcher
::
captureListeners
;
TypeListenerMap
CEventDispatcher
::
targetListeners
;
void
CEventDispatcher
::
addListener
(
xmlNodePtr
pNode
,
EventType
aType
,
const
Reference
<
XEventListener
>&
aListener
,
sal_Bool
bCapture
)
{
TypeListenerMap
*
pTMap
=
&
targetListeners
;
if
(
bCapture
)
pTMap
=
&
captureListeners
;
// get the multimap for the specified type
ListenerMap
*
pMap
=
0
;
TypeListenerMap
::
const_iterator
tIter
=
pTMap
->
find
(
aType
);
if
(
tIter
==
pTMap
->
end
())
{
// the map has to be created
pMap
=
new
ListenerMap
();
pTMap
->
insert
(
TypeListenerMap
::
value_type
(
aType
,
pMap
));
}
else
{
pMap
=
tIter
->
second
;
}
if
(
pMap
!=
0
)
pMap
->
insert
(
ListenerMap
::
value_type
(
pNode
,
aListener
));
}
void
CEventDispatcher
::
removeListener
(
xmlNodePtr
pNode
,
EventType
aType
,
const
Reference
<
XEventListener
>&
aListener
,
sal_Bool
bCapture
)
{
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
())
{
ListenerMap
*
pMap
=
tIter
->
second
;
// find listeners of specied type for specified node
ListenerMap
::
iterator
iter
=
pMap
->
find
(
pNode
);
ListenerMap
::
const_iterator
ibound
=
pMap
->
upper_bound
(
pNode
);
while
(
iter
!=
ibound
)
{
// erase all references to specified listener
if
((
iter
->
second
).
is
()
&&
(
iter
->
second
)
==
aListener
)
{
ListenerMap
::
iterator
i2
=
iter
;
iter
++
;
pMap
->
erase
(
i2
);
}
else
iter
++
;
}
}
}
void
CEventDispatcher
::
callListeners
(
xmlNodePtr
pNode
,
EventType
aType
,
const
Reference
<
XEvent
>&
xEvent
,
sal_Bool
bCapture
)
{
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
())
{
ListenerMap
*
pMap
=
tIter
->
second
;
ListenerMap
::
const_iterator
iter
=
pMap
->
find
(
pNode
);
if
(
iter
==
pMap
->
end
()
)
return
;
ListenerMap
::
const_iterator
ibound
=
pMap
->
upper_bound
(
pNode
);
while
(
iter
!=
ibound
)
{
if
((
iter
->
second
).
is
())
{
(
iter
->
second
)
->
handleEvent
(
xEvent
);
}
iter
++
;
}
}
}