sw/qa/extras/ooxmlexport/ooxmlexport19.cxx |    1 +
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx  |    8 ++++++++
 sw/source/filter/ww8/docxsdrexport.cxx     |    5 +++++
 3 files changed, 14 insertions(+)

New commits:
commit 54ad2fd256224804181050f60c0668aa24cc82f7
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Fri Jan 12 09:34:51 2024 -0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Jan 15 08:51:12 2024 +0100

    tdf#139915 DOCX export: fix anchored obj position with TEXT_LINE
    
    The position of objects was waffling back and forth
    between "above" or "below" every round-trip.
    For example, the unit test was alternating between 410 and 3951.
    
    make CppunitTest_sw_ooxmlexport19 CPPUNIT_TEST_NAME=testTdf97371
    
    This is an export followup to vmiklos' import fix in
    LO 7.2 commit 2f21e4f357ec60450df84ddd858c3cf0a4711b02
    
    I noticed that import still does not correctly position images:
    make CppunitTest_sw_ooxmlexport8 CPPUNIT_TEST_NAME=testN747461
    so I created tdf#159157 and tdf#159158 as follow-up bugs for that.
    
    Change-Id: I29864d53f3b5e2fc9830793275f17a11eac0516f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161985
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    (cherry picked from commit c45bf5f4ae858d5d0532ee9b58fcbf23e94e2d75)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161996
    Tested-by: Justin Luth <jl...@mail.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 0c1d1a25fb35..d6193305e96c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -609,6 +609,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf97371, "tdf97371.docx")
     tools::Long nDiff = std::abs(pShape->GetSnapRect().Top() - 
pTextBox->GetSnapRect().Top());
     // The top of the two shapes were 410 and 3951, now it should be 3950 and 
3951.
     CPPUNIT_ASSERT(nDiff < 10);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(3900), 
pShape->GetSnapRect().Top(), 100);
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf99140)
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index 10fd87ebec2c..2463534dd8ba 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -173,6 +173,14 @@ after they are loaded.
     CPPUNIT_ASSERT_EQUAL( OUString( "Black" ), descr1 );
     CPPUNIT_ASSERT_EQUAL( OUString( "Red" ), descr2 );
     CPPUNIT_ASSERT_EQUAL( OUString( "Green" ), descr3 );
+
+    //FIXME: MS Word shows the image below the line of text, not above it.
+    // tdf#139915 This was 826, but it should be -826
+    if (isExported())
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(-826), getProperty<sal_Int32>(image1, 
"VertOrientPosition"));
+    sal_Int16 nExpected = text::RelOrientation::TEXT_LINE;
+    CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int16>(image1, 
"VertOrientRelation"));
+
 }
 
 DECLARE_OOXMLEXPORT_TEST(testN750255, "n750255.docx")
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx 
b/sw/source/filter/ww8/docxsdrexport.cxx
index 0c42d28fc6ad..5c746f6afe6e 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -939,6 +939,11 @@ void DocxSdrExport::startDMLAnchorInline(const 
SwFrameFormat* pFrameFormat, cons
                 relativeFromV = "paragraph";
                 break;
             case text::RelOrientation::TEXT_LINE:
+                relativeFromV = "line";
+                // Word's "line" is "below the bottom of the line", our 
TEXT_LINE is
+                // "towards top, from the bottom of the line", so invert the 
vertical position.
+                aPos.Y *= -1;
+                break;
             default:
                 relativeFromV = "line";
                 break;

Reply via email to