Coverage Report

Created: 2026-06-13 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwpd/src/lib/WP1FixedLengthGroup.cpp
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* libwpd
3
 * Version: MPL 2.0 / LGPLv2.1+
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
 * Major Contributor(s):
10
 * Copyright (C) 2003 William Lachance (wrlach@gmail.com)
11
 * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
12
 * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13
 *
14
 * For minor contributions see the git repository.
15
 *
16
 * Alternatively, the contents of this file may be used under the terms
17
 * of the GNU Lesser General Public License Version 2.1 or later
18
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19
 * applicable instead of those above.
20
 *
21
 * For further information visit http://libwpd.sourceforge.net
22
 */
23
24
/* "This product is not manufactured, approved, or supported by
25
 * Corel Corporation or Corel Corporation Limited."
26
 */
27
28
#include "WP1FixedLengthGroup.h"
29
#include "WP1SuppressPageCharacteristicsGroup.h"
30
#include "WP1UnsupportedFixedLengthGroup.h"
31
#include "WP1MarginResetGroup.h"
32
#include "WP1MarginReleaseGroup.h"
33
#include "WP1TopMarginGroup.h"
34
#include "WP1BottomMarginGroup.h"
35
#include "WP1ExtendedCharacterGroup.h"
36
#include "WP1PointSizeGroup.h"
37
#include "WP1LeftIndentGroup.h"
38
#include "WP1FontIdGroup.h"
39
#include "WP1LeftRightIndentGroup.h"
40
#include "WP1JustificationGroup.h"
41
#include "WP1SpacingResetGroup.h"
42
#include "WP1CenterTextGroup.h"
43
#include "WP1FlushRightGroup.h"
44
#include "WP1FileStructure.h"
45
#include "libwpd_internal.h"
46
47
WP1FixedLengthGroup::WP1FixedLengthGroup(unsigned char group)
48
0
  : m_group(group)
49
0
{
50
0
}
51
52
WP1FixedLengthGroup *WP1FixedLengthGroup::constructFixedLengthGroup(librevenge::RVNGInputStream *input, WPXEncryption *encryption, unsigned char group)
53
0
{
54
0
  switch (group)
55
0
  {
56
0
  case WP1_MARGIN_RESET_GROUP:
57
0
    return new WP1MarginResetGroup(input, encryption, group);
58
0
  case WP1_TOP_MARGIN_SET_GROUP:
59
0
    return new WP1TopMarginGroup(input, encryption, group);
60
0
  case WP1_BOTTOM_MARGIN_SET_GROUP:
61
0
    return new WP1BottomMarginGroup(input, encryption, group);
62
0
  case WP1_LEFT_INDENT_GROUP:
63
0
    return new WP1LeftIndentGroup(input, encryption, group);
64
0
  case WP1_SUPPRESS_PAGE_CHARACTERISTICS_GROUP:
65
0
    return new WP1SuppressPageCharacteristicsGroup(input, encryption, group);
66
0
  case WP1_LEFT_RIGHT_INDENT_GROUP:
67
0
    return new WP1LeftRightIndentGroup(input, encryption, group);
68
0
  case WP1_FONT_ID_GROUP:
69
0
    return new WP1FontIdGroup(input, encryption, group);
70
0
  case WP1_MARGIN_RELEASE_GROUP:
71
0
    return new WP1MarginReleaseGroup(input, encryption, group);
72
0
  case WP1_CENTER_TEXT_GROUP:
73
0
    return new WP1CenterTextGroup(input, encryption, group);
74
0
  case WP1_FLUSH_RIGHT_GROUP:
75
0
    return new WP1FlushRightGroup(input, encryption, group);
76
0
  case WP1_EXTENDED_CHARACTER_GROUP:
77
0
    return new WP1ExtendedCharacterGroup(input, encryption, group);
78
0
  case WP1_POINT_SIZE_GROUP:
79
0
    return new WP1PointSizeGroup(input, encryption, group);
80
0
  case WP1_JUSTIFICATION_GROUP:
81
0
    return new WP1JustificationGroup(input, encryption, group);
82
0
  case WP1_SPACING_RESET_GROUP:
83
0
    return new WP1SpacingResetGroup(input, encryption, group);
84
0
  default:
85
    // this is an unhandled group, just skip it
86
0
    return new WP1UnsupportedFixedLengthGroup(input, encryption, group);
87
0
  }
88
0
}
89
90
void WP1FixedLengthGroup::_read(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
91
0
{
92
0
  long startPosition = input->tell();
93
94
0
  if (m_group >= 0xC0 && m_group <= 0xFE) // just an extra safety check
95
0
  {
96
0
    int size = WP1_FUNCTION_GROUP_SIZE[m_group-0xC0];
97
0
    if (size == -1)
98
0
      return;
99
100
0
    _readContents(input, encryption);
101
102
0
    input->seek((startPosition + size - 2), librevenge::RVNG_SEEK_SET);
103
0
    if (m_group != readU8(input, encryption))
104
0
    {
105
0
      WPD_DEBUG_MSG(("WordPerfect: Possible corruption detected. Bailing out!\n"));
106
0
      throw FileException();
107
0
    }
108
0
  }
109
0
  else
110
0
    throw FileException();
111
0
}
112
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */