1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <sot/storinfo.hxx>
22 #include <sot/exchange.hxx>
23 #include <osl/file.hxx>
24 #include <unotools/tempfile.hxx>
25 #include <tools/stream.hxx>
26 #include <tools/debug.hxx>
28 #include "sot/stg.hxx"
29 #include "stgelem.hxx"
30 #include "stgcache.hxx"
31 #include "stgstrms.hxx"
36 static long nTmpCount
= 0;
38 // The internal open mode is StreamMode::READ | StreamMode::TRUNC, which is silly
39 // by itself. It inhibits the checking of sharing modes and is used
40 // during CopyTo() and MoveTo() for opening a stream in read mode
41 // although it may be open in DENYALL mode
43 #define INTERNAL_MODE ( StreamMode::READ | StreamMode::TRUNC )
45 ///////////////////////// class StorageBase
47 TYPEINIT0( StorageBase
);
48 TYPEINIT1( BaseStorageStream
, StorageBase
);
49 TYPEINIT1( BaseStorage
, StorageBase
);
51 StorageBase::StorageBase()
52 : m_bAutoCommit( false )
54 m_nMode
= StreamMode::READ
;
55 m_nError
= SVSTREAM_OK
;
58 StorageBase::~StorageBase()
62 // The following three methods are declared as const, since they
63 // may be called from within a const method.
65 sal_uLong
StorageBase::GetError() const
67 sal_uLong n
= m_nError
;
68 const_cast<StorageBase
*>(this)->m_nError
= SVSTREAM_OK
;
72 void StorageBase::SetError( sal_uLong n
) const
75 const_cast<StorageBase
*>(this)->m_nError
= n
;
78 void StorageBase::ResetError() const
80 const_cast<StorageBase
*>(this)->m_nError
= SVSTREAM_OK
;
83 // Retrieve the underlying SvStream for info purposes
85 const SvStream
* OLEStorageBase::GetSvStream_Impl() const
87 return pIo
? pIo
->GetStrm() : NULL
;
90 OLEStorageBase::OLEStorageBase( StgIo
* p
, StgDirEntry
* pe
, StreamMode
& nMode
)
91 : nStreamMode( nMode
), pIo( p
), pEntry( pe
)
99 OLEStorageBase::~OLEStorageBase()
103 DBG_ASSERT( pEntry
->nRefCnt
, "RefCount unter 0" );
104 if( !--pEntry
->nRefCnt
)
106 if( pEntry
->bZombie
)
116 if( pIo
&& !pIo
->DecRef() )
123 // Validate the instance for I/O
125 bool OLEStorageBase::Validate_Impl( bool bWrite
) const
131 && ( !bWrite
|| !pEntry
->bDirect
|| ( nStreamMode
& StreamMode::WRITE
) ) )
136 bool OLEStorageBase::ValidateMode_Impl( StreamMode m
, StgDirEntry
* p
)
138 if( m
== INTERNAL_MODE
)
140 StreamMode nCurMode
= ( p
&& p
->nRefCnt
) ? p
->nMode
: StreamMode::SHARE_DENYALL
;
141 if( ( m
& STREAM_READWRITE
) == StreamMode::READ
)
143 // only SHARE_DENYWRITE or SHARE_DENYALL allowed
144 if( ( ( m
& StreamMode::SHARE_DENYWRITE
)
145 && ( nCurMode
& StreamMode::SHARE_DENYWRITE
) )
146 || ( ( m
& StreamMode::SHARE_DENYALL
)
147 && ( nCurMode
& StreamMode::SHARE_DENYALL
) ) )
152 // only SHARE_DENYALL allowed
153 // storages open in r/o mode are OK, since only
154 // the commit may fail
155 if( ( m
& StreamMode::SHARE_DENYALL
)
156 && ( nCurMode
& StreamMode::SHARE_DENYALL
) )
163 //////////////////////// class StorageStream
165 TYPEINIT1( StorageStream
, BaseStorageStream
);
167 StorageStream::StorageStream( StgIo
* p
, StgDirEntry
* q
, StreamMode m
)
168 : OLEStorageBase( p
, q
, m_nMode
), nPos( 0L )
170 // The dir entry may be 0; this means that the stream is invalid.
173 if( q
->nRefCnt
== 1 )
180 m
&= ~StreamMode(STREAM_READWRITE
);
184 StorageStream::~StorageStream()
186 // Do an auto-commit if the entry is open in direct mode
189 if( pEntry
&& pEntry
->nRefCnt
&& pEntry
->bDirect
&& (m_nMode
& StreamMode::WRITE
) )
193 bool StorageStream::Equals( const BaseStorageStream
& rStream
) const
195 const StorageStream
* pOther
= PTR_CAST( StorageStream
, &rStream
);
196 return pOther
&& ( pOther
->pEntry
== pEntry
);
199 sal_uLong
StorageStream::Read( void* pData
, sal_uLong nSize
)
203 pEntry
->Seek( nPos
);
204 nSize
= pEntry
->Read( pData
, (sal_Int32
) nSize
);
205 pIo
->MoveError( *this );
213 sal_uLong
StorageStream::Write( const void* pData
, sal_uLong nSize
)
215 if( Validate( true ) )
217 pEntry
->Seek( nPos
);
218 nSize
= pEntry
->Write( pData
, (sal_Int32
) nSize
);
219 pIo
->MoveError( *this );
227 sal_uInt64
StorageStream::Seek( sal_uInt64 n
)
230 return nPos
= pEntry
->Seek( n
);
235 void StorageStream::Flush()
237 // Flushing means committing, since streams are never transacted
241 bool StorageStream::SetSize( sal_uLong nNewSize
)
243 if( Validate( true ) )
245 bool b
= pEntry
->SetSize( (sal_Int32
) nNewSize
);
246 pIo
->MoveError( *this );
253 sal_uLong
StorageStream::GetSize() const
256 return pEntry
->GetSize();
260 bool StorageStream::Commit()
264 if( !( m_nMode
& StreamMode::WRITE
) )
266 SetError( SVSTREAM_ACCESS_DENIED
);
272 pIo
->MoveError( *this );
277 bool StorageStream::Revert()
279 bool bResult
= false;
284 pIo
->MoveError( *this );
291 bool StorageStream::CopyTo( BaseStorageStream
* pDest
)
293 if( !Validate() || !pDest
|| !pDest
->Validate( true ) || Equals( *pDest
) )
295 pEntry
->Copy( *pDest
);
297 pIo
->MoveError( *this );
298 SetError( pDest
->GetError() );
299 return Good() && pDest
->Good();
302 const SvStream
* StorageStream::GetSvStream() const
304 return GetSvStream_Impl();
307 bool StorageStream::Validate( bool bValidate
) const
309 bool bRet
= Validate_Impl( bValidate
);
311 SetError( SVSTREAM_ACCESS_DENIED
);
315 bool StorageStream::ValidateMode( StreamMode nMode
) const
317 bool bRet
= ValidateMode_Impl( nMode
, NULL
);
319 SetError( SVSTREAM_ACCESS_DENIED
);
323 ///////////////////////// class SvStorageInfo
325 SvStorageInfo::SvStorageInfo( const StgDirEntry
& rE
)
327 rE
.aEntry
.GetName( aName
);
328 bStorage
= rE
.aEntry
.GetType() == STG_STORAGE
;
329 bStream
= rE
.aEntry
.GetType() == STG_STREAM
;
330 nSize
= bStorage
? 0 : rE
.aEntry
.GetSize();
333 /////////////////////////// class Storage
335 bool Storage::IsStorageFile( const OUString
& rFileName
)
338 if( aIo
.Open( rFileName
, STREAM_STD_READ
) )
343 bool Storage::IsStorageFile( SvStream
* pStream
)
350 sal_uLong nPos
= pStream
->Tell();
351 bRet
= ( aHdr
.Load( *pStream
) && aHdr
.Check() );
353 // It's not a stream error if it is too small for a OLE storage header
354 if ( pStream
->GetErrorCode() == ERRCODE_IO_CANTSEEK
)
355 pStream
->ResetError();
356 pStream
->Seek( nPos
);
362 // Open the storage file. If writing is permitted and the file is not
363 // a storage file, initialize it.
365 TYPEINIT1( Storage
, BaseStorage
);
367 Storage::Storage( const OUString
& rFile
, StreamMode m
, bool bDirect
)
368 : OLEStorageBase( new StgIo
, NULL
, m_nMode
)
369 , aName( rFile
), bIsRoot( false )
372 if( aName
.isEmpty() )
374 // no name = temporary name!
375 aName
= utl::TempFile::CreateTempName();
378 // the root storage creates the I/O system
380 if( pIo
->Open( aName
, m
) )
382 Init( ( m
& ( StreamMode::TRUNC
| StreamMode::NOCREATE
) ) == StreamMode::TRUNC
);
385 pEntry
->bDirect
= bDirect
;
387 pEntry
->bTemp
= bTemp
;
392 pIo
->MoveError( *this );
397 // Create a storage on a given stream.
399 Storage::Storage( SvStream
& r
, bool bDirect
)
400 : OLEStorageBase( new StgIo
, NULL
, m_nMode
)
403 m_nMode
= StreamMode::READ
;
405 m_nMode
= StreamMode::READ
| StreamMode::WRITE
;
406 if( r
.GetError() == SVSTREAM_OK
)
408 pIo
->SetStrm( &r
, false );
409 sal_uLong nSize
= r
.Seek( STREAM_SEEK_TO_END
);
411 // Initializing is OK if the stream is empty
415 pEntry
->bDirect
= bDirect
;
416 pEntry
->nMode
= m_nMode
;
418 pIo
->MoveError( *this );
422 SetError( r
.GetError() );
428 Storage::Storage( UCBStorageStream
& rStrm
, bool bDirect
)
429 : OLEStorageBase( new StgIo
, NULL
, m_nMode
), bIsRoot( false )
431 m_nMode
= StreamMode::READ
;
433 if ( rStrm
.GetError() != SVSTREAM_OK
)
435 SetError( rStrm
.GetError() );
440 SvStream
* pStream
= rStrm
.GetModifySvStream();
443 OSL_FAIL( "UCBStorageStream can not provide SvStream implementation!\n" );
444 SetError( SVSTREAM_GENERALERROR
);
449 if( pStream
->IsWritable() )
450 m_nMode
= StreamMode::READ
| StreamMode::WRITE
;
452 pIo
->SetStrm( &rStrm
);
454 sal_uLong nSize
= pStream
->Seek( STREAM_SEEK_TO_END
);
456 // Initializing is OK if the stream is empty
460 pEntry
->bDirect
= bDirect
;
461 pEntry
->nMode
= m_nMode
;
464 pIo
->MoveError( *this );
468 // Perform common code for both ctors above.
470 void Storage::Init( bool bCreate
)
473 bool bHdrLoaded
= false;
476 OSL_ENSURE( pIo
, "The pointer may not be empty at this point!" );
477 if( pIo
->Good() && pIo
->GetStrm() )
479 sal_uLong nSize
= pIo
->GetStrm()->Seek( STREAM_SEEK_TO_END
);
480 pIo
->GetStrm()->Seek( 0L );
483 bHdrLoaded
= pIo
->Load();
484 if( !bHdrLoaded
&& !bCreate
)
486 // File is not a storage and not empty; do not destroy!
487 SetError( SVSTREAM_FILEFORMAT_ERROR
);
492 // file is a storage, empty or should be overwritten
494 // we have to set up the data structures, since
498 if( pIo
->Good() && pIo
->pTOC
)
500 pEntry
= pIo
->pTOC
->GetRoot();
507 Storage::Storage( StgIo
* p
, StgDirEntry
* q
, StreamMode m
)
508 : OLEStorageBase( p
, q
, m_nMode
), bIsRoot( false )
511 q
->aEntry
.GetName( aName
);
513 m
&= ~StreamMode(STREAM_READWRITE
);
515 if( q
&& q
->nRefCnt
== 1 )
521 // Invalidate all open substorages
526 // Do an auto-commit if the entry is open in direct mode
527 if( pEntry
->nRefCnt
&& pEntry
->bDirect
&& (m_nMode
& StreamMode::WRITE
) )
529 if( pEntry
->nRefCnt
== 1 )
530 pEntry
->Invalidate();
532 // close the stream is root storage
535 // remove the file if temporary root storage
536 if( bIsRoot
&& pEntry
&& pEntry
->bTemp
)
538 osl::File::remove( GetName() );
542 const OUString
& Storage::GetName() const
544 if( !bIsRoot
&& Validate() )
545 pEntry
->aEntry
.GetName( const_cast<Storage
*>(this)->aName
);
549 // Fill in the info list for this storage
551 void Storage::FillInfoList( SvStorageInfoList
* pList
) const
553 if( Validate() && pList
)
555 StgIterator
aIter( *pEntry
);
556 StgDirEntry
* p
= aIter
.First();
561 SvStorageInfo
aInfo( *p
);
562 pList
->push_back( aInfo
);
569 // Open or create a substorage
571 BaseStorage
* Storage::OpenUCBStorage( const OUString
& rName
, StreamMode m
, bool bDirect
)
573 OSL_FAIL("Not supported!");
574 return OpenStorage( rName
, m
, bDirect
);
577 BaseStorage
* Storage::OpenOLEStorage( const OUString
& rName
, StreamMode m
, bool bDirect
)
579 return OpenStorage( rName
, m
, bDirect
);
582 BaseStorage
* Storage::OpenStorage( const OUString
& rName
, StreamMode m
, bool bDirect
)
584 if( !Validate() || !ValidateMode( m
) )
585 return new Storage( pIo
, NULL
, m
);
586 if( bDirect
&& !pEntry
->bDirect
)
589 StgDirEntry
* p
= pIo
->pTOC
->Find( *pEntry
, rName
);
592 if( !( m
& StreamMode::NOCREATE
) )
595 // create a new storage
596 OUString aNewName
= rName
;
597 if( aNewName
.isEmpty() )
599 aNewName
= "Temp Stg " + OUString::number( ++nTmpCount
);
602 p
= pIo
->pTOC
->Create( *pEntry
, aNewName
, STG_STORAGE
);
607 pIo
->SetError( ( m
& StreamMode::WRITE
)
608 ? SVSTREAM_CANNOT_MAKE
: SVSTREAM_FILE_NOT_FOUND
);
610 else if( !ValidateMode( m
, p
) )
612 if( p
&& p
->aEntry
.GetType() != STG_STORAGE
)
614 pIo
->SetError( SVSTREAM_FILE_NOT_FOUND
);
618 // Either direct or transacted mode is supported
619 if( p
&& pEntry
->nRefCnt
== 1 )
620 p
->bDirect
= bDirect
;
622 // Dont check direct conflict if opening readonly
623 if( p
&& (m
& StreamMode::WRITE
))
625 if( p
->bDirect
!= bDirect
)
626 SetError( SVSTREAM_ACCESS_DENIED
);
628 Storage
* pStg
= new Storage( pIo
, p
, m
);
629 pIo
->MoveError( *pStg
);
630 if( m
& StreamMode::WRITE
) pStg
->m_bAutoCommit
= true;
636 BaseStorageStream
* Storage::OpenStream( const OUString
& rName
, StreamMode m
, bool,
643 DBG_ASSERT(!pB
, "Encryption not supported");
645 if( !Validate() || !ValidateMode( m
) )
646 return new StorageStream( pIo
, NULL
, m
);
647 StgDirEntry
* p
= pIo
->pTOC
->Find( *pEntry
, rName
);
651 if( !( m
& StreamMode::NOCREATE
) )
653 // create a new stream
654 // make a name if the stream is temporary (has no name)
655 OUString
aNewName( rName
);
656 if( aNewName
.isEmpty() )
658 aNewName
= "Temp Strm " + OUString::number( ++nTmpCount
);
661 p
= pIo
->pTOC
->Create( *pEntry
, aNewName
, STG_STREAM
);
664 pIo
->SetError( ( m
& StreamMode::WRITE
)
665 ? SVSTREAM_CANNOT_MAKE
: SVSTREAM_FILE_NOT_FOUND
);
667 else if( !ValidateMode( m
, p
) )
669 if( p
&& p
->aEntry
.GetType() != STG_STREAM
)
671 pIo
->SetError( SVSTREAM_FILE_NOT_FOUND
);
677 p
->bDirect
= pEntry
->bDirect
;
679 StorageStream
* pStm
= new StorageStream( pIo
, p
, m
);
680 if( p
&& !p
->bDirect
)
681 pStm
->SetAutoCommit( true );
682 pIo
->MoveError( *pStm
);
686 // Delete a stream or substorage by setting the temp bit.
688 bool Storage::Remove( const OUString
& rName
)
690 if( !Validate( true ) )
692 StgDirEntry
* p
= pIo
->pTOC
->Find( *pEntry
, rName
);
695 p
->Invalidate( true );
700 SetError( SVSTREAM_FILE_NOT_FOUND
);
705 // Rename a storage element
707 bool Storage::Rename( const OUString
& rOld
, const OUString
& rNew
)
709 if( Validate( true ) )
711 bool b
= pIo
->pTOC
->Rename( *pEntry
, rOld
, rNew
);
712 pIo
->MoveError( *this );
721 bool Storage::CopyTo( const OUString
& rElem
, BaseStorage
* pDest
, const OUString
& rNew
)
723 if( !Validate() || !pDest
|| !pDest
->Validate( true ) )
725 StgDirEntry
* pElem
= pIo
->pTOC
->Find( *pEntry
, rElem
);
728 if( pElem
->aEntry
.GetType() == STG_STORAGE
)
730 // copy the entire storage
731 BaseStorage
* p1
= OpenStorage( rElem
, INTERNAL_MODE
);
732 BaseStorage
* p2
= pDest
->OpenOLEStorage( rNew
, StreamMode::WRITE
| StreamMode::SHARE_DENYALL
, pEntry
->bDirect
);
736 sal_uLong nTmpErr
= p2
->GetError();
739 p2
->SetClassId( p1
->GetClassId() );
741 SetError( p1
->GetError() );
743 nTmpErr
= p2
->GetError();
747 pDest
->SetError( nTmpErr
);
750 pDest
->SetError( nTmpErr
);
755 return Good() && pDest
->Good();
760 BaseStorageStream
* p1
= OpenStream( rElem
, INTERNAL_MODE
);
761 BaseStorageStream
* p2
= pDest
->OpenStream( rNew
, StreamMode::WRITE
| StreamMode::SHARE_DENYALL
, pEntry
->bDirect
);
765 sal_uLong nTmpErr
= p2
->GetError();
769 SetError( p1
->GetError() );
771 nTmpErr
= p2
->GetError();
775 pDest
->SetError( nTmpErr
);
778 pDest
->SetError( nTmpErr
);
783 return Good() && pDest
->Good();
786 SetError( SVSTREAM_FILE_NOT_FOUND
);
790 bool Storage::CopyTo( BaseStorage
* pDest
) const
792 if( !Validate() || !pDest
|| !pDest
->Validate( true ) || Equals( *pDest
) )
794 SetError( SVSTREAM_ACCESS_DENIED
);
797 Storage
* pThis
= const_cast<Storage
*>(this);
798 pDest
->SetClassId( GetClassId() );
800 SvStorageInfoList aList
;
801 FillInfoList( &aList
);
803 for( size_t i
= 0; i
< aList
.size() && bRes
; i
++ )
805 SvStorageInfo
& rInfo
= aList
[ i
];
806 bRes
= pThis
->CopyTo( rInfo
.GetName(), pDest
, rInfo
.GetName() );
809 SetError( pDest
->GetError() );
810 return Good() && pDest
->Good();
815 bool Storage::MoveTo( const OUString
& rElem
, BaseStorage
* pODest
, const OUString
& rNew
)
817 if( !Validate() || !pODest
|| !pODest
->Validate( true ) || Equals( *pODest
) )
819 SetError( SVSTREAM_ACCESS_DENIED
);
823 StgDirEntry
* pElem
= pIo
->pTOC
->Find( *pEntry
, rElem
);
826 // Simplest case: both storages share the same file
828 Storage
*pOther
= PTR_CAST( Storage
, pODest
);
829 if( pOther
&& pIo
== pOther
->pIo
&& rElem
== rNew
)
831 Storage
*p
= static_cast<Storage
*>(pODest
);
833 // both storages are conventional storages, use implementation dependent code
834 if( !pElem
->IsContained( pDest
->pEntry
) )
837 SetError( SVSTREAM_ACCESS_DENIED
);
840 bRes
= pIo
->pTOC
->Move( *pEntry
, *pDest
->pEntry
, rNew
);
843 pIo
->MoveError( *this );
844 pDest
->pIo
->MoveError( *pDest
);
845 sal_uLong nErr
= GetError();
847 nErr
= pDest
->GetError();
849 pDest
->SetError( nErr
);
854 bRes
= CopyTo( rElem
, pODest
, rNew
);
856 bRes
= Remove( rElem
);
859 SetError( pIo
->GetError() );
862 SetError( SVSTREAM_FILE_NOT_FOUND
);
866 bool Storage::IsStorage( const OUString
& rName
) const
870 StgDirEntry
* p
= pIo
->pTOC
->Find( *pEntry
, rName
);
872 return p
->aEntry
.GetType() == STG_STORAGE
;
877 bool Storage::IsStream( const OUString
& rName
) const
881 StgDirEntry
* p
= pIo
->pTOC
->Find( *pEntry
, rName
);
883 return p
->aEntry
.GetType() == STG_STREAM
;
888 bool Storage::IsContained( const OUString
& rName
) const
891 return pIo
->pTOC
->Find( *pEntry
, rName
) != NULL
;
896 // Commit all sub-elements within this storage. If this is
897 // the root, commit the FAT, the TOC and the header as well.
899 bool Storage::Commit()
904 if( !( m_nMode
& StreamMode::WRITE
) )
906 SetError( SVSTREAM_ACCESS_DENIED
);
911 // Also commit the sub-streams and Storages
912 StgIterator
aIter( *pEntry
);
913 for( StgDirEntry
* p
= aIter
.First(); p
&& bRes
; p
= aIter
.Next() )
915 if( bRes
&& bIsRoot
)
917 bRes
= pEntry
->Commit();
919 bRes
= pIo
->CommitAll();
921 pIo
->MoveError( *this );
926 bool Storage::Revert()
931 ///////////////////////////// OLE Support
933 // Set the storage type
935 void Storage::SetClass( const SvGlobalName
& rClass
,
936 SotClipboardFormatId nOriginalClipFormat
,
937 const OUString
& rUserTypeName
)
939 if( Validate( true ) )
941 // set the class name in the root entry
942 pEntry
->aEntry
.SetClassId( (const ClsId
&) rClass
.GetCLSID() );
944 // then create the streams
945 StgCompObjStream
aCompObj( *this, true );
946 aCompObj
.GetClsId() = (const ClsId
&) rClass
.GetCLSID();
947 aCompObj
.GetCbFormat() = nOriginalClipFormat
;
948 aCompObj
.GetUserName() = rUserTypeName
;
949 if( !aCompObj
.Store() )
950 SetError( aCompObj
.GetError() );
953 StgOleStream
aOle(*this, true);
955 SetError( aOle
.GetError() );
959 SetError( SVSTREAM_ACCESS_DENIED
);
962 void Storage::SetConvertClass( const SvGlobalName
& rConvertClass
,
963 SotClipboardFormatId nOriginalClipFormat
,
964 const OUString
& rUserTypeName
)
966 if( Validate( true ) )
968 SetClass( rConvertClass
, nOriginalClipFormat
, rUserTypeName
);
969 // plus the convert flag:
970 StgOleStream
aOle( *this, true );
971 aOle
.GetFlags() |= 4;
973 SetError( aOle
.GetError() );
977 SvGlobalName
Storage::GetClassName()
979 StgCompObjStream
aCompObj( *this, false );
980 if( aCompObj
.Load() )
981 return SvGlobalName( aCompObj
.GetClsId() );
985 return SvGlobalName( pEntry
->aEntry
.GetClassId() );
987 return SvGlobalName();
990 SotClipboardFormatId
Storage::GetFormat()
992 StgCompObjStream
aCompObj( *this, false );
993 if( aCompObj
.Load() )
994 return aCompObj
.GetCbFormat();
996 return SotClipboardFormatId::NONE
;
999 OUString
Storage::GetUserName()
1001 StgCompObjStream
aCompObj( *this, false );
1002 if( aCompObj
.Load() )
1003 return aCompObj
.GetUserName();
1008 bool Storage::ShouldConvert()
1010 StgOleStream
aOle( *this, false );
1012 return ( aOle
.GetFlags() & 4 ) != 0;
1020 bool Storage::ValidateFAT()
1022 Link
<> aLink
= StgIo::GetErrorLink();
1023 ErrCode nErr
= pIo
->ValidateFATs();
1024 StgIo::SetErrorLink( aLink
);
1025 return nErr
== ERRCODE_NONE
;
1028 void Storage::SetDirty()
1034 void Storage::SetClassId( const ClsId
& rId
)
1037 pEntry
->aEntry
.SetClassId( rId
);
1040 const ClsId
& Storage::GetClassId() const
1043 return pEntry
->aEntry
.GetClassId();
1045 static ClsId aDummyId
= {0,0,0,{0,0,0,0,0,0,0,0}};
1049 const SvStream
* Storage::GetSvStream() const
1051 return GetSvStream_Impl();
1054 bool Storage::Validate( bool bValidate
) const
1056 bool bRet
= Validate_Impl( bValidate
);
1058 SetError( SVSTREAM_ACCESS_DENIED
);
1062 bool Storage::ValidateMode( StreamMode nMode
) const
1064 bool bRet
= ValidateMode_Impl( nMode
);
1066 SetError( SVSTREAM_ACCESS_DENIED
);
1070 bool Storage::ValidateMode( StreamMode nMode
, StgDirEntry
* p
) const
1072 bool bRet
= ValidateMode_Impl( nMode
, p
);
1074 SetError( SVSTREAM_ACCESS_DENIED
);
1078 bool Storage::Equals( const BaseStorage
& rStorage
) const
1080 const Storage
* pOther
= PTR_CAST( Storage
, &rStorage
);
1081 return pOther
&& ( pOther
->pEntry
== pEntry
);
1085 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */