sw/qa/extras/ww8export/data/tdf133504_wrapNotBeside.doc |binary
 sw/qa/extras/ww8export/ww8export.cxx                    |    8 +++++
 sw/source/filter/ww8/ww8par6.cxx                        |   24 ++++++++++++----
 3 files changed, 27 insertions(+), 5 deletions(-)

New commits:
commit 4f91e6c91b449ffe1e51cc517e8fc93179feca67
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Thu May 25 12:19:16 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Fri May 26 16:19:38 2023 +0200

    tdf#133504 doc import: set the correct wrap
    
    Umm, I'm amazed that
    1.) this hasn't been a bigger, burning issue, and
    2.) that no one has ever investigated or fixed this.
    It was super easy.
    
    The code is mind boggling though. "Auto" and "Not Beside" are NONE,
    but around, none, tight, and through are "Optimal"?
    
    How about auto is optimal, around/tight are parallel,
    none is none, and through is through.
    
    Lets try that and see how it works.
    
    Prior patchsets submitted searched for existing examples.
    They suggest that MS Word's UI only allows for notBeside and around,
    but I kept the others there just in case something can trigger them.
    
    Change-Id: I893dfd66737bcc3148b48c68cb6df778d3f528c8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152286
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/ww8export/data/tdf133504_wrapNotBeside.doc 
b/sw/qa/extras/ww8export/data/tdf133504_wrapNotBeside.doc
new file mode 100644
index 000000000000..865023e34489
Binary files /dev/null and 
b/sw/qa/extras/ww8export/data/tdf133504_wrapNotBeside.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx 
b/sw/qa/extras/ww8export/ww8export.cxx
index d248c6ce6b26..fd4da5249319 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/table/TableBorder.hpp>
 #include <com/sun/star/table/TableBorder2.hpp>
 #include <com/sun/star/text/GraphicCrop.hpp>
+#include <com/sun/star/text/WrapTextMode.hpp>
 #include <com/sun/star/text/XFormField.hpp>
 #include <com/sun/star/text/XTextField.hpp>
 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
@@ -577,6 +578,13 @@ DECLARE_WW8EXPORT_TEST(testBnc787942, "bnc787942.doc")
 
     // this is on page 1 in Word
     parseDump("/root/page[1]/body/txt[4]/anchored");
+
+    CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_PARALLEL, 
getProperty<text::WrapTextMode>(getShape(1), "Surround"));
+}
+
+DECLARE_WW8EXPORT_TEST(testTdf133504_wrapNotBeside, 
"tdf133504_wrapNotBeside.doc")
+{
+    CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_NONE, 
getProperty<text::WrapTextMode>(getShape(1), "Surround"));
 }
 
 DECLARE_WW8EXPORT_TEST(testLayoutHanging, "fdo68967.doc")
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 671e25a97aa5..134acfba537d 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -1912,7 +1912,6 @@ eHRel(text::RelOrientation::PAGE_FRAME),
 eVRel(text::RelOrientation::FRAME),
 eVAlign(text::VertOrientation::NONE),
 eHAlign(text::HoriOrientation::NONE),
-eSurround(( rWW.nPWr > 1 ) ? css::text::WrapTextMode_DYNAMIC : 
css::text::WrapTextMode_NONE),
 nXBind(( rWW.nTPc & 0xc0 ) >> 6),
 nYBind(( rWW.nTPc & 0x30 ) >> 4),
 nNewNetWidth(MINFLY),
@@ -1920,10 +1919,25 @@ nLineSpace(0),
 bAutoWidth(false),
 bTogglePos(false)
 {
-    //#i119466 mapping "Around" wrap setting to "Parallel" for table
-    const bool bIsTable = 
rIo.m_xPlcxMan->HasParaSprm(NS_sprm::PFInTable::val).pSprm;
-    if (bIsTable && rWW.nPWr == 2)
-        eSurround = css::text::WrapTextMode_PARALLEL;
+    switch(rWW.nPWr)
+    {
+        case 0: // ST_Wrap: auto
+            eSurround = css::text::WrapTextMode_DYNAMIC;
+            break;
+        case 1: // ST_Wrap: notBeside
+        case 3: // ST_Wrap: none
+            eSurround = css::text::WrapTextMode_NONE;
+            break;
+        case 2: // ST_Wrap: around
+        case 4: // ST_Wrap: tight
+            eSurround = css::text::WrapTextMode_PARALLEL;
+            break;
+        case 5: // St_Wrap: through
+            eSurround = css::text::WrapTextMode_THROUGH;
+            break;
+        default:
+            eSurround = css::text::WrapTextMode_DYNAMIC;
+    }
 
     /*
      #95905#, #83307# seems to have gone away now, so re-enable parallel

Reply via email to