1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _COMPHELPER_STREAMSECTION_HXX_ 29 #define _COMPHELPER_STREAMSECTION_HXX_ 30 31 #include <com/sun/star/io/XMarkableStream.hpp> 32 #include <com/sun/star/io/XDataInputStream.hpp> 33 #include <com/sun/star/io/XDataOutputStream.hpp> 34 #include "comphelper/comphelperdllapi.h" 35 36 namespace comphelper 37 { 38 39 namespace stario = ::com::sun::star::io; 40 namespace staruno = ::com::sun::star::uno; 41 42 /** implements handling for compatibly reading/writing data from/into an input/output stream. 43 data written in a block secured by this class should be readable by older versions which 44 use the same mechanism. 45 46 @author Frank Schoenheit 47 @since 00/26/05 48 */ 49 50 class COMPHELPER_DLLPUBLIC OStreamSection 51 { 52 staruno::Reference< stario::XMarkableStream > m_xMarkStream; 53 staruno::Reference< stario::XDataInputStream > m_xInStream; 54 staruno::Reference< stario::XDataOutputStream > m_xOutStream; 55 56 sal_Int32 m_nBlockStart; 57 sal_Int32 m_nBlockLen; 58 59 public: 60 /** starts reading of a "skippable" section of data within the given input stream<BR> 61 @param _rxInput the stream to read from. Must support the 62 <type scope="com::sun::star::io">XMarkableStream</type> interface 63 */ 64 OStreamSection(const staruno::Reference< stario::XDataInputStream >& _rxInput); 65 66 /** starts writing of a "skippable" section of data into the given output stream 67 @param _rxOutput the stream the stream to write to. Must support the 68 <type scope="com::sun::star::io">XMarkableStream</type> interface 69 @param _nPresumedLength estimation for the length of the upcoming section. If greater 0, this 70 value will be written as section length and corrected (in the dtor) only if 71 needed. If you know how much bytes you are about to write, you may 72 want to use this param, saving some stream operations this way. 73 */ 74 OStreamSection(const staruno::Reference< stario::XDataOutputStream >& _rxOutput, sal_Int32 _nPresumedLength = 0); 75 76 /** dtor. <BR>If constructed for writing, the section "opened" by this object will be "closed".<BR> 77 If constructed for reading, any remaining bytes 'til the end of the section will be skipped. 78 */ 79 ~OStreamSection(); 80 /** 81 return the number of bytes which are still available 82 */ 83 sal_Int32 available(); 84 }; 85 86 } // namespace comphelper 87 88 #endif // _COMPHELPER_STREAMSECTION_HXX_ 89