[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Dec 7 11:35:15 UTC 2016


 sw/qa/extras/uiwriter/data/tdf104440.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx       |   15 +++++++++++++++
 sw/source/core/text/txtfly.cxx           |    7 +++++++
 3 files changed, 22 insertions(+)

New commits:
commit 862c12396585661606d4e6ae583d1d024a19d222
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Dec 7 10:00:10 2016 +0100

    tdf#104440 sw: fix layout inconsistency with dynamic wrapping and undo
    
    The problem was that the second fly frame was placed on the first page
    initially, but after typing a character (which moved it to the second
    page) and then undoing, it wasn't moved back.
    
    Fix the inconsistency by handling the "fly frame takes all horizontal
    space" case as parallel wrapping (which will result in no wrapping at
    the end), this way the second fly frame appears on the second page both
    initially and after editing.
    
    As an additional data point, the DOC export of the bugdoc is now
    rendered in Word the same way as in Writer.
    
    Change-Id: Ifc9f17458ad0501b8ab6077e5a4998d48fd6f1d8

diff --git a/sw/qa/extras/uiwriter/data/tdf104440.odt b/sw/qa/extras/uiwriter/data/tdf104440.odt
new file mode 100644
index 0000000..b226bb5
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf104440.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index c3ca4ee..44dd39e 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -216,6 +216,7 @@ public:
     void testLandscape();
     void testTdf95699();
     void testTdf104032();
+    void testTdf104440();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -328,6 +329,7 @@ public:
     CPPUNIT_TEST(testLandscape);
     CPPUNIT_TEST(testTdf95699);
     CPPUNIT_TEST(testTdf104032);
+    CPPUNIT_TEST(testTdf104440);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4086,6 +4088,19 @@ void SwUiWriterTest::testTdf104032()
     rUndoManager.Undo();
 }
 
+void SwUiWriterTest::testTdf104440()
+{
+    createDoc("tdf104440.odt");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//page[2]/body/txt/anchored");
+    xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
+    // This was 0: both Text Frames in the document were anchored to a
+    // paragraph on page 1, while we expect that the second Text Frame is
+    // anchored to a paragraph on page 2.
+    CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlNodes));
+    xmlXPathFreeObject(pXmlObj);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index d0ed11e..2547d98 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -1370,6 +1370,13 @@ SwSurround SwTextFly::GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredO
             const int textMin = GetMaster()->GetNode()
                 ->getIDocumentSettingAccess()->get(DocumentSettingId::SURROUND_TEXT_WRAP_SMALL )
                 ? TEXT_MIN_SMALL : TEXT_MIN;
+
+            // In case there is no space on either side, then SURROUND_PARALLEL
+            // gives the same result when doing the initial layout or a layout
+            // update after editing, so prefer that over SURROUND_NONE.
+            if (nLeft == 0 && nRight == 0)
+                return SURROUND_PARALLEL;
+
             if( nLeft < textMin )
                 nLeft = 0;
             if( nRight < textMin )


More information about the Libreoffice-commits mailing list