xref: /trunk/main/oox/inc/oox/vml/vmlinputstream.hxx (revision a893be29)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef OOX_VML_VMLINPUTSTREAM_HXX
25 #define OOX_VML_VMLINPUTSTREAM_HXX
26 
27 #include <com/sun/star/io/XInputStream.hpp>
28 #include <cppuhelper/implbase1.hxx>
29 #include <rtl/string.hxx>
30 
31 namespace com { namespace sun { namespace star {
32     namespace io { class XTextInputStream; }
33     namespace uno { class XComponentContext; }
34 } } }
35 
36 namespace oox {
37 namespace vml {
38 
39 // ============================================================================
40 
41 typedef ::cppu::WeakImplHelper1< ::com::sun::star::io::XInputStream > InputStream_BASE;
42 
43 /** An input stream class for VML streams, implementing the UNO interface
44     com.sun.star.io.XInputStream needed by the Expat XML parsers.
45 
46     This stream reads the data from the input stream passed to the constructor,
47     and parses all XML elements for features unsupported by the current Expat
48     XML parser:
49 
50     1)  All elements that have the form '<![inst]>' where 'inst' is any string
51         not containing the characters '<' and '>' are stripped from the input
52         stream.
53 
54     2)  Multiple occurrences of the same attribute in an element but the last
55         are removed.
56 
57     3)  Line breaks represented by a single <br> element (without matching
58         </br> element) are replaced by a literal LF character.
59  */
60 class InputStream : public InputStream_BASE
61 {
62 public:
63     explicit            InputStream(
64                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
65                             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm );
66     virtual             ~InputStream();
67 
68     virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& rData, sal_Int32 nBytesToRead )
69                         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
70     virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& rData, sal_Int32 nMaxBytesToRead )
71                         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
72     virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
73                         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
74     virtual sal_Int32 SAL_CALL available()
75                         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
76     virtual void SAL_CALL closeInput()
77                         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
78 
79 private:
80     void                updateBuffer() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
81     ::rtl::OString      readToElementBegin() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
82     ::rtl::OString      readToElementEnd() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
83 
84 private:
85     ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream >
86                         mxTextStrm;
87     ::com::sun::star::uno::Sequence< sal_Unicode > maOpeningBracket;
88     ::com::sun::star::uno::Sequence< sal_Unicode > maClosingBracket;
89     const ::rtl::OString maOpeningCData;
90     const ::rtl::OString maClosingCData;
91     ::rtl::OString      maBuffer;
92     sal_Int32           mnBufferPos;
93 };
94 
95 // ============================================================================
96 
97 } // namespace vml
98 } // namespace oox
99 
100 #endif
101