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 Lesser 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."
25
#include "WP5FontGroup.h"
26
#include "WPXListener.h"
27
#include "libwpd_internal.h"
28
#include "WP5FileStructure.h"
29
#include "WP5PrefixData.h"
30
#include "WP5ListFontsUsedPacket.h"
31
#include "WP5FontNameStringPoolPacket.h"
32
#include "WP5Listener.h"
34
WP5FontGroup::WP5FontGroup(WPXInputStream *input) :
35
WP5VariableLengthGroup(),
45
void WP5FontGroup::_readContents(WPXInputStream *input)
49
case WP5_TOP_FONT_GROUP_COLOR:
50
input->seek(3, WPX_SEEK_CUR);
51
m_red = readU8(input);
52
m_green = readU8(input);
53
m_blue = readU8(input);
55
case WP5_TOP_FONT_GROUP_FONT_CHANGE:
56
input->seek(25, WPX_SEEK_CUR);
57
m_fontNumber = readU8(input);
60
input->seek(2, WPX_SEEK_CUR);
61
m_fontSize = (float)(readU16(input) / 50);
69
void WP5FontGroup::parse(WP5Listener *listener)
71
WPD_DEBUG_MSG(("WordPerfect: handling a Font group\n"));
73
uint16_t tmpFontNameOffset;
74
float tmpFontSize = 12.0f;
75
WPXString tmpFontName("Times New Roman");
79
case WP5_TOP_FONT_GROUP_COLOR:
80
listener->characterColorChange(m_red, m_green, m_blue);
82
case WP5_TOP_FONT_GROUP_FONT_CHANGE:
83
if (listener->getGeneralPacketData(15))
85
tmpFontSize = static_cast<const WP5ListFontsUsedPacket*>(listener->getGeneralPacketData(15))->getFontSize(m_fontNumber);
86
tmpFontNameOffset = static_cast<const WP5ListFontsUsedPacket*>(listener->getGeneralPacketData(15))->getFontNameOffset(m_fontNumber);
89
else if (listener->getGeneralPacketData(2))
91
tmpFontSize = static_cast<const WP5ListFontsUsedPacket*>(listener->getGeneralPacketData(2))->getFontSize(m_fontNumber);
92
tmpFontNameOffset = static_cast<const WP5ListFontsUsedPacket*>(listener->getGeneralPacketData(2))->getFontNameOffset(m_fontNumber);
96
listener->setFont(tmpFontName, tmpFontSize);
100
tmpFontName = static_cast<const WP5FontNameStringPoolPacket*>(listener->getGeneralPacketData(7))->getFontName(tmpFontNameOffset);
102
tmpFontSize = m_fontSize;
104
WPD_DEBUG_MSG(("WP5 Parsing Font Change, fontNumber %i, fontName: %s, fontSize: %.4f\n", m_fontNumber, tmpFontName.cstr(), tmpFontSize));
105
listener->setFont(tmpFontName, tmpFontSize);