summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-01-04 02:51:36 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-01-04 03:54:16 +0100
commit9c4a374baa4d18dec4066e547d76a40501b20d45 (patch)
tree72f02e794a8e89a70692caffecbd4a6bd5c23bf0
parentc4218b3655c200e4d4880405fc5898c625b4459e (diff)
Unfloat: Add some tests about the visibility of the unfloat button
Change-Id: Id0bc6e5be5a55480233afeae44eccac24fa01434 Reviewed-on: https://gerrit.libreoffice.org/65820 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r--sw/qa/extras/uiwriter/data/floating_table/small_floating_table.odtbin0 -> 8977 bytes
-rw-r--r--sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.docbin0 -> 69120 bytes
-rw-r--r--sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.docxbin0 -> 14282 bytes
-rw-r--r--sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.odtbin0 -> 9331 bytes
-rw-r--r--sw/qa/extras/uiwriter/data/floating_table/unfloatable_small_floating_table.docxbin0 -> 13381 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx116
-rw-r--r--sw/source/core/inc/flyfrm.hxx5
-rw-r--r--sw/source/core/inc/layfrm.hxx3
-rw-r--r--sw/source/core/inc/sortedobjs.hxx3
9 files changed, 122 insertions, 5 deletions
diff --git a/sw/qa/extras/uiwriter/data/floating_table/small_floating_table.odt b/sw/qa/extras/uiwriter/data/floating_table/small_floating_table.odt
new file mode 100644
index 000000000000..6b77569f2583
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/floating_table/small_floating_table.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.doc b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.doc
new file mode 100644
index 000000000000..e5247f1598c2
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.doc
Binary files differ
diff --git a/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.docx b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.docx
new file mode 100644
index 000000000000..cef1f7bf685d
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.odt b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.odt
new file mode 100644
index 000000000000..eb2534ba4c52
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/data/floating_table/unfloatable_small_floating_table.docx b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_small_floating_table.docx
new file mode 100644
index 000000000000..d51056af1177
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_small_floating_table.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 233b50ebe3dc..3f49e4c591f8 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -21,12 +21,20 @@
#include <swdtflvr.hxx>
#include <wrtsh.hxx>
#include <redline.hxx>
+#include <flyfrms.hxx>
#include <UndoManager.hxx>
+#include <edtwin.hxx>
+#include <view.hxx>
+#include <sortedobjs.hxx>
+#include <anchoredobject.hxx>
+#include <FrameControlsManager.hxx>
+#include <FloatingTableButton.hxx>
namespace
{
char const DATA_DIRECTORY[] = "/sw/qa/extras/uiwriter/data2/";
-}
+char const FLOATING_TABLE_DATA_DIRECTORY[] = "/sw/qa/extras/uiwriter/data/floating_table/";
+} // namespace
/// Second set of tests asserting the behavior of Writer user interface shells.
class SwUiWriterTest2 : public SwModelTestBase
@@ -43,6 +51,9 @@ public:
void testTdf119019();
void testTdf119824();
void testTdf105413();
+ void testUnfloatButtonSmallTable();
+ void testUnfloatButton();
+ void testUnfloatButtonReadOnlyMode();
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testRedlineMoveInsertInDelete);
@@ -56,6 +67,9 @@ public:
CPPUNIT_TEST(testTdf119019);
CPPUNIT_TEST(testTdf119824);
CPPUNIT_TEST(testTdf105413);
+ CPPUNIT_TEST(testUnfloatButtonSmallTable);
+ CPPUNIT_TEST(testUnfloatButton);
+ CPPUNIT_TEST(testUnfloatButtonReadOnlyMode);
CPPUNIT_TEST_SUITE_END();
private:
@@ -521,6 +535,106 @@ void SwUiWriterTest2::testTdf105413()
getProperty<OUString>(getParagraph(1), "ParaStyleName"));
}
+void SwUiWriterTest2::testUnfloatButtonSmallTable()
+{
+ // The floating table in the test document is too small, so we don't provide an unfloat button
+ load(FLOATING_TABLE_DATA_DIRECTORY, "small_floating_table.odt");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+
+ 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];
+
+ SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+ CPPUNIT_ASSERT(pFlyFrame);
+ CPPUNIT_ASSERT(!pFlyFrame->IsShowUnfloatButton(pWrtShell));
+
+ SdrObject* pObj = pFlyFrame->GetFormat()->FindRealSdrObject();
+ CPPUNIT_ASSERT(pObj);
+ pWrtShell->SelectObj(Point(), 0, pObj);
+ CPPUNIT_ASSERT(!pFlyFrame->IsShowUnfloatButton(pWrtShell));
+}
+
+void SwUiWriterTest2::testUnfloatButton()
+{
+ // Different use cases where unfloat button should be visible
+ const std::vector<OUString> aTestFiles = {
+ "unfloatable_floating_table.odt", // Typical use case of multipage floating table
+ "unfloatable_floating_table.docx", // Need to test the DOCX import whether we detect the floating table correctly
+ "unfloatable_floating_table.doc", // Also the DOC import
+ "unfloatable_small_floating_table.docx" // Atypical use case, when the table is small, but because of it's position is it broken to two pages
+ };
+
+ for (const OUString& aTestFile : aTestFiles)
+ {
+ OString sTestFileName = OUStringToOString(aTestFile, RTL_TEXTENCODING_UTF8);
+ OString sFailureMessage = OString("Failure in the test file: ") + sTestFileName;
+
+ load(FLOATING_TABLE_DATA_DIRECTORY, sTestFileName.getStr());
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pTextDoc);
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pWrtShell);
+
+ const SwSortedObjs* pAnchored;
+ if (sTestFileName == "unfloatable_small_floating_table.docx")
+ pAnchored = pWrtShell->GetLayout()
+ ->GetLower()
+ ->GetLower()
+ ->GetLower()
+ ->GetNext()
+ ->GetDrawObjs();
+ else
+ pAnchored = pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs();
+ CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pAnchored);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailureMessage.getStr(), static_cast<size_t>(1),
+ pAnchored->size());
+ SwAnchoredObject* pAnchoredObj = (*pAnchored)[0];
+
+ // The unfloat button is not visible until it gets selected
+ SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+ CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pFlyFrame);
+ CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(),
+ !pFlyFrame->IsShowUnfloatButton(pWrtShell));
+
+ SdrObject* pObj = pFlyFrame->GetFormat()->FindRealSdrObject();
+ CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pObj);
+ pWrtShell->SelectObj(Point(), 0, pObj);
+ CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pFlyFrame->IsShowUnfloatButton(pWrtShell));
+ }
+}
+
+void SwUiWriterTest2::testUnfloatButtonReadOnlyMode()
+{
+ // In read only mode we don't show the unfloat button even if we have a multipage floating table
+ 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);
+ pWrtShell->SetReadonlyOption(true);
+
+ 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];
+
+ SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+ CPPUNIT_ASSERT(pFlyFrame);
+ CPPUNIT_ASSERT(!pFlyFrame->IsShowUnfloatButton(pWrtShell));
+
+ SdrObject* pObj = pFlyFrame->GetFormat()->FindRealSdrObject();
+ CPPUNIT_ASSERT(pObj);
+ pWrtShell->SelectObj(Point(), 0, pObj);
+ CPPUNIT_ASSERT(!pFlyFrame->IsShowUnfloatButton(pWrtShell));
+}
+
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 6501ab592510..5ee5eb152b9b 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -24,6 +24,7 @@
#include <vector>
#include <frmfmt.hxx>
#include <anchoredobject.hxx>
+#include <swdllapi.h>
class SwFormatAnchor;
class SwPageFrame;
@@ -58,7 +59,7 @@ bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, bool bMove = true );
#i26791# - inherit also from <SwAnchoredFlyFrame>
*/
-class SwFlyFrame : public SwLayoutFrame, public SwAnchoredObject
+class SW_DLLPUBLIC SwFlyFrame : public SwLayoutFrame, public SwAnchoredObject
{
// is allowed to lock, implemented in frmtool.cxx
friend void AppendObj(SwFrame *const pFrame, SwPageFrame *const pPage, SwFrameFormat *const pFormat, const SwFormatAnchor & rAnch);
@@ -271,9 +272,9 @@ public:
void InvalidateContentPos();
void SelectionHasChanged(SwFEShell* pShell);
+ bool IsShowUnfloatButton(SwWrtShell* pWrtSh) const;
private:
- bool IsShowUnfloatButton(SwWrtShell* pWrtSh) const;
void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const;
void PaintDecorators() const;
};
diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index 92fc189fba8a..8fd0e5f626aa 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -20,6 +20,7 @@
#define INCLUDED_SW_SOURCE_CORE_INC_LAYFRM_HXX
#include "frame.hxx"
+#include <swdllapi.h>
class SwAnchoredObject;
class SwContentFrame;
@@ -31,7 +32,7 @@ class SwBorderAttrs;
class SwFormatFrameSize;
class SwCellFrame;
-class SwLayoutFrame: public SwFrame
+class SW_DLLPUBLIC SwLayoutFrame: public SwFrame
{
// The SwFrame in disguise
friend class SwFlowFrame;
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;