1*7f654276SAndrew Rist /************************************************************** 2*7f654276SAndrew Rist * 3*7f654276SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*7f654276SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*7f654276SAndrew Rist * distributed with this work for additional information 6*7f654276SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*7f654276SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*7f654276SAndrew Rist * "License"); you may not use this file except in compliance 9*7f654276SAndrew Rist * with the License. You may obtain a copy of the License at 10*7f654276SAndrew Rist * 11*7f654276SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*7f654276SAndrew Rist * 13*7f654276SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*7f654276SAndrew Rist * software distributed under the License is distributed on an 15*7f654276SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*7f654276SAndrew Rist * KIND, either express or implied. See the License for the 17*7f654276SAndrew Rist * specific language governing permissions and limitations 18*7f654276SAndrew Rist * under the License. 19*7f654276SAndrew Rist * 20*7f654276SAndrew Rist *************************************************************/ 21*7f654276SAndrew Rist 22*7f654276SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef DOM_DOCUMENTBUILDER_HXX 25cdf0e10cSrcweir #define DOM_DOCUMENTBUILDER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <sal/types.h> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 32cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hpp> 35cdf0e10cSrcweir #include <com/sun/star/xml/dom/XDocumentBuilder.hpp> 36cdf0e10cSrcweir #include <com/sun/star/xml/dom/XDocument.hpp> 37cdf0e10cSrcweir #include <com/sun/star/xml/dom/XDOMImplementation.hpp> 38cdf0e10cSrcweir #include <com/sun/star/xml/sax/XEntityResolver.hpp> 39cdf0e10cSrcweir #include <com/sun/star/xml/sax/XErrorHandler.hpp> 40cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXParseException.hpp> 41cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 42cdf0e10cSrcweir #include <com/sun/star/io/IOException.hpp> 43cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 44cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 45cdf0e10cSrcweir 46cdf0e10cSrcweir 47cdf0e10cSrcweir using ::rtl::OUString; 48cdf0e10cSrcweir using namespace com::sun::star::uno; 49cdf0e10cSrcweir using namespace com::sun::star::lang; 50cdf0e10cSrcweir using namespace com::sun::star::xml::dom; 51cdf0e10cSrcweir using namespace com::sun::star::xml::sax; 52cdf0e10cSrcweir using namespace com::sun::star::io; 53cdf0e10cSrcweir 54cdf0e10cSrcweir namespace DOM 55cdf0e10cSrcweir { 56cdf0e10cSrcweir typedef ::cppu::WeakImplHelper2 57cdf0e10cSrcweir < XDocumentBuilder 58cdf0e10cSrcweir , ::com::sun::star::lang::XServiceInfo 59cdf0e10cSrcweir > CDocumentBuilder_Base; 60cdf0e10cSrcweir 61cdf0e10cSrcweir class CDocumentBuilder 62cdf0e10cSrcweir : public CDocumentBuilder_Base 63cdf0e10cSrcweir { 64cdf0e10cSrcweir private: 65cdf0e10cSrcweir ::osl::Mutex m_Mutex; 66cdf0e10cSrcweir Reference< ::com::sun::star::lang::XMultiServiceFactory > const 67cdf0e10cSrcweir m_xFactory; 68cdf0e10cSrcweir Reference< XEntityResolver > m_xEntityResolver; 69cdf0e10cSrcweir Reference< XErrorHandler > m_xErrorHandler; 70cdf0e10cSrcweir 71cdf0e10cSrcweir public: 72cdf0e10cSrcweir 73cdf0e10cSrcweir // ctor 74cdf0e10cSrcweir CDocumentBuilder( 75cdf0e10cSrcweir Reference< ::com::sun::star::lang::XMultiServiceFactory > const& 76cdf0e10cSrcweir xFactory); 77cdf0e10cSrcweir 78cdf0e10cSrcweir // call for factory 79cdf0e10cSrcweir static Reference< XInterface > getInstance( 80cdf0e10cSrcweir Reference< ::com::sun::star::lang::XMultiServiceFactory > const& 81cdf0e10cSrcweir xFactory); 82cdf0e10cSrcweir 83cdf0e10cSrcweir // static helpers for service info and component management 84cdf0e10cSrcweir static const char* aImplementationName; 85cdf0e10cSrcweir static const char* aSupportedServiceNames[]; 86cdf0e10cSrcweir static OUString _getImplementationName(); 87cdf0e10cSrcweir static Sequence< OUString > _getSupportedServiceNames(); 88cdf0e10cSrcweir static Reference< XInterface > _getInstance( 89cdf0e10cSrcweir Reference< ::com::sun::star::lang::XMultiServiceFactory > const& 90cdf0e10cSrcweir rSMgr); 91cdf0e10cSrcweir 92cdf0e10cSrcweir // XServiceInfo 93cdf0e10cSrcweir virtual OUString SAL_CALL getImplementationName() 94cdf0e10cSrcweir throw (RuntimeException); 95cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) 96cdf0e10cSrcweir throw (RuntimeException); 97cdf0e10cSrcweir virtual Sequence< OUString > SAL_CALL getSupportedServiceNames () 98cdf0e10cSrcweir throw (RuntimeException); 99cdf0e10cSrcweir 100cdf0e10cSrcweir /** 101cdf0e10cSrcweir Obtain an instance of a DOMImplementation object. 102cdf0e10cSrcweir */ 103cdf0e10cSrcweir virtual Reference< XDOMImplementation > SAL_CALL getDOMImplementation() 104cdf0e10cSrcweir throw (RuntimeException); 105cdf0e10cSrcweir 106cdf0e10cSrcweir /** 107cdf0e10cSrcweir Indicates whether or not this parser is configured to understand 108cdf0e10cSrcweir namespaces. 109cdf0e10cSrcweir */ 110cdf0e10cSrcweir virtual sal_Bool SAL_CALL isNamespaceAware() 111cdf0e10cSrcweir throw (RuntimeException); 112cdf0e10cSrcweir 113cdf0e10cSrcweir /** 114cdf0e10cSrcweir Indicates whether or not this parser is configured to validate XML 115cdf0e10cSrcweir documents. 116cdf0e10cSrcweir */ 117cdf0e10cSrcweir virtual sal_Bool SAL_CALL isValidating() 118cdf0e10cSrcweir throw (RuntimeException); 119cdf0e10cSrcweir 120cdf0e10cSrcweir /** 121cdf0e10cSrcweir Obtain a new instance of a DOM Document object to build a DOM tree 122cdf0e10cSrcweir with. 123cdf0e10cSrcweir */ 124cdf0e10cSrcweir virtual Reference< XDocument > SAL_CALL newDocument() 125cdf0e10cSrcweir throw (RuntimeException); 126cdf0e10cSrcweir 127cdf0e10cSrcweir /** 128cdf0e10cSrcweir Parse the content of the given InputStream as an XML document and 129cdf0e10cSrcweir return a new DOM Document object. 130cdf0e10cSrcweir */ 131cdf0e10cSrcweir virtual Reference< XDocument > SAL_CALL parse(const Reference< XInputStream >& is) 132cdf0e10cSrcweir throw (RuntimeException, SAXParseException, IOException); 133cdf0e10cSrcweir 134cdf0e10cSrcweir /** 135cdf0e10cSrcweir Parse the content of the given URI as an XML document and return 136cdf0e10cSrcweir a new DOM Document object. 137cdf0e10cSrcweir */ 138cdf0e10cSrcweir virtual Reference< XDocument > SAL_CALL parseURI(const OUString& uri) 139cdf0e10cSrcweir throw (RuntimeException, SAXParseException, IOException); 140cdf0e10cSrcweir 141cdf0e10cSrcweir /** 142cdf0e10cSrcweir Specify the EntityResolver to be used to resolve entities present 143cdf0e10cSrcweir in the XML document to be parsed. 144cdf0e10cSrcweir */ 145cdf0e10cSrcweir virtual void SAL_CALL setEntityResolver(const Reference< XEntityResolver >& er) 146cdf0e10cSrcweir throw (RuntimeException); 147cdf0e10cSrcweir 148cdf0e10cSrcweir virtual Reference< XEntityResolver > SAL_CALL getEntityResolver() 149cdf0e10cSrcweir throw (RuntimeException); 150cdf0e10cSrcweir 151cdf0e10cSrcweir 152cdf0e10cSrcweir /** 153cdf0e10cSrcweir Specify the ErrorHandler to be used to report errors present in 154cdf0e10cSrcweir the XML document to be parsed. 155cdf0e10cSrcweir */ 156cdf0e10cSrcweir virtual void SAL_CALL setErrorHandler(const Reference< XErrorHandler >& eh) 157cdf0e10cSrcweir throw (RuntimeException); 158cdf0e10cSrcweir }; 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir #endif 162