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