Coverage Report

Created: 2026-10-28 06:34

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
9.59k
  WP5VariableLengthGroup(),
32
9.59k
  m_subDocument(),
33
9.59k
  m_noteReference()
34
9.59k
{
35
9.59k
  _read(input, encryption);
36
9.59k
}
37
38
WP5FootnoteEndnoteGroup::~WP5FootnoteEndnoteGroup()
39
9.23k
{
40
9.23k
}
41
42
void WP5FootnoteEndnoteGroup::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
43
9.59k
{
44
9.59k
  int tmpSizeOfNote = getSize() - 8;
45
9.59k
  unsigned char tmpFlags = readU8(input, encryption);
46
9.59k
  tmpSizeOfNote -= 1;
47
9.59k
  int tmpNumOfNote = readU16(input, encryption);
48
9.59k
  tmpSizeOfNote -= 2;
49
9.59k
  if (getSubGroup() == WP5_FOOTNOTE_ENDNOTE_GROUP_FOOTNOTE)
50
8.10k
  {
51
8.10k
    int tmpNumOfAdditionalPages = readU8(input, encryption);
52
8.10k
    tmpSizeOfNote -= 1;
53
8.10k
    input->seek(2*(tmpNumOfAdditionalPages+1) + 9, librevenge::RVNG_SEEK_CUR);
54
8.10k
    tmpSizeOfNote -= 2*(tmpNumOfAdditionalPages+1) + 9;
55
8.10k
  }
56
1.49k
  else /* WP5_FOOTNOTE_ENDNOTE_GROUP_ENDNOTE */
57
1.49k
  {
58
1.49k
    input->seek(4, librevenge::RVNG_SEEK_CUR);
59
1.49k
    tmpSizeOfNote -= 4;
60
1.49k
  }
61
62
9.59k
  if (tmpSizeOfNote > 0)
63
4.86k
    m_subDocument.reset(new WP5SubDocument(input, encryption, (unsigned)tmpSizeOfNote));
64
9.59k
  if (tmpFlags & 0x80)
65
5.24k
    m_noteReference.sprintf("%c", tmpNumOfNote);
66
4.35k
  else
67
4.35k
    m_noteReference.sprintf("%i", tmpNumOfNote);
68
9.59k
}
69
70
void WP5FootnoteEndnoteGroup::parse(WP5Listener *listener)
71
9.23k
{
72
9.23k
  WPD_DEBUG_MSG(("WordPerfect: handling a Footnote/Endnote group\n"));
73
9.23k
  listener->insertNoteReference(m_noteReference);
74
9.23k
  switch (getSubGroup())
75
9.23k
  {
76
7.85k
  case WP5_FOOTNOTE_ENDNOTE_GROUP_FOOTNOTE:
77
7.85k
    listener->insertNote(FOOTNOTE, m_subDocument.get());
78
7.85k
    break;
79
1.09k
  case WP5_FOOTNOTE_ENDNOTE_GROUP_ENDNOTE:
80
1.09k
    listener->insertNote(ENDNOTE, m_subDocument.get());
81
1.09k
    break;
82
297
  default: // something else we don't support, since it isn't in the docs
83
297
    break;
84
9.23k
  }
85
9.23k
}
86
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */