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