Coverage Report

Created: 2026-10-28 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwpd/src/lib/WP3Part.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) 2004 Marc Maurer (uwog@uwog.net)
11
 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
12
 *
13
 * For minor contributions see the git repository.
14
 *
15
 * Alternatively, the contents of this file may be used under the terms
16
 * of the GNU Lesser General Public License Version 2.1 or later
17
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18
 * applicable instead of those above.
19
 *
20
 * For further information visit http://libwpd.sourceforge.net
21
 */
22
23
/* "This product is not manufactured, approved, or supported by
24
 * Corel Corporation or Corel Corporation Limited."
25
 */
26
27
#include "WP3Part.h"
28
#include "WP3VariableLengthGroup.h"
29
#include "WP3FixedLengthGroup.h"
30
#include "WP3SingleByteFunction.h"
31
#include "libwpd_internal.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 is between 0xC0 and 0xEF
37
WP3Part *WP3Part::constructPart(librevenge::RVNGInputStream *input, WPXEncryption *encryption, const unsigned char readVal)
38
37.2M
{
39
37.2M
  WPD_DEBUG_MSG(("WordPerfect: ConstructPart for group 0x%x\n", readVal));
40
41
37.2M
  if (readVal >= (unsigned char)0x80 && readVal <= (unsigned char)0xBF)
42
11.7M
  {
43
    // single-byte function
44
11.7M
    WPD_DEBUG_MSG(("WordPerfect: constructSingleByteFunction(input, val)\n"));
45
11.7M
    return WP3SingleByteFunction::constructSingleByteFunction(input, encryption, readVal);
46
11.7M
  }
47
25.5M
  else if (readVal >= (unsigned char)0xC0 && readVal <= (unsigned char)0xCF)
48
4.87M
  {
49
    // fixed length multi-byte function
50
51
4.87M
    if (!WP3FixedLengthGroup::isGroupConsistent(input, encryption, readVal))
52
3.79M
    {
53
3.79M
      WPD_DEBUG_MSG(("WordPerfect: Consistency Check (fixed length) failed; ignoring this byte\n"));
54
3.79M
      return nullptr;
55
3.79M
    }
56
1.07M
    WPD_DEBUG_MSG(("WordPerfect: constructFixedLengthGroup(input, val)\n"));
57
1.07M
    return WP3FixedLengthGroup::constructFixedLengthGroup(input, encryption, readVal);
58
4.87M
  }
59
20.6M
  else if (readVal >= (unsigned char)0xD0 && readVal <= (unsigned char)0xEF)
60
16.9M
  {
61
    // variable length multi-byte function
62
63
16.9M
    if (!WP3VariableLengthGroup::isGroupConsistent(input, encryption, readVal))
64
16.0M
    {
65
16.0M
      WPD_DEBUG_MSG(("WordPerfect: Consistency Check (variable length) failed; ignoring this byte\n"));
66
16.0M
      return nullptr;
67
16.0M
    }
68
991k
    WPD_DEBUG_MSG(("WordPerfect: constructVariableLengthGroup(input, val)\n"));
69
991k
    return WP3VariableLengthGroup::constructVariableLengthGroup(input, encryption, readVal);
70
16.9M
  }
71
72
3.64M
  WPD_DEBUG_MSG(("WordPerfect: Returning 0 from constructPart\n"));
73
3.64M
  return nullptr;
74
37.2M
}
75
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */