/src/libwpd/src/lib/WP5FontNameStringPoolPacket.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 "WP5FontNameStringPoolPacket.h" |
28 | | #include "WP5Parser.h" |
29 | | #include "libwpd_internal.h" |
30 | | |
31 | | WP5FontNameStringPoolPacket::WP5FontNameStringPoolPacket(librevenge::RVNGInputStream *input, WPXEncryption *encryption, int /* id */, unsigned dataOffset, unsigned dataSize) : |
32 | 0 | WP5GeneralPacketData(), |
33 | 0 | m_fontNameString() |
34 | 0 | { |
35 | 0 | _read(input, encryption, dataOffset, dataSize); |
36 | 0 | } |
37 | | |
38 | | WP5FontNameStringPoolPacket::~WP5FontNameStringPoolPacket() |
39 | 0 | { |
40 | 0 | } |
41 | | |
42 | | void WP5FontNameStringPoolPacket::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption, unsigned dataSize) |
43 | 0 | { |
44 | 0 | long tmpInitialOffset = input->tell(); |
45 | 0 | while (input->tell() < (long)(tmpInitialOffset + dataSize)) |
46 | 0 | { |
47 | 0 | auto offset = (unsigned)(input->tell() - tmpInitialOffset); |
48 | 0 | librevenge::RVNGString fontName = readCString(input, encryption); |
49 | 0 | m_fontNameString[offset] = fontName; |
50 | 0 | } |
51 | |
|
52 | 0 | for (std::map<unsigned int, librevenge::RVNGString>::const_iterator Iter = m_fontNameString.begin(); Iter != m_fontNameString.end(); ++Iter) |
53 | 0 | WPD_DEBUG_MSG(("WP5 Font Name String Pool Packet: offset: %i font name: %s\n", Iter->first, (Iter->second).cstr())); |
54 | 0 | } |
55 | | |
56 | | librevenge::RVNGString WP5FontNameStringPoolPacket::getFontName(const unsigned int offset) const |
57 | 0 | { |
58 | 0 | auto Iter = m_fontNameString.find(offset); |
59 | 0 | if (Iter != m_fontNameString.end()) |
60 | 0 | return Iter->second; |
61 | | // if the offset is not correct, return the default value |
62 | 0 | return librevenge::RVNGString("Times New Roman"); |
63 | 0 | } |
64 | | |
65 | | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |