[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sc/qa sc/source

Marco Cecchetti (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 25 13:30:32 UTC 2020


 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 464dcf45a085bffbe9b8368162f94606558605cb
Author:     Marco Cecchetti <marco.cecchetti at collabora.com>
AuthorDate: Mon Jun 22 14:55:06 2020 +0200
Commit:     Marco Cecchetti <marco.cecchetti at collabora.com>
CommitDate: Thu Jun 25 15:29:59 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 <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97114
    Reviewed-by: Marco Cecchetti <marco.cecchetti at collabora.com>

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 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;
 }
 


More information about the Libreoffice-commits mailing list