diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2021-01-19 19:39:39 +0530 |
---|---|---|
committer | Dennis Francis <dennis.francis@collabora.com> | 2021-01-21 14:28:05 +0100 |
commit | c0b283b50f3cb166f85fe77629fff3375b8a3545 (patch) | |
tree | be42993a1e0d2cfddb34ba805abcf2ab663f74f1 /sc/qa/unit/tiledrendering | |
parent | ab59506f44db55f8c888dbc1bb947b624fefa311 (diff) |
unit test for row-height invalidations on pasting
... into a cell whose line-break attribute is set.
Change-Id: I82d021a262d6af48d5eaef5fefa0fe9098758a86
(cherry picked from commit dc2b3f50baa0e96e1073707574cce401e76ccf28)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109692
Tested-by: Jenkins
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'sc/qa/unit/tiledrendering')
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index d849e3291820..bc91dd9608fa 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -40,6 +40,8 @@ #include <chrono> #include <cstddef> +#include <attrib.hxx> +#include <scitems.hxx> #include <tabvwsh.hxx> #include <docsh.hxx> #include <document.hxx> @@ -109,6 +111,7 @@ public: void testDeleteCellMultilineContent(); void testSpellOnlineParameter(); void testSpellOnlineRenderParameter(); + void testPasteIntoWrapTextCell(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnHeaders); @@ -155,6 +158,7 @@ public: CPPUNIT_TEST(testDeleteCellMultilineContent); CPPUNIT_TEST(testSpellOnlineParameter); CPPUNIT_TEST(testSpellOnlineRenderParameter); + CPPUNIT_TEST(testPasteIntoWrapTextCell); CPPUNIT_TEST_SUITE_END(); private: @@ -468,6 +472,7 @@ public: OString m_sCellFormula; boost::property_tree::ptree m_aCommentCallbackResult; OString m_sInvalidateHeader; + OString m_sInvalidateSheetGeometry; ViewCallback(bool bDeleteListenerOnDestruct=true) : m_bOwnCursorInvalidated(false), @@ -577,6 +582,11 @@ public: { m_sInvalidateHeader = pPayload; } + break; + case LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY: + { + m_sInvalidateSheetGeometry = pPayload; + } } } }; @@ -2320,6 +2330,54 @@ void ScTiledRenderingTest::testDeleteCellMultilineContent() SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } +void ScTiledRenderingTest::testPasteIntoWrapTextCell() +{ + comphelper::LibreOfficeKit::setActive(); + comphelper::LibreOfficeKit::setCompatFlag( + comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs); + + ScModelObj* pModelObj = createDoc("empty.ods"); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + + // Set Wrap text in A3 + pDoc->ApplyAttr(0, 2, 0, ScLineBreakCell(true)); + const ScLineBreakCell* pItem = pDoc->GetAttr(0, 2, 0, ATTR_LINEBREAK); + CPPUNIT_ASSERT(pItem->GetValue()); + + ScViewData* pViewData = ScDocShell::GetViewData(); + CPPUNIT_ASSERT(pViewData); + + ViewCallback aView; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView); + CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData)); + + ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); + CPPUNIT_ASSERT(pView); + + // Go to A2 and paste. + pView->SetCursor(0, 1); + Scheduler::ProcessEventsToIdle(); + aView.m_sInvalidateSheetGeometry = ""; + pView->GetViewFrame()->GetBindings().Execute(SID_PASTE); + Scheduler::ProcessEventsToIdle(); + + // No SG invalidations + CPPUNIT_ASSERT_EQUAL(OString(""), aView.m_sInvalidateSheetGeometry); + + // Go to A3 and paste. + pView->SetCursor(0, 2); + Scheduler::ProcessEventsToIdle(); + aView.m_sInvalidateSheetGeometry = ""; + pView->GetViewFrame()->GetBindings().Execute(SID_PASTE); + Scheduler::ProcessEventsToIdle(); + + // SG invalidations for rows + CPPUNIT_ASSERT_EQUAL(OString("rows"), aView.m_sInvalidateSheetGeometry); + + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); +} + } CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); |