~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to filters/kword/msword-odf/wv2/src/headers.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
Headers::Headers( U32 fcPlcfhdd, U32 lcbPlcfhdd, OLEStreamReader* tableStream, WordVersion version )
28
28
{
29
 
    if ( lcbPlcfhdd == 0 )
 
29
    if ( lcbPlcfhdd == 0 ) {
30
30
        return;
 
31
    }
31
32
 
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;
 
36
 
 
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;
 
44
    }
37
45
#endif
38
46
 
39
 
    // remove later (do we want asserts in here???)
40
 
    if ( lcbPlcfhdd % 4 )
 
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 )
 
50
    }
 
51
    else if ( version == Word8 && ( lcbPlcfhdd / 4 - 2 ) % headerTypes ) {
43
52
        wvlog << "Bug: #headers % " << headerTypes << " != 0!" << endl;
 
53
    }
44
54
 
45
55
    tableStream->seek( fcPlcfhdd, G_SEEK_SET );
46
56
 
47
57
    U32 i = 0;
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();
 
62
        }
 
63
    }
 
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() );
 
67
    }
54
68
 
55
69
    tableStream->pop();
56
70
}
59
73
{
60
74
}
61
75
 
62
 
void Headers::headerMask( U8 /*sep_grpfIhdt*/ )
 
76
QList<bool> Headers::headersMask( void )
 
77
{
 
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
 
82
 
 
83
    bool nempty;
 
84
    QList<bool> mask;
 
85
 
 
86
#ifdef WV2_DEBUG_HEADERS
 
87
    for (U32 i = 0; i < (U32) m_headers.size(); i++) {
 
88
        wvlog << "m_headers: " << m_headers[i];
 
89
    }
 
90
#endif
 
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) {
 
93
        nempty = false;
 
94
        for (U32 j = 0; j < 6; j++) {
 
95
            if (m_headers[i + j] != m_headers[i + j + 1]) {
 
96
                nempty = true;
 
97
                break;
 
98
            }
 
99
        }
 
100
        mask.push_back(nempty);
 
101
    }
 
102
 
 
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];
 
106
    }
 
107
#endif
 
108
    return mask;
 
109
}
 
110
 
 
111
void Headers::set_headerMask( U8 /*sep_grpfIhdt*/ )
63
112
{
64
113
}