summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-12-13 20:45:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-12-14 06:57:53 +0100
commit5bcdbf03012e9d2754c3eb166bd5a01201406d9b (patch)
treec910eac80023f9cb1c0f943c8edad1928977968f /sc/inc
parent113444f59dc7690850919155b9b164b1a686bbe7 (diff)
sc: rowcol: tdf#50916 convert Valid* methods
which means we end up passing around ScDocument* __everywhere__ Change-Id: I44d235ca5e9d57519f068b6880ee7d66f3ceb529 Reviewed-on: https://gerrit.libreoffice.org/83548 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/address.hxx12
-rw-r--r--sc/inc/compiler.hxx1
-rw-r--r--sc/inc/refdata.hxx27
-rw-r--r--sc/inc/reftokenhelper.hxx6
-rw-r--r--sc/inc/sharedformula.hxx2
-rw-r--r--sc/inc/table.hxx2
-rw-r--r--sc/inc/token.hxx10
7 files changed, 32 insertions, 28 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 5a1f7d91f2ab..2109d582f67b 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -88,13 +88,13 @@ const SCCOL SC_TABSTART_NONE = SCCOL_MAX;
const SCROW MAXROW_30 = 8191;
-[[nodiscard]] inline bool ValidCol( SCCOL nCol, SCCOL nMaxCol = MAXCOL )
+[[nodiscard]] inline bool ValidCol( SCCOL nCol, SCCOL nMaxCol )
{
assert(nMaxCol == MAXCOL); // temporary to debug jumbo sheets work
return nCol >= 0 && nCol <= nMaxCol;
}
-[[nodiscard]] inline bool ValidRow( SCROW nRow, SCROW nMaxRow = MAXROW)
+[[nodiscard]] inline bool ValidRow( SCROW nRow, SCROW nMaxRow)
{
assert(nMaxRow == MAXROW); // temporary to debug jumbo sheets work
return nRow >= 0 && nRow <= nMaxRow;
@@ -110,25 +110,25 @@ const SCROW MAXROW_30 = 8191;
return nTab >= 0 && nTab <= nMaxTab;
}
-[[nodiscard]] inline bool ValidColRow( SCCOL nCol, SCROW nRow, SCCOL nMaxCol = MAXCOL, SCROW nMaxRow = MAXROW )
+[[nodiscard]] inline bool ValidColRow( SCCOL nCol, SCROW nRow, SCCOL nMaxCol, SCROW nMaxRow )
{
assert(nMaxRow == MAXROW); // temporary to debug jumbo sheets work
return ValidCol(nCol,nMaxCol) && ValidRow(nRow,nMaxRow);
}
-[[nodiscard]] inline bool ValidColRowTab( SCCOL nCol, SCROW nRow, SCTAB nTab, SCCOL nMaxCol = MAXCOL, SCROW nMaxRow = MAXROW )
+[[nodiscard]] inline bool ValidColRowTab( SCCOL nCol, SCROW nRow, SCTAB nTab, SCCOL nMaxCol, SCROW nMaxRow )
{
assert(nMaxRow == MAXROW); // temporary to debug jumbo sheets work
return ValidCol(nCol,nMaxCol) && ValidRow(nRow,nMaxRow) && ValidTab( nTab);
}
-[[nodiscard]] inline SCCOL SanitizeCol( SCCOL nCol, SCCOL nMaxCol = MAXCOL )
+[[nodiscard]] inline SCCOL SanitizeCol( SCCOL nCol, SCCOL nMaxCol )
{
assert(nMaxCol == MAXCOL); // temporary to debug jumbo sheets work
return nCol < 0 ? 0 : (nCol > nMaxCol ? nMaxCol : nCol);
}
-[[nodiscard]] inline SCROW SanitizeRow( SCROW nRow, SCROW nMaxRow = MAXROW )
+[[nodiscard]] inline SCROW SanitizeRow( SCROW nRow, SCROW nMaxRow )
{
assert(nMaxRow == MAXROW); // temporary to debug jumbo sheets work
return nRow < 0 ? 0 : (nRow > nMaxRow ? nMaxRow : nRow);
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 623f94945943..eca794a657a5 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -218,6 +218,7 @@ public:
const OUString& rName ) const = 0;
virtual void makeExternalRefStr(
+ ScSheetLimits& rLimits,
OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 nFileId, const OUString& rFileName,
const OUString& rTabName, const ScSingleRefData& rRef ) const = 0;
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index a6e2299054b9..055095f485a2 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -24,6 +24,8 @@
#include "scdllapi.h"
#include "calcmacros.hxx"
+struct ScSheetLimits;
+
/// Single reference (one address) into the sheet
struct SC_DLLPUBLIC ScSingleRefData
{
@@ -55,9 +57,9 @@ public:
void InitAddress( const ScAddress& rAdr );
void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab );
/// InitAddressRel: InitFlags and set address, everything relative to rPos
- void InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos );
+ void InitAddressRel( const ScDocument* pDoc, const ScAddress& rAdr, const ScAddress& rPos );
/// InitFlags and set address, relative to rPos if rRef says so.
- void InitFromRefAddress( const ScRefAddress& rRef, const ScAddress& rPos );
+ void InitFromRefAddress( const ScDocument* pDoc, const ScRefAddress& rRef, const ScAddress& rPos );
sal_uInt8 FlagValue() const { return mnFlagValue;}
void SetColRel( bool bVal ) { Flags.bColRel = bVal; }
@@ -99,10 +101,9 @@ public:
loaded. */
bool ValidExternal(const ScDocument* pDoc) const;
- ScAddress toAbs( const ScAddress& rPos ) const;
+ ScAddress toAbs( ScSheetLimits& rLimits, const ScAddress& rPos ) const;
ScAddress toAbs( const ScDocument* pDoc, const ScAddress& rPos ) const;
- void SetAddress( const ScAddress& rAddr, const ScAddress& rPos );
- void SetAddress( const ScDocument* pDoc, const ScAddress& rAddr, const ScAddress& rPos );
+ void SetAddress( ScSheetLimits& rLimits, const ScAddress& rAddr, const ScAddress& rPos );
SCROW Row() const;
SCCOL Col() const;
SCTAB Tab() const;
@@ -131,10 +132,10 @@ struct ScComplexRefData
Ref1.InitAddress( rRange.aStart );
Ref2.InitAddress( rRange.aEnd );
}
- void InitRangeRel( const ScRange& rRange, const ScAddress& rPos )
+ void InitRangeRel( const ScDocument* pDoc, const ScRange& rRange, const ScAddress& rPos )
{
- Ref1.InitAddressRel( rRange.aStart, rPos );
- Ref2.InitAddressRel( rRange.aEnd, rPos );
+ Ref1.InitAddressRel( pDoc, rRange.aStart, rPos );
+ Ref2.InitAddressRel( pDoc, rRange.aEnd, rPos );
}
void InitRange( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2 )
@@ -144,7 +145,7 @@ struct ScComplexRefData
}
/// InitFlags and set range, relative to rPos if rRef1 and rRef2 say so.
- void InitFromRefAddresses( const ScRefAddress& rRef1, const ScRefAddress& rRef2, const ScAddress& rPos );
+ void InitFromRefAddresses( const ScDocument* pDoc, const ScRefAddress& rRef1, const ScRefAddress& rRef2, const ScAddress& rPos );
bool Valid(const ScDocument* pDoc) const;
@@ -167,12 +168,12 @@ struct ScComplexRefData
return Ref1.Col() == 0 && Ref2.Col() == MAXCOL && !Ref1.IsColRel() && !Ref2.IsColRel();
}
- SC_DLLPUBLIC ScRange toAbs( const ScAddress& rPos ) const;
+ SC_DLLPUBLIC ScRange toAbs( ScSheetLimits& rLimits, const ScAddress& rPos ) const;
SC_DLLPUBLIC ScRange toAbs( const ScDocument* pDoc, const ScAddress& rPos ) const;
/** Set a new range, assuming that the ordering of the range matches the
ordering of the reference data flags already set. */
- void SetRange( const ScRange& rRange, const ScAddress& rPos );
+ void SetRange( ScSheetLimits& rLimits, const ScRange& rRange, const ScAddress& rPos );
/** Adjust ordering (front-top-left/rear-bottom-right) to a new position. */
void PutInOrder( const ScAddress& rPos );
@@ -182,8 +183,8 @@ struct ScComplexRefData
/** Enlarge range if reference passed is not within existing range.
ScAddress position is used to calculate absolute references from
relative references. */
- ScComplexRefData& Extend( const ScSingleRefData & rRef, const ScAddress & rPos );
- ScComplexRefData& Extend( const ScComplexRefData & rRef, const ScAddress & rPos );
+ ScComplexRefData& Extend( ScSheetLimits& rLimits, const ScSingleRefData & rRef, const ScAddress & rPos );
+ ScComplexRefData& Extend( ScSheetLimits& rLimits, const ScComplexRefData & rRef, const ScAddress & rPos );
/** Increment or decrement end column unless or until sticky.
@see ScRange::IncEndColSticky()
diff --git a/sc/inc/reftokenhelper.hxx b/sc/inc/reftokenhelper.hxx
index 759d69c5762e..a63d882011d7 100644
--- a/sc/inc/reftokenhelper.hxx
+++ b/sc/inc/reftokenhelper.hxx
@@ -40,9 +40,9 @@ namespace ScRefTokenHelper
::std::vector<ScTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc,
const sal_Unicode cSep, ::formula::FormulaGrammar::Grammar eGrammar, bool bOnly3DRef = false);
- bool getRangeFromToken(ScRange& rRange, const ScTokenRef& pToken, const ScAddress& rPos, bool bExternal = false);
+ bool getRangeFromToken(const ScDocument* pDoc, ScRange& rRange, const ScTokenRef& pToken, const ScAddress& rPos, bool bExternal = false);
- void getRangeListFromTokens(ScRangeList& rRangeList, const ::std::vector<ScTokenRef>& pTokens, const ScAddress& rPos);
+ void getRangeListFromTokens(const ScDocument* pDoc, ScRangeList& rRangeList, const ::std::vector<ScTokenRef>& pTokens, const ScAddress& rPos);
/**
* Create a double reference token from a range object.
@@ -54,7 +54,7 @@ namespace ScRefTokenHelper
bool SC_DLLPUBLIC isRef(const ScTokenRef& pToken);
bool SC_DLLPUBLIC isExternalRef(const ScTokenRef& pToken);
- bool SC_DLLPUBLIC intersects(
+ bool SC_DLLPUBLIC intersects(const ScDocument* pDoc,
const ::std::vector<ScTokenRef>& rTokens, const ScTokenRef& pToken, const ScAddress& rPos);
void SC_DLLPUBLIC join(const ScDocument* pDoc, ::std::vector<ScTokenRef>& rTokens, const ScTokenRef& pToken, const ScAddress& rPos);
diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx
index b8ba5555812d..c61ce62b6b79 100644
--- a/sc/inc/sharedformula.hxx
+++ b/sc/inc/sharedformula.hxx
@@ -85,7 +85,7 @@ public:
* @return TRUE if there indeed was a split, else FALSE (e.g. split
* positions were only top or bottom cells or no formula group).
*/
- static bool splitFormulaCellGroups(CellStoreType& rCells, std::vector<SCROW>& rBounds);
+ static bool splitFormulaCellGroups(const ScDocument* pDoc, CellStoreType& rCells, std::vector<SCROW>& rBounds);
/**
* See if two specified adjacent formula cells can be merged, and if they
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 681167b9c5f6..8feb233480cf 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -449,7 +449,7 @@ public:
CellType GetCellType( const ScAddress& rPos ) const
{
- if (!ValidColRow(rPos.Col(),rPos.Row()))
+ if (!GetDoc().ValidColRow(rPos.Col(),rPos.Row()))
return CELLTYPE_NONE;
if (rPos.Col() >= aCol.size())
return CELLTYPE_NONE;
diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index ff52adac2031..433a5e33ab74 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -60,10 +60,11 @@ formula::FormulaTokenRef extendRangeReference( ScSheetLimits& rLimits, formula::
class ScSingleRefToken final : public formula::FormulaToken
{
private:
+ ScSheetLimits& mrSheetLimits; // don't use rtl::Reference to avoid ref-counting traffic
ScSingleRefData aSingleRef;
public:
- ScSingleRefToken( ScSheetLimits& , const ScSingleRefData& r, OpCode e = ocPush ) :
- FormulaToken( formula::svSingleRef, e ), aSingleRef( r ) {}
+ ScSingleRefToken( ScSheetLimits& rLimits, const ScSingleRefData& r, OpCode e = ocPush ) :
+ FormulaToken( formula::svSingleRef, e ), mrSheetLimits(rLimits), aSingleRef( r ) {}
virtual const ScSingleRefData* GetSingleRef() const override;
virtual ScSingleRefData* GetSingleRef() override;
virtual bool TextEqual( const formula::FormulaToken& rToken ) const override;
@@ -74,10 +75,11 @@ public:
class ScDoubleRefToken final : public formula::FormulaToken
{
private:
+ ScSheetLimits& mrSheetLimits; // don't use rtl::Reference to avoid ref-counting traffic
ScComplexRefData aDoubleRef;
public:
- ScDoubleRefToken( ScSheetLimits&, const ScComplexRefData& r, OpCode e = ocPush ) :
- FormulaToken( formula::svDoubleRef, e ), aDoubleRef( r ) {}
+ ScDoubleRefToken( ScSheetLimits& rLimits, const ScComplexRefData& r, OpCode e = ocPush ) :
+ FormulaToken( formula::svDoubleRef, e ), mrSheetLimits(rLimits), aDoubleRef( r ) {}
virtual const ScSingleRefData* GetSingleRef() const override;
virtual ScSingleRefData* GetSingleRef() override;
virtual const ScComplexRefData* GetDoubleRef() const override;