LCOV - code coverage report
Current view: top level - include/sot - storage.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 9 16 56.2 %
Date: 2014-11-03 Functions: 5 8 62.5 %
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_STORAGE_HXX
      21             : #define INCLUDED_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 ) SAL_OVERRIDE;
      58             :     virtual sal_uLong       PutData( const void* pData, sal_uLong nSize ) SAL_OVERRIDE;
      59             :     virtual sal_uInt64      SeekPos(sal_uInt64 nPos) SAL_OVERRIDE;
      60             :     virtual void        FlushData() SAL_OVERRIDE;
      61             :                         virtual ~SotStorageStream();
      62             : public:
      63             :                         SotStorageStream( const OUString &,
      64             :                                           StreamMode = STREAM_STD_READWRITE,
      65             :                                           StorageMode = 0 );
      66             :                         SotStorageStream( BaseStorageStream *pStm );
      67             :                         SotStorageStream();
      68             : 
      69             : private:
      70           0 :     static SotFactory **       GetFactoryAdress()
      71           0 :                               { return &(SOTDATA()->pSotStorageStreamFactory); }
      72             : public:
      73             :     static void *             CreateInstance( SotObject ** = NULL );
      74             :     static SotFactory *        ClassFactory();
      75             :     virtual const SotFactory * GetSvFactory() const SAL_OVERRIDE;
      76             :     virtual void *            Cast( const SotFactory * ) SAL_OVERRIDE;
      77             : 
      78             :     virtual void        ResetError() SAL_OVERRIDE;
      79             : 
      80             :     virtual void        SetSize( sal_uInt64 nNewSize ) SAL_OVERRIDE;
      81             :     sal_uInt32              GetSize() const;
      82             :     bool                CopyTo( SotStorageStream * pDestStm );
      83             :     virtual bool        Commit();
      84             :     virtual bool        Revert();
      85             :     bool                SetProperty( const OUString& rName, const ::com::sun::star::uno::Any& rValue );
      86             :     virtual sal_uInt64 remainingSize() SAL_OVERRIDE;
      87             : };
      88             : 
      89             : #ifndef SOT_DECL_SOTSTORAGESTREAM_DEFINED
      90             : #define SOT_DECL_SOTSTORAGESTREAM_DEFINED
      91             : typedef tools::SvRef<SotStorageStream> SotStorageStreamRef;
      92             : #endif
      93             : 
      94             : namespace ucbhelper
      95             : {
      96             :     class Content;
      97             : }
      98             : 
      99             : class  BaseStorage;
     100             : class  UNOStorageHolder;
     101             : class SOT_DLLPUBLIC SotStorage : virtual public SotObject
     102             : {
     103             : friend class SotStorageStream;
     104             : friend class SvStorage;
     105             : 
     106             :     BaseStorage *   m_pOwnStg;   // Zielstorage
     107             :     SvStream *      m_pStorStm;  // nur fuer SDSTORAGES
     108             :     sal_uLong       m_nError;
     109             :     OUString        m_aName;     // Name des Storage
     110             :     bool            m_bIsRoot;   // z.B.: File-Storage
     111             :     bool            m_bDelStm;
     112             :     OString         m_aKey;      // aKey.Len != 0  -> Verschluesselung
     113             :     long            m_nVersion;
     114             : 
     115             : protected:
     116             :                         virtual ~SotStorage();
     117             :    void                 CreateStorage( bool bUCBStorage, StreamMode, StorageMode );
     118             : public:
     119             :                         SotStorage( const OUString &,
     120             :                                     StreamMode = STREAM_STD_READWRITE,
     121             :                                     StorageMode = 0 );
     122             :                         SotStorage( bool bUCBStorage, const OUString &,
     123             :                                     StreamMode = STREAM_STD_READWRITE,
     124             :                                     StorageMode = 0 );
     125             :                         SotStorage( BaseStorage * );
     126             :                         SotStorage( SvStream & rStm );
     127             :                         SotStorage( bool bUCBStorage, SvStream & rStm );
     128             :                         SotStorage( SvStream * pStm, bool bDelete );
     129             :                         SotStorage();
     130             : 
     131             : private:
     132           0 :     static SotFactory **       GetFactoryAdress()
     133           0 :                               { return &(SOTDATA()->pSotStorageFactory); }
     134             : public:
     135             :     static void *             CreateInstance( SotObject ** = NULL );
     136             :     static SotFactory *        ClassFactory();
     137             :     virtual const SotFactory * GetSvFactory() const SAL_OVERRIDE;
     138             :     virtual void *            Cast( const SotFactory * ) SAL_OVERRIDE;
     139             : 
     140             :     SvMemoryStream *    CreateMemoryStream();
     141             : 
     142             :     static bool         IsStorageFile( const OUString & rFileName );
     143             :     static bool         IsStorageFile( SvStream* pStream );
     144             : 
     145             :     virtual const OUString& GetName() const;
     146             : 
     147             :     virtual bool        Validate();
     148             : 
     149          20 :     const OString&      GetKey() const { return m_aKey;}
     150             : 
     151           0 :     void                SetVersion( long nVers )
     152             :                         {
     153           0 :                             m_nVersion = nVers;
     154           0 :                         }
     155          20 :     long                GetVersion() const
     156             :                         {
     157          20 :                             return m_nVersion;
     158             :                         }
     159             : 
     160             :     sal_uLong               GetErrorCode() const { return m_nError; }
     161        1380 :     sal_uLong               GetError() const { return ERRCODE_TOERROR(m_nError); }
     162        7266 :     void                SetError( sal_uLong nErrorCode )
     163             :                         {
     164        7266 :                             if( m_nError == SVSTREAM_OK )
     165        7238 :                                 m_nError = nErrorCode;
     166        7266 :                         }
     167             :     virtual void        ResetError();
     168             : 
     169             :     bool                IsRoot() const              { return m_bIsRoot; }
     170        5432 :     void                SignAsRoot( bool b = true ) { m_bIsRoot = b; }
     171             :     void                SetDeleteStream( bool bDelete ) { m_bDelStm = bDelete; }
     172             : 
     173             :                         // eigener Datenbereich
     174             :     virtual void        SetClass( const SvGlobalName & rClass,
     175             :                                   sal_uLong bOriginalClipFormat,
     176             :                                   const OUString & rUserTypeName );
     177             :     virtual void        SetConvertClass( const SvGlobalName & rConvertClass,
     178             :                                          sal_uLong bOriginalClipFormat,
     179             :                                          const OUString & rUserTypeName );
     180             :     virtual SvGlobalName GetClassName();// Typ der Daten im Storage
     181             :     virtual sal_uLong   GetFormat();
     182             :     virtual OUString    GetUserName();
     183             :     virtual bool        ShouldConvert();
     184             : 
     185             :                         // Liste aller Elemente
     186             :     virtual void        FillInfoList( SvStorageInfoList * ) const;
     187             :     virtual bool        CopyTo( SotStorage * pDestStg );
     188             :     virtual bool        Commit();
     189             :     virtual bool        Revert();
     190             : 
     191             :                         /* Element Methoden     */
     192             :                         // Stream mit Verbindung zu Storage erzeugen,
     193             :                         // in etwa eine Parent-Child Beziehung
     194             :     SotStorageStream *  OpenSotStream( const OUString & rEleName,
     195             :                                        StreamMode = STREAM_STD_READWRITE,
     196             :                                        StorageMode = 0 );
     197             :     SotStorage *        OpenSotStorage( const OUString & rEleName,
     198             :                                         StreamMode = STREAM_STD_READWRITE,
     199             :                                         bool transacted = true );
     200             :                         // Abfrage auf Storage oder Stream
     201             :     virtual bool        IsStream( const OUString & rEleName ) const;
     202             :     virtual bool        IsStorage( const OUString & rEleName ) const;
     203             :     virtual bool        IsContained( const OUString & rEleName ) const;
     204             :                         // Element loeschen
     205             :     virtual bool        Remove( const OUString & rEleName );
     206             :                         // Elementnamen aendern
     207             :     virtual bool        Rename( const OUString & rEleName,
     208             :                                 const OUString & rNewName );
     209             :     virtual bool        CopyTo( const OUString & rEleName, SotStorage * pDest,
     210             :                                 const OUString & rNewName );
     211             :     virtual bool        MoveTo( const OUString & rEleName, SotStorage * pDest,
     212             :                                 const OUString & rNewName );
     213             : 
     214             :     bool                IsOLEStorage() const;
     215             :     static bool         IsOLEStorage( const OUString & rFileName );
     216             :     static bool         IsOLEStorage( SvStream* pStream );
     217             : 
     218             :     static SotStorage*  OpenOLEStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage,
     219             :                                         const OUString& rEleName, StreamMode = STREAM_STD_READWRITE );
     220             :     static sal_Int32    GetFormatID( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage );
     221             :     static sal_Int32    GetVersion( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage );
     222             : };
     223             : 
     224             : #ifndef SOT_DECL_SOTSTORAGE_DEFINED
     225             : #define SOT_DECL_SOTSTORAGE_DEFINED
     226             : typedef tools::SvRef<SotStorage> SotStorageRef;
     227             : #endif
     228             : 
     229             : #define SvStorage SotStorage
     230             : #define SvStorageRef SotStorageRef
     231             : #define SvStorageStream SotStorageStream
     232             : #define SvStorageStreamRef SotStorageStreamRef
     233             : 
     234             : #endif // _SVSTOR_HXX
     235             : 
     236             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10