Coverage Report

Created: 2026-03-12 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwpd/src/lib/WP5FootnoteEndnoteGroup.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) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
11
 *
12
 * For minor contributions see the git repository.
13
 *
14
 * Alternatively, the contents of this file may be used under the terms
15
 * of the GNU Lesser General Public License Version 2.1 or later
16
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
17
 * applicable instead of those above.
18
 *
19
 * For further information visit http://libwpd.sourceforge.net
20
 */
21
22
/* "This product is not manufactured, approved, or supported by
23
 * Corel Corporation or Corel Corporation Limited."
24
 */
25
26
#include "WP5FootnoteEndnoteGroup.h"
27
#include "WP5FileStructure.h"
28
#include "WP5Parser.h"
29
30
WP5FootnoteEndnoteGroup::WP5FootnoteEndnoteGroup(librevenge::RVNGInputStream *input, WPXEncryption *encryption) :
31
8.28k
  WP5VariableLengthGroup(),
32
8.28k
  m_subDocument(),
33
8.28k
  m_noteReference()
34
8.28k
{
35
8.28k
  _read(input, encryption);
36
8.28k
}
37
38
WP5FootnoteEndnoteGroup::~WP5FootnoteEndnoteGroup()
39
7.93k
{
40
7.93k
}
41
42
void WP5FootnoteEndnoteGroup::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
43
8.28k
{
44
8.28k
  int tmpSizeOfNote = getSize() - 8;
45
8.28k
  unsigned char tmpFlags = readU8(input, encryption);
46
8.28k
  tmpSizeOfNote -= 1;
47
8.28k
  int tmpNumOfNote = readU16(input, encryption);
48
8.28k
  tmpSizeOfNote -= 2;
49
8.28k
  if (getSubGroup() == WP5_FOOTNOTE_ENDNOTE_GROUP_FOOTNOTE)
50
7.13k
  {
51
7.13k
    int tmpNumOfAdditionalPages = readU8(input, encryption);
52
7.13k
    tmpSizeOfNote -= 1;
53
7.13k
    input->seek(2*(tmpNumOfAdditionalPages+1) + 9, librevenge::RVNG_SEEK_CUR);
54
7.13k
    tmpSizeOfNote -= 2*(tmpNumOfAdditionalPages+1) + 9;
55
7.13k
  }
56
1.15k
  else /* WP5_FOOTNOTE_ENDNOTE_GROUP_ENDNOTE */
57
1.15k
  {
58
1.15k
    input->seek(4, librevenge::RVNG_SEEK_CUR);
59
1.15k
    tmpSizeOfNote -= 4;
60
1.15k
  }
61
62
8.28k
  if (tmpSizeOfNote > 0)
63
4.64k
    m_subDocument.reset(new WP5SubDocument(input, encryption, (unsigned)tmpSizeOfNote));
64
8.28k
  if (tmpFlags & 0x80)
65
4.83k
    m_noteReference.sprintf("%c", tmpNumOfNote);
66
3.45k
  else
67
3.45k
    m_noteReference.sprintf("%i", tmpNumOfNote);
68
8.28k
}
69
70
void WP5FootnoteEndnoteGroup::parse(WP5Listener *listener)
71
7.93k
{
72
7.93k
  WPD_DEBUG_MSG(("WordPerfect: handling a Footnote/Endnote group\n"));
73
7.93k
  listener->insertNoteReference(m_noteReference);
74
7.93k
  switch (getSubGroup())
75
7.93k
  {
76
6.88k
  case WP5_FOOTNOTE_ENDNOTE_GROUP_FOOTNOTE:
77
6.88k
    listener->insertNote(FOOTNOTE, m_subDocument.get());
78
6.88k
    break;
79
783
  case WP5_FOOTNOTE_ENDNOTE_GROUP_ENDNOTE:
80
783
    listener->insertNote(ENDNOTE, m_subDocument.get());
81
783
    break;
82
270
  default: // something else we don't support, since it isn't in the docs
83
270
    break;
84
7.93k
  }
85
7.93k
}
86
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */