Coverage Report

Created: 2026-07-20 07:04

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