Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _SOT_STORAGE_HXX
21 : #define _SOT_STORAGE_HXX
22 :
23 : #include <com/sun/star/uno/Any.hxx>
24 : #include <com/sun/star/uno/Reference.h>
25 :
26 : #include <com/sun/star/io/XInputStream.hpp>
27 : #include <com/sun/star/embed/XStorage.hpp>
28 : #include <sot/object.hxx>
29 : #include <sot/factory.hxx>
30 : #include <tools/stream.hxx>
31 : #include <tools/errcode.hxx>
32 : #include "sot/storinfo.hxx"
33 : #include "sot/sotdllapi.h"
34 :
35 : #define STORAGE_FAILIFTHERE 0x02
36 : #define STORAGE_TRANSACTED 0x04
37 : #define STORAGE_PRIORITY 0x08
38 : #define STORAGE_DELETEONRELEASE 0x10
39 : #define STORAGE_CONVERT 0x20
40 : #define STORAGE_UNPACKED_MODE 0x40
41 : #define STORAGE_DISKSPANNED_MODE 0x80
42 : #define STORAGE_CREATE_UNPACKED 0x44
43 : typedef short StorageMode;
44 :
45 : class SvStorage;
46 :
47 :
48 : /*************************************************************************
49 : *************************************************************************/
50 : class SotStorage;
51 : class BaseStorageStream;
52 : class SOT_DLLPUBLIC SotStorageStream : virtual public SotObject, public SvStream
53 : {
54 : friend class SotStorage;
55 : BaseStorageStream * pOwnStm;// Zeiger auf den eigenen Stream
56 : protected:
57 : virtual sal_uLong GetData( void* pData, sal_uLong nSize );
58 : virtual sal_uLong PutData( const void* pData, sal_uLong nSize );
59 : virtual sal_uLong SeekPos( sal_uLong nPos );
60 : virtual void FlushData();
61 : ~SotStorageStream();
62 : public:
63 : SotStorageStream( const String &,
64 : StreamMode = STREAM_STD_READWRITE,
65 : StorageMode = 0 );
66 : SotStorageStream( BaseStorageStream *pStm );
67 : SotStorageStream();
68 0 : SO2_DECL_BASIC_CLASS_DLL(SotStorageStream,SOTDATA())
69 :
70 : virtual void ResetError();
71 :
72 : virtual void SetSize( sal_uLong nNewSize );
73 : sal_uInt32 GetSize() const;
74 : sal_Bool CopyTo( SotStorageStream * pDestStm );
75 : virtual sal_Bool Commit();
76 : virtual sal_Bool Revert();
77 : sal_Bool SetProperty( const String& rName, const ::com::sun::star::uno::Any& rValue );
78 : virtual sal_Size remainingSize();
79 : };
80 :
81 : #ifndef SOT_DECL_SOTSTORAGESTREAM_DEFINED
82 : #define SOT_DECL_SOTSTORAGESTREAM_DEFINED
83 2052275 : SV_DECL_REF(SotStorageStream)
84 : #endif
85 1474 : SV_IMPL_REF(SotStorageStream)
86 :
87 : namespace ucbhelper
88 : {
89 : class Content;
90 : }
91 :
92 : class BaseStorage;
93 : class UNOStorageHolder;
94 : class SOT_DLLPUBLIC SotStorage : virtual public SotObject
95 : {
96 : friend class SotStorageStream;
97 : friend class SvStorage;
98 :
99 : BaseStorage * m_pTmpStg; // Temp-Storage fuer Transacted, nur auf diesem schreiben! ??? Useless ???
100 : BaseStorage * m_pOwnStg; // Zielstorage
101 : SvStream * m_pStorStm; // nur fuer SDSTORAGES
102 : sal_uLong m_nError;
103 : String m_aName; // Name des Storage
104 : sal_Bool m_bIsRoot:1, // z.B.: File-Storage
105 : m_bDelStm:1;
106 : rtl::OString m_aKey; // aKey.Len != 0 -> Verschluesselung
107 : long m_nVersion;
108 :
109 : protected:
110 : ~SotStorage();
111 : void CreateStorage( sal_Bool bUCBStorage, StreamMode, StorageMode );
112 : public:
113 : SotStorage( const String &,
114 : StreamMode = STREAM_STD_READWRITE,
115 : StorageMode = 0 );
116 : SotStorage( sal_Bool bUCBStorage, const String &,
117 : StreamMode = STREAM_STD_READWRITE,
118 : StorageMode = 0 );
119 : SotStorage( BaseStorage * );
120 : SotStorage( SvStream & rStm );
121 : SotStorage( sal_Bool bUCBStorage, SvStream & rStm );
122 : SotStorage( SvStream * pStm, sal_Bool bDelete );
123 : SotStorage();
124 0 : SO2_DECL_BASIC_CLASS_DLL(SotStorage,SOTDATA())
125 :
126 : SvMemoryStream * CreateMemoryStream();
127 :
128 : static sal_Bool IsStorageFile( const String & rFileName );
129 : static sal_Bool IsStorageFile( SvStream* pStream );
130 :
131 : virtual const String & GetName() const;
132 :
133 : virtual sal_Bool Validate();
134 :
135 : const rtl::OString& GetKey() const;
136 :
137 0 : void SetVersion( long nVers )
138 : {
139 0 : m_nVersion = nVers;
140 0 : }
141 6 : long GetVersion() const
142 : {
143 6 : return m_nVersion;
144 : }
145 :
146 : sal_uLong GetErrorCode() const { return m_nError; }
147 51 : sal_uLong GetError() const { return ERRCODE_TOERROR(m_nError); }
148 440 : void SetError( sal_uLong nErrorCode )
149 : {
150 440 : if( m_nError == SVSTREAM_OK )
151 440 : m_nError = nErrorCode;
152 440 : }
153 : virtual void ResetError();
154 :
155 : sal_Bool IsRoot() const { return m_bIsRoot; }
156 340 : void SignAsRoot( sal_Bool b = sal_True ) { m_bIsRoot = b; }
157 : void SetDeleteStream( sal_Bool bDelete ) { m_bDelStm = bDelete; }
158 :
159 : // eigener Datenbereich
160 : virtual void SetClass( const SvGlobalName & rClass,
161 : sal_uLong bOriginalClipFormat,
162 : const String & rUserTypeName );
163 : virtual void SetConvertClass( const SvGlobalName & rConvertClass,
164 : sal_uLong bOriginalClipFormat,
165 : const String & rUserTypeName );
166 : virtual SvGlobalName GetClassName();// Typ der Daten im Storage
167 : virtual sal_uLong GetFormat();
168 : virtual String GetUserName();
169 : virtual sal_Bool ShouldConvert();
170 :
171 : // Liste aller Elemente
172 : virtual void FillInfoList( SvStorageInfoList * ) const;
173 : virtual sal_Bool CopyTo( SotStorage * pDestStg );
174 : virtual sal_Bool Commit();
175 : virtual sal_Bool Revert();
176 :
177 : /* Element Methoden */
178 : // Stream mit Verbindung zu Storage erzeugen,
179 : // in etwa eine Parent-Child Beziehung
180 : SotStorageStream * OpenSotStream( const String & rEleName,
181 : StreamMode = STREAM_STD_READWRITE,
182 : StorageMode = 0 );
183 : SotStorage * OpenSotStorage( const String & rEleName,
184 : StreamMode = STREAM_STD_READWRITE,
185 : StorageMode = STORAGE_TRANSACTED );
186 : // Abfrage auf Storage oder Stream
187 : virtual sal_Bool IsStream( const String & rEleName ) const;
188 : virtual sal_Bool IsStorage( const String & rEleName ) const;
189 : virtual sal_Bool IsContained( const String & rEleName ) const;
190 : // Element loeschen
191 : virtual sal_Bool Remove( const String & rEleName );
192 : // Elementnamen aendern
193 : virtual sal_Bool Rename( const String & rEleName,
194 : const String & rNewName );
195 : virtual sal_Bool CopyTo( const String & rEleName, SotStorage * pDest,
196 : const String & rNewName );
197 : virtual sal_Bool MoveTo( const String & rEleName, SotStorage * pDest,
198 : const String & rNewName );
199 :
200 : sal_Bool IsOLEStorage() const;
201 : static sal_Bool IsOLEStorage( const String & rFileName );
202 : static sal_Bool IsOLEStorage( SvStream* pStream );
203 :
204 : static SotStorage* OpenOLEStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage,
205 : const String& rEleName, StreamMode = STREAM_STD_READWRITE );
206 : static sal_Int32 GetFormatID( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage );
207 : static sal_Int32 GetVersion( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage );
208 : };
209 :
210 : #ifndef SOT_DECL_SOTSTORAGE_DEFINED
211 : #define SOT_DECL_SOTSTORAGE_DEFINED
212 1387 : SV_DECL_REF(SotStorage)
213 : #endif
214 1786 : SV_IMPL_REF(SotStorage)
215 :
216 : #define SvStorage SotStorage
217 : #define SvStorageRef SotStorageRef
218 : #define SvStorageStream SotStorageStream
219 : #define SvStorageStreamRef SotStorageStreamRef
220 :
221 : #endif // _SVSTOR_HXX
222 :
223 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|