sc/qa/unit/data/ods/tdf150815.ods       |binary
 sc/qa/unit/subsequent_filters_test3.cxx |   22 +++++++++++++++++++++-
 sc/source/ui/inc/viewfunc.hxx           |    4 ++--
 sc/source/ui/view/viewfunc.cxx          |   22 ++++++++++++++++++++++
 4 files changed, 45 insertions(+), 3 deletions(-)

New commits:
commit d1411afab98f7b41e9e700ef26b43dc77242d917
Author:     Tibor Nagy <nagy.tib...@nisz.hu>
AuthorDate: Wed Aug 30 16:22:02 2023 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Thu Aug 31 18:01:33 2023 +0200

    tdf#150815 sc: fix repainting sparkline
    
    On Windows, if the input range of the sparkline is not in the
    same row as the output range, the sparkline wasn't repainted
    after changing the data within its range. Force the update
    to avoid of showing obsolete data.
    
    Change-Id: Id56209b20387ee68144507a0102d3a0d093ff1ea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156304
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: László Németh <nem...@numbertext.org>

diff --git a/sc/qa/unit/data/ods/tdf150815.ods 
b/sc/qa/unit/data/ods/tdf150815.ods
new file mode 100644
index 000000000000..2dd407b6cea5
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf150815.ods differ
diff --git a/sc/qa/unit/subsequent_filters_test3.cxx 
b/sc/qa/unit/subsequent_filters_test3.cxx
index d277e0858905..ff19d3d55c3c 100644
--- a/sc/qa/unit/subsequent_filters_test3.cxx
+++ b/sc/qa/unit/subsequent_filters_test3.cxx
@@ -393,7 +393,8 @@ struct PaintListener : public SfxListener
         {
             if ((pPaintHint->GetStartCol() <= 0 && pPaintHint->GetEndCol() >= 
0)
                 && ((pPaintHint->GetStartRow() <= 9 && pPaintHint->GetEndRow() 
>= 9)
-                    || (pPaintHint->GetStartRow() == 2 && 
pPaintHint->GetEndRow() == 3)))
+                    || (pPaintHint->GetStartRow() == 2 && 
pPaintHint->GetEndRow() == 3)
+                    || (pPaintHint->GetStartRow() == 1 && 
pPaintHint->GetEndRow() == 1)))
             {
                 mbCalled = true;
             }
@@ -441,6 +442,25 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf131471)
     CPPUNIT_ASSERT(aListener.mbCalled);
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf150815_RepaintSparkline)
+{
+    createScDoc("ods/tdf150815.ods");
+
+    ScDocument* pDoc = getScDoc();
+    ScDocShell* pDocSh = getScDocShell();
+
+    PaintListener aListener;
+    aListener.StartListening(*pDocSh);
+
+    auto pSparkline = pDoc->GetSparkline(ScAddress(0, 1, 0));
+    CPPUNIT_ASSERT(pSparkline);
+
+    ScTabViewShell* pViewShell = getViewShell();
+    pViewShell->EnterData(0, 0, 0, "10");
+
+    CPPUNIT_ASSERT(aListener.mbCalled);
+}
+
 CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf137091)
 {
     // Set the system locale to Turkish
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 0d8d7515441a..323e7cbbe793 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -90,8 +90,8 @@ public:
     bool            AutoSum( const ScRange& rRange, bool bSubTotal, bool 
bSetCursor, bool bContinue, const OpCode eCode );
     OUString        GetAutoSumFormula( const ScRangeList& rRangeList, bool 
bSubTotal, const ScAddress& rAddr, const OpCode eCode );
 
-    void            EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const 
OUString& rString,
-                               const EditTextObject* pData = nullptr, bool 
bMatrixExpand = false );
+    SC_DLLPUBLIC void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const 
OUString& rString,
+                                const EditTextObject* pData = nullptr, bool 
bMatrixExpand = false);
     void            EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
                                const EditTextObject& rData, bool bTestSimple = 
false );
     void            EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const 
double& rValue );
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 13c4ce63c6e7..af0dc57357f9 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -77,6 +77,7 @@
 #include <conditio.hxx>
 #include <columnspanset.hxx>
 #include <stringutil.hxx>
+#include <SparklineList.hxx>
 
 #include <memory>
 
@@ -103,6 +104,26 @@ static void lcl_PostRepaintCondFormat( const 
ScConditionalFormat *pCondFmt, ScDo
     }
 }
 
+static void lcl_PostRepaintSparkLine(sc::SparklineList* pSparklineList, const 
ScRange& rRange,
+                                     ScDocShell* pDocSh)
+{
+    if (pSparklineList)
+    {
+        for (auto& rSparkLineGroup : pSparklineList->getSparklineGroups())
+        {
+            for (auto& rSparkline : 
pSparklineList->getSparklinesFor(rSparkLineGroup))
+            {
+                if (rSparkline->getInputRange().Contains(rRange))
+                {
+                    pDocSh->PostPaint(
+                        ScRange(rSparkline->getColumn(), rSparkline->getRow(), 
rRange.aStart.Tab()),
+                        PaintPartFlags::All, SC_PF_TESTMERGE);
+                }
+            }
+        }
+    }
+}
+
 ScViewFunc::ScViewFunc( vcl::Window* pParent, ScDocShell& rDocSh, 
ScTabViewShell* pViewShell ) :
     ScTabView( pParent, rDocSh, pViewShell ),
     bFormatValid( false )
@@ -662,6 +683,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB 
nTab,
 
     aModificator.SetDocumentModified();
     lcl_PostRepaintCondFormat( rDoc.GetCondFormat( nCol, nRow, nTab ), pDocSh 
);
+    lcl_PostRepaintSparkLine(rDoc.GetSparklineList(nTab), ScRange(nCol, nRow, 
nTab), pDocSh);
 }
 
 // enter value in single cell (on nTab only)

Reply via email to