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/mapunit.hxx>
22 #include <ooxml/resourceids.hxx>
24 #include "rtfcharsets.hxx"
26 #include "rtfreferenceproperties.hxx"
27 #include "rtfskipdestination.hxx"
29 #include <officecfg/Setup.hxx>
30 #include <officecfg/Office/Linguistic.hxx>
31 #include <unotools/wincodepage.hxx>
33 using namespace com::sun::star
;
37 OUString
getLODefaultLanguage()
39 OUString
result(::officecfg::Office::Linguistic::General::DefaultLocale::get());
41 result
= ::officecfg::Setup::L10N::ooSetupSystemLocale::get();
46 namespace writerfilter
48 static int getNumberFormat(int nParam
)
50 static const int aMap
[]
51 = { NS_ooxml::LN_Value_ST_NumberFormat_decimal
,
52 NS_ooxml::LN_Value_ST_NumberFormat_upperRoman
,
53 NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman
,
54 NS_ooxml::LN_Value_ST_NumberFormat_upperLetter
,
55 NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter
,
56 NS_ooxml::LN_Value_ST_NumberFormat_ordinal
,
57 NS_ooxml::LN_Value_ST_NumberFormat_cardinalText
,
58 NS_ooxml::LN_Value_ST_NumberFormat_ordinalText
,
59 NS_ooxml::LN_Value_ST_NumberFormat_none
, // Undefined in RTF 1.8 spec.
60 NS_ooxml::LN_Value_ST_NumberFormat_none
, // Undefined in RTF 1.8 spec.
61 NS_ooxml::LN_Value_ST_NumberFormat_ideographDigital
,
62 NS_ooxml::LN_Value_ST_NumberFormat_japaneseCounting
,
63 NS_ooxml::LN_Value_ST_NumberFormat_aiueo
,
64 NS_ooxml::LN_Value_ST_NumberFormat_iroha
,
65 NS_ooxml::LN_Value_ST_NumberFormat_decimalFullWidth
,
66 NS_ooxml::LN_Value_ST_NumberFormat_decimalHalfWidth
,
67 NS_ooxml::LN_Value_ST_NumberFormat_japaneseLegal
,
68 NS_ooxml::LN_Value_ST_NumberFormat_japaneseDigitalTenThousand
,
69 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedCircleChinese
,
70 NS_ooxml::LN_Value_ST_NumberFormat_decimalFullWidth2
,
71 NS_ooxml::LN_Value_ST_NumberFormat_aiueoFullWidth
,
72 NS_ooxml::LN_Value_ST_NumberFormat_irohaFullWidth
,
73 NS_ooxml::LN_Value_ST_NumberFormat_decimalZero
,
74 NS_ooxml::LN_Value_ST_NumberFormat_bullet
,
75 NS_ooxml::LN_Value_ST_NumberFormat_ganada
,
76 NS_ooxml::LN_Value_ST_NumberFormat_chosung
,
77 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedFullstop
,
78 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedParen
,
79 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedCircleChinese
,
80 NS_ooxml::LN_Value_ST_NumberFormat_ideographEnclosedCircle
,
81 NS_ooxml::LN_Value_ST_NumberFormat_ideographTraditional
,
82 NS_ooxml::LN_Value_ST_NumberFormat_ideographZodiac
,
83 NS_ooxml::LN_Value_ST_NumberFormat_ideographZodiacTraditional
,
84 NS_ooxml::LN_Value_ST_NumberFormat_taiwaneseCounting
,
85 NS_ooxml::LN_Value_ST_NumberFormat_ideographLegalTraditional
,
86 NS_ooxml::LN_Value_ST_NumberFormat_taiwaneseCountingThousand
,
87 NS_ooxml::LN_Value_ST_NumberFormat_taiwaneseDigital
,
88 NS_ooxml::LN_Value_ST_NumberFormat_chineseCounting
,
89 NS_ooxml::LN_Value_ST_NumberFormat_chineseLegalSimplified
,
90 NS_ooxml::LN_Value_ST_NumberFormat_chineseCountingThousand
,
91 NS_ooxml::LN_Value_ST_NumberFormat_decimal
,
92 NS_ooxml::LN_Value_ST_NumberFormat_koreanDigital
,
93 NS_ooxml::LN_Value_ST_NumberFormat_koreanCounting
,
94 NS_ooxml::LN_Value_ST_NumberFormat_koreanLegal
,
95 NS_ooxml::LN_Value_ST_NumberFormat_koreanDigital2
,
96 NS_ooxml::LN_Value_ST_NumberFormat_hebrew1
,
97 NS_ooxml::LN_Value_ST_NumberFormat_arabicAlpha
,
98 NS_ooxml::LN_Value_ST_NumberFormat_hebrew2
,
99 NS_ooxml::LN_Value_ST_NumberFormat_arabicAbjad
};
100 const int nLen
= SAL_N_ELEMENTS(aMap
);
102 if (nParam
>= 0 && nParam
< nLen
)
103 nValue
= aMap
[nParam
];
104 else // 255 and the other cases.
105 nValue
= NS_ooxml::LN_Value_ST_NumberFormat_none
;
111 RTFError
RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword
, int nParam
)
114 checkUnicode(/*bUnicode =*/nKeyword
!= RTF_U
, /*bHex =*/true);
115 RTFSkipDestination
aSkip(*this);
117 tools::SvRef
<RTFValue
> pIntValue(new RTFValue(nParam
));
118 // Trivial table sprms.
123 nSprm
= NS_ooxml::LN_CT_Lvl_lvlJc
;
128 nValue
= NS_ooxml::LN_Value_ST_Jc_left
;
131 nValue
= NS_ooxml::LN_Value_ST_Jc_center
;
134 nValue
= NS_ooxml::LN_Value_ST_Jc_right
;
137 pIntValue
= new RTFValue(nValue
);
141 nSprm
= NS_ooxml::LN_CT_Lvl_numFmt
;
142 pIntValue
= new RTFValue(getNumberFormat(nParam
));
144 case RTF_LEVELSTARTAT
:
145 nSprm
= NS_ooxml::LN_CT_Lvl_start
;
147 case RTF_LEVELPICTURE
:
148 nSprm
= NS_ooxml::LN_CT_Lvl_lvlPicBulletId
;
151 nSprm
= NS_ooxml::LN_CT_Style_basedOn
;
152 pIntValue
= new RTFValue(getStyleName(nParam
));
159 m_aStates
.top().getTableSprms().set(nSprm
, pIntValue
);
162 // Trivial character sprms.
167 switch (m_aStates
.top().getRunType())
169 case RTFParserState::RunType::HICH
:
170 case RTFParserState::RunType::RTLCH_LTRCH_1
:
171 case RTFParserState::RunType::LTRCH_RTLCH_2
:
172 case RTFParserState::RunType::DBCH
:
173 nSprm
= NS_ooxml::LN_EG_RPrBase_szCs
;
175 case RTFParserState::RunType::NONE
:
176 case RTFParserState::RunType::LOCH
:
177 case RTFParserState::RunType::LTRCH_RTLCH_1
:
178 case RTFParserState::RunType::RTLCH_LTRCH_2
:
180 nSprm
= NS_ooxml::LN_EG_RPrBase_sz
;
185 nSprm
= NS_ooxml::LN_EG_RPrBase_spacing
;
188 nSprm
= NS_ooxml::LN_EG_RPrBase_kern
;
191 nSprm
= NS_ooxml::LN_EG_RPrBase_w
;
198 m_aStates
.top().getCharacterSprms().set(nSprm
, pIntValue
);
201 // Trivial character attributes.
206 switch (m_aStates
.top().getRunType())
208 case RTFParserState::RunType::HICH
:
209 case RTFParserState::RunType::RTLCH_LTRCH_1
:
210 case RTFParserState::RunType::LTRCH_RTLCH_2
:
211 nSprm
= NS_ooxml::LN_CT_Language_bidi
;
213 case RTFParserState::RunType::DBCH
:
214 nSprm
= NS_ooxml::LN_CT_Language_eastAsia
;
216 case RTFParserState::RunType::NONE
:
217 case RTFParserState::RunType::LOCH
:
218 case RTFParserState::RunType::LTRCH_RTLCH_1
:
219 case RTFParserState::RunType::RTLCH_LTRCH_2
:
221 nSprm
= NS_ooxml::LN_CT_Language_val
;
225 case RTF_LANGFE
: // this one is always CJK apparently
226 nSprm
= NS_ooxml::LN_CT_Language_eastAsia
;
233 LanguageTag
aTag((LanguageType(static_cast<sal_uInt16
>(nParam
))));
234 auto pValue
= new RTFValue(aTag
.getBcp47());
235 putNestedAttribute(m_aStates
.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_lang
, nSprm
,
237 // Language is a character property, but we should store it at a paragraph level as well for fields.
238 if (nKeyword
== RTF_LANG
&& m_bNeedPap
)
239 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_EG_RPrBase_lang
,
243 // Trivial paragraph sprms.
247 nSprm
= NS_ooxml::LN_tblDepth
;
248 // tdf#117268: If \itap0 is encountered inside tables (between \cellxN and \cell), then
249 // use the default value (1), as Word apparently does
250 if (nParam
== 0 && (m_nTopLevelCells
!= 0 || m_nNestedCells
!= 0))
253 pIntValue
= new RTFValue(nParam
);
261 m_aStates
.top().getParagraphSprms().set(nSprm
, pIntValue
);
262 if (nKeyword
== RTF_ITAP
&& nParam
> 0)
264 while (m_aTableBufferStack
.size() < sal::static_int_cast
<std::size_t>(nParam
))
266 m_aTableBufferStack
.emplace_back(RTFBuffer_t());
268 // Invalid tables may omit INTBL after ITAP
269 dispatchFlag(RTF_INTBL
); // sets newly pushed buffer as current
270 assert(m_aStates
.top().getCurrentBuffer() == &m_aTableBufferStack
.back());
280 m_aStates
.top().setYear(nParam
);
286 m_aStates
.top().setMonth(nParam
);
292 m_aStates
.top().setDay(nParam
);
298 m_aStates
.top().setHour(nParam
);
304 m_aStates
.top().setMinute(nParam
);
314 // Frame size / position.
319 nId
= NS_ooxml::LN_CT_FramePr_w
;
322 nId
= NS_ooxml::LN_CT_FramePr_h
;
326 nId
= NS_ooxml::LN_CT_FramePr_x
;
327 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign
, 0);
332 nId
= NS_ooxml::LN_CT_FramePr_y
;
333 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign
, 0);
343 // Don't try to support text frames inside tables for now.
344 if (m_aStates
.top().getCurrentBuffer() != &m_aTableBufferStack
.back())
345 m_aStates
.top().getFrame().setSprm(nId
, nParam
);
350 // Then check for the more complex ones.
355 switch (m_aStates
.top().getRunType())
357 case RTFParserState::RunType::HICH
:
358 case RTFParserState::RunType::RTLCH_LTRCH_1
:
359 case RTFParserState::RunType::LTRCH_RTLCH_2
:
360 nSprm
= NS_ooxml::LN_CT_Fonts_cs
;
362 case RTFParserState::RunType::DBCH
:
363 nSprm
= NS_ooxml::LN_CT_Fonts_eastAsia
;
365 case RTFParserState::RunType::NONE
:
366 case RTFParserState::RunType::LOCH
:
367 case RTFParserState::RunType::LTRCH_RTLCH_1
:
368 case RTFParserState::RunType::RTLCH_LTRCH_2
:
370 nSprm
= NS_ooxml::LN_CT_Fonts_ascii
;
374 if (m_aStates
.top().getDestination() == Destination::FONTTABLE
375 || m_aStates
.top().getDestination() == Destination::FONTENTRY
)
377 m_aFontIndexes
.push_back(nParam
);
378 m_nCurrentFontIndex
= getFontIndex(nParam
);
380 else if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
382 RTFSprms aFontAttributes
;
383 aFontAttributes
.set(nSprm
, new RTFValue(m_aFontNames
[getFontIndex(nParam
)]));
384 RTFSprms aRunPropsSprms
;
385 aRunPropsSprms
.set(NS_ooxml::LN_EG_RPrBase_rFonts
, new RTFValue(aFontAttributes
));
386 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_rPr
,
387 new RTFValue(RTFSprms(), aRunPropsSprms
),
388 RTFOverwrite::NO_APPEND
);
392 m_nCurrentFontIndex
= getFontIndex(nParam
);
393 auto pValue
= new RTFValue(getFontName(m_nCurrentFontIndex
));
394 putNestedAttribute(m_aStates
.top().getCharacterSprms(),
395 NS_ooxml::LN_EG_RPrBase_rFonts
, nSprm
, pValue
);
396 if (nKeyword
== RTF_F
)
397 m_aStates
.top().setCurrentEncoding(getEncoding(m_nCurrentFontIndex
));
401 m_aStates
.top().getCurrentColor().SetRed(nParam
);
404 m_aStates
.top().getCurrentColor().SetGreen(nParam
);
407 m_aStates
.top().getCurrentColor().SetBlue(nParam
);
411 // we always send text to the domain mapper in OUString, so no
412 // need to send encoding info
414 for (i
= 0; i
< nRTFEncodings
; i
++)
416 if (aRTFEncodings
[i
].charset
== nParam
)
419 if (i
== nRTFEncodings
)
424 = aRTFEncodings
[i
].codepage
== 0 // Default (CP_ACP)
425 ? osl_getThreadTextEncoding()
426 : rtl_getTextEncodingFromWindowsCodePage(aRTFEncodings
[i
].codepage
);
427 m_aStates
.top().setCurrentEncoding(m_nCurrentEncoding
);
433 rtl_TextEncoding nEncoding
435 ? utl_getWinTextEncodingFromLangStr(getLODefaultLanguage().toUtf8().getStr())
436 : rtl_getTextEncodingFromWindowsCodePage(nParam
);
437 if (nKeyword
== RTF_ANSICPG
)
438 m_aDefaultState
.setCurrentEncoding(nEncoding
);
440 m_nCurrentEncoding
= nEncoding
;
441 m_aStates
.top().setCurrentEncoding(nEncoding
);
446 RTFSprms aAttributes
;
447 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
448 aAttributes
.set(NS_ooxml::LN_CT_Color_val
, pValue
);
449 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_color
,
450 new RTFValue(aAttributes
));
455 m_aStates
.top().setCurrentStyleIndex(nParam
);
457 if (m_aStates
.top().getDestination() == Destination::STYLESHEET
458 || m_aStates
.top().getDestination() == Destination::STYLEENTRY
)
460 m_nCurrentStyleIndex
= nParam
;
461 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_StyleType_paragraph
);
462 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_Style_type
,
463 pValue
); // paragraph style
467 OUString aName
= getStyleName(nParam
);
468 if (!aName
.isEmpty())
470 if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
471 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_pStyle
,
472 new RTFValue(aName
));
474 m_aStates
.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_pStyle
,
475 new RTFValue(aName
));
481 m_aStates
.top().setCurrentCharacterStyleIndex(nParam
);
482 if (m_aStates
.top().getDestination() == Destination::STYLESHEET
483 || m_aStates
.top().getDestination() == Destination::STYLEENTRY
)
485 m_nCurrentStyleIndex
= nParam
;
486 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_StyleType_character
);
487 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_Style_type
,
488 pValue
); // character style
492 OUString aName
= getStyleName(nParam
);
493 if (!aName
.isEmpty())
494 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_rStyle
,
495 new RTFValue(aName
));
499 if (m_aStates
.top().getDestination() == Destination::STYLESHEET
500 || m_aStates
.top().getDestination() == Destination::STYLEENTRY
)
502 m_nCurrentStyleIndex
= nParam
;
503 auto pValue
= new RTFValue(0); // TODO no value in enum StyleType?
504 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_Style_type
,
505 pValue
); // section style
509 if (m_aStates
.top().getDestination() == Destination::STYLESHEET
510 || m_aStates
.top().getDestination() == Destination::STYLEENTRY
)
512 m_nCurrentStyleIndex
= nParam
;
513 // 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
514 auto pValue
= new RTFValue(0);
515 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_Style_type
,
516 pValue
); // table style
520 m_nDefaultFontIndex
= nParam
;
523 // tdf#123703 switch off longer space sequence except in the case of the fixed compatibility setting font id 31505
525 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_longerSpaceSequence
,
531 LanguageTag
aTag((LanguageType(static_cast<sal_uInt16
>(nParam
))));
532 auto pValue
= new RTFValue(aTag
.getBcp47());
533 putNestedAttribute(m_aStates
.top().getCharacterSprms(),
534 (nKeyword
== RTF_DEFLANG
? NS_ooxml::LN_EG_RPrBase_lang
535 : NS_ooxml::LN_CT_Language_bidi
),
541 auto pValue
= new RTFValue(sal_uInt32(nParam
? getColorTable(nParam
) : COL_AUTO
));
542 putNestedAttribute(m_aStates
.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_shd
,
543 NS_ooxml::LN_CT_Shd_fill
, pValue
);
549 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
550 putNestedAttribute(m_aStates
.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_shd
,
551 NS_ooxml::LN_CT_Shd_fill
, pValue
);
557 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
558 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PrBase_shd
,
559 NS_ooxml::LN_CT_Shd_fill
, pValue
);
564 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
565 m_aStates
.top().getCharacterSprms().set(0x6877, pValue
);
570 auto pValue
= new RTFValue(sal_uInt32(nParam
? getColorTable(nParam
) : COL_AUTO
));
571 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_highlight
, pValue
);
577 auto pValue
= new RTFValue(nParam
* (nKeyword
== RTF_UP
? 1 : -1));
578 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_position
, pValue
);
583 auto pValue
= new RTFValue(int(true));
584 m_aStates
.top().getCharacterAttributes().set(NS_ooxml::LN_CT_EastAsianLayout_vert
,
587 // rotate fits to a single line
588 m_aStates
.top().getCharacterAttributes().set(
589 NS_ooxml::LN_CT_EastAsianLayout_vertCompress
, pValue
);
594 // Convert quarter-points to twentieths of a point
595 auto pValue
= new RTFValue(nParam
* 5);
596 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_spacing
, pValue
);
601 auto pValue
= new RTFValue(int(true));
602 m_aStates
.top().getCharacterAttributes().set(NS_ooxml::LN_CT_EastAsianLayout_combine
,
608 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_none
;
611 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_round
;
614 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_square
;
617 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_angle
;
620 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_curly
;
624 m_aStates
.top().getCharacterAttributes().set(
625 NS_ooxml::LN_CT_EastAsianLayout_combineBrackets
, new RTFValue(nId
));
630 // This is similar to RTF_ABSH, negative value means 'exact', positive means 'at least'.
631 tools::SvRef
<RTFValue
> pValue(
632 new RTFValue(NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast
));
635 pValue
= new RTFValue(NS_ooxml::LN_Value_doc_ST_LineSpacingRule_exact
);
636 pIntValue
= new RTFValue(-nParam
);
638 m_aStates
.top().getParagraphAttributes().set(NS_ooxml::LN_CT_Spacing_lineRule
, pValue
);
639 m_aStates
.top().getParagraphAttributes().set(NS_ooxml::LN_CT_Spacing_line
, pIntValue
);
645 auto pValue
= new RTFValue(NS_ooxml::LN_Value_doc_ST_LineSpacingRule_auto
);
646 m_aStates
.top().getParagraphAttributes().set(NS_ooxml::LN_CT_Spacing_lineRule
,
652 // dmapper expects it in 1/8 pt, we have it in twip - but avoid rounding 1 to 0
654 nParam
= nParam
* 2 / 5;
655 auto pValue
= new RTFValue(nParam
);
656 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_sz
, pValue
);
661 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
662 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_color
, pValue
);
667 // dmapper expects it in points, we have it in twip
668 auto pValue
= new RTFValue(nParam
/ 20);
669 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_space
, pValue
);
674 m_aStates
.top().getTabAttributes().set(NS_ooxml::LN_CT_TabStop_pos
, pIntValue
);
675 auto pValue
= new RTFValue(m_aStates
.top().getTabAttributes());
676 if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
677 putNestedSprm(m_aStates
.top().getTableSprms(), NS_ooxml::LN_CT_PPrBase_tabs
,
678 NS_ooxml::LN_CT_Tabs_tab
, pValue
);
680 putNestedSprm(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_tabs
,
681 NS_ooxml::LN_CT_Tabs_tab
, pValue
);
682 m_aStates
.top().getTabAttributes().clear();
686 putNestedSprm(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_numPr
,
687 NS_ooxml::LN_CT_NumPr_ilvl
, pIntValue
);
689 case RTF_LISTTEMPLATEID
:
690 // This one is not referenced anywhere, so it's pointless to store it at the moment.
694 if (m_aStates
.top().getDestination() == Destination::LISTENTRY
)
695 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_AbstractNum_abstractNumId
,
697 else if (m_aStates
.top().getDestination() == Destination::LISTOVERRIDEENTRY
)
698 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Num_abstractNumId
, pIntValue
);
699 m_aStates
.top().setCurrentListIndex(nParam
);
704 if (m_aStates
.top().getDestination() == Destination::LISTOVERRIDEENTRY
)
706 m_aStates
.top().getTableAttributes().set(NS_ooxml::LN_CT_AbstractNum_nsid
,
708 m_aStates
.top().setCurrentListOverrideIndex(nParam
);
712 // Insert at the start, so properties inherited from the list
713 // can be overridden by direct formatting. But still allow the
714 // case when old-style paragraph numbering is already
716 putNestedSprm(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_numPr
,
717 NS_ooxml::LN_CT_NumPr_numId
, pIntValue
, RTFOverwrite::YES_PREPEND
);
722 if ((SAL_MIN_INT16
<= nParam
) && (nParam
<= SAL_MAX_INT16
))
723 m_aStates
.top().setUc(nParam
);
726 // sal_Unicode is unsigned 16-bit, RTF may represent that as a
727 // signed SAL_MIN_INT16..SAL_MAX_INT16 or 0..SAL_MAX_UINT16. The
728 // static_cast() will do the right thing.
729 if ((SAL_MIN_INT16
<= nParam
) && (nParam
<= SAL_MAX_UINT16
))
731 if (m_aStates
.top().getDestination() == Destination::LEVELNUMBERS
)
734 m_aStates
.top().getLevelNumbers().push_back(sal_Int32(nParam
));
736 // ';' in \u form is not considered valid.
737 m_aStates
.top().setLevelNumbersValid(false);
740 m_aUnicodeBuffer
.append(static_cast<sal_Unicode
>(nParam
));
741 m_aStates
.top().getCharsToSkip() = m_aStates
.top().getUc();
744 case RTF_LEVELFOLLOW
:
759 if (!sValue
.isEmpty())
760 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_suff
, new RTFValue(sValue
));
765 sal_Int32 nValue
= 0;
769 nValue
= NS_ooxml::LN_Value_ST_Pitch_default
;
772 nValue
= NS_ooxml::LN_Value_ST_Pitch_fixed
;
775 nValue
= NS_ooxml::LN_Value_ST_Pitch_variable
;
780 RTFSprms aAttributes
;
781 aAttributes
.set(NS_ooxml::LN_CT_Pitch_val
, new RTFValue(nValue
));
782 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Font_pitch
,
783 new RTFValue(aAttributes
));
787 case RTF_LISTOVERRIDECOUNT
:
788 // Ignore this for now, the exporter always emits it with a zero parameter.
791 m_aStates
.top().getPicture().nScaleX
= nParam
;
794 m_aStates
.top().getPicture().nScaleY
= nParam
;
797 m_aStates
.top().getPicture().nWidth
= nParam
;
800 m_aStates
.top().getPicture().nHeight
= nParam
;
803 m_aStates
.top().getPicture().nGoalWidth
= convertTwipToMm100(nParam
);
806 m_aStates
.top().getPicture().nGoalHeight
= convertTwipToMm100(nParam
);
809 m_aStates
.top().getPicture().nCropL
= convertTwipToMm100(nParam
);
812 m_aStates
.top().getPicture().nCropR
= convertTwipToMm100(nParam
);
815 m_aStates
.top().getPicture().nCropT
= convertTwipToMm100(nParam
);
818 m_aStates
.top().getPicture().nCropB
= convertTwipToMm100(nParam
);
826 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_bothSides
;
829 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_left
;
832 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_right
;
835 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_largest
;
840 auto pValue
= new RTFValue(nValue
);
841 RTFValue::Pointer_t pTight
842 = m_aStates
.top().getCharacterSprms().find(NS_ooxml::LN_EG_WrapType_wrapTight
);
844 pTight
->getAttributes().set(NS_ooxml::LN_CT_WrapTight_wrapText
, pValue
);
846 m_aStates
.top().getCharacterAttributes().set(NS_ooxml::LN_CT_WrapSquare_wrapText
,
855 m_aStates
.top().getShape().setWrap(text::WrapTextMode_NONE
);
858 m_aStates
.top().getShape().setWrap(text::WrapTextMode_PARALLEL
);
861 m_aStates
.top().getShape().setWrap(text::WrapTextMode_THROUGH
);
862 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_WrapType_wrapNone
,
866 m_aStates
.top().getShape().setWrap(text::WrapTextMode_PARALLEL
);
867 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_WrapType_wrapTight
,
871 m_aStates
.top().getShape().setWrap(text::WrapTextMode_THROUGH
);
879 (Destination::NESTEDTABLEPROPERTIES
== m_aStates
.top().getDestination())
880 ? m_nNestedCurrentCellX
881 : m_nTopLevelCurrentCellX
);
882 int nCellX
= nParam
- rCurrentCellX
;
883 const int COL_DFLT_WIDTH
884 = 41; // sw/source/filter/inc/wrtswtbl.hxx, minimal possible width of cells.
886 nCellX
= COL_DFLT_WIDTH
;
888 // If there is a negative left margin, then the first cellx is relative to that.
889 RTFValue::Pointer_t pTblInd
890 = m_aStates
.top().getTableRowSprms().find(NS_ooxml::LN_CT_TblPrBase_tblInd
);
891 if (rCurrentCellX
== 0 && pTblInd
.get())
893 RTFValue::Pointer_t pWidth
894 = pTblInd
->getAttributes().find(NS_ooxml::LN_CT_TblWidth_w
);
895 if (pWidth
.get() && pWidth
->getInt() < 0)
896 nCellX
= -1 * (pWidth
->getInt() - nParam
);
899 rCurrentCellX
= nParam
;
900 auto pXValue
= new RTFValue(nCellX
);
901 m_aStates
.top().getTableRowSprms().set(NS_ooxml::LN_CT_TblGridBase_gridCol
, pXValue
,
902 RTFOverwrite::NO_APPEND
);
903 if (Destination::NESTEDTABLEPROPERTIES
== m_aStates
.top().getDestination())
906 // Push cell properties.
907 m_aNestedTableCellsSprms
.push_back(m_aStates
.top().getTableCellSprms());
908 m_aNestedTableCellsAttributes
.push_back(m_aStates
.top().getTableCellAttributes());
913 // Push cell properties.
914 m_aTopLevelTableCellsSprms
.push_back(m_aStates
.top().getTableCellSprms());
915 m_aTopLevelTableCellsAttributes
.push_back(m_aStates
.top().getTableCellAttributes());
918 m_aStates
.top().getTableCellSprms() = m_aDefaultState
.getTableCellSprms();
919 m_aStates
.top().getTableCellAttributes() = m_aDefaultState
.getTableCellAttributes();
920 // We assume text after a row definition always belongs to the table, to handle text before the real INTBL token
921 dispatchFlag(RTF_INTBL
);
924 // Wasn't in table, but now is -> tblStart.
925 RTFSprms aAttributes
;
927 aSprms
.set(NS_ooxml::LN_tblStart
, new RTFValue(1));
928 writerfilter::Reference
<Properties
>::Pointer_t pProperties
929 = new RTFReferenceProperties(aAttributes
, aSprms
);
930 Mapper().props(pProperties
);
932 m_nCellxMax
= std::max(m_nCellxMax
, nParam
);
937 OUString
hRule("auto");
940 tools::SvRef
<RTFValue
> pAbsValue(new RTFValue(-nParam
));
941 std::swap(pIntValue
, pAbsValue
);
948 putNestedAttribute(m_aStates
.top().getTableRowSprms(),
949 NS_ooxml::LN_CT_TrPrBase_trHeight
, NS_ooxml::LN_CT_Height_val
,
952 auto pHRule
= new RTFValue(hRule
);
953 putNestedAttribute(m_aStates
.top().getTableRowSprms(),
954 NS_ooxml::LN_CT_TrPrBase_trHeight
, NS_ooxml::LN_CT_Height_hRule
,
960 // the value is in twips
961 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblInd
,
962 NS_ooxml::LN_CT_TblWidth_type
,
963 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
964 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblInd
,
965 NS_ooxml::LN_CT_TblWidth_w
, new RTFValue(nParam
));
966 auto const aDestination
= m_aStates
.top().getDestination();
967 int& rCurrentTRLeft((Destination::NESTEDTABLEPROPERTIES
== aDestination
)
969 : m_nTopLevelTRLeft
);
970 int& rCurrentCellX((Destination::NESTEDTABLEPROPERTIES
== aDestination
)
971 ? m_nNestedCurrentCellX
972 : m_nTopLevelCurrentCellX
);
973 rCurrentTRLeft
= rCurrentCellX
= nParam
;
977 putNestedAttribute(m_aStates
.top().getSectionSprms(),
978 NS_ooxml::LN_EG_SectPrContents_cols
, NS_ooxml::LN_CT_Columns_num
,
982 putNestedAttribute(m_aStates
.top().getSectionSprms(),
983 NS_ooxml::LN_EG_SectPrContents_cols
, NS_ooxml::LN_CT_Columns_space
,
987 putNestedSprm(m_aStates
.top().getSectionSprms(), NS_ooxml::LN_EG_SectPrContents_cols
,
988 NS_ooxml::LN_CT_Columns_col
, pIntValue
);
993 RTFSprms
& rAttributes
= getLastAttributes(m_aStates
.top().getSectionSprms(),
994 NS_ooxml::LN_EG_SectPrContents_cols
);
996 (nKeyword
== RTF_COLW
? NS_ooxml::LN_CT_Column_w
: NS_ooxml::LN_CT_Column_space
),
1001 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1002 NS_ooxml::LN_EG_SectPrContents_pgSz
, NS_ooxml::LN_CT_PageSz_h
,
1004 [[fallthrough
]]; // set the default + current value
1006 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1007 NS_ooxml::LN_EG_SectPrContents_pgSz
, NS_ooxml::LN_CT_PageSz_h
,
1011 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1012 NS_ooxml::LN_EG_SectPrContents_pgSz
, NS_ooxml::LN_CT_PageSz_w
,
1014 [[fallthrough
]]; // set the default + current value
1016 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1017 NS_ooxml::LN_EG_SectPrContents_pgSz
, NS_ooxml::LN_CT_PageSz_w
,
1021 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1022 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_left
,
1024 [[fallthrough
]]; // set the default + current value
1026 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1027 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_left
,
1031 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1032 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_right
,
1034 [[fallthrough
]]; // set the default + current value
1036 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1037 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_right
,
1041 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1042 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_top
,
1044 [[fallthrough
]]; // set the default + current value
1046 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1047 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_top
,
1051 putNestedAttribute(m_aDefaultState
.getSectionSprms(),
1052 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_bottom
,
1054 [[fallthrough
]]; // set the default + current value
1056 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1057 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_bottom
,
1061 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1062 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_header
,
1066 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1067 NS_ooxml::LN_EG_SectPrContents_pgMar
, NS_ooxml::LN_CT_PageMar_footer
,
1071 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_defaultTabStop
, pIntValue
);
1074 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1075 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
1076 NS_ooxml::LN_CT_LineNumber_countBy
, pIntValue
);
1080 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1081 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
1082 NS_ooxml::LN_CT_LineNumber_distance
, pIntValue
);
1084 case RTF_LINESTARTS
:
1086 // OOXML <w:lnNumType w:start="..."/> is 0-based, RTF is 1-based.
1087 auto pStart
= tools::make_ref
<RTFValue
>(nParam
- 1);
1088 putNestedAttribute(m_aStates
.top().getSectionSprms(),
1089 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
1090 NS_ooxml::LN_CT_LineNumber_start
, pStart
);
1094 case RTF_REVAUTHDEL
:
1096 auto pValue
= new RTFValue(m_aAuthors
[nParam
]);
1097 putNestedAttribute(m_aStates
.top().getCharacterSprms(), NS_ooxml::LN_trackchange
,
1098 NS_ooxml::LN_CT_TrackChange_author
, pValue
);
1102 case RTF_REVDTTMDEL
:
1105 OStringToOUString(DTTM22OString(nParam
), m_aStates
.top().getCurrentEncoding()));
1106 auto pValue
= new RTFValue(aStr
);
1107 putNestedAttribute(m_aStates
.top().getCharacterSprms(), NS_ooxml::LN_trackchange
,
1108 NS_ooxml::LN_CT_TrackChange_date
, pValue
);
1112 m_aStates
.top().getShape().setLeft(convertTwipToMm100(nParam
));
1115 m_aStates
.top().getShape().setTop(convertTwipToMm100(nParam
));
1118 m_aStates
.top().getShape().setRight(convertTwipToMm100(nParam
));
1121 m_aStates
.top().getShape().setBottom(convertTwipToMm100(nParam
));
1124 m_aStates
.top().getShape().setZ(nParam
);
1130 m_nFormFieldType
= RTFFormFieldType::TEXT
;
1133 m_nFormFieldType
= RTFFormFieldType::CHECKBOX
;
1136 m_nFormFieldType
= RTFFormFieldType::LIST
;
1139 m_nFormFieldType
= RTFFormFieldType::NONE
;
1144 if (m_nFormFieldType
== RTFFormFieldType::CHECKBOX
)
1145 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFCheckBox_default
, pIntValue
);
1146 else if (m_nFormFieldType
== RTFFormFieldType::LIST
)
1147 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFDDList_default
, pIntValue
);
1150 // 25 means undefined, see [MS-DOC] 2.9.79, FFDataBits.
1151 if (m_nFormFieldType
== RTFFormFieldType::CHECKBOX
&& nParam
!= 25)
1152 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFCheckBox_checked
, pIntValue
);
1153 else if (m_nFormFieldType
== RTFFormFieldType::LIST
)
1154 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFDDList_result
, pIntValue
);
1157 if (m_xDocumentProperties
.is())
1159 // tdf#116851 some RTF may be malformed
1162 m_xDocumentProperties
->setEditingDuration(nParam
);
1168 case RTF_NOFCHARSWS
:
1169 if (m_xDocumentProperties
.is())
1171 comphelper::SequenceAsHashMap aSeq
= m_xDocumentProperties
->getDocumentStatistics();
1176 aName
= "PageCount";
1180 aName
= "WordCount";
1183 aName
= "CharacterCount";
1185 case RTF_NOFCHARSWS
:
1186 aName
= "NonWhitespaceCharacterCount";
1191 if (!aName
.isEmpty())
1193 aSeq
[aName
] <<= sal_Int32(nParam
);
1194 m_xDocumentProperties
->setDocumentStatistics(aSeq
.getAsConstNamedValueList());
1199 if (m_xDocumentProperties
.is())
1200 m_xDocumentProperties
->setEditingCycles(nParam
);
1203 // Ignore this for now, later the RTF writer version could be used to add hacks for older buggy writers.
1206 putNestedSprm(m_aDefaultState
.getParagraphSprms(),
1207 NS_ooxml::LN_EG_SectPrContents_footnotePr
,
1208 NS_ooxml::LN_EG_FtnEdnNumProps_numStart
, pIntValue
);
1211 putNestedSprm(m_aDefaultState
.getParagraphSprms(),
1212 NS_ooxml::LN_EG_SectPrContents_endnotePr
,
1213 NS_ooxml::LN_EG_FtnEdnNumProps_numStart
, pIntValue
);
1216 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hSpace
, nParam
);
1219 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vSpace
, nParam
);
1223 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hSpace
, nParam
);
1224 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vSpace
, nParam
);
1229 RTFVertOrient
aVertOrient(nParam
);
1230 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_yAlign
,
1231 aVertOrient
.GetAlign());
1232 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_vAnchor
,
1233 aVertOrient
.GetAnchor());
1238 RTFHoriOrient
aHoriOrient(nParam
);
1239 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_xAlign
,
1240 aHoriOrient
.GetAlign());
1241 m_aStates
.top().getFrame().setSprm(NS_ooxml::LN_CT_FramePr_hAnchor
,
1242 aHoriOrient
.GetAnchor());
1248 m_aStates
.top().getPicture().eWMetafile
= nParam
;
1251 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_spacing
,
1252 NS_ooxml::LN_CT_Spacing_before
, pIntValue
);
1255 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_spacing
,
1256 NS_ooxml::LN_CT_Spacing_after
, pIntValue
);
1259 m_aStates
.top().getDrawingObject().setLeft(convertTwipToMm100(nParam
));
1262 m_aStates
.top().getDrawingObject().setTop(convertTwipToMm100(nParam
));
1265 m_aStates
.top().getDrawingObject().setRight(convertTwipToMm100(nParam
));
1268 m_aStates
.top().getDrawingObject().setBottom(convertTwipToMm100(nParam
));
1271 m_aStates
.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_start
, pIntValue
);
1275 auto pValue
= new RTFValue(m_aFontNames
[getFontIndex(nParam
)]);
1276 RTFSprms aAttributes
;
1277 aAttributes
.set(NS_ooxml::LN_CT_Fonts_ascii
, pValue
);
1278 putNestedSprm(m_aStates
.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_rPr
,
1279 NS_ooxml::LN_EG_RPrBase_rFonts
, new RTFValue(aAttributes
));
1283 m_aSettingsTableAttributes
.set(NS_ooxml::LN_CT_Zoom_percent
, pIntValue
);
1287 m_aStates
.top().setInternalState(RTFInternalState::BIN
);
1288 m_aStates
.top().setBinaryToRead(nParam
);
1292 m_aStates
.top().getDrawingObject().setLineColorR(nParam
);
1293 m_aStates
.top().getDrawingObject().setHasLineColor(true);
1296 m_aStates
.top().getDrawingObject().setLineColorG(nParam
);
1297 m_aStates
.top().getDrawingObject().setHasLineColor(true);
1300 m_aStates
.top().getDrawingObject().setLineColorB(nParam
);
1301 m_aStates
.top().getDrawingObject().setHasLineColor(true);
1303 case RTF_DPFILLBGCR
:
1304 m_aStates
.top().getDrawingObject().setFillColorR(nParam
);
1305 m_aStates
.top().getDrawingObject().setHasFillColor(true);
1307 case RTF_DPFILLBGCG
:
1308 m_aStates
.top().getDrawingObject().setFillColorG(nParam
);
1309 m_aStates
.top().getDrawingObject().setHasFillColor(true);
1311 case RTF_DPFILLBGCB
:
1312 m_aStates
.top().getDrawingObject().setFillColorB(nParam
);
1313 m_aStates
.top().getDrawingObject().setHasFillColor(true);
1321 nValue
= NS_ooxml::LN_Value_ST_Shd_pct5
;
1324 nValue
= NS_ooxml::LN_Value_ST_Shd_pct10
;
1327 nValue
= NS_ooxml::LN_Value_ST_Shd_pct12
;
1330 nValue
= NS_ooxml::LN_Value_ST_Shd_pct15
;
1333 nValue
= NS_ooxml::LN_Value_ST_Shd_pct20
;
1336 nValue
= NS_ooxml::LN_Value_ST_Shd_pct25
;
1339 nValue
= NS_ooxml::LN_Value_ST_Shd_pct30
;
1342 nValue
= NS_ooxml::LN_Value_ST_Shd_pct35
;
1345 nValue
= NS_ooxml::LN_Value_ST_Shd_pct37
;
1348 nValue
= NS_ooxml::LN_Value_ST_Shd_pct40
;
1351 nValue
= NS_ooxml::LN_Value_ST_Shd_pct45
;
1354 nValue
= NS_ooxml::LN_Value_ST_Shd_pct50
;
1357 nValue
= NS_ooxml::LN_Value_ST_Shd_pct55
;
1360 nValue
= NS_ooxml::LN_Value_ST_Shd_pct60
;
1363 nValue
= NS_ooxml::LN_Value_ST_Shd_pct62
;
1366 nValue
= NS_ooxml::LN_Value_ST_Shd_pct65
;
1369 nValue
= NS_ooxml::LN_Value_ST_Shd_pct70
;
1372 nValue
= NS_ooxml::LN_Value_ST_Shd_pct75
;
1375 nValue
= NS_ooxml::LN_Value_ST_Shd_pct80
;
1378 nValue
= NS_ooxml::LN_Value_ST_Shd_pct85
;
1381 nValue
= NS_ooxml::LN_Value_ST_Shd_pct87
;
1384 nValue
= NS_ooxml::LN_Value_ST_Shd_pct90
;
1387 nValue
= NS_ooxml::LN_Value_ST_Shd_pct95
;
1393 putNestedAttribute(m_aStates
.top().getTableCellSprms(),
1394 NS_ooxml::LN_CT_TcPrBase_shd
, NS_ooxml::LN_CT_Shd_val
,
1395 new RTFValue(nValue
));
1399 m_aStates
.top().getDrawingObject().setDhgt(nParam
);
1401 case RTF_DPPOLYCOUNT
:
1404 m_aStates
.top().getDrawingObject().setPolyLineCount(nParam
);
1409 RTFDrawingObject
& rDrawingObject
= m_aStates
.top().getDrawingObject();
1411 if (rDrawingObject
.getPolyLinePoints().empty())
1412 dispatchValue(RTF_DPPOLYCOUNT
, 2);
1414 rDrawingObject
.getPolyLinePoints().emplace_back(
1415 awt::Point(convertTwipToMm100(nParam
), 0));
1420 RTFDrawingObject
& rDrawingObject
= m_aStates
.top().getDrawingObject();
1421 if (!rDrawingObject
.getPolyLinePoints().empty())
1423 rDrawingObject
.getPolyLinePoints().back().Y
= convertTwipToMm100(nParam
);
1424 rDrawingObject
.setPolyLineCount(rDrawingObject
.getPolyLineCount() - 1);
1425 if (rDrawingObject
.getPolyLineCount() == 0 && rDrawingObject
.getPropertySet().is())
1427 uno::Sequence
<uno::Sequence
<awt::Point
>> aPointSequenceSequence
1428 = { comphelper::containerToSequence(rDrawingObject
.getPolyLinePoints()) };
1429 rDrawingObject
.getPropertySet()->setPropertyValue(
1430 "PolyPolygon", uno::Any(aPointSequenceSequence
));
1435 case RTF_SHPFBLWTXT
:
1436 // Shape is below text -> send it to the background.
1437 m_aStates
.top().getShape().setInBackground(nParam
!= 0);
1444 RTFSprms aAttributes
;
1445 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_type
,
1446 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
1447 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_w
, new RTFValue(nParam
));
1448 // Top and left is swapped, that's what Word does.
1452 nSprm
= NS_ooxml::LN_CT_TcMar_bottom
;
1455 nSprm
= NS_ooxml::LN_CT_TcMar_top
;
1458 nSprm
= NS_ooxml::LN_CT_TcMar_right
;
1461 nSprm
= NS_ooxml::LN_CT_TcMar_left
;
1466 putNestedSprm(m_aStates
.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar
,
1467 nSprm
, new RTFValue(aAttributes
));
1475 RTFSprms aAttributes
;
1479 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_type
,
1480 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
1486 nSprm
= NS_ooxml::LN_CT_TcMar_bottom
;
1489 nSprm
= NS_ooxml::LN_CT_TcMar_left
;
1492 nSprm
= NS_ooxml::LN_CT_TcMar_right
;
1495 nSprm
= NS_ooxml::LN_CT_TcMar_top
;
1500 putNestedAttribute(m_aStates
.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar
,
1501 nSprm
, new RTFValue(aAttributes
));
1502 putNestedAttribute(m_aDefaultState
.getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar
,
1503 nSprm
, new RTFValue(aAttributes
));
1511 RTFSprms aAttributes
;
1512 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_w
, new RTFValue(nParam
));
1516 nSprm
= NS_ooxml::LN_CT_TcMar_bottom
;
1519 nSprm
= NS_ooxml::LN_CT_TcMar_left
;
1522 nSprm
= NS_ooxml::LN_CT_TcMar_right
;
1525 nSprm
= NS_ooxml::LN_CT_TcMar_top
;
1530 putNestedSprm(m_aStates
.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar
,
1531 nSprm
, new RTFValue(aAttributes
));
1532 putNestedSprm(m_aDefaultState
.getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_tcMar
,
1533 nSprm
, new RTFValue(aAttributes
));
1538 if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
1540 if (m_aStates
.top().getLevelNumbersValid())
1541 putNestedAttribute(m_aStates
.top().getTableSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1542 NS_ooxml::LN_CT_Ind_firstLine
, pIntValue
);
1544 m_aInvalidListLevelFirstIndents
[m_nListLevel
] = nParam
;
1547 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1548 NS_ooxml::LN_CT_Ind_firstLine
, pIntValue
);
1553 if (m_aStates
.top().getDestination() == Destination::LISTLEVEL
)
1555 if (m_aStates
.top().getLevelNumbersValid())
1556 putNestedAttribute(m_aStates
.top().getTableSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1557 NS_ooxml::LN_CT_Ind_left
, pIntValue
);
1561 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1562 NS_ooxml::LN_CT_Ind_left
, pIntValue
);
1564 // It turns out \li should reset the \fi inherited from the stylesheet.
1565 // So set the direct formatting to zero, if we don't have such direct formatting yet.
1566 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1567 NS_ooxml::LN_CT_Ind_firstLine
, new RTFValue(0),
1568 RTFOverwrite::NO_IGNORE
);
1572 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1573 NS_ooxml::LN_CT_Ind_right
, pIntValue
);
1576 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1577 NS_ooxml::LN_CT_Ind_start
, pIntValue
);
1580 putNestedAttribute(m_aStates
.top().getParagraphSprms(), NS_ooxml::LN_CT_PPrBase_ind
,
1581 NS_ooxml::LN_CT_Ind_end
, pIntValue
);
1583 case RTF_OUTLINELEVEL
:
1584 m_aStates
.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_outlineLvl
, pIntValue
);
1587 // Half of the space between the cells of a table row: default left/right table cell margin.
1590 RTFSprms aAttributes
;
1591 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_type
,
1592 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
1593 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_w
, pIntValue
);
1594 putNestedSprm(m_aStates
.top().getTableRowSprms(),
1595 NS_ooxml::LN_CT_TblPrBase_tblCellMar
, NS_ooxml::LN_CT_TblCellMar_left
,
1596 new RTFValue(aAttributes
));
1597 putNestedSprm(m_aStates
.top().getTableRowSprms(),
1598 NS_ooxml::LN_CT_TblPrBase_tblCellMar
,
1599 NS_ooxml::LN_CT_TblCellMar_right
, new RTFValue(aAttributes
));
1602 case RTF_TRFTSWIDTH
:
1603 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblW
,
1604 NS_ooxml::LN_CT_TblWidth_type
, pIntValue
);
1607 putNestedAttribute(m_aStates
.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblW
,
1608 NS_ooxml::LN_CT_TblWidth_w
, pIntValue
);
1615 m_aStates
.top().setPropType(cppu::UnoType
<sal_Int32
>::get());
1618 m_aStates
.top().setPropType(cppu::UnoType
<double>::get());
1621 m_aStates
.top().setPropType(cppu::UnoType
<bool>::get());
1624 m_aStates
.top().setPropType(cppu::UnoType
<OUString
>::get());
1627 m_aStates
.top().setPropType(cppu::UnoType
<util::DateTime
>::get());
1633 m_aStates
.top().getPicture().eStyle
= RTFBmpStyle::DIBITMAP
;
1636 m_aStates
.top().setTableRowWidthAfter(nParam
);
1644 nId
= NS_ooxml::LN_Value_ST_TextEffect_none
;
1647 nId
= NS_ooxml::LN_Value_ST_TextEffect_blinkBackground
;
1652 m_aStates
.top().getCharacterSprms().set(NS_ooxml::LN_EG_RPrBase_effect
,
1658 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_displayBackgroundShape
, pIntValue
);
1659 // Send this token immediately, if it only appears before the first
1660 // run, it will be too late, we ignored the background shape already by then.
1661 outputSettingsTable();
1670 nId
= NS_ooxml::LN_Value_ST_TextDirection_lrTb
;
1673 nId
= NS_ooxml::LN_Value_ST_TextDirection_tbRl
;
1679 m_aStates
.top().getSectionSprms().set(NS_ooxml::LN_EG_SectPrContents_textDirection
,
1686 SAL_INFO("writerfilter", "TODO handle value '" << keywordToString(nKeyword
) << "'");
1687 aSkip
.setParsed(false);
1691 return RTFError::OK
;
1694 } // namespace rtftok
1695 } // namespace writerfilter
1697 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */