LCOV - code coverage report
Current view: top level - libreoffice/sot/source/sdstor - stgelem.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 17 88.2 %
Date: 2012-12-27 Functions: 18 20 90.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             : // This file reflects the structure of MS file elements.
      21             : // It is very sensitive to alignment!
      22             : 
      23             : #ifndef _STGELEM_HXX
      24             : #define _STGELEM_HXX
      25             : 
      26             : #include <tools/solar.h>
      27             : 
      28             : #include <sot/stg.hxx>
      29             : 
      30             : class StgIo;
      31             : class SvStream;
      32             : class String;
      33             : 
      34             : SvStream& operator>>( SvStream&, ClsId& );
      35             : SvStream& operator<<( SvStream&, const ClsId& );
      36             : 
      37             : class StgHeader
      38             : {
      39             :     sal_uInt8   cSignature[ 8 ];            // 00 signature (see below)
      40             :     ClsId   aClsId;                     // 08 Class ID
      41             :     sal_Int32   nVersion;                   // 18 version number
      42             :     sal_uInt16  nByteOrder;                 // 1C Unicode byte order indicator
      43             :     sal_Int16   nPageSize;                  // 1E 1 << nPageSize = block size
      44             :     sal_Int16   nDataPageSize;              // 20 1 << this size == data block size
      45             :     sal_uInt8   bDirty;                     // 22 internal dirty flag
      46             :     sal_uInt8   cReserved[ 9 ];             // 23
      47             :     sal_Int32   nFATSize;                   // 2C total number of FAT pages
      48             :     sal_Int32   nTOCstrm;                   // 30 starting page for the TOC stream
      49             :     sal_Int32   nReserved;                  // 34
      50             :     sal_Int32   nThreshold;                 // 38 minimum file size for big data
      51             :     sal_Int32   nDataFAT;                   // 3C page # of 1st data FAT block
      52             :     sal_Int32   nDataFATSize;               // 40 # of data fat blocks
      53             :     sal_Int32   nMasterChain;               // 44 chain to the next master block
      54             :     sal_Int32   nMaster;                    // 48 # of additional master blocks
      55             :     sal_Int32   nMasterFAT[ 109 ];          // 4C first 109 master FAT pages
      56             : public:
      57             :     StgHeader();
      58             : 
      59             :     void  Init();                       // initialize the header
      60             :     sal_Bool  Load( StgIo& );
      61             :     sal_Bool  Load( SvStream& );
      62             :     sal_Bool  Store( StgIo& );
      63             :     sal_Bool  Check();                      // check the signature and version
      64             :     short GetByteOrder() const          { return nByteOrder;    }
      65         102 :     sal_Int32 GetTOCStart() const           { return nTOCstrm;      }
      66             :     void  SetTOCStart( sal_Int32 n );
      67          99 :     sal_Int32 GetDataFATStart() const       { return nDataFAT;      }
      68             :     void  SetDataFATStart( sal_Int32 n );
      69           0 :     sal_Int32 GetDataFATSize() const        { return nDataFATSize;  }
      70             :     void  SetDataFATSize( sal_Int32 n );
      71        1149 :     sal_Int32 GetThreshold() const          { return nThreshold;    }
      72         201 :     short GetPageSize() const           { return nPageSize;     }
      73         983 :     short GetDataPageSize() const       { return nDataPageSize; }
      74         102 :     sal_Int32 GetFATSize() const            { return nFATSize;      }
      75             :     void  SetFATSize( sal_Int32 n );
      76          20 :     sal_Int32 GetFATChain() const           { return nMasterChain;  }
      77             :     void  SetFATChain( sal_Int32 n );
      78          20 :     sal_Int32 GetMasters() const            { return nMaster;       }
      79             :     void  SetMasters( sal_Int32 n );
      80       28047 :     short GetFAT1Size() const           { return 109;           }
      81             :     const ClsId& GetClassId() const     { return aClsId;        }
      82             :     sal_Int32 GetFATPage( short ) const;
      83             :     void  SetFATPage( short, sal_Int32 );
      84             : };
      85             : 
      86             : enum StgEntryType {                     // dir entry types:
      87             :     STG_EMPTY     = 0,
      88             :     STG_STORAGE   = 1,
      89             :     STG_STREAM    = 2,
      90             :     STG_LOCKBYTES = 3,
      91             :     STG_PROPERTY  = 4,
      92             :     STG_ROOT      = 5
      93             : };
      94             : 
      95             : enum StgEntryRef {                      // reference blocks:
      96             :     STG_LEFT      = 0,                  // left
      97             :     STG_RIGHT     = 1,                  // right
      98             :     STG_CHILD     = 2,                  // child
      99             :     STG_DATA      = 3                   // data start
     100             : };
     101             : 
     102             : enum StgEntryTime {                     // time codes:
     103             :     STG_MODIFIED  = 0,                  // last modification
     104             :     STG_ACCESSED  = 1                   // last access
     105             : };
     106             : 
     107             : #define STGENTRY_SIZE 128
     108             : 
     109             : //StructuredStorageDirectoryEntry
     110       21819 : class StgEntry {                        // directory enty
     111             :     sal_uInt16  nName[ 32 ];                // 00 name as WCHAR
     112             :     sal_uInt16  nNameLen;                   // 40 size of name in bytes including 00H
     113             :     sal_uInt8   cType;                      // 42 entry type
     114             :     sal_uInt8   cFlags;                     // 43 0 or 1 (tree balance?)
     115             :     sal_Int32   nLeft;                      // 44 left node entry
     116             :     sal_Int32   nRight;                     // 48 right node entry
     117             :     sal_Int32   nChild;                     // 4C 1st child entry if storage
     118             :     ClsId   aClsId;                     // 50 class ID (optional)
     119             :     sal_Int32   nFlags;                     // 60 state flags(?)
     120             :     sal_Int32   nMtime[ 2 ];                // 64 modification time
     121             :     sal_Int32   nAtime[ 2 ];                // 6C creation and access time
     122             :     sal_Int32   nPage1;                     // 74 starting block (either direct or translated)
     123             :     sal_Int32   nSize;                      // 78 file size
     124             :     sal_Int32   nUnknown;                   // 7C unknown
     125             :     String  aName;                      // Name as Compare String (ascii, upper)
     126             : public:
     127             :     sal_Bool    Init();                     // initialize the data
     128             :     sal_Bool    SetName( const String& );   // store a name (ASCII, up to 32 chars)
     129             :     void    GetName( String& rName ) const;
     130             :                                         // fill in the name
     131             :     short   Compare( const StgEntry& ) const;   // compare two entries
     132             :     sal_Bool    Load( const void* pBuffer, sal_uInt32 nBufSize );
     133             :     void    Store( void* );
     134        8350 :     StgEntryType GetType() const        { return (StgEntryType) cType;  }
     135           0 :     sal_Int32   GetStartPage() const        { return nPage1; }
     136         344 :     void    SetType( StgEntryType t )   { cType = (sal_uInt8) t;                }
     137             :     sal_uInt8   GetFlags() const            { return cFlags;                }
     138             :     void    SetFlags( sal_uInt8 c )         { cFlags = c;                   }
     139     1709883 :     sal_Int32   GetSize() const             { return nSize;                 }
     140        3800 :     void    SetSize( sal_Int32 n )          { nSize = n;                    }
     141          18 :     const   ClsId& GetClassId() const   { return aClsId;                }
     142             :     void    SetClassId( const ClsId& );
     143             :     sal_Int32   GetLeaf( StgEntryRef ) const;
     144             :     void    SetLeaf( StgEntryRef, sal_Int32 );
     145             : };
     146             : 
     147             : 
     148             : #define STG_FREE    -1L                 // page is free
     149             : #define STG_EOF     -2L                 // page is last page in chain
     150             : #define STG_FAT     -3L                 // page is FAT page
     151             : #define STG_MASTER  -4L                 // page is master FAT page
     152             : 
     153             : #endif
     154             : 
     155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10