sc/qa/unit/tiledrendering/data/multiline.ods |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   41 +++++++++++++++++++++++++++
 sc/source/ui/docshell/docfunc.cxx            |   18 +++++++++++
 3 files changed, 59 insertions(+)

New commits:
commit 9dc53a0c6d8ea11b488bdea68573c9aaf12fb939
Author:     Marco Cecchetti <[email protected]>
AuthorDate: Mon Jun 22 14:55:06 2020 +0200
Commit:     Dennis Francis <[email protected]>
CommitDate: Thu Jul 16 22:49:46 2020 +0200

    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 <[email protected]>
    Reviewed-by: Andras Timar <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97114
    Reviewed-by: Marco Cecchetti <[email protected]>
    (cherry picked from commit 464dcf45a085bffbe9b8368162f94606558605cb)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98889
    Tested-by: Jenkins
    Reviewed-by: Dennis Francis <[email protected]>

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
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/multiline.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 1956f1851422..965dac89f5c9 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -109,6 +109,7 @@ public:
     void testJumpToLastRowInvalidation();
     void testSheetGeometryDataInvariance();
     void testSheetGeometryDataCorrectness();
+    void testDeleteCellMultilineContent();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnHeaders);
@@ -152,6 +153,7 @@ public:
     CPPUNIT_TEST(testJumpToLastRowInvalidation);
     CPPUNIT_TEST(testSheetGeometryDataInvariance);
     CPPUNIT_TEST(testSheetGeometryDataCorrectness);
+    CPPUNIT_TEST(testDeleteCellMultilineContent);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -464,6 +466,7 @@ public:
     bool m_bViewLock;
     OString m_sCellFormula;
     boost::property_tree::ptree m_aCommentCallbackResult;
+    OString m_sInvalidateHeader;
 
     ViewCallback(bool bDeleteListenerOnDestruct=true)
         : m_bOwnCursorInvalidated(false),
@@ -569,6 +572,10 @@ public:
             m_aCommentCallbackResult = 
m_aCommentCallbackResult.get_child("comment");
         }
         break;
+        case LOK_CALLBACK_INVALIDATE_HEADER:
+        {
+            m_sInvalidateHeader = pPayload;
+        }
         }
     }
 };
@@ -2241,6 +2248,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(OString("row"), aView1.m_sInvalidateHeader);
+    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 764c07b2f369..eae54450e608 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;
 }
 
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to