sw/qa/extras/uiwriter/data/floating_table/small_floating_table.odt |binary sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.doc |binary sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.docx |binary sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.odt |binary sw/qa/extras/uiwriter/data/floating_table/unfloatable_small_floating_table.docx |binary sw/qa/extras/uiwriter/uiwriter2.cxx | 116 +++++++++- sw/source/core/inc/flyfrm.hxx | 5 sw/source/core/inc/layfrm.hxx | 3 sw/source/core/inc/sortedobjs.hxx | 3 9 files changed, 122 insertions(+), 5 deletions(-)
New commits: commit 9c4a374baa4d18dec4066e547d76a40501b20d45 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Fri Jan 4 02:51:36 2019 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Fri Jan 4 03:54:16 2019 +0100 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.zol...@collabora.com> 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 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/floating_table/small_floating_table.odt 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 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.doc 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 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.docx 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 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_floating_table.odt 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 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/floating_table/unfloatable_small_floating_table.docx 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits