Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef OOX_CORE_FASTPARSER_HXX
21 : : #define OOX_CORE_FASTPARSER_HXX
22 : :
23 : : #include <com/sun/star/uno/XComponentContext.hpp>
24 : : #include <com/sun/star/xml/sax/XFastParser.hpp>
25 : :
26 : : namespace oox {
27 : : struct NamespaceMap;
28 : : class StorageBase;
29 : : }
30 : :
31 : : namespace oox {
32 : : namespace core {
33 : :
34 : : // ============================================================================
35 : :
36 : : /** Wrapper for a fast SAX parser that works on automatically generated OOXML
37 : : token and namespace identifiers.
38 : : */
39 : : class FastParser
40 : : {
41 : : public:
42 : : explicit FastParser(
43 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext )
44 : : throw( ::com::sun::star::uno::RuntimeException );
45 : :
46 : : virtual ~FastParser();
47 : :
48 : : /** Registers an OOXML namespace at the parser. */
49 : : void registerNamespace( sal_Int32 nNamespaceId )
50 : : throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
51 : :
52 : : /** Sets the passed document handler that will receive the SAX parser events. */
53 : : void setDocumentHandler(
54 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastDocumentHandler >& rxDocHandler )
55 : : throw( ::com::sun::star::uno::RuntimeException );
56 : :
57 : : /** Parses the passed SAX input source.
58 : : @param bCloseStream True = closes the stream in the input source after parsing. */
59 : : void parseStream( const ::com::sun::star::xml::sax::InputSource& rInputSource, bool bCloseStream = false )
60 : : throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException );
61 : :
62 : : /** Parses the passed input stream.
63 : : @param bCloseStream True = closes the passed stream after parsing. */
64 : : void parseStream(
65 : : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream,
66 : : const ::rtl::OUString& rStreamName, bool bCloseStream = false )
67 : : throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException );
68 : :
69 : : /** Parses a stream from the passed storage with the specified name.
70 : : @param bCloseStream True = closes the stream after parsing. */
71 : : void parseStream( StorageBase& rStorage, const ::rtl::OUString& rStreamName, bool bCloseStream = false )
72 : : throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException );
73 : :
74 : : ::rtl::OUString getNamespaceURL( const ::rtl::OUString& rPrefix )
75 : : throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
76 : :
77 : : sal_Int32 getNamespaceId( const ::rtl::OUString& aUrl );
78 : :
79 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >
80 : 15 : getTokenHandler() const { return mxTokenHandler; }
81 : :
82 : : private:
83 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastParser >
84 : : mxParser;
85 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >
86 : : mxTokenHandler;
87 : : const NamespaceMap& mrNamespaceMap;
88 : : };
89 : :
90 : : // ============================================================================
91 : :
92 : : } // namespace core
93 : : } // namespace oox
94 : :
95 : : #endif
96 : :
97 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|