[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-1' - sw/CppunitTest_sw_layoutwriter.mk sw/inc sw/qa sw/source
Jan-Marek Glogowski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Feb 4 21:19:10 UTC 2020
sw/CppunitTest_sw_layoutwriter.mk | 1
sw/inc/swrect.hxx | 3
sw/qa/extras/layout/data/stable-at-page-anchored-fly-position.odt |binary
sw/qa/extras/layout/layout.cxx | 49 ++++++++++
sw/source/core/inc/sortedobjs.hxx | 3
5 files changed, 54 insertions(+), 2 deletions(-)
New commits:
commit 82480ecbe0dc3c99777dcc4e32b63a968a6c2ae7
Author: Jan-Marek Glogowski <jan-marek.glogowski at extern.cib.de>
AuthorDate: Fri Jan 31 16:53:47 2020 +0000
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Feb 4 22:18:41 2020 +0100
Unit test for stable at-page anchored fly position
This is the unit test for commit
5cee586a97a11c23dd252accc42099bd5e9b4187 ("sw: fix moving of
at-page anchored flys to different page"). Originally the error
was just triggered by toggling "View -> Field Names". Luckily
it's also triggered by adding some text to page four, so no need
for some UI test.
Change-Id: I3a63b50dd898788607c3d24a848d8f43ae966377
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87776
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
(cherry picked from commit 5fed8bb5f6f65963fed27f96de3be14dff830d38)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87847
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
(cherry picked from commit 4db184ea279a2974679b05eaa8ca52ec087f68af)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87983
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/CppunitTest_sw_layoutwriter.mk b/sw/CppunitTest_sw_layoutwriter.mk
index 675299180e44..6ec6195eea72 100644
--- a/sw/CppunitTest_sw_layoutwriter.mk
+++ b/sw/CppunitTest_sw_layoutwriter.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_layoutwriter,\
$(eval $(call gb_CppunitTest_set_include,sw_layoutwriter,\
-I$(SRCDIR)/sw/inc \
-I$(SRCDIR)/sw/source/core/inc \
+ -I$(SRCDIR)/sw/source/uibase/inc \
-I$(SRCDIR)/sw/qa/extras/inc \
$$(INCLUDE) \
))
diff --git a/sw/inc/swrect.hxx b/sw/inc/swrect.hxx
index c4b1889ae4ae..a2beda693112 100644
--- a/sw/inc/swrect.hxx
+++ b/sw/inc/swrect.hxx
@@ -23,6 +23,7 @@
#include <sal/log.hxx>
#include <tools/gen.hxx>
+#include <swdllapi.h>
class SvStream;
@@ -30,7 +31,7 @@ class SvStream;
/// This is half-open so m_Point.X() + m_Size.getWidth() is *not* included.
/// Note the tools Rectangle is (usually? sometimes?) closed so there's a
/// SVRect() to subtract 1 for the conversion.
-class SAL_WARN_UNUSED SwRect
+class SW_DLLPUBLIC SAL_WARN_UNUSED SwRect
{
Point m_Point;
Size m_Size;
diff --git a/sw/qa/extras/layout/data/stable-at-page-anchored-fly-position.odt b/sw/qa/extras/layout/data/stable-at-page-anchored-fly-position.odt
new file mode 100644
index 000000000000..e5a3779c54c5
Binary files /dev/null and b/sw/qa/extras/layout/data/stable-at-page-anchored-fly-position.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 7d6eeccd18b8..bdbcc12c9487 100755
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -10,6 +10,10 @@
#include <swmodeltestbase.hxx>
#include <comphelper/propertysequence.hxx>
#include <test/mtfxmldump.hxx>
+#include <wrtsh.hxx>
+#include <pagefrm.hxx>
+#include <sortedobjs.hxx>
+#include <anchoredobject.hxx>
static char const DATA_DIRECTORY[] = "/sw/qa/extras/layout/data/";
@@ -32,6 +36,7 @@ public:
void testTdf117188();
void testTdf119875();
void testTdf116989();
+ void testStableAtPageAnchoredFlyPosition();
CPPUNIT_TEST_SUITE(SwLayoutWriter);
CPPUNIT_TEST(testTdf116830);
@@ -49,6 +54,7 @@ public:
CPPUNIT_TEST(testTdf117188);
CPPUNIT_TEST(testTdf119875);
CPPUNIT_TEST(testTdf116989);
+ CPPUNIT_TEST(testStableAtPageAnchoredFlyPosition);
CPPUNIT_TEST_SUITE_END();
private:
@@ -304,6 +310,49 @@ void SwLayoutWriter::testTdf116989()
}
}
+static SwRect lcl_getVisibleFlyObjRect(SwWrtShell* pWrtShell)
+{
+ SwRootFrame* pRoot = pWrtShell->GetLayout();
+ SwPageFrame* pPage = static_cast<SwPageFrame*>(pRoot->GetLower());
+ pPage = static_cast<SwPageFrame*>(pPage->GetNext());
+ pPage = static_cast<SwPageFrame*>(pPage->GetNext());
+ SwSortedObjs* pDrawObjs = pPage->GetDrawObjs();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDrawObjs->size());
+ SwAnchoredObject* pDrawObj = (*pDrawObjs)[0];
+ CPPUNIT_ASSERT_EQUAL(OUString("Rahmen8"), pDrawObj->GetFrameFormat().GetName());
+ pPage = static_cast<SwPageFrame*>(pPage->GetNext());
+ pDrawObjs = pPage->GetDrawObjs();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDrawObjs->size());
+ pDrawObj = (*pDrawObjs)[0];
+ CPPUNIT_ASSERT_EQUAL(OUString("Rahmen123"), pDrawObj->GetFrameFormat().GetName());
+ SwRect aFlyRect = pDrawObj->GetObjRect();
+ CPPUNIT_ASSERT(pPage->getFrameArea().IsInside(aFlyRect));
+ return aFlyRect;
+}
+
+void SwLayoutWriter::testStableAtPageAnchoredFlyPosition()
+{
+ // this doc has two page-anchored frames: one tiny on page 3 and one large on page 4.
+ // it also has a style:master-page named "StandardEntwurf", which contains some fields.
+ // if you add a break to page 2, or append some text to page 4 (or just toggle display field names),
+ // the page anchored frame on page 4 vanishes, as it is incorrectly moved out of the page bounds.
+ SwDoc* pDoc = createDoc("stable-at-page-anchored-fly-position.odt");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+ // look up the layout position of the page-bound frame on page four
+ SwRect aOrigRect = lcl_getVisibleFlyObjRect(pWrtShell);
+
+ // append some text to the document to trigger bug / relayout
+ pWrtShell->SttEndDoc(false);
+ pWrtShell->Insert("foo");
+
+ // get the current position of the frame on page four
+ SwRect aRelayoutRect = lcl_getVisibleFlyObjRect(pWrtShell);
+
+ // the anchored frame should not have moved
+ CPPUNIT_ASSERT_EQUAL(aOrigRect, aRelayoutRect);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/inc/sortedobjs.hxx b/sw/source/core/inc/sortedobjs.hxx
index 0fd6a9cb9d71..5e5dcc45712f 100644
--- a/sw/source/core/inc/sortedobjs.hxx
+++ b/sw/source/core/inc/sortedobjs.hxx
@@ -21,6 +21,7 @@
#include <sal/types.h>
#include <vector>
+#include <swdllapi.h>
class SwAnchoredObject;
@@ -45,7 +46,7 @@ class SwAnchoredObject;
If one of the sort criteria attributes of an anchored object changes,
the sorting has to be updated - use method <Update(..)>
*/
-class SwSortedObjs
+class SW_DLLPUBLIC SwSortedObjs
{
private:
std::vector< SwAnchoredObject* > maSortedObjLst;
More information about the Libreoffice-commits
mailing list