1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: documentbuilder.hxx,v $
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 _DOCUMENTBUILDER_HXX
32 #define _DOCUMENTBUILDER_HXX
34 #include <sal/types.h>
35 #include <cppuhelper/implbase2.hxx>
36 #include <com/sun/star/uno/Reference.h>
37 #include <com/sun/star/uno/Sequence.h>
39 #include <com/sun/star/uno/XInterface.hpp>
40 #include <com/sun/star/uno/Exception.hpp>
41 #include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
42 #include <com/sun/star/xml/dom/XDocument.hpp>
43 #include <com/sun/star/xml/dom/XDOMImplementation.hpp>
44 #include <com/sun/star/xml/sax/XEntityResolver.hpp>
45 #include <com/sun/star/xml/sax/XErrorHandler.hpp>
46 #include <com/sun/star/xml/sax/SAXParseException.hpp>
47 #include <com/sun/star/io/XInputStream.hpp>
48 #include <com/sun/star/io/IOException.hpp>
49 #include <com/sun/star/lang/XServiceInfo.hpp>
50 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
51 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 #include "libxml/tree.h"
55 using ::rtl::OUString
;
56 using namespace com::sun::star::uno
;
57 using namespace com::sun::star::lang
;
58 using namespace com::sun::star::xml::dom
;
59 using namespace com::sun::star::xml::sax
;
60 using namespace com::sun::star::io
;
64 class CDocumentBuilder
65 : public ::cppu::WeakImplHelper2
< XDocumentBuilder
, XServiceInfo
>
68 Reference
< XMultiServiceFactory
> m_aFactory
;
69 Reference
< XEntityResolver
> m_aEntityResolver
;
70 Reference
< XErrorHandler
> m_aErrorHandler
;
75 CDocumentBuilder(const Reference
< XMultiServiceFactory
>& xFactory
);
78 static Reference
< XInterface
> getInstance(const Reference
< XMultiServiceFactory
>& xFactory
);
80 // static helpers for service info and component management
81 static const char* aImplementationName
;
82 static const char* aSupportedServiceNames
[];
83 static OUString
_getImplementationName();
84 static Sequence
< OUString
> _getSupportedServiceNames();
85 static Reference
< XInterface
> _getInstance(const Reference
< XMultiServiceFactory
>& rSMgr
);
88 virtual OUString SAL_CALL
getImplementationName()
89 throw (RuntimeException
);
90 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
)
91 throw (RuntimeException
);
92 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames ()
93 throw (RuntimeException
);
96 Obtain an instance of a DOMImplementation object.
98 virtual Reference
< XDOMImplementation
> SAL_CALL
getDOMImplementation()
99 throw (RuntimeException
);
102 Indicates whether or not this parser is configured to understand
105 virtual sal_Bool SAL_CALL
isNamespaceAware()
106 throw (RuntimeException
);
109 Indicates whether or not this parser is configured to validate XML
112 virtual sal_Bool SAL_CALL
isValidating()
113 throw (RuntimeException
);
116 Obtain a new instance of a DOM Document object to build a DOM tree
119 virtual Reference
< XDocument
> SAL_CALL
newDocument()
120 throw (RuntimeException
);
123 Parse the content of the given InputStream as an XML document and
124 return a new DOM Document object.
126 virtual Reference
< XDocument
> SAL_CALL
parse(const Reference
< XInputStream
>& is
)
127 throw (RuntimeException
, SAXParseException
, IOException
);
130 Parse the content of the given URI as an XML document and return
131 a new DOM Document object.
133 virtual Reference
< XDocument
> SAL_CALL
parseURI(const OUString
& uri
)
134 throw (RuntimeException
, SAXParseException
, IOException
);
136 virtual Reference
< XDocument
> SAL_CALL
parseSource(const InputSource
& is
)
137 throw (RuntimeException
, SAXParseException
, IOException
);
141 Specify the EntityResolver to be used to resolve entities present
142 in the XML document to be parsed.
144 virtual void SAL_CALL
setEntityResolver(const Reference
< XEntityResolver
>& er
)
145 throw (RuntimeException
);
147 virtual Reference
< XEntityResolver
> SAL_CALL
getEntityResolver()
148 throw (RuntimeException
);
152 Specify the ErrorHandler to be used to report errors present in
153 the XML document to be parsed.
155 virtual void SAL_CALL
setErrorHandler(const Reference
< XErrorHandler
>& eh
)
156 throw (RuntimeException
);