sc/inc/conditio.hxx | 7 +++++++ sc/qa/unit/ucalc.hxx | 2 ++ sc/qa/unit/ucalc_condformat.cxx | 38 ++++++++++++++++++++++++++++++++++++++ sc/source/core/data/conditio.cxx | 33 +++++++++++++++++++++++++++++++++ sc/source/core/data/table2.cxx | 2 ++ 5 files changed, 82 insertions(+)
New commits: commit be7203eca9745bd39d167777d7ec824954b3e4c0 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> AuthorDate: Sat Jul 14 01:55:45 2018 +0200 Commit: Markus Mohrhard <markus.mohrh...@googlemail.com> CommitDate: Sat Jul 14 10:28:10 2018 +0200 add test for tdf#91385 Change-Id: Ic755d330f242a78214e8b1610aa496ecce3d61b4 Reviewed-on: https://gerrit.libreoffice.org/57410 Tested-by: Jenkins Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 60cee22b07c2..e2c778a01dda 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -523,6 +523,7 @@ public: void testMultipleSingleCellCondFormatCopyPaste(); void testDeduplicateMultipleCondFormats(); void testCondFormatListenToOwnRange(); + void testCondFormatVolatileFunctionRecalc(); void testImportStream(); void testDeleteContents(); @@ -812,6 +813,7 @@ public: CPPUNIT_TEST(testCondFormatUndoList); CPPUNIT_TEST(testMultipleSingleCellCondFormatCopyPaste); CPPUNIT_TEST(testDeduplicateMultipleCondFormats); + CPPUNIT_TEST(testCondFormatVolatileFunctionRecalc); CPPUNIT_TEST(testIconSet); CPPUNIT_TEST(testDataBarLengthAutomaticAxis); CPPUNIT_TEST(testDataBarLengthMiddleAxis); diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx index 62b0ba9dace0..d2bf5d23c6df 100644 --- a/sc/qa/unit/ucalc_condformat.cxx +++ b/sc/qa/unit/ucalc_condformat.cxx @@ -1226,4 +1226,42 @@ void Test::testCondFormatListenToOwnRange() m_pDoc->DeleteTab(0); } +void Test::testCondFormatVolatileFunctionRecalc() +{ + m_pDoc->InsertTab(0, "Test"); + + m_pDoc->SetValue(0, 0, 0, 0.5); + + ScConditionalFormatList* pList = m_pDoc->GetCondFormList(0); + + ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc); + ScRangeList aRangeList(ScRange(0,0,0,10,0,0)); + pFormat->SetRange(aRangeList); + + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Greater,"RAND()","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + pEntry->SetParent(pFormat); + + m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1); + pFormat->AddEntry(pEntry); + pList->InsertNew(pFormat); + + ScRefCellValue aCell(*m_pDoc, ScAddress(0, 0, 0)); + bool bValid = pEntry->IsCellValid(aCell, ScAddress(0, 0, 0)); + + bool bNewValid = bValid; + // chance of a random failure is 0.5^100, anyone hitting that will get a beer from me + for (size_t i = 0; i < 100; ++i) + { + pFormat->CalcAll(); + bNewValid = pEntry->IsCellValid(aCell, ScAddress(0, 0, 0)); + + if (bValid != bNewValid) + break; + } + + CPPUNIT_ASSERT(bValid != bNewValid); + + m_pDoc->DeleteTab(0); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 1ce2d70bc29b348f2f819d616a897e1dcb6a1a9f Author: Markus Mohrhard <markus.mohrh...@googlemail.com> AuthorDate: Sat Jul 14 01:21:59 2018 +0200 Commit: Markus Mohrhard <markus.mohrh...@googlemail.com> CommitDate: Sat Jul 14 10:28:03 2018 +0200 tdf#91385, recalc cond format formulas during hard recalc Change-Id: I54b650d228c89a15eb37294eb108ab736163a000 Reviewed-on: https://gerrit.libreoffice.org/57409 Tested-by: Jenkins Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index 31ca3531bf20..be9c1362742c 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -401,6 +401,7 @@ public: virtual void startRendering() override; bool NeedsRepaint() const; + void CalcAll(); protected: virtual void DataChanged() const; @@ -589,6 +590,9 @@ public: void startRendering(); void endRendering(); + + // Forced recalculation for formulas + void CalcAll(); }; // List of all conditional formats in a sheet @@ -654,6 +658,9 @@ public: void endRendering(); sal_uInt32 getMaxKey() const; + + /// Forced recalculation of formulas + void CalcAll(); }; #endif diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 018d9757c058..a13ccf622e4c 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1532,6 +1532,18 @@ ScFormatEntry* ScCondFormatEntry::Clone( ScDocument* pDoc ) const return new ScCondFormatEntry( pDoc, *this ); } +void ScConditionEntry::CalcAll() +{ + if (pFCell1 || pFCell2) + { + if (pFCell1) + pFCell1->SetDirty(); + if (pFCell2) + pFCell2->SetDirty(); + pCondFormat->DoRepaint(); + } +} + ScCondDateFormatEntry::ScCondDateFormatEntry( ScDocument* pDoc ) : ScFormatEntry( pDoc ) , meType(condformat::TODAY) @@ -2028,6 +2040,18 @@ void ScConditionalFormat::endRendering() } } +void ScConditionalFormat::CalcAll() +{ + for(auto itr = maEntries.cbegin(); itr != maEntries.cend(); ++itr) + { + if ((*itr)->GetType() == ScFormatEntry::Type::Condition) + { + ScCondFormatEntry& rFormat = static_cast<ScCondFormatEntry&>(**itr); + rFormat.CalcAll(); + } + } +} + ScConditionalFormatList::ScConditionalFormatList(const ScConditionalFormatList& rList) { for(const_iterator itr = rList.begin(); itr != rList.end(); ++itr) @@ -2281,4 +2305,13 @@ sal_uInt32 ScConditionalFormatList::getMaxKey() const return nMax; } +void ScConditionalFormatList::CalcAll() +{ + for (const auto& aEntry : m_ConditionalFormats) + { + aEntry->CalcAll(); + } + +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index fe8b69035ad6..d2aa2a0a4d6e 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1877,6 +1877,8 @@ void ScTable::CalcAll() { for (SCCOL i=0; i < aCol.size(); i++) aCol[i].CalcAll(); + + mpCondFormatList->CalcAll(); } void ScTable::CompileAll( sc::CompileFormulaContext& rCxt ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits