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/drawing/XDrawPageSupplier.hpp>
13 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
14 #include <com/sun/star/text/RelOrientation.hpp>
15 #include <com/sun/star/text/VertOrientation.hpp>
16 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
18 #include <filter/msfilter/escherex.hxx>
20 #include <ooxml/resourceids.hxx>
22 #include <sal/log.hxx>
24 #include "rtfsdrimport.hxx"
25 #include "rtfskipdestination.hxx"
27 using namespace com::sun::star
;
29 namespace writerfilter
33 RTFError
RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword
)
36 checkUnicode(/*bUnicode =*/true, /*bHex =*/true);
37 RTFSkipDestination
aSkip(*this);
45 nSprm
= NS_ooxml::LN_Value_ST_Underline_dotted
;
48 nSprm
= NS_ooxml::LN_Value_ST_Underline_words
;
55 auto pValue
= new RTFValue(nSprm
);
56 m_aStates
.top().aCharacterAttributes
.set(NS_ooxml::LN_CT_Underline_val
, pValue
);
64 nParam
= NS_ooxml::LN_Value_ST_Jc_center
;
67 nParam
= NS_ooxml::LN_Value_ST_Jc_both
;
70 nParam
= NS_ooxml::LN_Value_ST_Jc_left
;
73 nParam
= NS_ooxml::LN_Value_ST_Jc_right
;
76 nParam
= NS_ooxml::LN_Value_ST_Jc_both
;
83 auto pValue
= new RTFValue(nParam
);
84 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_CT_PPrBase_jc
, pValue
);
94 nParam
= NS_ooxml::LN_Value_doc_ST_TextAlignment_auto
;
97 nParam
= NS_ooxml::LN_Value_doc_ST_TextAlignment_top
;
100 nParam
= NS_ooxml::LN_Value_doc_ST_TextAlignment_center
;
103 nParam
= NS_ooxml::LN_Value_doc_ST_TextAlignment_baseline
;
106 nParam
= NS_ooxml::LN_Value_doc_ST_TextAlignment_bottom
;
113 auto pValue
= new RTFValue(nParam
);
114 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_CT_PPrBase_textAlignment
, pValue
);
122 nParam
= NS_ooxml::LN_Value_ST_TabJc_right
;
125 nParam
= NS_ooxml::LN_Value_ST_TabJc_center
;
128 nParam
= NS_ooxml::LN_Value_ST_TabJc_decimal
;
135 auto pValue
= new RTFValue(nParam
);
136 m_aStates
.top().aTabAttributes
.set(NS_ooxml::LN_CT_TabStop_val
, pValue
);
144 nParam
= NS_ooxml::LN_Value_ST_TabTlc_dot
;
147 nParam
= NS_ooxml::LN_Value_ST_TabTlc_middleDot
;
150 nParam
= NS_ooxml::LN_Value_ST_TabTlc_hyphen
;
153 nParam
= NS_ooxml::LN_Value_ST_TabTlc_underscore
;
156 nParam
= NS_ooxml::LN_Value_ST_TabTlc_hyphen
;
157 break; // thick line is not supported by dmapper, this is just a hack
159 nParam
= NS_ooxml::LN_Value_ST_TabTlc_none
;
160 break; // equal sign isn't, either
166 auto pValue
= new RTFValue(nParam
);
167 m_aStates
.top().aTabAttributes
.set(NS_ooxml::LN_CT_TabStop_leader
, pValue
);
175 // brdrhair and brdrs are the same, brdrw will make a difference
176 // map to values in ooxml/model.xml resource ST_Border
179 nParam
= NS_ooxml::LN_Value_ST_Border_single
;
182 nParam
= NS_ooxml::LN_Value_ST_Border_dotted
;
185 nParam
= NS_ooxml::LN_Value_ST_Border_dashed
;
188 nParam
= NS_ooxml::LN_Value_ST_Border_double
;
191 nParam
= NS_ooxml::LN_Value_ST_Border_thinThickSmallGap
;
194 nParam
= NS_ooxml::LN_Value_ST_Border_thinThickMediumGap
;
197 nParam
= NS_ooxml::LN_Value_ST_Border_thinThickLargeGap
;
200 nParam
= NS_ooxml::LN_Value_ST_Border_thickThinSmallGap
;
203 nParam
= NS_ooxml::LN_Value_ST_Border_thickThinMediumGap
;
206 nParam
= NS_ooxml::LN_Value_ST_Border_thickThinLargeGap
;
209 nParam
= NS_ooxml::LN_Value_ST_Border_threeDEmboss
;
211 case RTF_BRDRENGRAVE
:
212 nParam
= NS_ooxml::LN_Value_ST_Border_threeDEngrave
;
215 nParam
= NS_ooxml::LN_Value_ST_Border_outset
;
218 nParam
= NS_ooxml::LN_Value_ST_Border_inset
;
221 nParam
= NS_ooxml::LN_Value_ST_Border_dashSmallGap
;
224 nParam
= NS_ooxml::LN_Value_ST_Border_dotDash
;
227 nParam
= NS_ooxml::LN_Value_ST_Border_dotDotDash
;
230 nParam
= NS_ooxml::LN_Value_ST_Border_none
;
237 auto pValue
= new RTFValue(nParam
);
238 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_val
, pValue
);
247 nParam
= NS_ooxml::LN_Value_ST_SectionMark_continuous
;
250 nParam
= NS_ooxml::LN_Value_ST_SectionMark_nextColumn
;
253 nParam
= NS_ooxml::LN_Value_ST_SectionMark_nextPage
;
256 nParam
= NS_ooxml::LN_Value_ST_SectionMark_evenPage
;
259 nParam
= NS_ooxml::LN_Value_ST_SectionMark_oddPage
;
266 if (m_nResetBreakOnSectBreak
!= RTF_invalid
)
268 m_nResetBreakOnSectBreak
= nKeyword
;
270 auto pValue
= new RTFValue(nParam
);
271 m_aStates
.top().aSectionSprms
.set(NS_ooxml::LN_EG_SectPrContents_type
, pValue
);
275 // Footnote numbering
279 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_decimal
;
282 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter
;
285 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_upperLetter
;
288 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman
;
291 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_upperRoman
;
294 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_chicago
;
301 auto pValue
= new RTFValue(nParam
);
302 putNestedSprm(m_aDefaultState
.aParagraphSprms
, NS_ooxml::LN_EG_SectPrContents_footnotePr
,
303 NS_ooxml::LN_CT_FtnProps_numFmt
, pValue
);
307 // Footnote restart type
311 nParam
= NS_ooxml::LN_Value_ST_RestartNumber_eachPage
;
314 nParam
= NS_ooxml::LN_Value_ST_RestartNumber_eachSect
;
317 nParam
= NS_ooxml::LN_Value_ST_RestartNumber_continuous
;
324 auto pValue
= new RTFValue(nParam
);
325 putNestedSprm(m_aDefaultState
.aParagraphSprms
, NS_ooxml::LN_EG_SectPrContents_footnotePr
,
326 NS_ooxml::LN_EG_FtnEdnNumProps_numRestart
, pValue
);
334 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_decimal
;
337 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter
;
340 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_upperLetter
;
343 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman
;
346 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_upperRoman
;
349 nParam
= NS_ooxml::LN_Value_ST_NumberFormat_chicago
;
356 auto pValue
= new RTFValue(nParam
);
357 putNestedSprm(m_aDefaultState
.aParagraphSprms
, NS_ooxml::LN_EG_SectPrContents_endnotePr
,
358 NS_ooxml::LN_CT_EdnProps_numFmt
, pValue
);
365 nParam
= NS_ooxml::LN_Value_ST_Jc_left
;
368 nParam
= NS_ooxml::LN_Value_ST_Jc_center
;
371 nParam
= NS_ooxml::LN_Value_ST_Jc_right
;
378 auto pValue
= new RTFValue(nParam
);
379 m_aStates
.top().aTableRowSprms
.set(NS_ooxml::LN_CT_TrPrBase_jc
, pValue
);
387 nParam
= NS_ooxml::LN_Value_ST_TextDirection_lrTb
;
390 nParam
= NS_ooxml::LN_Value_ST_TextDirection_tbRl
;
393 nParam
= NS_ooxml::LN_Value_ST_TextDirection_btLr
;
396 nParam
= NS_ooxml::LN_Value_ST_TextDirection_lrTbV
;
399 nParam
= NS_ooxml::LN_Value_ST_TextDirection_tbRlV
;
406 auto pValue
= new RTFValue(nParam
);
407 m_aStates
.top().aTableCellSprms
.set(NS_ooxml::LN_CT_TcPrBase_textDirection
, pValue
);
410 // Trivial paragraph flags
414 if (m_aStates
.top().pCurrentBuffer
!= &m_aTableBufferStack
.back())
415 nParam
= NS_ooxml::LN_CT_PPrBase_keepLines
;
418 if (m_aStates
.top().pCurrentBuffer
!= &m_aTableBufferStack
.back())
419 nParam
= NS_ooxml::LN_CT_PPrBase_keepNext
;
423 m_aStates
.top().pCurrentBuffer
= &m_aTableBufferStack
.back();
424 nParam
= NS_ooxml::LN_inTbl
;
428 nParam
= NS_ooxml::LN_CT_PPrBase_pageBreakBefore
;
435 auto pValue
= new RTFValue(1);
436 m_aStates
.top().aParagraphSprms
.erase(NS_ooxml::LN_inTbl
);
437 m_aStates
.top().aParagraphSprms
.set(nParam
, pValue
);
451 // TODO ooxml:CT_Font_family seems to be ignored by the domain mapper
454 m_aStates
.top().nCurrentEncoding
= RTL_TEXTENCODING_MS_1252
;
457 m_aDefaultState
.nCurrentEncoding
= RTL_TEXTENCODING_APPLE_ROMAN
;
458 m_aStates
.top().nCurrentEncoding
= m_aDefaultState
.nCurrentEncoding
;
461 m_aDefaultState
.nCurrentEncoding
= RTL_TEXTENCODING_IBM_437
;
462 m_aStates
.top().nCurrentEncoding
= m_aDefaultState
.nCurrentEncoding
;
465 m_aDefaultState
.nCurrentEncoding
= RTL_TEXTENCODING_IBM_850
;
466 m_aStates
.top().nCurrentEncoding
= m_aDefaultState
.nCurrentEncoding
;
470 m_aStates
.top().aCharacterSprms
= getDefaultState().aCharacterSprms
;
471 m_aStates
.top().nCurrentEncoding
= getEncoding(getFontIndex(m_nDefaultFontIndex
));
472 m_aStates
.top().aCharacterAttributes
= getDefaultState().aCharacterAttributes
;
473 m_aStates
.top().nCurrentCharacterStyleIndex
= -1;
474 m_aStates
.top().isRightToLeft
= false;
475 m_aStates
.top().eRunType
= RTFParserState::RunType::LOCH
;
481 dispatchSymbol(RTF_PAR
);
482 // \pard is allowed between \cell and \row, but in that case it should not reset the fact that we're inside a table.
483 // It should not reset the paragraph style, either, so remember the old paragraph style.
484 RTFValue::Pointer_t pOldStyle
485 = m_aStates
.top().aParagraphSprms
.find(NS_ooxml::LN_CT_PPrBase_pStyle
);
486 m_aStates
.top().aParagraphSprms
= m_aDefaultState
.aParagraphSprms
;
487 m_aStates
.top().aParagraphAttributes
= m_aDefaultState
.aParagraphAttributes
;
489 if (m_nTopLevelCells
== 0 && m_nNestedCells
== 0)
491 // Reset that we're in a table.
492 m_aStates
.top().pCurrentBuffer
= nullptr;
496 // We are still in a table.
497 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_inTbl
, new RTFValue(1));
498 if (m_bAfterCellBeforeRow
&& pOldStyle
)
499 // And we still have the same paragraph style.
500 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_CT_PPrBase_pStyle
, pOldStyle
);
501 // Ideally getDefaultSPRM() would take care of this, but it would not when we're buffering.
502 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_CT_PPrBase_tabs
, new RTFValue());
506 // Reset currently selected paragraph style as well, unless we are in the special "after \cell, before \row" state.
507 // By default the style with index 0 is applied.
508 if (!m_bAfterCellBeforeRow
)
510 OUString
const aName
= getStyleName(0);
511 // But only in case it's not a character style.
513 && getStyleType(0) != NS_ooxml::LN_Value_ST_StyleType_character
)
515 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_CT_PPrBase_pStyle
,
516 new RTFValue(aName
));
517 m_aStates
.top().nCurrentStyleIndex
= 0;
521 m_aStates
.top().nCurrentStyleIndex
= -1;
524 // Need to send paragraph properties again, if there will be any.
530 m_aStates
.top().aSectionSprms
= m_aDefaultState
.aSectionSprms
;
531 m_aStates
.top().aSectionAttributes
= m_aDefaultState
.aSectionAttributes
;
536 // Back these up, in case later we still need this info.
537 backupTableRowProperties();
538 resetTableRowProperties();
539 // In case the table definition is in the middle of the row
540 // (invalid), make sure table definition is emitted.
545 case RTF_NOWIDCTLPAR
:
547 auto pValue
= new RTFValue(int(nKeyword
== RTF_WIDCTLPAR
));
548 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_CT_PPrBase_widowControl
, pValue
);
553 RTFSprms aAttributes
;
554 auto pValue
= new RTFValue(aAttributes
);
555 for (int i
= 0; i
< 4; i
++)
556 m_aStates
.top().aParagraphSprms
.set(getParagraphBorder(i
), pValue
);
557 m_aStates
.top().nBorderState
= RTFBorderState::PARAGRAPH_BOX
;
563 auto pValue
= new RTFValue(nKeyword
== RTF_LTRSECT
? 0 : 1);
564 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_EG_SectPrContents_textDirection
,
571 auto pValue
= new RTFValue(nKeyword
== RTF_LTRPAR
? 0 : 1);
572 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_CT_PPrBase_bidi
, pValue
);
577 m_aStates
.top().aTableRowSprms
.set(NS_ooxml::LN_CT_TblPrBase_bidiVisual
,
578 new RTFValue(int(nKeyword
== RTF_RTLROW
)));
581 // dmapper does not support this.
582 m_aStates
.top().isRightToLeft
= false;
585 m_aStates
.top().isRightToLeft
= true;
586 if (m_aDefaultState
.nCurrentEncoding
== RTL_TEXTENCODING_MS_1255
)
587 m_aStates
.top().nCurrentEncoding
= m_aDefaultState
.nCurrentEncoding
;
591 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_Underline_none
);
592 m_aStates
.top().aCharacterAttributes
.set(NS_ooxml::LN_CT_Underline_val
, pValue
);
596 case RTF_MMATHPICT
: // Picture group used by readers not understanding \moMath group
597 m_aStates
.top().eDestination
= Destination::SKIP
;
604 RTFSprms aAttributes
;
606 auto pValue
= new RTFValue(aAttributes
, aSprms
);
610 nParam
= NS_ooxml::LN_CT_TcBorders_top
;
613 nParam
= NS_ooxml::LN_CT_TcBorders_left
;
616 nParam
= NS_ooxml::LN_CT_TcBorders_bottom
;
619 nParam
= NS_ooxml::LN_CT_TcBorders_right
;
624 putNestedSprm(m_aStates
.top().aTableCellSprms
, NS_ooxml::LN_CT_TcPrBase_tcBorders
,
626 m_aStates
.top().nBorderState
= RTFBorderState::CELL
;
634 RTFSprms aAttributes
;
636 auto pValue
= new RTFValue(aAttributes
, aSprms
);
640 nParam
= NS_ooxml::LN_CT_PageBorders_top
;
643 nParam
= NS_ooxml::LN_CT_PageBorders_left
;
646 nParam
= NS_ooxml::LN_CT_PageBorders_bottom
;
649 nParam
= NS_ooxml::LN_CT_PageBorders_right
;
654 putNestedSprm(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgBorders
,
656 m_aStates
.top().nBorderState
= RTFBorderState::PAGE
;
664 RTFSprms aAttributes
;
666 auto pValue
= new RTFValue(aAttributes
, aSprms
);
670 nParam
= getParagraphBorder(0);
673 nParam
= getParagraphBorder(1);
676 nParam
= getParagraphBorder(2);
679 nParam
= getParagraphBorder(3);
684 putNestedSprm(m_aStates
.top().aParagraphSprms
, NS_ooxml::LN_CT_PrBase_pBdr
, nParam
,
686 m_aStates
.top().nBorderState
= RTFBorderState::PARAGRAPH
;
691 RTFSprms aAttributes
;
692 auto pValue
= new RTFValue(aAttributes
);
693 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_RPrBase_bdr
, pValue
);
694 m_aStates
.top().nBorderState
= RTFBorderState::CHARACTER
;
699 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_Merge_restart
);
700 m_aStates
.top().aTableCellSprms
.set(NS_ooxml::LN_CT_TcPrBase_hMerge
, pValue
);
705 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_Merge_continue
);
706 m_aStates
.top().aTableCellSprms
.set(NS_ooxml::LN_CT_TcPrBase_hMerge
, pValue
);
711 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_Merge_restart
);
712 m_aStates
.top().aTableCellSprms
.set(NS_ooxml::LN_CT_TcPrBase_vMerge
, pValue
);
717 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_Merge_continue
);
718 m_aStates
.top().aTableCellSprms
.set(NS_ooxml::LN_CT_TcPrBase_vMerge
, pValue
);
728 nParam
= NS_ooxml::LN_Value_ST_VerticalJc_top
;
731 nParam
= NS_ooxml::LN_Value_ST_VerticalJc_center
;
734 nParam
= NS_ooxml::LN_Value_ST_VerticalJc_bottom
;
739 auto pValue
= new RTFValue(nParam
);
740 m_aStates
.top().aTableCellSprms
.set(NS_ooxml::LN_CT_TcPrBase_vAlign
, pValue
);
745 auto pValue
= new RTFValue(1);
746 m_aStates
.top().aTableRowSprms
.set(NS_ooxml::LN_CT_TrPrBase_cantSplit
, pValue
);
749 case RTF_SECTUNLOCKED
:
751 auto pValue
= new RTFValue(0);
752 m_aStates
.top().aSectionSprms
.set(NS_ooxml::LN_EG_SectPrContents_formProt
, pValue
);
757 // These should be mapped to NS_ooxml::LN_EG_SectPrContents_pgNumType, but dmapper has no API for that at the moment.
760 m_aStates
.top().eRunType
= RTFParserState::RunType::LOCH
;
763 m_aStates
.top().eRunType
= RTFParserState::RunType::HICH
;
766 m_aStates
.top().eRunType
= RTFParserState::RunType::DBCH
;
770 auto pValue
= new RTFValue(1);
771 m_aStates
.top().aSectionSprms
.set(NS_ooxml::LN_EG_SectPrContents_titlePg
, pValue
);
776 // Make sure character properties are not lost if the document
777 // starts with a footnote.
778 if (!isStyleSheetImport())
784 if (!m_aStates
.top().pCurrentBuffer
)
785 m_aStates
.top().pCurrentBuffer
= &m_aSuperBuffer
;
787 auto pValue
= new RTFValue("superscript");
788 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_RPrBase_vertAlign
, pValue
);
793 auto pValue
= new RTFValue("subscript");
794 m_aStates
.top().aCharacterSprms
.set(NS_ooxml::LN_EG_RPrBase_vertAlign
, pValue
);
799 if (m_aStates
.top().pCurrentBuffer
== &m_aSuperBuffer
)
801 replayBuffer(m_aSuperBuffer
, nullptr, nullptr);
802 m_aStates
.top().pCurrentBuffer
= nullptr;
804 m_aStates
.top().aCharacterSprms
.erase(NS_ooxml::LN_EG_RPrBase_vertAlign
);
810 auto pValue
= new RTFValue(nKeyword
== RTF_LINEPPAGE
811 ? NS_ooxml::LN_Value_ST_LineNumberRestart_newPage
812 : NS_ooxml::LN_Value_ST_LineNumberRestart_continuous
);
813 putNestedAttribute(m_aStates
.top().aSectionSprms
,
814 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
815 NS_ooxml::LN_CT_LineNumber_restart
, pValue
);
819 // Noop, this is the default in Writer.
822 // Noop, Writer does not support having endnotes at the end of section.
824 case RTF_AFTNRSTCONT
:
825 // Noop, this is the default in Writer.
827 case RTF_AFTNRESTART
:
828 // Noop, Writer does not support restarting endnotes at each section.
831 // Noop, this is the default in Writer.
835 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_RestartNumber_eachSect
);
836 putNestedSprm(m_aDefaultState
.aParagraphSprms
,
837 NS_ooxml::LN_EG_SectPrContents_footnotePr
,
838 NS_ooxml::LN_EG_FtnEdnNumProps_numRestart
, pValue
);
842 eraseNestedAttribute(m_aStates
.top().aSectionSprms
,
843 NS_ooxml::LN_EG_SectPrContents_lnNumType
,
844 NS_ooxml::LN_CT_LineNumber_distance
);
847 // Noop, this is the default in Writer.
850 m_aStates
.top().aPicture
.eStyle
= RTFBmpStyle::PNG
;
853 m_aStates
.top().aPicture
.eStyle
= RTFBmpStyle::JPEG
;
856 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_yAlign
,
857 NS_ooxml::LN_Value_doc_ST_YAlign_top
);
860 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_yAlign
,
861 NS_ooxml::LN_Value_doc_ST_YAlign_bottom
);
864 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_yAlign
,
865 NS_ooxml::LN_Value_doc_ST_YAlign_center
);
868 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_yAlign
,
869 NS_ooxml::LN_Value_doc_ST_YAlign_inside
);
872 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_yAlign
,
873 NS_ooxml::LN_Value_doc_ST_YAlign_outside
);
876 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_yAlign
,
877 NS_ooxml::LN_Value_doc_ST_YAlign_inline
);
881 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor
,
882 NS_ooxml::LN_Value_doc_ST_HAnchor_margin
);
885 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor
,
886 NS_ooxml::LN_Value_doc_ST_VAnchor_margin
);
889 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor
,
890 NS_ooxml::LN_Value_doc_ST_HAnchor_page
);
893 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor
,
894 NS_ooxml::LN_Value_doc_ST_VAnchor_page
);
897 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor
,
898 NS_ooxml::LN_Value_doc_ST_HAnchor_text
);
901 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor
,
902 NS_ooxml::LN_Value_doc_ST_VAnchor_text
);
906 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_xAlign
,
907 NS_ooxml::LN_Value_doc_ST_XAlign_center
);
910 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_xAlign
,
911 NS_ooxml::LN_Value_doc_ST_XAlign_inside
);
914 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_xAlign
,
915 NS_ooxml::LN_Value_doc_ST_XAlign_outside
);
918 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_xAlign
,
919 NS_ooxml::LN_Value_doc_ST_XAlign_left
);
922 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_xAlign
,
923 NS_ooxml::LN_Value_doc_ST_XAlign_right
);
937 m_aStates
.top().aDrawingObject
.xShape
.set(
938 getModelFactory()->createInstance("com.sun.star.drawing.LineShape"),
942 // The reason this is not a simple CustomShape is that in the old syntax we have no ViewBox info.
943 m_aStates
.top().aDrawingObject
.xShape
.set(
944 getModelFactory()->createInstance("com.sun.star.drawing.PolyLineShape"),
948 m_aStates
.top().aDrawingObject
.xShape
.set(
949 getModelFactory()->createInstance("com.sun.star.drawing.PolyPolygonShape"),
953 m_aStates
.top().aDrawingObject
.xShape
.set(
954 getModelFactory()->createInstance("com.sun.star.drawing.RectangleShape"),
958 nType
= ESCHER_ShpInst_Ellipse
;
962 m_aStates
.top().aDrawingObject
.xShape
.set(
963 getModelFactory()->createInstance("com.sun.star.text.TextFrame"),
965 std::vector
<beans::PropertyValue
> aDefaults
966 = RTFSdrImport::getTextFrameDefaults(false);
967 for (const auto& rDefault
: aDefaults
)
969 if (!findPropertyName(m_aStates
.top().aDrawingObject
.aPendingProperties
,
971 m_aStates
.top().aDrawingObject
.aPendingProperties
.push_back(rDefault
);
974 Mapper().startShape(m_aStates
.top().aDrawingObject
.xShape
);
975 m_aStates
.top().aDrawingObject
.bHadShapeText
= true;
982 m_aStates
.top().aDrawingObject
.xShape
.set(
983 getModelFactory()->createInstance("com.sun.star.drawing.CustomShape"),
985 uno::Reference
<drawing::XDrawPageSupplier
> xDrawSupplier(m_xDstDoc
, uno::UNO_QUERY
);
986 m_aStates
.top().aDrawingObject
.xPropertySet
.set(m_aStates
.top().aDrawingObject
.xShape
,
988 if (xDrawSupplier
.is())
990 uno::Reference
<drawing::XShapes
> xShapes(xDrawSupplier
->getDrawPage(),
992 if (xShapes
.is() && nKeyword
!= RTF_DPTXBX
)
994 // set default VertOrient before inserting
995 m_aStates
.top().aDrawingObject
.xPropertySet
->setPropertyValue(
996 "VertOrient", uno::makeAny(text::VertOrientation::NONE
));
997 xShapes
->add(m_aStates
.top().aDrawingObject
.xShape
);
1002 uno::Reference
<drawing::XEnhancedCustomShapeDefaulter
> xDefaulter(
1003 m_aStates
.top().aDrawingObject
.xShape
, uno::UNO_QUERY
);
1004 xDefaulter
->createCustomShapeDefaults(OUString::number(nType
));
1006 std::vector
<beans::PropertyValue
>& rPendingProperties
1007 = m_aStates
.top().aDrawingObject
.aPendingProperties
;
1008 for (auto& rPendingProperty
: rPendingProperties
)
1009 m_aStates
.top().aDrawingObject
.xPropertySet
->setPropertyValue(
1010 rPendingProperty
.Name
, rPendingProperty
.Value
);
1011 m_pSdrImport
->resolveDhgt(m_aStates
.top().aDrawingObject
.xPropertySet
,
1012 m_aStates
.top().aDrawingObject
.nDhgt
, /*bOldStyle=*/true);
1015 case RTF_DOBXMARGIN
:
1016 case RTF_DOBYMARGIN
:
1018 beans::PropertyValue aPropertyValue
;
1019 aPropertyValue
.Name
= (nKeyword
== RTF_DOBXMARGIN
? OUString("HoriOrientRelation")
1020 : OUString("VertOrientRelation"));
1021 aPropertyValue
.Value
<<= text::RelOrientation::PAGE_PRINT_AREA
;
1022 m_aStates
.top().aDrawingObject
.aPendingProperties
.push_back(aPropertyValue
);
1028 beans::PropertyValue aPropertyValue
;
1029 aPropertyValue
.Name
= (nKeyword
== RTF_DOBXPAGE
? OUString("HoriOrientRelation")
1030 : OUString("VertOrientRelation"));
1031 aPropertyValue
.Value
<<= text::RelOrientation::PAGE_FRAME
;
1032 m_aStates
.top().aDrawingObject
.aPendingProperties
.push_back(aPropertyValue
);
1037 beans::PropertyValue aPropertyValue
;
1038 aPropertyValue
.Name
= "VertOrientRelation";
1039 aPropertyValue
.Value
<<= text::RelOrientation::FRAME
;
1040 m_aStates
.top().aDrawingObject
.aPendingProperties
.push_back(aPropertyValue
);
1043 case RTF_CONTEXTUALSPACE
:
1045 auto pValue
= new RTFValue(1);
1046 m_aStates
.top().aParagraphSprms
.set(NS_ooxml::LN_CT_PPrBase_contextualSpacing
, pValue
);
1049 case RTF_LINKSTYLES
:
1051 auto pValue
= new RTFValue(1);
1052 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_linkStyles
, pValue
);
1057 auto pValue
= new RTFValue(2);
1058 m_aStates
.top().aTableAttributes
.set(NS_ooxml::LN_CT_AbstractNum_nsid
, pValue
);
1063 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_decimal
);
1064 m_aStates
.top().aTableSprms
.set(NS_ooxml::LN_CT_Lvl_numFmt
, pValue
);
1069 m_aStates
.top().aTableAttributes
.set(NS_ooxml::LN_CT_AbstractNum_nsid
, new RTFValue(1));
1070 m_aStates
.top().aTableSprms
.set(
1071 NS_ooxml::LN_CT_Lvl_numFmt
,
1072 new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_bullet
));
1077 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_PageOrientation_landscape
);
1078 putNestedAttribute(m_aDefaultState
.aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgSz
,
1079 NS_ooxml::LN_CT_PageSz_orient
, pValue
);
1080 SAL_FALLTHROUGH
; // set the default + current value
1084 auto pValue
= new RTFValue(NS_ooxml::LN_Value_ST_PageOrientation_landscape
);
1085 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_pgSz
,
1086 NS_ooxml::LN_CT_PageSz_orient
, pValue
);
1090 m_aStates
.top().aShape
.nHoriOrientRelation
= text::RelOrientation::PAGE_FRAME
;
1091 m_aStates
.top().aShape
.nHoriOrientRelationToken
1092 = NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page
;
1095 m_aStates
.top().aShape
.nVertOrientRelation
= text::RelOrientation::PAGE_FRAME
;
1096 m_aStates
.top().aShape
.nVertOrientRelationToken
1097 = NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page
;
1099 case RTF_DPLINEHOLLOW
:
1100 m_aStates
.top().aDrawingObject
.nFLine
= 0;
1103 if (m_aStates
.top().aDrawingObject
.xPropertySet
.is())
1104 // Seems this old syntax has no way to specify a custom radius, and this is the default
1105 m_aStates
.top().aDrawingObject
.xPropertySet
->setPropertyValue(
1106 "CornerRadius", uno::makeAny(sal_Int32(83)));
1109 m_aStates
.top().aFrame
.setSprm(NS_ooxml::LN_CT_FramePr_wrap
,
1110 NS_ooxml::LN_Value_doc_ST_Wrap_notBeside
);
1116 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_trackRevisions
, new RTFValue(1));
1119 putBorderProperty(m_aStates
, NS_ooxml::LN_CT_Border_shadow
, new RTFValue(1));
1122 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Compat_noColumnBalance
, new RTFValue(1));
1124 case RTF_MARGMIRROR
:
1125 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_mirrorMargins
, new RTFValue(1));
1128 m_aStates
.top().aTableSprms
.set(NS_ooxml::LN_CT_Style_autoRedefine
, new RTFValue(1));
1131 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Settings_widowControl
, new RTFValue(1));
1133 case RTF_LINEBETCOL
:
1134 putNestedAttribute(m_aStates
.top().aSectionSprms
, NS_ooxml::LN_EG_SectPrContents_cols
,
1135 NS_ooxml::LN_CT_Columns_sep
, new RTFValue(1));
1137 case RTF_PGNRESTART
:
1138 putNestedAttribute(m_aStates
.top().aSectionSprms
,
1139 NS_ooxml::LN_EG_SectPrContents_pgNumType
,
1140 NS_ooxml::LN_CT_PageNumber_start
, new RTFValue(1));
1144 auto pIntValue
= new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_upperLetter
);
1145 putNestedAttribute(m_aStates
.top().aSectionSprms
,
1146 NS_ooxml::LN_EG_SectPrContents_pgNumType
,
1147 NS_ooxml::LN_CT_PageNumber_fmt
, pIntValue
);
1152 auto pIntValue
= new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter
);
1153 putNestedAttribute(m_aStates
.top().aSectionSprms
,
1154 NS_ooxml::LN_EG_SectPrContents_pgNumType
,
1155 NS_ooxml::LN_CT_PageNumber_fmt
, pIntValue
);
1160 auto pIntValue
= new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_upperRoman
);
1161 putNestedAttribute(m_aStates
.top().aSectionSprms
,
1162 NS_ooxml::LN_EG_SectPrContents_pgNumType
,
1163 NS_ooxml::LN_CT_PageNumber_fmt
, pIntValue
);
1168 auto pIntValue
= new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman
);
1169 putNestedAttribute(m_aStates
.top().aSectionSprms
,
1170 NS_ooxml::LN_EG_SectPrContents_pgNumType
,
1171 NS_ooxml::LN_CT_PageNumber_fmt
, pIntValue
);
1176 auto pIntValue
= new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_decimal
);
1177 putNestedAttribute(m_aStates
.top().aSectionSprms
,
1178 NS_ooxml::LN_EG_SectPrContents_pgNumType
,
1179 NS_ooxml::LN_CT_PageNumber_fmt
, pIntValue
);
1183 m_aSettingsTableSprms
.set(NS_ooxml::LN_CT_Compat_doNotUseHTMLParagraphAutoSpacing
,
1188 SAL_INFO("writerfilter", "TODO handle flag '" << keywordToString(nKeyword
) << "'");
1189 aSkip
.setParsed(false);
1193 return RTFError::OK
;
1196 } // namespace rtftok
1197 } // namespace writerfilter
1199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */