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 77980d4375b270f328afe1dd90e96e2e31fd498d
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Tue Mar 5 20:19:09 2024 -0500
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Thu Mar 7 02:20:33 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 <jl...@mail.com>

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 8bae715cf4de..bc5d5f253e8e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -304,6 +304,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 fb34152cda6f..b7d5f101f417 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1290,6 +1290,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;
 

Reply via email to