update dev300-m58
[ooovba.git] / unoxml / source / dom / document.hxx
blob422fc3b0c520dccc20ee74e1b298e772b0297805
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: document.hxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DOCUMENT_HXX
32 #define _DOCUMENT_HXX
34 #include <list>
35 #include <set>
36 #include <sal/types.h>
37 #include <cppuhelper/implbase6.hxx>
38 #include <com/sun/star/uno/Reference.h>
39 #include <com/sun/star/uno/Exception.hpp>
40 #include <com/sun/star/beans/StringPair.hpp>
41 #include <com/sun/star/xml/dom/XNode.hpp>
42 #include <com/sun/star/xml/dom/XAttr.hpp>
43 #include <com/sun/star/xml/dom/XElement.hpp>
44 #include <com/sun/star/xml/dom/XDOMImplementation.hpp>
45 #include <com/sun/star/xml/dom/events/XDocumentEvent.hpp>
46 #include <com/sun/star/xml/dom/events/XEvent.hpp>
47 #include <com/sun/star/xml/sax/XSAXSerializable.hpp>
48 #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
49 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
50 #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
51 #include <com/sun/star/io/XActiveDataSource.hpp>
52 #include <com/sun/star/io/XActiveDataControl.hpp>
53 #include <com/sun/star/io/XOutputStream.hpp>
54 #include <com/sun/star/io/XStreamListener.hpp>
56 #include "node.hxx"
58 #include <libxml/tree.h>
60 using namespace std;
61 using ::rtl::OUString;
62 using namespace com::sun::star;
63 using namespace com::sun::star::uno;
64 using namespace com::sun::star::lang;
65 using namespace com::sun::star::xml::sax;
66 using namespace com::sun::star::io;
67 using namespace com::sun::star::xml::dom;
68 using namespace com::sun::star::xml::dom::events;
70 namespace DOM
73 class CDocument : public cppu::ImplInheritanceHelper6<
74 CNode, XDocument, XDocumentEvent,
75 XActiveDataControl, XActiveDataSource, XSAXSerializable, XFastSAXSerializable>
77 friend class CNode;
78 typedef std::list< Reference< XNode >* > nodereflist_t;
79 typedef set< Reference< XStreamListener > > listenerlist_t;
80 private:
82 nodereflist_t m_aNodeRefList;
84 xmlDocPtr m_aDocPtr;
86 // datacontrol/source state
87 listenerlist_t m_streamListeners;
88 Reference< XOutputStream > m_rOutputStream;
90 protected:
91 CDocument(xmlDocPtr aDocPtr);
93 void addnode(xmlNodePtr aNode);
95 public:
97 virtual ~CDocument();
99 virtual void SAL_CALL saxify(
100 const Reference< XDocumentHandler >& i_xHandler);
102 virtual void SAL_CALL fastSaxify( Context& rContext );
105 Creates an Attr of the given name.
107 virtual Reference< XAttr > SAL_CALL createAttribute(const OUString& name)
108 throw (RuntimeException, DOMException);
111 Creates an attribute of the given qualified name and namespace URI.
113 virtual Reference< XAttr > SAL_CALL createAttributeNS(const OUString& namespaceURI, const OUString& qualifiedName)
114 throw (RuntimeException, DOMException);
117 Creates a CDATASection node whose value is the specified string.
119 virtual Reference< XCDATASection > SAL_CALL createCDATASection(const OUString& data)
120 throw (RuntimeException);
123 Creates a Comment node given the specified string.
125 virtual Reference< XComment > SAL_CALL createComment(const OUString& data)
126 throw (RuntimeException);
129 Creates an empty DocumentFragment object.
131 virtual Reference< XDocumentFragment > SAL_CALL createDocumentFragment()
132 throw (RuntimeException);
135 Creates an element of the type specified.
137 virtual Reference< XElement > SAL_CALL createElement(const OUString& tagName)
138 throw (RuntimeException, DOMException);
141 Creates an element of the given qualified name and namespace URI.
143 virtual Reference< XElement > SAL_CALL createElementNS(const OUString& namespaceURI, const OUString& qualifiedName)
144 throw (RuntimeException, DOMException);
147 Creates an EntityReference object.
149 virtual Reference< XEntityReference > SAL_CALL createEntityReference(const OUString& name)
150 throw (RuntimeException, DOMException);
153 Creates a ProcessingInstruction node given the specified name and
154 data strings.
156 virtual Reference< XProcessingInstruction > SAL_CALL createProcessingInstruction(
157 const OUString& target, const OUString& data)
158 throw (RuntimeException, DOMException);
161 Creates a Text node given the specified string.
163 virtual Reference< XText > SAL_CALL createTextNode(const OUString& data)
164 throw (RuntimeException);
167 The Document Type Declaration (see DocumentType) associated with this
168 document.
170 virtual Reference< XDocumentType > SAL_CALL getDoctype()
171 throw (RuntimeException);
174 This is a convenience attribute that allows direct access to the child
175 node that is the root element of the document.
177 virtual Reference< XElement > SAL_CALL getDocumentElement()
178 throw (RuntimeException);
181 Returns the Element whose ID is given by elementId.
183 virtual Reference< XElement > SAL_CALL getElementById(const OUString& elementId)
184 throw (RuntimeException);
187 Returns a NodeList of all the Elements with a given tag name in the
188 order in which they are encountered in a preorder traversal of the
189 Document tree.
191 virtual Reference< XNodeList > SAL_CALL getElementsByTagName(const OUString& tagname)
192 throw (RuntimeException);
195 Returns a NodeList of all the Elements with a given local name and
196 namespace URI in the order in which they are encountered in a preorder
197 traversal of the Document tree.
199 virtual Reference< XNodeList > SAL_CALL getElementsByTagNameNS(const OUString& namespaceURI, const OUString& localName)
200 throw (RuntimeException);
203 The DOMImplementation object that handles this document.
205 virtual Reference< XDOMImplementation > SAL_CALL getImplementation()
206 throw (RuntimeException);
209 Imports a node from another document to this document.
211 virtual Reference< XNode > SAL_CALL importNode(const Reference< XNode >& importedNode, sal_Bool deep)
212 throw (RuntimeException, DOMException);
214 // XDocumentEvent
215 virtual Reference< XEvent > SAL_CALL createEvent(const OUString& eventType) throw (RuntimeException);
217 // XActiveDataControl,
218 // see http://api.openoffice.org/docs/common/ref/com/sun/star/io/XActiveDataControl.html
219 virtual void SAL_CALL addListener(const Reference< XStreamListener >& aListener ) throw (RuntimeException);
220 virtual void SAL_CALL removeListener(const Reference< XStreamListener >& aListener ) throw (RuntimeException);
221 virtual void SAL_CALL start() throw (RuntimeException);
222 virtual void SAL_CALL terminate() throw (RuntimeException);
224 // XActiveDataSource
225 // see http://api.openoffice.org/docs/common/ref/com/sun/star/io/XActiveDataSource.html
226 virtual void SAL_CALL setOutputStream( const Reference< XOutputStream >& aStream ) throw (RuntimeException);
227 virtual Reference< XOutputStream > SAL_CALL getOutputStream() throw (RuntimeException);
229 // ---- resolve uno inheritance problems...
230 // overrides for XNode base
231 virtual OUString SAL_CALL getNodeName()
232 throw (RuntimeException);
233 virtual OUString SAL_CALL getNodeValue()
234 throw (RuntimeException);
235 // --- delegation for XNde base.
236 virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild)
237 throw (RuntimeException, DOMException)
239 return CNode::appendChild(newChild);
241 virtual Reference< XNode > SAL_CALL cloneNode(sal_Bool deep)
242 throw (RuntimeException)
244 return CNode::cloneNode(deep);
246 virtual Reference< XNamedNodeMap > SAL_CALL getAttributes()
247 throw (RuntimeException)
249 return CNode::getAttributes();
251 virtual Reference< XNodeList > SAL_CALL getChildNodes()
252 throw (RuntimeException)
254 return CNode::getChildNodes();
256 virtual Reference< XNode > SAL_CALL getFirstChild()
257 throw (RuntimeException)
259 return CNode::getFirstChild();
261 virtual Reference< XNode > SAL_CALL getLastChild()
262 throw (RuntimeException)
264 return CNode::getLastChild();
266 virtual OUString SAL_CALL getLocalName()
267 throw (RuntimeException)
269 return CNode::getLocalName();
271 virtual OUString SAL_CALL getNamespaceURI()
272 throw (RuntimeException)
274 return CNode::getNamespaceURI();
276 virtual Reference< XNode > SAL_CALL getNextSibling()
277 throw (RuntimeException)
279 return CNode::getNextSibling();
281 virtual NodeType SAL_CALL getNodeType()
282 throw (RuntimeException)
284 return CNode::getNodeType();
286 virtual Reference< XDocument > SAL_CALL getOwnerDocument()
287 throw (RuntimeException)
289 return CNode::getOwnerDocument();
291 virtual Reference< XNode > SAL_CALL getParentNode()
292 throw (RuntimeException)
294 return CNode::getParentNode();
296 virtual OUString SAL_CALL getPrefix()
297 throw (RuntimeException)
299 return CNode::getPrefix();
301 virtual Reference< XNode > SAL_CALL getPreviousSibling()
302 throw (RuntimeException)
304 return CNode::getPreviousSibling();
306 virtual sal_Bool SAL_CALL hasAttributes()
307 throw (RuntimeException)
309 return CNode::hasAttributes();
311 virtual sal_Bool SAL_CALL hasChildNodes()
312 throw (RuntimeException)
314 return CNode::hasChildNodes();
316 virtual Reference< XNode > SAL_CALL insertBefore(
317 const Reference< XNode >& newChild, const Reference< XNode >& refChild)
318 throw (DOMException)
320 return CNode::insertBefore(newChild, refChild);
322 virtual sal_Bool SAL_CALL isSupported(const OUString& feature, const OUString& ver)
323 throw (RuntimeException)
325 return CNode::isSupported(feature, ver);
327 virtual void SAL_CALL normalize()
328 throw (RuntimeException)
330 CNode::normalize();
332 virtual Reference< XNode > SAL_CALL removeChild(const Reference< XNode >& oldChild)
333 throw (RuntimeException, DOMException)
335 return CNode::removeChild(oldChild);
337 virtual Reference< XNode > SAL_CALL replaceChild(
338 const Reference< XNode >& newChild, const Reference< XNode >& oldChild)
339 throw (RuntimeException, DOMException)
341 return CNode::replaceChild(newChild, oldChild);
343 virtual void SAL_CALL setNodeValue(const OUString& nodeValue)
344 throw (RuntimeException, DOMException)
346 return CNode::setNodeValue(nodeValue);
348 virtual void SAL_CALL setPrefix(const OUString& prefix)
349 throw (RuntimeException, DOMException)
351 return CNode::setPrefix(prefix);
354 // ::com::sun::star::xml::sax::XSAXSerializable
355 virtual void SAL_CALL serialize(
356 const Reference< XDocumentHandler >& i_xHandler,
357 const Sequence< beans::StringPair >& i_rNamespaces)
358 throw (RuntimeException, SAXException);
360 // ::com::sun::star::xml::sax::XFastSAXSerializable
361 virtual void SAL_CALL fastSerialize( const Reference< XFastDocumentHandler >& handler,
362 const Reference< XFastTokenHandler >& tokenHandler,
363 const Sequence< beans::StringPair >& i_rNamespaces,
364 const Sequence< beans::Pair< rtl::OUString, sal_Int32 > >& namespaces )
365 throw (SAXException, RuntimeException);
369 #endif