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.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2023-10-12 08:54:26 +02:00
parent faa590cf41
commit b9b5713312
2 changed files with 14 additions and 34 deletions
-15
View File
@@ -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);
+14 -19
View File
@@ -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;