sc/qa/uitest/validity/tdf138134.py |   63 +++++++++++++++++++++++++++++++++++++
 sc/source/ui/view/output.cxx       |   11 ++++++
 2 files changed, 74 insertions(+)

New commits:
commit 0478bdb68e8945cc76dc04c6f7040526656329a8
Author:     Tibor Nagy <nagy.tib...@nisz.hu>
AuthorDate: Tue Nov 24 13:46:45 2020 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri Jan 8 12:36:09 2021 +0100

    tdf#138134 sc: remove red circle of updated formula
    
    Recalculation of formulas didn't remove the red validation
    circle around the formula cells despite their new valid value.
    
    Note: to check/show the fix manually, run the test with
    
    $ (cd sc && make -srj8 UITest_validity 
UITEST_TEST_NAME="tdf138134.DetectiveCircle.test_delete_circle_at_formula" 
SAL_USE_VCLPLUGIN=gen)
    
    (if needed, by adding
    
    import time
    time.sleep(5)
    
    to the called function of sc/qa/uitest/validity/tdf138134.py)
    
    Co-authored-by: Attila Szűcs (NISZ)
    
    Change-Id: Ieda4449b1ef07a3cb536881e99130d967c1bb175
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106502
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sc/qa/uitest/validity/tdf138134.py 
b/sc/qa/uitest/validity/tdf138134.py
new file mode 100644
index 000000000000..6d660019d15e
--- /dev/null
+++ b/sc/qa/uitest/validity/tdf138134.py
@@ -0,0 +1,63 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class DetectiveCircle(UITestCase):
+
+    def test_delete_circle_at_formula(self):
+        calc_doc = self.ui_test.create_doc_in_start_center("calc")
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        gridwin = xCalcDoc.getChild("grid_window")
+        document = self.ui_test.get_component()
+        enter_text_to_cell(gridwin, "A1", "1")
+        enter_text_to_cell(gridwin, "A2", "3")
+        enter_text_to_cell(gridwin, "A3", "=SUM(A1:A2)")
+
+        #Select the cells to be validated
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"}))
+        #Apply Data > Validity ... > Whole Numbers
+        self.ui_test.execute_dialog_through_command(".uno:Validation")
+        xDialog = self.xUITest.getTopFocusWindow()
+        xTabs = xDialog.getChild("tabcontrol")
+        select_pos(xTabs, "0")
+        xallow = xDialog.getChild("allow")
+        xallowempty = xDialog.getChild("allowempty")
+        xdata = xDialog.getChild("data")
+        xmin = xDialog.getChild("min")
+        xmax = xDialog.getChild("max")
+
+        props = {"TEXT": "Whole Numbers"}
+        actionProps = mkPropertyValues(props)
+        xallow.executeAction("SELECT", actionProps)
+        xallowempty.executeAction("CLICK", tuple())
+        propsA = {"TEXT": "equal"}
+        actionPropsA = mkPropertyValues(propsA)
+        xdata.executeAction("SELECT", actionPropsA)
+        xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"5"}))
+        xOKBtn = xDialog.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOKBtn)
+
+        self.xUITest.executeCommand(".uno:ShowInvalid")
+
+        detectiveCircle1 = 
document.Sheets.getByName("Sheet1").DrawPage.getCount()
+        #There should be 1 detective circle object!
+        self.assertEqual(detectiveCircle1, 1)
+
+        enter_text_to_cell(gridwin, "A1", "2")
+
+        detectiveCircle2 = 
document.Sheets.getByName("Sheet1").DrawPage.getCount()
+        #There should not be a detective circle object!
+        self.assertEqual(detectiveCircle2, 0)
+
+        self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index a64f7f047e8d..dc054dae86c0 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -55,6 +55,8 @@
 #include <scmod.hxx>
 #include <appoptio.hxx>
 #include <postit.hxx>
+#include <validat.hxx>
+#include <detfunc.hxx>
 
 #include <colorscale.hxx>
 
@@ -1829,6 +1831,15 @@ void ScOutputData::FindChanged()
                 nCol2 = std::max(rPos.Col(), nCol2);
                 nRow1 = std::min(rPos.Row(), nRow1);
                 nRow2 = std::max(rPos.Row(), nRow2);
+
+                const SfxUInt32Item* pItem = mpDoc->GetAttr(rPos, 
ATTR_VALIDDATA);
+                const ScValidationData* pData = 
mpDoc->GetValidationEntry(pItem->GetValue());
+                if (pData)
+                {
+                    ScRefCellValue aCell(*mpDoc, rPos);
+                    if (pData->IsDataValid(aCell, rPos))
+                        ScDetectiveFunc(*mpDoc, 
rPos.Tab()).DeleteCirclesAt(rPos.Col(), rPos.Row());
+                }
             }
         }
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to