/src/libwpd/src/lib/WP3WindowGroup.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) 2005 Fridrich Strba (fridrich.strba@bluewin.ch) |
11 | | * |
12 | | * For minor contributions see the git repository. |
13 | | * |
14 | | * Alternatively, the contents of this file may be used under the terms |
15 | | * of the GNU Lesser General Public License Version 2.1 or later |
16 | | * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are |
17 | | * applicable instead of those above. |
18 | | * |
19 | | * For further information visit http://libwpd.sourceforge.net |
20 | | */ |
21 | | |
22 | | /* "This product is not manufactured, approved, or supported by |
23 | | * Corel Corporation or Corel Corporation Limited." |
24 | | */ |
25 | | |
26 | | #include "WP3WindowGroup.h" |
27 | | #include "WP3FileStructure.h" |
28 | | #include "WPXFileStructure.h" |
29 | | #include "libwpd_internal.h" |
30 | | #include "WP3Listener.h" |
31 | | #include "WP3ResourceFork.h" |
32 | | |
33 | | WP3WindowGroup::WP3WindowGroup(librevenge::RVNGInputStream *input, WPXEncryption *encryption) : |
34 | 0 | WP3VariableLengthGroup(), |
35 | 0 | m_figureFlags(0), |
36 | 0 | m_leftColumn(0), |
37 | 0 | m_rightColumn(0), |
38 | 0 | m_boxType(0xFF), |
39 | 0 | m_width(0.0), |
40 | 0 | m_height(0.0), |
41 | 0 | m_horizontalOffset(0.0), |
42 | 0 | m_verticalOffset(0.0), |
43 | 0 | m_resourceID(0), |
44 | 0 | m_subDocument(), |
45 | 0 | m_caption() |
46 | 0 | { |
47 | 0 | _read(input, encryption); |
48 | 0 | } |
49 | | |
50 | | WP3WindowGroup::~WP3WindowGroup() |
51 | 0 | { |
52 | 0 | } |
53 | | |
54 | | void WP3WindowGroup::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption) |
55 | 0 | { |
56 | 0 | switch (getSubGroup()) |
57 | 0 | { |
58 | 0 | case WP3_WINDOW_GROUP_FIGURE_BOX_FUNCTION: |
59 | 0 | case WP3_WINDOW_GROUP_TABLE_BOX_FUNCTION: |
60 | 0 | case WP3_WINDOW_GROUP_TEXT_BOX_FUNCTION: |
61 | 0 | case WP3_WINDOW_GROUP_USER_BOX_FUNCTION: |
62 | 0 | case WP3_WINDOW_GROUP_EQUATION_BOX_FUNCTION: |
63 | 0 | case WP3_WINDOW_GROUP_HTML_IMAGE_BOX_FUNCTION: |
64 | 0 | { |
65 | 0 | input->seek(14, librevenge::RVNG_SEEK_CUR); |
66 | 0 | m_figureFlags = readU16(input, encryption, true); // picture flags |
67 | 0 | input->seek(2, librevenge::RVNG_SEEK_CUR); |
68 | 0 | m_leftColumn = readU8(input, encryption); // left align column |
69 | 0 | m_rightColumn = readU8(input, encryption); // right align column |
70 | 0 | input->seek(28, librevenge::RVNG_SEEK_CUR); |
71 | 0 | m_boxType = readU8(input, encryption); |
72 | 0 | input->seek(1, librevenge::RVNG_SEEK_CUR); |
73 | 0 | m_resourceID = readU16(input, encryption, true); |
74 | 0 | m_verticalOffset = fixedPointToDouble(readU32(input, encryption, true)); |
75 | 0 | m_horizontalOffset = fixedPointToDouble(readU32(input, encryption, true)); |
76 | 0 | m_width = fixedPointToDouble(readU32(input, encryption, true)); |
77 | 0 | m_height = fixedPointToDouble(readU32(input, encryption, true)); |
78 | 0 | input->seek(9, librevenge::RVNG_SEEK_CUR); |
79 | 0 | unsigned char tmpNumSubRect = readU8(input, encryption); |
80 | 0 | input->seek(tmpNumSubRect * 8, librevenge::RVNG_SEEK_CUR); |
81 | 0 | unsigned short tmpBoxCaptionSize = readU16(input, encryption, true); |
82 | 0 | if (tmpBoxCaptionSize) |
83 | 0 | m_caption.reset(new WP3SubDocument(input, encryption, tmpBoxCaptionSize)); |
84 | 0 | unsigned short tmpTextBoxLength = readU16(input, encryption, true); |
85 | 0 | if (tmpTextBoxLength) |
86 | 0 | m_subDocument.reset(new WP3SubDocument(input, encryption, tmpTextBoxLength)); |
87 | 0 | } |
88 | 0 | break; |
89 | | |
90 | 0 | case WP3_WINDOW_GROUP_HORIZONTAL_LINE: |
91 | 0 | break; |
92 | | |
93 | 0 | default: /* something else we don't support, since it isn't in the docs */ |
94 | 0 | break; |
95 | 0 | } |
96 | 0 | } |
97 | | |
98 | | void WP3WindowGroup::parse(WP3Listener *listener) |
99 | 0 | { |
100 | 0 | WPD_DEBUG_MSG(("WordPerfect: handling a Window group\n")); |
101 | |
|
102 | 0 | switch (getSubGroup()) |
103 | 0 | { |
104 | 0 | case WP3_WINDOW_GROUP_FIGURE_BOX_FUNCTION: |
105 | 0 | case WP3_WINDOW_GROUP_TABLE_BOX_FUNCTION: |
106 | 0 | case WP3_WINDOW_GROUP_TEXT_BOX_FUNCTION: |
107 | 0 | case WP3_WINDOW_GROUP_USER_BOX_FUNCTION: |
108 | 0 | case WP3_WINDOW_GROUP_EQUATION_BOX_FUNCTION: |
109 | 0 | case WP3_WINDOW_GROUP_HTML_IMAGE_BOX_FUNCTION: |
110 | 0 | if (m_boxType == 0x02) |
111 | 0 | { |
112 | 0 | librevenge::RVNGBinaryData tmpWBOXData; |
113 | 0 | for (int i=0; i < 512; i++) |
114 | 0 | tmpWBOXData.append((unsigned char)0); |
115 | 0 | if (listener->getResourceFork() && listener->getResourceFork()->getResource(0x57424f58, m_resourceID)) // WBOX resource |
116 | 0 | { |
117 | 0 | tmpWBOXData.append(listener->getResourceFork()->getResource(0x57424f58, m_resourceID)->getResourceData()); |
118 | 0 | listener->insertPicture(m_height, m_width, m_verticalOffset, m_horizontalOffset, m_leftColumn, m_rightColumn, m_figureFlags, tmpWBOXData); |
119 | 0 | } |
120 | 0 | } |
121 | 0 | else if (m_boxType == 0x01 || m_boxType == 0x03) |
122 | 0 | { |
123 | 0 | librevenge::RVNGBinaryData tmpPICTData; |
124 | 0 | for (int i=0; i < 512; i++) |
125 | 0 | tmpPICTData.append((unsigned char)0); |
126 | 0 | if (listener->getResourceFork() && listener->getResourceFork()->getResource(0x50494354, m_resourceID)) // replacement picture in PICT format |
127 | 0 | { |
128 | 0 | tmpPICTData.append(listener->getResourceFork()->getResource(0x50494354, m_resourceID)->getResourceData()); |
129 | 0 | listener->insertPicture(m_height, m_width, m_verticalOffset, m_horizontalOffset, m_leftColumn, m_rightColumn, m_figureFlags, tmpPICTData); |
130 | 0 | } |
131 | 0 | } |
132 | 0 | else if (m_boxType == 0x00) |
133 | 0 | { |
134 | 0 | if (m_subDocument || m_caption) |
135 | 0 | listener->insertTextBox(m_height, m_width, m_verticalOffset, m_horizontalOffset, m_leftColumn, m_rightColumn, m_figureFlags, m_subDocument.get(), m_caption.get()); |
136 | 0 | } |
137 | 0 | else if (m_boxType == 0x04 || m_boxType == 0x05) |
138 | 0 | { |
139 | 0 | if (m_subDocument || m_caption) |
140 | 0 | listener->insertWP51Table(m_height, m_width, m_verticalOffset, m_horizontalOffset, m_leftColumn, m_rightColumn, m_figureFlags, m_subDocument.get(), m_caption.get()); |
141 | 0 | } |
142 | 0 | break; |
143 | | |
144 | 0 | case WP3_WINDOW_GROUP_HORIZONTAL_LINE: |
145 | 0 | break; |
146 | | |
147 | 0 | default: |
148 | 0 | break; |
149 | 0 | } |
150 | 0 | } |
151 | | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |