sw/qa/extras/ooxmlexport/data/tdf160049_anchorMargin2.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 10 ++++++++++ writerfilter/source/dmapper/GraphicImport.cxx | 10 ++++++++++ 3 files changed, 20 insertions(+)
New commits: commit 14451b801029e8efc05d7f777692a91eddab9e16 Author: Justin Luth <[email protected]> AuthorDate: Tue Mar 5 20:19:09 2024 -0500 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Mar 11 09:47:18 2024 +0100 tdf#160049 dml shape import: use margins with left/right HoriOrientRel make CppunitTest_sw_ooxmlexport21 \ CPPUNIT_TEST_NAME=testTdf160049_anchorMargin Change-Id: I3e2df2037cabfedbb6df6b8c8257e90baeaab96e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164445 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164584 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/data/tdf160049_anchorMargin2.docx b/sw/qa/extras/ooxmlexport/data/tdf160049_anchorMargin2.docx new file mode 100644 index 000000000000..349ed4cbeea7 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf160049_anchorMargin2.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index d57c94835e4b..61c1b3172d19 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -302,6 +302,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMarginVML, "tdf160049_anchorMarginV getProperty<sal_Int16>(getShape(1), "HoriOrientRelation")); } +DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMargin2, "tdf160049_anchorMargin2.docx") +{ + // given a DML compat14 (Word 2010) document with a LEFT "column/text" anchored shape + + // The shape takes into account the margin, so it looks like it is in the middle of the doc, + // which is "Paragraph text area"/PRINT_AREA/1, not "Entire paragraph area"/FRAME/0 + CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PRINT_AREA, + getProperty<sal_Int16>(getShape(1), "HoriOrientRelation")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMargin15, "tdf160049_anchorMargin15.docx") { // given a DML compat15 (Word 2013) document with a LEFT "column/text" anchored image diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 3e5d6d87b267..46a5da451226 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1268,6 +1268,16 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) m_pImpl->m_bLayoutInCell = false; } + if (m_pImpl->m_nHoriRelation == text::RelOrientation::FRAME + && m_pImpl->m_nHoriOrient > text::HoriOrientation::NONE + && m_pImpl->m_nHoriOrient != text::HoriOrientation::CENTER + && m_pImpl->m_nHoriOrient < text::HoriOrientation::FULL) + { + // before compat15, relative left/right/inside/outside honored margins. + if (m_pImpl->m_rDomainMapper.GetSettingsTable()->GetWordCompatibilityMode() < 15) + m_pImpl->m_nHoriRelation = text::RelOrientation::PRINT_AREA; + } + // Anchored: Word only supports at-char in that case. text::TextContentAnchorType eAnchorType = text::TextContentAnchorType_AT_CHARACTER;
