Coverage Report

Created: 2026-03-12 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwpd/src/lib/WP6PrefixData.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-2003 Marc Maurer (uwog@uwog.net)
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 "WP6PrefixData.h"
28
29
#include <vector>
30
31
#include "WP6PrefixIndice.h"
32
#include "WP6PrefixDataPacket.h"
33
#include "WP6FontDescriptorPacket.h"
34
#include "WP6DefaultInitialFontPacket.h"
35
#include "libwpd_internal.h"
36
37
WP6PrefixData::WP6PrefixData(librevenge::RVNGInputStream *input, WPXEncryption *encryption, const int numPrefixIndices) :
38
0
  m_prefixDataPacketHash(),
39
0
  m_prefixDataPacketTypeHash(),
40
0
  m_defaultInitialFontPID((-1))
41
0
{
42
0
  if (!numPrefixIndices)
43
0
  {
44
0
    WPD_DEBUG_MSG(("WordPerfect: constructing called without any prefix\n"));
45
0
    return;
46
0
  }
47
0
  unsigned short i;
48
0
  std::vector<WP6PrefixIndice> prefixIndiceArray;
49
0
  prefixIndiceArray.reserve(numPrefixIndices - 1);
50
0
  for (i=1; i<numPrefixIndices; i++)
51
0
  {
52
0
    WPD_DEBUG_MSG(("WordPerfect: constructing prefix indice 0x%x\n", i));
53
0
    prefixIndiceArray.emplace_back(input, encryption, i);
54
0
  }
55
56
0
  for (i=1; i<numPrefixIndices; i++)
57
0
  {
58
0
    WPD_DEBUG_MSG(("WordPerfect: constructing prefix packet 0x%x\n", i));
59
0
    auto prefixDataPacket = WP6PrefixDataPacket::constructPrefixDataPacket(input, encryption, prefixIndiceArray[(i-1)]);
60
0
    if (prefixDataPacket)
61
0
    {
62
0
      m_prefixDataPacketHash[i] = prefixDataPacket;
63
0
      m_prefixDataPacketTypeHash.insert(std::make_pair(prefixIndiceArray[i-1].getType(), prefixDataPacket));
64
0
      if (dynamic_cast<WP6DefaultInitialFontPacket *>(prefixDataPacket.get()))
65
0
        m_defaultInitialFontPID = i;
66
0
    }
67
0
  }
68
0
}
69
70
WP6PrefixData::~WP6PrefixData()
71
0
{
72
0
}
73
74
const WP6PrefixDataPacket *WP6PrefixData::getPrefixDataPacket(const int prefixID) const
75
0
{
76
0
  auto pos = m_prefixDataPacketHash.find(prefixID);
77
0
  if (pos != m_prefixDataPacketHash.end())
78
0
    return pos->second.get();
79
0
  else
80
0
    return nullptr;
81
0
}
82
83
std::pair<MPDP_CIter, MPDP_CIter> WP6PrefixData::getPrefixDataPacketsOfType(const int type) const
84
0
{
85
0
  std::pair<MPDP_CIter, MPDP_CIter> tempPair = m_prefixDataPacketTypeHash.equal_range(type);
86
87
0
  return tempPair;
88
0
}
89
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */