merge the formfield patch from ooo-build
[ooovba.git] / sot / source / sdstor / stgelem.hxx
blob6784b6494d7aefd20bea4e4f02ffdd7a04f5b4a0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: stgelem.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // This file reflects the structure of MS file elements.
32 // It is very sensitive to alignment!
34 #ifndef _STGELEM_HXX
35 #define _STGELEM_HXX
37 #ifndef _TOOLS_SOLAR_H
38 #include <tools/solar.h>
39 #endif
41 #include <stg.hxx>
43 class StgIo;
44 class SvStream;
45 class String;
47 SvStream& operator>>( SvStream&, ClsId& );
48 SvStream& operator<<( SvStream&, const ClsId& );
50 class StgHeader
52 BYTE cSignature[ 8 ]; // 00 signature (see below)
53 ClsId aClsId; // 08 Class ID
54 INT32 nVersion; // 18 version number
55 UINT16 nByteOrder; // 1C Unicode byte order indicator
56 INT16 nPageSize; // 1E 1 << nPageSize = block size
57 INT16 nDataPageSize; // 20 1 << this size == data block size
58 BYTE bDirty; // 22 internal dirty flag
59 BYTE cReserved[ 9 ]; // 23
60 INT32 nFATSize; // 2C total number of FAT pages
61 INT32 nTOCstrm; // 30 starting page for the TOC stream
62 INT32 nReserved; // 34
63 INT32 nThreshold; // 38 minimum file size for big data
64 INT32 nDataFAT; // 3C page # of 1st data FAT block
65 INT32 nDataFATSize; // 40 # of data fat blocks
66 INT32 nMasterChain; // 44 chain to the next master block
67 INT32 nMaster; // 48 # of additional master blocks
68 INT32 nMasterFAT[ 109 ]; // 4C first 109 master FAT pages
69 public:
70 StgHeader();
71 void Init(); // initialize the header
72 BOOL Load( StgIo& );
73 BOOL Load( SvStream& );
74 BOOL Store( StgIo& );
75 BOOL Check(); // check the signature and version
76 short GetByteOrder() const { return nByteOrder; }
77 INT32 GetTOCStart() const { return nTOCstrm; }
78 void SetTOCStart( INT32 n );
79 INT32 GetDataFATStart() const { return nDataFAT; }
80 void SetDataFATStart( INT32 n );
81 INT32 GetDataFATSize() const { return nDataFATSize; }
82 void SetDataFATSize( INT32 n );
83 INT32 GetThreshold() const { return nThreshold; }
84 short GetPageSize() const { return nPageSize; }
85 short GetDataPageSize() const { return nDataPageSize; }
86 INT32 GetFATSize() const { return nFATSize; }
87 void SetFATSize( INT32 n );
88 INT32 GetFATChain() const { return nMasterChain; }
89 void SetFATChain( INT32 n );
90 INT32 GetMasters() const { return nMaster; }
91 void SetMasters( INT32 n );
92 short GetFAT1Size() const { return 109; }
93 const ClsId& GetClassId() const { return aClsId; }
94 void SetClassId( const ClsId& );
95 INT32 GetFATPage( short ) const;
96 void SetFATPage( short, INT32 );
99 enum StgEntryType { // dir entry types:
100 STG_EMPTY = 0,
101 STG_STORAGE = 1,
102 STG_STREAM = 2,
103 STG_LOCKBYTES = 3,
104 STG_PROPERTY = 4,
105 STG_ROOT = 5
108 enum StgEntryRef { // reference blocks:
109 STG_LEFT = 0, // left
110 STG_RIGHT = 1, // right
111 STG_CHILD = 2, // child
112 STG_DATA = 3 // data start
115 enum StgEntryTime { // time codes:
116 STG_MODIFIED = 0, // last modification
117 STG_ACCESSED = 1 // last access
120 class StgStream;
122 #define STGENTRY_SIZE 128
124 class StgEntry { // directory enty
125 UINT16 nName[ 32 ]; // 00 name as WCHAR
126 INT16 nNameLen; // 40 size of name in bytes including 00H
127 BYTE cType; // 42 entry type
128 BYTE cFlags; // 43 0 or 1 (tree balance?)
129 INT32 nLeft; // 44 left node entry
130 INT32 nRight; // 48 right node entry
131 INT32 nChild; // 4C 1st child entry if storage
132 ClsId aClsId; // 50 class ID (optional)
133 INT32 nFlags; // 60 state flags(?)
134 INT32 nMtime[ 2 ]; // 64 modification time
135 INT32 nAtime[ 2 ]; // 6C creation and access time
136 INT32 nPage1; // 74 starting block (either direct or translated)
137 INT32 nSize; // 78 file size
138 INT32 nUnknown; // 7C unknown
139 String aName; // Name as Compare String (ascii, upper)
140 public:
141 BOOL Init(); // initialize the data
142 BOOL SetName( const String& ); // store a name (ASCII, up to 32 chars)
143 void GetName( String& rName ) const;
144 // fill in the name
145 short Compare( const StgEntry& ) const; // compare two entries
146 BOOL Load( const void* );
147 void Store( void* );
148 StgEntryType GetType() const { return (StgEntryType) cType; }
149 INT32 GetStartPage() const { return nPage1; }
150 void SetType( StgEntryType t ) { cType = (BYTE) t; }
151 BYTE GetFlags() const { return cFlags; }
152 void SetFlags( BYTE c ) { cFlags = c; }
153 INT32 GetSize() const { return nSize; }
154 void SetSize( INT32 n ) { nSize = n; }
155 const ClsId& GetClassId() const { return aClsId; }
156 void SetClassId( const ClsId& );
157 INT32 GetLeaf( StgEntryRef ) const;
158 void SetLeaf( StgEntryRef, INT32 );
159 const INT32* GetTime( StgEntryTime ) const;
160 void SetTime( StgEntryTime, INT32* );
164 #define STG_FREE -1L // page is free
165 #define STG_EOF -2L // page is last page in chain
166 #define STG_FAT -3L // page is FAT page
167 #define STG_MASTER -4L // page is master FAT page
169 #endif