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."
26
#include "WP3DefinitionGroup.h"
27
#include "WP3FileStructure.h"
28
#include "WPXFileStructure.h"
29
#include "libwpd_internal.h"
30
#include "libwpd_math.h"
32
WP3DefinitionGroup::WP3DefinitionGroup(WPXInputStream *input) :
33
WP3VariableLengthGroup()
38
WP3DefinitionGroup::~WP3DefinitionGroup()
40
// fixme delete the font name
43
void WP3DefinitionGroup::_readContents(WPXInputStream *input)
45
// this group can contain different kinds of data, thus we need to read
46
// the contents accordingly
47
switch (getSubGroup())
49
case WP3_DEFINITION_GROUP_SET_COLUMNS:
51
uint8_t tmpColType = readU8(input);
54
uint8_t tmpNumColumns = readU8(input);
56
input->seek(((2*tmpNumColumns) - 1), WPX_SEEK_CUR);
59
m_colType = readU8(input);
63
m_isFixedWidth.clear();
64
m_columnWidth.clear();
68
m_numColumns = readU8(input);
71
for (int i=0; i<((2*m_numColumns)-1); i++)
75
uint32_t tmpSpaceBetweenColumns = readU32(input, true);
76
m_isFixedWidth.push_back(true);
77
m_columnWidth.push_back((float)((double)fixedPointToWPUs(tmpSpaceBetweenColumns)/(double)WPX_NUM_WPUS_PER_INCH));
81
uint16_t tmpSizeOfColumn = readU16(input, true);
82
m_isFixedWidth.push_back(false);
83
m_columnWidth.push_back((float)((double)tmpSizeOfColumn/(double)0x10000));
90
default: /* something else we don't support, since it isn't in the docs */
95
void WP3DefinitionGroup::parse(WP3Listener *listener)
97
WPD_DEBUG_MSG(("WordPerfect: handling a Definition group\n"));
99
switch (getSubGroup())
101
case WP3_DEFINITION_GROUP_SET_COLUMNS:
102
// number of columns = {0,1} means columns off
103
if ((m_numColumns <= 1))
105
listener->columnChange(NEWSPAPER, 1, m_columnWidth, m_isFixedWidth); // the value "1" is bugus, the false bool gives you all the information you need here
111
case WP3_COLUMN_TYPE_NEWSPAPER:
112
listener->columnChange(NEWSPAPER, m_numColumns, m_columnWidth, m_isFixedWidth);
114
case WP3_COLUMN_TYPE_PARALLEL:
115
listener->columnChange(PARALLEL, m_numColumns, m_columnWidth, m_isFixedWidth);
117
case WP3_COLUMN_TYPE_EXTENDED:
118
listener->columnChange(PARALLEL_PROTECT, m_numColumns, m_columnWidth, m_isFixedWidth);
120
default: // something else we don't support, since it isn't in the docs
125
default: // something else we don't support, since it isn't in the docs