LCOV - code coverage report
Current view: top level - sot/source/sdstor - stgdir.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 5 5 100.0 %
Date: 2014-11-03 Functions: 5 5 100.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_SOURCE_SDSTOR_STGDIR_HXX
      21             : #define INCLUDED_SOT_SOURCE_SDSTOR_STGDIR_HXX
      22             : 
      23             : #include "stgavl.hxx"
      24             : #include "stgelem.hxx"
      25             : #include "stgstrms.hxx"
      26             : 
      27             : class StgIo;
      28             : class StgEntry;
      29             : class StgDirEntry;
      30             : class StgDirStrm;
      31             : 
      32             : class BaseStorageStream;
      33             : class StgDirEntry : public StgAvlNode
      34             : {
      35             :     friend class StgIterator;
      36             :     friend class StgDirStrm;
      37             :     StgEntry     aSave;                     // original dir entry
      38             :     StgDirEntry*  pUp;                      // parent directory
      39             :     StgDirEntry*  pDown;                    // child directory for storages
      40             :     StgDirEntry** ppRoot;                   // root of TOC tree
      41             :     StgStrm*     pStgStrm;                  // storage stream
      42             :     StgTmpStrm*  pTmpStrm;                  // temporary stream
      43             :     StgTmpStrm*  pCurStrm;                  // temp stream after commit
      44             :     sal_Int32    nEntry;                    // entry # in TOC stream (temp)
      45             :     sal_Int32    nPos;                      // current position
      46             :     bool         bDirty;                    // dirty directory entry
      47             :     bool         bCreated;                  // newly created entry
      48             :     bool         bRemoved;                  // removed per Invalidate()
      49             :     bool         bRenamed;                  // renamed
      50             :     void         InitMembers();             // ctor helper
      51             :     virtual short Compare( const StgAvlNode* ) const SAL_OVERRIDE;
      52             :     bool         StoreStream( StgIo& );     // store the stream
      53             :     bool         StoreStreams( StgIo& );    // store all streams
      54             :     void         RevertAll();               // revert the whole tree
      55             :     bool         Strm2Tmp();                // copy stgstream to temp file
      56             :     bool         Tmp2Strm();                // copy temp file to stgstream
      57             : public:
      58             :     StgEntry     aEntry;                    // entry data
      59             :     sal_Int32        nRefCnt;                   // reference count
      60             :     StreamMode   nMode;                     // open mode
      61             :     bool         bTemp;                     // true: delete on dir flush
      62             :     bool         bDirect;                   // true: direct mode
      63             :     bool         bZombie;                   // true: Removed From StgIo
      64             :     bool         bInvalid;                  // true: invalid entry
      65             :     StgDirEntry( const void* pBuffer, sal_uInt32 nBufferLen, bool * pbOk );
      66             :     StgDirEntry( const StgEntry& );
      67             :     virtual ~StgDirEntry();
      68             : 
      69             :     void Invalidate( bool=false );          // invalidate all open entries
      70             :     void Enum( sal_Int32& );                    // enumerate entries for iteration
      71             :     void DelTemp( bool );                   // delete temporary entries
      72             :     bool Store( StgDirStrm& );              // save entry into dir strm
      73             :     bool IsContained( StgDirEntry* );       // check if subentry
      74             : 
      75       55881 :     void SetDirty()  { bDirty = true; }
      76             :     bool IsDirty();
      77             :     void ClearDirty();
      78             : 
      79             :     bool Commit();
      80             :     bool Revert();
      81             : 
      82             :     void  OpenStream( StgIo&, bool=false );     // set up an approbiate stream
      83             :     void  Close();
      84             :     sal_Int32 GetSize();
      85             :     bool  SetSize( sal_Int32 );
      86             :     sal_Int32 Seek( sal_Int32 );
      87             :     sal_Int32 Tell() { return nPos; }
      88             :     sal_Int32 Read( void*, sal_Int32 );
      89             :     sal_Int32 Write( const void*, sal_Int32 );
      90             :     void  Copy( BaseStorageStream& );
      91             : };
      92             : 
      93             : class StgDirStrm : public StgDataStrm
      94             : {
      95             :     friend class StgIterator;
      96             :     StgDirEntry* pRoot;                         // root of dir tree
      97             :     short        nEntries;                      // entries per page
      98             :     void         SetupEntry( sal_Int32, StgDirEntry* );
      99             : public:
     100             :     StgDirStrm( StgIo& );
     101             :     virtual ~StgDirStrm();
     102             :     virtual bool SetSize( sal_Int32 ) SAL_OVERRIDE;              // change the size
     103             :     bool         Store();
     104             :     void*        GetEntry( sal_Int32 n, bool=false );// get an entry
     105        2490 :     StgDirEntry* GetRoot() { return pRoot; }
     106             :     StgDirEntry* Find( StgDirEntry&, const OUString& );
     107             :     StgDirEntry* Create( StgDirEntry&, const OUString&, StgEntryType );
     108             :     bool         Remove( StgDirEntry&, const OUString& );
     109             :     bool         Rename( StgDirEntry&, const OUString&, const OUString& );
     110             :     bool         Move( StgDirEntry&, StgDirEntry&, const OUString& );
     111             : };
     112             : 
     113             : class StgIterator : public StgAvlIterator
     114             : {
     115             : public:
     116        5562 :     StgIterator( StgDirEntry& rStg ) : StgAvlIterator( rStg.pDown ) {}
     117        5562 :     StgDirEntry* First() { return static_cast<StgDirEntry*>( StgAvlIterator::First() ); }
     118       36304 :     StgDirEntry* Next()  { return static_cast<StgDirEntry*>( StgAvlIterator::Next() );  }
     119             : };
     120             : 
     121             : #endif
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10