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

Miklos Vajna vmiklos at collabora.co.uk
Fri Dec 5 04:34:11 PST 2014


 sw/qa/extras/inc/swmodeltestbase.hxx    |   14 ++++++++++----
 sw/qa/extras/uiwriter/data/fdo87005.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx      |   11 +++++++++++
 sw/source/core/text/itrform2.cxx        |    7 +++++++
 4 files changed, 28 insertions(+), 4 deletions(-)

New commits:
commit 25c50ff9fb0f277da9bc164d8244a774ef1ebba4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Dec 5 12:12:50 2014 +0100

    fdo#87005 SwTxtFormatter::NewPortion: fix lost SwFlyPortion
    
    In case there are two flys anchored to the paragraph and it's empty,
    then the situation is that SwTxtFormatter::BuildPortions() calls
    NewPortion() two times, second time the SwTxtFormatInfo has no fly set
    initially, only after NewPortion() calls CalcFlyWidth(). When that
    happens, we used to return pPor, even in case it was 0, and we the
    SwTxtFormatInfo had a fly portion.
    
    Fix the problem by checking if SwTxtFormatInfo has a fly portion after
    CalcFlyWidth(), and in case otherwise we would return 0, return the fly
    portion of SwTxtFormatInfo instead. As a result, the paragraph delimiter
    in the bugdoc will be positioned at the correct position, as the
    SwTxtFrm will properly have two layout portions, just like non-empty
    SwTxtFrms.
    
    Change-Id: I51e5ba61e79b4353c7b11c6d76b8c370ac3d4d37

diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 4f71ff6..cc18a77 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -392,6 +392,15 @@ protected:
         return xAutoStyleFamily;
     }
 
+    /// Similar to parseExport(), but this gives the xmlDocPtr of the layout dump.
+    xmlDocPtr parseLayoutDump()
+    {
+        if (!mpXmlBuffer)
+            dumpLayout();
+
+        return xmlParseMemory((const char*)xmlBufferContent(mpXmlBuffer), xmlBufferLength(mpXmlBuffer));;
+    }
+
     /**
      * Extract a value from the layout dump using an XPath expression and an attribute name.
      *
@@ -399,10 +408,7 @@ protected:
      */
     OUString parseDump(const OString& aXPath, const OString& aAttribute = OString())
     {
-        if (!mpXmlBuffer)
-            dumpLayout();
-
-        xmlDocPtr pXmlDoc = xmlParseMemory((const char*)xmlBufferContent(mpXmlBuffer), xmlBufferLength(mpXmlBuffer));;
+        xmlDocPtr pXmlDoc = parseLayoutDump();
 
         xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc);
         xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(aXPath.getStr()), pXmlXpathCtx);
diff --git a/sw/qa/extras/uiwriter/data/fdo87005.odt b/sw/qa/extras/uiwriter/data/fdo87005.odt
new file mode 100644
index 0000000..54d7119
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/fdo87005.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 6fe83c2..7352983 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -61,6 +61,7 @@ public:
     void testChineseConversionSimplifiedToTraditional();
     void testFdo85554();
     void testAutoCorr();
+    void testFdo87005();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -85,6 +86,7 @@ public:
     CPPUNIT_TEST(testChineseConversionSimplifiedToTraditional);
     CPPUNIT_TEST(testFdo85554);
     CPPUNIT_TEST(testAutoCorr);
+    CPPUNIT_TEST(testFdo87005);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -620,6 +622,15 @@ void SwUiWriterTest::testAutoCorr()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getColumns()->getCount());
 }
 
+void SwUiWriterTest::testFdo87005()
+{
+    createDoc("fdo87005.odt");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    CPPUNIT_ASSERT(pXmlDoc);
+    // This was 1, no SwFlyPortion was created for the second fly.
+    assertXPath(pXmlDoc, "//Special[@nType='POR_FLY']", 2);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 37ae1bab..fca53ab 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -1301,6 +1301,13 @@ SwLinePortion *SwTxtFormatter::NewPortion( SwTxtFormatInfo &rInf )
             {
                 rInf.SetFull(true);
                 CalcFlyWidth( rInf );
+
+                // In case we have no portion to return, but CalcFlyWidth()
+                // created a fly portion, then return that. Otherwise such a
+                // fly portion would not be ever inserted to the layout.
+                if (!pPor)
+                    pPor = rInf.GetFly();
+
                 return pPor;
             }
             cChar = rInf.GetChar( rInf.GetIdx() );


More information about the Libreoffice-commits mailing list