Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / oox / vml / vmlinputstream.hxx
blob4fc6dc9e9fc983f48862fdbacecd4176fddce736
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_VML_VMLINPUTSTREAM_HXX
21 #define INCLUDED_OOX_VML_VMLINPUTSTREAM_HXX
23 #include <com/sun/star/io/XInputStream.hpp>
24 #include <cppuhelper/implbase.hxx>
25 #include <rtl/string.hxx>
27 namespace com { namespace sun { namespace star {
28 namespace io { class XTextInputStream2; }
29 namespace uno { class XComponentContext; }
30 } } }
32 namespace oox {
33 namespace vml {
36 /** An input stream class for VML streams, implementing the UNO interface
37 com.sun.star.io.XInputStream needed by the Expat XML parsers.
39 This stream reads the data from the input stream passed to the constructor,
40 and parses all XML elements for features unsupported by the current Expat
41 XML parser:
43 1) All elements that have the form '<![inst]>' where 'inst' is any string
44 not containing the characters '<' and '>' are stripped from the input
45 stream.
47 2) Multiple occurrences of the same attribute in an element but the last
48 are removed.
50 3) Line breaks represented by a single <br> element (without matching
51 </br> element) are replaced by a literal LF character.
53 class InputStream : public ::cppu::WeakImplHelper< css::io::XInputStream >
55 public:
56 explicit InputStream(
57 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
58 const css::uno::Reference< css::io::XInputStream >& rxInStrm );
59 virtual ~InputStream();
61 virtual sal_Int32 SAL_CALL readBytes( css::uno::Sequence< sal_Int8 >& rData, sal_Int32 nBytesToRead )
62 throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException, std::exception) override;
63 virtual sal_Int32 SAL_CALL readSomeBytes( css::uno::Sequence< sal_Int8 >& rData, sal_Int32 nMaxBytesToRead )
64 throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException, std::exception) override;
65 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
66 throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException, std::exception) override;
67 virtual sal_Int32 SAL_CALL available()
68 throw (css::io::NotConnectedException, css::io::IOException, css::uno::RuntimeException, std::exception) override;
69 virtual void SAL_CALL closeInput()
70 throw (css::io::NotConnectedException, css::io::IOException, css::uno::RuntimeException, std::exception) override;
72 private:
73 void updateBuffer() throw (css::io::IOException, css::uno::RuntimeException);
74 OString readToElementBegin() throw (css::io::IOException, css::uno::RuntimeException);
75 OString readToElementEnd() throw (css::io::IOException, css::uno::RuntimeException);
77 private:
78 css::uno::Reference< css::io::XTextInputStream2 >
79 mxTextStrm;
80 css::uno::Sequence< sal_Unicode > maOpeningBracket;
81 css::uno::Sequence< sal_Unicode > maClosingBracket;
82 const OString maOpeningCData;
83 const OString maClosingCData;
84 OString maBuffer;
85 sal_Int32 mnBufferPos;
89 } // namespace vml
90 } // namespace oox
92 #endif
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */