~ubuntu-branches/ubuntu/saucy/libwpd/saucy

« back to all changes in this revision

Viewing changes to src/lib/WP6VariableLengthGroup.cpp

  • Committer: Package Import Robot
  • Author(s): Rene Engelhard
  • Date: 2011-11-29 23:31:13 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20111129233113-xdtwca9h0y6wdxst
Tags: 0.9.4-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
1
2
/* libwpd
2
3
 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
3
4
 * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
4
5
 * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
5
 
 *  
 
6
 *
6
7
 * This library is free software; you can redistribute it and/or
7
8
 * modify it under the terms of the GNU Lesser General Public
8
9
 * License as published by the Free Software Foundation; either
20
21
 * For further information visit http://libwpd.sourceforge.net
21
22
 */
22
23
 
23
 
/* "This product is not manufactured, approved, or supported by 
 
24
/* "This product is not manufactured, approved, or supported by
24
25
 * Corel Corporation or Corel Corporation Limited."
25
26
 */
26
27
 
60
61
                delete [] m_prefixIDs;
61
62
}
62
63
 
63
 
WP6VariableLengthGroup * WP6VariableLengthGroup::constructVariableLengthGroup(WPXInputStream *input, WPXEncryption *encryption, const uint8_t groupID)
 
64
WP6VariableLengthGroup *WP6VariableLengthGroup::constructVariableLengthGroup(WPXInputStream *input, WPXEncryption *encryption, const uint8_t groupID)
64
65
{
65
66
        switch (groupID)
66
67
        {
70
71
                return new WP6SetNumberGroup(input, encryption);
71
72
        case WP6_TOP_PAGE_GROUP:
72
73
                return new WP6PageGroup(input, encryption);
73
 
        case WP6_TOP_EOL_GROUP: 
 
74
        case WP6_TOP_EOL_GROUP:
74
75
                return new WP6EOLGroup(input, encryption);
75
76
        case WP6_TOP_CHARACTER_GROUP:
76
77
                return new WP6CharacterGroup(input, encryption);
120
121
                        input->seek(startPosition, WPX_SEEK_SET);
121
122
                        return false;
122
123
                }
123
 
                
 
124
 
124
125
                input->seek(startPosition, WPX_SEEK_SET);
125
126
                return true;
126
127
        }
134
135
void WP6VariableLengthGroup::_read(WPXInputStream *input, WPXEncryption *encryption)
135
136
{
136
137
        uint32_t startPosition = input->tell();
137
 
        
 
138
 
138
139
        m_subGroup = readU8(input, encryption);
139
140
        if ((m_size = readU16(input, encryption)) == 0)
140
141
                throw FileException();
143
144
        if (m_flags & WP6_VARIABLE_GROUP_PREFIX_ID_BIT)
144
145
        {
145
146
                m_numPrefixIDs = readU8(input, encryption);
146
 
                
 
147
 
147
148
                if (m_numPrefixIDs > 0)
148
149
                {
149
150
                        m_prefixIDs = new uint16_t[m_numPrefixIDs];
150
151
                        for (uint32_t i = 0; i < m_numPrefixIDs; i++)
151
152
                        {
152
 
                                m_prefixIDs[i] = readU16(input, encryption);            
 
153
                                m_prefixIDs[i] = readU16(input, encryption);
153
154
                        }
154
 
                }       
155
 
        }       
 
155
                }
 
156
        }
156
157
        else
157
158
        {
158
159
                m_numPrefixIDs = 0;
159
160
                m_prefixIDs = 0;
160
161
        }
161
 
                
 
162
 
162
163
        m_sizeNonDeletable = readU16(input, encryption);
163
164
        if (m_sizeNonDeletable > m_size || (m_sizeNonDeletable & 0x8000))
164
165
        {
165
166
                WPD_DEBUG_MSG(("WordPerfect: Possible corruption detected, bailing out!\n"));
166
167
                throw FileException();
167
168
        }
168
 
        
 
169
 
169
170
        uint32_t tmpPosition = input->tell();
170
171
        input->seek(m_sizeNonDeletable, WPX_SEEK_CUR);
171
172
        m_sizeDeletable = (uint16_t)(startPosition + m_size - 4 - input->tell());
185
186
 
186
187
        input->seek((startPosition + m_size - 1), WPX_SEEK_SET);
187
188
}
 
189
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */