diff options
Diffstat (limited to 'unoxml/source/dom/document.hxx')
-rw-r--r-- | unoxml/source/dom/document.hxx | 85 |
1 files changed, 61 insertions, 24 deletions
diff --git a/unoxml/source/dom/document.hxx b/unoxml/source/dom/document.hxx index 3fe593ff2b24..c85a85fba9a6 100644 --- a/unoxml/source/dom/document.hxx +++ b/unoxml/source/dom/document.hxx @@ -25,15 +25,19 @@ * ************************************************************************/ -#ifndef _DOCUMENT_HXX -#define _DOCUMENT_HXX +#ifndef DOM_DOCUMENT_HXX +#define DOM_DOCUMENT_HXX -#include <list> #include <set> +#include <memory> + +#include <libxml/tree.h> + #include <sal/types.h> + #include <cppuhelper/implbase6.hxx> + #include <com/sun/star/uno/Reference.h> -#include <com/sun/star/uno/Exception.hpp> #include <com/sun/star/beans/StringPair.hpp> #include <com/sun/star/xml/dom/XNode.hpp> #include <com/sun/star/xml/dom/XAttr.hpp> @@ -52,13 +56,11 @@ #include "node.hxx" -#include <libxml/tree.h> using namespace std; using ::rtl::OUString; using namespace com::sun::star; using namespace com::sun::star::uno; -using namespace com::sun::star::lang; using namespace com::sun::star::xml::sax; using namespace com::sun::star::io; using namespace com::sun::star::xml::dom; @@ -66,32 +68,70 @@ using namespace com::sun::star::xml::dom::events; namespace DOM { + namespace events { + class CEventDispatcher; + } + + class CElement; - class CDocument : public cppu::ImplInheritanceHelper6< - CNode, XDocument, XDocumentEvent, - XActiveDataControl, XActiveDataSource, XSAXSerializable, XFastSAXSerializable> + typedef ::cppu::ImplInheritanceHelper6< + CNode, XDocument, XDocumentEvent, + XActiveDataControl, XActiveDataSource, + XSAXSerializable, XFastSAXSerializable> + CDocument_Base; + + class CDocument + : public CDocument_Base { - friend class CNode; - typedef set< Reference< XStreamListener > > listenerlist_t; - private: - xmlDocPtr m_aDocPtr; + private: + /// this Mutex is used for synchronization of all UNO wrapper + /// objects that belong to this document + ::osl::Mutex m_Mutex; + /// the libxml document: freed in destructor + /// => all UNO wrapper objects must keep the CDocument alive + xmlDocPtr const m_aDocPtr; // datacontrol/source state + typedef set< Reference< XStreamListener > > listenerlist_t; listenerlist_t m_streamListeners; Reference< XOutputStream > m_rOutputStream; - protected: - CDocument(xmlDocPtr aDocPtr); + typedef std::map< const xmlNodePtr, + ::std::pair< WeakReference<XNode>, CNode* > > nodemap_t; + nodemap_t m_NodeMap; + + ::std::auto_ptr<events::CEventDispatcher> const m_pEventDispatcher; + + CDocument(xmlDocPtr const pDocPtr); + public: + /// factory: only way to create instance! + static ::rtl::Reference<CDocument> + CreateCDocument(xmlDocPtr const pDoc); virtual ~CDocument(); - virtual void SAL_CALL saxify( - const Reference< XDocumentHandler >& i_xHandler); + // needed by CXPathAPI + ::osl::Mutex & GetMutex() { return m_Mutex; } + + events::CEventDispatcher & GetEventDispatcher(); + ::rtl::Reference< CElement > GetDocumentElement(); + + /// get UNO wrapper instance for a libxml node + ::rtl::Reference<CNode> GetCNode( + xmlNodePtr const pNode, bool const bCreate = true); + /// remove a UNO wrapper instance + void RemoveCNode(xmlNodePtr const pNode, CNode const*const pCNode); + + virtual CDocument & GetOwnerDocument(); - virtual void SAL_CALL fastSaxify( Context& rContext ); + virtual void saxify(const Reference< XDocumentHandler >& i_xHandler); + + virtual void fastSaxify( Context& rContext ); + + virtual bool IsChildTypeAllowed(NodeType const nodeType); /** Creates an Attr of the given name. @@ -224,17 +264,14 @@ namespace DOM throw (RuntimeException); virtual OUString SAL_CALL getNodeValue() throw (RuntimeException); + virtual Reference< XNode > SAL_CALL cloneNode(sal_Bool deep) + throw (RuntimeException); // --- delegation for XNde base. virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild) throw (RuntimeException, DOMException) { return CNode::appendChild(newChild); } - virtual Reference< XNode > SAL_CALL cloneNode(sal_Bool deep) - throw (RuntimeException) - { - return CNode::cloneNode(deep); - } virtual Reference< XNamedNodeMap > SAL_CALL getAttributes() throw (RuntimeException) { @@ -307,7 +344,7 @@ namespace DOM } virtual Reference< XNode > SAL_CALL insertBefore( const Reference< XNode >& newChild, const Reference< XNode >& refChild) - throw (DOMException) + throw (RuntimeException, DOMException) { return CNode::insertBefore(newChild, refChild); } |