summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-03-25 21:36:02 +0100
committerAron Budea <aron.budea@collabora.com>2019-04-23 16:34:00 +0200
commit08985dcb5df638a67934f22aa628744fb3441aba (patch)
tree76d567596bdcb10abd85ed47290e3f55e49c4bf3 /sw
parentda21956366a13b62b056d6074262f44c1559b29d (diff)
tdf#123651 sw AddVerticalFrameOffsets: make vert offset depend on hori offset
Regression from commit 961ba62df045473e5793d9e103be86eaad8d9575 (tdf#123032 sw, AddVerticalFrameOffsets: fix shape pos after mouse move, 2019-02-07), the vertical position of the bugdoc was too large, and turns out Word only works with vertical offsets if there is already a horizontal offset. For example open tdf98987.docx in Word, remove the left square shape, notice how the other square shape jumps up due to no longer working with a vertical offset (while the doc model vertical position of the shape is unchanged). Change our layout, so that in case the AddVerticalFrameOffsets compatibility flag is on (which was added to emulate Word's behavior), we also consider the horizontal offset before setting the vertical offset. Also improve the SwUiWriterTest2::testTdf122942() test that asserted doc model positions, which are now different (needed so that at the end the layout position visible to the user is unchanged). (cherry picked from commit 27894be916d5d03ee820e757d2f4abbf21d54615) Conflicts: sw/qa/extras/layout/layout.cxx sw/qa/extras/uiwriter/uiwriter2.cxx Change-Id: I8ac451efbacefdd3578b3a578260e7b2060c16a6 Reviewed-on: https://gerrit.libreoffice.org/71128 Reviewed-by: Aron Budea <aron.budea@collabora.com> Tested-by: Aron Budea <aron.budea@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/layout/data/tdf123651.docxbin0 -> 34012 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx11
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx23
-rw-r--r--sw/source/core/text/txtfrm.cxx3
4 files changed, 22 insertions, 15 deletions
diff --git a/sw/qa/extras/layout/data/tdf123651.docx b/sw/qa/extras/layout/data/tdf123651.docx
new file mode 100644
index 000000000000..4cda0b4e7f36
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf123651.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 5dee5c580402..59f73e0b78bd 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -24,6 +24,7 @@ public:
void testTdf118058();
void testTdf117188();
void testTdf119875();
+ void testTdf123651();
CPPUNIT_TEST_SUITE(SwLayoutWriter);
CPPUNIT_TEST(testTdf116830);
@@ -33,6 +34,7 @@ public:
CPPUNIT_TEST(testTdf118058);
CPPUNIT_TEST(testTdf117188);
CPPUNIT_TEST(testTdf119875);
+ CPPUNIT_TEST(testTdf123651);
CPPUNIT_TEST_SUITE_END();
private:
@@ -171,6 +173,15 @@ void SwLayoutWriter::testTdf119875()
CPPUNIT_ASSERT_LESS(nSecondTop, nFirstTop);
}
+void SwLayoutWriter::testTdf123651()
+{
+ createDoc("tdf123651.docx");
+ xmlDocPtr pXmlDoc = parseLayoutDump();
+ // Without the accompanying fix in place, this test would have failed with 'Expected: 7639;
+ // Actual: 12926'. The shape was below the second "Lorem ipsum" text, not above it.
+ assertXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "top", "7639");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 6d3355af30bb..a5b74cc8265b 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -455,12 +455,6 @@ void SwUiWriterTest2::testTdf122942()
const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats();
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size());
- // Without the accompanying fix in place, this test would have failed with
- // 'Expected less than: 0; Actual : 1030', i.e. the shape was below the
- // paragraph mark, not above it.
- const SwFormatVertOrient& rVert = rFormats[1]->GetVertOrient();
- CPPUNIT_ASSERT_LESS(static_cast<SwTwips>(0), rVert.GetPos());
-
reload("writer8", "tdf122942.odt");
pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
@@ -468,14 +462,15 @@ void SwUiWriterTest2::testTdf122942()
const SwFrameFormats& rFormats2 = *pDoc->GetSpzFrameFormats();
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats2.size());
- SdrObject* pObject = rFormats2[1]->FindSdrObject();
- CPPUNIT_ASSERT(pObject);
-
- const tools::Rectangle& rOutRect = pObject->GetLastBoundRect();
- // Without the accompanying fix in place, this test would have failed with
- // 'Expected greater than: 5000; Actual : 2817', i.e. the shape moved up
- // after a reload(), while it's expected to not change its position (5773).
- CPPUNIT_ASSERT_GREATER(static_cast<SwTwips>(5000), rOutRect.Top());
+ // Make sure the top of the inserted shape does not move outside the existing shape, even after
+ // reload.
+ SdrObject* pObject1 = rFormats2[0]->FindSdrObject();
+ CPPUNIT_ASSERT(pObject1);
+ const tools::Rectangle& rOutRect1 = pObject1->GetLastBoundRect();
+ SdrObject* pObject2 = rFormats2[1]->FindSdrObject();
+ CPPUNIT_ASSERT(pObject2);
+ const tools::Rectangle& rOutRect2 = pObject2->GetLastBoundRect();
+ CPPUNIT_ASSERT(rOutRect2.Top() > rOutRect1.Top() && rOutRect2.Top() < rOutRect1.Bottom());
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 6cccb9653a3e..82a2e7b7aeb9 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2762,7 +2762,8 @@ void SwTextFrame::CalcBaseOfstForFly()
if (!pNode->getIDocumentSettingAccess()->get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS))
return;
- mnFlyAnchorVertOfstNoWrap = nFlyAnchorVertOfstNoWrap;
+ if (mnFlyAnchorOfstNoWrap > 0)
+ mnFlyAnchorVertOfstNoWrap = nFlyAnchorVertOfstNoWrap;
}
SwTwips SwTextFrame::GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const