summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2020-06-22 14:55:06 +0200
committerMarco Cecchetti <marco.cecchetti@collabora.com>2020-06-25 15:29:59 +0200
commit464dcf45a085bffbe9b8368162f94606558605cb (patch)
tree3f6350db6400f28485513a60e7df4ffab07b4833 /sc
parent472ab1cad9d7565572877f30709029606c86dc54 (diff)
lok: calc: messed up view when deleting from multiline content
To see the problem was enough to click on the cell with the multiline content (because of wrap text enabled), and press delete. Change-Id: I8288e7739c8513f5fa0bdee5f7eb414b4abac456 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96905 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97114 Reviewed-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/tiledrendering/data/multiline.odsbin0 -> 10413 bytes
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx41
-rw-r--r--sc/source/ui/docshell/docfunc.cxx18
3 files changed, 59 insertions, 0 deletions
diff --git a/sc/qa/unit/tiledrendering/data/multiline.ods b/sc/qa/unit/tiledrendering/data/multiline.ods
new file mode 100644
index 000000000000..847835690a5f
--- /dev/null
+++ b/sc/qa/unit/tiledrendering/data/multiline.ods
Binary files differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index a8acc44c6627..fda5ced604d3 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -108,6 +108,7 @@ public:
void testJumpToLastRowInvalidation();
void testSheetGeometryDataInvariance();
void testSheetGeometryDataCorrectness();
+ void testDeleteCellMultilineContent();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnHeaders);
@@ -151,6 +152,7 @@ public:
CPPUNIT_TEST(testJumpToLastRowInvalidation);
CPPUNIT_TEST(testSheetGeometryDataInvariance);
CPPUNIT_TEST(testSheetGeometryDataCorrectness);
+ CPPUNIT_TEST(testDeleteCellMultilineContent);
CPPUNIT_TEST_SUITE_END();
private:
@@ -463,6 +465,7 @@ public:
bool m_bViewLock;
OString m_sCellFormula;
boost::property_tree::ptree m_aCommentCallbackResult;
+ OString m_sInvalidateHeader;
ViewCallback(bool bDeleteListenerOnDestruct=true)
: m_bOwnCursorInvalidated(false),
@@ -568,6 +571,10 @@ public:
m_aCommentCallbackResult = m_aCommentCallbackResult.get_child("comment");
}
break;
+ case LOK_CALLBACK_INVALIDATE_HEADER:
+ {
+ m_sInvalidateHeader = pPayload;
+ }
}
}
};
@@ -2240,6 +2247,40 @@ void ScTiledRenderingTest::testSheetGeometryDataCorrectness()
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
}
+void ScTiledRenderingTest::testDeleteCellMultilineContent()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ ScModelObj* pModelObj = createDoc("multiline.ods");
+ CPPUNIT_ASSERT(pModelObj);
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ CPPUNIT_ASSERT(pViewData);
+ ScDocShell* pDocSh = dynamic_cast< ScDocShell* >( pModelObj->GetEmbeddedObject() );
+ CPPUNIT_ASSERT(pDocSh);
+
+ // view #1
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
+
+ aView1.m_sInvalidateHeader = "";
+ ScDocument& rDoc = pDocSh->GetDocument();
+ sal_uInt16 nRow1Height = rDoc.GetRowHeight(static_cast<SCROW>(0), static_cast<SCTAB>(0), false);
+
+ // delete multiline cell content in view #1
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DELETE);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DELETE);
+ Scheduler::ProcessEventsToIdle();
+
+ // check if the row header has been invalidated and if the involved row is of the expected height
+ CPPUNIT_ASSERT_EQUAL(aView1.m_sInvalidateHeader, OString("row"));
+ sal_uInt16 nRow2Height = rDoc.GetRowHeight(static_cast<SCROW>(0), static_cast<SCTAB>(0), false);
+ CPPUNIT_ASSERT_EQUAL(nRow1Height, nRow2Height);
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+}
+
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 2922d3ccc3b4..a7d72d12ea34 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -136,6 +136,7 @@ static void lcl_PaintAbove( ScDocShell& rDocShell, const ScRange& rRange )
bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint )
{
ScDocument& rDoc = rDocShell.GetDocument();
+ SfxViewShell* pSomeViewForThisDoc = rDocShell.GetBestViewShell(false);
if ( rDoc.IsImportingXML() )
{
// for XML import, all row heights are updated together after importing
@@ -150,6 +151,20 @@ bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint )
SCROW nStartRow = rRange.aStart.Row();
SCROW nEndRow = rRange.aEnd.Row();
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ while (pViewShell)
+ {
+ ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
+ if (pTabViewShell && pTabViewShell->GetDocId() == pSomeViewForThisDoc->GetDocId())
+ {
+ pTabViewShell->GetViewData().GetLOKHeightHelper(nTab)->invalidateByIndex(nStartRow);
+ }
+ pViewShell = SfxViewShell::GetNext(*pViewShell);
+ }
+ }
+
ScSizeDeviceProvider aProv( &rDocShell );
Fraction aOne(1,1);
@@ -163,6 +178,9 @@ bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint )
rDocShell.PostPaint(ScRange(0, nStartRow, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab),
PaintPartFlags::Grid | PaintPartFlags::Left);
+ if (comphelper::LibreOfficeKit::isActive())
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(pSomeViewForThisDoc, ROW_HEADER, nTab);
+
return bChanged;
}