nss: upgrade to release 3.73
[LibreOffice.git] / include / sot / stg.hxx
blob429ea01ecf7a8c7fcd65f3bf1118aa496fdd08ff
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SOT_STG_HXX
21 #define INCLUDED_SOT_STG_HXX
23 #include <tools/solar.h>
24 #include <tools/stream.hxx>
25 #include <tools/globname.hxx>
26 #include <sot/storinfo.hxx>
27 #include <sot/sotdllapi.h>
28 #include <config_options.h>
30 namespace com::sun::star::ucb { class XProgressHandler; }
31 namespace com::sun::star::uno { class Any; }
32 namespace com::sun::star::uno { template <typename > class Reference; }
34 class StgIo;
35 class StgDirEntry;
36 typedef struct SvGUID ClsId;
38 class StorageBase : public SvRefBase
40 protected:
41 mutable ErrCode m_nError; // error code
42 StreamMode m_nMode; // open mode
43 bool m_bAutoCommit;
44 StorageBase();
45 virtual ~StorageBase() override;
46 public:
47 virtual bool Validate( bool=false ) const = 0;
48 virtual bool ValidateMode( StreamMode ) const = 0;
49 void ResetError() const;
50 void SetError( ErrCode ) const;
51 ErrCode GetError() const;
52 bool Good() const { return m_nError == ERRCODE_NONE; }
53 StreamMode GetMode() const { return m_nMode; }
54 void SetAutoCommit( bool bSet )
55 { m_bAutoCommit = bSet; }
58 class BaseStorageStream : public StorageBase
60 public:
61 virtual sal_uLong Read( void * pData, sal_uLong nSize ) = 0;
62 virtual sal_uLong Write( const void* pData, sal_uLong nSize ) = 0;
63 virtual sal_uInt64 Seek( sal_uInt64 nPos ) = 0;
64 virtual sal_uLong Tell() = 0;
65 virtual void Flush() = 0;
66 virtual bool SetSize( sal_uLong nNewSize ) = 0;
67 virtual sal_uLong GetSize() const = 0;
68 virtual void CopyTo( BaseStorageStream * pDestStm ) = 0;
69 virtual bool Commit() = 0;
70 virtual bool Equals( const BaseStorageStream& rStream ) const = 0;
73 enum class SotClipboardFormatId : sal_uInt32;
75 class SAL_DLLPUBLIC_RTTI BaseStorage : public StorageBase
77 public:
78 virtual const OUString& GetName() const = 0;
79 virtual bool IsRoot() const = 0;
80 virtual void SetClassId( const ClsId& ) = 0;
81 virtual const ClsId& GetClassId() const = 0;
82 virtual void SetDirty() = 0;
83 virtual void SetClass( const SvGlobalName & rClass,
84 SotClipboardFormatId nOriginalClipFormat,
85 const OUString & rUserTypeName ) = 0;
86 virtual SvGlobalName GetClassName() = 0;
87 virtual SotClipboardFormatId GetFormat() = 0;
88 virtual OUString GetUserName() = 0;
89 virtual void FillInfoList( SvStorageInfoList* ) const = 0;
90 virtual bool CopyTo( BaseStorage* pDestStg ) const = 0;
91 virtual bool Commit() = 0;
92 virtual bool Revert() = 0;
93 virtual BaseStorageStream* OpenStream( const OUString & rEleName,
94 StreamMode = StreamMode::STD_READWRITE,
95 bool bDirect = true ) = 0;
96 virtual BaseStorage* OpenStorage( const OUString & rEleName,
97 StreamMode = StreamMode::STD_READWRITE,
98 bool bDirect = false ) = 0;
99 virtual BaseStorage* OpenUCBStorage( const OUString & rEleName,
100 StreamMode = StreamMode::STD_READWRITE,
101 bool bDirect = false ) = 0;
102 virtual BaseStorage* OpenOLEStorage( const OUString & rEleName,
103 StreamMode = StreamMode::STD_READWRITE,
104 bool bDirect = false ) = 0;
105 virtual bool IsStream( const OUString& rEleName ) const = 0;
106 virtual bool IsStorage( const OUString& rEleName ) const = 0;
107 virtual bool IsContained( const OUString& rEleName ) const = 0;
108 virtual void Remove( const OUString & rEleName ) = 0;
109 virtual bool CopyTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) = 0;
110 virtual bool ValidateFAT() = 0;
111 virtual bool Equals( const BaseStorage& rStream ) const = 0;
114 class OLEStorageBase
116 protected:
117 StreamMode& nStreamMode; // open mode
118 StgIo* pIo; // I/O subsystem
119 StgDirEntry* pEntry; // the dir entry
120 OLEStorageBase( StgIo*, StgDirEntry*, StreamMode& );
121 ~OLEStorageBase();
122 bool Validate_Impl( bool ) const;
123 static bool ValidateMode_Impl( StreamMode, StgDirEntry const * p = nullptr );
126 class StorageStream final : public BaseStorageStream, public OLEStorageBase
128 //friend class Storage;
129 sal_uLong nPos; // current position
131 virtual ~StorageStream() override;
132 public:
133 StorageStream( StgIo*, StgDirEntry*, StreamMode );
134 virtual sal_uLong Read( void * pData, sal_uLong nSize ) override;
135 virtual sal_uLong Write( const void* pData, sal_uLong nSize ) override;
136 virtual sal_uInt64 Seek( sal_uInt64 nPos ) override;
137 virtual sal_uLong Tell() override { return nPos; }
138 virtual void Flush() override;
139 virtual bool SetSize( sal_uLong nNewSize ) override;
140 virtual sal_uLong GetSize() const override;
141 virtual void CopyTo( BaseStorageStream * pDestStm ) override;
142 virtual bool Commit() final override;
143 virtual bool Validate( bool=false ) const override;
144 virtual bool ValidateMode( StreamMode ) const override;
145 virtual bool Equals( const BaseStorageStream& rStream ) const override;
148 class UCBStorageStream;
150 class UNLESS_MERGELIBS(SOT_DLLPUBLIC) Storage final : public BaseStorage, public OLEStorageBase
152 OUString aName;
153 bool bIsRoot;
154 void Init( bool bCreate );
155 Storage( StgIo*, StgDirEntry*, StreamMode );
156 virtual ~Storage() override;
157 public:
158 Storage( const OUString &, StreamMode, bool bDirect );
159 Storage( SvStream& rStrm, bool bDirect );
160 Storage( UCBStorageStream& rStrm, bool bDirect );
162 static bool IsStorageFile( const OUString & rFileName );
163 static bool IsStorageFile( SvStream* );
165 virtual const OUString& GetName() const final override;
166 virtual bool IsRoot() const override { return bIsRoot; }
167 virtual void SetClassId( const ClsId& ) override;
168 virtual const ClsId& GetClassId() const override;
169 virtual void SetDirty() override;
170 virtual void SetClass( const SvGlobalName & rClass,
171 SotClipboardFormatId nOriginalClipFormat,
172 const OUString & rUserTypeName ) override;
173 virtual SvGlobalName GetClassName() override;
174 virtual SotClipboardFormatId GetFormat() override;
175 virtual OUString GetUserName() override;
176 virtual void FillInfoList( SvStorageInfoList* ) const override;
177 virtual bool CopyTo( BaseStorage* pDestStg ) const override;
178 virtual bool Commit() final override;
179 virtual bool Revert() override;
180 virtual BaseStorageStream* OpenStream( const OUString & rEleName,
181 StreamMode = StreamMode::STD_READWRITE,
182 bool bDirect = true ) override;
183 virtual BaseStorage* OpenStorage( const OUString & rEleName,
184 StreamMode = StreamMode::STD_READWRITE,
185 bool bDirect = false ) override;
186 virtual BaseStorage* OpenUCBStorage( const OUString & rEleName,
187 StreamMode = StreamMode::STD_READWRITE,
188 bool bDirect = false ) override;
189 virtual BaseStorage* OpenOLEStorage( const OUString & rEleName,
190 StreamMode = StreamMode::STD_READWRITE,
191 bool bDirect = false ) override;
192 virtual bool IsStream( const OUString& rEleName ) const override;
193 virtual bool IsStorage( const OUString& rEleName ) const override;
194 virtual bool IsContained( const OUString& rEleName ) const override;
195 virtual void Remove( const OUString & rEleName ) override;
196 virtual bool CopyTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) override;
197 virtual bool ValidateFAT() override;
198 virtual bool Validate( bool=false ) const override;
199 virtual bool ValidateMode( StreamMode ) const override;
200 bool ValidateMode( StreamMode, StgDirEntry const * p ) const;
201 virtual bool Equals( const BaseStorage& rStream ) const override;
204 class UCBStorageStream_Impl;
205 class UCBStorageStream : public BaseStorageStream
207 friend class UCBStorage;
209 UCBStorageStream_Impl*
210 pImp;
211 protected:
212 virtual ~UCBStorageStream() override;
213 public:
214 UCBStorageStream( const OUString& rName, StreamMode nMode, bool bDirect, bool bRepair, css::uno::Reference< css::ucb::XProgressHandler > const & xProgress );
215 UCBStorageStream( UCBStorageStream_Impl* );
217 virtual sal_uLong Read( void * pData, sal_uLong nSize ) override;
218 virtual sal_uLong Write( const void* pData, sal_uLong nSize ) override;
219 virtual sal_uInt64 Seek( sal_uInt64 nPos ) override;
220 virtual sal_uLong Tell() override;
221 virtual void Flush() override;
222 virtual bool SetSize( sal_uLong nNewSize ) override;
223 virtual sal_uLong GetSize() const override;
224 virtual void CopyTo( BaseStorageStream * pDestStm ) override;
225 virtual bool Commit() override;
226 virtual bool Validate( bool=false ) const override;
227 virtual bool ValidateMode( StreamMode ) const override;
228 virtual bool Equals( const BaseStorageStream& rStream ) const override;
229 bool SetProperty( const OUString& rName, const css::uno::Any& rValue );
231 SvStream* GetModifySvStream();
234 namespace ucbhelper
236 class Content;
239 class UCBStorage_Impl;
240 struct UCBStorageElement_Impl;
241 class SOT_DLLPUBLIC UCBStorage : public BaseStorage
243 UCBStorage_Impl* pImp;
245 protected:
246 virtual ~UCBStorage() override;
247 public:
248 static bool IsStorageFile( SvStream* );
250 UCBStorage( const ::ucbhelper::Content& rContent,
251 const OUString& rName,
252 StreamMode nMode,
253 bool bDirect,
254 bool bIsRoot );
256 UCBStorage( const OUString& rName,
257 StreamMode nMode,
258 bool bDirect,
259 bool bIsRoot );
261 UCBStorage( const OUString& rName,
262 StreamMode nMode,
263 bool bDirect,
264 bool bIsRoot,
265 bool bIsRepair,
266 css::uno::Reference< css::ucb::XProgressHandler > const &
267 xProgressHandler );
269 UCBStorage( UCBStorage_Impl* );
271 UCBStorage( SvStream& rStrm, bool bDirect );
273 virtual const OUString& GetName() const override;
274 virtual bool IsRoot() const override;
275 virtual void SetClassId( const ClsId& ) override;
276 virtual const ClsId& GetClassId() const override;
277 virtual void SetDirty() override;
278 virtual void SetClass( const SvGlobalName & rClass,
279 SotClipboardFormatId nOriginalClipFormat,
280 const OUString & rUserTypeName ) override;
281 virtual SvGlobalName GetClassName() override;
282 virtual SotClipboardFormatId GetFormat() override;
283 virtual OUString GetUserName() override;
284 virtual void FillInfoList( SvStorageInfoList* ) const override;
285 virtual bool CopyTo( BaseStorage* pDestStg ) const override;
286 virtual bool Commit() final override;
287 virtual bool Revert() override;
288 virtual BaseStorageStream* OpenStream( const OUString & rEleName,
289 StreamMode = StreamMode::STD_READWRITE,
290 bool bDirect = true ) override;
291 virtual BaseStorage* OpenStorage( const OUString & rEleName,
292 StreamMode = StreamMode::STD_READWRITE,
293 bool bDirect = false ) override;
294 virtual BaseStorage* OpenUCBStorage( const OUString & rEleName,
295 StreamMode = StreamMode::STD_READWRITE,
296 bool bDirect = false ) override;
297 virtual BaseStorage* OpenOLEStorage( const OUString & rEleName,
298 StreamMode = StreamMode::STD_READWRITE,
299 bool bDirect = false ) override;
300 virtual bool IsStream( const OUString& rEleName ) const override;
301 virtual bool IsStorage( const OUString& rEleName ) const override;
302 virtual bool IsContained( const OUString& rEleName ) const override;
303 virtual void Remove( const OUString & rEleName ) override;
304 virtual bool CopyTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) override;
305 virtual bool ValidateFAT() override;
306 virtual bool Validate( bool=false ) const override;
307 virtual bool ValidateMode( StreamMode ) const override;
308 virtual bool Equals( const BaseStorage& rStream ) const override;
310 UCBStorageElement_Impl* FindElement_Impl( const OUString& rName ) const;
311 bool CopyStorageElement_Impl( UCBStorageElement_Impl const & rElement,
312 BaseStorage* pDest, const OUString& rNew ) const;
313 BaseStorage* OpenStorage_Impl( const OUString & rEleName,
314 StreamMode, bool bDirect, bool bForceUCBStorage );
318 #endif
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */