summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-02-16 11:05:38 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-02-17 01:13:52 +0100
commit6267a995ea5a621f5f147e5866b6af9cdd205b9c (patch)
tree97ce13066eea1d901e80469ffa7a29da0360de16 /sc
parentf3b2dd0fc4c413c9a8382aecbd8b7f842bfa8c28 (diff)
remove MAXCOL/MAXROW from ScExternalRefCache
The range is used just for filtering out, and since this is about references to other documents, I wasn't sure which document to use as the limits, so I did a copy that of the functions that returns all. Change-Id: I9711534004796496558848adef03d38ddb115441 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129988 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/externalrefmgr.hxx10
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx32
2 files changed, 36 insertions, 6 deletions
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 1064910ad975..20931043bfd1 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -144,11 +144,13 @@ public:
void setReferenced( bool bReferenced );
bool isReferenced() const;
/// Obtain a sorted vector of rows.
- void getAllRows(::std::vector<SCROW>& rRows, SCROW nLow = 0, SCROW nHigh = MAXROW) const;
+ void getAllRows(::std::vector<SCROW>& rRows, SCROW nLow, SCROW nHigh) const;
+ void getAllRows(::std::vector<SCROW>& rRows) const;
/// Returns the half-open range of used rows in this table. Returns [0,0) if table is empty.
SC_DLLPUBLIC ::std::pair< SCROW, SCROW > getRowRange() const;
/// Obtain a sorted vector of columns.
- void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols, SCCOL nLow = 0, SCCOL nHigh = MAXCOL) const;
+ void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols, SCCOL nLow, SCCOL nHigh) const;
+ void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols) const;
/// Returns the half-open range of used columns in the specified row. Returns [0,0) if row is empty.
SC_DLLPUBLIC ::std::pair< SCCOL, SCCOL > getColRange( SCROW nRow ) const;
void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
@@ -168,6 +170,10 @@ public:
private:
bool isInCachedRanges(SCCOL nCol, SCROW nRow) const;
TokenRef getEmptyOrNullToken(SCCOL nCol, SCROW nRow) const;
+ template< typename P >
+ void getAllRows(::std::vector<SCROW>& rRows, P predicate) const;
+ template< typename P >
+ void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols, P predicate) const;
private:
/** Data cache */
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index af4dc4b7d27b..2f2bf13bd2fc 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -330,12 +330,13 @@ bool ScExternalRefCache::Table::hasRow( SCROW nRow ) const
return itrRow != maRows.end();
}
-void ScExternalRefCache::Table::getAllRows(vector<SCROW>& rRows, SCROW nLow, SCROW nHigh) const
+template< typename P >
+void ScExternalRefCache::Table::getAllRows(vector<SCROW>& rRows, P predicate) const
{
vector<SCROW> aRows;
aRows.reserve(maRows.size());
for (const auto& rEntry : maRows)
- if (nLow <= rEntry.first && rEntry.first <= nHigh)
+ if (predicate(rEntry))
aRows.push_back(rEntry.first);
// hash map is not ordered, so we need to explicitly sort it.
@@ -343,6 +344,17 @@ void ScExternalRefCache::Table::getAllRows(vector<SCROW>& rRows, SCROW nLow, SCR
rRows.swap(aRows);
}
+void ScExternalRefCache::Table::getAllRows(vector<SCROW>& rRows, SCROW nLow, SCROW nHigh) const
+{
+ getAllRows(rRows,
+ [nLow, nHigh](std::pair<SCROW, RowDataType> rEntry) { return (nLow <= rEntry.first && rEntry.first <= nHigh); });
+}
+
+void ScExternalRefCache::Table::getAllRows(vector<SCROW>& rRows) const
+{
+ getAllRows(rRows, [](std::pair<SCROW, RowDataType>) { return true; } );
+}
+
::std::pair< SCROW, SCROW > ScExternalRefCache::Table::getRowRange() const
{
::std::pair< SCROW, SCROW > aRange( 0, 0 );
@@ -357,7 +369,8 @@ void ScExternalRefCache::Table::getAllRows(vector<SCROW>& rRows, SCROW nLow, SCR
return aRange;
}
-void ScExternalRefCache::Table::getAllCols(SCROW nRow, vector<SCCOL>& rCols, SCCOL nLow, SCCOL nHigh) const
+template< typename P >
+void ScExternalRefCache::Table::getAllCols(SCROW nRow, vector<SCCOL>& rCols, P predicate) const
{
RowsDataType::const_iterator itrRow = maRows.find(nRow);
if (itrRow == maRows.end())
@@ -368,7 +381,7 @@ void ScExternalRefCache::Table::getAllCols(SCROW nRow, vector<SCCOL>& rCols, SCC
vector<SCCOL> aCols;
aCols.reserve(rRowData.size());
for (const auto& rCol : rRowData)
- if (nLow <= rCol.first && rCol.first <= nHigh)
+ if (predicate(rCol))
aCols.push_back(rCol.first);
// hash map is not ordered, so we need to explicitly sort it.
@@ -376,6 +389,17 @@ void ScExternalRefCache::Table::getAllCols(SCROW nRow, vector<SCCOL>& rCols, SCC
rCols.swap(aCols);
}
+void ScExternalRefCache::Table::getAllCols(SCROW nRow, vector<SCCOL>& rCols, SCCOL nLow, SCCOL nHigh) const
+{
+ getAllCols(nRow, rCols,
+ [nLow, nHigh](std::pair<SCCOL, Cell> rCol) { return nLow <= rCol.first && rCol.first <= nHigh; } );
+}
+
+void ScExternalRefCache::Table::getAllCols(SCROW nRow, vector<SCCOL>& rCols) const
+{
+ getAllCols(nRow, rCols, [](std::pair<SCCOL, Cell>) { return true; } );
+}
+
::std::pair< SCCOL, SCCOL > ScExternalRefCache::Table::getColRange( SCROW nRow ) const
{
::std::pair< SCCOL, SCCOL > aRange( 0, 0 );