/src/libwpd/src/lib/WP6SingleByteFunction.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 "WP6SingleByteFunction.h" |
29 | | #include "WP6FileStructure.h" |
30 | | #include "WP6Listener.h" |
31 | | #include "libwpd_internal.h" |
32 | | |
33 | | WP6SingleByteFunction *WP6SingleByteFunction::constructSingleByteFunction(librevenge::RVNGInputStream * /* input */, WPXEncryption * /* encryption */, unsigned char groupID) |
34 | 9.90M | { |
35 | | |
36 | 9.90M | switch (groupID) |
37 | 9.90M | { |
38 | 26.5k | case WP6_TOP_SOFT_EOL: |
39 | 161k | case WP6_TOP_SOFT_EOL_AT_EOC: |
40 | 702k | case WP6_TOP_SOFT_EOL_AT_EOC_AT_EOP: |
41 | 820k | case WP6_TOP_SOFT_SPACE: |
42 | 820k | return new WP6SpaceFunction(); |
43 | | |
44 | 37.4k | case WP6_TOP_HARD_SPACE: |
45 | 37.4k | return new WP6HardSpaceFunction(); |
46 | | |
47 | 26.3k | case WP6_TOP_SOFT_HYPHEN_IN_LINE: |
48 | 45.3k | case WP6_TOP_SOFT_HYPHEN_AT_EOL: |
49 | 45.3k | return new WP6SoftHyphenFunction(); |
50 | | |
51 | 34.5k | case WP6_TOP_HARD_HYPHEN: |
52 | 34.5k | return new WP6HyphenFunction(); |
53 | | |
54 | 29.9k | case WP6_TOP_HARD_EOL: |
55 | 170k | case WP6_TOP_HARD_EOL_AT_EOC: |
56 | 226k | case WP6_TOP_HARD_EOL_AT_EOC_AT_EOP: |
57 | 279k | case WP6_TOP_DORMANT_HARD_RETURN: |
58 | 371k | case WP6_TOP_DELETABLE_HARD_EOL: |
59 | 613k | case WP6_TOP_DELETABLE_HARD_EOL_AT_EOC: |
60 | 659k | case WP6_TOP_DELETABLE_HARD_EOL_AT_EOC_AT_EOP: |
61 | 659k | return new WP6EOLFunction(); |
62 | | |
63 | 17.5k | case WP6_TOP_TABLE_OFF_AT_EOC: |
64 | 79.6k | case WP6_TOP_TABLE_OFF: |
65 | 79.6k | return new WP6TableOffFunction(); |
66 | | |
67 | 60.7k | case WP6_TOP_TABLE_OFF_AT_EOC_AT_EOP: |
68 | 60.7k | return new WP6TableOffAtSoftEOPFunction(); |
69 | | |
70 | 74.1k | case WP6_TOP_TABLE_ROW_AT_EOC: |
71 | 150k | case WP6_TOP_TABLE_ROW: |
72 | 150k | return new WP6TableRowFunction(); |
73 | | |
74 | 1.46M | case WP6_TOP_TABLE_ROW_AT_HARD_EOC: |
75 | 1.46M | return new WP6TableRowAtEOCFunction(); |
76 | | |
77 | 598k | case WP6_TOP_TABLE_ROW_AT_EOC_AT_EOP: |
78 | 598k | return new WP6TableRowAtSoftEOPFunction(); |
79 | | |
80 | 3.00M | case WP6_TOP_TABLE_ROW_AT_HARD_EOP: |
81 | 3.02M | case WP6_TOP_TABLE_ROW_AT_HARD_EOC_AT_HARD_EOP: |
82 | 3.02M | return new WP6TableRowAtEOPFunction(); |
83 | | |
84 | 602k | case WP6_TOP_TABLE_CELL: |
85 | 602k | return new WP6TableCellFunction(); |
86 | | |
87 | 17.1k | case WP6_TOP_HARD_EOC: |
88 | 65.8k | case WP6_TOP_HARD_EOC_AT_EOP: |
89 | 87.5k | case WP6_TOP_DELETABLE_HARD_EOC: |
90 | 103k | case WP6_TOP_DELETABLE_HARD_EOC_AT_EOP: |
91 | 103k | return new WP6EOCFunction(); |
92 | | |
93 | 86.9k | case WP6_TOP_HARD_EOP: |
94 | 1.16M | case WP6_TOP_DELETABLE_HARD_EOP: |
95 | 1.16M | return new WP6EOPFunction(); |
96 | | |
97 | | // Add the remaining cases here |
98 | 1.05M | default: |
99 | | // should not happen |
100 | 1.05M | return nullptr; |
101 | 9.90M | } |
102 | 9.90M | } |
103 | | |
104 | | void WP6SpaceFunction::parse(WP6Listener *listener) |
105 | 820k | { |
106 | 820k | listener->insertCharacter((unsigned) ' '); |
107 | 820k | } |
108 | | |
109 | | void WP6HardSpaceFunction::parse(WP6Listener *listener) |
110 | 37.4k | { |
111 | 37.4k | listener->insertCharacter((unsigned) 0xa0); |
112 | 37.4k | } |
113 | | |
114 | | void WP6SoftHyphenFunction::parse(WP6Listener *listener) |
115 | 45.3k | { |
116 | 45.3k | listener->insertCharacter((unsigned) 0xad); |
117 | 45.3k | } |
118 | | |
119 | | void WP6EOLFunction::parse(WP6Listener *listener) |
120 | 659k | { |
121 | 659k | listener->insertEOL(); |
122 | 659k | } |
123 | | |
124 | | void WP6EOCFunction::parse(WP6Listener *listener) |
125 | 103k | { |
126 | 103k | listener->insertBreak(WPX_COLUMN_BREAK); |
127 | 103k | } |
128 | | |
129 | | void WP6EOPFunction::parse(WP6Listener *listener) |
130 | 1.16M | { |
131 | 1.16M | listener->insertBreak(WPX_PAGE_BREAK); |
132 | 1.16M | } |
133 | | |
134 | | void WP6SoftEOPFunction::parse(WP6Listener *listener) |
135 | 0 | { |
136 | 0 | listener->insertBreak(WPX_SOFT_PAGE_BREAK); |
137 | 0 | } |
138 | | |
139 | | void WP6HyphenFunction::parse(WP6Listener *listener) |
140 | 34.5k | { |
141 | 34.5k | listener->insertCharacter((unsigned) '-'); |
142 | 34.5k | } |
143 | | |
144 | | void WP6TableRowFunction::parse(WP6Listener *listener) |
145 | 150k | { |
146 | | // use default values: if they were not default values, WordPerfect |
147 | | // would use the multi-byte variant of this function |
148 | 150k | listener->insertRow(0x0000, true, false); |
149 | 150k | RGBSColor tmpCellBorderColor(0x00, 0x00, 0x00, 0x64); |
150 | 150k | listener->insertCell(1, 1, 0x00, nullptr, nullptr, &tmpCellBorderColor, TOP, false, 0x00000000); |
151 | 150k | } |
152 | | |
153 | | void WP6TableCellFunction::parse(WP6Listener *listener) |
154 | 602k | { |
155 | | // default values |
156 | 602k | RGBSColor tmpCellBorderColor(0x00, 0x00, 0x00, 0x64); |
157 | 602k | listener->insertCell(1, 1, 0x00, nullptr, nullptr, &tmpCellBorderColor, TOP, false, 0x00000000); |
158 | 602k | } |
159 | | |
160 | | void WP6TableOffFunction::parse(WP6Listener *listener) |
161 | 79.6k | { |
162 | 79.6k | listener->endTable(); |
163 | 79.6k | } |
164 | | |
165 | | void WP6TableOffAtSoftEOPFunction::parse(WP6Listener *listener) |
166 | 60.7k | { |
167 | 60.7k | listener->endTable(); |
168 | 60.7k | listener->insertBreak(WPX_SOFT_PAGE_BREAK); |
169 | 60.7k | } |
170 | | |
171 | | void WP6TableRowAtSoftEOPFunction::parse(WP6Listener *listener) |
172 | 598k | { |
173 | | // use default values: if they were not default values, WordPerfect |
174 | | // would use the multi-byte variant of this function |
175 | 598k | listener->insertRow(0x0000, true, false); |
176 | 598k | RGBSColor tmpCellBorderColor(0x00, 0x00, 0x00, 0x64); |
177 | 598k | listener->insertCell(1, 1, 0x00, nullptr, nullptr, &tmpCellBorderColor, TOP, false, 0x00000000); |
178 | 598k | listener->insertBreak(WPX_SOFT_PAGE_BREAK); |
179 | 598k | } |
180 | | |
181 | | void WP6TableRowAtEOPFunction::parse(WP6Listener *listener) |
182 | 3.02M | { |
183 | | // use default values: if they were not default values, WordPerfect |
184 | | // would use the multi-byte variant of this function |
185 | 3.02M | listener->insertRow(0x0000, true, false); |
186 | 3.02M | RGBSColor tmpCellBorderColor(0x00, 0x00, 0x00, 0x64); |
187 | 3.02M | listener->insertCell(1, 1, 0x00, nullptr, nullptr, &tmpCellBorderColor, TOP, false, 0x00000000); |
188 | 3.02M | listener->insertBreak(WPX_PAGE_BREAK); |
189 | 3.02M | } |
190 | | |
191 | | void WP6TableRowAtEOCFunction::parse(WP6Listener *listener) |
192 | 1.46M | { |
193 | | // use default values: if they were not default values, WordPerfect |
194 | | // would use the multi-byte variant of this function |
195 | 1.46M | listener->insertRow(0x0000, true, false); |
196 | 1.46M | RGBSColor tmpCellBorderColor(0x00, 0x00, 0x00, 0x64); |
197 | 1.46M | listener->insertCell(1, 1, 0x00, nullptr, nullptr, &tmpCellBorderColor, TOP, false, 0x00000000); |
198 | 1.46M | listener->insertBreak(WPX_COLUMN_BREAK); |
199 | 1.46M | } |
200 | | |
201 | | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |