sw/qa/extras/ww8export/data/tdf160049_anchorMargin.doc |binary
 sw/qa/extras/ww8export/ww8export4.cxx                  |   10 ++++++++++
 sw/source/filter/ww8/ww8graf.cxx                       |    6 ++++++
 3 files changed, 16 insertions(+)

New commits:
commit 3aeaee800f675a5f733e06bb4ea73909570f9004
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Tue Mar 5 19:43:51 2024 -0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Mar 6 11:27:04 2024 +0100

    tdf#160049 doc import: use margins with left/right HoriOrientRelation
    
    No interesting existing unit tests.
    
    make CppunitTest_sw_ww8export4 \
        CPPUNIT_TEST_NAME=testTdf160049_anchorMargin
    
    Change-Id: Ib855d9f35db9e0f47aff18400b69a990cd1ad5ca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164444
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ww8export/data/tdf160049_anchorMargin.doc 
b/sw/qa/extras/ww8export/data/tdf160049_anchorMargin.doc
new file mode 100644
index 000000000000..d1082515fd9c
Binary files /dev/null and 
b/sw/qa/extras/ww8export/data/tdf160049_anchorMargin.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export4.cxx 
b/sw/qa/extras/ww8export/ww8export4.cxx
index ea50ed2a19b9..7ab6f76ec3a6 100644
--- a/sw/qa/extras/ww8export/ww8export4.cxx
+++ b/sw/qa/extras/ww8export/ww8export4.cxx
@@ -51,6 +51,16 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf77964)
     CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, 
getProperty<text::TextContentAnchorType>(getShapeByName(u"Image2"), 
"AnchorType"));
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf160049_anchorMargin, 
"tdf160049_anchorMargin.doc")
+{
+    // given a document with a LEFT "column/text" anchored image
+
+    // The image 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_WW8EXPORT_TEST(testTdf150197_anlv2ListFormat, 
"tdf150197_anlv2ListFormat.doc")
 {
     CPPUNIT_ASSERT_EQUAL(OUString("1."), 
getProperty<OUString>(getParagraph(2), "ListLabelString"));
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index a7c9ec979e09..28b1211683d1 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2400,6 +2400,12 @@ RndStdIds 
SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FS
         rFSPA.nXaLeft = 0;
         rFSPA.nXaRight = nWidth;
     }
+    else if ((eHoriOri == text::HoriOrientation::LEFT || eHoriOri == 
text::HoriOrientation::RIGHT)
+             && eHoriRel == text::RelOrientation::FRAME)
+    {
+        // relative left/right honors paragraph margins, but not with center 
or none/absolute offset
+        eHoriRel = text::RelOrientation::PRINT_AREA;
+    }
 
     // #i24255# - position of floating screen objects in
     // R2L layout are given in L2R layout, thus convert them of all

Reply via email to