/src/libwpd/src/lib/WP5ListFontsUsedPacket.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) 2005 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 | | #include <string.h> |
26 | | |
27 | | #include "WP5ListFontsUsedPacket.h" |
28 | | #include "WP5FileStructure.h" |
29 | | #include "WP5Parser.h" |
30 | | #include "libwpd_internal.h" |
31 | | |
32 | | WP5ListFontsUsedPacket::WP5ListFontsUsedPacket(librevenge::RVNGInputStream *input, WPXEncryption *encryption, int /* id */, unsigned dataOffset, unsigned dataSize, unsigned short packetType) : |
33 | 0 | WP5GeneralPacketData(), |
34 | 0 | m_packetType(packetType), |
35 | 0 | m_fontNameOffset(), |
36 | 0 | m_fontSize() |
37 | 0 | { |
38 | 0 | _read(input, encryption, dataOffset, dataSize); |
39 | 0 | } |
40 | | |
41 | | WP5ListFontsUsedPacket::~WP5ListFontsUsedPacket() |
42 | 0 | { |
43 | 0 | } |
44 | | |
45 | | void WP5ListFontsUsedPacket::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption, unsigned dataSize) |
46 | 0 | { |
47 | 0 | unsigned numFonts = dataSize / 86; // 86 == size of the structure describing the font |
48 | 0 | WPD_DEBUG_MSG(("WP5 List Fonts Used Packet, data size: %u, number fonts: %u\n", dataSize, numFonts)); |
49 | 0 | unsigned tempFontNameOffset; |
50 | 0 | double tempFontSize; |
51 | 0 | for (unsigned i=0; i<numFonts; i++) |
52 | 0 | { |
53 | 0 | input->seek(18, librevenge::RVNG_SEEK_CUR); |
54 | 0 | tempFontNameOffset=readU16(input, encryption); |
55 | 0 | if (m_packetType == WP50_LIST_FONTS_USED_PACKET) |
56 | 0 | { |
57 | 0 | input->seek(2, librevenge::RVNG_SEEK_CUR); |
58 | 0 | tempFontSize=(double)(readU16(input, encryption) / 50); |
59 | 0 | input->seek(62, librevenge::RVNG_SEEK_CUR); |
60 | 0 | } |
61 | 0 | else |
62 | 0 | { |
63 | 0 | input->seek(27, librevenge::RVNG_SEEK_CUR); |
64 | 0 | tempFontSize=(double)(readU16(input, encryption) / 50); |
65 | 0 | input->seek(37, librevenge::RVNG_SEEK_CUR); |
66 | 0 | } |
67 | 0 | WPD_DEBUG_MSG(("WP5 List Fonts Used Packet, font number: %u, font name offset: %u, font size, %.4f\n", i, tempFontNameOffset, tempFontSize)); |
68 | 0 | m_fontNameOffset.push_back(tempFontNameOffset); |
69 | 0 | m_fontSize.push_back(tempFontSize); |
70 | 0 | } |
71 | 0 | } |
72 | | |
73 | | unsigned WP5ListFontsUsedPacket::getFontNameOffset(unsigned fontNumber) const |
74 | 0 | { |
75 | 0 | if (fontNumber < m_fontNameOffset.size()) |
76 | 0 | return m_fontNameOffset[fontNumber]; |
77 | 0 | return 0; |
78 | 0 | } |
79 | | |
80 | | double WP5ListFontsUsedPacket::getFontSize(unsigned fontNumber) const |
81 | 0 | { |
82 | 0 | if (fontNumber < m_fontSize.size()) |
83 | 0 | return m_fontSize[fontNumber]; |
84 | 0 | return 0.0; |
85 | 0 | } |
86 | | |
87 | | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |