Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / inc / broadcast.hxx
blob55b1e64f0c9acb7825d1d92d031d92462bd7f83f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #pragma once
12 #include "address.hxx"
14 #include <map>
15 #include <variant>
16 #include <ostream>
18 class ScFormulaCell;
19 class SvtListener;
21 namespace sc
23 class FormulaGroupAreaListener;
25 struct BroadcasterState
27 struct CellListener
29 using DataType = std::variant<const ScFormulaCell*, const SvtListener*>;
31 DataType pData;
33 CellListener(const ScFormulaCell* p);
34 CellListener(const SvtListener* p);
37 struct AreaListener
39 using DataType = std::variant<const ScFormulaCell*, const sc::FormulaGroupAreaListener*,
40 const SvtListener*>;
42 DataType pData;
44 AreaListener(const ScFormulaCell* p);
45 AreaListener(const sc::FormulaGroupAreaListener* p);
46 AreaListener(const SvtListener* p);
49 std::map<ScAddress, std::vector<CellListener>> aCellListenerStore;
50 std::map<ScRange, std::vector<AreaListener>> aAreaListenerStore;
52 /**
53 * Check if a formula cell listens on a single cell.
55 bool hasFormulaCellListener(const ScAddress& rBroadcasterPos,
56 const ScAddress& rFormulaPos) const;
58 /**
59 * Check if a formula cell listens on a single range.
61 bool hasFormulaCellListener(const ScRange& rBroadcasterRange,
62 const ScAddress& rFormulaPos) const;
64 /**
65 * Dump all broadcaster state in YAML format.
67 void dump(std::ostream& rStrm, const ScDocument* pDoc = nullptr) const;
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */