diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2023-04-21 07:05:26 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-04-21 08:21:45 +0200 |
commit | 05425f73bfa41d3f7591461e2ad0beb4fafc39b4 (patch) | |
tree | c357d378788da1dad30da8a006a0205b8202aea1 /writerfilter/source/rtftok/rtfdispatchflag.cxx | |
parent | ac519af951541b7313a4c98e1bee463bf47356be (diff) |
sw floatable: teach the RTF import about SwFormatFlySplit
- if the document has no \nobrkwrptbl, then ignore all floating table
control word for now
- map the rest of the RTF control words to OOXML attributes under the
NS_ooxml::LN_CT_TblPrBase_tblpPr sprm:
- \tpv{para,mrg,pg} -> NS_ooxml::LN_CT_TblPPr_vertAnchor
- \tph{col,mrg,pg} -> NS_ooxml::LN_CT_TblPPr_horzAnchor
- \tposy -> NS_ooxml::LN_CT_TblPPr_tblpY
- \tposy{c,b} -> NS_ooxml::LN_CT_TblPPr_tblpYSpec
- \tposx -> NS_ooxml::LN_CT_TblPPr_tblpX
- \tposx{c,r} -> NS_ooxml::LN_CT_TblPPr_tblpXSpec
- \tdfrmtxtLeft -> NS_ooxml::LN_CT_TblPPr_leftFromText
- \tdfrmtxtRight -> NS_ooxml::LN_CT_TblPPr_rightFromText
- \tdfrmtxtTop -> NS_ooxml::LN_CT_TblPPr_topFromText
- \tdfrmtxtBottom -> NS_ooxml::LN_CT_TblPPr_bottomFromText
Change-Id: I0b30d0eba8c1b7b6d3497334c958146717d06552
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150738
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'writerfilter/source/rtftok/rtfdispatchflag.cxx')
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchflag.cxx | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx index 0ef4f21729d6..bc3c3037e16d 100644 --- a/writerfilter/source/rtftok/rtfdispatchflag.cxx +++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx @@ -32,6 +32,93 @@ using namespace com::sun::star; namespace writerfilter::rtftok { +bool RTFDocumentImpl::dispatchFloatingTableFlag(RTFKeyword nKeyword) +{ + if (!m_bBreakWrappedTables) + { + return false; + } + + // Positioned Wrapped Tables + OUString aParam; + switch (nKeyword) + { + case RTFKeyword::TPVPARA: + aParam = "text"; + break; + case RTFKeyword::TPVMRG: + aParam = "margin"; + break; + case RTFKeyword::TPVPG: + aParam = "page"; + break; + default: + break; + } + if (!aParam.isEmpty()) + { + putNestedAttribute(m_aStates.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr, + NS_ooxml::LN_CT_TblPPr_vertAnchor, new RTFValue(aParam)); + return true; + } + switch (nKeyword) + { + case RTFKeyword::TPHCOL: + aParam = "text"; + break; + case RTFKeyword::TPHMRG: + aParam = "margin"; + break; + case RTFKeyword::TPHPG: + aParam = "page"; + break; + default: + break; + } + if (!aParam.isEmpty()) + { + putNestedAttribute(m_aStates.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr, + NS_ooxml::LN_CT_TblPPr_horzAnchor, new RTFValue(aParam)); + return true; + } + switch (nKeyword) + { + case RTFKeyword::TPOSYC: + aParam = "center"; + break; + case RTFKeyword::TPOSYB: + aParam = "bottom"; + break; + default: + break; + } + if (!aParam.isEmpty()) + { + putNestedAttribute(m_aStates.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr, + NS_ooxml::LN_CT_TblPPr_tblpYSpec, new RTFValue(aParam)); + return true; + } + switch (nKeyword) + { + case RTFKeyword::TPOSXC: + aParam = "center"; + break; + case RTFKeyword::TPOSXR: + aParam = "right"; + break; + default: + break; + } + if (!aParam.isEmpty()) + { + putNestedAttribute(m_aStates.top().getTableRowSprms(), NS_ooxml::LN_CT_TblPrBase_tblpPr, + NS_ooxml::LN_CT_TblPPr_tblpXSpec, new RTFValue(aParam)); + return true; + } + + return false; +} + RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) { setNeedSect(true); @@ -442,6 +529,11 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) return RTFError::OK; } + if (dispatchFloatingTableFlag(nKeyword)) + { + return RTFError::OK; + } + switch (nKeyword) { case RTFKeyword::FNIL: @@ -1243,6 +1335,11 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) m_aStates.top().setFieldLocked(true); } break; + case RTFKeyword::NOBRKWRPTBL: + { + m_bBreakWrappedTables = true; + } + break; default: { SAL_INFO("writerfilter", "TODO handle flag '" << keywordToString(nKeyword) << "'"); |