LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / writerfilter / source / rtftok / rtfdispatchflag.cxx
blob9d891384360c4c01d5abf4c356376955753cb7a9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <sal/config.h>
12 #include <string_view>
14 #include "rtfdocumentimpl.hxx"
16 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
17 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
18 #include <com/sun/star/text/RelOrientation.hpp>
19 #include <com/sun/star/text/VertOrientation.hpp>
20 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
22 #include <filter/msfilter/escherex.hxx>
24 #include <ooxml/resourceids.hxx>
26 #include <sal/log.hxx>
28 #include "rtfsdrimport.hxx"
29 #include "rtfskipdestination.hxx"
31 using namespace com::sun::star;
33 namespace writerfilter::rtftok
35 RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
37 setNeedSect(true);
38 checkUnicode(/*bUnicode =*/true, /*bHex =*/true);
39 RTFSkipDestination aSkip(*this);
40 int nParam = -1;
41 int nSprm = -1;
43 // Underline flags.
44 switch (nKeyword)
46 case RTFKeyword::ULD:
47 nSprm = NS_ooxml::LN_Value_ST_Underline_dotted;
48 break;
49 case RTFKeyword::ULW:
50 nSprm = NS_ooxml::LN_Value_ST_Underline_words;
51 break;
52 default:
53 break;
55 if (nSprm >= 0)
57 auto pValue = new RTFValue(nSprm);
58 m_aStates.top().getCharacterAttributes().set(NS_ooxml::LN_CT_Underline_val, pValue);
59 return RTFError::OK;
62 // Indentation
63 switch (nKeyword)
65 case RTFKeyword::QC:
66 nParam = NS_ooxml::LN_Value_ST_Jc_center;
67 break;
68 case RTFKeyword::QJ:
69 nParam = NS_ooxml::LN_Value_ST_Jc_both;
70 break;
71 case RTFKeyword::QL:
72 nParam = NS_ooxml::LN_Value_ST_Jc_left;
73 break;
74 case RTFKeyword::QR:
75 nParam = NS_ooxml::LN_Value_ST_Jc_right;
76 break;
77 case RTFKeyword::QD:
78 nParam = NS_ooxml::LN_Value_ST_Jc_distribute;
79 break;
80 default:
81 break;
83 if (nParam >= 0)
85 auto pValue = new RTFValue(nParam);
86 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_jc, pValue);
87 m_bNeedPap = true;
88 return RTFError::OK;
91 // Font Alignment
92 switch (nKeyword)
94 case RTFKeyword::FAFIXED:
95 case RTFKeyword::FAAUTO:
96 nParam = NS_ooxml::LN_Value_doc_ST_TextAlignment_auto;
97 break;
98 case RTFKeyword::FAHANG:
99 nParam = NS_ooxml::LN_Value_doc_ST_TextAlignment_top;
100 break;
101 case RTFKeyword::FACENTER:
102 nParam = NS_ooxml::LN_Value_doc_ST_TextAlignment_center;
103 break;
104 case RTFKeyword::FAROMAN:
105 nParam = NS_ooxml::LN_Value_doc_ST_TextAlignment_baseline;
106 break;
107 case RTFKeyword::FAVAR:
108 nParam = NS_ooxml::LN_Value_doc_ST_TextAlignment_bottom;
109 break;
110 default:
111 break;
113 if (nParam >= 0)
115 auto pValue = new RTFValue(nParam);
116 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_textAlignment, pValue);
117 return RTFError::OK;
120 // Tab kind.
121 switch (nKeyword)
123 case RTFKeyword::TQR:
124 nParam = NS_ooxml::LN_Value_ST_TabJc_right;
125 break;
126 case RTFKeyword::TQC:
127 nParam = NS_ooxml::LN_Value_ST_TabJc_center;
128 break;
129 case RTFKeyword::TQDEC:
130 nParam = NS_ooxml::LN_Value_ST_TabJc_decimal;
131 break;
132 default:
133 break;
135 if (nParam >= 0)
137 auto pValue = new RTFValue(nParam);
138 m_aStates.top().getTabAttributes().set(NS_ooxml::LN_CT_TabStop_val, pValue);
139 return RTFError::OK;
142 // Tab lead.
143 switch (nKeyword)
145 case RTFKeyword::TLDOT:
146 nParam = NS_ooxml::LN_Value_ST_TabTlc_dot;
147 break;
148 case RTFKeyword::TLMDOT:
149 nParam = NS_ooxml::LN_Value_ST_TabTlc_middleDot;
150 break;
151 case RTFKeyword::TLHYPH:
152 nParam = NS_ooxml::LN_Value_ST_TabTlc_hyphen;
153 break;
154 case RTFKeyword::TLUL:
155 case RTFKeyword::TLTH:
156 nParam = NS_ooxml::LN_Value_ST_TabTlc_underscore;
157 break;
158 case RTFKeyword::TLEQ:
159 default:
160 break;
162 if (nParam >= 0)
164 auto pValue = new RTFValue(nParam);
165 m_aStates.top().getTabAttributes().set(NS_ooxml::LN_CT_TabStop_leader, pValue);
166 return RTFError::OK;
169 // Border types
171 switch (nKeyword)
173 // brdrhair and brdrs are the same, brdrw will make a difference
174 // map to values in ooxml/model.xml resource ST_Border
175 case RTFKeyword::BRDRHAIR:
176 case RTFKeyword::BRDRS:
177 nParam = NS_ooxml::LN_Value_ST_Border_single;
178 break;
179 case RTFKeyword::BRDRDOT:
180 nParam = NS_ooxml::LN_Value_ST_Border_dotted;
181 break;
182 case RTFKeyword::BRDRDASH:
183 nParam = NS_ooxml::LN_Value_ST_Border_dashed;
184 break;
185 case RTFKeyword::BRDRDB:
186 nParam = NS_ooxml::LN_Value_ST_Border_double;
187 break;
188 case RTFKeyword::BRDRTNTHSG:
189 nParam = NS_ooxml::LN_Value_ST_Border_thinThickSmallGap;
190 break;
191 case RTFKeyword::BRDRTNTHMG:
192 nParam = NS_ooxml::LN_Value_ST_Border_thinThickMediumGap;
193 break;
194 case RTFKeyword::BRDRTNTHLG:
195 nParam = NS_ooxml::LN_Value_ST_Border_thinThickLargeGap;
196 break;
197 case RTFKeyword::BRDRTHTNSG:
198 nParam = NS_ooxml::LN_Value_ST_Border_thickThinSmallGap;
199 break;
200 case RTFKeyword::BRDRTHTNMG:
201 nParam = NS_ooxml::LN_Value_ST_Border_thickThinMediumGap;
202 break;
203 case RTFKeyword::BRDRTHTNLG:
204 nParam = NS_ooxml::LN_Value_ST_Border_thickThinLargeGap;
205 break;
206 case RTFKeyword::BRDREMBOSS:
207 nParam = NS_ooxml::LN_Value_ST_Border_threeDEmboss;
208 break;
209 case RTFKeyword::BRDRENGRAVE:
210 nParam = NS_ooxml::LN_Value_ST_Border_threeDEngrave;
211 break;
212 case RTFKeyword::BRDROUTSET:
213 nParam = NS_ooxml::LN_Value_ST_Border_outset;
214 break;
215 case RTFKeyword::BRDRINSET:
216 nParam = NS_ooxml::LN_Value_ST_Border_inset;
217 break;
218 case RTFKeyword::BRDRDASHSM:
219 nParam = NS_ooxml::LN_Value_ST_Border_dashSmallGap;
220 break;
221 case RTFKeyword::BRDRDASHD:
222 nParam = NS_ooxml::LN_Value_ST_Border_dotDash;
223 break;
224 case RTFKeyword::BRDRDASHDD:
225 nParam = NS_ooxml::LN_Value_ST_Border_dotDotDash;
226 break;
227 case RTFKeyword::BRDRNONE:
228 nParam = NS_ooxml::LN_Value_ST_Border_none;
229 break;
230 default:
231 break;
233 if (nParam >= 0)
235 auto pValue = new RTFValue(nParam);
236 putBorderProperty(m_aStates, NS_ooxml::LN_CT_Border_val, pValue);
237 return RTFError::OK;
241 // Section breaks
242 switch (nKeyword)
244 case RTFKeyword::SBKNONE:
245 nParam = NS_ooxml::LN_Value_ST_SectionMark_continuous;
246 break;
247 case RTFKeyword::SBKCOL:
248 nParam = NS_ooxml::LN_Value_ST_SectionMark_nextColumn;
249 break;
250 case RTFKeyword::SBKPAGE:
251 nParam = NS_ooxml::LN_Value_ST_SectionMark_nextPage;
252 break;
253 case RTFKeyword::SBKEVEN:
254 nParam = NS_ooxml::LN_Value_ST_SectionMark_evenPage;
255 break;
256 case RTFKeyword::SBKODD:
257 nParam = NS_ooxml::LN_Value_ST_SectionMark_oddPage;
258 break;
259 default:
260 break;
262 if (nParam >= 0)
264 if (m_nResetBreakOnSectBreak != RTFKeyword::invalid)
266 m_nResetBreakOnSectBreak = nKeyword;
268 auto pValue = new RTFValue(nParam);
269 m_aStates.top().getSectionSprms().set(NS_ooxml::LN_EG_SectPrContents_type, pValue);
270 return RTFError::OK;
273 // Footnote numbering
274 switch (nKeyword)
276 case RTFKeyword::FTNNAR:
277 nParam = NS_ooxml::LN_Value_ST_NumberFormat_decimal;
278 break;
279 case RTFKeyword::FTNNALC:
280 nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter;
281 break;
282 case RTFKeyword::FTNNAUC:
283 nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperLetter;
284 break;
285 case RTFKeyword::FTNNRLC:
286 nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman;
287 break;
288 case RTFKeyword::FTNNRUC:
289 nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperRoman;
290 break;
291 case RTFKeyword::FTNNCHI:
292 nParam = NS_ooxml::LN_Value_ST_NumberFormat_chicago;
293 break;
294 default:
295 break;
297 if (nParam >= 0)
299 auto pInner = new RTFValue(nParam);
300 RTFSprms aAttributes;
301 aAttributes.set(NS_ooxml::LN_CT_NumFmt_val, pInner);
302 auto pOuter = new RTFValue(aAttributes);
303 putNestedSprm(m_aDefaultState.getParagraphSprms(),
304 NS_ooxml::LN_EG_SectPrContents_footnotePr, NS_ooxml::LN_CT_FtnProps_numFmt,
305 pOuter);
306 return RTFError::OK;
309 // Footnote restart type
310 switch (nKeyword)
312 case RTFKeyword::FTNRSTPG:
313 nParam = NS_ooxml::LN_Value_ST_RestartNumber_eachPage;
314 break;
315 case RTFKeyword::FTNRESTART:
316 nParam = NS_ooxml::LN_Value_ST_RestartNumber_eachSect;
317 break;
318 case RTFKeyword::FTNRSTCONT:
319 nParam = NS_ooxml::LN_Value_ST_RestartNumber_continuous;
320 break;
321 default:
322 break;
324 if (nParam >= 0)
326 auto pValue = new RTFValue(nParam);
327 putNestedSprm(m_aDefaultState.getParagraphSprms(),
328 NS_ooxml::LN_EG_SectPrContents_footnotePr,
329 NS_ooxml::LN_EG_FtnEdnNumProps_numRestart, pValue);
330 return RTFError::OK;
333 // Endnote numbering
334 switch (nKeyword)
336 case RTFKeyword::AFTNNAR:
337 nParam = NS_ooxml::LN_Value_ST_NumberFormat_decimal;
338 break;
339 case RTFKeyword::AFTNNALC:
340 nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter;
341 break;
342 case RTFKeyword::AFTNNAUC:
343 nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperLetter;
344 break;
345 case RTFKeyword::AFTNNRLC:
346 nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman;
347 break;
348 case RTFKeyword::AFTNNRUC:
349 nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperRoman;
350 break;
351 case RTFKeyword::AFTNNCHI:
352 nParam = NS_ooxml::LN_Value_ST_NumberFormat_chicago;
353 break;
354 default:
355 break;
357 if (nParam >= 0)
359 auto pInner = new RTFValue(nParam);
360 RTFSprms aAttributes;
361 aAttributes.set(NS_ooxml::LN_CT_NumFmt_val, pInner);
362 auto pOuter = new RTFValue(aAttributes);
363 putNestedSprm(m_aDefaultState.getParagraphSprms(), NS_ooxml::LN_EG_SectPrContents_endnotePr,
364 NS_ooxml::LN_CT_EdnProps_numFmt, pOuter);
365 return RTFError::OK;
368 switch (nKeyword)
370 case RTFKeyword::TRQL:
371 nParam = NS_ooxml::LN_Value_ST_Jc_left;
372 break;
373 case RTFKeyword::TRQC:
374 nParam = NS_ooxml::LN_Value_ST_Jc_center;
375 break;
376 case RTFKeyword::TRQR:
377 nParam = NS_ooxml::LN_Value_ST_Jc_right;
378 break;
379 default:
380 break;
382 if (nParam >= 0)
384 auto pValue = new RTFValue(nParam);
385 m_aStates.top().getTableRowSprms().set(NS_ooxml::LN_CT_TrPrBase_jc, pValue);
386 return RTFError::OK;
389 // Cell Text Flow
390 switch (nKeyword)
392 case RTFKeyword::CLTXLRTB:
393 nParam = NS_ooxml::LN_Value_ST_TextDirection_lrTb;
394 break;
395 case RTFKeyword::CLTXTBRL:
396 nParam = NS_ooxml::LN_Value_ST_TextDirection_tbRl;
397 break;
398 case RTFKeyword::CLTXBTLR:
399 nParam = NS_ooxml::LN_Value_ST_TextDirection_btLr;
400 break;
401 case RTFKeyword::CLTXLRTBV:
402 nParam = NS_ooxml::LN_Value_ST_TextDirection_lrTbV;
403 break;
404 case RTFKeyword::CLTXTBRLV:
405 nParam = NS_ooxml::LN_Value_ST_TextDirection_tbRlV;
406 break;
407 default:
408 break;
410 if (nParam >= 0)
412 auto pValue = new RTFValue(nParam);
413 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_textDirection, pValue);
416 // Trivial paragraph flags
417 switch (nKeyword)
419 case RTFKeyword::KEEP:
420 if (m_aStates.top().getCurrentBuffer() != &m_aTableBufferStack.back())
421 nParam = NS_ooxml::LN_CT_PPrBase_keepLines;
422 break;
423 case RTFKeyword::KEEPN:
424 nParam = NS_ooxml::LN_CT_PPrBase_keepNext;
425 break;
426 case RTFKeyword::INTBL:
428 m_aStates.top().setCurrentBuffer(&m_aTableBufferStack.back());
429 nParam = NS_ooxml::LN_inTbl;
431 break;
432 case RTFKeyword::PAGEBB:
433 nParam = NS_ooxml::LN_CT_PPrBase_pageBreakBefore;
434 break;
435 default:
436 break;
438 if (nParam >= 0)
440 auto pValue = new RTFValue(1);
441 m_aStates.top().getParagraphSprms().set(nParam, pValue);
442 return RTFError::OK;
445 switch (nKeyword)
447 case RTFKeyword::FNIL:
448 case RTFKeyword::FROMAN:
449 case RTFKeyword::FSWISS:
450 case RTFKeyword::FMODERN:
451 case RTFKeyword::FSCRIPT:
452 case RTFKeyword::FDECOR:
453 case RTFKeyword::FTECH:
454 case RTFKeyword::FBIDI:
455 // TODO ooxml:CT_Font_family seems to be ignored by the domain mapper
456 break;
457 case RTFKeyword::ANSI:
458 m_aStates.top().setCurrentEncoding(RTL_TEXTENCODING_MS_1252);
459 break;
460 case RTFKeyword::MAC:
461 m_aDefaultState.setCurrentEncoding(RTL_TEXTENCODING_APPLE_ROMAN);
462 m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
463 break;
464 case RTFKeyword::PC:
465 m_aDefaultState.setCurrentEncoding(RTL_TEXTENCODING_IBM_437);
466 m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
467 break;
468 case RTFKeyword::PCA:
469 m_aDefaultState.setCurrentEncoding(RTL_TEXTENCODING_IBM_850);
470 m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
471 break;
472 case RTFKeyword::PLAIN:
474 m_aStates.top().getCharacterSprms() = getDefaultState().getCharacterSprms();
475 m_aStates.top().setCurrentEncoding(getEncoding(getFontIndex(m_nDefaultFontIndex)));
476 m_aStates.top().getCharacterAttributes() = getDefaultState().getCharacterAttributes();
477 m_aStates.top().setCurrentCharacterStyleIndex(-1);
478 m_aStates.top().setRunType(RTFParserState::RunType::NONE);
480 break;
481 case RTFKeyword::PARD:
483 if (m_bHadPicture)
484 dispatchSymbol(RTFKeyword::PAR);
485 // \pard is allowed between \cell and \row, but in that case it should not reset the fact that we're inside a table.
486 // It should not reset the paragraph style, either, so remember the old paragraph style.
487 RTFValue::Pointer_t pOldStyle
488 = m_aStates.top().getParagraphSprms().find(NS_ooxml::LN_CT_PPrBase_pStyle);
489 m_aStates.top().getParagraphSprms() = m_aDefaultState.getParagraphSprms();
490 m_aStates.top().getParagraphAttributes() = m_aDefaultState.getParagraphAttributes();
492 if (m_nTopLevelCells == 0 && m_nNestedCells == 0)
494 // Reset that we're in a table.
495 m_aStates.top().setCurrentBuffer(nullptr);
497 else
499 // We are still in a table.
500 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_inTbl, new RTFValue(1));
501 if (m_bAfterCellBeforeRow && pOldStyle)
502 // And we still have the same paragraph style.
503 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_pStyle,
504 pOldStyle);
505 // Ideally getDefaultSPRM() would take care of this, but it would not when we're buffering.
506 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_tabs,
507 new RTFValue());
509 resetFrame();
511 // Reset currently selected paragraph style as well, unless we are in the special "after \cell, before \row" state.
512 // By default the style with index 0 is applied.
513 if (!m_bAfterCellBeforeRow)
515 OUString const aName = getStyleName(0);
516 // But only in case it's not a character style.
517 if (!aName.isEmpty()
518 && getStyleType(0) != NS_ooxml::LN_Value_ST_StyleType_character)
520 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_pStyle,
521 new RTFValue(aName));
523 m_aStates.top().setCurrentStyleIndex(0);
525 // Need to send paragraph properties again, if there will be any.
526 m_bNeedPap = true;
527 break;
529 case RTFKeyword::SECTD:
531 m_aStates.top().getSectionSprms() = m_aDefaultState.getSectionSprms();
532 m_aStates.top().getSectionAttributes() = m_aDefaultState.getSectionAttributes();
534 break;
535 case RTFKeyword::TROWD:
537 // Back these up, in case later we still need this info.
538 backupTableRowProperties();
539 resetTableRowProperties();
540 // In case the table definition is in the middle of the row
541 // (invalid), make sure table definition is emitted.
542 m_bNeedPap = true;
544 break;
545 case RTFKeyword::WIDCTLPAR:
546 case RTFKeyword::NOWIDCTLPAR:
548 auto pValue = new RTFValue(int(nKeyword == RTFKeyword::WIDCTLPAR));
549 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_widowControl, pValue);
551 break;
552 case RTFKeyword::BOX:
554 RTFSprms aAttributes;
555 auto pValue = new RTFValue(aAttributes);
556 for (int i = 0; i < 4; i++)
557 m_aStates.top().getParagraphSprms().set(getParagraphBorder(i), pValue);
558 m_aStates.top().setBorderState(RTFBorderState::PARAGRAPH_BOX);
560 break;
561 case RTFKeyword::LTRSECT:
562 case RTFKeyword::RTLSECT:
564 auto pValue = new RTFValue(nKeyword == RTFKeyword::LTRSECT ? 0 : 1);
565 m_aStates.top().setRunType(RTFParserState::RunType::NONE);
566 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_EG_SectPrContents_textDirection,
567 pValue);
569 break;
570 case RTFKeyword::LTRPAR:
571 case RTFKeyword::RTLPAR:
573 auto pValue = new RTFValue(nKeyword == RTFKeyword::LTRPAR ? 0 : 1);
574 m_aStates.top().setRunType(RTFParserState::RunType::NONE);
575 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_bidi, pValue);
577 break;
578 case RTFKeyword::LTRROW:
579 case RTFKeyword::RTLROW:
580 m_aStates.top().setRunType(RTFParserState::RunType::NONE);
581 m_aStates.top().getTableRowSprms().set(
582 NS_ooxml::LN_CT_TblPrBase_bidiVisual,
583 new RTFValue(int(nKeyword == RTFKeyword::RTLROW)));
584 break;
585 case RTFKeyword::LTRCH:
586 // dmapper does not support this.
587 if (m_aStates.top().getRunType() == RTFParserState::RunType::RTLCH_LTRCH_1)
588 m_aStates.top().setRunType(RTFParserState::RunType::RTLCH_LTRCH_2);
589 else
590 m_aStates.top().setRunType(RTFParserState::RunType::LTRCH_RTLCH_1);
591 break;
592 case RTFKeyword::RTLCH:
593 if (m_aStates.top().getRunType() == RTFParserState::RunType::LTRCH_RTLCH_1)
594 m_aStates.top().setRunType(RTFParserState::RunType::LTRCH_RTLCH_2);
595 else
596 m_aStates.top().setRunType(RTFParserState::RunType::RTLCH_LTRCH_1);
598 if (m_aDefaultState.getCurrentEncoding() == RTL_TEXTENCODING_MS_1255)
599 m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
600 break;
601 case RTFKeyword::ULNONE:
603 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_Underline_none);
604 m_aStates.top().getCharacterAttributes().set(NS_ooxml::LN_CT_Underline_val, pValue);
606 break;
607 case RTFKeyword::NONSHPPICT:
608 case RTFKeyword::MMATHPICT: // Picture group used by readers not understanding \moMath group
609 m_aStates.top().setDestination(Destination::SKIP);
610 break;
611 case RTFKeyword::CLBRDRT:
612 case RTFKeyword::CLBRDRL:
613 case RTFKeyword::CLBRDRB:
614 case RTFKeyword::CLBRDRR:
616 RTFSprms aAttributes;
617 RTFSprms aSprms;
618 auto pValue = new RTFValue(aAttributes, aSprms);
619 switch (nKeyword)
621 case RTFKeyword::CLBRDRT:
622 nParam = NS_ooxml::LN_CT_TcBorders_top;
623 break;
624 case RTFKeyword::CLBRDRL:
625 nParam = NS_ooxml::LN_CT_TcBorders_left;
626 break;
627 case RTFKeyword::CLBRDRB:
628 nParam = NS_ooxml::LN_CT_TcBorders_bottom;
629 break;
630 case RTFKeyword::CLBRDRR:
631 nParam = NS_ooxml::LN_CT_TcBorders_right;
632 break;
633 default:
634 break;
636 putNestedSprm(m_aStates.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcBorders,
637 nParam, pValue);
638 m_aStates.top().setBorderState(RTFBorderState::CELL);
640 break;
641 case RTFKeyword::PGBRDRT:
642 case RTFKeyword::PGBRDRL:
643 case RTFKeyword::PGBRDRB:
644 case RTFKeyword::PGBRDRR:
646 RTFSprms aAttributes;
647 RTFSprms aSprms;
648 auto pValue = new RTFValue(aAttributes, aSprms);
649 switch (nKeyword)
651 case RTFKeyword::PGBRDRT:
652 nParam = NS_ooxml::LN_CT_PageBorders_top;
653 break;
654 case RTFKeyword::PGBRDRL:
655 nParam = NS_ooxml::LN_CT_PageBorders_left;
656 break;
657 case RTFKeyword::PGBRDRB:
658 nParam = NS_ooxml::LN_CT_PageBorders_bottom;
659 break;
660 case RTFKeyword::PGBRDRR:
661 nParam = NS_ooxml::LN_CT_PageBorders_right;
662 break;
663 default:
664 break;
666 putNestedSprm(m_aStates.top().getSectionSprms(),
667 NS_ooxml::LN_EG_SectPrContents_pgBorders, nParam, pValue);
668 m_aStates.top().setBorderState(RTFBorderState::PAGE);
670 break;
671 case RTFKeyword::BRDRT:
672 case RTFKeyword::BRDRL:
673 case RTFKeyword::BRDRB:
674 case RTFKeyword::BRDRR:
675 case RTFKeyword::BRDRBTW:
677 RTFSprms aAttributes;
678 RTFSprms aSprms;
679 auto pValue = new RTFValue(aAttributes, aSprms);
680 switch (nKeyword)
682 case RTFKeyword::BRDRT:
683 nParam = getParagraphBorder(0);
684 break;
685 case RTFKeyword::BRDRL:
686 nParam = getParagraphBorder(1);
687 break;
688 case RTFKeyword::BRDRB:
689 nParam = getParagraphBorder(2);
690 break;
691 case RTFKeyword::BRDRR:
692 nParam = getParagraphBorder(3);
693 break;
694 case RTFKeyword::BRDRBTW:
695 nParam = getParagraphBorder(4);
696 break;
697 default:
698 break;
700 putNestedSprm(m_aStates.top().getParagraphSprms(), NS_ooxml::LN_CT_PrBase_pBdr, nParam,
701 pValue);
702 m_aStates.top().setBorderState(RTFBorderState::PARAGRAPH);
704 break;
705 case RTFKeyword::CHBRDR:
707 RTFSprms aAttributes;
708 auto pValue = new RTFValue(aAttributes);
709 m_aStates.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_bdr, pValue);
710 m_aStates.top().setBorderState(RTFBorderState::CHARACTER);
712 break;
713 case RTFKeyword::CLMGF:
715 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_Merge_restart);
716 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_hMerge, pValue);
718 break;
719 case RTFKeyword::CLMRG:
721 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_Merge_continue);
722 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_hMerge, pValue);
724 break;
725 case RTFKeyword::CLVMGF:
727 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_Merge_restart);
728 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_vMerge, pValue);
730 break;
731 case RTFKeyword::CLVMRG:
733 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_Merge_continue);
734 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_vMerge, pValue);
736 break;
737 case RTFKeyword::CLVERTALT:
738 case RTFKeyword::CLVERTALC:
739 case RTFKeyword::CLVERTALB:
741 switch (nKeyword)
743 case RTFKeyword::CLVERTALT:
744 nParam = NS_ooxml::LN_Value_ST_VerticalJc_top;
745 break;
746 case RTFKeyword::CLVERTALC:
747 nParam = NS_ooxml::LN_Value_ST_VerticalJc_center;
748 break;
749 case RTFKeyword::CLVERTALB:
750 nParam = NS_ooxml::LN_Value_ST_VerticalJc_bottom;
751 break;
752 default:
753 break;
755 auto pValue = new RTFValue(nParam);
756 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_vAlign, pValue);
758 break;
759 case RTFKeyword::TRKEEP:
761 auto pValue = new RTFValue(1);
762 m_aStates.top().getTableRowSprms().set(NS_ooxml::LN_CT_TrPrBase_cantSplit, pValue);
764 break;
765 case RTFKeyword::SECTUNLOCKED:
767 auto pValue = new RTFValue(0);
768 m_aStates.top().getSectionSprms().set(NS_ooxml::LN_EG_SectPrContents_formProt, pValue);
770 break;
771 case RTFKeyword::PGNBIDIA:
772 case RTFKeyword::PGNBIDIB:
773 // These should be mapped to NS_ooxml::LN_EG_SectPrContents_pgNumType, but dmapper has no API for that at the moment.
774 break;
775 case RTFKeyword::LOCH:
776 m_aStates.top().setRunType(RTFParserState::RunType::LOCH);
777 break;
778 case RTFKeyword::HICH:
779 m_aStates.top().setRunType(RTFParserState::RunType::HICH);
780 break;
781 case RTFKeyword::DBCH:
782 m_aStates.top().setRunType(RTFParserState::RunType::DBCH);
783 break;
784 case RTFKeyword::TITLEPG:
786 auto pValue = new RTFValue(1);
787 m_aStates.top().getSectionSprms().set(NS_ooxml::LN_EG_SectPrContents_titlePg, pValue);
789 break;
790 case RTFKeyword::SUPER:
792 // Make sure character properties are not lost if the document
793 // starts with a footnote.
794 if (!isStyleSheetImport())
796 checkFirstRun();
797 checkNeedPap();
800 if (!m_aStates.top().getCurrentBuffer())
801 m_aStates.top().setCurrentBuffer(&m_aSuperBuffer);
803 auto pValue = new RTFValue("superscript");
804 m_aStates.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue);
806 break;
807 case RTFKeyword::SUB:
809 auto pValue = new RTFValue("subscript");
810 m_aStates.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue);
812 break;
813 case RTFKeyword::NOSUPERSUB:
815 if (m_aStates.top().getCurrentBuffer() == &m_aSuperBuffer)
817 replayBuffer(m_aSuperBuffer, nullptr, nullptr);
818 m_aStates.top().setCurrentBuffer(nullptr);
820 m_aStates.top().getCharacterSprms().erase(NS_ooxml::LN_EG_RPrBase_vertAlign);
822 break;
823 case RTFKeyword::LINEPPAGE:
824 case RTFKeyword::LINECONT:
826 auto pValue = new RTFValue(nKeyword == RTFKeyword::LINEPPAGE
827 ? NS_ooxml::LN_Value_ST_LineNumberRestart_newPage
828 : NS_ooxml::LN_Value_ST_LineNumberRestart_continuous);
829 putNestedAttribute(m_aStates.top().getSectionSprms(),
830 NS_ooxml::LN_EG_SectPrContents_lnNumType,
831 NS_ooxml::LN_CT_LineNumber_restart, pValue);
833 break;
834 case RTFKeyword::AENDDOC:
835 // Noop, this is the default in Writer.
836 case RTFKeyword::AENDNOTES:
837 // Noop
838 case RTFKeyword::AFTNRSTCONT:
839 // Noop, this is the default in Writer.
840 case RTFKeyword::AFTNRESTART:
841 // Noop
842 case RTFKeyword::FTNBJ:
843 // Noop, this is the default in Writer.
844 break;
845 case RTFKeyword::ENDDOC:
847 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_RestartNumber_eachSect);
848 putNestedSprm(m_aDefaultState.getParagraphSprms(),
849 NS_ooxml::LN_EG_SectPrContents_footnotePr,
850 NS_ooxml::LN_EG_FtnEdnNumProps_numRestart, pValue);
852 break;
853 case RTFKeyword::NOLINE:
854 eraseNestedAttribute(m_aStates.top().getSectionSprms(),
855 NS_ooxml::LN_EG_SectPrContents_lnNumType,
856 NS_ooxml::LN_CT_LineNumber_distance);
857 break;
858 case RTFKeyword::FORMSHADE:
859 // Noop, this is the default in Writer.
860 break;
861 case RTFKeyword::PNGBLIP:
862 m_aStates.top().getPicture().eStyle = RTFBmpStyle::PNG;
863 break;
864 case RTFKeyword::JPEGBLIP:
865 m_aStates.top().getPicture().eStyle = RTFBmpStyle::JPEG;
866 break;
867 case RTFKeyword::POSYT:
868 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
869 NS_ooxml::LN_Value_doc_ST_YAlign_top);
870 break;
871 case RTFKeyword::POSYB:
872 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
873 NS_ooxml::LN_Value_doc_ST_YAlign_bottom);
874 break;
875 case RTFKeyword::POSYC:
876 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
877 NS_ooxml::LN_Value_doc_ST_YAlign_center);
878 break;
879 case RTFKeyword::POSYIN:
880 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
881 NS_ooxml::LN_Value_doc_ST_YAlign_inside);
882 break;
883 case RTFKeyword::POSYOUT:
884 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
885 NS_ooxml::LN_Value_doc_ST_YAlign_outside);
886 break;
887 case RTFKeyword::POSYIL:
888 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
889 NS_ooxml::LN_Value_doc_ST_YAlign_inline);
890 break;
892 case RTFKeyword::PHMRG:
893 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hAnchor,
894 NS_ooxml::LN_Value_doc_ST_HAnchor_margin);
895 break;
896 case RTFKeyword::PVMRG:
897 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vAnchor,
898 NS_ooxml::LN_Value_doc_ST_VAnchor_margin);
899 break;
900 case RTFKeyword::PHPG:
901 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hAnchor,
902 NS_ooxml::LN_Value_doc_ST_HAnchor_page);
903 break;
904 case RTFKeyword::PVPG:
905 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vAnchor,
906 NS_ooxml::LN_Value_doc_ST_VAnchor_page);
907 break;
908 case RTFKeyword::PHCOL:
909 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hAnchor,
910 NS_ooxml::LN_Value_doc_ST_HAnchor_text);
911 break;
912 case RTFKeyword::PVPARA:
913 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vAnchor,
914 NS_ooxml::LN_Value_doc_ST_VAnchor_text);
915 break;
917 case RTFKeyword::POSXC:
918 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign,
919 NS_ooxml::LN_Value_doc_ST_XAlign_center);
920 break;
921 case RTFKeyword::POSXI:
922 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign,
923 NS_ooxml::LN_Value_doc_ST_XAlign_inside);
924 break;
925 case RTFKeyword::POSXO:
926 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign,
927 NS_ooxml::LN_Value_doc_ST_XAlign_outside);
928 break;
929 case RTFKeyword::POSXL:
930 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign,
931 NS_ooxml::LN_Value_doc_ST_XAlign_left);
932 break;
933 case RTFKeyword::POSXR:
934 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign,
935 NS_ooxml::LN_Value_doc_ST_XAlign_right);
936 break;
938 case RTFKeyword::DPLINE:
939 case RTFKeyword::DPRECT:
940 case RTFKeyword::DPELLIPSE:
941 case RTFKeyword::DPTXBX:
942 case RTFKeyword::DPPOLYLINE:
943 case RTFKeyword::DPPOLYGON:
945 sal_Int32 nType = 0;
946 switch (nKeyword)
948 case RTFKeyword::DPLINE:
950 uno::Reference<drawing::XShape> xShape(
951 getModelFactory()->createInstance("com.sun.star.drawing.LineShape"),
952 uno::UNO_QUERY);
953 m_aStates.top().getDrawingObject().setShape(xShape);
954 break;
956 case RTFKeyword::DPPOLYLINE:
958 // The reason this is not a simple CustomShape is that in the old syntax we have no ViewBox info.
959 uno::Reference<drawing::XShape> xShape(
960 getModelFactory()->createInstance("com.sun.star.drawing.PolyLineShape"),
961 uno::UNO_QUERY);
962 m_aStates.top().getDrawingObject().setShape(xShape);
963 break;
965 case RTFKeyword::DPPOLYGON:
967 uno::Reference<drawing::XShape> xShape(
968 getModelFactory()->createInstance("com.sun.star.drawing.PolyPolygonShape"),
969 uno::UNO_QUERY);
970 m_aStates.top().getDrawingObject().setShape(xShape);
971 break;
973 case RTFKeyword::DPRECT:
975 uno::Reference<drawing::XShape> xShape(
976 getModelFactory()->createInstance("com.sun.star.drawing.RectangleShape"),
977 uno::UNO_QUERY);
978 m_aStates.top().getDrawingObject().setShape(xShape);
979 break;
981 case RTFKeyword::DPELLIPSE:
982 nType = ESCHER_ShpInst_Ellipse;
983 break;
984 case RTFKeyword::DPTXBX:
986 uno::Reference<drawing::XShape> xShape(
987 getModelFactory()->createInstance("com.sun.star.text.TextFrame"),
988 uno::UNO_QUERY);
989 m_aStates.top().getDrawingObject().setShape(xShape);
990 std::vector<beans::PropertyValue> aDefaults
991 = RTFSdrImport::getTextFrameDefaults(false);
992 for (const auto& rDefault : aDefaults)
994 if (!findPropertyName(
995 m_aStates.top().getDrawingObject().getPendingProperties(),
996 rDefault.Name))
997 m_aStates.top().getDrawingObject().getPendingProperties().push_back(
998 rDefault);
1000 checkFirstRun();
1001 Mapper().startShape(m_aStates.top().getDrawingObject().getShape());
1002 m_aStates.top().getDrawingObject().setHadShapeText(true);
1004 break;
1005 default:
1006 break;
1008 if (nType)
1010 uno::Reference<drawing::XShape> xShape(
1011 getModelFactory()->createInstance("com.sun.star.drawing.CustomShape"),
1012 uno::UNO_QUERY);
1013 m_aStates.top().getDrawingObject().setShape(xShape);
1015 uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier(m_xDstDoc, uno::UNO_QUERY);
1016 uno::Reference<beans::XPropertySet> xPropertySet(
1017 m_aStates.top().getDrawingObject().getShape(), uno::UNO_QUERY);
1018 m_aStates.top().getDrawingObject().setPropertySet(xPropertySet);
1019 if (xDrawSupplier.is())
1021 uno::Reference<drawing::XShapes> xShapes = xDrawSupplier->getDrawPage();
1022 if (xShapes.is() && nKeyword != RTFKeyword::DPTXBX)
1024 // set default VertOrient before inserting
1025 m_aStates.top().getDrawingObject().getPropertySet()->setPropertyValue(
1026 "VertOrient", uno::makeAny(text::VertOrientation::NONE));
1027 xShapes->add(m_aStates.top().getDrawingObject().getShape());
1030 if (nType)
1032 uno::Reference<drawing::XEnhancedCustomShapeDefaulter> xDefaulter(
1033 m_aStates.top().getDrawingObject().getShape(), uno::UNO_QUERY);
1034 xDefaulter->createCustomShapeDefaults(OUString::number(nType));
1036 std::vector<beans::PropertyValue>& rPendingProperties
1037 = m_aStates.top().getDrawingObject().getPendingProperties();
1038 for (const auto& rPendingProperty : rPendingProperties)
1039 m_aStates.top().getDrawingObject().getPropertySet()->setPropertyValue(
1040 rPendingProperty.Name, rPendingProperty.Value);
1041 m_pSdrImport->resolveDhgt(m_aStates.top().getDrawingObject().getPropertySet(),
1042 m_aStates.top().getDrawingObject().getDhgt(),
1043 /*bOldStyle=*/true);
1045 break;
1046 case RTFKeyword::DOBXMARGIN:
1047 case RTFKeyword::DOBYMARGIN:
1049 beans::PropertyValue aPropertyValue;
1050 aPropertyValue.Name
1051 = (nKeyword == RTFKeyword::DOBXMARGIN ? std::u16string_view(u"HoriOrientRelation")
1052 : std::u16string_view(u"VertOrientRelation"));
1053 aPropertyValue.Value <<= text::RelOrientation::PAGE_PRINT_AREA;
1054 m_aStates.top().getDrawingObject().getPendingProperties().push_back(aPropertyValue);
1056 break;
1057 case RTFKeyword::DOBXPAGE:
1058 case RTFKeyword::DOBYPAGE:
1060 beans::PropertyValue aPropertyValue;
1061 aPropertyValue.Name
1062 = (nKeyword == RTFKeyword::DOBXPAGE ? std::u16string_view(u"HoriOrientRelation")
1063 : std::u16string_view(u"VertOrientRelation"));
1064 aPropertyValue.Value <<= text::RelOrientation::PAGE_FRAME;
1065 m_aStates.top().getDrawingObject().getPendingProperties().push_back(aPropertyValue);
1067 break;
1068 case RTFKeyword::DOBYPARA:
1070 beans::PropertyValue aPropertyValue;
1071 aPropertyValue.Name = "VertOrientRelation";
1072 aPropertyValue.Value <<= text::RelOrientation::FRAME;
1073 m_aStates.top().getDrawingObject().getPendingProperties().push_back(aPropertyValue);
1075 break;
1076 case RTFKeyword::CONTEXTUALSPACE:
1078 auto pValue = new RTFValue(1);
1079 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_contextualSpacing,
1080 pValue);
1082 break;
1083 case RTFKeyword::LINKSTYLES:
1085 auto pValue = new RTFValue(1);
1086 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_linkStyles, pValue);
1088 break;
1089 case RTFKeyword::PNLVLBODY:
1091 auto pValue = new RTFValue(2);
1092 m_aStates.top().getTableAttributes().set(NS_ooxml::LN_CT_AbstractNum_nsid, pValue);
1094 break;
1095 case RTFKeyword::PNDEC:
1097 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_decimal);
1098 putNestedAttribute(m_aStates.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt,
1099 NS_ooxml::LN_CT_NumFmt_val, pValue);
1101 break;
1102 case RTFKeyword::PNLVLBLT:
1104 m_aStates.top().getTableAttributes().set(NS_ooxml::LN_CT_AbstractNum_nsid,
1105 new RTFValue(1));
1106 putNestedAttribute(m_aStates.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt,
1107 NS_ooxml::LN_CT_NumFmt_val,
1108 new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_bullet));
1110 break;
1111 case RTFKeyword::LANDSCAPE:
1113 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_PageOrientation_landscape);
1114 putNestedAttribute(m_aDefaultState.getSectionSprms(),
1115 NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_orient,
1116 pValue);
1117 [[fallthrough]]; // set the default + current value
1119 case RTFKeyword::LNDSCPSXN:
1121 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_PageOrientation_landscape);
1122 putNestedAttribute(m_aStates.top().getSectionSprms(),
1123 NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_orient,
1124 pValue);
1126 break;
1127 case RTFKeyword::SHPBXPAGE:
1128 m_aStates.top().getShape().setHoriOrientRelation(text::RelOrientation::PAGE_FRAME);
1129 m_aStates.top().getShape().setHoriOrientRelationToken(
1130 NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page);
1131 break;
1132 case RTFKeyword::SHPBYPAGE:
1133 m_aStates.top().getShape().setVertOrientRelation(text::RelOrientation::PAGE_FRAME);
1134 m_aStates.top().getShape().setVertOrientRelationToken(
1135 NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page);
1136 break;
1137 case RTFKeyword::DPLINEHOLLOW:
1138 m_aStates.top().getDrawingObject().setFLine(0);
1139 break;
1140 case RTFKeyword::DPROUNDR:
1141 if (m_aStates.top().getDrawingObject().getPropertySet().is())
1142 // Seems this old syntax has no way to specify a custom radius, and this is the default
1143 m_aStates.top().getDrawingObject().getPropertySet()->setPropertyValue(
1144 "CornerRadius", uno::makeAny(sal_Int32(83)));
1145 break;
1146 case RTFKeyword::NOWRAP:
1147 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_wrap,
1148 NS_ooxml::LN_Value_doc_ST_Wrap_notBeside);
1149 break;
1150 case RTFKeyword::MNOR:
1151 m_bMathNor = true;
1152 break;
1153 case RTFKeyword::REVISIONS:
1154 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_trackRevisions, new RTFValue(1));
1155 break;
1156 case RTFKeyword::BRDRSH:
1157 putBorderProperty(m_aStates, NS_ooxml::LN_CT_Border_shadow, new RTFValue(1));
1158 break;
1159 case RTFKeyword::NOCOLBAL:
1160 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Compat_noColumnBalance, new RTFValue(1));
1161 break;
1162 case RTFKeyword::MARGMIRROR:
1163 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_mirrorMargins, new RTFValue(1));
1164 break;
1165 case RTFKeyword::SAUTOUPD:
1166 m_aStates.top().getTableSprms().set(NS_ooxml::LN_CT_Style_autoRedefine,
1167 new RTFValue(1));
1168 break;
1169 case RTFKeyword::WIDOWCTRL:
1170 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_widowControl, new RTFValue(1));
1171 break;
1172 case RTFKeyword::LINEBETCOL:
1173 putNestedAttribute(m_aStates.top().getSectionSprms(),
1174 NS_ooxml::LN_EG_SectPrContents_cols, NS_ooxml::LN_CT_Columns_sep,
1175 new RTFValue(1));
1176 break;
1177 case RTFKeyword::PGNRESTART:
1178 putNestedAttribute(m_aStates.top().getSectionSprms(),
1179 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1180 NS_ooxml::LN_CT_PageNumber_start, new RTFValue(1));
1181 break;
1182 case RTFKeyword::PGNUCLTR:
1184 auto pIntValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_upperLetter);
1185 putNestedAttribute(m_aStates.top().getSectionSprms(),
1186 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1187 NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
1189 break;
1190 case RTFKeyword::PGNLCLTR:
1192 auto pIntValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter);
1193 putNestedAttribute(m_aStates.top().getSectionSprms(),
1194 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1195 NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
1197 break;
1198 case RTFKeyword::PGNUCRM:
1200 auto pIntValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_upperRoman);
1201 putNestedAttribute(m_aStates.top().getSectionSprms(),
1202 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1203 NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
1205 break;
1206 case RTFKeyword::PGNLCRM:
1208 auto pIntValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman);
1209 putNestedAttribute(m_aStates.top().getSectionSprms(),
1210 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1211 NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
1213 break;
1214 case RTFKeyword::PGNDEC:
1216 auto pIntValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_decimal);
1217 putNestedAttribute(m_aStates.top().getSectionSprms(),
1218 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1219 NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
1221 break;
1222 case RTFKeyword::HTMAUTSP:
1223 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Compat_doNotUseHTMLParagraphAutoSpacing,
1224 new RTFValue(0));
1225 break;
1226 case RTFKeyword::DNTBLNSBDB:
1227 // tdf#128428 switch off longer space sequence
1228 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_longerSpaceSequence,
1229 new RTFValue(0));
1230 break;
1231 case RTFKeyword::GUTTERPRL:
1232 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_gutterAtTop, new RTFValue(1));
1233 break;
1234 case RTFKeyword::RTLGUTTER:
1236 m_aStates.top().getSectionSprms().set(NS_ooxml::LN_EG_SectPrContents_rtlGutter,
1237 new RTFValue(1));
1239 break;
1240 case RTFKeyword::FLDLOCK:
1242 if (m_aStates.top().getDestination() == Destination::FIELD)
1243 m_aStates.top().setFieldLocked(true);
1245 break;
1246 default:
1248 SAL_INFO("writerfilter", "TODO handle flag '" << keywordToString(nKeyword) << "'");
1249 aSkip.setParsed(false);
1251 break;
1253 return RTFError::OK;
1256 } // namespace writerfilter
1258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */