1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // This file reflects the structure of MS file elements. 25 // It is very sensitive to alignment! 26 27 #ifndef _STGELEM_HXX 28 #define _STGELEM_HXX 29 30 #ifndef _TOOLS_SOLAR_H 31 #include <tools/solar.h> 32 #endif 33 34 #include <sot/stg.hxx> 35 36 class StgIo; 37 class SvStream; 38 class String; 39 40 SvStream& operator>>( SvStream&, ClsId& ); 41 SvStream& operator<<( SvStream&, const ClsId& ); 42 43 class StgHeader 44 { 45 sal_uInt8 cSignature[ 8 ]; // 00 signature (see below) 46 ClsId aClsId; // 08 Class ID 47 sal_Int32 nVersion; // 18 version number 48 sal_uInt16 nByteOrder; // 1C Unicode byte order indicator 49 sal_Int16 nPageSize; // 1E 1 << nPageSize = block size 50 sal_Int16 nDataPageSize; // 20 1 << this size == data block size 51 sal_uInt8 bDirty; // 22 internal dirty flag 52 sal_uInt8 cReserved[ 9 ]; // 23 53 sal_Int32 nFATSize; // 2C total number of FAT pages 54 sal_Int32 nTOCstrm; // 30 starting page for the TOC stream 55 sal_Int32 nReserved; // 34 56 sal_Int32 nThreshold; // 38 minimum file size for big data 57 sal_Int32 nDataFAT; // 3C page # of 1st data FAT block 58 sal_Int32 nDataFATSize; // 40 # of data fat blocks 59 sal_Int32 nMasterChain; // 44 chain to the next master block 60 sal_Int32 nMaster; // 48 # of additional master blocks 61 sal_Int32 nMasterFAT[ 109 ]; // 4C first 109 master FAT pages 62 public: 63 StgHeader(); 64 65 void Init(); // initialize the header 66 sal_Bool Load( StgIo& ); 67 sal_Bool Load( SvStream& ); 68 sal_Bool Store( StgIo& ); 69 sal_Bool Check(); // check the signature and version 70 short GetByteOrder() const { return nByteOrder; } 71 sal_Int32 GetTOCStart() const { return nTOCstrm; } 72 void SetTOCStart( sal_Int32 n ); 73 sal_Int32 GetDataFATStart() const { return nDataFAT; } 74 void SetDataFATStart( sal_Int32 n ); 75 sal_Int32 GetDataFATSize() const { return nDataFATSize; } 76 void SetDataFATSize( sal_Int32 n ); 77 sal_Int32 GetThreshold() const { return nThreshold; } 78 short GetPageSize() const { return nPageSize; } 79 short GetDataPageSize() const { return nDataPageSize; } 80 sal_Int32 GetFATSize() const { return nFATSize; } 81 void SetFATSize( sal_Int32 n ); 82 sal_Int32 GetFATChain() const { return nMasterChain; } 83 void SetFATChain( sal_Int32 n ); 84 sal_Int32 GetMasters() const { return nMaster; } 85 void SetMasters( sal_Int32 n ); 86 short GetFAT1Size() const { return 109; } 87 const ClsId& GetClassId() const { return aClsId; } 88 void SetClassId( const ClsId& ); 89 sal_Int32 GetFATPage( short ) const; 90 void SetFATPage( short, sal_Int32 ); 91 }; 92 93 enum StgEntryType { // dir entry types: 94 STG_EMPTY = 0, 95 STG_STORAGE = 1, 96 STG_STREAM = 2, 97 STG_LOCKBYTES = 3, 98 STG_PROPERTY = 4, 99 STG_ROOT = 5 100 }; 101 102 enum StgEntryRef { // reference blocks: 103 STG_LEFT = 0, // left 104 STG_RIGHT = 1, // right 105 STG_CHILD = 2, // child 106 STG_DATA = 3 // data start 107 }; 108 109 enum StgEntryTime { // time codes: 110 STG_MODIFIED = 0, // last modification 111 STG_ACCESSED = 1 // last access 112 }; 113 114 class StgStream; 115 116 #define STGENTRY_SIZE 128 117 118 class StgEntry { // directory enty 119 sal_uInt16 nName[ 32 ]; // 00 name as WCHAR 120 sal_Int16 nNameLen; // 40 size of name in bytes including 00H 121 sal_uInt8 cType; // 42 entry type 122 sal_uInt8 cFlags; // 43 0 or 1 (tree balance?) 123 sal_Int32 nLeft; // 44 left node entry 124 sal_Int32 nRight; // 48 right node entry 125 sal_Int32 nChild; // 4C 1st child entry if storage 126 ClsId aClsId; // 50 class ID (optional) 127 sal_Int32 nFlags; // 60 state flags(?) 128 sal_Int32 nMtime[ 2 ]; // 64 modification time 129 sal_Int32 nAtime[ 2 ]; // 6C creation and access time 130 sal_Int32 nPage1; // 74 starting block (either direct or translated) 131 sal_Int32 nSize; // 78 file size 132 sal_Int32 nUnknown; // 7C unknown 133 String aName; // Name as Compare String (ascii, upper) 134 public: 135 sal_Bool Init(); // initialize the data 136 sal_Bool SetName( const String& ); // store a name (ASCII, up to 32 chars) 137 void GetName( String& rName ) const; 138 // fill in the name 139 short Compare( const StgEntry& ) const; // compare two entries 140 sal_Bool Load( const void* pBuffer, sal_uInt32 nBufSize ); 141 void Store( void* ); 142 StgEntryType GetType() const { return (StgEntryType) cType; } 143 sal_Int32 GetStartPage() const { return nPage1; } 144 void SetType( StgEntryType t ) { cType = (sal_uInt8) t; } 145 sal_uInt8 GetFlags() const { return cFlags; } 146 void SetFlags( sal_uInt8 c ) { cFlags = c; } 147 sal_Int32 GetSize() const { return nSize; } 148 void SetSize( sal_Int32 n ) { nSize = n; } 149 const ClsId& GetClassId() const { return aClsId; } 150 void SetClassId( const ClsId& ); 151 sal_Int32 GetLeaf( StgEntryRef ) const; 152 void SetLeaf( StgEntryRef, sal_Int32 ); 153 const sal_Int32* GetTime( StgEntryTime ) const; 154 void SetTime( StgEntryTime, sal_Int32* ); 155 }; 156 157 158 #define STG_FREE -1L // page is free 159 #define STG_EOF -2L // page is last page in chain 160 #define STG_FAT -3L // page is FAT page 161 #define STG_MASTER -4L // page is master FAT page 162 163 #endif 164