/src/libmwaw/src/lib/MWAWParagraph.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
2 | | |
3 | | /* libmwaw |
4 | | * Version: MPL 2.0 / LGPLv2+ |
5 | | * |
6 | | * The contents of this file are subject to the Mozilla Public License Version |
7 | | * 2.0 (the "License"); you may not use this file except in compliance with |
8 | | * the License or as specified alternatively below. You may obtain a copy of |
9 | | * the License at http://www.mozilla.org/MPL/ |
10 | | * |
11 | | * Software distributed under the License is distributed on an "AS IS" basis, |
12 | | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
13 | | * for the specific language governing rights and limitations under the |
14 | | * License. |
15 | | * |
16 | | * Major Contributor(s): |
17 | | * Copyright (C) 2002 William Lachance (wrlach@gmail.com) |
18 | | * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net) |
19 | | * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch) |
20 | | * Copyright (C) 2006, 2007 Andrew Ziem |
21 | | * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr) |
22 | | * |
23 | | * |
24 | | * All Rights Reserved. |
25 | | * |
26 | | * For minor contributions see the git repository. |
27 | | * |
28 | | * Alternatively, the contents of this file may be used under the terms of |
29 | | * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
30 | | * in which case the provisions of the LGPLv2+ are applicable |
31 | | * instead of those above. |
32 | | */ |
33 | | |
34 | | #include <map> |
35 | | |
36 | | #include <librevenge/librevenge.h> |
37 | | |
38 | | #include "libmwaw_internal.hxx" |
39 | | |
40 | | #include "MWAWList.hxx" |
41 | | #include "MWAWPosition.hxx" |
42 | | |
43 | | #include "MWAWParagraph.hxx" |
44 | | |
45 | | //////////////////////////////////////////////////////////// |
46 | | // tabstop |
47 | | //////////////////////////////////////////////////////////// |
48 | | void MWAWTabStop::addTo(librevenge::RVNGPropertyListVector &propList, double decalX) const |
49 | 22.4M | { |
50 | 22.4M | librevenge::RVNGPropertyList tab; |
51 | | |
52 | | // type |
53 | 22.4M | switch (m_alignment) { |
54 | 1.19M | case RIGHT: |
55 | 1.19M | tab.insert("style:type", "right"); |
56 | 1.19M | break; |
57 | 1.50M | case CENTER: |
58 | 1.50M | tab.insert("style:type", "center"); |
59 | 1.50M | break; |
60 | 1.73M | case DECIMAL: |
61 | 1.73M | tab.insert("style:type", "char"); |
62 | 1.73M | if (m_decimalCharacter) { |
63 | 1.73M | librevenge::RVNGString sDecimal; |
64 | 1.73M | libmwaw::appendUnicode(m_decimalCharacter, sDecimal); |
65 | 1.73M | tab.insert("style:char", sDecimal); |
66 | 1.73M | } |
67 | 0 | else |
68 | 0 | tab.insert("style:char", "."); |
69 | 1.73M | break; |
70 | 17.9M | case LEFT: |
71 | 17.9M | case BAR: // BAR is not handled in OO |
72 | | #if !defined(__clang__) |
73 | | default: |
74 | | #endif |
75 | 17.9M | break; |
76 | 22.4M | } |
77 | | |
78 | | // leader character |
79 | 22.4M | if (m_leaderCharacter != 0x0000) { |
80 | 949k | librevenge::RVNGString sLeader; |
81 | 949k | libmwaw::appendUnicode(m_leaderCharacter, sLeader); |
82 | 949k | tab.insert("style:leader-text", sLeader); |
83 | 949k | tab.insert("style:leader-style", "solid"); |
84 | 949k | } |
85 | | |
86 | | // position |
87 | 22.4M | double position = m_position+decalX; |
88 | 22.4M | if (position < 0.00005 && position > -0.00005) |
89 | 6.14M | position = 0.0; |
90 | 22.4M | tab.insert("style:position", position, librevenge::RVNG_INCH); |
91 | | |
92 | 22.4M | propList.append(tab); |
93 | 22.4M | } |
94 | | |
95 | | int MWAWTabStop::cmp(MWAWTabStop const &tabs) const |
96 | 7.22M | { |
97 | 7.22M | if (m_position < tabs.m_position) return -1; |
98 | 7.18M | if (m_position > tabs.m_position) return 1; |
99 | 7.10M | if (m_alignment < tabs.m_alignment) return -1; |
100 | 7.07M | if (m_alignment > tabs.m_alignment) return 1; |
101 | 7.04M | if (m_leaderCharacter < tabs.m_leaderCharacter) return -1; |
102 | 7.04M | if (m_leaderCharacter > tabs.m_leaderCharacter) return 1; |
103 | 7.04M | if (m_decimalCharacter < tabs.m_decimalCharacter) return -1; |
104 | 7.04M | if (m_decimalCharacter > tabs.m_decimalCharacter) return 1; |
105 | 7.04M | return 0; |
106 | 7.04M | } |
107 | | |
108 | | // operator<< |
109 | | std::ostream &operator<<(std::ostream &o, MWAWTabStop const &tab) |
110 | 0 | { |
111 | 0 | o << tab.m_position; |
112 | |
|
113 | 0 | switch (tab.m_alignment) { |
114 | 0 | case MWAWTabStop::LEFT: |
115 | 0 | o << "L"; |
116 | 0 | break; |
117 | 0 | case MWAWTabStop::CENTER: |
118 | 0 | o << "C"; |
119 | 0 | break; |
120 | 0 | case MWAWTabStop::RIGHT: |
121 | 0 | o << "R"; |
122 | 0 | break; |
123 | 0 | case MWAWTabStop::DECIMAL: |
124 | 0 | o << ":decimal"; |
125 | 0 | break; |
126 | 0 | case MWAWTabStop::BAR: |
127 | 0 | o << ":bar"; |
128 | 0 | break; |
129 | | #if !defined(__clang__) |
130 | | default: |
131 | | o << ":#type=" << int(tab.m_alignment); |
132 | | break; |
133 | | #endif |
134 | 0 | } |
135 | 0 | if (tab.m_leaderCharacter != '\0') |
136 | 0 | o << ":sep='"<< char(tab.m_leaderCharacter) << "'"; |
137 | 0 | if (tab.m_decimalCharacter && tab.m_decimalCharacter != '.') |
138 | 0 | o << ":dec='" << char(tab.m_decimalCharacter) << "'"; |
139 | 0 | return o; |
140 | 0 | } |
141 | | |
142 | | //////////////////////////////////////////////////////////// |
143 | | // paragraph |
144 | | //////////////////////////////////////////////////////////// |
145 | | MWAWParagraph::MWAWParagraph() |
146 | 309M | : m_marginsUnit(librevenge::RVNG_INCH) |
147 | 309M | , m_spacingsInterlineUnit(librevenge::RVNG_PERCENT) |
148 | 309M | , m_spacingsInterlineType(Fixed) |
149 | 309M | , m_tabs() |
150 | 309M | , m_tabsRelativeToLeftMargin(false) |
151 | 309M | , m_justify(JustificationLeft) |
152 | 309M | , m_breakStatus(0) |
153 | 309M | , m_writingMode(libmwaw::WritingInherited) |
154 | 309M | , m_listLevelIndex(0) |
155 | 309M | , m_listId(-1) |
156 | 309M | , m_listStartValue(-1) |
157 | 309M | , m_listLevel() |
158 | 309M | , m_backgroundColor(MWAWColor::white()) |
159 | 309M | , m_borders() |
160 | | |
161 | 309M | , m_dropNumCharacters(0) |
162 | 309M | , m_dropNumLines(0) |
163 | | |
164 | 309M | , m_styleName("") |
165 | 309M | , m_extra("") |
166 | 309M | { |
167 | 929M | for (auto &margin : m_margins) { |
168 | 929M | margin=0; |
169 | 929M | margin.setSet(false); |
170 | 929M | } |
171 | 929M | for (auto &spacing : m_spacings) { |
172 | 929M | spacing=0; |
173 | 929M | spacing.setSet(false); |
174 | 929M | } |
175 | 309M | m_spacings[0] = 1.0; // interline normal |
176 | 309M | m_spacings[0].setSet(false); |
177 | 309M | } |
178 | | |
179 | | MWAWParagraph::~MWAWParagraph() |
180 | 444M | { |
181 | 444M | } |
182 | | |
183 | | int MWAWParagraph::cmp(MWAWParagraph const ¶) const |
184 | 10.9M | { |
185 | 35.4M | for (int i = 0; i < 3; i++) { |
186 | 27.6M | if (*(m_margins[i]) < *(para.m_margins[i])) return -1; |
187 | 26.6M | if (*(m_margins[i]) > *(para.m_margins[i])) return 1; |
188 | 25.5M | if (*(m_spacings[i]) < *(para.m_spacings[i])) return -1; |
189 | 25.3M | if (*(m_spacings[i]) > *(para.m_spacings[i])) return 1; |
190 | 25.3M | } |
191 | 7.78M | if (*m_justify < *para.m_justify) return -1; |
192 | 7.56M | if (*m_justify > *para.m_justify) return 1; |
193 | 7.27M | if (*m_marginsUnit < *para.m_marginsUnit) return -1; |
194 | 7.26M | if (*m_marginsUnit > *para.m_marginsUnit) return 1; |
195 | 7.22M | if (*m_spacingsInterlineUnit < *para.m_spacingsInterlineUnit) return -1; |
196 | 7.16M | if (*m_spacingsInterlineUnit > *para.m_spacingsInterlineUnit) return 1; |
197 | 7.05M | if (*m_spacingsInterlineType < *para.m_spacingsInterlineType) return -1; |
198 | 7.04M | if (*m_spacingsInterlineType > *para.m_spacingsInterlineType) return 1; |
199 | 7.02M | if (*m_tabsRelativeToLeftMargin < *para.m_tabsRelativeToLeftMargin) return -1; |
200 | 7.02M | if (*m_tabsRelativeToLeftMargin > *para.m_tabsRelativeToLeftMargin) return 1; |
201 | | |
202 | 7.02M | if (m_tabs->size() < para.m_tabs->size()) return -1; |
203 | 6.98M | if (m_tabs->size() > para.m_tabs->size()) return 1; |
204 | | |
205 | 13.7M | for (size_t i=0; i < m_tabs->size(); i++) { |
206 | 7.22M | int diff=(*m_tabs)[i].cmp((*para.m_tabs)[i]); |
207 | 7.22M | if (diff) return diff; |
208 | 7.22M | } |
209 | 6.55M | if (*m_breakStatus < *para.m_breakStatus) return -1; |
210 | 6.55M | if (*m_breakStatus > *para.m_breakStatus) return 1; |
211 | 6.54M | if (*m_writingMode < *para.m_writingMode) return -1; |
212 | 6.54M | if (*m_writingMode > *para.m_writingMode) return 1; |
213 | 6.54M | if (*m_listLevelIndex < *para.m_listLevelIndex) return -1; |
214 | 6.48M | if (*m_listLevelIndex > *para.m_listLevelIndex) return 1; |
215 | 6.40M | if (*m_listId < *para.m_listId) return -1; |
216 | 6.40M | if (*m_listId > *para.m_listId) return 1; |
217 | 6.39M | if (*m_listStartValue < *para.m_listStartValue) return -1; |
218 | 6.39M | if (*m_listStartValue > *para.m_listStartValue) return 1; |
219 | 6.39M | int diff=m_listLevel->cmp(*para.m_listLevel); |
220 | 6.39M | if (diff) return diff; |
221 | 6.39M | if (*m_backgroundColor < *para.m_backgroundColor) return -1; |
222 | 6.39M | if (*m_backgroundColor > *para.m_backgroundColor) return 1; |
223 | | |
224 | 6.39M | if (m_borders.size() < para.m_borders.size()) return -1; |
225 | 6.39M | if (m_borders.size() > para.m_borders.size()) return 1; |
226 | 6.39M | for (size_t i=0; i < m_borders.size(); i++) { |
227 | 8.42k | if (m_borders[i].isSet() != para.m_borders[i].isSet()) |
228 | 129 | return m_borders[i].isSet() ? 1 : -1; |
229 | 8.29k | diff = m_borders[i]->compare(*(para.m_borders[i])); |
230 | 8.29k | if (diff) return diff; |
231 | 8.29k | } |
232 | | |
233 | 6.38M | if (*m_dropNumCharacters < *para.m_dropNumCharacters) return -1; |
234 | 6.38M | if (*m_dropNumCharacters > *para.m_dropNumCharacters) return 1; |
235 | 6.38M | if (*m_dropNumLines < *para.m_dropNumLines) return -1; |
236 | 6.38M | if (*m_dropNumLines > *para.m_dropNumLines) return 1; |
237 | 6.38M | if (m_styleName<para.m_styleName) return -1; |
238 | 6.38M | if (m_styleName>para.m_styleName) return 1; |
239 | 6.38M | return 0; |
240 | 6.38M | } |
241 | | |
242 | | void MWAWParagraph::insert(MWAWParagraph const ¶) |
243 | 353k | { |
244 | 1.41M | for (int i = 0; i < 3; i++) { |
245 | 1.06M | m_margins[i].insert(para.m_margins[i]); |
246 | 1.06M | m_spacings[i].insert(para.m_spacings[i]); |
247 | 1.06M | } |
248 | 353k | m_marginsUnit.insert(para.m_marginsUnit); |
249 | 353k | m_spacingsInterlineUnit.insert(para.m_spacingsInterlineUnit); |
250 | 353k | m_spacingsInterlineType.insert(para.m_spacingsInterlineType); |
251 | 353k | if (para.m_tabs.isSet() && m_tabs.isSet()) { |
252 | 498 | std::map<double, MWAWTabStop> all; |
253 | 2.51k | for (size_t t=0; t <m_tabs->size(); ++t) |
254 | 2.01k | all[(*m_tabs)[t].m_position]=(*m_tabs)[t]; |
255 | 1.00k | for (size_t t=0; t <para.m_tabs->size(); ++t) |
256 | 502 | all[(*para.m_tabs)[t].m_position]=(*para.m_tabs)[t]; |
257 | | |
258 | 498 | m_tabs->resize(0); |
259 | 498 | for (auto const &it : all) |
260 | 2.49k | m_tabs->push_back(it.second); |
261 | 498 | } |
262 | 353k | else if (para.m_tabs.isSet()) |
263 | 1.57k | m_tabs=para.m_tabs; |
264 | 353k | m_tabsRelativeToLeftMargin.insert(para.m_tabsRelativeToLeftMargin); |
265 | 353k | m_justify.insert(para.m_justify); |
266 | 353k | m_breakStatus.insert(para.m_breakStatus); |
267 | 353k | m_writingMode.insert(para.m_writingMode); |
268 | 353k | m_listLevelIndex.insert(para.m_listLevelIndex); |
269 | 353k | m_listId.insert(para.m_listId); |
270 | 353k | m_listStartValue.insert(para.m_listStartValue); |
271 | 353k | m_listLevel.insert(para.m_listLevel); |
272 | 353k | m_backgroundColor.insert(para.m_backgroundColor); |
273 | 353k | if (m_borders.size() < para.m_borders.size()) |
274 | 93.8k | m_borders.resize(para.m_borders.size()); |
275 | 592k | for (size_t i = 0; i < para.m_borders.size(); i++) |
276 | 238k | m_borders[i].insert(para.m_borders[i]); |
277 | 353k | m_dropNumCharacters.insert(para.m_dropNumCharacters); |
278 | 353k | m_dropNumLines.insert(para.m_dropNumLines); |
279 | 353k | m_styleName=para.m_styleName; // checkme |
280 | 353k | m_extra += para.m_extra; |
281 | 353k | } |
282 | | |
283 | | bool MWAWParagraph::hasBorders() const |
284 | 26.8M | { |
285 | 27.2M | for (size_t i = 0; i < m_borders.size() && i < 4; i++) { |
286 | 570k | if (!m_borders[i].isSet()) |
287 | 333k | continue; |
288 | 236k | if (!m_borders[i]->isEmpty()) |
289 | 214k | return true; |
290 | 236k | } |
291 | 26.6M | return false; |
292 | 26.8M | } |
293 | | |
294 | | bool MWAWParagraph::hasDifferentBorders() const |
295 | 107k | { |
296 | 107k | if (!hasBorders()) return false; |
297 | 107k | if (m_borders.size() < 4) return true; |
298 | 105k | for (size_t i = 1; i < m_borders.size(); i++) { |
299 | 95.8k | if (m_borders[i].isSet() != m_borders[0].isSet()) |
300 | 33.1k | return true; |
301 | 62.7k | if (*(m_borders[i]) != *(m_borders[0])) |
302 | 9.11k | return true; |
303 | 62.7k | } |
304 | 9.65k | return false; |
305 | 51.8k | } |
306 | | |
307 | | double MWAWParagraph::getMarginsWidth() const |
308 | 2.33M | { |
309 | 2.33M | auto factor = double(MWAWPosition::getScaleFactor(*m_marginsUnit, librevenge::RVNG_INCH)); |
310 | 2.33M | return factor*(*(m_margins[1])+*(m_margins[2])); |
311 | 2.33M | } |
312 | | |
313 | | void MWAWParagraph::addTo(librevenge::RVNGPropertyList &propList, bool inTable) const |
314 | 28.8M | { |
315 | 28.8M | switch (*m_justify) { |
316 | 25.9M | case JustificationLeft: |
317 | | // doesn't require a paragraph prop - it is the default |
318 | 25.9M | propList.insert("fo:text-align", "left"); |
319 | 25.9M | break; |
320 | 602k | case JustificationCenter: |
321 | 602k | propList.insert("fo:text-align", "center"); |
322 | 602k | break; |
323 | 1.81M | case JustificationRight: |
324 | 1.81M | propList.insert("fo:text-align", "end"); |
325 | 1.81M | break; |
326 | 510k | case JustificationFull: |
327 | 510k | propList.insert("fo:text-align", "justify"); |
328 | 510k | break; |
329 | 926 | case JustificationFullAllLines: |
330 | 926 | propList.insert("fo:text-align", "justify"); |
331 | 926 | propList.insert("fo:text-align-last", "justify"); |
332 | 926 | break; |
333 | | #if !defined(__clang__) |
334 | | default: |
335 | | break; |
336 | | #endif |
337 | 28.8M | } |
338 | 28.8M | if (!inTable) { |
339 | 26.7M | propList.insert("fo:margin-left", *m_margins[1], *m_marginsUnit); |
340 | 26.7M | propList.insert("fo:text-indent", *m_margins[0], *m_marginsUnit); |
341 | 26.7M | propList.insert("fo:margin-right", *m_margins[2], *m_marginsUnit); |
342 | 26.7M | if (!m_styleName.empty()) |
343 | 0 | propList.insert("style:display-name", m_styleName.c_str()); |
344 | 26.7M | if (!m_backgroundColor->isWhite()) |
345 | 9.78k | propList.insert("fo:background-color", m_backgroundColor->str().c_str()); |
346 | 26.7M | if (hasBorders()) { |
347 | 107k | bool setAll = !hasDifferentBorders(); |
348 | 405k | for (size_t w = 0; w < m_borders.size() && w < 4; w++) { |
349 | 307k | if (w && setAll) |
350 | 0 | break; |
351 | 307k | if (!m_borders[w].isSet()) |
352 | 142k | continue; |
353 | 165k | MWAWBorder const &border = *(m_borders[w]); |
354 | 165k | if (border.isEmpty()) |
355 | 13.2k | continue; |
356 | 152k | if (setAll) { |
357 | 9.65k | border.addTo(propList); |
358 | 9.65k | break; |
359 | 9.65k | } |
360 | 142k | switch (w) { |
361 | 19.3k | case libmwaw::Left: |
362 | 19.3k | border.addTo(propList,"left"); |
363 | 19.3k | break; |
364 | 57.7k | case libmwaw::Right: |
365 | 57.7k | border.addTo(propList,"right"); |
366 | 57.7k | break; |
367 | 35.9k | case libmwaw::Top: |
368 | 35.9k | border.addTo(propList,"top"); |
369 | 35.9k | break; |
370 | 29.5k | case libmwaw::Bottom: |
371 | 29.5k | border.addTo(propList,"bottom"); |
372 | 29.5k | break; |
373 | | #if !defined(__clang__) |
374 | | default: |
375 | | MWAW_DEBUG_MSG(("MWAWParagraph::addTo: can not send %d border\n",int(w))); |
376 | | break; |
377 | | #endif |
378 | 142k | } |
379 | 142k | } |
380 | 107k | } |
381 | 26.7M | } |
382 | 28.8M | propList.insert("fo:margin-top", *(m_spacings[1]), librevenge::RVNG_INCH); |
383 | 28.8M | propList.insert("fo:margin-bottom", *(m_spacings[2]), librevenge::RVNG_INCH); |
384 | 28.8M | switch (*m_spacingsInterlineType) { |
385 | 27.8M | case Fixed: |
386 | 27.8M | propList.insert("fo:line-height", *(m_spacings[0]), *m_spacingsInterlineUnit); |
387 | 27.8M | break; |
388 | 1.05M | case AtLeast: |
389 | 1.05M | if (*(m_spacings[0]) <= 0 && *(m_spacings[0]) >= 0) |
390 | 213k | break; |
391 | 842k | if (*(m_spacings[0]) < 0) { |
392 | 286 | static bool first = true; |
393 | 286 | if (first) { |
394 | 23 | MWAW_DEBUG_MSG(("MWAWParagraph::addTo: interline spacing seems bad\n")); |
395 | 23 | first = false; |
396 | 23 | } |
397 | 286 | } |
398 | 841k | else if (*m_spacingsInterlineUnit != librevenge::RVNG_PERCENT) |
399 | 834k | propList.insert("style:line-height-at-least", *(m_spacings[0]), *m_spacingsInterlineUnit); |
400 | 6.97k | else { |
401 | 6.97k | propList.insert("style:line-height-at-least", *(m_spacings[0])*12.0, librevenge::RVNG_POINT); |
402 | 6.97k | static bool first = true; |
403 | 6.97k | if (first) { |
404 | 25 | first = false; |
405 | 25 | MWAW_DEBUG_MSG(("MWAWParagraph::addTo: assume height=12 to set line spacing at least with percent type\n")); |
406 | 25 | } |
407 | 6.97k | } |
408 | 842k | break; |
409 | | #if !defined(__clang__) |
410 | | default: |
411 | | MWAW_DEBUG_MSG(("MWAWParagraph::addTo: can not set line spacing type: %d\n",int(*m_spacingsInterlineType))); |
412 | | break; |
413 | | #endif |
414 | 28.8M | } |
415 | 28.8M | if (*m_breakStatus & NoBreakBit) |
416 | 38.0k | propList.insert("fo:keep-together", "always"); |
417 | 28.8M | if (*m_breakStatus & NoBreakWithNextBit) |
418 | 34.1k | propList.insert("fo:keep-with-next", "always"); |
419 | 28.8M | if (*m_writingMode!=libmwaw::WritingInherited) |
420 | 71.1k | propList.insert("style:writing-mode", libmwaw::writingModeToString(*m_writingMode).c_str()); |
421 | | |
422 | 28.8M | if (!m_tabs->empty()) { |
423 | 2.64M | double decalX=0; |
424 | 2.64M | librevenge::RVNGPropertyListVector tabs; |
425 | 2.64M | if (!*m_tabsRelativeToLeftMargin) { |
426 | | // tabs are absolute, we must remove left margin |
427 | 2.64M | auto factor = double(MWAWPosition::getScaleFactor(*m_marginsUnit, librevenge::RVNG_INCH)); |
428 | 2.64M | decalX -= m_margins[1].get()*factor; |
429 | 2.64M | } |
430 | | |
431 | 2.64M | for (auto const &tab : *m_tabs) |
432 | 22.4M | tab.addTo(tabs, decalX); |
433 | 2.64M | propList.insert("style:tab-stops", tabs); |
434 | 2.64M | } |
435 | | |
436 | 28.8M | if (m_dropNumCharacters.get()>0 && m_dropNumLines.get()>1) { |
437 | 0 | librevenge::RVNGPropertyList cap; |
438 | | //addme cap.insert("style:distance", ) |
439 | 0 | cap.insert("style:length", *m_dropNumCharacters); |
440 | 0 | cap.insert("style:lines", *m_dropNumLines); |
441 | 0 | librevenge::RVNGPropertyListVector capVector; |
442 | 0 | capVector.append(cap); |
443 | 0 | propList.insert("style:drop-cap", capVector); |
444 | 0 | } |
445 | 28.8M | } |
446 | | |
447 | | std::ostream &operator<<(std::ostream &o, MWAWParagraph const &pp) |
448 | 0 | { |
449 | 0 | if (!pp.m_styleName.empty()) |
450 | 0 | o << "style=\"" << pp.m_styleName << "\","; |
451 | 0 | if (pp.m_margins[0].get()<0||pp.m_margins[0].get()>0) |
452 | 0 | o << "textIndent=" << pp.m_margins[0].get() << ","; |
453 | 0 | if (pp.m_margins[1].get()<0||pp.m_margins[1].get()>0) |
454 | 0 | o << "leftMarg=" << pp.m_margins[1].get() << ","; |
455 | 0 | if (pp.m_margins[2].get()<0||pp.m_margins[2].get()>0) |
456 | 0 | o << "rightMarg=" << pp.m_margins[2].get() << ","; |
457 | |
|
458 | 0 | if (pp.m_spacingsInterlineUnit.get()==librevenge::RVNG_PERCENT) { |
459 | 0 | if (pp.m_spacings[0].get() < 1.0 || pp.m_spacings[0].get() > 1.0) { |
460 | 0 | o << "interLineSpacing=" << pp.m_spacings[0].get() << "%"; |
461 | 0 | if (pp.m_spacingsInterlineType.get()==MWAWParagraph::AtLeast) |
462 | 0 | o << "[atLeast]"; |
463 | 0 | o << ","; |
464 | 0 | } |
465 | 0 | } |
466 | 0 | else if (pp.m_spacings[0].get() > 0.0) { |
467 | 0 | o << "interLineSpacing=" << pp.m_spacings[0].get(); |
468 | 0 | if (pp.m_spacingsInterlineType.get()==MWAWParagraph::AtLeast) |
469 | 0 | o << "[atLeast]"; |
470 | 0 | o << ","; |
471 | 0 | } |
472 | 0 | if (pp.m_spacings[1].get()<0||pp.m_spacings[1].get()>0) |
473 | 0 | o << "befSpacing=" << pp.m_spacings[1].get() << ","; |
474 | 0 | if (pp.m_spacings[2].get()<0||pp.m_spacings[2].get()>0) |
475 | 0 | o << "aftSpacing=" << pp.m_spacings[2].get() << ","; |
476 | |
|
477 | 0 | if (pp.m_breakStatus.get() & MWAWParagraph::NoBreakBit) o << "dontbreak,"; |
478 | 0 | if (pp.m_breakStatus.get() & MWAWParagraph::NoBreakWithNextBit) o << "dontbreakafter,"; |
479 | 0 | if (pp.m_writingMode.get()!=libmwaw::WritingInherited) |
480 | 0 | o << "writing=" << libmwaw::writingModeToString(pp.m_writingMode.get()) << ","; |
481 | |
|
482 | 0 | switch (pp.m_justify.get()) { |
483 | 0 | case MWAWParagraph::JustificationLeft: |
484 | 0 | break; |
485 | 0 | case MWAWParagraph::JustificationCenter: |
486 | 0 | o << "just=centered, "; |
487 | 0 | break; |
488 | 0 | case MWAWParagraph::JustificationRight: |
489 | 0 | o << "just=right, "; |
490 | 0 | break; |
491 | 0 | case MWAWParagraph::JustificationFull: |
492 | 0 | o << "just=full, "; |
493 | 0 | break; |
494 | 0 | case MWAWParagraph::JustificationFullAllLines: |
495 | 0 | o << "just=fullAllLines, "; |
496 | 0 | break; |
497 | | #if !defined(__clang__) |
498 | | default: |
499 | | o << "just=" << pp.m_justify.get() << ", "; |
500 | | break; |
501 | | #endif |
502 | 0 | } |
503 | | |
504 | 0 | if (pp.m_tabs->size()) { |
505 | 0 | o << "tabs=("; |
506 | 0 | for (auto const &tab : *pp.m_tabs) |
507 | 0 | o << tab << ","; |
508 | 0 | o << "),"; |
509 | 0 | } |
510 | 0 | if (!pp.m_backgroundColor.get().isWhite()) |
511 | 0 | o << "backgroundColor=" << pp.m_backgroundColor.get() << ","; |
512 | 0 | if (*pp.m_listId >= 0) o << "listId=" << *pp.m_listId << ","; |
513 | 0 | if (pp.m_listLevelIndex.get() >= 1) |
514 | 0 | o << pp.m_listLevel.get() << ":" << pp.m_listLevelIndex.get() <<","; |
515 | |
|
516 | 0 | for (size_t i = 0; i < pp.m_borders.size(); i++) { |
517 | 0 | if (!pp.m_borders[i].isSet()) |
518 | 0 | continue; |
519 | 0 | MWAWBorder const &border = pp.m_borders[i].get(); |
520 | 0 | if (border.isEmpty()) |
521 | 0 | continue; |
522 | 0 | o << "bord"; |
523 | 0 | if (i < 6) { |
524 | 0 | static char const* const wh[] = { "L", "R", "T", "B", "MiddleH", "MiddleV" }; |
525 | 0 | o << wh[i]; |
526 | 0 | } |
527 | 0 | else o << "[#wh=" << i << "]"; |
528 | 0 | o << "=" << border << ","; |
529 | 0 | } |
530 | |
|
531 | 0 | if (pp.m_dropNumCharacters.get()>0 && pp.m_dropNumLines.get()>1) |
532 | 0 | o << "drop=" << *pp.m_dropNumCharacters << "[" << *pp.m_dropNumLines << "l],"; |
533 | 0 | if (!pp.m_extra.empty()) o << "extras=(" << pp.m_extra << ")"; |
534 | 0 | return o; |
535 | 0 | } |
536 | | |
537 | | // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |