summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-12-05 12:12:50 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-12-05 13:33:06 +0100
commit25c50ff9fb0f277da9bc164d8244a774ef1ebba4 (patch)
tree233dd9bab83c7e53ae3dcf555bb85b5d6d3045b7
parent2f90974fd06870457301ec0be0ab8c43981689ec (diff)
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
-rw-r--r--sw/qa/extras/inc/swmodeltestbase.hxx14
-rw-r--r--sw/qa/extras/uiwriter/data/fdo87005.odtbin0 -> 9578 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx11
-rw-r--r--sw/source/core/text/itrform2.cxx7
4 files changed, 28 insertions, 4 deletions
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 4f71ff6b8e1e..cc18a772972e 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 000000000000..54d7119abac7
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/fdo87005.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 6fe83c2fad8c..73529832bd37 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 37ae1bab91a1..fca53aba57f0 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() );