1*bbfc4cc7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*bbfc4cc7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*bbfc4cc7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*bbfc4cc7SAndrew Rist * distributed with this work for additional information 6*bbfc4cc7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*bbfc4cc7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*bbfc4cc7SAndrew Rist * "License"); you may not use this file except in compliance 9*bbfc4cc7SAndrew Rist * with the License. You may obtain a copy of the License at 10*bbfc4cc7SAndrew Rist * 11*bbfc4cc7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*bbfc4cc7SAndrew Rist * 13*bbfc4cc7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*bbfc4cc7SAndrew Rist * software distributed under the License is distributed on an 15*bbfc4cc7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*bbfc4cc7SAndrew Rist * KIND, either express or implied. See the License for the 17*bbfc4cc7SAndrew Rist * specific language governing permissions and limitations 18*bbfc4cc7SAndrew Rist * under the License. 19*bbfc4cc7SAndrew Rist * 20*bbfc4cc7SAndrew Rist *************************************************************/ 21*bbfc4cc7SAndrew Rist 22*bbfc4cc7SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SOT_STORAGE_HXX 25cdf0e10cSrcweir #define _SOT_STORAGE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 28cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_H_ 31cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp> 34cdf0e10cSrcweir #include <sot/object.hxx> 35cdf0e10cSrcweir #include <sot/factory.hxx> 36cdf0e10cSrcweir #ifndef _TOOLS_STREAM_HXX 37cdf0e10cSrcweir #include <tools/stream.hxx> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #ifndef _TOOLS_ERRCODE_HXX 40cdf0e10cSrcweir #include <tools/errcode.hxx> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #include "sot/sotdllapi.h" 43cdf0e10cSrcweir 44cdf0e10cSrcweir #define STORAGE_FAILIFTHERE 0x02 45cdf0e10cSrcweir #define STORAGE_TRANSACTED 0x04 46cdf0e10cSrcweir #define STORAGE_PRIORITY 0x08 47cdf0e10cSrcweir #define STORAGE_DELETEONRELEASE 0x10 48cdf0e10cSrcweir #define STORAGE_CONVERT 0x20 49cdf0e10cSrcweir #define STORAGE_UNPACKED_MODE 0x40 50cdf0e10cSrcweir #define STORAGE_DISKSPANNED_MODE 0x80 51cdf0e10cSrcweir #define STORAGE_CREATE_UNPACKED 0x44 52cdf0e10cSrcweir typedef short StorageMode; 53cdf0e10cSrcweir 54cdf0e10cSrcweir class SvStorage; 55cdf0e10cSrcweir namespace binfilter 56cdf0e10cSrcweir { 57cdf0e10cSrcweir class SvStorage; 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir /************************************************************************* 61cdf0e10cSrcweir *************************************************************************/ 62cdf0e10cSrcweir class SotStorage; 63cdf0e10cSrcweir class BaseStorageStream; 64cdf0e10cSrcweir class SOT_DLLPUBLIC SotStorageStream : virtual public SotObject, public SvStream 65cdf0e10cSrcweir { 66cdf0e10cSrcweir friend class SotStorage; 67cdf0e10cSrcweir friend class ImpStream; 68cdf0e10cSrcweir BaseStorageStream * pOwnStm;// Zeiger auf den eigenen Stream 69cdf0e10cSrcweir protected: 70cdf0e10cSrcweir virtual sal_uLong GetData( void* pData, sal_uLong nSize ); 71cdf0e10cSrcweir virtual sal_uLong PutData( const void* pData, sal_uLong nSize ); 72cdf0e10cSrcweir virtual sal_uLong SeekPos( sal_uLong nPos ); 73cdf0e10cSrcweir virtual void FlushData(); 74cdf0e10cSrcweir ~SotStorageStream(); 75cdf0e10cSrcweir public: 76cdf0e10cSrcweir SotStorageStream( const String &, 77cdf0e10cSrcweir StreamMode = STREAM_STD_READWRITE, 78cdf0e10cSrcweir StorageMode = 0 ); 79cdf0e10cSrcweir SotStorageStream( BaseStorageStream *pStm ); 80cdf0e10cSrcweir SotStorageStream(); 81cdf0e10cSrcweir SO2_DECL_BASIC_CLASS_DLL(SotStorageStream,SOTDATA()) 82cdf0e10cSrcweir SO2_DECL_INVARIANT() 83cdf0e10cSrcweir 84cdf0e10cSrcweir using SvStream::SyncSvStream; 85cdf0e10cSrcweir virtual void SyncSvStream(); SyncSysStream()86cdf0e10cSrcweir void SyncSysStream() { SvStream::SyncSysStream(); } 87cdf0e10cSrcweir 88cdf0e10cSrcweir virtual void ResetError(); 89cdf0e10cSrcweir 90cdf0e10cSrcweir virtual void SetSize( sal_uLong nNewSize ); 91cdf0e10cSrcweir sal_uInt32 GetSize() const; 92cdf0e10cSrcweir sal_Bool CopyTo( SotStorageStream * pDestStm ); 93cdf0e10cSrcweir virtual sal_Bool Commit(); 94cdf0e10cSrcweir virtual sal_Bool Revert(); 95cdf0e10cSrcweir sal_Bool SetProperty( const String& rName, const ::com::sun::star::uno::Any& rValue ); 96cdf0e10cSrcweir sal_Bool GetProperty( const String& rName, ::com::sun::star::uno::Any& rValue ); 97cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > 98cdf0e10cSrcweir GetXInputStream() const; 99cdf0e10cSrcweir }; 100cdf0e10cSrcweir 101cdf0e10cSrcweir #ifndef SOT_DECL_SOTSTORAGESTREAM_DEFINED 102cdf0e10cSrcweir #define SOT_DECL_SOTSTORAGESTREAM_DEFINED 103cdf0e10cSrcweir SO2_DECL_REF(SotStorageStream) 104cdf0e10cSrcweir #endif 105cdf0e10cSrcweir SO2_IMPL_REF(SotStorageStream) 106cdf0e10cSrcweir 107cdf0e10cSrcweir namespace ucbhelper 108cdf0e10cSrcweir { 109cdf0e10cSrcweir class Content; 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir class SvStorageInfoList; 113cdf0e10cSrcweir class BaseStorage; 114cdf0e10cSrcweir class UNOStorageHolder; 115cdf0e10cSrcweir class SOT_DLLPUBLIC SotStorage : virtual public SotObject 116cdf0e10cSrcweir { 117cdf0e10cSrcweir friend class SotStorageStream; 118cdf0e10cSrcweir friend class SvStorage; 119cdf0e10cSrcweir friend class ::binfilter::SvStorage; 120cdf0e10cSrcweir 121cdf0e10cSrcweir BaseStorage * m_pTmpStg; // Temp-Storage fuer Transacted, nur auf diesem schreiben! ??? Useless ??? 122cdf0e10cSrcweir BaseStorage * m_pOwnStg; // Zielstorage 123cdf0e10cSrcweir SvStream * m_pStorStm; // nur fuer SDSTORAGES 124cdf0e10cSrcweir sal_uLong m_nError; 125cdf0e10cSrcweir String m_aName; // Name des Storage 126cdf0e10cSrcweir sal_Bool m_bIsRoot:1, // z.B.: File-Storage 127cdf0e10cSrcweir m_bDelStm:1; 128cdf0e10cSrcweir ByteString m_aKey; // aKey.Len != 0 -> Verschluesselung 129cdf0e10cSrcweir long m_nVersion; 130cdf0e10cSrcweir 131cdf0e10cSrcweir protected: 132cdf0e10cSrcweir ~SotStorage(); 133cdf0e10cSrcweir void CreateStorage( sal_Bool bUCBStorage, StreamMode, StorageMode ); 134cdf0e10cSrcweir public: 135cdf0e10cSrcweir SotStorage( const String &, 136cdf0e10cSrcweir StreamMode = STREAM_STD_READWRITE, 137cdf0e10cSrcweir StorageMode = 0 ); 138cdf0e10cSrcweir SotStorage( sal_Bool bUCBStorage, const String &, 139cdf0e10cSrcweir StreamMode = STREAM_STD_READWRITE, 140cdf0e10cSrcweir StorageMode = 0 ); 141cdf0e10cSrcweir SotStorage( const ::ucbhelper::Content& rContent, const String &, 142cdf0e10cSrcweir StreamMode = STREAM_STD_READWRITE, 143cdf0e10cSrcweir StorageMode = 0 ); 144cdf0e10cSrcweir SotStorage( BaseStorage * ); 145cdf0e10cSrcweir SotStorage( SvStream & rStm ); 146cdf0e10cSrcweir SotStorage( sal_Bool bUCBStorage, SvStream & rStm ); 147cdf0e10cSrcweir SotStorage( SvStream * pStm, sal_Bool bDelete ); 148cdf0e10cSrcweir SotStorage(); 149cdf0e10cSrcweir SO2_DECL_BASIC_CLASS_DLL(SotStorage,SOTDATA()) 150cdf0e10cSrcweir SO2_DECL_INVARIANT() 151cdf0e10cSrcweir 152cdf0e10cSrcweir SvMemoryStream * CreateMemoryStream(); 153cdf0e10cSrcweir const SvStream * GetSvStream(); 154cdf0e10cSrcweir 155cdf0e10cSrcweir static sal_Bool IsStorageFile( const String & rFileName ); 156cdf0e10cSrcweir static sal_Bool IsStorageFile( SvStream* pStream ); 157cdf0e10cSrcweir 158cdf0e10cSrcweir virtual const String & GetName() const; 159cdf0e10cSrcweir 160cdf0e10cSrcweir virtual sal_Bool Validate(); 161cdf0e10cSrcweir 162cdf0e10cSrcweir void SetKey( const ByteString& rKey ); GetKey() const163cdf0e10cSrcweir const ByteString & GetKey() const { return m_aKey; } 164cdf0e10cSrcweir SetVersion(long nVers)165cdf0e10cSrcweir void SetVersion( long nVers ) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir m_nVersion = nVers; 168cdf0e10cSrcweir } GetVersion() const169cdf0e10cSrcweir long GetVersion() const 170cdf0e10cSrcweir { 171cdf0e10cSrcweir return m_nVersion; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir GetErrorCode() const174cdf0e10cSrcweir sal_uLong GetErrorCode() const { return m_nError; } GetError() const175cdf0e10cSrcweir sal_uLong GetError() const { return ERRCODE_TOERROR(m_nError); } SetError(sal_uLong nErrorCode)176cdf0e10cSrcweir void SetError( sal_uLong nErrorCode ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir if( m_nError == SVSTREAM_OK ) 179cdf0e10cSrcweir m_nError = nErrorCode; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir virtual void ResetError(); 182cdf0e10cSrcweir IsRoot() const183cdf0e10cSrcweir sal_Bool IsRoot() const { return m_bIsRoot; } SignAsRoot(sal_Bool b=sal_True)184cdf0e10cSrcweir void SignAsRoot( sal_Bool b = sal_True ) { m_bIsRoot = b; } SetDeleteStream(sal_Bool bDelete)185cdf0e10cSrcweir void SetDeleteStream( sal_Bool bDelete ) { m_bDelStm = bDelete; } 186cdf0e10cSrcweir 187cdf0e10cSrcweir // eigener Datenbereich 188cdf0e10cSrcweir virtual void SetClass( const SvGlobalName & rClass, 189cdf0e10cSrcweir sal_uLong bOriginalClipFormat, 190cdf0e10cSrcweir const String & rUserTypeName ); 191cdf0e10cSrcweir virtual void SetConvertClass( const SvGlobalName & rConvertClass, 192cdf0e10cSrcweir sal_uLong bOriginalClipFormat, 193cdf0e10cSrcweir const String & rUserTypeName ); 194cdf0e10cSrcweir virtual SvGlobalName GetClassName();// Typ der Daten im Storage 195cdf0e10cSrcweir virtual sal_uLong GetFormat(); 196cdf0e10cSrcweir virtual String GetUserName(); 197cdf0e10cSrcweir virtual sal_Bool ShouldConvert(); 198cdf0e10cSrcweir void SetName( const String& rName ); 199cdf0e10cSrcweir 200cdf0e10cSrcweir // Liste aller Elemente 201cdf0e10cSrcweir virtual void FillInfoList( SvStorageInfoList * ) const; 202cdf0e10cSrcweir virtual sal_Bool CopyTo( SotStorage * pDestStg ); 203cdf0e10cSrcweir virtual sal_Bool Commit(); 204cdf0e10cSrcweir virtual sal_Bool Revert(); 205cdf0e10cSrcweir 206cdf0e10cSrcweir /* Element Methoden */ 207cdf0e10cSrcweir // Stream mit Verbindung zu Storage erzeugen, 208cdf0e10cSrcweir // in etwa eine Parent-Child Beziehung 209cdf0e10cSrcweir SotStorageStream * OpenSotStream( const String & rEleName, 210cdf0e10cSrcweir StreamMode = STREAM_STD_READWRITE, 211cdf0e10cSrcweir StorageMode = 0 ); 212cdf0e10cSrcweir SotStorageStream * OpenEncryptedSotStream( const String & rEleName, const ByteString& rKey, 213cdf0e10cSrcweir StreamMode = STREAM_STD_READWRITE, 214cdf0e10cSrcweir StorageMode = 0 ); 215cdf0e10cSrcweir SotStorage * OpenSotStorage( const String & rEleName, 216cdf0e10cSrcweir StreamMode = STREAM_STD_READWRITE, 217cdf0e10cSrcweir StorageMode = STORAGE_TRANSACTED ); 218cdf0e10cSrcweir SotStorage * OpenUCBStorage( const String & rEleName, 219cdf0e10cSrcweir StreamMode = STREAM_STD_READWRITE, 220cdf0e10cSrcweir StorageMode = STORAGE_TRANSACTED ); 221cdf0e10cSrcweir SotStorage * OpenOLEStorage( const String & rEleName, 222cdf0e10cSrcweir StreamMode = STREAM_STD_READWRITE, 223cdf0e10cSrcweir StorageMode = STORAGE_TRANSACTED ); 224cdf0e10cSrcweir // Abfrage auf Storage oder Stream 225cdf0e10cSrcweir virtual sal_Bool IsStream( const String & rEleName ) const; 226cdf0e10cSrcweir virtual sal_Bool IsStorage( const String & rEleName ) const; 227cdf0e10cSrcweir virtual sal_Bool IsContained( const String & rEleName ) const; 228cdf0e10cSrcweir // Element loeschen 229cdf0e10cSrcweir virtual sal_Bool Remove( const String & rEleName ); 230cdf0e10cSrcweir // Elementnamen aendern 231cdf0e10cSrcweir virtual sal_Bool Rename( const String & rEleName, 232cdf0e10cSrcweir const String & rNewName ); 233cdf0e10cSrcweir virtual sal_Bool CopyTo( const String & rEleName, SotStorage * pDest, 234cdf0e10cSrcweir const String & rNewName ); 235cdf0e10cSrcweir virtual sal_Bool MoveTo( const String & rEleName, SotStorage * pDest, 236cdf0e10cSrcweir const String & rNewName ); 237cdf0e10cSrcweir 238cdf0e10cSrcweir SvStream* GetTargetSvStream() const; 239cdf0e10cSrcweir sal_Bool SetProperty( const String& rName, const ::com::sun::star::uno::Any& rValue ); 240cdf0e10cSrcweir sal_Bool GetProperty( const String& rName, ::com::sun::star::uno::Any& rValue ); 241cdf0e10cSrcweir sal_Bool GetProperty( const String& rEleName, const String& rName, ::com::sun::star::uno::Any& rValue ); 242cdf0e10cSrcweir sal_Bool IsOLEStorage() const; 243cdf0e10cSrcweir static sal_Bool IsOLEStorage( const String & rFileName ); 244cdf0e10cSrcweir static sal_Bool IsOLEStorage( SvStream* pStream ); 245cdf0e10cSrcweir 246cdf0e10cSrcweir // this is temporary HACK, _MUST_ be removed before release 247cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > 248cdf0e10cSrcweir GetUNOAPIDuplicate( const String& rEleName, sal_Int32 nUNOStorageMode ); 249cdf0e10cSrcweir void RemoveUNOStorageHolder( UNOStorageHolder* pHolder ); 250cdf0e10cSrcweir 251cdf0e10cSrcweir static SotStorage* OpenOLEStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage, 252cdf0e10cSrcweir const String& rEleName, StreamMode = STREAM_STD_READWRITE ); 253cdf0e10cSrcweir static sal_Int32 GetFormatID( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage ); 254cdf0e10cSrcweir static sal_Int32 GetVersion( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage ); 255cdf0e10cSrcweir }; 256cdf0e10cSrcweir 257cdf0e10cSrcweir #ifndef SOT_DECL_SOTSTORAGE_DEFINED 258cdf0e10cSrcweir #define SOT_DECL_SOTSTORAGE_DEFINED 259cdf0e10cSrcweir SO2_DECL_REF(SotStorage) 260cdf0e10cSrcweir #endif 261cdf0e10cSrcweir SO2_IMPL_REF(SotStorage) 262cdf0e10cSrcweir 263cdf0e10cSrcweir #define SvStorage SotStorage 264cdf0e10cSrcweir #define SvStorageRef SotStorageRef 265cdf0e10cSrcweir #define SvStorageStream SotStorageStream 266cdf0e10cSrcweir #define SvStorageStreamRef SotStorageStreamRef 267cdf0e10cSrcweir 268cdf0e10cSrcweir #endif // _SVSTOR_HXX 269