1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OOX_CORE_FASTPARSER_HXX
21 #define INCLUDED_OOX_CORE_FASTPARSER_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <rtl/ustring.hxx>
25 #include <rtl/ref.hxx>
26 #include <sal/types.h>
27 #include <oox/dllapi.h>
29 namespace com::sun::star
{
30 namespace io
{ class XInputStream
; }
31 namespace uno
{ class XComponentContext
; }
32 namespace xml::sax
{ class XFastDocumentHandler
; }
33 namespace xml::sax
{ class XFastParser
; }
34 namespace xml::sax
{ class XFastTokenHandler
; }
35 namespace xml::sax
{ struct InputSource
; }
43 namespace sax_fastparser
{
50 /** Wrapper for a fast SAX parser that works on automatically generated OOXML
51 token and namespace identifiers.
53 class OOX_DLLPUBLIC FastParser
56 /// @throws css::uno::RuntimeException
57 explicit FastParser();
59 FastParser(const FastParser
&) = delete;
60 FastParser
& operator=(const FastParser
&) = delete;
64 /** Registers an OOXML namespace at the parser.
65 @throws css::lang::IllegalArgumentException
66 @throws css::uno::RuntimeException
68 void registerNamespace( sal_Int32 nNamespaceId
);
70 /** Sets the passed document handler that will receive the SAX parser events.
71 @throws css::uno::RuntimeException
73 void setDocumentHandler(
74 const css::uno::Reference
< css::xml::sax::XFastDocumentHandler
>& rxDocHandler
);
76 void clearDocumentHandler();
78 /** Parses the passed SAX input source.
79 @param bCloseStream True = closes the stream in the input source after parsing.
80 @throws css::xml::sax::SAXException
81 @throws css::io::IOException
82 @throws css::uno::RuntimeException
84 void parseStream( const css::xml::sax::InputSource
& rInputSource
, bool bCloseStream
= false );
86 /** Parses the passed input stream.
87 @param bCloseStream True = closes the passed stream after parsing.
88 @throws css::xml::sax::SAXException
89 @throws css::io::IOException
90 @throws css::uno::RuntimeException
93 const css::uno::Reference
< css::io::XInputStream
>& rxInStream
,
94 const OUString
& rStreamName
);
96 /** Parses a stream from the passed storage with the specified name.
97 @param bCloseStream True = closes the stream after parsing.
98 @throws css::xml::sax::SAXException
99 @throws css::io::IOException
100 @throws css::uno::RuntimeException
102 void parseStream( StorageBase
& rStorage
, const OUString
& rStreamName
);
104 const css::uno::Reference
< css::xml::sax::XFastTokenHandler
>&
105 getTokenHandler() const { return mxTokenHandler
; }
108 css::uno::Reference
<css::xml::sax::XFastTokenHandler
> mxTokenHandler
;
109 const NamespaceMap
& mrNamespaceMap
;
110 rtl::Reference
<sax_fastparser::FastSaxParser
> mxParser
;
114 } // namespace oox::core
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */