android: Update app-specific/MIME type icons
[LibreOffice.git] / writerfilter / source / rtftok / rtfdispatchflag.cxx
blobde7b91e26faeb7ea7e571547a2394f089aa76d16
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 bool RTFDocumentImpl::dispatchFloatingTableFlag(RTFKeyword nKeyword)
37 // Positioned Wrapped Tables
38 OUString aParam;
39 switch (nKeyword)
41 case RTFKeyword::TPVPARA:
42 aParam = "text";
43 break;
44 case RTFKeyword::TPVMRG:
45 aParam = "margin";
46 break;
47 case RTFKeyword::TPVPG:
48 aParam = "page";
49 break;
50 default:
51 break;
53 if (!aParam.isEmpty())
55 putNestedAttribute(m_aStates.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr,
56 NS_ooxml::LN_CT_TblPPr_vertAnchor, new RTFValue(aParam));
57 return true;
59 switch (nKeyword)
61 case RTFKeyword::TPHCOL:
62 aParam = "text";
63 break;
64 case RTFKeyword::TPHMRG:
65 aParam = "margin";
66 break;
67 case RTFKeyword::TPHPG:
68 aParam = "page";
69 break;
70 default:
71 break;
73 if (!aParam.isEmpty())
75 putNestedAttribute(m_aStates.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr,
76 NS_ooxml::LN_CT_TblPPr_horzAnchor, new RTFValue(aParam));
77 return true;
79 switch (nKeyword)
81 case RTFKeyword::TPOSYC:
82 aParam = "center";
83 break;
84 case RTFKeyword::TPOSYB:
85 aParam = "bottom";
86 break;
87 default:
88 break;
90 if (!aParam.isEmpty())
92 putNestedAttribute(m_aStates.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr,
93 NS_ooxml::LN_CT_TblPPr_tblpYSpec, new RTFValue(aParam));
94 return true;
96 switch (nKeyword)
98 case RTFKeyword::TPOSXC:
99 aParam = "center";
100 break;
101 case RTFKeyword::TPOSXR:
102 aParam = "right";
103 break;
104 default:
105 break;
107 if (!aParam.isEmpty())
109 putNestedAttribute(m_aStates.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr,
110 NS_ooxml::LN_CT_TblPPr_tblpXSpec, new RTFValue(aParam));
111 return true;
114 if (nKeyword == RTFKeyword::TABSNOOVRLP)
116 m_aStates.top().getTableRowSprms().set(
117 NS_ooxml::LN_CT_TblPrBase_tblOverlap,
118 new RTFValue(NS_ooxml::LN_Value_ST_TblOverlap_never));
119 return true;
122 return false;
125 RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
127 setNeedSect(true);
128 checkUnicode(/*bUnicode =*/true, /*bHex =*/true);
129 RTFSkipDestination aSkip(*this);
130 int nParam = -1;
131 int nSprm = -1;
133 // Underline flags.
134 switch (nKeyword)
136 case RTFKeyword::ULD:
137 nSprm = NS_ooxml::LN_Value_ST_Underline_dotted;
138 break;
139 case RTFKeyword::ULW:
140 nSprm = NS_ooxml::LN_Value_ST_Underline_words;
141 break;
142 default:
143 break;
145 if (nSprm >= 0)
147 auto pValue = new RTFValue(nSprm);
148 m_aStates.top().getCharacterAttributes().set(NS_ooxml::LN_CT_Underline_val, pValue);
149 return RTFError::OK;
152 // Indentation
153 switch (nKeyword)
155 case RTFKeyword::QC:
156 nParam = NS_ooxml::LN_Value_ST_Jc_center;
157 break;
158 case RTFKeyword::QJ:
159 nParam = NS_ooxml::LN_Value_ST_Jc_both;
160 break;
161 case RTFKeyword::QL:
162 nParam = NS_ooxml::LN_Value_ST_Jc_left;
163 break;
164 case RTFKeyword::QR:
165 nParam = NS_ooxml::LN_Value_ST_Jc_right;
166 break;
167 case RTFKeyword::QD:
168 nParam = NS_ooxml::LN_Value_ST_Jc_distribute;
169 break;
170 default:
171 break;
173 if (nParam >= 0)
175 auto pValue = new RTFValue(nParam);
176 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_jc, pValue);
177 m_bNeedPap = true;
178 return RTFError::OK;
181 // Font Alignment
182 switch (nKeyword)
184 case RTFKeyword::FAFIXED:
185 case RTFKeyword::FAAUTO:
186 nParam = NS_ooxml::LN_Value_doc_ST_TextAlignment_auto;
187 break;
188 case RTFKeyword::FAHANG:
189 nParam = NS_ooxml::LN_Value_doc_ST_TextAlignment_top;
190 break;
191 case RTFKeyword::FACENTER:
192 nParam = NS_ooxml::LN_Value_doc_ST_TextAlignment_center;
193 break;
194 case RTFKeyword::FAROMAN:
195 nParam = NS_ooxml::LN_Value_doc_ST_TextAlignment_baseline;
196 break;
197 case RTFKeyword::FAVAR:
198 nParam = NS_ooxml::LN_Value_doc_ST_TextAlignment_bottom;
199 break;
200 default:
201 break;
203 if (nParam >= 0)
205 auto pValue = new RTFValue(nParam);
206 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_textAlignment, pValue);
207 return RTFError::OK;
210 // Tab kind.
211 switch (nKeyword)
213 case RTFKeyword::TQR:
214 nParam = NS_ooxml::LN_Value_ST_TabJc_right;
215 break;
216 case RTFKeyword::TQC:
217 nParam = NS_ooxml::LN_Value_ST_TabJc_center;
218 break;
219 case RTFKeyword::TQDEC:
220 nParam = NS_ooxml::LN_Value_ST_TabJc_decimal;
221 break;
222 default:
223 break;
225 if (nParam >= 0)
227 auto pValue = new RTFValue(nParam);
228 m_aStates.top().getTabAttributes().set(NS_ooxml::LN_CT_TabStop_val, pValue);
229 return RTFError::OK;
232 // Tab lead.
233 switch (nKeyword)
235 case RTFKeyword::TLDOT:
236 nParam = NS_ooxml::LN_Value_ST_TabTlc_dot;
237 break;
238 case RTFKeyword::TLMDOT:
239 nParam = NS_ooxml::LN_Value_ST_TabTlc_middleDot;
240 break;
241 case RTFKeyword::TLHYPH:
242 nParam = NS_ooxml::LN_Value_ST_TabTlc_hyphen;
243 break;
244 case RTFKeyword::TLUL:
245 case RTFKeyword::TLTH:
246 nParam = NS_ooxml::LN_Value_ST_TabTlc_underscore;
247 break;
248 case RTFKeyword::TLEQ:
249 default:
250 break;
252 if (nParam >= 0)
254 auto pValue = new RTFValue(nParam);
255 m_aStates.top().getTabAttributes().set(NS_ooxml::LN_CT_TabStop_leader, pValue);
256 return RTFError::OK;
259 // Border types
261 switch (nKeyword)
263 // brdrhair and brdrs are the same, brdrw will make a difference
264 // map to values in ooxml/model.xml resource ST_Border
265 case RTFKeyword::BRDRHAIR:
266 case RTFKeyword::BRDRS:
267 nParam = NS_ooxml::LN_Value_ST_Border_single;
268 break;
269 case RTFKeyword::BRDRDOT:
270 nParam = NS_ooxml::LN_Value_ST_Border_dotted;
271 break;
272 case RTFKeyword::BRDRDASH:
273 nParam = NS_ooxml::LN_Value_ST_Border_dashed;
274 break;
275 case RTFKeyword::BRDRDB:
276 nParam = NS_ooxml::LN_Value_ST_Border_double;
277 break;
278 case RTFKeyword::BRDRTNTHSG:
279 nParam = NS_ooxml::LN_Value_ST_Border_thinThickSmallGap;
280 break;
281 case RTFKeyword::BRDRTNTHMG:
282 nParam = NS_ooxml::LN_Value_ST_Border_thinThickMediumGap;
283 break;
284 case RTFKeyword::BRDRTNTHLG:
285 nParam = NS_ooxml::LN_Value_ST_Border_thinThickLargeGap;
286 break;
287 case RTFKeyword::BRDRTHTNSG:
288 nParam = NS_ooxml::LN_Value_ST_Border_thickThinSmallGap;
289 break;
290 case RTFKeyword::BRDRTHTNMG:
291 nParam = NS_ooxml::LN_Value_ST_Border_thickThinMediumGap;
292 break;
293 case RTFKeyword::BRDRTHTNLG:
294 nParam = NS_ooxml::LN_Value_ST_Border_thickThinLargeGap;
295 break;
296 case RTFKeyword::BRDREMBOSS:
297 nParam = NS_ooxml::LN_Value_ST_Border_threeDEmboss;
298 break;
299 case RTFKeyword::BRDRENGRAVE:
300 nParam = NS_ooxml::LN_Value_ST_Border_threeDEngrave;
301 break;
302 case RTFKeyword::BRDROUTSET:
303 nParam = NS_ooxml::LN_Value_ST_Border_outset;
304 break;
305 case RTFKeyword::BRDRINSET:
306 nParam = NS_ooxml::LN_Value_ST_Border_inset;
307 break;
308 case RTFKeyword::BRDRDASHSM:
309 nParam = NS_ooxml::LN_Value_ST_Border_dashSmallGap;
310 break;
311 case RTFKeyword::BRDRDASHD:
312 nParam = NS_ooxml::LN_Value_ST_Border_dotDash;
313 break;
314 case RTFKeyword::BRDRDASHDD:
315 nParam = NS_ooxml::LN_Value_ST_Border_dotDotDash;
316 break;
317 case RTFKeyword::BRDRNONE:
318 nParam = NS_ooxml::LN_Value_ST_Border_none;
319 break;
320 default:
321 break;
323 if (nParam >= 0)
325 auto pValue = new RTFValue(nParam);
326 putBorderProperty(m_aStates, NS_ooxml::LN_CT_Border_val, pValue);
327 return RTFError::OK;
331 // Section breaks
332 switch (nKeyword)
334 case RTFKeyword::SBKNONE:
335 nParam = NS_ooxml::LN_Value_ST_SectionMark_continuous;
336 break;
337 case RTFKeyword::SBKCOL:
338 nParam = NS_ooxml::LN_Value_ST_SectionMark_nextColumn;
339 break;
340 case RTFKeyword::SBKPAGE:
341 nParam = NS_ooxml::LN_Value_ST_SectionMark_nextPage;
342 break;
343 case RTFKeyword::SBKEVEN:
344 nParam = NS_ooxml::LN_Value_ST_SectionMark_evenPage;
345 break;
346 case RTFKeyword::SBKODD:
347 nParam = NS_ooxml::LN_Value_ST_SectionMark_oddPage;
348 break;
349 default:
350 break;
352 if (nParam >= 0)
354 if (m_nResetBreakOnSectBreak != RTFKeyword::invalid)
356 m_nResetBreakOnSectBreak = nKeyword;
358 auto pValue = new RTFValue(nParam);
359 m_aStates.top().getSectionSprms().set(NS_ooxml::LN_EG_SectPrContents_type, pValue);
360 return RTFError::OK;
363 // Footnote numbering
364 switch (nKeyword)
366 case RTFKeyword::FTNNAR:
367 nParam = NS_ooxml::LN_Value_ST_NumberFormat_decimal;
368 break;
369 case RTFKeyword::FTNNALC:
370 nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter;
371 break;
372 case RTFKeyword::FTNNAUC:
373 nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperLetter;
374 break;
375 case RTFKeyword::FTNNRLC:
376 nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman;
377 break;
378 case RTFKeyword::FTNNRUC:
379 nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperRoman;
380 break;
381 case RTFKeyword::FTNNCHI:
382 nParam = NS_ooxml::LN_Value_ST_NumberFormat_chicago;
383 break;
384 default:
385 break;
387 if (nParam >= 0)
389 auto pInner = new RTFValue(nParam);
390 RTFSprms aAttributes;
391 aAttributes.set(NS_ooxml::LN_CT_NumFmt_val, pInner);
392 auto pOuter = new RTFValue(aAttributes);
393 putNestedSprm(m_aDefaultState.getParagraphSprms(),
394 NS_ooxml::LN_EG_SectPrContents_footnotePr, NS_ooxml::LN_CT_FtnProps_numFmt,
395 pOuter);
396 return RTFError::OK;
399 // Footnote restart type
400 switch (nKeyword)
402 case RTFKeyword::FTNRSTPG:
403 nParam = NS_ooxml::LN_Value_ST_RestartNumber_eachPage;
404 break;
405 case RTFKeyword::FTNRESTART:
406 nParam = NS_ooxml::LN_Value_ST_RestartNumber_eachSect;
407 break;
408 case RTFKeyword::FTNRSTCONT:
409 nParam = NS_ooxml::LN_Value_ST_RestartNumber_continuous;
410 break;
411 default:
412 break;
414 if (nParam >= 0)
416 auto pValue = new RTFValue(nParam);
417 putNestedSprm(m_aDefaultState.getParagraphSprms(),
418 NS_ooxml::LN_EG_SectPrContents_footnotePr,
419 NS_ooxml::LN_EG_FtnEdnNumProps_numRestart, pValue);
420 return RTFError::OK;
423 // Endnote numbering
424 switch (nKeyword)
426 case RTFKeyword::AFTNNAR:
427 nParam = NS_ooxml::LN_Value_ST_NumberFormat_decimal;
428 break;
429 case RTFKeyword::AFTNNALC:
430 nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter;
431 break;
432 case RTFKeyword::AFTNNAUC:
433 nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperLetter;
434 break;
435 case RTFKeyword::AFTNNRLC:
436 nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman;
437 break;
438 case RTFKeyword::AFTNNRUC:
439 nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperRoman;
440 break;
441 case RTFKeyword::AFTNNCHI:
442 nParam = NS_ooxml::LN_Value_ST_NumberFormat_chicago;
443 break;
444 default:
445 break;
447 if (nParam >= 0)
449 auto pInner = new RTFValue(nParam);
450 RTFSprms aAttributes;
451 aAttributes.set(NS_ooxml::LN_CT_NumFmt_val, pInner);
452 auto pOuter = new RTFValue(aAttributes);
453 putNestedSprm(m_aDefaultState.getParagraphSprms(), NS_ooxml::LN_EG_SectPrContents_endnotePr,
454 NS_ooxml::LN_CT_EdnProps_numFmt, pOuter);
455 return RTFError::OK;
458 switch (nKeyword)
460 case RTFKeyword::TRQL:
461 nParam = NS_ooxml::LN_Value_ST_Jc_left;
462 break;
463 case RTFKeyword::TRQC:
464 nParam = NS_ooxml::LN_Value_ST_Jc_center;
465 break;
466 case RTFKeyword::TRQR:
467 nParam = NS_ooxml::LN_Value_ST_Jc_right;
468 break;
469 default:
470 break;
472 if (nParam >= 0)
474 auto pValue = new RTFValue(nParam);
475 m_aStates.top().getTableRowSprms().set(NS_ooxml::LN_CT_TrPrBase_jc, pValue);
476 return RTFError::OK;
479 // Cell Text Flow
480 switch (nKeyword)
482 case RTFKeyword::CLTXLRTB:
483 nParam = NS_ooxml::LN_Value_ST_TextDirection_lrTb;
484 break;
485 case RTFKeyword::CLTXTBRL:
486 nParam = NS_ooxml::LN_Value_ST_TextDirection_tbRl;
487 break;
488 case RTFKeyword::CLTXBTLR:
489 nParam = NS_ooxml::LN_Value_ST_TextDirection_btLr;
490 break;
491 case RTFKeyword::CLTXLRTBV:
492 nParam = NS_ooxml::LN_Value_ST_TextDirection_lrTbV;
493 break;
494 case RTFKeyword::CLTXTBRLV:
495 nParam = NS_ooxml::LN_Value_ST_TextDirection_tbRlV;
496 break;
497 default:
498 break;
500 if (nParam >= 0)
502 auto pValue = new RTFValue(nParam);
503 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_textDirection, pValue);
506 // Trivial paragraph flags
507 switch (nKeyword)
509 case RTFKeyword::KEEP:
510 if (m_aStates.top().getCurrentBuffer() != &m_aTableBufferStack.back())
511 nParam = NS_ooxml::LN_CT_PPrBase_keepLines;
512 break;
513 case RTFKeyword::KEEPN:
514 nParam = NS_ooxml::LN_CT_PPrBase_keepNext;
515 break;
516 case RTFKeyword::INTBL:
518 m_aStates.top().setCurrentBuffer(&m_aTableBufferStack.back());
519 nParam = NS_ooxml::LN_inTbl;
521 break;
522 case RTFKeyword::PAGEBB:
523 nParam = NS_ooxml::LN_CT_PPrBase_pageBreakBefore;
524 break;
525 default:
526 break;
528 if (nParam >= 0)
530 auto pValue = new RTFValue(1);
531 m_aStates.top().getParagraphSprms().set(nParam, pValue);
532 return RTFError::OK;
535 if (dispatchFloatingTableFlag(nKeyword))
537 return RTFError::OK;
540 switch (nKeyword)
542 case RTFKeyword::FNIL:
543 case RTFKeyword::FROMAN:
544 case RTFKeyword::FSWISS:
545 case RTFKeyword::FMODERN:
546 case RTFKeyword::FSCRIPT:
547 case RTFKeyword::FDECOR:
548 case RTFKeyword::FTECH:
549 case RTFKeyword::FBIDI:
550 // TODO ooxml:CT_Font_family seems to be ignored by the domain mapper
551 break;
552 case RTFKeyword::ANSI:
553 m_aStates.top().setCurrentEncoding(RTL_TEXTENCODING_MS_1252);
554 break;
555 case RTFKeyword::MAC:
556 m_aDefaultState.setCurrentEncoding(RTL_TEXTENCODING_APPLE_ROMAN);
557 m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
558 break;
559 case RTFKeyword::PC:
560 m_aDefaultState.setCurrentEncoding(RTL_TEXTENCODING_IBM_437);
561 m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
562 break;
563 case RTFKeyword::PCA:
564 m_aDefaultState.setCurrentEncoding(RTL_TEXTENCODING_IBM_850);
565 m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
566 break;
567 case RTFKeyword::PLAIN:
569 m_aStates.top().getCharacterSprms() = getDefaultState().getCharacterSprms();
570 m_aStates.top().setCurrentEncoding(getEncoding(getFontIndex(m_nDefaultFontIndex)));
571 m_aStates.top().getCharacterAttributes() = getDefaultState().getCharacterAttributes();
572 m_aStates.top().setCurrentCharacterStyleIndex(-1);
573 m_aStates.top().setRunType(RTFParserState::RunType::NONE);
575 break;
576 case RTFKeyword::PARD:
578 if (m_bHadPicture)
579 dispatchSymbol(RTFKeyword::PAR);
580 // \pard is allowed between \cell and \row, but in that case it should not reset the fact that we're inside a table.
581 // It should not reset the paragraph style, either, so remember the old paragraph style.
582 RTFValue::Pointer_t pOldStyle
583 = m_aStates.top().getParagraphSprms().find(NS_ooxml::LN_CT_PPrBase_pStyle);
584 m_aStates.top().getParagraphSprms() = m_aDefaultState.getParagraphSprms();
585 m_aStates.top().getParagraphAttributes() = m_aDefaultState.getParagraphAttributes();
587 if (m_nTopLevelCells == 0 && m_nNestedCells == 0)
589 // Reset that we're in a table.
590 m_aStates.top().setCurrentBuffer(nullptr);
592 else
594 // We are still in a table.
595 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_inTbl, new RTFValue(1));
596 if (m_bAfterCellBeforeRow && pOldStyle)
597 // And we still have the same paragraph style.
598 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_pStyle,
599 pOldStyle);
600 // Ideally getDefaultSPRM() would take care of this, but it would not when we're buffering.
601 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_tabs,
602 new RTFValue());
604 resetFrame();
606 // Reset currently selected paragraph style as well, unless we are in the special "after \cell, before \row" state.
607 // By default the style with index 0 is applied.
608 if (!m_bAfterCellBeforeRow)
610 OUString const aName = getStyleName(0);
611 // But only in case it's not a character style.
612 if (!aName.isEmpty()
613 && getStyleType(0) != NS_ooxml::LN_Value_ST_StyleType_character)
615 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_pStyle,
616 new RTFValue(aName));
618 m_aStates.top().setCurrentStyleIndex(0);
620 // Need to send paragraph properties again, if there will be any.
621 m_bNeedPap = true;
622 break;
624 case RTFKeyword::SECTD:
626 m_aStates.top().getSectionSprms() = m_aDefaultState.getSectionSprms();
627 m_aStates.top().getSectionAttributes() = m_aDefaultState.getSectionAttributes();
629 break;
630 case RTFKeyword::TROWD:
632 // Back these up, in case later we still need this info.
633 backupTableRowProperties();
634 resetTableRowProperties();
635 // In case the table definition is in the middle of the row
636 // (invalid), make sure table definition is emitted.
637 m_bNeedPap = true;
639 break;
640 case RTFKeyword::WIDCTLPAR:
641 case RTFKeyword::NOWIDCTLPAR:
643 auto pValue = new RTFValue(int(nKeyword == RTFKeyword::WIDCTLPAR));
644 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_widowControl, pValue);
646 break;
647 case RTFKeyword::BOX:
649 RTFSprms aAttributes;
650 auto pValue = new RTFValue(aAttributes);
651 for (int i = 0; i < 4; i++)
652 m_aStates.top().getParagraphSprms().set(getParagraphBorder(i), pValue);
653 m_aStates.top().setBorderState(RTFBorderState::PARAGRAPH_BOX);
655 break;
656 case RTFKeyword::LTRSECT:
657 case RTFKeyword::RTLSECT:
659 auto pValue = new RTFValue(nKeyword == RTFKeyword::LTRSECT ? 0 : 1);
660 m_aStates.top().setRunType(RTFParserState::RunType::NONE);
661 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_EG_SectPrContents_textDirection,
662 pValue);
664 break;
665 case RTFKeyword::LTRPAR:
666 case RTFKeyword::RTLPAR:
668 auto pValue = new RTFValue(nKeyword == RTFKeyword::LTRPAR ? 0 : 1);
669 m_aStates.top().setRunType(RTFParserState::RunType::NONE);
670 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_bidi, pValue);
672 break;
673 case RTFKeyword::LTRROW:
674 case RTFKeyword::RTLROW:
675 m_aStates.top().setRunType(RTFParserState::RunType::NONE);
676 m_aStates.top().getTableRowSprms().set(
677 NS_ooxml::LN_CT_TblPrBase_bidiVisual,
678 new RTFValue(int(nKeyword == RTFKeyword::RTLROW)));
679 break;
680 case RTFKeyword::LTRCH:
681 // dmapper does not support this.
682 if (m_aStates.top().getRunType() == RTFParserState::RunType::RTLCH_LTRCH_1)
683 m_aStates.top().setRunType(RTFParserState::RunType::RTLCH_LTRCH_2);
684 else
685 m_aStates.top().setRunType(RTFParserState::RunType::LTRCH_RTLCH_1);
686 break;
687 case RTFKeyword::RTLCH:
688 if (m_aStates.top().getRunType() == RTFParserState::RunType::LTRCH_RTLCH_1)
689 m_aStates.top().setRunType(RTFParserState::RunType::LTRCH_RTLCH_2);
690 else
691 m_aStates.top().setRunType(RTFParserState::RunType::RTLCH_LTRCH_1);
693 if (m_aDefaultState.getCurrentEncoding() == RTL_TEXTENCODING_MS_1255)
694 m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
695 break;
696 case RTFKeyword::ULNONE:
698 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_Underline_none);
699 m_aStates.top().getCharacterAttributes().set(NS_ooxml::LN_CT_Underline_val, pValue);
701 break;
702 case RTFKeyword::NONSHPPICT:
703 case RTFKeyword::MMATHPICT: // Picture group used by readers not understanding \moMath group
704 m_aStates.top().setDestination(Destination::SKIP);
705 break;
706 case RTFKeyword::CLBRDRT:
707 case RTFKeyword::CLBRDRL:
708 case RTFKeyword::CLBRDRB:
709 case RTFKeyword::CLBRDRR:
711 RTFSprms aAttributes;
712 RTFSprms aSprms;
713 auto pValue = new RTFValue(aAttributes, aSprms);
714 switch (nKeyword)
716 case RTFKeyword::CLBRDRT:
717 nSprm = NS_ooxml::LN_CT_TcBorders_top;
718 break;
719 case RTFKeyword::CLBRDRL:
720 nSprm = NS_ooxml::LN_CT_TcBorders_left;
721 break;
722 case RTFKeyword::CLBRDRB:
723 nSprm = NS_ooxml::LN_CT_TcBorders_bottom;
724 break;
725 case RTFKeyword::CLBRDRR:
726 nSprm = NS_ooxml::LN_CT_TcBorders_right;
727 break;
728 default:
729 break;
731 putNestedSprm(m_aStates.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcBorders,
732 nSprm, pValue);
733 m_aStates.top().setBorderState(RTFBorderState::CELL);
735 break;
736 case RTFKeyword::PGBRDRT:
737 case RTFKeyword::PGBRDRL:
738 case RTFKeyword::PGBRDRB:
739 case RTFKeyword::PGBRDRR:
741 RTFSprms aAttributes;
742 RTFSprms aSprms;
743 auto pValue = new RTFValue(aAttributes, aSprms);
744 switch (nKeyword)
746 case RTFKeyword::PGBRDRT:
747 nSprm = NS_ooxml::LN_CT_PageBorders_top;
748 break;
749 case RTFKeyword::PGBRDRL:
750 nSprm = NS_ooxml::LN_CT_PageBorders_left;
751 break;
752 case RTFKeyword::PGBRDRB:
753 nSprm = NS_ooxml::LN_CT_PageBorders_bottom;
754 break;
755 case RTFKeyword::PGBRDRR:
756 nSprm = NS_ooxml::LN_CT_PageBorders_right;
757 break;
758 default:
759 break;
761 putNestedSprm(m_aStates.top().getSectionSprms(),
762 NS_ooxml::LN_EG_SectPrContents_pgBorders, nSprm, pValue);
763 m_aStates.top().setBorderState(RTFBorderState::PAGE);
765 break;
766 case RTFKeyword::BRDRT:
767 case RTFKeyword::BRDRL:
768 case RTFKeyword::BRDRB:
769 case RTFKeyword::BRDRR:
770 case RTFKeyword::BRDRBTW:
772 RTFSprms aAttributes;
773 RTFSprms aSprms;
774 auto pValue = new RTFValue(aAttributes, aSprms);
775 switch (nKeyword)
777 case RTFKeyword::BRDRT:
778 nSprm = getParagraphBorder(0);
779 break;
780 case RTFKeyword::BRDRL:
781 nSprm = getParagraphBorder(1);
782 break;
783 case RTFKeyword::BRDRB:
784 nSprm = getParagraphBorder(2);
785 break;
786 case RTFKeyword::BRDRR:
787 nSprm = getParagraphBorder(3);
788 break;
789 case RTFKeyword::BRDRBTW:
790 nSprm = getParagraphBorder(4);
791 break;
792 default:
793 break;
795 putNestedSprm(m_aStates.top().getParagraphSprms(), NS_ooxml::LN_CT_PrBase_pBdr, nSprm,
796 pValue);
797 m_aStates.top().setBorderState(RTFBorderState::PARAGRAPH);
799 break;
800 case RTFKeyword::CHBRDR:
802 RTFSprms aAttributes;
803 auto pValue = new RTFValue(aAttributes);
804 m_aStates.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_bdr, pValue);
805 m_aStates.top().setBorderState(RTFBorderState::CHARACTER);
807 break;
808 case RTFKeyword::CLMGF:
810 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_Merge_restart);
811 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_hMerge, pValue);
813 break;
814 case RTFKeyword::CLMRG:
816 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_Merge_continue);
817 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_hMerge, pValue);
819 break;
820 case RTFKeyword::CLVMGF:
822 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_Merge_restart);
823 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_vMerge, pValue);
825 break;
826 case RTFKeyword::CLVMRG:
828 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_Merge_continue);
829 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_vMerge, pValue);
831 break;
832 case RTFKeyword::CLVERTALT:
833 case RTFKeyword::CLVERTALC:
834 case RTFKeyword::CLVERTALB:
836 switch (nKeyword)
838 case RTFKeyword::CLVERTALT:
839 nParam = NS_ooxml::LN_Value_ST_VerticalJc_top;
840 break;
841 case RTFKeyword::CLVERTALC:
842 nParam = NS_ooxml::LN_Value_ST_VerticalJc_center;
843 break;
844 case RTFKeyword::CLVERTALB:
845 nParam = NS_ooxml::LN_Value_ST_VerticalJc_bottom;
846 break;
847 default:
848 break;
850 auto pValue = new RTFValue(nParam);
851 m_aStates.top().getTableCellSprms().set(NS_ooxml::LN_CT_TcPrBase_vAlign, pValue);
853 break;
854 case RTFKeyword::TRKEEP:
856 auto pValue = new RTFValue(1);
857 m_aStates.top().getTableRowSprms().set(NS_ooxml::LN_CT_TrPrBase_cantSplit, pValue);
859 break;
860 case RTFKeyword::SECTUNLOCKED:
862 auto pValue = new RTFValue(0);
863 m_aStates.top().getSectionSprms().set(NS_ooxml::LN_EG_SectPrContents_formProt, pValue);
865 break;
866 case RTFKeyword::PGNBIDIA:
867 case RTFKeyword::PGNBIDIB:
868 // These should be mapped to NS_ooxml::LN_EG_SectPrContents_pgNumType, but dmapper has no API for that at the moment.
869 break;
870 case RTFKeyword::LOCH:
871 m_aStates.top().setRunType(RTFParserState::RunType::LOCH);
872 break;
873 case RTFKeyword::HICH:
874 m_aStates.top().setRunType(RTFParserState::RunType::HICH);
875 break;
876 case RTFKeyword::DBCH:
877 m_aStates.top().setRunType(RTFParserState::RunType::DBCH);
878 break;
879 case RTFKeyword::TITLEPG:
881 auto pValue = new RTFValue(1);
882 m_aStates.top().getSectionSprms().set(NS_ooxml::LN_EG_SectPrContents_titlePg, pValue);
884 break;
885 case RTFKeyword::SUPER:
887 // Make sure character properties are not lost if the document
888 // starts with a footnote.
889 if (!isStyleSheetImport())
891 checkFirstRun();
892 checkNeedPap();
895 if (!m_aStates.top().getCurrentBuffer())
896 m_aStates.top().setCurrentBuffer(&m_aSuperBuffer);
898 auto pValue = new RTFValue("superscript");
899 m_aStates.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue);
901 break;
902 case RTFKeyword::SUB:
904 auto pValue = new RTFValue("subscript");
905 m_aStates.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue);
907 break;
908 case RTFKeyword::NOSUPERSUB:
910 if (m_aStates.top().getCurrentBuffer() == &m_aSuperBuffer)
912 replayBuffer(m_aSuperBuffer, nullptr, nullptr);
913 m_aStates.top().setCurrentBuffer(nullptr);
915 m_aStates.top().getCharacterSprms().erase(NS_ooxml::LN_EG_RPrBase_vertAlign);
917 break;
918 case RTFKeyword::LINEPPAGE:
919 case RTFKeyword::LINECONT:
921 auto pValue = new RTFValue(nKeyword == RTFKeyword::LINEPPAGE
922 ? NS_ooxml::LN_Value_ST_LineNumberRestart_newPage
923 : NS_ooxml::LN_Value_ST_LineNumberRestart_continuous);
924 putNestedAttribute(m_aStates.top().getSectionSprms(),
925 NS_ooxml::LN_EG_SectPrContents_lnNumType,
926 NS_ooxml::LN_CT_LineNumber_restart, pValue);
928 break;
929 case RTFKeyword::AENDDOC:
930 // Noop, this is the default in Writer.
931 case RTFKeyword::AENDNOTES:
932 // Noop
933 case RTFKeyword::AFTNRSTCONT:
934 // Noop, this is the default in Writer.
935 case RTFKeyword::AFTNRESTART:
936 // Noop
937 case RTFKeyword::FTNBJ:
938 // Noop, this is the default in Writer.
939 break;
940 case RTFKeyword::ENDDOC:
942 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_RestartNumber_eachSect);
943 putNestedSprm(m_aDefaultState.getParagraphSprms(),
944 NS_ooxml::LN_EG_SectPrContents_footnotePr,
945 NS_ooxml::LN_EG_FtnEdnNumProps_numRestart, pValue);
947 break;
948 case RTFKeyword::NOLINE:
949 eraseNestedAttribute(m_aStates.top().getSectionSprms(),
950 NS_ooxml::LN_EG_SectPrContents_lnNumType,
951 NS_ooxml::LN_CT_LineNumber_distance);
952 break;
953 case RTFKeyword::FORMSHADE:
954 // Noop, this is the default in Writer.
955 break;
956 case RTFKeyword::PNGBLIP:
957 m_aStates.top().getPicture().eStyle = RTFBmpStyle::PNG;
958 break;
959 case RTFKeyword::JPEGBLIP:
960 m_aStates.top().getPicture().eStyle = RTFBmpStyle::JPEG;
961 break;
962 case RTFKeyword::POSYT:
963 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
964 NS_ooxml::LN_Value_doc_ST_YAlign_top);
965 break;
966 case RTFKeyword::POSYB:
967 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
968 NS_ooxml::LN_Value_doc_ST_YAlign_bottom);
969 break;
970 case RTFKeyword::POSYC:
971 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
972 NS_ooxml::LN_Value_doc_ST_YAlign_center);
973 break;
974 case RTFKeyword::POSYIN:
975 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
976 NS_ooxml::LN_Value_doc_ST_YAlign_inside);
977 break;
978 case RTFKeyword::POSYOUT:
979 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
980 NS_ooxml::LN_Value_doc_ST_YAlign_outside);
981 break;
982 case RTFKeyword::POSYIL:
983 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign,
984 NS_ooxml::LN_Value_doc_ST_YAlign_inline);
985 break;
987 case RTFKeyword::PHMRG:
988 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hAnchor,
989 NS_ooxml::LN_Value_doc_ST_HAnchor_margin);
990 break;
991 case RTFKeyword::PVMRG:
992 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vAnchor,
993 NS_ooxml::LN_Value_doc_ST_VAnchor_margin);
994 break;
995 case RTFKeyword::PHPG:
996 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hAnchor,
997 NS_ooxml::LN_Value_doc_ST_HAnchor_page);
998 break;
999 case RTFKeyword::PVPG:
1000 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vAnchor,
1001 NS_ooxml::LN_Value_doc_ST_VAnchor_page);
1002 break;
1003 case RTFKeyword::PHCOL:
1004 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hAnchor,
1005 NS_ooxml::LN_Value_doc_ST_HAnchor_text);
1006 break;
1007 case RTFKeyword::PVPARA:
1008 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vAnchor,
1009 NS_ooxml::LN_Value_doc_ST_VAnchor_text);
1010 break;
1012 case RTFKeyword::POSXC:
1013 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign,
1014 NS_ooxml::LN_Value_doc_ST_XAlign_center);
1015 break;
1016 case RTFKeyword::POSXI:
1017 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign,
1018 NS_ooxml::LN_Value_doc_ST_XAlign_inside);
1019 break;
1020 case RTFKeyword::POSXO:
1021 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign,
1022 NS_ooxml::LN_Value_doc_ST_XAlign_outside);
1023 break;
1024 case RTFKeyword::POSXL:
1025 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign,
1026 NS_ooxml::LN_Value_doc_ST_XAlign_left);
1027 break;
1028 case RTFKeyword::POSXR:
1029 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign,
1030 NS_ooxml::LN_Value_doc_ST_XAlign_right);
1031 break;
1033 case RTFKeyword::DPLINE:
1034 case RTFKeyword::DPRECT:
1035 case RTFKeyword::DPELLIPSE:
1036 case RTFKeyword::DPTXBX:
1037 case RTFKeyword::DPPOLYLINE:
1038 case RTFKeyword::DPPOLYGON:
1040 sal_Int32 nType = 0;
1041 switch (nKeyword)
1043 case RTFKeyword::DPLINE:
1045 uno::Reference<drawing::XShape> xShape(
1046 getModelFactory()->createInstance("com.sun.star.drawing.LineShape"),
1047 uno::UNO_QUERY);
1048 m_aStates.top().getDrawingObject().setShape(xShape);
1049 break;
1051 case RTFKeyword::DPPOLYLINE:
1053 // The reason this is not a simple CustomShape is that in the old syntax we have no ViewBox info.
1054 uno::Reference<drawing::XShape> xShape(
1055 getModelFactory()->createInstance("com.sun.star.drawing.PolyLineShape"),
1056 uno::UNO_QUERY);
1057 m_aStates.top().getDrawingObject().setShape(xShape);
1058 break;
1060 case RTFKeyword::DPPOLYGON:
1062 uno::Reference<drawing::XShape> xShape(
1063 getModelFactory()->createInstance("com.sun.star.drawing.PolyPolygonShape"),
1064 uno::UNO_QUERY);
1065 m_aStates.top().getDrawingObject().setShape(xShape);
1066 break;
1068 case RTFKeyword::DPRECT:
1070 uno::Reference<drawing::XShape> xShape(
1071 getModelFactory()->createInstance("com.sun.star.drawing.RectangleShape"),
1072 uno::UNO_QUERY);
1073 m_aStates.top().getDrawingObject().setShape(xShape);
1074 break;
1076 case RTFKeyword::DPELLIPSE:
1077 nType = ESCHER_ShpInst_Ellipse;
1078 break;
1079 case RTFKeyword::DPTXBX:
1081 uno::Reference<drawing::XShape> xShape(
1082 getModelFactory()->createInstance("com.sun.star.text.TextFrame"),
1083 uno::UNO_QUERY);
1084 m_aStates.top().getDrawingObject().setShape(xShape);
1085 std::vector<beans::PropertyValue> aDefaults
1086 = RTFSdrImport::getTextFrameDefaults(false);
1087 for (const auto& rDefault : aDefaults)
1089 if (!findPropertyName(
1090 m_aStates.top().getDrawingObject().getPendingProperties(),
1091 rDefault.Name))
1092 m_aStates.top().getDrawingObject().getPendingProperties().push_back(
1093 rDefault);
1095 checkFirstRun();
1096 Mapper().startShape(m_aStates.top().getDrawingObject().getShape());
1097 m_aStates.top().getDrawingObject().setHadShapeText(true);
1099 break;
1100 default:
1101 break;
1103 if (nType)
1105 uno::Reference<drawing::XShape> xShape(
1106 getModelFactory()->createInstance("com.sun.star.drawing.CustomShape"),
1107 uno::UNO_QUERY);
1108 m_aStates.top().getDrawingObject().setShape(xShape);
1110 uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier(m_xDstDoc, uno::UNO_QUERY);
1111 uno::Reference<beans::XPropertySet> xPropertySet(
1112 m_aStates.top().getDrawingObject().getShape(), uno::UNO_QUERY);
1113 m_aStates.top().getDrawingObject().setPropertySet(xPropertySet);
1114 if (xDrawSupplier.is())
1116 uno::Reference<drawing::XShapes> xShapes = xDrawSupplier->getDrawPage();
1117 if (xShapes.is() && nKeyword != RTFKeyword::DPTXBX)
1119 // set default VertOrient before inserting
1120 m_aStates.top().getDrawingObject().getPropertySet()->setPropertyValue(
1121 "VertOrient", uno::Any(text::VertOrientation::NONE));
1122 xShapes->add(m_aStates.top().getDrawingObject().getShape());
1125 if (nType)
1127 uno::Reference<drawing::XEnhancedCustomShapeDefaulter> xDefaulter(
1128 m_aStates.top().getDrawingObject().getShape(), uno::UNO_QUERY);
1129 xDefaulter->createCustomShapeDefaults(OUString::number(nType));
1131 std::vector<beans::PropertyValue>& rPendingProperties
1132 = m_aStates.top().getDrawingObject().getPendingProperties();
1133 for (const auto& rPendingProperty : rPendingProperties)
1134 m_aStates.top().getDrawingObject().getPropertySet()->setPropertyValue(
1135 rPendingProperty.Name, rPendingProperty.Value);
1136 m_pSdrImport->resolveDhgt(m_aStates.top().getDrawingObject().getPropertySet(),
1137 m_aStates.top().getDrawingObject().getDhgt(),
1138 /*bOldStyle=*/true);
1140 break;
1141 case RTFKeyword::DOBXMARGIN:
1142 case RTFKeyword::DOBYMARGIN:
1144 beans::PropertyValue aPropertyValue;
1145 aPropertyValue.Name
1146 = (nKeyword == RTFKeyword::DOBXMARGIN ? std::u16string_view(u"HoriOrientRelation")
1147 : std::u16string_view(u"VertOrientRelation"));
1148 aPropertyValue.Value <<= text::RelOrientation::PAGE_PRINT_AREA;
1149 m_aStates.top().getDrawingObject().getPendingProperties().push_back(aPropertyValue);
1151 break;
1152 case RTFKeyword::DOBXPAGE:
1153 case RTFKeyword::DOBYPAGE:
1155 beans::PropertyValue aPropertyValue;
1156 aPropertyValue.Name
1157 = (nKeyword == RTFKeyword::DOBXPAGE ? std::u16string_view(u"HoriOrientRelation")
1158 : std::u16string_view(u"VertOrientRelation"));
1159 aPropertyValue.Value <<= text::RelOrientation::PAGE_FRAME;
1160 m_aStates.top().getDrawingObject().getPendingProperties().push_back(aPropertyValue);
1162 break;
1163 case RTFKeyword::DOBYPARA:
1165 beans::PropertyValue aPropertyValue;
1166 aPropertyValue.Name = "VertOrientRelation";
1167 aPropertyValue.Value <<= text::RelOrientation::FRAME;
1168 m_aStates.top().getDrawingObject().getPendingProperties().push_back(aPropertyValue);
1170 break;
1171 case RTFKeyword::CONTEXTUALSPACE:
1173 auto pValue = new RTFValue(1);
1174 m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_contextualSpacing,
1175 pValue);
1177 break;
1178 case RTFKeyword::LINKSTYLES:
1180 auto pValue = new RTFValue(1);
1181 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_linkStyles, pValue);
1183 break;
1184 case RTFKeyword::PNLVLBODY:
1186 auto pValue = new RTFValue(2);
1187 m_aStates.top().getTableAttributes().set(NS_ooxml::LN_CT_AbstractNum_nsid, pValue);
1189 break;
1190 case RTFKeyword::PNDEC:
1192 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_decimal);
1193 putNestedAttribute(m_aStates.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt,
1194 NS_ooxml::LN_CT_NumFmt_val, pValue);
1196 break;
1197 case RTFKeyword::PNLVLBLT:
1199 m_aStates.top().getTableAttributes().set(NS_ooxml::LN_CT_AbstractNum_nsid,
1200 new RTFValue(1));
1201 putNestedAttribute(m_aStates.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt,
1202 NS_ooxml::LN_CT_NumFmt_val,
1203 new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_bullet));
1205 break;
1206 case RTFKeyword::LANDSCAPE:
1208 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_PageOrientation_landscape);
1209 putNestedAttribute(m_aDefaultState.getSectionSprms(),
1210 NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_orient,
1211 pValue);
1212 [[fallthrough]]; // set the default + current value
1214 case RTFKeyword::LNDSCPSXN:
1216 auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_PageOrientation_landscape);
1217 putNestedAttribute(m_aStates.top().getSectionSprms(),
1218 NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_orient,
1219 pValue);
1221 break;
1222 case RTFKeyword::SHPBXPAGE:
1223 m_aStates.top().getShape().setHoriOrientRelation(text::RelOrientation::PAGE_FRAME);
1224 m_aStates.top().getShape().setHoriOrientRelationToken(
1225 NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page);
1226 break;
1227 case RTFKeyword::SHPBYPAGE:
1228 m_aStates.top().getShape().setVertOrientRelation(text::RelOrientation::PAGE_FRAME);
1229 m_aStates.top().getShape().setVertOrientRelationToken(
1230 NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page);
1231 break;
1232 case RTFKeyword::DPLINEHOLLOW:
1233 m_aStates.top().getDrawingObject().setFLine(0);
1234 break;
1235 case RTFKeyword::DPROUNDR:
1236 if (m_aStates.top().getDrawingObject().getPropertySet().is())
1237 // Seems this old syntax has no way to specify a custom radius, and this is the default
1238 m_aStates.top().getDrawingObject().getPropertySet()->setPropertyValue(
1239 "CornerRadius", uno::Any(sal_Int32(83)));
1240 break;
1241 case RTFKeyword::NOWRAP:
1242 m_aStates.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_wrap,
1243 NS_ooxml::LN_Value_doc_ST_Wrap_notBeside);
1244 break;
1245 case RTFKeyword::MNOR:
1246 m_bMathNor = true;
1247 break;
1248 case RTFKeyword::REVISIONS:
1249 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_trackRevisions, new RTFValue(1));
1250 break;
1251 case RTFKeyword::BRDRSH:
1252 putBorderProperty(m_aStates, NS_ooxml::LN_CT_Border_shadow, new RTFValue(1));
1253 break;
1254 case RTFKeyword::NOCOLBAL:
1255 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Compat_noColumnBalance, new RTFValue(1));
1256 break;
1257 case RTFKeyword::MARGMIRROR:
1258 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_mirrorMargins, new RTFValue(1));
1259 break;
1260 case RTFKeyword::SAUTOUPD:
1261 m_aStates.top().getTableSprms().set(NS_ooxml::LN_CT_Style_autoRedefine,
1262 new RTFValue(1));
1263 break;
1264 case RTFKeyword::WIDOWCTRL:
1265 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_widowControl, new RTFValue(1));
1266 break;
1267 case RTFKeyword::LINEBETCOL:
1268 putNestedAttribute(m_aStates.top().getSectionSprms(),
1269 NS_ooxml::LN_EG_SectPrContents_cols, NS_ooxml::LN_CT_Columns_sep,
1270 new RTFValue(1));
1271 break;
1272 case RTFKeyword::PGNRESTART:
1273 putNestedAttribute(m_aStates.top().getSectionSprms(),
1274 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1275 NS_ooxml::LN_CT_PageNumber_start, new RTFValue(1));
1276 break;
1277 case RTFKeyword::PGNUCLTR:
1279 auto pIntValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_upperLetter);
1280 putNestedAttribute(m_aStates.top().getSectionSprms(),
1281 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1282 NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
1284 break;
1285 case RTFKeyword::PGNLCLTR:
1287 auto pIntValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter);
1288 putNestedAttribute(m_aStates.top().getSectionSprms(),
1289 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1290 NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
1292 break;
1293 case RTFKeyword::PGNUCRM:
1295 auto pIntValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_upperRoman);
1296 putNestedAttribute(m_aStates.top().getSectionSprms(),
1297 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1298 NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
1300 break;
1301 case RTFKeyword::PGNLCRM:
1303 auto pIntValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman);
1304 putNestedAttribute(m_aStates.top().getSectionSprms(),
1305 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1306 NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
1308 break;
1309 case RTFKeyword::PGNDEC:
1311 auto pIntValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_decimal);
1312 putNestedAttribute(m_aStates.top().getSectionSprms(),
1313 NS_ooxml::LN_EG_SectPrContents_pgNumType,
1314 NS_ooxml::LN_CT_PageNumber_fmt, pIntValue);
1316 break;
1317 case RTFKeyword::HTMAUTSP:
1318 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Compat_doNotUseHTMLParagraphAutoSpacing,
1319 new RTFValue(0));
1320 break;
1321 case RTFKeyword::DNTBLNSBDB:
1322 // tdf#128428 switch off longer space sequence
1323 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_longerSpaceSequence,
1324 new RTFValue(0));
1325 break;
1326 case RTFKeyword::GUTTERPRL:
1327 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_gutterAtTop, new RTFValue(1));
1328 break;
1329 case RTFKeyword::RTLGUTTER:
1331 m_aStates.top().getSectionSprms().set(NS_ooxml::LN_EG_SectPrContents_rtlGutter,
1332 new RTFValue(1));
1334 break;
1335 case RTFKeyword::FLDLOCK:
1337 if (m_aStates.top().getDestination() == Destination::FIELD)
1338 m_aStates.top().setFieldLocked(true);
1340 break;
1341 case RTFKeyword::NOBRKWRPTBL:
1343 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Compat_doNotBreakWrappedTables,
1344 new RTFValue(0));
1346 break;
1347 default:
1349 SAL_INFO("writerfilter", "TODO handle flag '" << keywordToString(nKeyword) << "'");
1350 aSkip.setParsed(false);
1352 break;
1354 return RTFError::OK;
1357 } // namespace writerfilter
1359 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */