~ubuntu-branches/ubuntu/trusty/libwpd/trusty

« back to all changes in this revision

Viewing changes to src/lib/WP5ListFontsUsedPacket.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Rene Engelhard
  • Date: 2006-06-11 23:56:17 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060611235617-ce504k38fuqe8twa
Tags: 0.8.5-2
* dpatch'ize 
* add patch from upstream fixing WP5 font handling regression

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* libwpd
 
2
 * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
 
3
 *  
 
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.
 
8
 *
 
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.
 
13
 *
 
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
 
17
 *
 
18
 * For further information visit http://libwpd.sourceforge.net
 
19
 */
 
20
 
 
21
/* "This product is not manufactured, approved, or supported by 
 
22
 * Corel Corporation or Corel Corporation Limited."
 
23
 */
 
24
#include <string.h>
 
25
 
 
26
#include "WP5ListFontsUsedPacket.h"
 
27
#include "WP5FileStructure.h"
 
28
#include "WP5Parser.h"
 
29
#include "libwpd_internal.h"
 
30
 
 
31
WP5ListFontsUsedPacket::WP5ListFontsUsedPacket(WPXInputStream *input, int id, uint32_t dataOffset, uint32_t dataSize, uint16_t packetType) :
 
32
        WP5GeneralPacketData(input),
 
33
        m_packetType(packetType)
 
34
{       
 
35
        _read(input, dataOffset, dataSize);
 
36
}
 
37
 
 
38
WP5ListFontsUsedPacket::~WP5ListFontsUsedPacket()
 
39
{
 
40
}
 
41
 
 
42
void WP5ListFontsUsedPacket::_readContents(WPXInputStream *input, uint32_t dataSize)
 
43
{
 
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;
 
47
        float tempFontSize;
 
48
        for (int i=0; i<numFonts; i++)
 
49
        {
 
50
                input->seek(18, WPX_SEEK_CUR);
 
51
                tempFontNameOffset=(int)readU16(input);
 
52
                if (m_packetType == WP50_LIST_FONTS_USED_PACKET)
 
53
                {
 
54
                        input->seek(2, WPX_SEEK_CUR);
 
55
                        tempFontSize=(float)(readU16(input) / 50);
 
56
                        input->seek(62, WPX_SEEK_CUR);
 
57
                }
 
58
                else
 
59
                {
 
60
                        input->seek(27, WPX_SEEK_CUR);
 
61
                        tempFontSize=(float)(readU16(input) / 50);
 
62
                        input->seek(37, WPX_SEEK_CUR);
 
63
                }
 
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);
 
67
        }
 
68
}
 
69
 
 
70
int WP5ListFontsUsedPacket::getFontNameOffset(const int fontNumber) const
 
71
{
 
72
        if ((fontNumber >= 0) && (fontNumber < fontNameOffset.size()))
 
73
                return fontNameOffset[fontNumber];
 
74
        return 0;
 
75
}
 
76
 
 
77
float WP5ListFontsUsedPacket::getFontSize(const int fontNumber) const
 
78
{
 
79
        if ((fontNumber >= 0) && (fontNumber < fontSize.size()))
 
80
                return fontSize[fontNumber];
 
81
        return 0.0f;
 
82
}
 
83