LibreOffice Module sot (master) 1
stgelem.hxx
Go to the documentation of this file.
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 INCLUDED_SOT_SOURCE_SDSTOR_STGELEM_HXX
24#define INCLUDED_SOT_SOURCE_SDSTOR_STGELEM_HXX
25
26#include <sot/stg.hxx>
27
28class StgIo;
29class SvStream;
30
33
35{
36 static const sal_uInt8 cFATPagesInHeader = 109;
37
38 sal_uInt8 m_cSignature[ 8 ] = {}; // 00 signature (see below)
39 ClsId m_aClsId = {}; // 08 Class ID
40 sal_Int32 m_nVersion; // 18 version number
41 sal_uInt16 m_nByteOrder; // 1C Unicode byte order indicator
42 sal_Int16 m_nPageSize; // 1E 1 << nPageSize = block size
43 sal_Int16 m_nDataPageSize; // 20 1 << this size == data block size
44 sal_uInt8 m_bDirty; // 22 internal dirty flag (should be
45 // bool, but probably required to
46 // be exactly one byte)
47 sal_uInt8 m_cReserved[ 9 ] = {}; // 23
48 sal_Int32 m_nFATSize; // 2C total number of FAT pages
49 sal_Int32 m_nTOCstrm; // 30 starting page for the TOC stream
50 sal_Int32 m_nReserved; // 34
51 sal_Int32 m_nThreshold; // 38 minimum file size for big data
52 sal_Int32 m_nDataFAT; // 3C page # of 1st data FAT block
53 sal_Int32 m_nDataFATSize; // 40 # of data fat blocks
54 sal_Int32 m_nMasterChain; // 44 chain to the next master block
55 sal_Int32 m_nMaster; // 48 # of additional master blocks
56 sal_Int32 m_nMasterFAT[ cFATPagesInHeader ] = {}; // 4C first [cFATPagesInHeader] master FAT pages
57public:
58 StgHeader();
59
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 sal_Int32 GetTOCStart() const { return m_nTOCstrm; }
66 void SetTOCStart( sal_Int32 n );
67 sal_Int32 GetDataFATStart() const { return m_nDataFAT; }
68 void SetDataFATStart( sal_Int32 n );
69 sal_Int32 GetDataFATSize() const { return m_nDataFATSize; }
70 void SetDataFATSize( sal_Int32 n );
71 sal_Int32 GetThreshold() const { return m_nThreshold; }
72 short GetPageSize() const { return m_nPageSize; }
73 short GetDataPageSize() const { return m_nDataPageSize; }
74 sal_Int32 GetFATSize() const { return m_nFATSize; }
75 void SetFATSize( sal_Int32 n );
76 sal_Int32 GetFATChain() const { return m_nMasterChain; }
77 void SetFATChain( sal_Int32 n );
78 sal_Int32 GetMasters() const { return m_nMaster; }
79 void SetMasters( sal_Int32 n );
80 static short GetFAT1Size() { return cFATPagesInHeader; }
81 sal_Int32 GetFATPage( short ) const;
82 void SetFATPage( short, sal_Int32 );
83};
84
85enum StgEntryType { // dir entry types:
89 STG_ROOT = 5
90};
91
92enum StgEntryRef { // reference blocks:
93 STG_LEFT = 0, // left
94 STG_RIGHT = 1, // right
95 STG_CHILD = 2, // child
96 STG_DATA = 3 // data start
97};
98
99#define STGENTRY_SIZE 128
100
101//StructuredStorageDirectoryEntry
103{ // directory entry
104 sal_Unicode m_nName[ 32 ]; // 00 name as WCHAR
105 sal_uInt16 m_nNameLen; // 40 size of name in bytes including 00H
106 sal_uInt8 m_cType; // 42 entry type
107 sal_uInt8 m_cFlags; // 43 0 or 1 (tree balance?)
108 sal_Int32 m_nLeft; // 44 left node entry
109 sal_Int32 m_nRight; // 48 right node entry
110 sal_Int32 m_nChild; // 4C 1st child entry if storage
111 ClsId m_aClsId; // 50 class ID (optional)
112 sal_Int32 m_nFlags; // 60 state flags(?)
113 sal_Int32 m_nMtime[ 2 ]; // 64 modification time
114 sal_Int32 m_nAtime[ 2 ]; // 6C creation and access time
115 sal_Int32 m_nPage1; // 74 starting block (either direct or translated)
116 sal_Int32 m_nSize; // 78 file size
117 sal_Int32 m_nUnknown; // 7C unknown
118 OUString m_aName; // Name as Compare String (ascii, upper)
119public:
120 void Init(); // initialize the data
121 void SetName( const OUString& ); // store a name (ASCII, up to 32 chars)
122 void GetName( OUString& rName ) const;
123 // fill in the name
124 sal_Int32 Compare( const StgEntry& ) const; // compare two entries
125 bool Load( const void* pBuffer, sal_uInt32 nBufSize, sal_uInt64 nUnderlyingStreamSize );
126 void Store( void* );
127 StgEntryType GetType() const { return static_cast<StgEntryType>(m_cType); }
128 sal_Int32 GetStartPage() const { return m_nPage1; }
129 void SetType( StgEntryType t ) { m_cType = static_cast<sal_uInt8>(t); }
130 sal_Int32 GetSize() const { return m_nSize; }
131 void SetSize( sal_Int32 n ) { m_nSize = n; }
132 const ClsId& GetClassId() const { return m_aClsId; }
133 void SetClassId( const ClsId& );
134 sal_Int32 GetLeaf( StgEntryRef ) const;
135 void SetLeaf( StgEntryRef, sal_Int32 );
136};
137
138
139#define STG_FREE -1L // page is free
140#define STG_EOF -2L // page is last page in chain
141#define STG_FAT -3L // page is FAT page
142#define STG_MASTER -4L // page is master FAT page
143
144#endif
145
146/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
sal_Int32 Compare(const StgEntry &) const
Definition: stgelem.cxx:375
OUString m_aName
Definition: stgelem.hxx:118
sal_Int32 GetSize() const
Definition: stgelem.hxx:130
sal_uInt16 m_nNameLen
Definition: stgelem.hxx:105
void Store(void *)
Definition: stgelem.cxx:462
sal_Int32 m_nAtime[2]
Definition: stgelem.hxx:114
void SetLeaf(StgEntryRef, sal_Int32)
Definition: stgelem.cxx:349
void GetName(OUString &rName) const
Definition: stgelem.cxx:365
const ClsId & GetClassId() const
Definition: stgelem.hxx:132
sal_Int32 m_nSize
Definition: stgelem.hxx:116
sal_Unicode m_nName[32]
Definition: stgelem.hxx:104
sal_Int32 GetLeaf(StgEntryRef) const
Definition: stgelem.cxx:336
ClsId m_aClsId
Definition: stgelem.hxx:111
void SetName(const OUString &)
Definition: stgelem.cxx:315
StgEntryType GetType() const
Definition: stgelem.hxx:127
sal_uInt8 m_cFlags
Definition: stgelem.hxx:107
sal_uInt8 m_cType
Definition: stgelem.hxx:106
void SetClassId(const ClsId &)
Definition: stgelem.cxx:360
sal_Int32 m_nFlags
Definition: stgelem.hxx:112
void Init()
Definition: stgelem.cxx:285
sal_Int32 GetStartPage() const
Definition: stgelem.hxx:128
sal_Int32 m_nUnknown
Definition: stgelem.hxx:117
sal_Int32 m_nRight
Definition: stgelem.hxx:109
bool Load(const void *pBuffer, sal_uInt32 nBufSize, sal_uInt64 nUnderlyingStreamSize)
Definition: stgelem.cxx:386
void SetSize(sal_Int32 n)
Definition: stgelem.hxx:131
sal_Int32 m_nMtime[2]
Definition: stgelem.hxx:113
void SetType(StgEntryType t)
Definition: stgelem.hxx:129
sal_Int32 m_nPage1
Definition: stgelem.hxx:115
sal_Int32 m_nLeft
Definition: stgelem.hxx:108
sal_Int32 m_nChild
Definition: stgelem.hxx:110
sal_Int16 m_nDataPageSize
Definition: stgelem.hxx:43
void SetTOCStart(sal_Int32 n)
Definition: stgelem.cxx:229
sal_uInt8 m_cReserved[9]
Definition: stgelem.hxx:47
static const sal_uInt8 cFATPagesInHeader
Definition: stgelem.hxx:36
sal_Int32 m_nTOCstrm
Definition: stgelem.hxx:49
sal_Int16 m_nPageSize
Definition: stgelem.hxx:42
sal_Int32 m_nFATSize
Definition: stgelem.hxx:48
sal_Int32 GetDataFATSize() const
Definition: stgelem.hxx:69
void SetDataFATSize(sal_Int32 n)
Definition: stgelem.cxx:247
void SetDataFATStart(sal_Int32 n)
Definition: stgelem.cxx:238
void SetFATPage(short, sal_Int32)
Definition: stgelem.cxx:217
sal_Int32 GetFATSize() const
Definition: stgelem.hxx:74
sal_Int32 GetDataFATStart() const
Definition: stgelem.hxx:67
sal_Int32 m_nReserved
Definition: stgelem.hxx:50
sal_Int32 m_nThreshold
Definition: stgelem.hxx:51
static short GetFAT1Size()
Definition: stgelem.hxx:80
StgHeader()
Definition: stgelem.cxx:71
sal_Int32 m_nVersion
Definition: stgelem.hxx:40
sal_Int32 m_nMasterChain
Definition: stgelem.hxx:54
bool Check()
Definition: stgelem.cxx:194
void SetMasters(sal_Int32 n)
Definition: stgelem.cxx:274
sal_Int32 GetFATChain() const
Definition: stgelem.hxx:76
sal_Int32 GetFATPage(short) const
Definition: stgelem.cxx:209
sal_Int32 GetThreshold() const
Definition: stgelem.hxx:71
bool Load(StgIo &)
Definition: stgelem.cxx:112
short GetDataPageSize() const
Definition: stgelem.hxx:73
sal_uInt8 m_bDirty
Definition: stgelem.hxx:44
sal_uInt8 m_cSignature[8]
Definition: stgelem.hxx:38
sal_Int32 m_nMasterFAT[cFATPagesInHeader]
Definition: stgelem.hxx:56
sal_Int32 GetTOCStart() const
Definition: stgelem.hxx:65
sal_Int32 m_nDataFAT
Definition: stgelem.hxx:52
sal_Int32 m_nMaster
Definition: stgelem.hxx:55
sal_Int32 GetMasters() const
Definition: stgelem.hxx:78
bool Store(StgIo &)
Definition: stgelem.cxx:152
void SetFATChain(sal_Int32 n)
Definition: stgelem.cxx:265
short GetPageSize() const
Definition: stgelem.hxx:72
void Init()
Definition: stgelem.cxx:88
sal_Int32 m_nDataFATSize
Definition: stgelem.hxx:53
sal_uInt16 m_nByteOrder
Definition: stgelem.hxx:41
ClsId m_aClsId
Definition: stgelem.hxx:39
void SetFATSize(sal_Int32 n)
Definition: stgelem.cxx:256
Definition: stgio.hxx:42
sal_Int64 n
SvStream & WriteClsId(SvStream &, const ClsId &)
Definition: stgelem.cxx:53
StgEntryType
Definition: stgelem.hxx:85
@ STG_STORAGE
Definition: stgelem.hxx:87
@ STG_STREAM
Definition: stgelem.hxx:88
@ STG_EMPTY
Definition: stgelem.hxx:86
@ STG_ROOT
Definition: stgelem.hxx:89
StgEntryRef
Definition: stgelem.hxx:92
@ STG_RIGHT
Definition: stgelem.hxx:94
@ STG_DATA
Definition: stgelem.hxx:96
@ STG_CHILD
Definition: stgelem.hxx:95
@ STG_LEFT
Definition: stgelem.hxx:93
SvStream & ReadClsId(SvStream &, ClsId &)
Definition: stgelem.cxx:37
unsigned char sal_uInt8
sal_uInt16 sal_Unicode