sc/inc/broadcast.hxx | 15 --------------- sc/source/core/data/broadcast.cxx | 33 ++++++++++++++------------------- 2 files changed, 14 insertions(+), 34 deletions(-)
New commits: commit b9b57133125179a88f7f68e14ef6cde888885ed1 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Oct 11 11:39:22 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Oct 12 08:54:26 2023 +0200 no need for these enums in BroadcasterState the std::variant already knows which alternative it stores Change-Id: I3838d83959cf6a97876aba3543179338ba088ccc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157819 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/inc/broadcast.hxx b/sc/inc/broadcast.hxx index b095f819acb7..55b1e64f0c9a 100644 --- a/sc/inc/broadcast.hxx +++ b/sc/inc/broadcast.hxx @@ -24,24 +24,10 @@ class FormulaGroupAreaListener; struct BroadcasterState { - enum class CellListenerType - { - FormulaCell, - Generic, - }; - - enum class AreaListenerType - { - FormulaCell, - FormulaGroup, - Generic, - }; - struct CellListener { using DataType = std::variant<const ScFormulaCell*, const SvtListener*>; - CellListenerType eType; DataType pData; CellListener(const ScFormulaCell* p); @@ -53,7 +39,6 @@ struct BroadcasterState using DataType = std::variant<const ScFormulaCell*, const sc::FormulaGroupAreaListener*, const SvtListener*>; - AreaListenerType eType; DataType pData; AreaListener(const ScFormulaCell* p); diff --git a/sc/source/core/data/broadcast.cxx b/sc/source/core/data/broadcast.cxx index c0cd0c29edca..d76591692f15 100644 --- a/sc/source/core/data/broadcast.cxx +++ b/sc/source/core/data/broadcast.cxx @@ -14,32 +14,27 @@ namespace sc { BroadcasterState::CellListener::CellListener(const ScFormulaCell* p) - : eType(CellListenerType::FormulaCell) - , pData(p) + : pData(p) { } BroadcasterState::CellListener::CellListener(const SvtListener* p) - : eType(CellListenerType::Generic) - , pData(p) + : pData(p) { } BroadcasterState::AreaListener::AreaListener(const ScFormulaCell* p) - : eType(AreaListenerType::FormulaCell) - , pData(p) + : pData(p) { } BroadcasterState::AreaListener::AreaListener(const sc::FormulaGroupAreaListener* p) - : eType(AreaListenerType::FormulaGroup) - , pData(p) + : pData(p) { } BroadcasterState::AreaListener::AreaListener(const SvtListener* p) - : eType(AreaListenerType::Generic) - , pData(p) + : pData(p) { } @@ -52,7 +47,7 @@ bool BroadcasterState::hasFormulaCellListener(const ScAddress& rBroadcasterPos, for (const auto& rLis : it->second) { - if (rLis.eType == CellListenerType::FormulaCell) + if (rLis.pData.index() == 0) { auto pFC = std::get<const ScFormulaCell*>(rLis.pData); if (pFC->aPos == rFormulaPos) @@ -72,7 +67,7 @@ bool BroadcasterState::hasFormulaCellListener(const ScRange& rBroadcasterRange, for (const auto& rLis : it->second) { - if (rLis.eType == AreaListenerType::FormulaCell) + if (rLis.pData.index() == 0) { auto pFC = std::get<const ScFormulaCell*>(rLis.pData); if (pFC->aPos == rFormulaPos) @@ -99,16 +94,16 @@ void BroadcasterState::dump(std::ostream& rStrm, const ScDocument* pDoc) const for (const auto& rLis : rListeners) { - switch (rLis.eType) + switch (rLis.pData.index()) { - case BroadcasterState::CellListenerType::FormulaCell: + case 0: { auto* pFC = std::get<const ScFormulaCell*>(rLis.pData); rStrm << " - type: formula-cell\n"; rStrm << " position: " << pFC->aPos.Format(nPosFlags, pDoc) << std::endl; break; } - case BroadcasterState::CellListenerType::Generic: + case 1: { rStrm << " - type: unknown" << std::endl; break; @@ -127,16 +122,16 @@ void BroadcasterState::dump(std::ostream& rStrm, const ScDocument* pDoc) const for (const auto& rLis : rListeners) { - switch (rLis.eType) + switch (rLis.pData.index()) { - case BroadcasterState::AreaListenerType::FormulaCell: + case 0: { auto* pFC = std::get<const ScFormulaCell*>(rLis.pData); rStrm << " - type: formula-cell\n"; rStrm << " position: " << pFC->aPos.Format(nPosFlags, pDoc) << std::endl; break; } - case BroadcasterState::AreaListenerType::FormulaGroup: + case 1: { auto* pFGL = std::get<const sc::FormulaGroupAreaListener*>(rLis.pData); @@ -150,7 +145,7 @@ void BroadcasterState::dump(std::ostream& rStrm, const ScDocument* pDoc) const } break; } - case BroadcasterState::AreaListenerType::Generic: + case 2: { rStrm << " - type: unknown" << std::endl; break;