xref: /AOO41X/main/svl/inc/svl/strmadpt.hxx (revision 39a19a47feaddbaa21988da8c7bf801707fd3d48)
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 SVTOOLS_STRMADPT_HXX
25 #define SVTOOLS_STRMADPT_HXX
26 
27 #include "svl/svldllapi.h"
28 #include <com/sun/star/io/XInputStream.hpp>
29 #include <com/sun/star/io/XOutputStream.hpp>
30 #include <com/sun/star/io/XSeekable.hpp>
31 #include <cppuhelper/weak.hxx>
32 #include <tools/stream.hxx>
33 
34 //============================================================================
35 class SVL_DLLPUBLIC SvOutputStreamOpenLockBytes: public SvOpenLockBytes
36 {
37     com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >
38         m_xOutputStream;
39     sal_uInt32 m_nPosition;
40 
41 public:
42     TYPEINFO();
43 
SvOutputStreamOpenLockBytes(const com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> & rTheOutputStream)44     SvOutputStreamOpenLockBytes(
45             const com::sun::star::uno::Reference<
46                       com::sun::star::io::XOutputStream > &
47                 rTheOutputStream):
48         m_xOutputStream(rTheOutputStream), m_nPosition(0) {}
49 
50     virtual ErrCode ReadAt(sal_uLong, void *, sal_uLong, sal_uLong *) const;
51 
52     virtual ErrCode WriteAt(sal_uLong nPos, const void * pBuffer, sal_uLong nCount,
53                             sal_uLong * pWritten);
54 
55     virtual ErrCode Flush() const;
56 
57     virtual ErrCode SetSize(sal_uLong);
58 
59     virtual ErrCode Stat(SvLockBytesStat * pStat, SvLockBytesStatFlag) const;
60 
61     virtual ErrCode FillAppend(const void * pBuffer, sal_uLong nCount,
62                                sal_uLong * pWritten);
63 
64     virtual sal_uLong Tell() const;
65 
66     virtual sal_uLong Seek(sal_uLong);
67 
68     virtual void Terminate();
69 };
70 
71 //============================================================================
72 class SVL_DLLPUBLIC SvLockBytesInputStream: public cppu::OWeakObject,
73                               public com::sun::star::io::XInputStream,
74                               public com::sun::star::io::XSeekable
75 {
76     SvLockBytesRef m_xLockBytes;
77     sal_Int64 m_nPosition;
78     bool m_bDone;
79 
80 public:
SvLockBytesInputStream(SvLockBytes * pTheLockBytes)81     SvLockBytesInputStream(SvLockBytes * pTheLockBytes):
82         m_xLockBytes(pTheLockBytes), m_nPosition(0), m_bDone(false) {}
83 
84     virtual com::sun::star::uno::Any SAL_CALL
85     queryInterface(const com::sun::star::uno::Type & rType)
86         throw (com::sun::star::uno::RuntimeException);
87 
88     virtual void SAL_CALL acquire() throw();
89 
90     virtual void SAL_CALL release() throw();
91 
92     virtual sal_Int32 SAL_CALL
93     readBytes(com::sun::star::uno::Sequence< sal_Int8 > & rData,
94               sal_Int32 nBytesToRead)
95         throw (com::sun::star::io::IOException,
96                com::sun::star::uno::RuntimeException);
97 
98     virtual sal_Int32 SAL_CALL
99     readSomeBytes(com::sun::star::uno::Sequence< sal_Int8 > & rData,
100                   sal_Int32 nMaxBytesToRead)
101         throw (com::sun::star::io::IOException,
102                com::sun::star::uno::RuntimeException);
103 
104     virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip)
105         throw (com::sun::star::io::IOException,
106                com::sun::star::uno::RuntimeException);
107 
108     virtual sal_Int32 SAL_CALL available()
109         throw (com::sun::star::io::IOException,
110                com::sun::star::uno::RuntimeException);
111 
112     virtual void SAL_CALL closeInput()
113         throw (com::sun::star::io::IOException,
114                com::sun::star::uno::RuntimeException);
115 
116     virtual void SAL_CALL seek(sal_Int64 nLocation)
117         throw (com::sun::star::lang::IllegalArgumentException,
118                com::sun::star::io::IOException,
119                com::sun::star::uno::RuntimeException);
120 
121     virtual sal_Int64 SAL_CALL getPosition()
122         throw (com::sun::star::io::IOException,
123                com::sun::star::uno::RuntimeException);
124 
125     virtual sal_Int64 SAL_CALL getLength()
126         throw (com::sun::star::io::IOException,
127                com::sun::star::uno::RuntimeException);
128 };
129 
130 #endif // SVTOOLS_STRMADPT_HXX
131 
132