2
* Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18
* For further information visit http://libwpd.sourceforge.net
21
/* "This product is not manufactured, approved, or supported by
22
* Corel Corporation or Corel Corporation Limited."
26
#include "WP5ListFontsUsedPacket.h"
27
#include "WP5FileStructure.h"
28
#include "WP5Parser.h"
29
#include "libwpd_internal.h"
31
WP5ListFontsUsedPacket::WP5ListFontsUsedPacket(WPXInputStream *input, int id, uint32_t dataOffset, uint32_t dataSize, uint16_t packetType) :
32
WP5GeneralPacketData(input),
33
m_packetType(packetType)
35
_read(input, dataOffset, dataSize);
38
WP5ListFontsUsedPacket::~WP5ListFontsUsedPacket()
42
void WP5ListFontsUsedPacket::_readContents(WPXInputStream *input, uint32_t dataSize)
44
int numFonts = (int)(dataSize / 86); // 86 == size of the structure describing the font
45
WPD_DEBUG_MSG(("WP5 List Fonts Used Packet, data size: %i, number fonts: %i\n", dataSize, numFonts));
46
int tempFontNameOffset;
48
for (int i=0; i<numFonts; i++)
50
input->seek(18, WPX_SEEK_CUR);
51
tempFontNameOffset=(int)readU16(input);
52
if (m_packetType == WP50_LIST_FONTS_USED_PACKET)
54
input->seek(2, WPX_SEEK_CUR);
55
tempFontSize=(float)(readU16(input) / 50);
56
input->seek(62, WPX_SEEK_CUR);
60
input->seek(27, WPX_SEEK_CUR);
61
tempFontSize=(float)(readU16(input) / 50);
62
input->seek(37, WPX_SEEK_CUR);
64
WPD_DEBUG_MSG(("WP5 List Fonts Used Packet, font number: %i, font name offset: %i, font size, %.4f\n", i, tempFontNameOffset, tempFontSize));
65
fontNameOffset.push_back(tempFontNameOffset);
66
fontSize.push_back(tempFontSize);
70
int WP5ListFontsUsedPacket::getFontNameOffset(const int fontNumber) const
72
if ((fontNumber >= 0) && (fontNumber < fontNameOffset.size()))
73
return fontNameOffset[fontNumber];
77
float WP5ListFontsUsedPacket::getFontSize(const int fontNumber) const
79
if ((fontNumber >= 0) && (fontNumber < fontSize.size()))
80
return fontSize[fontNumber];