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 void Init(); // initialize the header 65 sal_Bool Load( StgIo& ); 66 sal_Bool Load( SvStream& ); 67 sal_Bool Store( StgIo& ); 68 sal_Bool Check(); // check the signature and version 69 short GetByteOrder() const { return nByteOrder; } 70 sal_Int32 GetTOCStart() const { return nTOCstrm; } 71 void SetTOCStart( sal_Int32 n ); 72 sal_Int32 GetDataFATStart() const { return nDataFAT; } 73 void SetDataFATStart( sal_Int32 n ); 74 sal_Int32 GetDataFATSize() const { return nDataFATSize; } 75 void SetDataFATSize( sal_Int32 n ); 76 sal_Int32 GetThreshold() const { return nThreshold; } 77 short GetPageSize() const { return nPageSize; } 78 short GetDataPageSize() const { return nDataPageSize; } 79 sal_Int32 GetFATSize() const { return nFATSize; } 80 void SetFATSize( sal_Int32 n ); 81 sal_Int32 GetFATChain() const { return nMasterChain; } 82 void SetFATChain( sal_Int32 n ); 83 sal_Int32 GetMasters() const { return nMaster; } 84 void SetMasters( sal_Int32 n ); 85 short GetFAT1Size() const { return 109; } 86 const ClsId& GetClassId() const { return aClsId; } 87 void SetClassId( const ClsId& ); 88 sal_Int32 GetFATPage( short ) const; 89 void SetFATPage( short, sal_Int32 ); 90 }; 91 92 enum StgEntryType { // dir entry types: 93 STG_EMPTY = 0, 94 STG_STORAGE = 1, 95 STG_STREAM = 2, 96 STG_LOCKBYTES = 3, 97 STG_PROPERTY = 4, 98 STG_ROOT = 5 99 }; 100 101 enum StgEntryRef { // reference blocks: 102 STG_LEFT = 0, // left 103 STG_RIGHT = 1, // right 104 STG_CHILD = 2, // child 105 STG_DATA = 3 // data start 106 }; 107 108 enum StgEntryTime { // time codes: 109 STG_MODIFIED = 0, // last modification 110 STG_ACCESSED = 1 // last access 111 }; 112 113 class StgStream; 114 115 #define STGENTRY_SIZE 128 116 117 class StgEntry { // directory enty 118 sal_uInt16 nName[ 32 ]; // 00 name as WCHAR 119 sal_Int16 nNameLen; // 40 size of name in bytes including 00H 120 sal_uInt8 cType; // 42 entry type 121 sal_uInt8 cFlags; // 43 0 or 1 (tree balance?) 122 sal_Int32 nLeft; // 44 left node entry 123 sal_Int32 nRight; // 48 right node entry 124 sal_Int32 nChild; // 4C 1st child entry if storage 125 ClsId aClsId; // 50 class ID (optional) 126 sal_Int32 nFlags; // 60 state flags(?) 127 sal_Int32 nMtime[ 2 ]; // 64 modification time 128 sal_Int32 nAtime[ 2 ]; // 6C creation and access time 129 sal_Int32 nPage1; // 74 starting block (either direct or translated) 130 sal_Int32 nSize; // 78 file size 131 sal_Int32 nUnknown; // 7C unknown 132 String aName; // Name as Compare String (ascii, upper) 133 public: 134 sal_Bool Init(); // initialize the data 135 sal_Bool SetName( const String& ); // store a name (ASCII, up to 32 chars) 136 void GetName( String& rName ) const; 137 // fill in the name 138 short Compare( const StgEntry& ) const; // compare two entries 139 sal_Bool Load( const void* ); 140 void Store( void* ); 141 StgEntryType GetType() const { return (StgEntryType) cType; } 142 sal_Int32 GetStartPage() const { return nPage1; } 143 void SetType( StgEntryType t ) { cType = (sal_uInt8) t; } 144 sal_uInt8 GetFlags() const { return cFlags; } 145 void SetFlags( sal_uInt8 c ) { cFlags = c; } 146 sal_Int32 GetSize() const { return nSize; } 147 void SetSize( sal_Int32 n ) { nSize = n; } 148 const ClsId& GetClassId() const { return aClsId; } 149 void SetClassId( const ClsId& ); 150 sal_Int32 GetLeaf( StgEntryRef ) const; 151 void SetLeaf( StgEntryRef, sal_Int32 ); 152 const sal_Int32* GetTime( StgEntryTime ) const; 153 void SetTime( StgEntryTime, sal_Int32* ); 154 }; 155 156 157 #define STG_FREE -1L // page is free 158 #define STG_EOF -2L // page is last page in chain 159 #define STG_FAT -3L // page is FAT page 160 #define STG_MASTER -4L // page is master FAT page 161 162 #endif 163