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

Generated by: LCOV version 1.10