Coverage Report

Created: 2026-03-12 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwpd/src/lib/WP6PrefixDataPacket.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 Marc Maurer (uwog@uwog.net)
12
 * Copyright (C) 2007 Fridrich Strba (fridrich_strba@bluewin.ch)
13
 *
14
 * For minor contributions see the git repository.
15
 *
16
 * Alternatively, the contents of this file may be used under the terms
17
 * of the GNU Lesser General Public License Version 2.1 or later
18
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19
 * applicable instead of those above.
20
 *
21
 * For further information visit http://libwpd.sourceforge.net
22
 */
23
24
/* "This product is not manufactured, approved, or supported by
25
 * Corel Corporation or Corel Corporation Limited."
26
 */
27
28
#include "WP6PrefixDataPacket.h"
29
#include "WP6PrefixIndice.h"
30
#include "WP6CommentAnnotationPacket.h"
31
#include "WP6GeneralTextPacket.h"
32
#include "WP6FontDescriptorPacket.h"
33
#include "WP6FillStylePacket.h"
34
#include "WP6DefaultInitialFontPacket.h"
35
#include "WP6ExtendedDocumentSummaryPacket.h"
36
#include "WP6OutlineStylePacket.h"
37
#include "WP6FileStructure.h"
38
#include "WP6GraphicsBoxStylePacket.h"
39
#include "WP6TableStylePacket.h"
40
#include "WP6GraphicsFilenamePacket.h"
41
#include "WP6GraphicsCachedFileDataPacket.h"
42
#include "WP6HyperlinkPacket.h"
43
#include "libwpd_internal.h"
44
45
WP6PrefixDataPacket::WP6PrefixDataPacket(librevenge::RVNGInputStream * /* input */, WPXEncryption * /* encryption */) :
46
17.1k
  m_dataSize(0)
47
17.1k
{
48
17.1k
}
49
50
std::shared_ptr<WP6PrefixDataPacket> WP6PrefixDataPacket::constructPrefixDataPacket(librevenge::RVNGInputStream *input, WPXEncryption *encryption, const WP6PrefixIndice &prefixIndice)
51
0
{
52
0
  try
53
0
  {
54
0
    switch (prefixIndice.getType())
55
0
    {
56
0
    case WP6_INDEX_HEADER_INITIAL_FONT:
57
0
      return std::make_shared<WP6DefaultInitialFontPacket>(input, encryption, prefixIndice.getID(),
58
0
                                                           prefixIndice.getDataOffset(), prefixIndice.getDataSize());
59
0
    case WP6_INDEX_HEADER_HYPERLINK:
60
0
      return std::make_shared<WP6HyperlinkPacket>(input, encryption, prefixIndice.getID(),
61
0
                                                  prefixIndice.getDataOffset(), prefixIndice.getDataSize());
62
0
    case WP6_INDEX_HEADER_GENERAL_WORDPERFECT_TEXT:
63
0
      return std::make_shared<WP6GeneralTextPacket>(input, encryption, prefixIndice.getID(),
64
0
                                                    prefixIndice.getDataOffset(), prefixIndice.getDataSize());
65
0
    case WP6_INDEX_HEADER_DESIRED_FONT_DESCRIPTOR_POOL:
66
0
      return std::make_shared<WP6FontDescriptorPacket>(input, encryption, prefixIndice.getID(),
67
0
                                                       prefixIndice.getDataOffset(), prefixIndice.getDataSize());
68
0
    case WP6_INDEX_HEADER_FILL_STYLE:
69
0
      return std::make_shared<WP6FillStylePacket>(input, encryption, prefixIndice.getID(),
70
0
                                                  prefixIndice.getDataOffset(), prefixIndice.getDataSize());
71
0
    case WP6_INDEX_HEADER_EXTENDED_DOCUMENT_SUMMARY:
72
0
      return std::make_shared<WP6ExtendedDocumentSummaryPacket>(input, encryption, prefixIndice.getID(),
73
0
                                                                prefixIndice.getDataOffset(), prefixIndice.getDataSize());
74
0
    case WP6_INDEX_HEADER_OUTLINE_STYLE:
75
0
      return std::make_shared<WP6OutlineStylePacket>(input, encryption, prefixIndice.getID(),
76
0
                                                     prefixIndice.getDataOffset(), prefixIndice.getDataSize());
77
0
    case WP6_INDEX_HEADER_GRAPHICS_FILENAME:
78
0
      return std::make_shared<WP6GraphicsFilenamePacket>(input, encryption, prefixIndice.getID(), prefixIndice.getFlags(),
79
0
                                                         prefixIndice.getDataOffset(), prefixIndice.getDataSize());
80
0
    case WP6_INDEX_HEADER_GRAPHICS_CACHED_FILE_DATA:
81
0
      return std::make_shared<WP6GraphicsCachedFileDataPacket>(input, encryption, prefixIndice.getID(),
82
0
                                                               prefixIndice.getDataOffset(), prefixIndice.getDataSize());
83
0
    case WP6_INDEX_HEADER_GRAPHICS_BOX_STYLE:
84
0
      return std::make_shared<WP6GraphicsBoxStylePacket>(input, encryption, prefixIndice.getID(),
85
0
                                                         prefixIndice.getDataOffset(), prefixIndice.getDataSize());
86
0
    case WP6_INDEX_HEADER_TABLE_STYLE:
87
0
      return std::make_shared<WP6TableStylePacket>(input, encryption, prefixIndice.getID(),
88
0
                                                   prefixIndice.getDataOffset(), prefixIndice.getDataSize());
89
0
    case WP6_INDEX_HEADER_COMMENT_ANNOTATION:
90
0
      return std::make_shared<WP6CommentAnnotationPacket>(input, encryption, prefixIndice.getID(),
91
0
                                                          prefixIndice.getDataOffset(), prefixIndice.getDataSize());
92
0
    default:
93
0
      break;
94
0
    }
95
0
  }
96
0
  catch (FileException)
97
0
  {
98
0
  }
99
0
  return nullptr;
100
0
}
101
102
void WP6PrefixDataPacket::_read(librevenge::RVNGInputStream *input, WPXEncryption *encryption, unsigned dataOffset, unsigned dataSize)
103
17.1k
{
104
17.1k
  m_dataSize = dataSize;
105
106
17.1k
  if (!m_dataSize)
107
0
    return;
108
109
17.1k
  input->seek(dataOffset, librevenge::RVNG_SEEK_SET);
110
111
17.1k
  _readContents(input, encryption);
112
113
  // assert that we haven't surpassed the size of the packet?
114
17.1k
}
115
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */