[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jan 8 08:07:45 UTC 2019
sw/qa/extras/uiwriter/uiwriter2.cxx | 52 ++++++++++++++++++++++++++++++++++--
sw/source/core/inc/flyfrm.hxx | 3 ++
sw/source/core/layout/fly.cxx | 11 +++++++
3 files changed, 64 insertions(+), 2 deletions(-)
New commits:
commit 419ce1399c496e062676b7a8e4f87277f552d3d5
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Jan 4 11:23:59 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jan 8 09:07:21 2019 +0100
Unfloat: Test layout change of unfloat operation
Change-Id: I75298a392de6a10861ac96e1bc58a30173cd2dd2
Reviewed-on: https://gerrit.libreoffice.org/65823
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit dd0b559d6aac5bf09566af735bd00b28c00fb2e4)
Reviewed-on: https://gerrit.libreoffice.org/65874
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 088d02ca4761..274bec37d0b1 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -18,8 +18,7 @@
#include <view.hxx>
#include <sortedobjs.hxx>
#include <anchoredobject.hxx>
-#include <FrameControlsManager.hxx>
-#include <FloatingTableButton.hxx>
+#include <swtypes.hxx>
namespace
{
@@ -35,12 +34,14 @@ public:
void testUnfloatButtonSmallTable();
void testUnfloatButton();
void testUnfloatButtonReadOnlyMode();
+ void testUnfloating();
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testTdf101534);
CPPUNIT_TEST(testUnfloatButtonSmallTable);
CPPUNIT_TEST(testUnfloatButton);
CPPUNIT_TEST(testUnfloatButtonReadOnlyMode);
+ CPPUNIT_TEST(testUnfloating);
CPPUNIT_TEST_SUITE_END();
};
@@ -171,6 +172,53 @@ void SwUiWriterTest2::testUnfloatButtonReadOnlyMode()
CPPUNIT_ASSERT(!pFlyFrame->IsShowUnfloatButton(pWrtShell));
}
+void SwUiWriterTest2::testUnfloating()
+{
+ // Test what happens when pushing the unfloat button
+ load(FLOATING_TABLE_DATA_DIRECTORY, "unfloatable_floating_table.odt");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+
+ SwFlyFrame* pFlyFrame;
+
+ // Before unfloating we have only one page with a fly frame
+ {
+ CPPUNIT_ASSERT_EQUAL(SwFrameType::Page, pWrtShell->GetLayout()->GetLower()->GetType());
+ CPPUNIT_ASSERT(!pWrtShell->GetLayout()->GetLower()->GetNext());
+ CPPUNIT_ASSERT_EQUAL(SwFrameType::Txt,
+ pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetType());
+ const SwSortedObjs* pAnchored
+ = pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs();
+ CPPUNIT_ASSERT(pAnchored);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pAnchored->size());
+ SwAnchoredObject* pAnchoredObj = (*pAnchored)[0];
+ pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+ CPPUNIT_ASSERT(pFlyFrame);
+ }
+
+ // Select the floating table
+ SdrObject* pObj = pFlyFrame->GetFormat()->FindRealSdrObject();
+ CPPUNIT_ASSERT(pObj);
+ pWrtShell->SelectObj(Point(), 0, pObj);
+ CPPUNIT_ASSERT(pFlyFrame->IsShowUnfloatButton(pWrtShell));
+
+ // Push the unfloat button
+ pFlyFrame->ActiveUnfloatButton(pWrtShell);
+
+ // After unfloating we have two pages with one tablre frame on each page
+ CPPUNIT_ASSERT(pWrtShell->GetLayout()->GetLower()->GetNext());
+ CPPUNIT_ASSERT_EQUAL(SwFrameType::Page,
+ pWrtShell->GetLayout()->GetLower()->GetNext()->GetType());
+ CPPUNIT_ASSERT(!pWrtShell->GetLayout()->GetLower()->GetNext()->GetNext());
+ CPPUNIT_ASSERT_EQUAL(SwFrameType::Tab,
+ pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetType());
+ CPPUNIT_ASSERT_EQUAL(
+ SwFrameType::Tab,
+ pWrtShell->GetLayout()->GetLower()->GetNext()->GetLower()->GetLower()->GetType());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index bc9cea59e963..65ba6d636676 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -273,6 +273,9 @@ public:
void SelectionHasChanged(SwFEShell* pShell);
bool IsShowUnfloatButton(SwWrtShell* pWrtSh) const;
+ // For testing only (see uiwriter)
+ void ActiveUnfloatButton(SwWrtShell* pWrtSh);
+
private:
void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const;
void PaintDecorators() const;
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 59c825239e60..e19893fb62ce 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -1840,6 +1840,17 @@ bool SwFlyFrame::IsShowUnfloatButton(SwWrtShell* pWrtSh) const
return nBodyHeight < nTableHeight + nFrameOffset;
}
+void SwFlyFrame::ActiveUnfloatButton(SwWrtShell* pWrtSh)
+{
+ SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
+ SwFrameControlsManager& rMngr = rEditWin.GetFrameControlsManager();
+ SwFrameControlPtr pControl = rMngr.GetControl(FloatingTable, this);
+ if (pControl.get() || pControl->GetWindow())
+ {
+ pControl->GetWindow()->MouseButtonDown(MouseEvent());
+ }
+}
+
void SwFlyFrame::UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const
{
if (pWrtSh == nullptr)
More information about the Libreoffice-commits
mailing list