Coverage Report

Created: 2026-07-20 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwpd/src/lib/WP6Part.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) 2002 William Lachance (wrlach@gmail.com)
11
 * Copyright (C) 2002 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 "WP6Part.h"
29
#include "WP6VariableLengthGroup.h"
30
#include "WP6FixedLengthGroup.h"
31
#include "WP6SingleByteFunction.h"
32
33
// constructPart: constructs a parseable low-level representation of part of the document
34
// returns the part if it successfully creates the part, returns 0 if it can't
35
// throws an exception if there is an error
36
// precondition: readVal us between 0x80 and 0xFF
37
WP6Part *WP6Part::constructPart(librevenge::RVNGInputStream *input, WPXEncryption *encryption, const unsigned char readVal)
38
0
{
39
0
  WPD_DEBUG_MSG(("WordPerfect: ConstructPart\n"));
40
41
0
  if (readVal >= (unsigned char)0x80 && readVal <= (unsigned char)0xCF)
42
0
  {
43
0
    WPD_DEBUG_MSG(("WordPerfect: constructSingleByteFunction(input, val=0x%.2x)\n", readVal));
44
0
    return WP6SingleByteFunction::constructSingleByteFunction(input, encryption, readVal);
45
0
  }
46
0
  else if (readVal >= (unsigned char)0xD0 && readVal <= (unsigned char)0xEF)
47
0
  {
48
0
    if (!WP6VariableLengthGroup::isGroupConsistent(input, encryption, readVal))
49
0
    {
50
0
      WPD_DEBUG_MSG(("WordPerfect: Consistency Check (variable length) failed; ignoring this byte\n"));
51
0
      return nullptr;
52
0
    }
53
0
    WPD_DEBUG_MSG(("WordPerfect: constructVariableLengthGroup(input, val=0x%.2x)\n", readVal));
54
0
    return WP6VariableLengthGroup::constructVariableLengthGroup(input, encryption, readVal);
55
0
  }
56
57
0
  else if (readVal >= (unsigned char)0xF0 && readVal < (unsigned char)0xFF)
58
0
  {
59
0
    if (!WP6FixedLengthGroup::isGroupConsistent(input, encryption, readVal))
60
0
    {
61
0
      WPD_DEBUG_MSG(("WordPerfect: Consistency Check (fixed length) failed; ignoring this byte\n"));
62
0
      return nullptr;
63
0
    }
64
0
    WPD_DEBUG_MSG(("WordPerfect: constructFixedLengthGroup(input, val=0x%.2x)\n", readVal));
65
0
    return WP6FixedLengthGroup::constructFixedLengthGroup(input, encryption, readVal);
66
0
  }
67
#ifdef DEBUG
68
  else
69
    WPD_DEBUG_MSG(("WordPerfect: invalid group (val=0x%2x)\n", readVal));
70
#endif
71
72
0
  WPD_DEBUG_MSG(("WordPerfect: Returning 0 from constructPart\n"));
73
0
  return nullptr;
74
0
}
75
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */