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().aTableSprms
.set(nSprm
, pIntValue
);
162 // Trivial character sprms.
167 nSprm
= (m_aStates
.top().isRightToLeft
168 || m_aStates
.top().eRunType
== RTFParserState::RunType::HICH
)
169 ? NS_ooxml::LN_EG_RPrBase_szCs
170 : NS_ooxml::LN_EG_RPrBase_sz
;
173 nSprm
= NS_ooxml::LN_EG_RPrBase_spacing
;
176 nSprm
= NS_ooxml::LN_EG_RPrBase_kern
;
179 nSprm
= NS_ooxml::LN_EG_RPrBase_w
;
186 m_aStates
.top().aCharacterSprms
.set(nSprm
, pIntValue
);
189 // Trivial character attributes.
194 if (m_aStates
.top().isRightToLeft
195 || m_aStates
.top().eRunType
== RTFParserState::RunType::HICH
)
197 nSprm
= NS_ooxml::LN_CT_Language_bidi
;
199 else if (m_aStates
.top().eRunType
== RTFParserState::RunType::DBCH
)
201 nSprm
= NS_ooxml::LN_CT_Language_eastAsia
;
205 assert(m_aStates
.top().eRunType
== RTFParserState::RunType::LOCH
);
206 nSprm
= NS_ooxml::LN_CT_Language_val
;
209 case RTF_LANGFE
: // this one is always CJK apparently
210 nSprm
= NS_ooxml::LN_CT_Language_eastAsia
;
217 LanguageTag
aTag((LanguageType(static_cast<sal_uInt16
>(nParam
))));
218 auto pValue
= new RTFValue(aTag
.getBcp47());
219 putNestedAttribute(m_aStates
.top().aCharacterSprms
, NS_ooxml::LN_EG_RPrBase_lang
, nSprm
,
221 // Language is a character property, but we should store it at a paragraph level as well for fields.
222 if (nKeyword
== RTF_LANG
&& m_bNeedPap
)
223 putNestedAttribute(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_EG_RPrBase_lang
, nSprm
,
227 // Trivial paragraph sprms.
231 nSprm
= NS_ooxml::LN_tblDepth
;
232 // tdf#117268: If \itap0 is encountered inside tables (between \cellxN and \cell), then
233 // use the default value (1), as Word apparently does
234 if (nParam
== 0 && (m_nTopLevelCells
!= 0 || m_nNestedCells
!= 0))
237 pIntValue
= new RTFValue(nParam
);
245 m_aStates
.top().aParagraphSprms
.set(nSprm
, pIntValue
);
246 if (nKeyword
== RTF_ITAP
&& nParam
> 0)
248 while (m_aTableBufferStack
.size() < sal::static_int_cast
<std::size_t>(nParam
))
250 m_aTableBufferStack
.emplace_back(RTFBuffer_t());
252 // Invalid tables may omit INTBL after ITAP
253 dispatchFlag(RTF_INTBL
); // sets newly pushed buffer as current
254 assert(m_aStates
.top().pCurrentBuffer
== &m_aTableBufferStack
.back());
264 m_aStates
.top().nYear
= nParam
;
270 m_aStates
.top().nMonth
= nParam
;
276 m_aStates
.top().nDay
= nParam
;
282 m_aStates
.top().nHour
= nParam
;
288 m_aStates
.top().nMinute
= nParam
;
298 // Frame size / position.
303 nId
= NS_ooxml::LN_CT_FramePr_w
;
306 nId
= NS_ooxml::LN_CT_FramePr_h
;
310 nId
= NS_ooxml::LN_CT_FramePr_x
;
311 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_xAlign
, 0);
316 nId
= NS_ooxml::LN_CT_FramePr_y
;
317 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_yAlign
, 0);
327 // Don't try to support text frames inside tables for now.
328 if (m_aStates
.top().pCurrentBuffer
!= &m_aTableBufferStack
.back())
329 m_aStates
.top().aFrame
.setSprm(nId
, nParam
);
334 // Then check for the more complex ones.
339 if (m_aStates
.top().isRightToLeft
340 || m_aStates
.top().eRunType
== RTFParserState::RunType::HICH
)
342 nSprm
= NS_ooxml::LN_CT_Fonts_cs
;
344 else if (m_aStates
.top().eRunType
== RTFParserState::RunType::DBCH
)
346 nSprm
= NS_ooxml::LN_CT_Fonts_eastAsia
;
350 assert(m_aStates
.top().eRunType
== RTFParserState::RunType::LOCH
);
351 nSprm
= NS_ooxml::LN_CT_Fonts_ascii
;
353 if (m_aStates
.top().eDestination
== Destination::FONTTABLE
354 || m_aStates
.top().eDestination
== Destination::FONTENTRY
)
356 m_aFontIndexes
.push_back(nParam
);
357 m_nCurrentFontIndex
= getFontIndex(nParam
);
359 else if (m_aStates
.top().eDestination
== Destination::LISTLEVEL
)
361 RTFSprms aFontAttributes
;
362 aFontAttributes
.set(nSprm
, new RTFValue(m_aFontNames
[getFontIndex(nParam
)]));
363 RTFSprms aRunPropsSprms
;
364 aRunPropsSprms
.set(NS_ooxml::LN_EG_RPrBase_rFonts
, new RTFValue(aFontAttributes
));
365 m_aStates
.top().aTableSprms
.set(NS_ooxml::LN_CT_Lvl_rPr
,
366 new RTFValue(RTFSprms(), aRunPropsSprms
),
367 RTFOverwrite::NO_APPEND
);
371 m_nCurrentFontIndex
= getFontIndex(nParam
);
372 auto pValue
= new RTFValue(getFontName(m_nCurrentFontIndex
));
373 putNestedAttribute(m_aStates
.top().aCharacterSprms
, NS_ooxml::LN_EG_RPrBase_rFonts
,
375 if (nKeyword
== RTF_F
)
376 m_aStates
.top().nCurrentEncoding
= getEncoding(m_nCurrentFontIndex
);
380 m_aStates
.top().aCurrentColor
.SetRed(nParam
);
383 m_aStates
.top().aCurrentColor
.SetGreen(nParam
);
386 m_aStates
.top().aCurrentColor
.SetBlue(nParam
);
390 // we always send text to the domain mapper in OUString, so no
391 // need to send encoding info
393 for (i
= 0; i
< nRTFEncodings
; i
++)
395 if (aRTFEncodings
[i
].charset
== nParam
)
398 if (i
== nRTFEncodings
)
403 = aRTFEncodings
[i
].codepage
== 0 // Default (CP_ACP)
404 ? osl_getThreadTextEncoding()
405 : rtl_getTextEncodingFromWindowsCodePage(aRTFEncodings
[i
].codepage
);
406 m_aStates
.top().nCurrentEncoding
= m_nCurrentEncoding
;
412 rtl_TextEncoding nEncoding
414 ? utl_getWinTextEncodingFromLangStr(getLODefaultLanguage().toUtf8().getStr())
415 : rtl_getTextEncodingFromWindowsCodePage(nParam
);
416 if (nKeyword
== RTF_ANSICPG
)
417 m_aDefaultState
.nCurrentEncoding
= nEncoding
;
419 m_nCurrentEncoding
= nEncoding
;
420 m_aStates
.top().nCurrentEncoding
= nEncoding
;
425 RTFSprms aAttributes
;
426 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
427 aAttributes
.set(NS_ooxml::LN_CT_Color_val
, pValue
);
428 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_RPrBase_color
,
429 new RTFValue(aAttributes
));
434 m_aStates
.top().nCurrentStyleIndex
= nParam
;
436 if (m_aStates
.top().eDestination
== Destination::STYLESHEET
437 || m_aStates
.top().eDestination
== Destination::STYLEENTRY
)
439 m_nCurrentStyleIndex
= nParam
;
440 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_StyleType_paragraph
);
441 m_aStates
.top().aTableAttributes
.set(NS_ooxml::LN_CT_Style_type
,
442 pValue
); // paragraph style
446 OUString aName
= getStyleName(nParam
);
447 if (!aName
.isEmpty())
449 if (m_aStates
.top().eDestination
== Destination::LISTLEVEL
)
450 m_aStates
.top().aTableSprms
.set(NS_ooxml::LN_CT_Lvl_pStyle
,
451 new RTFValue(aName
));
453 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_CT_PPrBase_pStyle
,
454 new RTFValue(aName
));
460 m_aStates
.top().nCurrentCharacterStyleIndex
= nParam
;
461 if (m_aStates
.top().eDestination
== Destination::STYLESHEET
462 || m_aStates
.top().eDestination
== Destination::STYLEENTRY
)
464 m_nCurrentStyleIndex
= nParam
;
465 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_StyleType_character
);
466 m_aStates
.top().aTableAttributes
.set(NS_ooxml::LN_CT_Style_type
,
467 pValue
); // character style
471 OUString aName
= getStyleName(nParam
);
472 if (!aName
.isEmpty())
473 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_RPrBase_rStyle
,
474 new RTFValue(aName
));
478 if (m_aStates
.top().eDestination
== Destination::STYLESHEET
479 || m_aStates
.top().eDestination
== Destination::STYLEENTRY
)
481 m_nCurrentStyleIndex
= nParam
;
482 auto pValue
= new RTFValue(0); // TODO no value in enum StyleType?
483 m_aStates
.top().aTableAttributes
.set(NS_ooxml::LN_CT_Style_type
,
484 pValue
); // section style
488 if (m_aStates
.top().eDestination
== Destination::STYLESHEET
489 || m_aStates
.top().eDestination
== Destination::STYLEENTRY
)
491 m_nCurrentStyleIndex
= nParam
;
492 // 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
493 auto pValue
= new RTFValue(0);
494 m_aStates
.top().aTableAttributes
.set(NS_ooxml::LN_CT_Style_type
,
495 pValue
); // table style
499 m_nDefaultFontIndex
= nParam
;
504 LanguageTag
aTag((LanguageType(nParam
)));
505 auto pValue
= new RTFValue(aTag
.getBcp47());
506 putNestedAttribute(m_aStates
.top().aCharacterSprms
,
507 (nKeyword
== RTF_DEFLANG
? NS_ooxml::LN_EG_RPrBase_lang
508 : NS_ooxml::LN_CT_Language_bidi
),
514 auto pValue
= new RTFValue(sal_uInt32(nParam
? getColorTable(nParam
) : COL_AUTO
));
515 putNestedAttribute(m_aStates
.top().aCharacterSprms
, NS_ooxml::LN_EG_RPrBase_shd
,
516 NS_ooxml::LN_CT_Shd_fill
, pValue
);
522 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
523 putNestedAttribute(m_aStates
.top().aTableCellSprms
, NS_ooxml::LN_CT_TcPrBase_shd
,
524 NS_ooxml::LN_CT_Shd_fill
, pValue
);
530 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
531 putNestedAttribute(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PrBase_shd
,
532 NS_ooxml::LN_CT_Shd_fill
, pValue
);
537 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
538 m_aStates
.top().aCharacterSprms
.set(0x6877, pValue
);
543 auto pValue
= new RTFValue(sal_uInt32(nParam
? getColorTable(nParam
) : COL_AUTO
));
544 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_RPrBase_highlight
, pValue
);
550 auto pValue
= new RTFValue(nParam
* (nKeyword
== RTF_UP
? 1 : -1));
551 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_RPrBase_position
, pValue
);
556 auto pValue
= new RTFValue(int(true));
557 m_aStates
.top().aCharacterAttributes
.set(NS_ooxml::LN_CT_EastAsianLayout_vert
, pValue
);
559 // rotate fits to a single line
560 m_aStates
.top().aCharacterAttributes
.set(
561 NS_ooxml::LN_CT_EastAsianLayout_vertCompress
, pValue
);
566 // Convert quarter-points to twentieths of a point
567 auto pValue
= new RTFValue(nParam
* 5);
568 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_RPrBase_spacing
, pValue
);
573 auto pValue
= new RTFValue(int(true));
574 m_aStates
.top().aCharacterAttributes
.set(NS_ooxml::LN_CT_EastAsianLayout_combine
,
580 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_none
;
583 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_round
;
586 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_square
;
589 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_angle
;
592 nId
= NS_ooxml::LN_Value_ST_CombineBrackets_curly
;
596 m_aStates
.top().aCharacterAttributes
.set(
597 NS_ooxml::LN_CT_EastAsianLayout_combineBrackets
, new RTFValue(nId
));
602 // This is similar to RTF_ABSH, negative value means 'exact', positive means 'at least'.
603 tools::SvRef
<RTFValue
> pValue(
604 new RTFValue(NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast
));
607 pValue
= new RTFValue(NS_ooxml::LN_Value_doc_ST_LineSpacingRule_exact
);
608 pIntValue
= new RTFValue(-nParam
);
610 m_aStates
.top().aParagraphAttributes
.set(NS_ooxml::LN_CT_Spacing_lineRule
, pValue
);
611 m_aStates
.top().aParagraphAttributes
.set(NS_ooxml::LN_CT_Spacing_line
, pIntValue
);
617 auto pValue
= new RTFValue(NS_ooxml::LN_Value_doc_ST_LineSpacingRule_auto
);
618 m_aStates
.top().aParagraphAttributes
.set(NS_ooxml::LN_CT_Spacing_lineRule
, pValue
);
623 // dmapper expects it in 1/8 pt, we have it in twip - but avoid rounding 1 to 0
625 nParam
= nParam
* 2 / 5;
626 auto pValue
= new RTFValue(nParam
);
627 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_sz
, pValue
);
632 auto pValue
= new RTFValue(sal_uInt32(getColorTable(nParam
)));
633 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_color
, pValue
);
638 // dmapper expects it in points, we have it in twip
639 auto pValue
= new RTFValue(nParam
/ 20);
640 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_space
, pValue
);
645 m_aStates
.top().aTabAttributes
.set(NS_ooxml::LN_CT_TabStop_pos
, pIntValue
);
646 auto pValue
= new RTFValue(m_aStates
.top().aTabAttributes
);
647 if (m_aStates
.top().eDestination
== Destination::LISTLEVEL
)
648 putNestedSprm(m_aStates
.top().aTableSprms
, NS_ooxml::LN_CT_PPrBase_tabs
,
649 NS_ooxml::LN_CT_Tabs_tab
, pValue
);
651 putNestedSprm(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_tabs
,
652 NS_ooxml::LN_CT_Tabs_tab
, pValue
);
653 m_aStates
.top().aTabAttributes
.clear();
657 putNestedSprm(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_numPr
,
658 NS_ooxml::LN_CT_NumPr_ilvl
, pIntValue
);
660 case RTF_LISTTEMPLATEID
:
661 // This one is not referenced anywhere, so it's pointless to store it at the moment.
665 if (m_aStates
.top().eDestination
== Destination::LISTENTRY
)
666 m_aStates
.top().aTableAttributes
.set(NS_ooxml::LN_CT_AbstractNum_abstractNumId
,
668 else if (m_aStates
.top().eDestination
== Destination::LISTOVERRIDEENTRY
)
669 m_aStates
.top().aTableSprms
.set(NS_ooxml::LN_CT_Num_abstractNumId
, pIntValue
);
670 m_aStates
.top().nCurrentListIndex
= nParam
;
675 if (m_aStates
.top().eDestination
== Destination::LISTOVERRIDEENTRY
)
677 m_aStates
.top().aTableAttributes
.set(NS_ooxml::LN_CT_AbstractNum_nsid
, pIntValue
);
678 m_aStates
.top().nCurrentListOverrideIndex
= nParam
;
682 // Insert at the start, so properties inherited from the list
683 // can be overridden by direct formatting. But still allow the
684 // case when old-style paragraph numbering is already
686 putNestedSprm(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_numPr
,
687 NS_ooxml::LN_CT_NumPr_numId
, pIntValue
, RTFOverwrite::YES_PREPEND
);
692 if ((SAL_MIN_INT16
<= nParam
) && (nParam
<= SAL_MAX_INT16
))
693 m_aStates
.top().nUc
= nParam
;
696 // sal_Unicode is unsigned 16-bit, RTF may represent that as a
697 // signed SAL_MIN_INT16..SAL_MAX_INT16 or 0..SAL_MAX_UINT16. The
698 // static_cast() will do the right thing.
699 if ((SAL_MIN_INT16
<= nParam
) && (nParam
<= SAL_MAX_UINT16
))
701 if (m_aStates
.top().eDestination
== Destination::LEVELNUMBERS
)
704 m_aStates
.top().aLevelNumbers
.push_back(sal_Int32(nParam
));
706 // ';' in \u form is not considered valid.
707 m_aStates
.top().bLevelNumbersValid
= false;
710 m_aUnicodeBuffer
.append(static_cast<sal_Unicode
>(nParam
));
711 m_aStates
.top().nCharsToSkip
= m_aStates
.top().nUc
;
714 case RTF_LEVELFOLLOW
:
729 if (!sValue
.isEmpty())
730 m_aStates
.top().aTableSprms
.set(NS_ooxml::LN_CT_Lvl_suff
, new RTFValue(sValue
));
735 sal_Int32 nValue
= 0;
739 nValue
= NS_ooxml::LN_Value_ST_Pitch_default
;
742 nValue
= NS_ooxml::LN_Value_ST_Pitch_fixed
;
745 nValue
= NS_ooxml::LN_Value_ST_Pitch_variable
;
750 RTFSprms aAttributes
;
751 aAttributes
.set(NS_ooxml::LN_CT_Pitch_val
, new RTFValue(nValue
));
752 m_aStates
.top().aTableSprms
.set(NS_ooxml::LN_CT_Font_pitch
,
753 new RTFValue(aAttributes
));
757 case RTF_LISTOVERRIDECOUNT
:
758 // Ignore this for now, the exporter always emits it with a zero parameter.
761 m_aStates
.top().aPicture
.nScaleX
= nParam
;
764 m_aStates
.top().aPicture
.nScaleY
= nParam
;
767 m_aStates
.top().aPicture
.nWidth
= nParam
;
770 m_aStates
.top().aPicture
.nHeight
= nParam
;
773 m_aStates
.top().aPicture
.nGoalWidth
= convertTwipToMm100(nParam
);
776 m_aStates
.top().aPicture
.nGoalHeight
= convertTwipToMm100(nParam
);
779 m_aStates
.top().aPicture
.nCropL
= convertTwipToMm100(nParam
);
782 m_aStates
.top().aPicture
.nCropR
= convertTwipToMm100(nParam
);
785 m_aStates
.top().aPicture
.nCropT
= convertTwipToMm100(nParam
);
788 m_aStates
.top().aPicture
.nCropB
= convertTwipToMm100(nParam
);
796 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_bothSides
;
799 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_left
;
802 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_right
;
805 nValue
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_largest
;
810 auto pValue
= new RTFValue(nValue
);
811 RTFValue::Pointer_t pTight
812 = m_aStates
.top().aCharacterSprms
.find(NS_ooxml::LN_EG_WrapType_wrapTight
);
814 pTight
->getAttributes().set(NS_ooxml::LN_CT_WrapTight_wrapText
, pValue
);
816 m_aStates
.top().aCharacterAttributes
.set(NS_ooxml::LN_CT_WrapSquare_wrapText
,
825 m_aStates
.top().aShape
.nWrap
= text::WrapTextMode_NONE
;
828 m_aStates
.top().aShape
.nWrap
= text::WrapTextMode_PARALLEL
;
831 m_aStates
.top().aShape
.nWrap
= text::WrapTextMode_THROUGH
;
832 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_WrapType_wrapNone
,
836 m_aStates
.top().aShape
.nWrap
= text::WrapTextMode_PARALLEL
;
837 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_WrapType_wrapTight
,
841 m_aStates
.top().aShape
.nWrap
= text::WrapTextMode_THROUGH
;
848 int& rCurrentCellX((Destination::NESTEDTABLEPROPERTIES
== m_aStates
.top().eDestination
)
849 ? m_nNestedCurrentCellX
850 : m_nTopLevelCurrentCellX
);
851 int nCellX
= nParam
- rCurrentCellX
;
852 const int COL_DFLT_WIDTH
853 = 41; // sw/source/filter/inc/wrtswtbl.hxx, minimal possible width of cells.
855 nCellX
= COL_DFLT_WIDTH
;
857 // If there is a negative left margin, then the first cellx is relative to that.
858 RTFValue::Pointer_t pTblInd
859 = m_aStates
.top().aTableRowSprms
.find(NS_ooxml::LN_CT_TblPrBase_tblInd
);
860 if (rCurrentCellX
== 0 && pTblInd
.get())
862 RTFValue::Pointer_t pWidth
863 = pTblInd
->getAttributes().find(NS_ooxml::LN_CT_TblWidth_w
);
864 if (pWidth
.get() && pWidth
->getInt() < 0)
865 nCellX
= -1 * (pWidth
->getInt() - nParam
);
868 rCurrentCellX
= nParam
;
869 auto pXValue
= new RTFValue(nCellX
);
870 m_aStates
.top().aTableRowSprms
.set(NS_ooxml::LN_CT_TblGridBase_gridCol
, pXValue
,
871 RTFOverwrite::NO_APPEND
);
872 if (Destination::NESTEDTABLEPROPERTIES
== m_aStates
.top().eDestination
)
875 // Push cell properties.
876 m_aNestedTableCellsSprms
.push_back(m_aStates
.top().aTableCellSprms
);
877 m_aNestedTableCellsAttributes
.push_back(m_aStates
.top().aTableCellAttributes
);
882 // Push cell properties.
883 m_aTopLevelTableCellsSprms
.push_back(m_aStates
.top().aTableCellSprms
);
884 m_aTopLevelTableCellsAttributes
.push_back(m_aStates
.top().aTableCellAttributes
);
887 m_aStates
.top().aTableCellSprms
= m_aDefaultState
.aTableCellSprms
;
888 m_aStates
.top().aTableCellAttributes
= m_aDefaultState
.aTableCellAttributes
;
889 // We assume text after a row definition always belongs to the table, to handle text before the real INTBL token
890 dispatchFlag(RTF_INTBL
);
893 // Wasn't in table, but now is -> tblStart.
894 RTFSprms aAttributes
;
896 aSprms
.set(NS_ooxml::LN_tblStart
, new RTFValue(1));
897 writerfilter::Reference
<Properties
>::Pointer_t pProperties
898 = new RTFReferenceProperties(aAttributes
, aSprms
);
899 Mapper().props(pProperties
);
901 m_nCellxMax
= std::max(m_nCellxMax
, nParam
);
906 OUString
hRule("auto");
909 tools::SvRef
<RTFValue
> pAbsValue(new RTFValue(-nParam
));
910 std::swap(pIntValue
, pAbsValue
);
917 putNestedAttribute(m_aStates
.top().aTableRowSprms
, NS_ooxml::LN_CT_TrPrBase_trHeight
,
918 NS_ooxml::LN_CT_Height_val
, pIntValue
);
920 auto pHRule
= new RTFValue(hRule
);
921 putNestedAttribute(m_aStates
.top().aTableRowSprms
, NS_ooxml::LN_CT_TrPrBase_trHeight
,
922 NS_ooxml::LN_CT_Height_hRule
, pHRule
);
927 // the value is in twips
928 putNestedAttribute(m_aStates
.top().aTableRowSprms
, NS_ooxml::LN_CT_TblPrBase_tblInd
,
929 NS_ooxml::LN_CT_TblWidth_type
,
930 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
931 putNestedAttribute(m_aStates
.top().aTableRowSprms
, NS_ooxml::LN_CT_TblPrBase_tblInd
,
932 NS_ooxml::LN_CT_TblWidth_w
, new RTFValue(nParam
));
933 auto const aDestination
= m_aStates
.top().eDestination
;
934 int& rCurrentTRLeft((Destination::NESTEDTABLEPROPERTIES
== aDestination
)
936 : m_nTopLevelTRLeft
);
937 int& rCurrentCellX((Destination::NESTEDTABLEPROPERTIES
== aDestination
)
938 ? m_nNestedCurrentCellX
939 : m_nTopLevelCurrentCellX
);
940 rCurrentTRLeft
= rCurrentCellX
= nParam
;
944 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_cols
,
945 NS_ooxml::LN_CT_Columns_num
, pIntValue
);
948 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_cols
,
949 NS_ooxml::LN_CT_Columns_space
, pIntValue
);
952 putNestedSprm(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_cols
,
953 NS_ooxml::LN_CT_Columns_col
, pIntValue
);
958 RTFSprms
& rAttributes
= getLastAttributes(m_aStates
.top().aSectionSprms
,
959 NS_ooxml::LN_EG_SectPrContents_cols
);
961 (nKeyword
== RTF_COLW
? NS_ooxml::LN_CT_Column_w
: NS_ooxml::LN_CT_Column_space
),
966 putNestedAttribute(m_aDefaultState
.aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgSz
,
967 NS_ooxml::LN_CT_PageSz_h
, pIntValue
);
968 SAL_FALLTHROUGH
; // set the default + current value
970 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgSz
,
971 NS_ooxml::LN_CT_PageSz_h
, pIntValue
);
974 putNestedAttribute(m_aDefaultState
.aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgSz
,
975 NS_ooxml::LN_CT_PageSz_w
, pIntValue
);
976 SAL_FALLTHROUGH
; // set the default + current value
978 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgSz
,
979 NS_ooxml::LN_CT_PageSz_w
, pIntValue
);
982 putNestedAttribute(m_aDefaultState
.aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgMar
,
983 NS_ooxml::LN_CT_PageMar_left
, pIntValue
);
984 SAL_FALLTHROUGH
; // set the default + current value
986 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgMar
,
987 NS_ooxml::LN_CT_PageMar_left
, pIntValue
);
990 putNestedAttribute(m_aDefaultState
.aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgMar
,
991 NS_ooxml::LN_CT_PageMar_right
, pIntValue
);
992 SAL_FALLTHROUGH
; // set the default + current value
994 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgMar
,
995 NS_ooxml::LN_CT_PageMar_right
, pIntValue
);
998 putNestedAttribute(m_aDefaultState
.aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgMar
,
999 NS_ooxml::LN_CT_PageMar_top
, pIntValue
);
1000 SAL_FALLTHROUGH
; // set the default + current value
1002 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgMar
,
1003 NS_ooxml::LN_CT_PageMar_top
, pIntValue
);
1006 putNestedAttribute(m_aDefaultState
.aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgMar
,
1007 NS_ooxml::LN_CT_PageMar_bottom
, pIntValue
);
1008 SAL_FALLTHROUGH
; // set the default + current value
1010 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgMar
,
1011 NS_ooxml::LN_CT_PageMar_bottom
, pIntValue
);
1014 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgMar
,
1015 NS_ooxml::LN_CT_PageMar_header
, pIntValue
);
1018 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgMar
,
1019 NS_ooxml::LN_CT_PageMar_footer
, pIntValue
);
1022 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_defaultTabStop
, pIntValue
);
1025 putNestedAttribute(m_aStates
.top().aSectionSprms
,
1026 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
1027 NS_ooxml::LN_CT_LineNumber_countBy
, pIntValue
);
1031 putNestedAttribute(m_aStates
.top().aSectionSprms
,
1032 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
1033 NS_ooxml::LN_CT_LineNumber_distance
, pIntValue
);
1035 case RTF_LINESTARTS
:
1036 putNestedAttribute(m_aStates
.top().aSectionSprms
,
1037 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
1038 NS_ooxml::LN_CT_LineNumber_start
, pIntValue
);
1041 case RTF_REVAUTHDEL
:
1043 auto pValue
= new RTFValue(m_aAuthors
[nParam
]);
1044 putNestedAttribute(m_aStates
.top().aCharacterSprms
, NS_ooxml::LN_trackchange
,
1045 NS_ooxml::LN_CT_TrackChange_author
, pValue
);
1049 case RTF_REVDTTMDEL
:
1052 OStringToOUString(DTTM22OString(nParam
), m_aStates
.top().nCurrentEncoding
));
1053 auto pValue
= new RTFValue(aStr
);
1054 putNestedAttribute(m_aStates
.top().aCharacterSprms
, NS_ooxml::LN_trackchange
,
1055 NS_ooxml::LN_CT_TrackChange_date
, pValue
);
1059 m_aStates
.top().aShape
.nLeft
= convertTwipToMm100(nParam
);
1062 m_aStates
.top().aShape
.nTop
= convertTwipToMm100(nParam
);
1065 m_aStates
.top().aShape
.nRight
= convertTwipToMm100(nParam
);
1068 m_aStates
.top().aShape
.nBottom
= convertTwipToMm100(nParam
);
1071 m_aStates
.top().aShape
.oZ
.reset(nParam
);
1077 m_nFormFieldType
= RTFFormFieldType::TEXT
;
1080 m_nFormFieldType
= RTFFormFieldType::CHECKBOX
;
1083 m_nFormFieldType
= RTFFormFieldType::LIST
;
1086 m_nFormFieldType
= RTFFormFieldType::NONE
;
1091 if (m_nFormFieldType
== RTFFormFieldType::CHECKBOX
)
1092 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFCheckBox_default
, pIntValue
);
1093 else if (m_nFormFieldType
== RTFFormFieldType::LIST
)
1094 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFDDList_default
, pIntValue
);
1097 // 25 means undefined, see [MS-DOC] 2.9.79, FFDataBits.
1098 if (m_nFormFieldType
== RTFFormFieldType::CHECKBOX
&& nParam
!= 25)
1099 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFCheckBox_checked
, pIntValue
);
1100 else if (m_nFormFieldType
== RTFFormFieldType::LIST
)
1101 m_aFormfieldSprms
.set(NS_ooxml::LN_CT_FFDDList_result
, pIntValue
);
1104 if (m_xDocumentProperties
.is())
1106 // tdf#116851 some RTF may be malformed
1109 m_xDocumentProperties
->setEditingDuration(nParam
);
1115 case RTF_NOFCHARSWS
:
1116 if (m_xDocumentProperties
.is())
1118 comphelper::SequenceAsHashMap aSeq
= m_xDocumentProperties
->getDocumentStatistics();
1123 aName
= "PageCount";
1127 aName
= "WordCount";
1130 aName
= "CharacterCount";
1132 case RTF_NOFCHARSWS
:
1133 aName
= "NonWhitespaceCharacterCount";
1138 if (!aName
.isEmpty())
1140 aSeq
[aName
] <<= sal_Int32(nParam
);
1141 m_xDocumentProperties
->setDocumentStatistics(aSeq
.getAsConstNamedValueList());
1146 if (m_xDocumentProperties
.is())
1147 m_xDocumentProperties
->setEditingCycles(nParam
);
1150 // Ignore this for now, later the RTF writer version could be used to add hacks for older buggy writers.
1153 putNestedSprm(m_aDefaultState
.aParagraphSprms
,
1154 NS_ooxml::LN_EG_SectPrContents_footnotePr
,
1155 NS_ooxml::LN_EG_FtnEdnNumProps_numStart
, pIntValue
);
1158 putNestedSprm(m_aDefaultState
.aParagraphSprms
, NS_ooxml::LN_EG_SectPrContents_endnotePr
,
1159 NS_ooxml::LN_EG_FtnEdnNumProps_numStart
, pIntValue
);
1162 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_hSpace
, nParam
);
1165 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_vSpace
, nParam
);
1169 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_hSpace
, nParam
);
1170 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_vSpace
, nParam
);
1175 RTFVertOrient
aVertOrient(nParam
);
1176 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_yAlign
, aVertOrient
.GetAlign());
1177 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor
,
1178 aVertOrient
.GetAnchor());
1183 RTFHoriOrient
aHoriOrient(nParam
);
1184 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_xAlign
, aHoriOrient
.GetAlign());
1185 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor
,
1186 aHoriOrient
.GetAnchor());
1192 m_aStates
.top().aPicture
.eWMetafile
= nParam
;
1195 putNestedAttribute(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_spacing
,
1196 NS_ooxml::LN_CT_Spacing_before
, pIntValue
);
1199 putNestedAttribute(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_spacing
,
1200 NS_ooxml::LN_CT_Spacing_after
, pIntValue
);
1203 m_aStates
.top().aDrawingObject
.nLeft
= convertTwipToMm100(nParam
);
1206 m_aStates
.top().aDrawingObject
.nTop
= convertTwipToMm100(nParam
);
1209 m_aStates
.top().aDrawingObject
.nRight
= convertTwipToMm100(nParam
);
1212 m_aStates
.top().aDrawingObject
.nBottom
= convertTwipToMm100(nParam
);
1215 m_aStates
.top().aTableSprms
.set(NS_ooxml::LN_CT_Lvl_start
, pIntValue
);
1219 auto pValue
= new RTFValue(m_aFontNames
[getFontIndex(nParam
)]);
1220 RTFSprms aAttributes
;
1221 aAttributes
.set(NS_ooxml::LN_CT_Fonts_ascii
, pValue
);
1222 putNestedSprm(m_aStates
.top().aTableSprms
, NS_ooxml::LN_CT_Lvl_rPr
,
1223 NS_ooxml::LN_EG_RPrBase_rFonts
, new RTFValue(aAttributes
));
1227 m_aSettingsTableAttributes
.set(NS_ooxml::LN_CT_Zoom_percent
, pIntValue
);
1231 m_aStates
.top().nInternalState
= RTFInternalState::BIN
;
1232 m_aStates
.top().nBinaryToRead
= nParam
;
1236 m_aStates
.top().aDrawingObject
.nLineColorR
= nParam
;
1237 m_aStates
.top().aDrawingObject
.bHasLineColor
= true;
1240 m_aStates
.top().aDrawingObject
.nLineColorG
= nParam
;
1241 m_aStates
.top().aDrawingObject
.bHasLineColor
= true;
1244 m_aStates
.top().aDrawingObject
.nLineColorB
= nParam
;
1245 m_aStates
.top().aDrawingObject
.bHasLineColor
= true;
1247 case RTF_DPFILLBGCR
:
1248 m_aStates
.top().aDrawingObject
.nFillColorR
= nParam
;
1249 m_aStates
.top().aDrawingObject
.bHasFillColor
= true;
1251 case RTF_DPFILLBGCG
:
1252 m_aStates
.top().aDrawingObject
.nFillColorG
= nParam
;
1253 m_aStates
.top().aDrawingObject
.bHasFillColor
= true;
1255 case RTF_DPFILLBGCB
:
1256 m_aStates
.top().aDrawingObject
.nFillColorB
= nParam
;
1257 m_aStates
.top().aDrawingObject
.bHasFillColor
= true;
1265 nValue
= NS_ooxml::LN_Value_ST_Shd_pct5
;
1268 nValue
= NS_ooxml::LN_Value_ST_Shd_pct10
;
1271 nValue
= NS_ooxml::LN_Value_ST_Shd_pct12
;
1274 nValue
= NS_ooxml::LN_Value_ST_Shd_pct15
;
1277 nValue
= NS_ooxml::LN_Value_ST_Shd_pct20
;
1280 nValue
= NS_ooxml::LN_Value_ST_Shd_pct25
;
1283 nValue
= NS_ooxml::LN_Value_ST_Shd_pct30
;
1286 nValue
= NS_ooxml::LN_Value_ST_Shd_pct35
;
1289 nValue
= NS_ooxml::LN_Value_ST_Shd_pct37
;
1292 nValue
= NS_ooxml::LN_Value_ST_Shd_pct40
;
1295 nValue
= NS_ooxml::LN_Value_ST_Shd_pct45
;
1298 nValue
= NS_ooxml::LN_Value_ST_Shd_pct50
;
1301 nValue
= NS_ooxml::LN_Value_ST_Shd_pct55
;
1304 nValue
= NS_ooxml::LN_Value_ST_Shd_pct60
;
1307 nValue
= NS_ooxml::LN_Value_ST_Shd_pct62
;
1310 nValue
= NS_ooxml::LN_Value_ST_Shd_pct65
;
1313 nValue
= NS_ooxml::LN_Value_ST_Shd_pct70
;
1316 nValue
= NS_ooxml::LN_Value_ST_Shd_pct75
;
1319 nValue
= NS_ooxml::LN_Value_ST_Shd_pct80
;
1322 nValue
= NS_ooxml::LN_Value_ST_Shd_pct85
;
1325 nValue
= NS_ooxml::LN_Value_ST_Shd_pct87
;
1328 nValue
= NS_ooxml::LN_Value_ST_Shd_pct90
;
1331 nValue
= NS_ooxml::LN_Value_ST_Shd_pct95
;
1337 putNestedAttribute(m_aStates
.top().aTableCellSprms
, NS_ooxml::LN_CT_TcPrBase_shd
,
1338 NS_ooxml::LN_CT_Shd_val
, new RTFValue(nValue
));
1342 m_aStates
.top().aDrawingObject
.nDhgt
= nParam
;
1344 case RTF_DPPOLYCOUNT
:
1347 m_aStates
.top().aDrawingObject
.nPolyLineCount
= nParam
;
1352 RTFDrawingObject
& rDrawingObject
= m_aStates
.top().aDrawingObject
;
1354 if (rDrawingObject
.aPolyLinePoints
.empty())
1355 dispatchValue(RTF_DPPOLYCOUNT
, 2);
1357 rDrawingObject
.aPolyLinePoints
.emplace_back(awt::Point(convertTwipToMm100(nParam
), 0));
1362 RTFDrawingObject
& rDrawingObject
= m_aStates
.top().aDrawingObject
;
1363 if (!rDrawingObject
.aPolyLinePoints
.empty())
1365 rDrawingObject
.aPolyLinePoints
.back().Y
= convertTwipToMm100(nParam
);
1366 rDrawingObject
.nPolyLineCount
--;
1367 if (rDrawingObject
.nPolyLineCount
== 0 && rDrawingObject
.xPropertySet
.is())
1369 uno::Sequence
<uno::Sequence
<awt::Point
>> aPointSequenceSequence
1370 = { comphelper::containerToSequence(rDrawingObject
.aPolyLinePoints
) };
1371 rDrawingObject
.xPropertySet
->setPropertyValue("PolyPolygon",
1372 uno::Any(aPointSequenceSequence
));
1377 case RTF_SHPFBLWTXT
:
1378 // Shape is below text -> send it to the background.
1379 m_aStates
.top().aShape
.bInBackground
= nParam
;
1386 RTFSprms aAttributes
;
1387 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_type
,
1388 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
1389 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_w
, new RTFValue(nParam
));
1390 // Top and left is swapped, that's what Word does.
1394 nSprm
= NS_ooxml::LN_CT_TcMar_bottom
;
1397 nSprm
= NS_ooxml::LN_CT_TcMar_top
;
1400 nSprm
= NS_ooxml::LN_CT_TcMar_right
;
1403 nSprm
= NS_ooxml::LN_CT_TcMar_left
;
1408 putNestedSprm(m_aStates
.top().aTableCellSprms
, NS_ooxml::LN_CT_TcPrBase_tcMar
, nSprm
,
1409 new RTFValue(aAttributes
));
1417 RTFSprms aAttributes
;
1421 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_type
,
1422 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
1428 nSprm
= NS_ooxml::LN_CT_TcMar_bottom
;
1431 nSprm
= NS_ooxml::LN_CT_TcMar_left
;
1434 nSprm
= NS_ooxml::LN_CT_TcMar_right
;
1437 nSprm
= NS_ooxml::LN_CT_TcMar_top
;
1442 putNestedAttribute(m_aStates
.top().aTableCellSprms
, NS_ooxml::LN_CT_TcPrBase_tcMar
,
1443 nSprm
, new RTFValue(aAttributes
));
1444 putNestedAttribute(m_aDefaultState
.aTableCellSprms
, NS_ooxml::LN_CT_TcPrBase_tcMar
,
1445 nSprm
, new RTFValue(aAttributes
));
1453 RTFSprms aAttributes
;
1454 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_w
, new RTFValue(nParam
));
1458 nSprm
= NS_ooxml::LN_CT_TcMar_bottom
;
1461 nSprm
= NS_ooxml::LN_CT_TcMar_left
;
1464 nSprm
= NS_ooxml::LN_CT_TcMar_right
;
1467 nSprm
= NS_ooxml::LN_CT_TcMar_top
;
1472 putNestedSprm(m_aStates
.top().aTableCellSprms
, NS_ooxml::LN_CT_TcPrBase_tcMar
, nSprm
,
1473 new RTFValue(aAttributes
));
1474 putNestedSprm(m_aDefaultState
.aTableCellSprms
, NS_ooxml::LN_CT_TcPrBase_tcMar
, nSprm
,
1475 new RTFValue(aAttributes
));
1480 if (m_aStates
.top().eDestination
== Destination::LISTLEVEL
)
1482 if (m_aStates
.top().bLevelNumbersValid
)
1483 putNestedAttribute(m_aStates
.top().aTableSprms
, NS_ooxml::LN_CT_PPrBase_ind
,
1484 NS_ooxml::LN_CT_Ind_firstLine
, pIntValue
);
1486 m_aInvalidListLevelFirstIndents
[m_nListLevel
] = nParam
;
1489 putNestedAttribute(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_ind
,
1490 NS_ooxml::LN_CT_Ind_firstLine
, pIntValue
);
1495 if (m_aStates
.top().eDestination
== Destination::LISTLEVEL
)
1497 if (m_aStates
.top().bLevelNumbersValid
)
1498 putNestedAttribute(m_aStates
.top().aTableSprms
, NS_ooxml::LN_CT_PPrBase_ind
,
1499 NS_ooxml::LN_CT_Ind_left
, pIntValue
);
1503 putNestedAttribute(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_ind
,
1504 NS_ooxml::LN_CT_Ind_left
, pIntValue
);
1506 // It turns out \li should reset the \fi inherited from the stylesheet.
1507 // So set the direct formatting to zero, if we don't have such direct formatting yet.
1508 putNestedAttribute(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_ind
,
1509 NS_ooxml::LN_CT_Ind_firstLine
, new RTFValue(0),
1510 RTFOverwrite::NO_IGNORE
);
1514 putNestedAttribute(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_ind
,
1515 NS_ooxml::LN_CT_Ind_right
, pIntValue
);
1518 putNestedAttribute(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_ind
,
1519 NS_ooxml::LN_CT_Ind_start
, pIntValue
);
1522 putNestedAttribute(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PPrBase_ind
,
1523 NS_ooxml::LN_CT_Ind_end
, pIntValue
);
1525 case RTF_OUTLINELEVEL
:
1526 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_CT_PPrBase_outlineLvl
, pIntValue
);
1529 // Half of the space between the cells of a table row: default left/right table cell margin.
1532 RTFSprms aAttributes
;
1533 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_type
,
1534 new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa
));
1535 aAttributes
.set(NS_ooxml::LN_CT_TblWidth_w
, pIntValue
);
1536 putNestedSprm(m_aStates
.top().aTableRowSprms
, NS_ooxml::LN_CT_TblPrBase_tblCellMar
,
1537 NS_ooxml::LN_CT_TblCellMar_left
, new RTFValue(aAttributes
));
1538 putNestedSprm(m_aStates
.top().aTableRowSprms
, NS_ooxml::LN_CT_TblPrBase_tblCellMar
,
1539 NS_ooxml::LN_CT_TblCellMar_right
, new RTFValue(aAttributes
));
1542 case RTF_TRFTSWIDTH
:
1543 putNestedAttribute(m_aStates
.top().aTableRowSprms
, NS_ooxml::LN_CT_TblPrBase_tblW
,
1544 NS_ooxml::LN_CT_TblWidth_type
, pIntValue
);
1547 putNestedAttribute(m_aStates
.top().aTableRowSprms
, NS_ooxml::LN_CT_TblPrBase_tblW
,
1548 NS_ooxml::LN_CT_TblWidth_w
, pIntValue
);
1555 m_aStates
.top().aPropType
= cppu::UnoType
<sal_Int32
>::get();
1558 m_aStates
.top().aPropType
= cppu::UnoType
<double>::get();
1561 m_aStates
.top().aPropType
= cppu::UnoType
<bool>::get();
1564 m_aStates
.top().aPropType
= cppu::UnoType
<OUString
>::get();
1567 m_aStates
.top().aPropType
= cppu::UnoType
<util::DateTime
>::get();
1573 m_aStates
.top().aPicture
.eStyle
= RTFBmpStyle::DIBITMAP
;
1576 m_aStates
.top().nTableRowWidthAfter
= nParam
;
1584 nId
= NS_ooxml::LN_Value_ST_TextEffect_none
;
1587 nId
= NS_ooxml::LN_Value_ST_TextEffect_blinkBackground
;
1592 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_RPrBase_effect
,
1598 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_displayBackgroundShape
, pIntValue
);
1599 // Send this token immediately, if it only appears before the first
1600 // run, it will be too late, we ignored the background shape already by then.
1601 outputSettingsTable();
1606 SAL_INFO("writerfilter", "TODO handle value '" << keywordToString(nKeyword
) << "'");
1607 aSkip
.setParsed(false);
1611 return RTFError::OK
;
1614 } // namespace rtftok
1615 } // namespace writerfilter
1617 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */