LCOV - code coverage report
Current view: top level - include/sot - stg.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 8 0.0 %
Date: 2014-04-14 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          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 INCLUDED_SOT_STG_HXX
      21             : #define INCLUDED_SOT_STG_HXX
      22             : 
      23             : #include <com/sun/star/uno/Any.h>
      24             : #include <com/sun/star/uno/Reference.h>
      25             : 
      26             : #include <com/sun/star/io/XInputStream.hpp>
      27             : 
      28             : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      29             : 
      30             : #include <com/sun/star/embed/XStorage.hpp>
      31             : 
      32             : 
      33             : #include <tools/rtti.hxx>
      34             : #include <tools/solar.h>
      35             : #include <tools/stream.hxx>
      36             : #include <tools/globname.hxx>
      37             : #include <sot/storinfo.hxx>
      38             : #include <sot/sotdllapi.h>
      39             : 
      40             : class Storage;
      41             : class StorageStream;
      42             : class StgIo;
      43             : class StgDirEntry;
      44             : class StgStrm;
      45             : class SvGlobalName;
      46             : struct ClsId
      47             : {
      48             :     sal_Int32   n1;
      49             :     sal_Int16   n2, n3;
      50             :     sal_uInt8   n4, n5, n6, n7, n8, n9, n10, n11;
      51             : };
      52             : 
      53             : class SOT_DLLPUBLIC StorageBase : public SvRefBase
      54             : {
      55             : protected:
      56             :     sal_uLong       m_nError;                   // error code
      57             :     StreamMode      m_nMode;                    // open mode
      58             :     bool            m_bAutoCommit;
      59             :                     StorageBase();
      60             :     virtual         ~StorageBase();
      61             : public:
      62             :                     TYPEINFO();
      63             :     virtual const SvStream* GetSvStream() const = 0;
      64             :     virtual bool    Validate( bool=false ) const = 0;
      65             :     virtual bool    ValidateMode( StreamMode ) const = 0;
      66             :     void            ResetError() const;
      67             :     void            SetError( sal_uLong ) const;
      68             :     sal_uLong       GetError() const;
      69           0 :     bool            Good() const          { return bool( m_nError == SVSTREAM_OK ); }
      70           0 :     StreamMode      GetMode() const  { return m_nMode;  }
      71           0 :     void            SetAutoCommit( bool bSet )
      72           0 :                     { m_bAutoCommit = bSet; }
      73             : };
      74             : 
      75           0 : class BaseStorageStream : public StorageBase
      76             : {
      77             : public:
      78             :                         TYPEINFO_OVERRIDE();
      79             :     virtual sal_uLong   Read( void * pData, sal_uLong nSize ) = 0;
      80             :     virtual sal_uLong   Write( const void* pData, sal_uLong nSize ) = 0;
      81             :     virtual sal_uInt64  Seek( sal_uInt64 nPos ) = 0;
      82             :     virtual sal_uLong   Tell() = 0;
      83             :     virtual void        Flush() = 0;
      84             :     virtual bool        SetSize( sal_uLong nNewSize ) = 0;
      85             :     virtual sal_uLong   GetSize() const = 0;
      86             :     virtual bool        CopyTo( BaseStorageStream * pDestStm ) = 0;
      87             :     virtual bool        Commit() = 0;
      88             :     virtual bool        Revert() = 0;
      89             :     virtual bool        Equals( const BaseStorageStream& rStream ) const = 0;
      90             : };
      91             : 
      92           0 : class BaseStorage : public StorageBase
      93             : {
      94             : public:
      95             :                                 TYPEINFO_OVERRIDE();
      96             :     virtual const OUString&     GetName() const = 0;
      97             :     virtual bool                IsRoot() const = 0;
      98             :     virtual void                SetClassId( const ClsId& ) = 0;
      99             :     virtual const ClsId&        GetClassId() const = 0;
     100             :     virtual void                SetDirty() = 0;
     101             :     virtual void                SetClass( const SvGlobalName & rClass,
     102             :                                           sal_uLong nOriginalClipFormat,
     103             :                                           const OUString & rUserTypeName ) = 0;
     104             :     virtual void                SetConvertClass( const SvGlobalName & rConvertClass,
     105             :                                                  sal_uLong nOriginalClipFormat,
     106             :                                                  const OUString & rUserTypeName ) = 0;
     107             :     virtual SvGlobalName        GetClassName() = 0;
     108             :     virtual sal_uLong           GetFormat() = 0;
     109             :     virtual OUString            GetUserName() = 0;
     110             :     virtual bool                ShouldConvert() = 0;
     111             :     virtual void                FillInfoList( SvStorageInfoList* ) const = 0;
     112             :     virtual bool                CopyTo( BaseStorage* pDestStg ) const = 0;
     113             :     virtual bool                Commit() = 0;
     114             :     virtual bool                Revert() = 0;
     115             :     virtual BaseStorageStream*  OpenStream( const OUString & rEleName,
     116             :                                             StreamMode = STREAM_STD_READWRITE,
     117             :                                             bool bDirect = true, const OString* pKey=0 ) = 0;
     118             :     virtual BaseStorage*        OpenStorage( const OUString & rEleName,
     119             :                                              StreamMode = STREAM_STD_READWRITE,
     120             :                                              bool bDirect = false ) = 0;
     121             :     virtual BaseStorage*        OpenUCBStorage( const OUString & rEleName,
     122             :                                                 StreamMode = STREAM_STD_READWRITE,
     123             :                                                 bool bDirect = false ) = 0;
     124             :     virtual BaseStorage*        OpenOLEStorage( const OUString & rEleName,
     125             :                                                 StreamMode = STREAM_STD_READWRITE,
     126             :                                                 bool bDirect = false ) = 0;
     127             :     virtual bool                IsStream( const OUString& rEleName ) const = 0;
     128             :     virtual bool                IsStorage( const OUString& rEleName ) const = 0;
     129             :     virtual bool                IsContained( const OUString& rEleName ) const = 0;
     130             :     virtual bool                Remove( const OUString & rEleName ) = 0;
     131             :     virtual bool                Rename( const OUString & rEleName, const OUString & rNewName ) = 0;
     132             :     virtual bool                CopyTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) = 0;
     133             :     virtual bool                MoveTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) = 0;
     134             :     virtual bool                ValidateFAT() = 0;
     135             :     virtual bool                Equals( const BaseStorage& rStream ) const = 0;
     136             : };
     137             : 
     138             : class OLEStorageBase
     139             : {
     140             : protected:
     141             :     StreamMode&     nStreamMode;              // open mode
     142             :     StgIo*          pIo;                      // I/O subsystem
     143             :     StgDirEntry*    pEntry;                   // the dir entry
     144             :                     OLEStorageBase( StgIo*, StgDirEntry*, StreamMode& );
     145             :                     ~OLEStorageBase();
     146             :     bool            Validate_Impl( bool=false ) const;
     147             :     bool            ValidateMode_Impl( StreamMode, StgDirEntry* p = NULL ) const ;
     148             :     const SvStream* GetSvStream_Impl() const;
     149             : public:
     150             : };
     151             : 
     152             : class StorageStream : public BaseStorageStream, public OLEStorageBase
     153             : {
     154             : //friend class Storage;
     155             :     sal_uLong           nPos;                             // current position
     156             : protected:
     157             :                         virtual ~StorageStream();
     158             : public:
     159             :                         TYPEINFO_OVERRIDE();
     160             :                         StorageStream( StgIo*, StgDirEntry*, StreamMode );
     161             :     virtual sal_uLong   Read( void * pData, sal_uLong nSize ) SAL_OVERRIDE;
     162             :     virtual sal_uLong   Write( const void* pData, sal_uLong nSize ) SAL_OVERRIDE;
     163             :     virtual sal_uInt64  Seek( sal_uInt64 nPos ) SAL_OVERRIDE;
     164           0 :     virtual sal_uLong   Tell() SAL_OVERRIDE { return nPos; }
     165             :     virtual void        Flush() SAL_OVERRIDE;
     166             :     virtual bool        SetSize( sal_uLong nNewSize ) SAL_OVERRIDE;
     167             :     virtual sal_uLong   GetSize() const SAL_OVERRIDE;
     168             :     virtual bool        CopyTo( BaseStorageStream * pDestStm ) SAL_OVERRIDE;
     169             :     virtual bool        Commit() SAL_OVERRIDE;
     170             :     virtual bool        Revert() SAL_OVERRIDE;
     171             :     virtual bool        Validate( bool=false ) const SAL_OVERRIDE;
     172             :     virtual bool        ValidateMode( StreamMode ) const SAL_OVERRIDE;
     173             :     const SvStream*     GetSvStream() const SAL_OVERRIDE;
     174             :     virtual bool        Equals( const BaseStorageStream& rStream ) const SAL_OVERRIDE;
     175             : };
     176             : 
     177             : class UCBStorageStream;
     178             : 
     179             : class SOT_DLLPUBLIC Storage : public BaseStorage, public OLEStorageBase
     180             : {
     181             :     OUString                    aName;
     182             :     bool                        bIsRoot;
     183             :     void                        Init( bool bCreate );
     184             :                                 Storage( StgIo*, StgDirEntry*, StreamMode );
     185             : protected:
     186             :                                 virtual ~Storage();
     187             : public:
     188             :                                 TYPEINFO_OVERRIDE();
     189             :                                 Storage( const OUString &, StreamMode = STREAM_STD_READWRITE, bool bDirect = true );
     190             :                                 Storage( SvStream& rStrm, bool bDirect = true );
     191             :                                 Storage( UCBStorageStream& rStrm, bool bDirect = true );
     192             : 
     193             :     static bool                 IsStorageFile( const OUString & rFileName );
     194             :     static bool                 IsStorageFile( SvStream* );
     195             : 
     196             :     virtual const OUString&     GetName() const SAL_OVERRIDE;
     197           0 :     virtual bool                IsRoot() const SAL_OVERRIDE { return bIsRoot; }
     198             :     virtual void                SetClassId( const ClsId& ) SAL_OVERRIDE;
     199             :     virtual const ClsId&        GetClassId() const SAL_OVERRIDE;
     200             :     virtual void                SetDirty() SAL_OVERRIDE;
     201             :     virtual void                SetClass( const SvGlobalName & rClass,
     202             :                                           sal_uLong nOriginalClipFormat,
     203             :                                           const OUString & rUserTypeName ) SAL_OVERRIDE;
     204             :     virtual void                SetConvertClass( const SvGlobalName & rConvertClass,
     205             :                                                  sal_uLong nOriginalClipFormat,
     206             :                                                  const OUString & rUserTypeName ) SAL_OVERRIDE;
     207             :     virtual SvGlobalName        GetClassName() SAL_OVERRIDE;
     208             :     virtual sal_uLong           GetFormat() SAL_OVERRIDE;
     209             :     virtual OUString            GetUserName() SAL_OVERRIDE;
     210             :     virtual bool                ShouldConvert() SAL_OVERRIDE;
     211             :     virtual void                FillInfoList( SvStorageInfoList* ) const SAL_OVERRIDE;
     212             :     virtual bool                CopyTo( BaseStorage* pDestStg ) const SAL_OVERRIDE;
     213             :     virtual bool                Commit() SAL_OVERRIDE;
     214             :     virtual bool                Revert() SAL_OVERRIDE;
     215             :     virtual BaseStorageStream*  OpenStream( const OUString & rEleName,
     216             :                                             StreamMode = STREAM_STD_READWRITE,
     217             :                                             bool bDirect = true, const OString* pKey=0 ) SAL_OVERRIDE;
     218             :     virtual BaseStorage*        OpenStorage( const OUString & rEleName,
     219             :                                              StreamMode = STREAM_STD_READWRITE,
     220             :                                              bool bDirect = false ) SAL_OVERRIDE;
     221             :     virtual BaseStorage*        OpenUCBStorage( const OUString & rEleName,
     222             :                                                 StreamMode = STREAM_STD_READWRITE,
     223             :                                                 bool bDirect = false ) SAL_OVERRIDE;
     224             :     virtual BaseStorage*        OpenOLEStorage( const OUString & rEleName,
     225             :                                                 StreamMode = STREAM_STD_READWRITE,
     226             :                                                 bool bDirect = false ) SAL_OVERRIDE;
     227             :     virtual bool                IsStream( const OUString& rEleName ) const SAL_OVERRIDE;
     228             :     virtual bool                IsStorage( const OUString& rEleName ) const SAL_OVERRIDE;
     229             :     virtual bool                IsContained( const OUString& rEleName ) const SAL_OVERRIDE;
     230             :     virtual bool                Remove( const OUString & rEleName ) SAL_OVERRIDE;
     231             :     virtual bool                Rename( const OUString & rEleName, const OUString & rNewName ) SAL_OVERRIDE;
     232             :     virtual bool                CopyTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) SAL_OVERRIDE;
     233             :     virtual bool                MoveTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) SAL_OVERRIDE;
     234             :     virtual bool                ValidateFAT() SAL_OVERRIDE;
     235             :     virtual bool                Validate( bool=false ) const SAL_OVERRIDE;
     236             :     virtual bool                ValidateMode( StreamMode ) const SAL_OVERRIDE;
     237             :     bool                        ValidateMode( StreamMode, StgDirEntry* p ) const;
     238             :     virtual const SvStream*     GetSvStream() const SAL_OVERRIDE;
     239             :     virtual bool                Equals( const BaseStorage& rStream ) const SAL_OVERRIDE;
     240             : };
     241             : 
     242             : class UCBStorageStream_Impl;
     243             : class UCBStorageStream : public BaseStorageStream
     244             : {
     245             : friend class UCBStorage;
     246             : 
     247             :     UCBStorageStream_Impl*
     248             :             pImp;
     249             : protected:
     250             :                                 virtual ~UCBStorageStream();
     251             : public:
     252             :                                 TYPEINFO_OVERRIDE();
     253             :                                 UCBStorageStream( const OUString& rName, StreamMode nMode, bool bDirect, const OString* pKey, bool bRepair, ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XProgressHandler > xProgress );
     254             :                                 UCBStorageStream( UCBStorageStream_Impl* );
     255             : 
     256             :     virtual sal_uLong           Read( void * pData, sal_uLong nSize ) SAL_OVERRIDE;
     257             :     virtual sal_uLong           Write( const void* pData, sal_uLong nSize ) SAL_OVERRIDE;
     258             :     virtual sal_uInt64          Seek( sal_uInt64 nPos ) SAL_OVERRIDE;
     259             :     virtual sal_uLong           Tell() SAL_OVERRIDE;
     260             :     virtual void                Flush() SAL_OVERRIDE;
     261             :     virtual bool                SetSize( sal_uLong nNewSize ) SAL_OVERRIDE;
     262             :     virtual sal_uLong           GetSize() const SAL_OVERRIDE;
     263             :     virtual bool                CopyTo( BaseStorageStream * pDestStm ) SAL_OVERRIDE;
     264             :     virtual bool                Commit() SAL_OVERRIDE;
     265             :     virtual bool                Revert() SAL_OVERRIDE;
     266             :     virtual bool                Validate( bool=false ) const SAL_OVERRIDE;
     267             :     virtual bool                ValidateMode( StreamMode ) const SAL_OVERRIDE;
     268             :     const SvStream*             GetSvStream() const SAL_OVERRIDE;
     269             :     virtual bool                Equals( const BaseStorageStream& rStream ) const SAL_OVERRIDE;
     270             :     bool                        SetProperty( const OUString& rName, const ::com::sun::star::uno::Any& rValue );
     271             : 
     272             :     SvStream*                   GetModifySvStream();
     273             : };
     274             : 
     275             : namespace ucbhelper
     276             : {
     277             :     class Content;
     278             : }
     279             : 
     280             : class UCBStorage_Impl;
     281             : struct UCBStorageElement_Impl;
     282             : class SOT_DLLPUBLIC UCBStorage : public BaseStorage
     283             : {
     284             :     UCBStorage_Impl*            pImp;
     285             : 
     286             : protected:
     287             :                                 virtual ~UCBStorage();
     288             : public:
     289             :     static bool                 IsStorageFile( SvStream* );
     290             :     static bool                 IsDiskSpannedFile( SvStream* );
     291             :     static OUString             GetLinkedFile( SvStream& );
     292             :     static OUString             CreateLinkFile( const OUString& rName );
     293             : 
     294             :                                 UCBStorage( const ::ucbhelper::Content& rContent, const OUString& rName, StreamMode nMode, bool bDirect = true, bool bIsRoot = true );
     295             :                                 UCBStorage( const OUString& rName,
     296             :                                             StreamMode nMode,
     297             :                                             bool bDirect = true,
     298             :                                             bool bIsRoot = true );
     299             : 
     300             :                                 UCBStorage( const OUString& rName,
     301             :                                             StreamMode nMode,
     302             :                                             bool bDirect,
     303             :                                             bool bIsRoot,
     304             :                                             bool bIsRepair,
     305             :                                             ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XProgressHandler >
     306             :                                             xProgressHandler );
     307             : 
     308             :                                 UCBStorage( UCBStorage_Impl* );
     309             :                                 UCBStorage( SvStream& rStrm, bool bDirect = true );
     310             : 
     311             :                                 TYPEINFO_OVERRIDE();
     312             :     virtual const OUString&     GetName() const SAL_OVERRIDE;
     313             :     virtual bool                IsRoot() const SAL_OVERRIDE;
     314             :     virtual void                SetClassId( const ClsId& ) SAL_OVERRIDE;
     315             :     virtual const ClsId&        GetClassId() const SAL_OVERRIDE;
     316             :     virtual void                SetDirty() SAL_OVERRIDE;
     317             :     virtual void                SetClass( const SvGlobalName & rClass,
     318             :                                           sal_uLong nOriginalClipFormat,
     319             :                                           const OUString & rUserTypeName ) SAL_OVERRIDE;
     320             :     virtual void                SetConvertClass( const SvGlobalName & rConvertClass,
     321             :                                                  sal_uLong nOriginalClipFormat,
     322             :                                                  const OUString & rUserTypeName ) SAL_OVERRIDE;
     323             :     virtual SvGlobalName        GetClassName() SAL_OVERRIDE;
     324             :     virtual sal_uLong           GetFormat() SAL_OVERRIDE;
     325             :     virtual OUString            GetUserName() SAL_OVERRIDE;
     326             :     virtual bool                ShouldConvert() SAL_OVERRIDE;
     327             :     virtual void                FillInfoList( SvStorageInfoList* ) const SAL_OVERRIDE;
     328             :     virtual bool                CopyTo( BaseStorage* pDestStg ) const SAL_OVERRIDE;
     329             :     virtual bool                Commit() SAL_OVERRIDE;
     330             :     virtual bool                Revert() SAL_OVERRIDE;
     331             :     virtual BaseStorageStream*  OpenStream( const OUString & rEleName,
     332             :                                             StreamMode = STREAM_STD_READWRITE,
     333             :                                             bool bDirect = true, const OString* pKey=0 ) SAL_OVERRIDE;
     334             :     virtual BaseStorage*        OpenStorage( const OUString & rEleName,
     335             :                                              StreamMode = STREAM_STD_READWRITE,
     336             :                                              bool bDirect = false ) SAL_OVERRIDE;
     337             :     virtual BaseStorage*        OpenUCBStorage( const OUString & rEleName,
     338             :                                                 StreamMode = STREAM_STD_READWRITE,
     339             :                                                 bool bDirect = false ) SAL_OVERRIDE;
     340             :     virtual BaseStorage*        OpenOLEStorage( const OUString & rEleName,
     341             :                                                 StreamMode = STREAM_STD_READWRITE,
     342             :                                                 bool bDirect = false ) SAL_OVERRIDE;
     343             :     virtual bool                IsStream( const OUString& rEleName ) const SAL_OVERRIDE;
     344             :     virtual bool                IsStorage( const OUString& rEleName ) const SAL_OVERRIDE;
     345             :     virtual bool                IsContained( const OUString& rEleName ) const SAL_OVERRIDE;
     346             :     virtual bool                Remove( const OUString & rEleName ) SAL_OVERRIDE;
     347             :     virtual bool                Rename( const OUString & rEleName, const OUString & rNewName ) SAL_OVERRIDE;
     348             :     virtual bool                CopyTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) SAL_OVERRIDE;
     349             :     virtual bool                MoveTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) SAL_OVERRIDE;
     350             :     virtual bool                ValidateFAT() SAL_OVERRIDE;
     351             :     virtual bool                Validate( bool=false ) const SAL_OVERRIDE;
     352             :     virtual bool                ValidateMode( StreamMode ) const SAL_OVERRIDE;
     353             :     virtual const SvStream*     GetSvStream() const SAL_OVERRIDE;
     354             :     virtual bool                Equals( const BaseStorage& rStream ) const SAL_OVERRIDE;
     355             :     bool                        GetProperty( const OUString& rEleName, const OUString& rName, ::com::sun::star::uno::Any& rValue );
     356             : 
     357             :     UCBStorageElement_Impl*     FindElement_Impl( const OUString& rName ) const;
     358             :     bool                        CopyStorageElement_Impl( UCBStorageElement_Impl& rElement,
     359             :                                                          BaseStorage* pDest, const OUString& rNew ) const;
     360             :     BaseStorage*                OpenStorage_Impl( const OUString & rEleName,
     361             :                                                   StreamMode, bool bDirect, bool bForceUCBStorage );
     362             : 
     363             : };
     364             : 
     365             : #endif
     366             : 
     367             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10