/src/libwpd/src/lib/WP5TableEOLGroup.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) 2002 William Lachance (wrlach@gmail.com) |
11 | | * Copyright (C) 2002 Marc Maurer (uwog@uwog.net) |
12 | | * Copyright (C) 2004 Fridrich Strba (fridrich.strba@bluewin.ch) |
13 | | * |
14 | | * For minor contributions see the git repository. |
15 | | * |
16 | | * Alternatively, the contents of this file may be used under the terms |
17 | | * of the GNU Lesser General Public License Version 2.1 or later |
18 | | * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are |
19 | | * applicable instead of those above. |
20 | | * |
21 | | * For further information visit http://libwpd.sourceforge.net |
22 | | */ |
23 | | |
24 | | /* "This product is not manufactured, approved, or supported by |
25 | | * Corel Corporation or Corel Corporation Limited." |
26 | | */ |
27 | | |
28 | | #include "WP5TableEOLGroup.h" |
29 | | #include "WP5FileStructure.h" |
30 | | #include "WP5Listener.h" |
31 | | #include "libwpd_internal.h" |
32 | | |
33 | | WP5TableEOLGroup::WP5TableEOLGroup(librevenge::RVNGInputStream *input, WPXEncryption *encryption) : |
34 | 3.62k | WP5VariableLengthGroup(), |
35 | 3.62k | m_cellVerticalAlignment(0), |
36 | 3.62k | m_useCellAttributes(false), |
37 | 3.62k | m_useCellJustification(false), |
38 | 3.62k | m_columnNumber(0), |
39 | 3.62k | m_colSpan(0), |
40 | 3.62k | m_rowSpan(0), |
41 | 3.62k | m_spannedFromAbove(false), |
42 | 3.62k | m_cellAttributes(0), |
43 | 3.62k | m_cellJustification(0) |
44 | 3.62k | { |
45 | 3.62k | _read(input, encryption); |
46 | 3.62k | } |
47 | | |
48 | | WP5TableEOLGroup::~WP5TableEOLGroup() |
49 | 3.39k | { |
50 | 3.39k | } |
51 | | |
52 | | void WP5TableEOLGroup::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption) |
53 | 3.62k | { |
54 | 3.62k | unsigned char tmpFlags, tmpColumnSpanning; |
55 | 3.62k | switch (getSubGroup()) |
56 | 3.62k | { |
57 | 1.62k | case WP5_TABLE_EOL_GROUP_BEGINNING_OF_COLUMN_AT_EOL: |
58 | 1.62k | tmpFlags = readU8(input, encryption); |
59 | 1.62k | if ((tmpFlags & 0x01) == 0x01) |
60 | 402 | m_useCellJustification = true; |
61 | 1.62k | if ((tmpFlags & 0x02) == 0x02) |
62 | 268 | m_useCellAttributes = true; |
63 | 1.62k | m_cellVerticalAlignment = (unsigned char)((tmpFlags & 0x0C) >> 2); |
64 | 1.62k | m_columnNumber = readU8(input, encryption); |
65 | 1.62k | tmpColumnSpanning = readU8(input, encryption); |
66 | 1.62k | m_colSpan = tmpColumnSpanning & 0x7F; |
67 | 1.62k | if ((tmpColumnSpanning & 0x80) == 0x80) |
68 | 771 | m_spannedFromAbove = true; |
69 | 1.62k | m_rowSpan = readU8(input, encryption); |
70 | 1.62k | input->seek(4, librevenge::RVNG_SEEK_CUR); |
71 | 1.62k | m_cellAttributes = readU16(input, encryption); |
72 | 1.62k | m_cellJustification = readU8(input, encryption); |
73 | 1.62k | break; |
74 | 230 | case WP5_TABLE_EOL_GROUP_BEGINNING_OF_ROW_AT_EOL: |
75 | 230 | break; |
76 | 1.02k | case WP5_TABLE_EOL_GROUP_TABLE_OFF_AT_EOL: |
77 | 1.02k | break; |
78 | 742 | default: /* something else we don't support, since it isn't in the docs */ |
79 | 742 | break; |
80 | 3.62k | } |
81 | 3.62k | } |
82 | | |
83 | | void WP5TableEOLGroup::parse(WP5Listener *listener) |
84 | 3.39k | { |
85 | 3.39k | WPD_DEBUG_MSG(("WordPerfect: handling a Table EOL group\n")); |
86 | | |
87 | 3.39k | switch (getSubGroup()) |
88 | 3.39k | { |
89 | 1.39k | case WP5_TABLE_EOL_GROUP_BEGINNING_OF_COLUMN_AT_EOL: |
90 | 1.39k | if (!m_spannedFromAbove) |
91 | 823 | { |
92 | 823 | RGBSColor tmpCellBorderColor(0x00, 0x00, 0x00, 0x64); |
93 | 823 | listener->insertCell(m_colSpan, m_rowSpan, 0x00, nullptr, nullptr, &tmpCellBorderColor, |
94 | 823 | TOP, m_useCellAttributes, m_cellAttributes); |
95 | 823 | } |
96 | 1.39k | break; |
97 | 230 | case WP5_TABLE_EOL_GROUP_BEGINNING_OF_ROW_AT_EOL: |
98 | 230 | listener->insertRow(0, true, false); |
99 | 230 | break; |
100 | 1.02k | case WP5_TABLE_EOL_GROUP_TABLE_OFF_AT_EOL: |
101 | 1.02k | listener->endTable(); |
102 | 1.02k | break; |
103 | 742 | default: // something else we don't support, since it isn't in the docs |
104 | 742 | break; |
105 | 3.39k | } |
106 | 3.39k | } |
107 | | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |