Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_svtools / flbytes.hxx
blobe9073f298db341ab4e847966819b2faad3e7b800
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: flbytes.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _FLBYTES_HXX
32 #define _FLBYTES_HXX
34 #ifndef _TOOLS_DEBUG_HXX
35 #include <tools/debug.hxx>
36 #endif
37 #ifndef _STREAM_HXX
38 #include <tools/stream.hxx>
39 #endif
41 namespace binfilter
44 //============================================================================
45 class SvSyncLockBytes: public SvOpenLockBytes
47 SvAsyncLockBytesRef m_xAsyncLockBytes;
49 public:
50 TYPEINFO();
52 /// Create a synchronous wrapper around existing asynchronous lock bytes.
53 ///
54 /// @param pTheAsyncLockBytes Must not be null.
55 inline SvSyncLockBytes(SvAsyncLockBytes * pTheAsyncLockBytes);
57 /// Create a synchronous wrapper around an existing stream.
58 ///
59 /// @descr This is like first creating asynchronous lock bytes around the
60 /// stream and than creating a synchronous wrapper around the asynchronous
61 /// lock bytes.
62 ///
63 /// @param pStream Must not be null.
64 ///
65 /// @param bOwner True if these lock bytes own the stream (delete it on
66 /// destruction).
67 SvSyncLockBytes(SvStream * pStream, BOOL bOwner):
68 m_xAsyncLockBytes(new SvAsyncLockBytes(pStream, bOwner)) {}
70 virtual const SvStream * GetStream() const
71 { return m_xAsyncLockBytes->GetStream(); }
73 virtual void SetSynchronMode(BOOL bSync = TRUE)
74 { m_xAsyncLockBytes->SetSynchronMode(bSync); }
76 virtual BOOL IsSynchronMode() const
77 { return m_xAsyncLockBytes->IsSynchronMode(); }
79 virtual ErrCode ReadAt(ULONG nPos, void * pBuffer, ULONG nCount,
80 ULONG * pRead) const;
82 virtual ErrCode WriteAt(ULONG nPos, const void * pBuffer, ULONG nCount,
83 ULONG * pWritten);
85 virtual ErrCode Flush() const { return m_xAsyncLockBytes->Flush(); }
87 virtual ErrCode SetSize(ULONG nSize)
88 { return m_xAsyncLockBytes->SetSize(nSize); }
90 virtual ErrCode LockRegion(ULONG nPos, ULONG nCount, LockType eType)
91 { return m_xAsyncLockBytes->LockRegion(nPos, nCount, eType); }
93 virtual ErrCode UnlockRegion(ULONG nPos, ULONG nCount, LockType eType)
94 { return m_xAsyncLockBytes->UnlockRegion(nPos, nCount, eType); }
96 virtual ErrCode Stat(SvLockBytesStat * pStat, SvLockBytesStatFlag eFlag)
97 const
98 { return m_xAsyncLockBytes->Stat(pStat, eFlag); }
100 virtual ErrCode FillAppend(const void * pBuffer, ULONG nCount,
101 ULONG * pWritten)
102 { return m_xAsyncLockBytes->FillAppend(pBuffer, nCount, pWritten); }
104 virtual ULONG Tell() const { return m_xAsyncLockBytes->Tell(); }
106 virtual ULONG Seek(ULONG nPos)
107 { return m_xAsyncLockBytes->Seek(nPos); }
109 virtual void Terminate() { m_xAsyncLockBytes->Terminate(); }
112 inline SvSyncLockBytes::SvSyncLockBytes(SvAsyncLockBytes *
113 pTheAsyncLockBytes):
114 m_xAsyncLockBytes(pTheAsyncLockBytes)
116 DBG_ASSERT(m_xAsyncLockBytes.Is(),
117 "SvSyncLockBytes::SvSyncLockBytes(): Null");
120 SV_DECL_IMPL_REF(SvSyncLockBytes);
123 #endif