2
* Copyright (C) 2003 William Lachance (wrlach@gmail.com)
3
* Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
4
* Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20
* For further information visit http://libwpd.sourceforge.net
23
/* "This product is not manufactured, approved, or supported by
24
* Corel Corporation or Corel Corporation Limited."
27
#include "WP1FixedLengthGroup.h"
28
#include "WP1SuppressPageCharacteristicsGroup.h"
29
#include "WP1UnsupportedFixedLengthGroup.h"
30
#include "WP1MarginResetGroup.h"
31
#include "WP1MarginReleaseGroup.h"
32
#include "WP1TopMarginGroup.h"
33
#include "WP1BottomMarginGroup.h"
34
#include "WP1ExtendedCharacterGroup.h"
35
#include "WP1PointSizeGroup.h"
36
#include "WP1LeftIndentGroup.h"
37
#include "WP1LeftRightIndentGroup.h"
38
#include "WP1JustificationGroup.h"
39
#include "WP1SpacingResetGroup.h"
40
#include "WP1CenterTextGroup.h"
41
#include "WP1FlushRightGroup.h"
42
#include "WP1FileStructure.h"
43
#include "libwpd_internal.h"
45
WP1FixedLengthGroup::WP1FixedLengthGroup(uint8_t group)
50
WP1FixedLengthGroup * WP1FixedLengthGroup::constructFixedLengthGroup(WPXInputStream *input, uint8_t group)
54
case WP1_MARGIN_RESET_GROUP:
55
return new WP1MarginResetGroup(input, group);
56
case WP1_TOP_MARGIN_SET_GROUP:
57
return new WP1TopMarginGroup(input, group);
58
case WP1_BOTTOM_MARGIN_SET_GROUP:
59
return new WP1BottomMarginGroup(input, group);
60
case WP1_LEFT_INDENT_GROUP:
61
return new WP1LeftIndentGroup(input, group);
62
case WP1_SUPPRESS_PAGE_CHARACTERISTICS_GROUP:
63
return new WP1SuppressPageCharacteristicsGroup(input, group);
64
case WP1_LEFT_RIGHT_INDENT_GROUP:
65
return new WP1LeftRightIndentGroup(input, group);
66
case WP1_MARGIN_RELEASE_GROUP:
67
return new WP1MarginReleaseGroup(input, group);
68
case WP1_CENTER_TEXT_GROUP:
69
return new WP1CenterTextGroup(input, group);
70
case WP1_FLUSH_RIGHT_GROUP:
71
return new WP1FlushRightGroup(input, group);
72
case WP1_EXTENDED_CHARACTER_GROUP:
73
return new WP1ExtendedCharacterGroup(input, group);
74
case WP1_POINT_SIZE_GROUP:
75
return new WP1PointSizeGroup(input, group);
76
case WP1_JUSTIFICATION_GROUP:
77
return new WP1JustificationGroup(input, group);
78
case WP1_SPACING_RESET_GROUP:
79
return new WP1SpacingResetGroup(input, group);
81
// this is an unhandled group, just skip it
82
return new WP1UnsupportedFixedLengthGroup(input, group);
86
bool WP1FixedLengthGroup::isGroupConsistent(WPXInputStream *input, const uint8_t groupID)
88
uint32_t startPosition = input->tell();
92
int size = WP1_FUNCTION_GROUP_SIZE[groupID-0xC0];
93
if (input->seek((startPosition + size - 2 - input->tell()), WPX_SEEK_CUR) || input->atEOS())
95
input->seek(startPosition, WPX_SEEK_SET);
98
if (groupID != readU8(input))
100
input->seek(startPosition, WPX_SEEK_SET);
104
input->seek(startPosition, WPX_SEEK_SET);
109
input->seek(startPosition, WPX_SEEK_SET);
114
void WP1FixedLengthGroup::_read(WPXInputStream *input)
116
uint32_t startPosition = input->tell();
118
if (m_group >= 0xC0 && m_group <= 0xFE) // just an extra safety check
120
int size = WP1_FUNCTION_GROUP_SIZE[m_group-0xC0];
124
_readContents(input);
126
input->seek((startPosition + size - 2 - input->tell()), WPX_SEEK_CUR);
127
if (m_group != readU8(input))
129
WPD_DEBUG_MSG(("WordPerfect: Possible corruption detected. Bailing out!\n"));
130
throw FileException();
134
throw FileException();