summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei@libreoffice.org>2023-02-21 22:16:30 -0500
committerKohei Yoshida <kohei@libreoffice.org>2023-03-02 23:35:56 +0000
commit687b950702c49c90cff9a43655ea97a0343799a0 (patch)
treede60765d191b62c0e92374534d3f836b8c406cbc /sc/inc
parente34074feeb1b918ab9f26a18c5fdb0b1f2e35f94 (diff)
Add a means to query the internal broadcaster state ...
... and use it in one unit test case. Also, remove the code inside DEBUG_AREA_BROADCASTER macro since it no longer builds & has been superceded by this new state query method. Change-Id: I38691a76df5c63034ff488522936dd566bf8b4e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148079 Tested-by: Kohei Yoshida <kohei@libreoffice.org> Reviewed-by: Kohei Yoshida <kohei@libreoffice.org>
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/broadcast.hxx86
-rw-r--r--sc/inc/calcmacros.hxx4
-rw-r--r--sc/inc/column.hxx3
-rw-r--r--sc/inc/document.hxx7
-rw-r--r--sc/inc/grouparealistener.hxx3
-rw-r--r--sc/inc/table.hxx3
6 files changed, 98 insertions, 8 deletions
diff --git a/sc/inc/broadcast.hxx b/sc/inc/broadcast.hxx
new file mode 100644
index 000000000000..b095f819acb7
--- /dev/null
+++ b/sc/inc/broadcast.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * 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/.
+ */
+
+#pragma once
+
+#include "address.hxx"
+
+#include <map>
+#include <variant>
+#include <ostream>
+
+class ScFormulaCell;
+class SvtListener;
+
+namespace sc
+{
+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);
+ CellListener(const SvtListener* p);
+ };
+
+ struct AreaListener
+ {
+ using DataType = std::variant<const ScFormulaCell*, const sc::FormulaGroupAreaListener*,
+ const SvtListener*>;
+
+ AreaListenerType eType;
+ DataType pData;
+
+ AreaListener(const ScFormulaCell* p);
+ AreaListener(const sc::FormulaGroupAreaListener* p);
+ AreaListener(const SvtListener* p);
+ };
+
+ std::map<ScAddress, std::vector<CellListener>> aCellListenerStore;
+ std::map<ScRange, std::vector<AreaListener>> aAreaListenerStore;
+
+ /**
+ * Check if a formula cell listens on a single cell.
+ */
+ bool hasFormulaCellListener(const ScAddress& rBroadcasterPos,
+ const ScAddress& rFormulaPos) const;
+
+ /**
+ * Check if a formula cell listens on a single range.
+ */
+ bool hasFormulaCellListener(const ScRange& rBroadcasterRange,
+ const ScAddress& rFormulaPos) const;
+
+ /**
+ * Dump all broadcaster state in YAML format.
+ */
+ void dump(std::ostream& rStrm, const ScDocument* pDoc = nullptr) const;
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/calcmacros.hxx b/sc/inc/calcmacros.hxx
index c0c68d4487cf..ebe96654804a 100644
--- a/sc/inc/calcmacros.hxx
+++ b/sc/inc/calcmacros.hxx
@@ -12,7 +12,6 @@
#define DEBUG_COLUMN_STORAGE 0
#define DEBUG_PIVOT_TABLE 0
#define DEBUG_FORMULA_COMPILER 0
-#define DEBUG_AREA_BROADCASTER 0
#define DUMP_COLUMN_STORAGE 0
#define DUMP_PIVOT_TABLE 0
@@ -26,8 +25,7 @@
#if DUMP_PIVOT_TABLE || DEBUG_PIVOT_TABLE || \
DUMP_COLUMN_STORAGE || DEBUG_COLUMN_STORAGE || \
- DEBUG_FORMULA_COMPILER || \
- DEBUG_AREA_BROADCASTER
+ DEBUG_FORMULA_COMPILER
#include <iostream>
using std::cout;
using std::cerr;
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 949ca30dd137..5c42f02794ab 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -42,6 +42,7 @@ namespace formula { struct VectorRefArray; }
namespace sc {
+struct BroadcasterState;
struct FormulaGroupEntry;
class StartListeningContext;
class EndListeningContext;
@@ -864,6 +865,8 @@ private:
void EndListeningGroup( sc::EndListeningContext& rCxt, SCROW nRow );
void SetNeedsListeningGroup( SCROW nRow );
+
+ void CollectBroadcasterState(sc::BroadcasterState& rState) const;
};
inline bool ScColumn::IsEmptyAttr() const
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 092d9ba0d9a9..09fcc126ed06 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -77,6 +77,7 @@ namespace tools { class Guid; }
namespace sc {
+struct BroadcasterState;
struct FormulaGroupContext;
class StartListeningContext;
class EndListeningContext;
@@ -2368,6 +2369,8 @@ public:
void EndListeningFormulaCells( std::vector<ScFormulaCell*>& rCells );
+ sc::BroadcasterState GetBroadcasterState() const;
+
void PutInFormulaTree( ScFormulaCell* pCell );
void RemoveFromFormulaTree( ScFormulaCell* pCell );
@@ -2611,10 +2614,6 @@ public:
SC_DLLPUBLIC void DumpColumnStorage( SCTAB nTab, SCCOL nCol ) const;
#endif
-#if DEBUG_AREA_BROADCASTER
- SC_DLLPUBLIC void DumpAreaBroadcasters() const;
-#endif
-
SC_DLLPUBLIC void SetCalcConfig( const ScCalcConfig& rConfig );
const ScCalcConfig& GetCalcConfig() const { return maCalcConfig; }
void ConvertFormulaToValue( const ScRange& rRange, sc::TableValues* pUndo );
diff --git a/sc/inc/grouparealistener.hxx b/sc/inc/grouparealistener.hxx
index d823fc987627..a52dc2fb8a74 100644
--- a/sc/inc/grouparealistener.hxx
+++ b/sc/inc/grouparealistener.hxx
@@ -60,10 +60,11 @@ public:
void collectFormulaCells( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, std::vector<ScFormulaCell*>& rCells ) const;
void collectFormulaCells( SCROW nRow1, SCROW nRow2, std::vector<ScFormulaCell*>& rCells ) const;
+ const ScFormulaCell* getTopCell() const;
+
private:
void notifyCellChange( const SfxHint& rHint, const ScAddress& rPos, SCROW nNumRows );
void notifyBulkChange( const BulkDataHint& rHint );
- const ScFormulaCell* getTopCell() const;
};
}
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index f81e3925964e..b5fa4e9ec334 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -57,6 +57,7 @@ namespace com::sun::star {
namespace formula { struct VectorRefArray; }
namespace sc {
+struct BroadcasterState;
class StartListeningContext;
class EndListeningContext;
class CopyFromClipContext;
@@ -1156,6 +1157,8 @@ public:
void CheckIntegrity() const;
+ void CollectBroadcasterState(sc::BroadcasterState& rState) const;
+
private:
void FillFormulaVertical(