tdf#170494: Revert "optimize relative conditional formatting effort"

This reverts commit 7ca98e3865.

Change-Id: Ic7c89ecbfbfa3472410a19655fa3c38fa9cf25af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208639
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli
2026-07-27 13:58:15 +02:00
parent 9f63a1307a
commit 4326e7d4a5
3 changed files with 19 additions and 110 deletions
+2 -12
View File
@@ -205,7 +205,7 @@ public:
checkLRUMaxSize();
}
list_const_iterator_t insert(key_value_pair_t& rPair)
void insert(key_value_pair_t& rPair)
{
map_iterator_t i = mLruMap.find(rPair.first);
@@ -230,11 +230,9 @@ public:
mLruList.splice(mLruList.begin(), mLruList, i->second);
checkLRUItemUpdate();
}
return mLruList.cbegin();
}
list_const_iterator_t insert(key_value_pair_t&& rPair)
void insert(key_value_pair_t&& rPair)
{
map_iterator_t i = mLruMap.find(rPair.first);
@@ -258,8 +256,6 @@ public:
mLruList.splice(mLruList.begin(), mLruList, i->second);
checkLRUItemUpdate();
}
return mLruList.cbegin();
}
list_const_iterator_t find(const Key& key)
@@ -305,12 +301,6 @@ public:
return mLruMap.size();
}
size_t empty() const
{
assert(mLruMap.empty() == mLruList.empty());
return mLruMap.empty();
}
// size_t total_size() const; - only if custom ValueSize
void clear()
+1 -12
View File
@@ -34,8 +34,6 @@
#include <rtl/math.hxx>
#include <tools/date.hxx>
#include <tools/link.hxx>
#include <o3tl/lru_map.hxx>
#include <vcl/dropcache.hxx>
#include <optional>
#include <map>
@@ -303,7 +301,7 @@ public:
}
};
class SAL_DLLPUBLIC_RTTI ScConditionEntry : public ScFormatEntry, public CacheOwner
class SAL_DLLPUBLIC_RTTI ScConditionEntry : public ScFormatEntry
{
// stored data:
ScConditionMode eOp;
@@ -325,9 +323,6 @@ class SAL_DLLPUBLIC_RTTI ScConditionEntry : public ScFormatEntry, public CacheOw
OUString aSrcString; // formula source position as text during XML import
std::unique_ptr<ScFormulaCell> pFCell1;
std::unique_ptr<ScFormulaCell> pFCell2;
typedef o3tl::lru_map<ScAddress, std::unique_ptr<ScFormulaCell>> RelRefCells;
std::unique_ptr<RelRefCells> xRelRefCells1;
std::unique_ptr<RelRefCells> xRelRefCells2;
bool bRelRef1;
bool bRelRef2;
bool bFirstRun;
@@ -351,8 +346,6 @@ class SAL_DLLPUBLIC_RTTI ScConditionEntry : public ScFormatEntry, public CacheOw
bool IsValidStr( const OUString& rArg, const ScAddress& rPos ) const;
void StartListening();
static std::unique_ptr<RelRefCells> makeRelRefCells();
public:
ScConditionEntry( ScConditionMode eOper,
const OUString& rExpr1, const OUString& rExpr2,
@@ -408,10 +401,6 @@ public:
virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) override;
virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) override;
virtual bool dropCaches() override;
virtual void dumpState(rtl::OStringBuffer& rState) override;
virtual OUString getCacheName() const override;
bool MarkUsedExternalReferences() const;
virtual Type GetType() const override { return eConditionType; }
+16 -86
View File
@@ -458,9 +458,7 @@ void ScConditionEntry::SetCaseSensitive(bool bSet)
void ScConditionEntry::CompileAll()
{
pFCell1.reset();
xRelRefCells1.reset();
pFCell2.reset();
xRelRefCells2.reset();
}
void ScConditionEntry::CompileXML()
@@ -555,11 +553,7 @@ void ScConditionEntry::UpdateReference( sc::RefUpdateContext& rCxt )
}
if (aRes.mbReferenceModified || bChangedPos)
{
// is created again in IsValid
pFCell1.reset();
xRelRefCells1.reset();
}
pFCell1.reset(); // is created again in IsValid
}
if (pFormula2)
@@ -578,11 +572,7 @@ void ScConditionEntry::UpdateReference( sc::RefUpdateContext& rCxt )
}
if (aRes.mbReferenceModified || bChangedPos)
{
// is created again in IsValid
pFCell2.reset();
xRelRefCells2.reset();
}
pFCell2.reset(); // is created again in IsValid
}
StartListening();
@@ -594,14 +584,12 @@ void ScConditionEntry::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt )
{
pFormula1->AdjustReferenceOnInsertedTab(rCxt, aSrcPos);
pFCell1.reset();
xRelRefCells1.reset();
}
if (pFormula2)
{
pFormula2->AdjustReferenceOnInsertedTab(rCxt, aSrcPos);
pFCell2.reset();
xRelRefCells2.reset();
}
ScRangeUpdater::UpdateInsertTab(aSrcPos, rCxt);
@@ -613,14 +601,12 @@ void ScConditionEntry::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt )
{
pFormula1->AdjustReferenceOnDeletedTab(rCxt, aSrcPos);
pFCell1.reset();
xRelRefCells1.reset();
}
if (pFormula2)
{
pFormula2->AdjustReferenceOnDeletedTab(rCxt, aSrcPos);
pFCell2.reset();
xRelRefCells2.reset();
}
ScRangeUpdater::UpdateDeleteTab(aSrcPos, rCxt);
@@ -637,7 +623,6 @@ void ScConditionEntry::UpdateMoveTab(sc::RefUpdateMoveTabContext& rCxt)
if (aRes.mbValueChanged)
aResFinal.mnTab = aRes.mnTab;
pFCell1.reset();
xRelRefCells1.reset();
}
if (pFormula2)
@@ -646,7 +631,6 @@ void ScConditionEntry::UpdateMoveTab(sc::RefUpdateMoveTabContext& rCxt)
if (aRes.mbValueChanged)
aResFinal.mnTab = aRes.mnTab;
pFCell2.reset();
xRelRefCells2.reset();
}
if (aResFinal.mnTab != aSrcPos.Tab())
@@ -693,12 +677,6 @@ bool ScConditionEntry::IsEqual( const ScFormatEntry& rOther, bool bIgnoreSrcPos
return true;
}
//static
std::unique_ptr<ScConditionEntry::RelRefCells> ScConditionEntry::makeRelRefCells()
{
return std::make_unique<RelRefCells>(0x9fff);
}
void ScConditionEntry::Interpret( const ScAddress& rPos )
{
// Create formula cells
@@ -709,25 +687,16 @@ void ScConditionEntry::Interpret( const ScAddress& rPos )
// Evaluate formulas
bool bDirty = false; // 1 and 2 separate?
std::optional<ScFormulaCell> oTemp;
ScFormulaCell* pEff1 = pFCell1.get();
if ( bRelRef1 )
{
if (!xRelRefCells1)
xRelRefCells1 = makeRelRefCells();
auto iFind = xRelRefCells1->find(rPos);
if (iFind != xRelRefCells1->end())
pEff1 = iFind->second.get();
if (pFormula1)
oTemp.emplace(mrDoc, rPos, *pFormula1);
else
{
std::unique_ptr<ScFormulaCell> xCell;
if (pFormula1)
xCell = std::make_unique<ScFormulaCell>(mrDoc, rPos, *pFormula1);
else
xCell = std::make_unique<ScFormulaCell>(mrDoc, rPos);
xCell->SetFreeFlying(true);
xCell->StartListeningTo(mrDoc);
pEff1 = xRelRefCells1->insert(std::make_pair(rPos, std::move(xCell)))->second.get();
}
oTemp.emplace(mrDoc, rPos);
pEff1 = &*oTemp;
pEff1->SetFreeFlying(true);
}
if ( pEff1 )
{
@@ -750,26 +719,17 @@ void ScConditionEntry::Interpret( const ScAddress& rPos )
}
}
}
oTemp.reset();
ScFormulaCell* pEff2 = pFCell2.get(); //@ 1!=2
if ( bRelRef2 )
{
if (!xRelRefCells2)
xRelRefCells2 = makeRelRefCells();
auto iFind = xRelRefCells2->find(rPos);
if (iFind != xRelRefCells2->end())
pEff2 = iFind->second.get();
if (pFormula2)
oTemp.emplace(mrDoc, rPos, *pFormula2);
else
{
std::unique_ptr<ScFormulaCell> xCell;
if (pFormula2)
xCell = std::make_unique<ScFormulaCell>(mrDoc, rPos, *pFormula2);
else
xCell = std::make_unique<ScFormulaCell>(mrDoc, rPos);
xCell->SetFreeFlying(true);
xCell->StartListeningTo(mrDoc);
pEff2 = xRelRefCells2->insert(std::make_pair(rPos, std::move(xCell)))->second.get();
}
oTemp.emplace(mrDoc, rPos);
pEff2 = &*oTemp;
pEff2->SetFreeFlying(true);
}
if ( pEff2 )
{
@@ -791,6 +751,7 @@ void ScConditionEntry::Interpret( const ScAddress& rPos )
}
}
}
oTemp.reset();
// If IsRunning, the last values remain
if (bDirty && !bFirstRun)
@@ -1605,47 +1566,16 @@ ScFormatEntry* ScCondFormatEntry::Clone( ScDocument& rDoc ) const
void ScConditionEntry::CalcAll()
{
if (pFCell1 || pFCell2 || xRelRefCells1 || !xRelRefCells2)
if (pFCell1 || pFCell2)
{
if (pFCell1)
pFCell1->SetDirty();
if (xRelRefCells1)
{
for (auto& rEntry : *xRelRefCells1)
rEntry.second->SetDirty();
}
if (pFCell2)
pFCell2->SetDirty();
if (xRelRefCells2)
{
for (auto& rEntry : *xRelRefCells2)
rEntry.second->SetDirty();
}
pCondFormat->DoRepaint();
}
}
OUString ScConditionEntry::getCacheName() const
{
return "ScConditionEntry";
}
bool ScConditionEntry::dropCaches()
{
xRelRefCells1.reset();
xRelRefCells2.reset();
return true;
}
void ScConditionEntry::dumpState(rtl::OStringBuffer& rState)
{
rState.append("\nScConditionEntry:");
rState.append("\n\t rel ref cells1: ");
rState.append(xRelRefCells1 ? static_cast<sal_Int32>(xRelRefCells1->size()) : 0);
rState.append("\n\t rel ref cells2: ");
rState.append(xRelRefCells2 ? static_cast<sal_Int32>(xRelRefCells2->size()) : 0);
}
ScCondDateFormatEntry::ScCondDateFormatEntry( ScDocument& rDoc )
: ScFormatEntry( rDoc )
, meType(condformat::TODAY)