summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/ww8export/data/inlinePageBreakFirstLine.docbin0 -> 26624 bytes
-rw-r--r--sw/qa/extras/ww8export/data/nonInlinePageBreakFirstLine.docbin0 -> 26624 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export4.cxx61
-rw-r--r--sw/source/filter/ww8/ww8par.cxx5
4 files changed, 65 insertions, 1 deletions
diff --git a/sw/qa/extras/ww8export/data/inlinePageBreakFirstLine.doc b/sw/qa/extras/ww8export/data/inlinePageBreakFirstLine.doc
new file mode 100644
index 000000000000..4f339511d664
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/inlinePageBreakFirstLine.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/data/nonInlinePageBreakFirstLine.doc b/sw/qa/extras/ww8export/data/nonInlinePageBreakFirstLine.doc
new file mode 100644
index 000000000000..5351a9edecc7
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/nonInlinePageBreakFirstLine.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx
index 7e3042aefab2..459daa69ec81 100644
--- a/sw/qa/extras/ww8export/ww8export4.cxx
+++ b/sw/qa/extras/ww8export/ww8export4.cxx
@@ -25,6 +25,8 @@
#include <IDocumentMarkAccess.hxx>
#include <IDocumentSettingAccess.hxx>
#include <unotxdoc.hxx>
+#include <ndtxt.hxx>
+#include <editeng/lrspitem.hxx>
class Test : public SwModelTestBase
{
@@ -142,6 +144,65 @@ CPPUNIT_TEST_FIXTURE(Test, testDontBreakWrappedTables)
CPPUNIT_ASSERT(bDontBreakWrappedTables);
}
+static bool IsFirstLine(const SwTextNode* pTextNode)
+{
+ const SfxPoolItem* pItem = pTextNode->GetNoCondAttr(RES_MARGIN_FIRSTLINE, false);
+ return !!pItem;
+}
+
+DECLARE_WW8EXPORT_TEST(testInlinePageBreakFirstLine, "inlinePageBreakFirstLine.doc")
+{
+ SwDoc* pDoc = getSwDoc();
+ const SwNodes& rNodes = pDoc->GetNodes();
+
+ std::vector<SwTextNode*> aTextNodes;
+
+ for (SwNodeOffset nNode(0); nNode < rNodes.Count(); ++nNode)
+ {
+ SwNode* pNode = pDoc->GetNodes()[nNode];
+ SwTextNode* pTextNode = pNode->GetTextNode();
+ if (!pTextNode)
+ continue;
+ aTextNodes.push_back(pTextNode);
+ }
+
+ CPPUNIT_ASSERT_EQUAL(size_t(3), aTextNodes.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("First line"), aTextNodes[0]->GetText());
+ CPPUNIT_ASSERT(IsFirstLine(aTextNodes[0]));
+ // Here exists an inline pagebreak (a pagebreak without a paragraph before it)
+ // This text node is not indented because it is not the first line of the paragraph
+ CPPUNIT_ASSERT_EQUAL(OUString("Should not be indented"), aTextNodes[1]->GetText());
+ CPPUNIT_ASSERT(!IsFirstLine(aTextNodes[1]));
+ // Here is the actual second paragraph
+ CPPUNIT_ASSERT_EQUAL(OUString("Should be indented"), aTextNodes[2]->GetText());
+ CPPUNIT_ASSERT(IsFirstLine(aTextNodes[2]));
+}
+
+DECLARE_WW8EXPORT_TEST(testNonInlinePageBreakFirstLine, "nonInlinePageBreakFirstLine.doc")
+{
+ SwDoc* pDoc = getSwDoc();
+ const SwNodes& rNodes = pDoc->GetNodes();
+
+ std::vector<SwTextNode*> aTextNodes;
+
+ for (SwNodeOffset nNode(0); nNode < rNodes.Count(); ++nNode)
+ {
+ SwNode* pNode = pDoc->GetNodes()[nNode];
+ SwTextNode* pTextNode = pNode->GetTextNode();
+ if (!pTextNode)
+ continue;
+ aTextNodes.push_back(pTextNode);
+ }
+
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aTextNodes.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("First line"), aTextNodes[0]->GetText());
+ CPPUNIT_ASSERT(IsFirstLine(aTextNodes[0]));
+ // Here exists a pagebreak after a paragraph
+ // This text node is indented because it is the first line of a paragraph
+ CPPUNIT_ASSERT_EQUAL(OUString("Should be indented"), aTextNodes[1]->GetText());
+ CPPUNIT_ASSERT(IsFirstLine(aTextNodes[1]));
+}
+
DECLARE_WW8EXPORT_TEST(testTdf104704_mangledFooter, "tdf104704_mangledFooter.odt")
{
CPPUNIT_ASSERT_EQUAL(2, getPages());
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 04c00b90b78e..e2d6b35e7345 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1418,7 +1418,10 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
if (firstLineNew != firstLineOld)
{
- pNd->SetAttr(firstLineNew);
+ if (nStart == aRegion.Start()->GetNodeIndex())
+ {
+ pNd->SetAttr(firstLineNew);
+ }
}
if (leftMarginNew != leftMarginOld)
{