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