27
27
Headers::Headers( U32 fcPlcfhdd, U32 lcbPlcfhdd, OLEStreamReader* tableStream, WordVersion version )
29
if ( lcbPlcfhdd == 0 )
29
if ( lcbPlcfhdd == 0 ) {
32
33
tableStream->push();
33
34
#ifdef WV2_DEBUG_HEADERS
34
35
wvlog << "Headers::Headers(): fc=" << fcPlcfhdd << " lcb=" << lcbPlcfhdd << endl;
35
if ( version == Word8 )
36
wvlog << " there is/are " << lcbPlcfhdd / 4 - 2 << " header(s)" << endl;
37
//number of stories in PlcfHdd, first six stories specify footnote and
38
//endnote separators, MS-DOC, p.33
39
if ( version == Word8 ) {
40
//second-to-last CP ends the last story, last CP must be ignored
41
int n = lcbPlcfhdd / 4 - 2;
42
wvlog << "num. of stories in PlcfHdd:" << n << endl;
43
wvlog << "num. of header/footer stories:" << n - 6 << endl;
39
// remove later (do we want asserts in here???)
47
//remove later (do we want asserts in here???)
48
if ( lcbPlcfhdd % 4 ) {
41
49
wvlog << "Bug: m_fib.lcbPlcfhdd % 4 != 0!" << endl;
42
else if ( version == Word8 && ( lcbPlcfhdd / 4 - 2 ) % headerTypes )
51
else if ( version == Word8 && ( lcbPlcfhdd / 4 - 2 ) % headerTypes ) {
43
52
wvlog << "Bug: #headers % " << headerTypes << " != 0!" << endl;
45
55
tableStream->seek( fcPlcfhdd, G_SEEK_SET );
48
if ( version == Word8 )
49
for ( ; i < headerTypes * sizeof( U32 ); i += sizeof( U32 ) )
50
if ( tableStream->readU32() )
51
wvlog << "Bug: Read a value != 0 where I expected a 0!" << endl;
52
for ( ; i < lcbPlcfhdd; i += sizeof( U32 ) )
58
if ( version == Word8 ) {
59
//CPs of footnote/endnote separators related stories
60
for ( ; i < 6 * sizeof( U32 ); i += sizeof( U32 ) ) {
61
tableStream->readU32();
64
//CPs of header/footer related stories (last one has to be ignored)
65
for ( ; i < lcbPlcfhdd; i += sizeof( U32 ) ) {
53
66
m_headers.push_back( tableStream->readU32() );
55
69
tableStream->pop();
62
void Headers::headerMask( U8 /*sep_grpfIhdt*/ )
76
QList<bool> Headers::headersMask( void )
78
//NOTE: Stories are considered empty if they have no contents and no guard
79
//paragraph mark. Thus, an empty story is indicated by the story`s
80
//starting CP, as specified in PlcfHdd, being the same as the next CP in
81
//PlcfHdd. MS-DOC, p.33
86
#ifdef WV2_DEBUG_HEADERS
87
for (U32 i = 0; i < (U32) m_headers.size(); i++) {
88
wvlog << "m_headers: " << m_headers[i];
91
//second-to-last CP ends the last story, last CP must be ignored
92
for (U32 i = 0; i < (U32) (m_headers.size() - 2); i += 6) {
94
for (U32 j = 0; j < 6; j++) {
95
if (m_headers[i + j] != m_headers[i + j + 1]) {
100
mask.push_back(nempty);
103
#ifdef WV2_DEBUG_HEADERS
104
for (U32 i = 0; i < (U32) mask.size(); i++) {
105
wvlog << "Section" << i << ": new header/footer content: " << mask[i];
111
void Headers::set_headerMask( U8 /*sep_grpfIhdt*/ )