1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include "rtfdocumentimpl.hxx"
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/text/WrapTextMode.hpp>
14 #include <com/sun/star/document/XDocumentProperties.hpp>
15 #include <comphelper/sequence.hxx>
16 #include <i18nlangtag/languagetag.hxx>
17 #include <osl/thread.h>
18 #include <sal/log.hxx>
19 #include <rtl/tencinfo.h>
20 #include <tools/UnitConversion.hxx>
22 #include <ooxml/resourceids.hxx>
24 #include "rtfcharsets.hxx"
26 #include "rtfreferenceproperties.hxx"
27 #include "rtfskipdestination.hxx"
29 #include <unotools/defaultencoding.hxx>
30 #include <unotools/wincodepage.hxx>
32 using namespace com::sun::star
;
34 namespace writerfilter
36 static int getNumberFormat(int nParam
)
38 static const int aMap
[]
39 = { NS_ooxml::LN_Value_ST_NumberFormat_decimal
,
40 NS_ooxml::LN_Value_ST_NumberFormat_upperRoman
,
41 NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman
,
42 NS_ooxml::LN_Value_ST_NumberFormat_upperLetter
,
43 NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter
,
44 NS_ooxml::LN_Value_ST_NumberFormat_ordinal
,
45 NS_ooxml::LN_Value_ST_NumberFormat_cardinalText
,
46 NS_ooxml::LN_Value_ST_NumberFormat_ordinalText
,
47 NS_ooxml::LN_Value_ST_NumberFormat_none
, // Undefined in RTF 1.8 spec.
48 NS_ooxml::LN_Value_ST_NumberFormat_none
, // Undefined in RTF 1.8 spec.
49 NS_ooxml::LN_Value_ST_NumberFormat_ideographDigital
,
50 NS_ooxml::LN_Value_ST_NumberFormat_japaneseCounting
,
51 NS_ooxml::LN_Value_ST_NumberFormat_aiueo
,
52 NS_ooxml::LN_Value_ST_NumberFormat_iroha
,
53 NS_ooxml::LN_Value_ST_NumberFormat_decimalFullWidth
,
54 NS_ooxml::LN_Value_ST_NumberFormat_decimalHalfWidth
,
55 NS_ooxml::LN_Value_ST_NumberFormat_japaneseLegal
,
56 NS_ooxml::LN_Value_ST_NumberFormat_japaneseDigitalTenThousand
,
57 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedCircleChinese
,
58 NS_ooxml::LN_Value_ST_NumberFormat_decimalFullWidth2
,
59 NS_ooxml::LN_Value_ST_NumberFormat_aiueoFullWidth
,
60 NS_ooxml::LN_Value_ST_NumberFormat_irohaFullWidth
,
61 NS_ooxml::LN_Value_ST_NumberFormat_decimalZero
,
62 NS_ooxml::LN_Value_ST_NumberFormat_bullet
,
63 NS_ooxml::LN_Value_ST_NumberFormat_ganada
,
64 NS_ooxml::LN_Value_ST_NumberFormat_chosung
,
65 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedFullstop
,
66 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedParen
,
67 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedCircleChinese
,
68 NS_ooxml::LN_Value_ST_NumberFormat_ideographEnclosedCircle
,
69 NS_ooxml::LN_Value_ST_NumberFormat_ideographTraditional
,
70 NS_ooxml::LN_Value_ST_NumberFormat_ideographZodiac
,
71 NS_ooxml::LN_Value_ST_NumberFormat_ideographZodiacTraditional
,
72 NS_ooxml::LN_Value_ST_NumberFormat_taiwaneseCounting
,
73 NS_ooxml::LN_Value_ST_NumberFormat_ideographLegalTraditional
,
74 NS_ooxml::LN_Value_ST_NumberFormat_taiwaneseCountingThousand
,
75 NS_ooxml::LN_Value_ST_NumberFormat_taiwaneseDigital
,
76 NS_ooxml::LN_Value_ST_NumberFormat_chineseCounting
,
77 NS_ooxml::LN_Value_ST_NumberFormat_chineseLegalSimplified
,
78 NS_ooxml::LN_Value_ST_NumberFormat_chineseCountingThousand
,
79 NS_ooxml::LN_Value_ST_NumberFormat_decimal
,
80 NS_ooxml::LN_Value_ST_NumberFormat_koreanDigital
,
81 NS_ooxml::LN_Value_ST_NumberFormat_koreanCounting
,
82 NS_ooxml::LN_Value_ST_NumberFormat_koreanLegal
,
83 NS_ooxml::LN_Value_ST_NumberFormat_koreanDigital2
,
84 NS_ooxml::LN_Value_ST_NumberFormat_hebrew1
,
85 NS_ooxml::LN_Value_ST_NumberFormat_arabicAlpha
,
86 NS_ooxml::LN_Value_ST_NumberFormat_hebrew2
,
87 NS_ooxml::LN_Value_ST_NumberFormat_arabicAbjad
};
88 const int nLen
= SAL_N_ELEMENTS(aMap
);
90 if (nParam
>= 0 && nParam
< nLen
)
91 nValue
= aMap
[nParam
];
92 else // 255 and the other cases.
93 nValue
= NS_ooxml::LN_Value_ST_NumberFormat_none
;
99 bool RTFDocumentImpl::dispatchTableSprmValue(RTFKeyword nKeyword
, int nParam
)
102 tools::SvRef
<RTFValue
> pIntValue(new RTFValue(nParam
));
105 case RTFKeyword::LEVELJC
:
107 nSprm
= NS_ooxml::LN_CT_Lvl_lvlJc
;
112 nValue
= NS_ooxml::LN_Value_ST_Jc_left
;
115 nValue
= NS_ooxml::LN_Value_ST_Jc_center
;
118 nValue
= NS_ooxml::LN_Value_ST_Jc_right
;
121 pIntValue
= new RTFValue(nValue
);
124 case RTFKeyword::LEVELSTARTAT
:
125 nSprm
= NS_ooxml::LN_CT_Lvl_start
;
127 case RTFKeyword::LEVELPICTURE
:
128 nSprm
= NS_ooxml::LN_CT_Lvl_lvlPicBulletId
;
130 case RTFKeyword::SBASEDON
:
131 nSprm
= NS_ooxml::LN_CT_Style_basedOn
;
132 pIntValue
= new RTFValue(getStyleName(nParam
));
134 case RTFKeyword::SNEXT
:
135 nSprm
= NS_ooxml::LN_CT_Style_next
;
136 pIntValue
= new RTFValue(getStyleName(nParam
));
143 m_aStates
.top().getTableSprms().set(nSprm
, pIntValue
);
146 if (nKeyword
== RTFKeyword::LEVELNFC
)
148 pIntValue
= new RTFValue(getNumberFormat(nParam
));
149 putNestedAttribute(m_aStates
.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt
,
150 NS_ooxml::LN_CT_NumFmt_val
, pIntValue
);
157 bool RTFDocumentImpl::dispatchCharacterSprmValue(RTFKeyword nKeyword
, int nParam
)
160 tools::SvRef
<RTFValue
> pIntValue(new RTFValue(nParam
));
165 case RTFKeyword::AFS
:
166 switch (m_aStates
.top().getRunType())
168 case RTFParserState::RunType::HICH
:
169 case RTFParserState::RunType::RTLCH_LTRCH_1
:
170 case RTFParserState::RunType::LTRCH_RTLCH_2
:
171 nSprm
= NS_ooxml::LN_EG_RPrBase_szCs
;
173 case RTFParserState::RunType::NONE
:
174 case RTFParserState::RunType::LOCH
:
175 case RTFParserState::RunType::LTRCH_RTLCH_1
:
176 case RTFParserState::RunType::RTLCH_LTRCH_2
:
177 case RTFParserState::RunType::DBCH
:
179 nSprm
= NS_ooxml::LN_EG_RPrBase_sz
;
183 case RTFKeyword::EXPNDTW
:
184 nSprm
= NS_ooxml::LN_EG_RPrBase_spacing
;
186 case RTFKeyword::KERNING
:
187 nSprm
= NS_ooxml::LN_EG_RPrBase_kern
;
189 case RTFKeyword::CHARSCALEX
:
190 nSprm
= NS_ooxml::LN_EG_RPrBase_w
;
197 if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
199 m_aStates
.top().getTableSprms().set(nSprm
, pIntValue
);
203 m_aStates
.top().getCharacterSprms().set(nSprm
, pIntValue
);
211 bool RTFDocumentImpl::dispatchCharacterAttributeValue(RTFKeyword nKeyword
, int nParam
)
217 case RTFKeyword::LANG
:
218 case RTFKeyword::ALANG
:
219 switch (m_aStates
.top().getRunType())
221 case RTFParserState::RunType::HICH
:
222 case RTFParserState::RunType::RTLCH_LTRCH_1
:
223 case RTFParserState::RunType::LTRCH_RTLCH_2
:
224 nSprm
= NS_ooxml::LN_CT_Language_bidi
;
226 case RTFParserState::RunType::DBCH
:
227 nSprm
= NS_ooxml::LN_CT_Language_eastAsia
;
229 case RTFParserState::RunType::NONE
:
230 case RTFParserState::RunType::LOCH
:
231 case RTFParserState::RunType::LTRCH_RTLCH_1
:
232 case RTFParserState::RunType::RTLCH_LTRCH_2
:
234 nSprm
= NS_ooxml::LN_CT_Language_val
;
238 case RTFKeyword::LANGFE
: // this one is always CJK apparently
239 nSprm
= NS_ooxml::LN_CT_Language_eastAsia
;
246 LanguageTag
aTag((LanguageType(static_cast<sal_uInt16
>(nParam
))));
247 auto pValue
= new RTFValue(aTag
.getBcp47());
248 putNestedAttribute(m_aStates
.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_lang
, nSprm
,
250 // Language is a character property, but we should store it at a paragraph level as well for fields.
251 if (nKeyword
== RTFKeyword::LANG
&& m_bNeedPap
)
252 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_EG_RPrBase_lang
,
260 bool RTFDocumentImpl::dispatchParagraphSprmValue(RTFKeyword nKeyword
, int nParam
)
263 tools::SvRef
<RTFValue
> pIntValue(new RTFValue(nParam
));
267 case RTFKeyword::ITAP
:
268 nSprm
= NS_ooxml::LN_tblDepth
;
269 // tdf#117268: If \itap0 is encountered inside tables (between \cellxN and \cell), then
270 // use the default value (1), as Word apparently does
271 if (nParam
== 0 && (m_nTopLevelCells
!= 0 || m_nNestedCells
!= 0))
274 pIntValue
= new RTFValue(nParam
);
282 m_aStates
.top().getParagraphSprms().set(nSprm
, pIntValue
);
283 if (nKeyword
== RTFKeyword::ITAP
&& nParam
> 0)
285 while (m_aTableBufferStack
.size() < sal::static_int_cast
<std::size_t>(nParam
))
287 m_aTableBufferStack
.emplace_back();
289 // Invalid tables may omit INTBL after ITAP
290 dispatchFlag(RTFKeyword::INTBL
); // sets newly pushed buffer as current
291 assert(m_aStates
.top().getCurrentBuffer() == &m_aTableBufferStack
.back());
299 bool RTFDocumentImpl::dispatchInfoValue(RTFKeyword nKeyword
, int nParam
)
307 m_aStates
.top().setYear(nParam
);
313 m_aStates
.top().setMonth(nParam
);
319 m_aStates
.top().setDay(nParam
);
325 m_aStates
.top().setHour(nParam
);
329 case RTFKeyword::MIN
:
331 m_aStates
.top().setMinute(nParam
);
342 bool RTFDocumentImpl::dispatchFrameValue(RTFKeyword nKeyword
, int nParam
)
347 case RTFKeyword::ABSW
:
348 nId
= NS_ooxml::LN_CT_FramePr_w
;
350 case RTFKeyword::ABSH
:
351 nId
= NS_ooxml::LN_CT_FramePr_h
;
353 case RTFKeyword::POSX
:
355 nId
= NS_ooxml::LN_CT_FramePr_x
;
356 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign
, 0);
359 case RTFKeyword::POSY
:
361 nId
= NS_ooxml::LN_CT_FramePr_y
;
362 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign
, 0);
372 // Don't try to support text frames inside tables for now.
373 if (m_aStates
.top().getCurrentBuffer() != &m_aTableBufferStack
.back())
374 m_aStates
.top().getFrame().setSprm(nId
, nParam
);
382 bool RTFDocumentImpl::dispatchTableValue(RTFKeyword nKeyword
, int nParam
)
385 tools::SvRef
<RTFValue
> pIntValue(new RTFValue(nParam
));
389 case RTFKeyword::CELLX
:
392 (Destination::NESTEDTABLEPROPERTIES
== m_aStates
.top().getDestination())
393 ? m_nNestedCurrentCellX
394 : m_nTopLevelCurrentCellX
);
395 int nCellX
= nParam
- rCurrentCellX
;
397 if (!nCellX
&& nParam
> 0)
399 // If width of cell is 0, BUT there is a value for \cellxN use minimal
400 // possible width. But if \cellxN has no value leave 0 so autofit will
401 // try to resolve this.
403 // sw/source/filter/inc/wrtswtbl.hxx, minimal possible width of cells.
404 const int COL_DFLT_WIDTH
= 41;
405 nCellX
= COL_DFLT_WIDTH
;
408 // If there is a negative left margin, then the first cellx is relative to that.
409 RTFValue::Pointer_t pTblInd
410 = m_aStates
.top().getTableRowSprms().find(NS_ooxml::LN_CT_TblPrBase_tblInd
);
411 if (rCurrentCellX
== 0 && pTblInd
)
413 RTFValue::Pointer_t pWidth
414 = pTblInd
->getAttributes().find(NS_ooxml::LN_CT_TblWidth_w
);
415 if (pWidth
&& pWidth
->getInt() < 0)
416 nCellX
= -1 * (pWidth
->getInt() - nParam
);
419 rCurrentCellX
= nParam
;
420 auto pXValue
= new RTFValue(nCellX
);
421 m_aStates
.top().getTableRowSprms().set(NS_ooxml::LN_CT_TblGridBase_gridCol
, pXValue
,
422 RTFOverwrite::NO_APPEND
);
423 if (Destination::NESTEDTABLEPROPERTIES
== m_aStates
.top().getDestination())
426 // Push cell properties.
427 m_aNestedTableCellsSprms
.push_back(m_aStates
.top().getTableCellSprms());
428 m_aNestedTableCellsAttributes
.push_back(m_aStates
.top().getTableCellAttributes());
433 // Push cell properties.
434 m_aTopLevelTableCellsSprms
.push_back(m_aStates
.top().getTableCellSprms());
435 m_aTopLevelTableCellsAttributes
.push_back(m_aStates
.top().getTableCellAttributes());
438 m_aStates
.top().getTableCellSprms() = m_aDefaultState
.getTableCellSprms();
439 m_aStates
.top().getTableCellAttributes() = m_aDefaultState
.getTableCellAttributes();
440 // We assume text after a row definition always belongs to the table, to handle text before the real INTBL token
441 dispatchFlag(RTFKeyword::INTBL
);
444 // Wasn't in table, but now is -> tblStart.
445 RTFSprms aAttributes
;
447 aSprms
.set(NS_ooxml::LN_tblStart
, new RTFValue(1));
448 writerfilter::Reference
<Properties
>::Pointer_t pProperties
449 = new RTFReferenceProperties(std::move(aAttributes
), std::move(aSprms
));
450 Mapper().props(pProperties
);
452 m_nCellxMax
= std::max(m_nCellxMax
, nParam
);
456 case RTFKeyword::TRRH
:
458 OUString
hRule("auto");
461 tools::SvRef
<RTFValue
> pAbsValue(new RTFValue(-nParam
));
462 std::swap(pIntValue
, pAbsValue
);
469 putNestedAttribute(m_aStates
.top().getTableRowSprms(),
470 NS_ooxml::LN_CT_TrPrBase_trHeight
, NS_ooxml::LN_CT_Height_val
,
473 auto pHRule
= new RTFValue(hRule
);
474 putNestedAttribute(m_aStates
.top().getTableRowSprms(),
475 NS_ooxml::LN_CT_TrPrBase_trHeight
, NS_ooxml::LN_CT_Height_hRule
,
480 case RTFKeyword::TRLEFT
:
481 case RTFKeyword::TBLIND
:
483 // the value is in twips
484 auto const aDestination
= m_aStates
.top().getDestination();
485 int& rCurrentTRLeft((Destination::NESTEDTABLEPROPERTIES
== aDestination
)
487 : m_nTopLevelTRLeft
);
488 int& rCurrentCellX((Destination::NESTEDTABLEPROPERTIES
== aDestination
)
489 ? m_nNestedCurrentCellX
490 : m_nTopLevelCurrentCellX
);
491 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblInd
,
492 NS_ooxml::LN_CT_TblWidth_type
,
493 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
495 if (nKeyword
== RTFKeyword::TBLIND
)
497 RTFValue::Pointer_t pCellMargin
498 = m_aStates
.top().getTableRowSprms().find(NS_ooxml::LN_CT_TblPrBase_tblCellMar
);
501 RTFValue::Pointer_t pMarginLeft
502 = pCellMargin
->getSprms().find(NS_ooxml::LN_CT_TcMar_left
);
504 nParam
-= pMarginLeft
->getAttributes()
505 .find(NS_ooxml::LN_CT_TblWidth_w
)
508 rCurrentTRLeft
= nParam
;
511 rCurrentTRLeft
= rCurrentCellX
= nParam
;
513 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblInd
,
514 +NS_ooxml::LN_CT_TblWidth_w
, new RTFValue(nParam
));
518 case RTFKeyword::CLSHDNG
:
523 nValue
= NS_ooxml::LN_Value_ST_Shd_clear
;
524 else if (nParam
< 750)
525 // Values in between 1 and 250 visually closer to 0% shading (white)
526 // But this will mean "no shading" while cell actually have some.
527 // So lets use minimal available value.
528 nValue
= NS_ooxml::LN_Value_ST_Shd_pct5
;
529 else if (nParam
< 1100)
530 nValue
= NS_ooxml::LN_Value_ST_Shd_pct10
;
531 else if (nParam
< 1350)
532 nValue
= NS_ooxml::LN_Value_ST_Shd_pct12
;
533 else if (nParam
< 1750)
534 nValue
= NS_ooxml::LN_Value_ST_Shd_pct15
;
535 else if (nParam
< 2250)
536 nValue
= NS_ooxml::LN_Value_ST_Shd_pct20
;
537 else if (nParam
< 2750)
538 nValue
= NS_ooxml::LN_Value_ST_Shd_pct25
;
539 else if (nParam
< 3250)
540 nValue
= NS_ooxml::LN_Value_ST_Shd_pct30
;
541 else if (nParam
< 3600)
542 nValue
= NS_ooxml::LN_Value_ST_Shd_pct35
;
543 else if (nParam
< 3850)
544 nValue
= NS_ooxml::LN_Value_ST_Shd_pct37
;
545 else if (nParam
< 4250)
546 nValue
= NS_ooxml::LN_Value_ST_Shd_pct40
;
547 else if (nParam
< 4750)
548 nValue
= NS_ooxml::LN_Value_ST_Shd_pct45
;
549 else if (nParam
< 5250)
550 nValue
= NS_ooxml::LN_Value_ST_Shd_pct50
;
551 else if (nParam
< 5750)
552 nValue
= NS_ooxml::LN_Value_ST_Shd_pct55
;
553 else if (nParam
< 6100)
554 nValue
= NS_ooxml::LN_Value_ST_Shd_pct60
;
555 else if (nParam
< 6350)
556 nValue
= NS_ooxml::LN_Value_ST_Shd_pct62
;
557 else if (nParam
< 6750)
558 nValue
= NS_ooxml::LN_Value_ST_Shd_pct65
;
559 else if (nParam
< 7250)
560 nValue
= NS_ooxml::LN_Value_ST_Shd_pct70
;
561 else if (nParam
< 7750)
562 nValue
= NS_ooxml::LN_Value_ST_Shd_pct75
;
563 else if (nParam
< 8250)
564 nValue
= NS_ooxml::LN_Value_ST_Shd_pct80
;
565 else if (nParam
< 8600)
566 nValue
= NS_ooxml::LN_Value_ST_Shd_pct85
;
567 else if (nParam
< 8850)
568 nValue
= NS_ooxml::LN_Value_ST_Shd_pct87
;
569 else if (nParam
< 9250)
570 nValue
= NS_ooxml::LN_Value_ST_Shd_pct90
;
571 else if (nParam
< 9750)
572 nValue
= NS_ooxml::LN_Value_ST_Shd_pct95
;
575 nValue
= NS_ooxml::LN_Value_ST_Shd_solid
;
577 putNestedAttribute(m_aStates
.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_shd
,
578 NS_ooxml::LN_CT_Shd_val
, new RTFValue(nValue
));
582 case RTFKeyword::CLPADB
:
583 case RTFKeyword::CLPADL
:
584 case RTFKeyword::CLPADR
:
585 case RTFKeyword::CLPADT
:
587 RTFSprms aAttributes
;
588 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_type
,
589 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
590 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_w
, new RTFValue(nParam
));
591 // Top and left is swapped, that's what Word does.
594 case RTFKeyword::CLPADB
:
595 nSprm
= NS_ooxml::LN_CT_TcMar_bottom
;
597 case RTFKeyword::CLPADL
:
598 nSprm
= NS_ooxml::LN_CT_TcMar_top
;
600 case RTFKeyword::CLPADR
:
601 nSprm
= NS_ooxml::LN_CT_TcMar_right
;
603 case RTFKeyword::CLPADT
:
604 nSprm
= NS_ooxml::LN_CT_TcMar_left
;
609 putNestedSprm(m_aStates
.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar
,
610 nSprm
, new RTFValue(aAttributes
));
614 case RTFKeyword::TRPADDFB
:
615 case RTFKeyword::TRPADDFL
:
616 case RTFKeyword::TRPADDFR
:
617 case RTFKeyword::TRPADDFT
:
619 RTFSprms aAttributes
;
623 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_type
,
624 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
629 case RTFKeyword::TRPADDFB
:
630 nSprm
= NS_ooxml::LN_CT_TcMar_bottom
;
632 case RTFKeyword::TRPADDFL
:
633 nSprm
= NS_ooxml::LN_CT_TcMar_left
;
635 case RTFKeyword::TRPADDFR
:
636 nSprm
= NS_ooxml::LN_CT_TcMar_right
;
638 case RTFKeyword::TRPADDFT
:
639 nSprm
= NS_ooxml::LN_CT_TcMar_top
;
644 putNestedAttribute(m_aStates
.top().getTableRowSprms(),
645 NS_ooxml::LN_CT_TblPrBase_tblCellMar
, nSprm
,
646 new RTFValue(aAttributes
));
647 // tdf#74795 also set on current cell, and as default for table cells
648 // (why isn't this done by domainmapper?)
649 putNestedAttribute(m_aStates
.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar
,
650 nSprm
, new RTFValue(aAttributes
));
651 putNestedAttribute(m_aDefaultState
.getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar
,
652 nSprm
, new RTFValue(aAttributes
));
656 case RTFKeyword::TRPADDB
:
657 case RTFKeyword::TRPADDL
:
658 case RTFKeyword::TRPADDR
:
659 case RTFKeyword::TRPADDT
:
661 RTFSprms aAttributes
;
662 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_w
, new RTFValue(nParam
));
665 case RTFKeyword::TRPADDB
:
666 nSprm
= NS_ooxml::LN_CT_TcMar_bottom
;
668 case RTFKeyword::TRPADDL
:
669 nSprm
= NS_ooxml::LN_CT_TcMar_left
;
671 case RTFKeyword::TRPADDR
:
672 nSprm
= NS_ooxml::LN_CT_TcMar_right
;
674 case RTFKeyword::TRPADDT
:
675 nSprm
= NS_ooxml::LN_CT_TcMar_top
;
680 putNestedSprm(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblCellMar
,
681 nSprm
, new RTFValue(aAttributes
));
682 // tdf#74795 also set on current cell, and as default for table cells
683 // (why isn't this done by domainmapper?)
684 putNestedSprm(m_aStates
.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar
,
685 nSprm
, new RTFValue(aAttributes
));
686 putNestedSprm(m_aDefaultState
.getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar
,
687 nSprm
, new RTFValue(aAttributes
));
690 case RTFKeyword::TRGAPH
:
691 // Half of the space between the cells of a table row: default left/right table cell margin.
694 RTFSprms aAttributes
;
695 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_type
,
696 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
697 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_w
, pIntValue
);
698 // FIXME: this is wrong, it is half-gap, needs to be distinguished from margin! depending on TRPADDFL/TRPADDFR
699 putNestedSprm(m_aStates
.top().getTableRowSprms(),
700 NS_ooxml::LN_CT_TblPrBase_tblCellMar
, NS_ooxml::LN_CT_TblCellMar_left
,
701 new RTFValue(aAttributes
));
702 putNestedSprm(m_aStates
.top().getTableRowSprms(),
703 NS_ooxml::LN_CT_TblPrBase_tblCellMar
,
704 NS_ooxml::LN_CT_TblCellMar_right
, new RTFValue(aAttributes
));
707 case RTFKeyword::TRFTSWIDTH
:
708 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblW
,
709 NS_ooxml::LN_CT_TblWidth_type
, pIntValue
);
711 case RTFKeyword::TRWWIDTH
:
712 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblW
,
713 NS_ooxml::LN_CT_TblWidth_w
, pIntValue
);
722 RTFError
RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword
, int nParam
)
725 checkUnicode(/*bUnicode =*/nKeyword
!= RTFKeyword::U
, /*bHex =*/true);
726 RTFSkipDestination
aSkip(*this);
728 tools::SvRef
<RTFValue
> pIntValue(new RTFValue(nParam
));
729 // Trivial table sprms.
730 if (dispatchTableSprmValue(nKeyword
, nParam
))
735 // Trivial character sprms.
736 if (dispatchCharacterSprmValue(nKeyword
, nParam
))
741 // Trivial character attributes.
742 if (dispatchCharacterAttributeValue(nKeyword
, nParam
))
747 // Trivial paragraph sprms.
748 if (dispatchParagraphSprmValue(nKeyword
, nParam
))
754 if (dispatchInfoValue(nKeyword
, nParam
))
759 // Frame size / position.
760 if (dispatchFrameValue(nKeyword
, nParam
))
765 // Table-related values.
766 if (dispatchTableValue(nKeyword
, nParam
))
771 // Then check for the more complex ones.
776 switch (m_aStates
.top().getRunType())
778 case RTFParserState::RunType::RTLCH_LTRCH_1
:
779 case RTFParserState::RunType::LTRCH_RTLCH_2
:
780 nSprm
= NS_ooxml::LN_CT_Fonts_cs
;
782 case RTFParserState::RunType::DBCH
:
783 nSprm
= NS_ooxml::LN_CT_Fonts_eastAsia
;
785 case RTFParserState::RunType::NONE
:
786 case RTFParserState::RunType::LOCH
:
787 case RTFParserState::RunType::HICH
:
788 case RTFParserState::RunType::LTRCH_RTLCH_1
:
789 case RTFParserState::RunType::RTLCH_LTRCH_2
:
791 nSprm
= NS_ooxml::LN_CT_Fonts_ascii
;
795 if (m_aStates
.top().getDestination() == Destination::FONTTABLE
796 || m_aStates
.top().getDestination() == Destination::FONTENTRY
)
798 // Some text in buffer? It is font name. So previous font definition is complete
799 if (m_aStates
.top().getCurrentDestinationText()->getLength())
800 handleFontTableEntry();
802 m_aFontIndexes
.push_back(nParam
);
803 m_nCurrentFontIndex
= getFontIndex(nParam
);
805 else if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
807 RTFSprms aFontAttributes
;
808 aFontAttributes
.set(nSprm
, new RTFValue(m_aFontNames
[getFontIndex(nParam
)]));
809 RTFSprms aRunPropsSprms
;
810 aRunPropsSprms
.set(NS_ooxml::LN_EG_RPrBase_rFonts
, new RTFValue(aFontAttributes
));
811 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_rPr
,
812 new RTFValue(RTFSprms(), aRunPropsSprms
),
813 RTFOverwrite::NO_APPEND
);
817 m_nCurrentFontIndex
= getFontIndex(nParam
);
818 auto pValue
= new RTFValue(getFontName(m_nCurrentFontIndex
));
819 putNestedAttribute(m_aStates
.top().getCharacterSprms(),
820 NS_ooxml::LN_EG_RPrBase_rFonts
, nSprm
, pValue
);
821 if (nKeyword
== RTFKeyword::F
)
822 m_aStates
.top().setCurrentEncoding(getEncoding(m_nCurrentFontIndex
));
825 case RTFKeyword::RED
:
826 m_aStates
.top().getCurrentColor().SetRed(nParam
);
828 case RTFKeyword::GREEN
:
829 m_aStates
.top().getCurrentColor().SetGreen(nParam
);
831 case RTFKeyword::BLUE
:
832 m_aStates
.top().getCurrentColor().SetBlue(nParam
);
834 case RTFKeyword::FCHARSET
:
836 // we always send text to the domain mapper in OUString, so no
837 // need to send encoding info
839 for (i
= 0; i
< nRTFEncodings
; i
++)
841 if (aRTFEncodings
[i
].charset
== nParam
)
844 if (i
== nRTFEncodings
)
849 = aRTFEncodings
[i
].codepage
== 0 // Default (CP_ACP)
850 ? osl_getThreadTextEncoding()
851 : rtl_getTextEncodingFromWindowsCodePage(aRTFEncodings
[i
].codepage
);
852 m_aStates
.top().setCurrentEncoding(m_nCurrentEncoding
);
855 case RTFKeyword::ANSICPG
:
856 case RTFKeyword::CPG
:
858 rtl_TextEncoding nEncoding
860 ? utl_getWinTextEncodingFromLangStr(utl_getLocaleForGlobalDefaultEncoding())
861 : rtl_getTextEncodingFromWindowsCodePage(nParam
);
862 if (nKeyword
== RTFKeyword::ANSICPG
)
863 m_aDefaultState
.setCurrentEncoding(nEncoding
);
865 m_nCurrentEncoding
= nEncoding
;
866 m_aStates
.top().setCurrentEncoding(nEncoding
);
871 RTFSprms aAttributes
;
872 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
873 aAttributes
.set(NS_ooxml::LN_CT_Color_val
, pValue
);
874 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_color
,
875 new RTFValue(aAttributes
));
880 m_aStates
.top().setCurrentStyleIndex(nParam
);
882 if (m_aStates
.top().getDestination() == Destination::STYLESHEET
883 || m_aStates
.top().getDestination() == Destination::STYLEENTRY
)
885 m_nCurrentStyleIndex
= nParam
;
886 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_StyleType_paragraph
);
887 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_Style_type
,
888 pValue
); // paragraph style
892 OUString aName
= getStyleName(nParam
);
893 if (!aName
.isEmpty())
895 if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
896 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_pStyle
,
897 new RTFValue(aName
));
899 m_aStates
.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_pStyle
,
900 new RTFValue(aName
));
906 m_aStates
.top().setCurrentCharacterStyleIndex(nParam
);
907 if (m_aStates
.top().getDestination() == Destination::STYLESHEET
908 || m_aStates
.top().getDestination() == Destination::STYLEENTRY
)
910 m_nCurrentStyleIndex
= nParam
;
911 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_StyleType_character
);
912 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_Style_type
,
913 pValue
); // character style
917 OUString aName
= getStyleName(nParam
);
918 if (!aName
.isEmpty())
919 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_rStyle
,
920 new RTFValue(aName
));
924 if (m_aStates
.top().getDestination() == Destination::STYLESHEET
925 || m_aStates
.top().getDestination() == Destination::STYLEENTRY
)
927 m_nCurrentStyleIndex
= nParam
;
928 auto pValue
= new RTFValue(0); // TODO no value in enum StyleType?
929 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_Style_type
,
930 pValue
); // section style
934 if (m_aStates
.top().getDestination() == Destination::STYLESHEET
935 || m_aStates
.top().getDestination() == Destination::STYLEENTRY
)
937 m_nCurrentStyleIndex
= nParam
;
938 // FIXME the correct value would be NS_ooxml::LN_Value_ST_StyleType_table but maybe table styles mess things up in dmapper, be cautious and disable them for now
939 auto pValue
= new RTFValue(0);
940 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_Style_type
,
941 pValue
); // table style
944 case RTFKeyword::DEFF
:
945 m_nDefaultFontIndex
= nParam
;
947 case RTFKeyword::STSHFDBCH
:
948 // tdf#123703 switch off longer space sequence except in the case of the fixed compatibility setting font id 31505
950 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_longerSpaceSequence
,
953 case RTFKeyword::DEFLANG
:
954 case RTFKeyword::ADEFLANG
:
956 LanguageTag
aTag((LanguageType(static_cast<sal_uInt16
>(nParam
))));
957 auto pValue
= new RTFValue(aTag
.getBcp47());
958 putNestedAttribute(m_aStates
.top().getCharacterSprms(),
959 (nKeyword
== RTFKeyword::DEFLANG
? NS_ooxml::LN_EG_RPrBase_lang
960 : NS_ooxml::LN_CT_Language_bidi
),
964 case RTFKeyword::CHCBPAT
:
966 auto pValue
= new RTFValue(sal_uInt32(nParam
? getColorTable(nParam
) : COL_AUTO
));
967 putNestedAttribute(m_aStates
.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_shd
,
968 NS_ooxml::LN_CT_Shd_fill
, pValue
);
971 case RTFKeyword::CLCBPAT
:
972 case RTFKeyword::CLCBPATRAW
:
974 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
975 putNestedAttribute(m_aStates
.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_shd
,
976 NS_ooxml::LN_CT_Shd_fill
, pValue
);
979 case RTFKeyword::CBPAT
:
982 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
983 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PrBase_shd
,
984 NS_ooxml::LN_CT_Shd_fill
, pValue
);
987 case RTFKeyword::ULC
:
989 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
990 m_aStates
.top().getCharacterSprms().set(0x6877, pValue
);
993 case RTFKeyword::HIGHLIGHT
:
995 auto pValue
= new RTFValue(sal_uInt32(nParam
? getColorTable(nParam
) : COL_AUTO
));
996 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_highlight
, pValue
);
1000 case RTFKeyword::DN
:
1002 auto pValue
= new RTFValue(nParam
* (nKeyword
== RTFKeyword::UP
? 1 : -1));
1003 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_position
, pValue
);
1006 case RTFKeyword::HORZVERT
:
1008 auto pValue
= new RTFValue(int(true));
1009 m_aStates
.top().getCharacterAttributes().set(NS_ooxml::LN_CT_EastAsianLayout_vert
,
1012 // rotate fits to a single line
1013 m_aStates
.top().getCharacterAttributes().set(
1014 NS_ooxml::LN_CT_EastAsianLayout_vertCompress
, pValue
);
1017 case RTFKeyword::EXPND
:
1019 // Convert quarter-points to twentieths of a point
1020 auto pValue
= new RTFValue(nParam
* 5);
1021 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_spacing
, pValue
);
1024 case RTFKeyword::TWOINONE
:
1026 auto pValue
= new RTFValue(int(true));
1027 m_aStates
.top().getCharacterAttributes().set(NS_ooxml::LN_CT_EastAsianLayout_combine
,
1033 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_none
;
1036 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_round
;
1039 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_square
;
1042 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_angle
;
1045 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_curly
;
1049 m_aStates
.top().getCharacterAttributes().set(
1050 NS_ooxml::LN_CT_EastAsianLayout_combineBrackets
, new RTFValue(nId
));
1053 case RTFKeyword::SL
:
1055 // This is similar to RTFKeyword::ABSH, negative value means 'exact', positive means 'at least'.
1056 tools::SvRef
<RTFValue
> pValue(
1057 new RTFValue(NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast
));
1060 pValue
= new RTFValue(NS_ooxml::LN_Value_doc_ST_LineSpacingRule_exact
);
1061 pIntValue
= new RTFValue(-nParam
);
1063 m_aStates
.top().getParagraphAttributes().set(NS_ooxml::LN_CT_Spacing_lineRule
, pValue
);
1064 m_aStates
.top().getParagraphAttributes().set(NS_ooxml::LN_CT_Spacing_line
, pIntValue
);
1067 case RTFKeyword::SLMULT
:
1070 auto pValue
= new RTFValue(NS_ooxml::LN_Value_doc_ST_LineSpacingRule_auto
);
1071 m_aStates
.top().getParagraphAttributes().set(NS_ooxml::LN_CT_Spacing_lineRule
,
1075 case RTFKeyword::BRDRW
:
1077 // dmapper expects it in 1/8 pt, we have it in twip - but avoid rounding 1 to 0
1079 nParam
= nParam
* 2 / 5;
1080 auto pValue
= new RTFValue(nParam
);
1081 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_sz
, pValue
);
1084 case RTFKeyword::BRDRCF
:
1086 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
1087 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_color
, pValue
);
1090 case RTFKeyword::BRSP
:
1092 // dmapper expects it in points, we have it in twip
1093 auto pValue
= new RTFValue(nParam
/ 20);
1094 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_space
, pValue
);
1097 case RTFKeyword::TX
:
1099 m_aStates
.top().getTabAttributes().set(NS_ooxml::LN_CT_TabStop_pos
, pIntValue
);
1100 auto pValue
= new RTFValue(m_aStates
.top().getTabAttributes());
1101 if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
1102 putNestedSprm(m_aStates
.top().getTableSprms(), NS_ooxml::LN_CT_PPrBase_tabs
,
1103 NS_ooxml::LN_CT_Tabs_tab
, pValue
);
1105 putNestedSprm(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_tabs
,
1106 NS_ooxml::LN_CT_Tabs_tab
, pValue
);
1107 m_aStates
.top().getTabAttributes().clear();
1110 case RTFKeyword::ILVL
:
1111 putNestedSprm(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_numPr
,
1112 NS_ooxml::LN_CT_NumPr_ilvl
, pIntValue
);
1114 case RTFKeyword::LISTTEMPLATEID
:
1115 // This one is not referenced anywhere, so it's pointless to store it at the moment.
1117 case RTFKeyword::LISTID
:
1119 if (m_aStates
.top().getDestination() == Destination::LISTENTRY
)
1120 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_AbstractNum_abstractNumId
,
1122 else if (m_aStates
.top().getDestination() == Destination::LISTOVERRIDEENTRY
)
1123 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Num_abstractNumId
, pIntValue
);
1124 m_aStates
.top().setCurrentListIndex(nParam
);
1127 case RTFKeyword::LS
:
1129 if (m_aStates
.top().getDestination() == Destination::LISTOVERRIDEENTRY
)
1131 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_AbstractNum_nsid
,
1133 m_aStates
.top().setCurrentListOverrideIndex(nParam
);
1137 // Insert at the start, so properties inherited from the list
1138 // can be overridden by direct formatting. But still allow the
1139 // case when old-style paragraph numbering is already
1141 putNestedSprm(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_numPr
,
1142 NS_ooxml::LN_CT_NumPr_numId
, pIntValue
, RTFOverwrite::YES_PREPEND
);
1146 case RTFKeyword::UC
:
1147 if ((SAL_MIN_INT16
<= nParam
) && (nParam
<= SAL_MAX_INT16
))
1148 m_aStates
.top().setUc(nParam
);
1151 // sal_Unicode is unsigned 16-bit, RTF may represent that as a
1152 // signed SAL_MIN_INT16..SAL_MAX_INT16 or 0..SAL_MAX_UINT16. The
1153 // static_cast() will do the right thing.
1154 if ((SAL_MIN_INT16
<= nParam
) && (nParam
<= SAL_MAX_UINT16
))
1156 if (m_aStates
.top().getDestination() == Destination::LEVELNUMBERS
)
1159 m_aStates
.top().getLevelNumbers().push_back(sal_Int32(nParam
));
1161 // ';' in \u form is not considered valid.
1162 m_aStates
.top().setLevelNumbersValid(false);
1165 m_aUnicodeBuffer
.append(static_cast<sal_Unicode
>(nParam
));
1166 m_aStates
.top().getCharsToSkip() = m_aStates
.top().getUc();
1169 case RTFKeyword::LEVELFOLLOW
:
1184 if (!sValue
.isEmpty())
1185 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_suff
, new RTFValue(sValue
));
1188 case RTFKeyword::FPRQ
:
1190 sal_Int32 nValue
= 0;
1194 nValue
= NS_ooxml::LN_Value_ST_Pitch_default
;
1197 nValue
= NS_ooxml::LN_Value_ST_Pitch_fixed
;
1200 nValue
= NS_ooxml::LN_Value_ST_Pitch_variable
;
1205 RTFSprms aAttributes
;
1206 aAttributes
.set(NS_ooxml::LN_CT_Pitch_val
, new RTFValue(nValue
));
1207 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Font_pitch
,
1208 new RTFValue(aAttributes
));
1212 case RTFKeyword::LISTOVERRIDECOUNT
:
1213 // Ignore this for now, the exporter always emits it with a zero parameter.
1215 case RTFKeyword::PICSCALEX
:
1216 m_aStates
.top().getPicture().nScaleX
= nParam
;
1218 case RTFKeyword::PICSCALEY
:
1219 m_aStates
.top().getPicture().nScaleY
= nParam
;
1221 case RTFKeyword::PICW
:
1222 m_aStates
.top().getPicture().nWidth
= nParam
;
1224 case RTFKeyword::PICH
:
1225 m_aStates
.top().getPicture().nHeight
= nParam
;
1227 case RTFKeyword::PICWGOAL
:
1228 m_aStates
.top().getPicture().nGoalWidth
= convertTwipToMm100(nParam
);
1230 case RTFKeyword::PICHGOAL
:
1231 m_aStates
.top().getPicture().nGoalHeight
= convertTwipToMm100(nParam
);
1233 case RTFKeyword::PICCROPL
:
1234 m_aStates
.top().getPicture().nCropL
= convertTwipToMm100(nParam
);
1236 case RTFKeyword::PICCROPR
:
1237 m_aStates
.top().getPicture().nCropR
= convertTwipToMm100(nParam
);
1239 case RTFKeyword::PICCROPT
:
1240 m_aStates
.top().getPicture().nCropT
= convertTwipToMm100(nParam
);
1242 case RTFKeyword::PICCROPB
:
1243 m_aStates
.top().getPicture().nCropB
= convertTwipToMm100(nParam
);
1245 case RTFKeyword::SHPWRK
:
1251 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_bothSides
;
1254 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_left
;
1257 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_right
;
1260 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_largest
;
1265 auto pValue
= new RTFValue(nValue
);
1266 RTFValue::Pointer_t pTight
1267 = m_aStates
.top().getCharacterSprms().find(NS_ooxml::LN_EG_WrapType_wrapTight
);
1269 pTight
->getAttributes().set(NS_ooxml::LN_CT_WrapTight_wrapText
, pValue
);
1271 m_aStates
.top().getCharacterAttributes().set(NS_ooxml::LN_CT_WrapSquare_wrapText
,
1275 case RTFKeyword::SHPWR
:
1280 m_aStates
.top().getShape().setWrap(text::WrapTextMode_NONE
);
1283 m_aStates
.top().getShape().setWrap(text::WrapTextMode_PARALLEL
);
1286 m_aStates
.top().getShape().setWrap(text::WrapTextMode_THROUGH
);
1287 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_WrapType_wrapNone
,
1291 m_aStates
.top().getShape().setWrap(text::WrapTextMode_PARALLEL
);
1292 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_WrapType_wrapTight
,
1296 m_aStates
.top().getShape().setWrap(text::WrapTextMode_THROUGH
);
1301 case RTFKeyword::COLS
:
1302 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1303 NS_ooxml::LN_EG_SectPrContents_cols
, NS_ooxml::LN_CT_Columns_num
,
1306 case RTFKeyword::COLSX
:
1307 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1308 NS_ooxml::LN_EG_SectPrContents_cols
, NS_ooxml::LN_CT_Columns_space
,
1311 case RTFKeyword::COLNO
:
1312 putNestedSprm(m_aStates
.top().getSectionSprms(), NS_ooxml::LN_EG_SectPrContents_cols
,
1313 NS_ooxml::LN_CT_Columns_col
, pIntValue
);
1315 case RTFKeyword::COLW
:
1316 case RTFKeyword::COLSR
:
1318 RTFSprms
& rAttributes
= getLastAttributes(m_aStates
.top().getSectionSprms(),
1319 NS_ooxml::LN_EG_SectPrContents_cols
);
1320 rAttributes
.set((nKeyword
== RTFKeyword::COLW
? NS_ooxml::LN_CT_Column_w
1321 : NS_ooxml::LN_CT_Column_space
),
1325 case RTFKeyword::PAPERH
:
1326 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1327 NS_ooxml::LN_EG_SectPrContents_pgSz
, NS_ooxml::LN_CT_PageSz_h
,
1329 [[fallthrough
]]; // set the default + current value
1330 case RTFKeyword::PGHSXN
:
1331 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1332 NS_ooxml::LN_EG_SectPrContents_pgSz
, NS_ooxml::LN_CT_PageSz_h
,
1335 case RTFKeyword::PAPERW
:
1336 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1337 NS_ooxml::LN_EG_SectPrContents_pgSz
, NS_ooxml::LN_CT_PageSz_w
,
1339 [[fallthrough
]]; // set the default + current value
1340 case RTFKeyword::PGWSXN
:
1341 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1342 NS_ooxml::LN_EG_SectPrContents_pgSz
, NS_ooxml::LN_CT_PageSz_w
,
1345 case RTFKeyword::MARGL
:
1346 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1347 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_left
,
1349 [[fallthrough
]]; // set the default + current value
1350 case RTFKeyword::MARGLSXN
:
1351 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1352 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_left
,
1355 case RTFKeyword::MARGR
:
1356 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1357 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_right
,
1359 [[fallthrough
]]; // set the default + current value
1360 case RTFKeyword::MARGRSXN
:
1361 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1362 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_right
,
1365 case RTFKeyword::MARGT
:
1366 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1367 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_top
,
1369 [[fallthrough
]]; // set the default + current value
1370 case RTFKeyword::MARGTSXN
:
1371 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1372 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_top
,
1375 case RTFKeyword::MARGB
:
1376 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1377 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_bottom
,
1379 [[fallthrough
]]; // set the default + current value
1380 case RTFKeyword::MARGBSXN
:
1381 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1382 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_bottom
,
1385 case RTFKeyword::HEADERY
:
1386 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1387 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_header
,
1390 case RTFKeyword::FOOTERY
:
1391 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1392 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_footer
,
1395 case RTFKeyword::GUTTER
:
1396 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1397 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_gutter
,
1400 case RTFKeyword::DEFTAB
:
1401 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_defaultTabStop
, pIntValue
);
1403 case RTFKeyword::LINEMOD
:
1404 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1405 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
1406 NS_ooxml::LN_CT_LineNumber_countBy
, pIntValue
);
1408 case RTFKeyword::LINEX
:
1410 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1411 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
1412 NS_ooxml::LN_CT_LineNumber_distance
, pIntValue
);
1414 case RTFKeyword::LINESTARTS
:
1416 // OOXML <w:lnNumType w:start="..."/> is 0-based, RTF is 1-based.
1417 auto pStart
= tools::make_ref
<RTFValue
>(nParam
- 1);
1418 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1419 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
1420 NS_ooxml::LN_CT_LineNumber_start
, pStart
);
1423 case RTFKeyword::REVAUTH
:
1424 case RTFKeyword::REVAUTHDEL
:
1426 auto pValue
= new RTFValue(m_aAuthors
[nParam
]);
1427 putNestedAttribute(m_aStates
.top().getCharacterSprms(), NS_ooxml::LN_trackchange
,
1428 NS_ooxml::LN_CT_TrackChange_author
, pValue
);
1431 case RTFKeyword::REVDTTM
:
1432 case RTFKeyword::REVDTTMDEL
:
1435 OStringToOUString(DTTM22OString(nParam
), m_aStates
.top().getCurrentEncoding()));
1436 auto pValue
= new RTFValue(aStr
);
1437 putNestedAttribute(m_aStates
.top().getCharacterSprms(), NS_ooxml::LN_trackchange
,
1438 NS_ooxml::LN_CT_TrackChange_date
, pValue
);
1441 case RTFKeyword::SHPLEFT
:
1442 m_aStates
.top().getShape().setLeft(convertTwipToMm100(nParam
));
1444 case RTFKeyword::SHPTOP
:
1445 m_aStates
.top().getShape().setTop(convertTwipToMm100(nParam
));
1447 case RTFKeyword::SHPRIGHT
:
1448 m_aStates
.top().getShape().setRight(convertTwipToMm100(nParam
));
1450 case RTFKeyword::SHPBOTTOM
:
1451 m_aStates
.top().getShape().setBottom(convertTwipToMm100(nParam
));
1453 case RTFKeyword::SHPZ
:
1454 m_aStates
.top().getShape().setZ(nParam
);
1456 case RTFKeyword::FFTYPE
:
1460 m_nFormFieldType
= RTFFormFieldType::TEXT
;
1463 m_nFormFieldType
= RTFFormFieldType::CHECKBOX
;
1466 m_nFormFieldType
= RTFFormFieldType::LIST
;
1469 m_nFormFieldType
= RTFFormFieldType::NONE
;
1473 case RTFKeyword::FFDEFRES
:
1474 if (m_nFormFieldType
== RTFFormFieldType::CHECKBOX
)
1475 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFCheckBox_default
, pIntValue
);
1476 else if (m_nFormFieldType
== RTFFormFieldType::LIST
)
1477 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFDDList_default
, pIntValue
);
1479 case RTFKeyword::FFRES
:
1480 // 25 means undefined, see [MS-DOC] 2.9.79, FFDataBits.
1481 if (m_nFormFieldType
== RTFFormFieldType::CHECKBOX
&& nParam
!= 25)
1482 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFCheckBox_checked
, pIntValue
);
1483 else if (m_nFormFieldType
== RTFFormFieldType::LIST
)
1484 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFDDList_result
, pIntValue
);
1486 case RTFKeyword::EDMINS
:
1487 if (m_xDocumentProperties
.is())
1489 // tdf#116851 some RTF may be malformed
1492 m_xDocumentProperties
->setEditingDuration(nParam
);
1495 case RTFKeyword::NOFPAGES
:
1496 case RTFKeyword::NOFWORDS
:
1497 case RTFKeyword::NOFCHARS
:
1498 case RTFKeyword::NOFCHARSWS
:
1499 if (m_xDocumentProperties
.is())
1501 comphelper::SequenceAsHashMap aSeq
= m_xDocumentProperties
->getDocumentStatistics();
1505 case RTFKeyword::NOFPAGES
:
1506 aName
= "PageCount";
1509 case RTFKeyword::NOFWORDS
:
1510 aName
= "WordCount";
1512 case RTFKeyword::NOFCHARS
:
1513 aName
= "CharacterCount";
1515 case RTFKeyword::NOFCHARSWS
:
1516 aName
= "NonWhitespaceCharacterCount";
1521 if (!aName
.isEmpty())
1523 aSeq
[aName
] <<= sal_Int32(nParam
);
1524 m_xDocumentProperties
->setDocumentStatistics(aSeq
.getAsConstNamedValueList());
1528 case RTFKeyword::VERSION
:
1529 if (m_xDocumentProperties
.is())
1530 m_xDocumentProperties
->setEditingCycles(nParam
);
1532 case RTFKeyword::VERN
:
1533 // Ignore this for now, later the RTF writer version could be used to add hacks for older buggy writers.
1535 case RTFKeyword::FTNSTART
:
1536 putNestedSprm(m_aDefaultState
.getParagraphSprms(),
1537 NS_ooxml::LN_EG_SectPrContents_footnotePr
,
1538 NS_ooxml::LN_EG_FtnEdnNumProps_numStart
, pIntValue
);
1540 case RTFKeyword::AFTNSTART
:
1541 putNestedSprm(m_aDefaultState
.getParagraphSprms(),
1542 NS_ooxml::LN_EG_SectPrContents_endnotePr
,
1543 NS_ooxml::LN_EG_FtnEdnNumProps_numStart
, pIntValue
);
1545 case RTFKeyword::DFRMTXTX
:
1546 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hSpace
, nParam
);
1548 case RTFKeyword::DFRMTXTY
:
1549 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vSpace
, nParam
);
1551 case RTFKeyword::DXFRTEXT
:
1553 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hSpace
, nParam
);
1554 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vSpace
, nParam
);
1557 case RTFKeyword::FLYVERT
:
1559 RTFVertOrient
aVertOrient(nParam
);
1560 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign
,
1561 aVertOrient
.GetAlign());
1562 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vAnchor
,
1563 aVertOrient
.GetAnchor());
1566 case RTFKeyword::FLYHORZ
:
1568 RTFHoriOrient
aHoriOrient(nParam
);
1569 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign
,
1570 aHoriOrient
.GetAlign());
1571 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hAnchor
,
1572 aHoriOrient
.GetAnchor());
1575 case RTFKeyword::FLYANCHOR
:
1577 case RTFKeyword::WMETAFILE
:
1578 m_aStates
.top().getPicture().eWMetafile
= nParam
;
1580 case RTFKeyword::SB
:
1581 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_spacing
,
1582 NS_ooxml::LN_CT_Spacing_before
, pIntValue
);
1584 case RTFKeyword::SA
:
1585 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_spacing
,
1586 NS_ooxml::LN_CT_Spacing_after
, pIntValue
);
1588 case RTFKeyword::DPX
:
1589 m_aStates
.top().getDrawingObject().setLeft(convertTwipToMm100(nParam
));
1591 case RTFKeyword::DPY
:
1592 m_aStates
.top().getDrawingObject().setTop(convertTwipToMm100(nParam
));
1594 case RTFKeyword::DPXSIZE
:
1595 m_aStates
.top().getDrawingObject().setRight(convertTwipToMm100(nParam
));
1597 case RTFKeyword::DPYSIZE
:
1598 m_aStates
.top().getDrawingObject().setBottom(convertTwipToMm100(nParam
));
1600 case RTFKeyword::PNSTART
:
1601 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_start
, pIntValue
);
1603 case RTFKeyword::PNF
:
1605 auto pValue
= new RTFValue(m_aFontNames
[getFontIndex(nParam
)]);
1606 RTFSprms aAttributes
;
1607 aAttributes
.set(NS_ooxml::LN_CT_Fonts_ascii
, pValue
);
1608 putNestedSprm(m_aStates
.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_rPr
,
1609 NS_ooxml::LN_EG_RPrBase_rFonts
, new RTFValue(aAttributes
));
1612 case RTFKeyword::VIEWSCALE
:
1613 m_aSettingsTableAttributes
.set(NS_ooxml::LN_CT_Zoom_percent
, pIntValue
);
1615 case RTFKeyword::BIN
:
1617 m_aStates
.top().setInternalState(RTFInternalState::BIN
);
1618 m_aStates
.top().setBinaryToRead(nParam
);
1621 case RTFKeyword::DPLINECOR
:
1622 m_aStates
.top().getDrawingObject().setLineColorR(nParam
);
1623 m_aStates
.top().getDrawingObject().setHasLineColor(true);
1625 case RTFKeyword::DPLINECOG
:
1626 m_aStates
.top().getDrawingObject().setLineColorG(nParam
);
1627 m_aStates
.top().getDrawingObject().setHasLineColor(true);
1629 case RTFKeyword::DPLINECOB
:
1630 m_aStates
.top().getDrawingObject().setLineColorB(nParam
);
1631 m_aStates
.top().getDrawingObject().setHasLineColor(true);
1633 case RTFKeyword::DPFILLBGCR
:
1634 m_aStates
.top().getDrawingObject().setFillColorR(nParam
);
1635 m_aStates
.top().getDrawingObject().setHasFillColor(true);
1637 case RTFKeyword::DPFILLBGCG
:
1638 m_aStates
.top().getDrawingObject().setFillColorG(nParam
);
1639 m_aStates
.top().getDrawingObject().setHasFillColor(true);
1641 case RTFKeyword::DPFILLBGCB
:
1642 m_aStates
.top().getDrawingObject().setFillColorB(nParam
);
1643 m_aStates
.top().getDrawingObject().setHasFillColor(true);
1645 case RTFKeyword::DODHGT
:
1646 m_aStates
.top().getDrawingObject().setDhgt(nParam
);
1648 case RTFKeyword::DPPOLYCOUNT
:
1651 m_aStates
.top().getDrawingObject().setPolyLineCount(nParam
);
1654 case RTFKeyword::DPPTX
:
1656 RTFDrawingObject
& rDrawingObject
= m_aStates
.top().getDrawingObject();
1658 if (rDrawingObject
.getPolyLinePoints().empty())
1659 dispatchValue(RTFKeyword::DPPOLYCOUNT
, 2);
1661 rDrawingObject
.getPolyLinePoints().emplace_back(convertTwipToMm100(nParam
), 0);
1664 case RTFKeyword::DPPTY
:
1666 RTFDrawingObject
& rDrawingObject
= m_aStates
.top().getDrawingObject();
1667 if (!rDrawingObject
.getPolyLinePoints().empty())
1669 rDrawingObject
.getPolyLinePoints().back().Y
= convertTwipToMm100(nParam
);
1670 rDrawingObject
.setPolyLineCount(rDrawingObject
.getPolyLineCount() - 1);
1671 if (rDrawingObject
.getPolyLineCount() == 0 && rDrawingObject
.getPropertySet().is())
1673 uno::Sequence
<uno::Sequence
<awt::Point
>> aPointSequenceSequence
1674 = { comphelper::containerToSequence(rDrawingObject
.getPolyLinePoints()) };
1675 rDrawingObject
.getPropertySet()->setPropertyValue(
1676 "PolyPolygon", uno::Any(aPointSequenceSequence
));
1681 case RTFKeyword::SHPFBLWTXT
:
1682 // Shape is below text -> send it to the background.
1683 m_aStates
.top().getShape().setInBackground(nParam
!= 0);
1685 case RTFKeyword::FI
:
1687 if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
1689 if (m_aStates
.top().getLevelNumbersValid())
1690 putNestedAttribute(m_aStates
.top().getTableSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1691 NS_ooxml::LN_CT_Ind_firstLine
, pIntValue
);
1693 m_aInvalidListLevelFirstIndents
[m_nListLevel
] = nParam
;
1696 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1697 NS_ooxml::LN_CT_Ind_firstLine
, pIntValue
);
1700 case RTFKeyword::LI
:
1702 if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
1704 if (m_aStates
.top().getLevelNumbersValid())
1705 putNestedAttribute(m_aStates
.top().getTableSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1706 NS_ooxml::LN_CT_Ind_left
, pIntValue
);
1710 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1711 NS_ooxml::LN_CT_Ind_left
, pIntValue
);
1713 // It turns out \li should reset the \fi inherited from the stylesheet.
1714 // So set the direct formatting to zero, if we don't have such direct formatting yet.
1715 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1716 NS_ooxml::LN_CT_Ind_firstLine
, new RTFValue(0),
1717 RTFOverwrite::NO_IGNORE
);
1720 case RTFKeyword::RI
:
1721 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1722 NS_ooxml::LN_CT_Ind_right
, pIntValue
);
1724 case RTFKeyword::LIN
:
1725 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1726 NS_ooxml::LN_CT_Ind_start
, pIntValue
);
1728 case RTFKeyword::RIN
:
1729 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1730 NS_ooxml::LN_CT_Ind_end
, pIntValue
);
1732 case RTFKeyword::OUTLINELEVEL
:
1733 m_aStates
.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_outlineLvl
, pIntValue
);
1735 case RTFKeyword::PROPTYPE
:
1740 m_aStates
.top().setPropType(cppu::UnoType
<sal_Int32
>::get());
1743 m_aStates
.top().setPropType(cppu::UnoType
<double>::get());
1746 m_aStates
.top().setPropType(cppu::UnoType
<bool>::get());
1749 m_aStates
.top().setPropType(cppu::UnoType
<OUString
>::get());
1752 m_aStates
.top().setPropType(cppu::UnoType
<util::DateTime
>::get());
1757 case RTFKeyword::DIBITMAP
:
1758 m_aStates
.top().getPicture().eStyle
= RTFBmpStyle::DIBITMAP
;
1760 case RTFKeyword::TRWWIDTHA
:
1761 m_aStates
.top().setTableRowWidthAfter(nParam
);
1763 case RTFKeyword::ANIMTEXT
:
1769 nId
= NS_ooxml::LN_Value_ST_TextEffect_none
;
1772 nId
= NS_ooxml::LN_Value_ST_TextEffect_blinkBackground
;
1777 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_effect
,
1781 case RTFKeyword::VIEWBKSP
:
1783 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_displayBackgroundShape
, pIntValue
);
1784 // Send this token immediately, if it only appears before the first
1785 // run, it will be too late, we ignored the background shape already by then.
1786 outputSettingsTable();
1789 case RTFKeyword::STEXTFLOW
:
1795 nId
= NS_ooxml::LN_Value_ST_TextDirection_lrTb
;
1798 nId
= NS_ooxml::LN_Value_ST_TextDirection_tbRl
;
1804 m_aStates
.top().getSectionSprms().set(NS_ooxml::LN_EG_SectPrContents_textDirection
,
1809 case RTFKeyword::LBR
:
1815 nId
= NS_ooxml::LN_Value_ST_BrClear_left
;
1818 nId
= NS_ooxml::LN_Value_ST_BrClear_right
;
1821 nId
= NS_ooxml::LN_Value_ST_BrClear_all
;
1827 m_aStates
.top().getCharacterAttributes().set(NS_ooxml::LN_CT_Br_clear
,
1832 case RTFKeyword::PGBRDROPT
:
1834 sal_Int16 nOffsetFrom
= (nParam
& 0xe0) >> 5;
1835 bool bFromEdge
= nOffsetFrom
== 1;
1838 Id nId
= NS_ooxml::LN_Value_doc_ST_PageBorderOffset_page
;
1839 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1840 NS_ooxml::LN_EG_SectPrContents_pgBorders
,
1841 NS_ooxml::LN_CT_PageBorders_offsetFrom
, new RTFValue(nId
));
1845 case RTFKeyword::TPOSY
:
1847 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr
,
1848 NS_ooxml::LN_CT_TblPPr_tblpY
, new RTFValue(nParam
));
1851 case RTFKeyword::TPOSX
:
1853 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr
,
1854 NS_ooxml::LN_CT_TblPPr_tblpX
, new RTFValue(nParam
));
1857 case RTFKeyword::TDFRMTXTLEFT
:
1859 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr
,
1860 NS_ooxml::LN_CT_TblPPr_leftFromText
, new RTFValue(nParam
));
1863 case RTFKeyword::TDFRMTXTRIGHT
:
1865 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr
,
1866 NS_ooxml::LN_CT_TblPPr_rightFromText
, new RTFValue(nParam
));
1869 case RTFKeyword::TDFRMTXTTOP
:
1871 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr
,
1872 NS_ooxml::LN_CT_TblPPr_topFromText
, new RTFValue(nParam
));
1875 case RTFKeyword::TDFRMTXTBOTTOM
:
1877 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr
,
1878 NS_ooxml::LN_CT_TblPPr_bottomFromText
, new RTFValue(nParam
));
1883 SAL_INFO("writerfilter", "TODO handle value '" << keywordToString(nKeyword
) << "'");
1884 aSkip
.setParsed(false);
1888 return RTFError::OK
;
1891 } // namespace rtftok
1892 } // namespace writerfilter
1894 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */