[Libreoffice-commits] core.git: sc/inc sc/qa sc/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 29 13:24:01 UTC 2019
sc/inc/address.hxx | 18 +--
sc/inc/chgtrack.hxx | 4
sc/inc/compiler.hxx | 4
sc/inc/markdata.hxx | 4
sc/inc/rangenam.hxx | 2
sc/inc/refdata.hxx | 16 +-
sc/inc/sharedformula.hxx | 2
sc/inc/tokenarray.hxx | 6 -
sc/qa/unit/helper/shared_test_impl.hxx | 2
sc/qa/unit/subsequent_export-test.cxx | 2
sc/qa/unit/subsequent_filters-test.cxx | 4
sc/qa/unit/ucalc_formula.cxx | 34 +++---
sc/source/core/data/column2.cxx | 2
sc/source/core/data/formulacell.cxx | 2
sc/source/core/data/markdata.cxx | 12 +-
sc/source/core/data/table7.cxx | 2
sc/source/core/tool/address.cxx | 150 ++++++++++++++-------------
sc/source/core/tool/chartlis.cxx | 2
sc/source/core/tool/chgtrack.cxx | 60 +++++-----
sc/source/core/tool/compiler.cxx | 95 +++++++++--------
sc/source/core/tool/consoli.cxx | 2
sc/source/core/tool/dbdata.cxx | 4
sc/source/core/tool/detfunc.cxx | 8 -
sc/source/core/tool/formulalogger.cxx | 2
sc/source/core/tool/interpr1.cxx | 16 +-
sc/source/core/tool/interpr4.cxx | 8 -
sc/source/core/tool/rangenam.cxx | 6 -
sc/source/core/tool/refdata.cxx | 49 ++++----
sc/source/core/tool/reftokenhelper.cxx | 8 -
sc/source/core/tool/refupdat.cxx | 32 ++---
sc/source/core/tool/sharedformula.cxx | 6 -
sc/source/core/tool/token.cxx | 54 ++++-----
sc/source/filter/excel/excrecds.cxx | 4
sc/source/filter/excel/xecontent.cxx | 9 -
sc/source/filter/excel/xedbdata.cxx | 2
sc/source/filter/excel/xeescher.cxx | 3
sc/source/filter/excel/xeextlst.cxx | 2
sc/source/filter/excel/xelink.cxx | 8 -
sc/source/filter/excel/xepivotxml.cxx | 4
sc/source/filter/excel/xestream.cxx | 12 +-
sc/source/filter/excel/xetable.cxx | 3
sc/source/filter/excel/xeview.cxx | 2
sc/source/filter/inc/xeescher.hxx | 1
sc/source/filter/inc/xestream.hxx | 6 -
sc/source/filter/inc/xetable.hxx | 1
sc/source/filter/oox/formulabuffer.cxx | 5
sc/source/filter/oox/revisionfragment.cxx | 2
sc/source/filter/xcl97/XclExpChangeTrack.cxx | 12 +-
sc/source/filter/xcl97/xcl97rec.cxx | 2
sc/source/ui/docshell/docfunc.cxx | 2
sc/source/ui/formdlg/formula.cxx | 2
sc/source/ui/inc/navipi.hxx | 6 -
sc/source/ui/navipi/navipi.cxx | 13 +-
sc/source/ui/pagedlg/areasdlg.cxx | 18 +--
sc/source/ui/sidebar/ScPanelFactory.hxx | 1
sc/source/ui/uitest/uiobject.cxx | 12 +-
sc/source/ui/unoobj/docuno.cxx | 4
sc/source/ui/vba/vbarange.cxx | 11 +
sc/source/ui/vba/vbarange.hxx | 1
sc/source/ui/vba/vbaworksheet.cxx | 4
sc/source/ui/view/cellsh1.cxx | 2
sc/source/ui/view/viewfun2.cxx | 2
sc/source/ui/view/viewfunc.cxx | 4
63 files changed, 409 insertions(+), 369 deletions(-)
New commits:
commit 0ef5c47547bec6319b853326603f3b807407fe78
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Oct 28 13:08:29 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Oct 29 14:22:48 2019 +0100
sc: rowcol: tdf#50916 convert core/tool
Change-Id: I0fe5a7ef4a79d0832802945ce1b9da4752f1d5fc
Reviewed-on: https://gerrit.libreoffice.org/81598
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 6a4c5570c877..ec63932c5fc6 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -550,9 +550,11 @@ public:
SC_DLLPUBLIC ScRefFlags ParseAny( const OUString&, const ScDocument*,
const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 );
- SC_DLLPUBLIC ScRefFlags ParseCols( const OUString&,
+ SC_DLLPUBLIC ScRefFlags ParseCols( const ScDocument* pDoc,
+ const OUString&,
const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 );
- SC_DLLPUBLIC void ParseRows( const OUString&,
+ SC_DLLPUBLIC void ParseRows( const ScDocument* pDoc,
+ const OUString&,
const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 );
/** Parse an Excel style reference up to and including the sheet name
@@ -623,11 +625,11 @@ public:
ScRange& rErrorRange, const ScDocument* pDocument = nullptr );
/** Same as Move() but with sticky end col/row anchors. */
- [[nodiscard]] SC_DLLPUBLIC bool MoveSticky( SCCOL aDeltaX, SCROW aDeltaY, SCTAB aDeltaZ,
+ [[nodiscard]] SC_DLLPUBLIC bool MoveSticky( const ScDocument* pDoc, SCCOL aDeltaX, SCROW aDeltaY, SCTAB aDeltaZ,
ScRange& rErrorRange );
- SC_DLLPUBLIC void IncColIfNotLessThan(SCCOL nStartCol, SCCOL nOffset);
- SC_DLLPUBLIC void IncRowIfNotLessThan(SCROW nStartRow, SCROW nOffset);
+ SC_DLLPUBLIC void IncColIfNotLessThan(const ScDocument* pDoc, SCCOL nStartCol, SCCOL nOffset);
+ SC_DLLPUBLIC void IncRowIfNotLessThan(const ScDocument* pDoc, SCROW nStartRow, SCROW nOffset);
SC_DLLPUBLIC void ExtendTo( const ScRange& rRange );
SC_DLLPUBLIC bool Intersects( const ScRange& rRange ) const; // do two ranges intersect?
@@ -642,12 +644,12 @@ public:
/** Increment or decrement end column unless sticky or until it becomes
sticky. Checks if the range encompasses at least two columns so should
be called before adjusting the start column. */
- void IncEndColSticky( SCCOL nDelta );
+ void IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta );
/** Increment or decrement end row unless sticky or until it becomes
sticky. Checks if the range encompasses at least two rows so should
be called before adjusting the start row. */
- void IncEndRowSticky( SCROW nDelta );
+ void IncEndRowSticky( const ScDocument* pDoc, SCROW nDelta );
inline bool operator==( const ScRange& rRange ) const;
inline bool operator!=( const ScRange& rRange ) const;
@@ -977,7 +979,7 @@ inline OUString ScColToAlpha( SCCOL nCol )
}
/// get column number of A..IV... string
-bool AlphaToCol( SCCOL& rCol, const OUString& rStr);
+bool AlphaToCol( const ScDocument* pDoc, SCCOL& rCol, const OUString& rStr);
#endif // INCLUDED_SC_INC_ADDRESS_HXX
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index 502d463a6c3e..730cedc20cd0 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -369,7 +369,7 @@ class SAL_DLLPUBLIC_RTTI ScChangeActionIns : public ScChangeAction
bool const mbEndOfList; /// whether or not a row was auto-inserted at the bottom.
- ScChangeActionIns( const ScRange& rRange, bool bEndOfList = false );
+ ScChangeActionIns( const ScDocument* pDoc, const ScRange& rRange, bool bEndOfList = false );
virtual void AddContent( ScChangeActionContent* ) override {}
virtual void DeleteCellEntries() override {}
@@ -439,7 +439,7 @@ class ScChangeActionDel final : public ScChangeAction
SCCOL nDx;
SCROW nDy;
- ScChangeActionDel( const ScRange& rRange, SCCOL nDx, SCROW nDy, ScChangeTrack* );
+ ScChangeActionDel( const ScDocument* pDoc, const ScRange& rRange, SCCOL nDx, SCROW nDy, ScChangeTrack* );
virtual void AddContent( ScChangeActionContent* ) override;
virtual void DeleteCellEntries() override;
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 8be539a606f6..b45af659ecab 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -165,7 +165,7 @@ public:
false. Used only in ScCompiler::NextNewToken() to preserve non-existing
sheet names in otherwise valid references.
*/
- bool IsValidReference() const;
+ bool IsValidReference(const ScDocument* pDoc) const;
formula::FormulaToken* CreateToken() const; // create typified token
};
@@ -189,6 +189,7 @@ public:
virtual ~Convention();
virtual void makeRefStr(
+ const ScDocument* pDoc,
OUStringBuffer& rBuffer,
formula::FormulaGrammar::Grammar eGram,
const ScAddress& rPos,
@@ -219,6 +220,7 @@ public:
const OUString& rTabName, const ScSingleRefData& rRef ) const = 0;
virtual void makeExternalRefStr(
+ const ScDocument* pDoc,
OUStringBuffer& rBuffer, const ScAddress& rPos,
sal_uInt16 nFileId, const OUString& rFileName, const std::vector<OUString>& rTabNames,
const OUString& rTabName, const ScComplexRefData& rRef ) const = 0;
diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx
index 2052c23daa52..b605c8a1bbf7 100644
--- a/sc/inc/markdata.hxx
+++ b/sc/inc/markdata.hxx
@@ -140,8 +140,8 @@ public:
void InsertTab( SCTAB nTab );
void DeleteTab( SCTAB nTab );
- void ShiftCols(SCCOL nStartCol, long nColOffset);
- void ShiftRows(SCROW nStartRow, long nRowOffset);
+ void ShiftCols(const ScDocument* pDoc, SCCOL nStartCol, long nColOffset);
+ void ShiftRows(const ScDocument* pDoc, SCROW nStartRow, long nRowOffset);
// Generate envelopes if multimarked and fills the passed ScRange object with
// the smallest range that includes the marked area plus its envelopes.
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 4ca0054050fd..93d9e49effd4 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -153,7 +153,7 @@ public:
void ValidateTabRefs();
- static void MakeValidName( OUString& rName );
+ static void MakeValidName( const ScDocument* pDoc, OUString& rName );
SC_DLLPUBLIC static IsNameValidType IsNameValid( const OUString& rName, const ScDocument* pDoc );
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 1274636d17da..f46e13e60821 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -90,14 +90,14 @@ public:
void SetRelName( bool bVal ) { Flags.bRelName = bVal; }
bool IsRelName() const { return Flags.bRelName; }
- bool Valid() const;
- bool ColValid() const;
- bool RowValid() const;
+ bool Valid(const ScDocument* pDoc) const;
+ bool ColValid(const ScDocument* pDoc) const;
+ bool RowValid(const ScDocument* pDoc) const;
bool TabValid() const;
/** In external references nTab is -1 if the external document was not
loaded but the sheet was cached, or >=0 if the external document was
loaded. */
- bool ValidExternal() const;
+ bool ValidExternal(const ScDocument* pDoc) const;
ScAddress toAbs( const ScAddress& rPos ) const;
void SetAddress( const ScAddress& rAddr, const ScAddress& rPos );
@@ -144,12 +144,12 @@ 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 );
- bool Valid() const;
+ bool Valid(const ScDocument* pDoc) const;
/** In external references nTab is -1 for the start tab and -1 for the end
tab if one sheet and the external document was not loaded but sheet was
cached, or >=0 also if more than one sheets. */
- bool ValidExternal() const;
+ bool ValidExternal(const ScDocument* pDoc) const;
/** Whether this references entire columns, A:A */
bool IsEntireCol() const
@@ -185,12 +185,12 @@ struct ScComplexRefData
/** Increment or decrement end column unless or until sticky.
@see ScRange::IncEndColSticky()
@return TRUE if changed. */
- bool IncEndColSticky( SCCOL nDelta, const ScAddress& rPos );
+ bool IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta, const ScAddress& rPos );
/** Increment or decrement end row unless or until sticky.
@see ScRange::IncEndRowSticky()
@return TRUE if changed. */
- bool IncEndRowSticky( SCROW nDelta, const ScAddress& rPos );
+ bool IncEndRowSticky( const ScDocument* pDoc, SCROW nDelta, const ScAddress& rPos );
bool IsDeleted() const;
diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx
index b7c9577b2dfa..b8ba5555812d 100644
--- a/sc/inc/sharedformula.hxx
+++ b/sc/inc/sharedformula.hxx
@@ -128,7 +128,7 @@ public:
* @param rCells cell storage container
* @param rRows row positions at which to unshare formula cells.
*/
- static void unshareFormulaCells(CellStoreType& rCells, std::vector<SCROW>& rRows);
+ static void unshareFormulaCells(const ScDocument* pDoc, CellStoreType& rCells, std::vector<SCROW>& rRows);
/**
* Have all formula cells belonging to a group start listening to their
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 721577866214..151655c3ebc5 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -90,7 +90,9 @@ public:
/** Determines the extent of direct adjacent
references. Only use with real functions, e.g.
GetOuterFuncOpCode() == ocSum ! */
- bool GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend,
+ bool GetAdjacentExtendOfOuterFuncRefs(
+ const ScDocument* pDoc,
+ SCCOLROW& nExtend,
const ScAddress& rPos, ScDirection );
formula::FormulaToken* AddRawToken( const ScRawToken& );
@@ -251,7 +253,7 @@ public:
* Create a string representation of formula token array without modifying
* the internal state of the token array.
*/
- OUString CreateString( sc::TokenStringContext& rCxt, const ScAddress& rPos ) const;
+ OUString CreateString( const ScDocument* pDoc, sc::TokenStringContext& rCxt, const ScAddress& rPos ) const;
void WrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nMaxRow );
bool NeedsWrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nMaxRow ) const;
diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx
index e75a521f0fce..6dbd67769c85 100644
--- a/sc/qa/unit/helper/shared_test_impl.hxx
+++ b/sc/qa/unit/helper/shared_test_impl.hxx
@@ -281,7 +281,7 @@ void testCeilingFloor_Impl( ScDocument& rDoc )
const char pORef[] = "Sheet1.K1";
OUString aRef(pORef);
ScAddress aPos;
- aPos.Parse(aRef);
+ aPos.Parse(aRef, &rDoc);
ASSERT_FORMULA_EQUAL(rDoc, aPos, "AND(K3:K81)", "Wrong formula.");
CPPUNIT_ASSERT_MESSAGE( OString( pORef + OStringLiteral(" result is error.")).getStr(),
isFormulaWithoutError( rDoc, aPos));
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 9ee5fd9a0e8c..dcd395784949 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -2786,7 +2786,7 @@ void ScExportTest::testSharedFormulaExportXLS()
return false;
}
- OUString aFormula = pFC->GetCode()->CreateString(aCxt, aPos);
+ OUString aFormula = pFC->GetCode()->CreateString(&rDoc, aCxt, aPos);
aExpected = "Coefficients!RC[-1]";
if (aFormula != aExpected)
{
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index b5ef29905a07..8524db0273ff 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -3835,13 +3835,13 @@ void ScFiltersTest::testEmptyRowsXLSXML()
};
ScRange aDataRange;
- aDataRange.Parse("A1:B9");
+ aDataRange.Parse("A1:B9", &rDoc);
bool bSuccess = checkOutput(&rDoc, aDataRange, aOutputCheck, "Expected output");
CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
}
ScAddress aPos;
- aPos.Parse("B9");
+ aPos.Parse("B9", &rDoc);
ASSERT_FORMULA_EQUAL(rDoc, aPos, "SUM(B4:B8)", nullptr);
xDocSh->DoClose();
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 9266c4cca840..7952c0c46e58 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -3690,7 +3690,7 @@ void Test::testFormulaRefUpdateNameDeleteRow()
sc::TokenStringContext aCxt(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH);
const ScTokenArray* pCode = pName->GetCode();
- OUString aExpr = pCode->CreateString(aCxt, ScAddress(0,0,0));
+ OUString aExpr = pCode->CreateString(m_pDoc, aCxt, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$2:$B$4"), aExpr);
// Insert a new name 'MyAddress' to reference $B$3. Note absolute row.
@@ -3702,7 +3702,7 @@ void Test::testFormulaRefUpdateNameDeleteRow()
sc::TokenStringContext aCxt2(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH);
const ScTokenArray* pCode2 = pName2->GetCode();
- OUString aExpr2 = pCode2->CreateString(aCxt2, ScAddress(0,0,0));
+ OUString aExpr2 = pCode2->CreateString(m_pDoc, aCxt2, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$3"), aExpr2);
ScDocFunc& rFunc = getDocShell().GetDocFunc();
@@ -3713,16 +3713,16 @@ void Test::testFormulaRefUpdateNameDeleteRow()
rFunc.DeleteCells(ScRange(0,2,0,m_pDoc->MaxCol(),2,0), &aMark, DelCellCmd::CellsUp, true);
// The reference in the 'MyRange' name should get updated to B2:B3.
- aExpr = pCode->CreateString(aCxt, ScAddress(0,0,0));
+ aExpr = pCode->CreateString(m_pDoc, aCxt, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$2:$B$3"), aExpr);
// The reference in the 'MyAddress' name should get updated to $B$#REF!.
- aExpr2 = pCode2->CreateString(aCxt2, ScAddress(0,0,0));
+ aExpr2 = pCode2->CreateString(m_pDoc, aCxt2, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$#REF!"), aExpr2);
// Delete row 3 again.
rFunc.DeleteCells(ScRange(0,2,0,m_pDoc->MaxCol(),2,0), &aMark, DelCellCmd::CellsUp, true);
- aExpr = pCode->CreateString(aCxt, ScAddress(0,0,0));
+ aExpr = pCode->CreateString(m_pDoc, aCxt, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$2:$B$2"), aExpr);
// Undo and check.
@@ -3735,7 +3735,7 @@ void Test::testFormulaRefUpdateNameDeleteRow()
CPPUNIT_ASSERT(pName);
pCode = pName->GetCode();
- aExpr = pCode->CreateString(aCxt, ScAddress(0,0,0));
+ aExpr = pCode->CreateString(m_pDoc, aCxt, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$2:$B$3"), aExpr);
// Undo again and check.
@@ -3745,13 +3745,13 @@ void Test::testFormulaRefUpdateNameDeleteRow()
CPPUNIT_ASSERT(pName);
pCode = pName->GetCode();
- aExpr = pCode->CreateString(aCxt, ScAddress(0,0,0));
+ aExpr = pCode->CreateString(m_pDoc, aCxt, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$2:$B$4"), aExpr);
// Delete row 2-3.
rFunc.DeleteCells(ScRange(0,1,0,m_pDoc->MaxCol(),2,0), &aMark, DelCellCmd::CellsUp, true);
- aExpr = pCode->CreateString(aCxt, ScAddress(0,0,0));
+ aExpr = pCode->CreateString(m_pDoc, aCxt, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$2:$B$2"), aExpr);
// Undo and check.
@@ -3761,14 +3761,14 @@ void Test::testFormulaRefUpdateNameDeleteRow()
CPPUNIT_ASSERT(pName);
pCode = pName->GetCode();
- aExpr = pCode->CreateString(aCxt, ScAddress(0,0,0));
+ aExpr = pCode->CreateString(m_pDoc, aCxt, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$2:$B$4"), aExpr);
pName2 = m_pDoc->GetRangeName()->findByUpperName("MYADDRESS");
CPPUNIT_ASSERT(pName2);
pCode2 = pName2->GetCode();
- aExpr2 = pCode2->CreateString(aCxt2, ScAddress(0,0,0));
+ aExpr2 = pCode2->CreateString(m_pDoc, aCxt2, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$3"), aExpr2);
m_pDoc->InsertTab(1, "test2");
@@ -3781,7 +3781,7 @@ void Test::testFormulaRefUpdateNameDeleteRow()
CPPUNIT_ASSERT(pName);
pCode = pName->GetCode();
- aExpr = pCode->CreateString(aCxt, ScAddress(0,0,0));
+ aExpr = pCode->CreateString(m_pDoc, aCxt, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$2:$B$4"), aExpr);
pName2 = m_pDoc->GetRangeName()->findByUpperName("MYADDRESS");
@@ -3794,7 +3794,7 @@ void Test::testFormulaRefUpdateNameDeleteRow()
// relative to its base position on sheet 0 (same for the 'MyRange' range,
// which is the reason why it is not updated either).
// This is a tad confusing...
- aExpr2 = pCode2->CreateString(aCxt2, ScAddress(0,0,0));
+ aExpr2 = pCode2->CreateString(m_pDoc, aCxt2, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$B$3"), aExpr2);
m_pDoc->DeleteTab(1);
@@ -4022,7 +4022,7 @@ void Test::testFormulaRefUpdateNameDelete()
m_pDoc->DeleteCol(1, 0, 3, 0, 0, 1);
const ScTokenArray* pCode = pName->GetCode();
sc::TokenStringContext aCxt(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH);
- OUString aExpr = pCode->CreateString(aCxt, ScAddress(0,0,0));
+ OUString aExpr = pCode->CreateString(m_pDoc, aCxt, ScAddress(0,0,0));
CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$1"), aExpr);
m_pDoc->DeleteTab(0);
@@ -4181,7 +4181,7 @@ void Test::testTokenArrayRefUpdateMove()
ScCompiler aComp(m_pDoc, aPos, m_pDoc->GetGrammar());
std::unique_ptr<ScTokenArray> pArray(aComp.CompileString(aTest));
- OUString aStr = pArray->CreateString(aCxt, aPos);
+ OUString aStr = pArray->CreateString(m_pDoc, aCxt, aPos);
CPPUNIT_ASSERT_EQUAL(aTest, aStr);
@@ -4189,7 +4189,7 @@ void Test::testTokenArrayRefUpdateMove()
// string should not change.
pArray->AdjustReferenceOnMove(aRefCxt, aPos, aPos);
- aStr = pArray->CreateString(aCxt, aPos);
+ aStr = pArray->CreateString(m_pDoc, aCxt, aPos);
CPPUNIT_ASSERT_EQUAL(aTest, aStr);
}
@@ -8459,7 +8459,7 @@ void Test::testRefR1C1WholeCol()
ScCompiler aComp(m_pDoc, aPos, FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
std::unique_ptr<ScTokenArray> pTokens(aComp.CompileString("=C[10]"));
sc::TokenStringContext aCxt(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH);
- OUString aFormula = pTokens->CreateString(aCxt, aPos);
+ OUString aFormula = pTokens->CreateString(m_pDoc, aCxt, aPos);
CPPUNIT_ASSERT_EQUAL(OUString("L:L"), aFormula);
@@ -8474,7 +8474,7 @@ void Test::testRefR1C1WholeRow()
ScCompiler aComp(m_pDoc, aPos, FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
std::unique_ptr<ScTokenArray> pTokens(aComp.CompileString("=R[3]"));
sc::TokenStringContext aCxt(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH);
- OUString aFormula = pTokens->CreateString(aCxt, aPos);
+ OUString aFormula = pTokens->CreateString(m_pDoc, aCxt, aPos);
CPPUNIT_ASSERT_EQUAL(OUString("5:5"), aFormula);
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index dfcee81cdde0..ad7a89d0a0f5 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1688,7 +1688,7 @@ struct ColumnStorageDumper
void printFormula(const ScFormulaCell* pCell) const
{
sc::TokenStringContext aCxt(mpDoc, mpDoc->GetGrammar());
- OUString aFormula = pCell->GetCode()->CreateString(aCxt, pCell->aPos);
+ OUString aFormula = pCell->GetCode()->CreateString(mpDoc, aCxt, pCell->aPos);
cout << " * formula: " << aFormula << endl;
}
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index a70fa9d702d7..c2886ed2ae28 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -5480,7 +5480,7 @@ void ScFormulaCell::Dump() const
}
sc::TokenStringContext aCxt(pDocument, pDocument->GetGrammar());
- cout << " * code: " << pCode->CreateString(aCxt, aPos) << endl;
+ cout << " * code: " << pCode->CreateString(pDocument, aCxt, aPos) << endl;
FormulaError nErrCode = pCode->GetCodeError();
cout << " * code error: ";
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index 60e7db0fb0ca..33c833e191ec 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -637,29 +637,29 @@ void ScMarkData::DeleteTab( SCTAB nTab )
maTabMarked.swap(tabMarked);
}
-void ScMarkData::ShiftCols(SCCOL nStartCol, long nColOffset)
+void ScMarkData::ShiftCols(const ScDocument* pDoc, SCCOL nStartCol, long nColOffset)
{
if (bMarked)
{
- aMarkRange.IncColIfNotLessThan(nStartCol, nColOffset);
+ aMarkRange.IncColIfNotLessThan(pDoc, nStartCol, nColOffset);
}
else if (bMultiMarked)
{
aMultiSel.ShiftCols(nStartCol, nColOffset);
- aMultiRange.IncColIfNotLessThan(nStartCol, nColOffset);
+ aMultiRange.IncColIfNotLessThan(pDoc, nStartCol, nColOffset);
}
}
-void ScMarkData::ShiftRows(SCROW nStartRow, long nRowOffset)
+void ScMarkData::ShiftRows(const ScDocument* pDoc, SCROW nStartRow, long nRowOffset)
{
if (bMarked)
{
- aMarkRange.IncRowIfNotLessThan(nStartRow, nRowOffset);
+ aMarkRange.IncRowIfNotLessThan(pDoc, nStartRow, nRowOffset);
}
else if (bMultiMarked)
{
aMultiSel.ShiftRows(nStartRow, nRowOffset);
- aMultiRange.IncRowIfNotLessThan(nStartRow, nRowOffset);
+ aMultiRange.IncRowIfNotLessThan(pDoc, nStartRow, nRowOffset);
}
}
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index 203b1e417dbb..76404c83afa9 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -277,7 +277,7 @@ void ScTable::UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows )
if (!IsColValid(nCol))
return;
- sc::SharedFormulaUtil::unshareFormulaCells(aCol[nCol].maCells, rRows);
+ sc::SharedFormulaUtil::unshareFormulaCells(pDocument, aCol[nCol].maCells, rRows);
}
void ScTable::RegroupFormulaCells( SCCOL nCol )
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 1020a8a47cc3..2ac28a46bb38 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -816,7 +816,7 @@ static ScRefFlags lcl_ScRange_Parse_XL_R1C1( ScRange& r,
ScRefFlags::COL_VALID | ScRefFlags::COL2_VALID |
ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS;
r.aStart.SetCol( 0 );
- r.aEnd.SetCol( MAXCOL );
+ r.aEnd.SetCol( pDoc->MaxCol() );
return bOnlyAcceptSingle ? ScRefFlags::ZERO : nFlags;
}
@@ -887,7 +887,7 @@ static ScRefFlags lcl_ScRange_Parse_XL_R1C1( ScRange& r,
ScRefFlags::ROW_VALID | ScRefFlags::ROW2_VALID |
ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS;
r.aStart.SetRow( 0 );
- r.aEnd.SetRow( MAXROW );
+ r.aEnd.SetRow( pDoc->MaxRow() );
return bOnlyAcceptSingle ? ScRefFlags::ZERO : nFlags;
}
@@ -895,7 +895,8 @@ static ScRefFlags lcl_ScRange_Parse_XL_R1C1( ScRange& r,
return nBailOutFlags;
}
-static const sal_Unicode* lcl_a1_get_col( const sal_Unicode* p,
+static const sal_Unicode* lcl_a1_get_col( const ScDocument* pDoc,
+ const sal_Unicode* p,
ScAddress* pAddr,
ScRefFlags* nFlags,
const OUString* pErrRef )
@@ -920,9 +921,9 @@ static const sal_Unicode* lcl_a1_get_col( const sal_Unicode* p,
return nullptr;
nCol = sal::static_int_cast<SCCOL>( rtl::toAsciiUpperCase( *p++ ) - 'A' );
- while (nCol <= MAXCOL && rtl::isAsciiAlpha(*p))
+ while (nCol <= pDoc->MaxCol() && rtl::isAsciiAlpha(*p))
nCol = sal::static_int_cast<SCCOL>( ((nCol + 1) * 26) + rtl::toAsciiUpperCase( *p++ ) - 'A' );
- if( nCol > MAXCOL || rtl::isAsciiAlpha( *p ) )
+ if( nCol > pDoc->MaxCol() || rtl::isAsciiAlpha( *p ) )
return nullptr;
*nFlags |= ScRefFlags::COL_VALID;
@@ -931,7 +932,8 @@ static const sal_Unicode* lcl_a1_get_col( const sal_Unicode* p,
return p;
}
-static const sal_Unicode* lcl_a1_get_row( const sal_Unicode* p,
+static const sal_Unicode* lcl_a1_get_row( const ScDocument* pDoc,
+ const sal_Unicode* p,
ScAddress* pAddr,
ScRefFlags* nFlags,
const OUString* pErrRef )
@@ -954,7 +956,7 @@ static const sal_Unicode* lcl_a1_get_row( const sal_Unicode* p,
}
n = sal_Unicode_strtol( p, &pEnd ) - 1;
- if( nullptr == pEnd || p == pEnd || n < 0 || n > MAXROW )
+ if( nullptr == pEnd || p == pEnd || n < 0 || n > pDoc->MaxRow() )
return nullptr;
*nFlags |= ScRefFlags::ROW_VALID;
@@ -1004,24 +1006,24 @@ static ScRefFlags lcl_ScRange_Parse_XL_A1( ScRange& r,
if( nullptr == p )
return nBailOutFlags;
- tmp1 = lcl_a1_get_col( p, &r.aStart, &nFlags, pErrRef);
+ tmp1 = lcl_a1_get_col( pDoc, p, &r.aStart, &nFlags, pErrRef);
if( tmp1 == nullptr ) // Is it a row only reference 3:5
{
if( bOnlyAcceptSingle ) // by definition full row refs are ranges
return nBailOutFlags;
- tmp1 = lcl_a1_get_row( p, &r.aStart, &nFlags, pErrRef);
+ tmp1 = lcl_a1_get_row( pDoc, p, &r.aStart, &nFlags, pErrRef);
tmp1 = lcl_eatWhiteSpace( tmp1 );
if( !tmp1 || *tmp1++ != ':' ) // Even a singleton requires ':' (eg 2:2)
return nBailOutFlags;
tmp1 = lcl_eatWhiteSpace( tmp1 );
- tmp2 = lcl_a1_get_row( tmp1, &r.aEnd, &nFlags2, pErrRef);
+ tmp2 = lcl_a1_get_row( pDoc, tmp1, &r.aEnd, &nFlags2, pErrRef);
if( !tmp2 || *tmp2 != 0 ) // Must have fully parsed a singleton.
return nBailOutFlags;
- r.aStart.SetCol( 0 ); r.aEnd.SetCol( MAXCOL );
+ r.aStart.SetCol( 0 ); r.aEnd.SetCol( pDoc->MaxCol() );
nFlags |=
ScRefFlags::COL_VALID | ScRefFlags::COL2_VALID |
ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS;
@@ -1029,7 +1031,7 @@ static ScRefFlags lcl_ScRange_Parse_XL_A1( ScRange& r,
return nFlags;
}
- tmp2 = lcl_a1_get_row( tmp1, &r.aStart, &nFlags, pErrRef);
+ tmp2 = lcl_a1_get_row( pDoc, tmp1, &r.aStart, &nFlags, pErrRef);
if( tmp2 == nullptr ) // check for col only reference F:H
{
if( bOnlyAcceptSingle ) // by definition full col refs are ranges
@@ -1040,11 +1042,11 @@ static ScRefFlags lcl_ScRange_Parse_XL_A1( ScRange& r,
return nBailOutFlags;
tmp1 = lcl_eatWhiteSpace( tmp1 );
- tmp2 = lcl_a1_get_col( tmp1, &r.aEnd, &nFlags2, pErrRef);
+ tmp2 = lcl_a1_get_col( pDoc, tmp1, &r.aEnd, &nFlags2, pErrRef);
if( !tmp2 || *tmp2 != 0 ) // Must have fully parsed a singleton.
return nBailOutFlags;
- r.aStart.SetRow( 0 ); r.aEnd.SetRow( MAXROW );
+ r.aStart.SetRow( 0 ); r.aEnd.SetRow( pDoc->MaxRow() );
nFlags |=
ScRefFlags::ROW_VALID | ScRefFlags::ROW2_VALID |
ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS;
@@ -1088,7 +1090,7 @@ static ScRefFlags lcl_ScRange_Parse_XL_A1( ScRange& r,
}
p = lcl_eatWhiteSpace( tmp2+1 ); // after ':'
- tmp1 = lcl_a1_get_col( p, &r.aEnd, &nFlags2, pErrRef);
+ tmp1 = lcl_a1_get_col( pDoc, p, &r.aEnd, &nFlags2, pErrRef);
if( !tmp1 && aEndTabName.isEmpty() ) // Probably the aEndTabName was specified after the first range
{
p = lcl_XL_ParseSheetRef( p, aEndTabName, false, nullptr, pErrRef);
@@ -1102,13 +1104,13 @@ static ScRefFlags lcl_ScRange_Parse_XL_A1( ScRange& r,
}
if (*p == '!' || *p == ':')
p = lcl_eatWhiteSpace( p+1 );
- tmp1 = lcl_a1_get_col( p, &r.aEnd, &nFlags2, pErrRef);
+ tmp1 = lcl_a1_get_col( pDoc, p, &r.aEnd, &nFlags2, pErrRef);
}
}
if( !tmp1 ) // strange, but maybe valid singleton
return isValidSingleton( nFlags, nFlags2) ? nFlags : (nFlags & ~ScRefFlags::VALID);
- tmp2 = lcl_a1_get_row( tmp1, &r.aEnd, &nFlags2, pErrRef);
+ tmp2 = lcl_a1_get_row( pDoc, tmp1, &r.aEnd, &nFlags2, pErrRef);
if( !tmp2 ) // strange, but maybe valid singleton
return isValidSingleton( nFlags, nFlags2) ? nFlags : (nFlags & ~ScRefFlags::VALID);
@@ -1278,13 +1280,13 @@ static ScRefFlags lcl_ScAddress_Parse_OOo( const sal_Unicode* p, const ScDocumen
if (rtl::isAsciiAlpha( *p ))
{
nCol = sal::static_int_cast<SCCOL>( rtl::toAsciiUpperCase( *p++ ) - 'A' );
- while (nCol < MAXCOL && rtl::isAsciiAlpha(*p))
+ while (nCol < pDoc->MaxCol() && rtl::isAsciiAlpha(*p))
nCol = sal::static_int_cast<SCCOL>( ((nCol + 1) * 26) + rtl::toAsciiUpperCase( *p++ ) - 'A' );
}
else
nBits = ScRefFlags::ZERO;
- if (nCol > MAXCOL || (*p && *p != '$' && !rtl::isAsciiDigit( *p ) &&
+ if (nCol > pDoc->MaxCol() || (*p && *p != '$' && !rtl::isAsciiDigit( *p ) &&
(!pErrRef || !lcl_isString( p, *pErrRef))))
nBits = ScRefFlags::ZERO;
if( nBits == ScRefFlags::ZERO )
@@ -1328,7 +1330,7 @@ static ScRefFlags lcl_ScAddress_Parse_OOo( const sal_Unicode* p, const ScDocumen
long n = rtl_ustr_toInt32( p, 10 ) - 1;
while (rtl::isAsciiDigit( *p ))
p++;
- if( n < 0 || n > MAXROW )
+ if( n < 0 || n > pDoc->MaxRow() )
nBits = ScRefFlags::ZERO;
nRow = static_cast<SCROW>(n);
}
@@ -1646,14 +1648,14 @@ static ScRefFlags lcl_ScRange_Parse_OOo( ScRange& rRange,
if (nRawRes1 & ScRefFlags::COL_VALID)
{
rRange.aStart.SetRow(0);
- rRange.aEnd.SetRow(MAXROW);
+ rRange.aEnd.SetRow(pDoc->MaxRow());
nRes1 |= ScRefFlags::ROW_VALID | ScRefFlags::ROW_ABS;
nRes2 |= ScRefFlags::ROW_VALID | ScRefFlags::ROW_ABS;
}
else
{
rRange.aStart.SetCol(0);
- rRange.aEnd.SetCol(MAXCOL);
+ rRange.aEnd.SetCol(pDoc->MaxCol());
nRes1 |= ScRefFlags::COL_VALID | ScRefFlags::COL_ABS;
nRes2 |= ScRefFlags::COL_VALID | ScRefFlags::COL_ABS;
}
@@ -1664,14 +1666,14 @@ static ScRefFlags lcl_ScRange_Parse_OOo( ScRange& rRange,
// as such. If the sticky reference parts are not both
// absolute or relative, assume that the user thought about
// something we should not touch.
- if (rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW &&
+ if (rRange.aStart.Row() == 0 && rRange.aEnd.Row() == pDoc->MaxRow() &&
((nRes1 & ScRefFlags::ROW_ABS) == ScRefFlags::ZERO) &&
((nRes2 & ScRefFlags::ROW_ABS) == ScRefFlags::ZERO))
{
nRes1 |= ScRefFlags::ROW_ABS;
nRes2 |= ScRefFlags::ROW_ABS;
}
- else if (rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL &&
+ else if (rRange.aStart.Col() == 0 && rRange.aEnd.Col() == pDoc->MaxCol() &&
((nRes1 & ScRefFlags::COL_ABS) == ScRefFlags::ZERO) && ((nRes2 & ScRefFlags::COL_ABS) == ScRefFlags::ZERO))
{
nRes1 |= ScRefFlags::COL_ABS;
@@ -1779,7 +1781,8 @@ ScRefFlags ScRange::ParseAny( const OUString& rString, const ScDocument* pDoc,
}
// Parse only full row references
-ScRefFlags ScRange::ParseCols( const OUString& rStr,
+ScRefFlags ScRange::ParseCols( const ScDocument* pDoc,
+ const OUString& rStr,
const ScAddress::Details& rDetails )
{
if (rStr.isEmpty())
@@ -1795,11 +1798,11 @@ ScRefFlags ScRange::ParseCols( const OUString& rStr,
case formula::FormulaGrammar::CONV_OOO: // No full col refs in OOO yet, assume XL notation
case formula::FormulaGrammar::CONV_XL_A1:
case formula::FormulaGrammar::CONV_XL_OOX:
- if (nullptr != (p = lcl_a1_get_col( p, &aStart, &ignored, nullptr) ) )
+ if (nullptr != (p = lcl_a1_get_col( pDoc, p, &aStart, &ignored, nullptr) ) )
{
if( p[0] == ':')
{
- if( nullptr != (p = lcl_a1_get_col( p+1, &aEnd, &ignored, nullptr)))
+ if( nullptr != (p = lcl_a1_get_col( pDoc, p+1, &aEnd, &ignored, nullptr)))
{
nRes = ScRefFlags::COL_VALID;
}
@@ -1837,7 +1840,8 @@ ScRefFlags ScRange::ParseCols( const OUString& rStr,
}
// Parse only full row references
-void ScRange::ParseRows( const OUString& rStr,
+void ScRange::ParseRows( const ScDocument* pDoc,
+ const OUString& rStr,
const ScAddress::Details& rDetails )
{
if (rStr.isEmpty())
@@ -1852,11 +1856,11 @@ void ScRange::ParseRows( const OUString& rStr,
case formula::FormulaGrammar::CONV_OOO: // No full row refs in OOO yet, assume XL notation
case formula::FormulaGrammar::CONV_XL_A1:
case formula::FormulaGrammar::CONV_XL_OOX:
- if (nullptr != (p = lcl_a1_get_row( p, &aStart, &ignored, nullptr) ) )
+ if (nullptr != (p = lcl_a1_get_row( pDoc, p, &aStart, &ignored, nullptr) ) )
{
if( p[0] == ':')
{
- p = lcl_a1_get_row( p+1, &aEnd, &ignored, nullptr);
+ p = lcl_a1_get_row( pDoc, p+1, &aEnd, &ignored, nullptr);
}
else
{
@@ -2233,14 +2237,14 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc,
case formula::FormulaGrammar::CONV_XL_A1:
case formula::FormulaGrammar::CONV_XL_OOX:
lcl_ScRange_Format_XL_Header( r, *this, nFlags, pDoc, rDetails );
- if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL && !bFullAddressNotation )
+ if( aStart.Col() == 0 && aEnd.Col() >= pDoc->MaxCol() && !bFullAddressNotation )
{
// Full col refs always require 2 rows (2:2)
lcl_a1_append_r( r, aStart.Row(), (nFlags & ScRefFlags::ROW_ABS) != ScRefFlags::ZERO );
r.append(":");
lcl_a1_append_r( r, aEnd.Row(), (nFlags & ScRefFlags::ROW2_ABS) != ScRefFlags::ZERO );
}
- else if( aStart.Row() == 0 && aEnd.Row() >= MAXROW && !bFullAddressNotation )
+ else if( aStart.Row() == 0 && aEnd.Row() >= pDoc->MaxRow() && !bFullAddressNotation )
{
// Full row refs always require 2 cols (A:A)
lcl_a1_append_c( r, aStart.Col(), (nFlags & ScRefFlags::COL_ABS) != ScRefFlags::ZERO );
@@ -2264,7 +2268,7 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc,
case formula::FormulaGrammar::CONV_XL_R1C1:
lcl_ScRange_Format_XL_Header( r, *this, nFlags, pDoc, rDetails );
- if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL && !bFullAddressNotation )
+ if( aStart.Col() == 0 && aEnd.Col() >= pDoc->MaxCol() && !bFullAddressNotation )
{
lcl_r1c1_append_r( r, aStart.Row(), (nFlags & ScRefFlags::ROW_ABS) != ScRefFlags::ZERO, rDetails );
if( aStart.Row() != aEnd.Row() ||
@@ -2273,7 +2277,7 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc,
lcl_r1c1_append_r( r, aEnd.Row(), (nFlags & ScRefFlags::ROW2_ABS) != ScRefFlags::ZERO, rDetails );
}
}
- else if( aStart.Row() == 0 && aEnd.Row() >= MAXROW && !bFullAddressNotation )
+ else if( aStart.Row() == 0 && aEnd.Row() >= pDoc->MaxRow() && !bFullAddressNotation )
{
lcl_r1c1_append_c( r, aStart.Col(), (nFlags & ScRefFlags::COL_ABS) != ScRefFlags::ZERO, rDetails );
if( aStart.Col() != aEnd.Col() ||
@@ -2302,6 +2306,8 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc,
bool ScAddress::Move( SCCOL dx, SCROW dy, SCTAB dz, ScAddress& rErrorPos, const ScDocument* pDoc )
{
SCTAB nMaxTab = pDoc ? pDoc->GetTableCount() : MAXTAB;
+ SCCOL nMaxCol = pDoc ? pDoc->MaxCol() : MAXCOL;
+ SCROW nMaxRow = pDoc ? pDoc->MaxRow() : MAXROW;
dx = Col() + dx;
dy = Row() + dy;
dz = Tab() + dz;
@@ -2312,9 +2318,9 @@ bool ScAddress::Move( SCCOL dx, SCROW dy, SCTAB dz, ScAddress& rErrorPos, const
dx = 0;
bValid = false;
}
- else if( dx > MAXCOL )
+ else if( dx > nMaxCol )
{
- dx = MAXCOL;
+ dx = nMaxCol;
bValid =false;
}
rErrorPos.SetRow(dy);
@@ -2323,9 +2329,9 @@ bool ScAddress::Move( SCCOL dx, SCROW dy, SCTAB dz, ScAddress& rErrorPos, const
dy = 0;
bValid = false;
}
- else if( dy > MAXROW )
+ else if( dy > nMaxRow )
{
- dy = MAXROW;
+ dy = nMaxRow;
bValid =false;
}
rErrorPos.SetTab(dz);
@@ -2347,85 +2353,87 @@ bool ScAddress::Move( SCCOL dx, SCROW dy, SCTAB dz, ScAddress& rErrorPos, const
bool ScRange::Move( SCCOL dx, SCROW dy, SCTAB dz, ScRange& rErrorRange, const ScDocument* pDoc )
{
- if (dy && aStart.Row() == 0 && aEnd.Row() == MAXROW)
+ SCCOL nMaxCol = pDoc ? pDoc->MaxCol() : MAXCOL;
+ SCROW nMaxRow = pDoc ? pDoc->MaxRow() : MAXROW;
+ if (dy && aStart.Row() == 0 && aEnd.Row() == nMaxRow)
dy = 0; // Entire column not to be moved.
- if (dx && aStart.Col() == 0 && aEnd.Col() == MAXCOL)
+ if (dx && aStart.Col() == 0 && aEnd.Col() == nMaxCol)
dx = 0; // Entire row not to be moved.
bool b = aStart.Move( dx, dy, dz, rErrorRange.aStart, pDoc );
b &= aEnd.Move( dx, dy, dz, rErrorRange.aEnd, pDoc );
return b;
}
-bool ScRange::MoveSticky( SCCOL dx, SCROW dy, SCTAB dz, ScRange& rErrorRange )
+bool ScRange::MoveSticky( const ScDocument* pDoc, SCCOL dx, SCROW dy, SCTAB dz, ScRange& rErrorRange )
{
bool bColRange = (aStart.Col() < aEnd.Col());
bool bRowRange = (aStart.Row() < aEnd.Row());
- if (dy && aStart.Row() == 0 && aEnd.Row() == MAXROW)
+ if (dy && aStart.Row() == 0 && aEnd.Row() == pDoc->MaxRow())
dy = 0; // Entire column not to be moved.
- if (dx && aStart.Col() == 0 && aEnd.Col() == MAXCOL)
+ if (dx && aStart.Col() == 0 && aEnd.Col() == pDoc->MaxCol())
dx = 0; // Entire row not to be moved.
bool b1 = aStart.Move( dx, dy, dz, rErrorRange.aStart );
- if (dx && bColRange && aEnd.Col() == MAXCOL)
+ if (dx && bColRange && aEnd.Col() == pDoc->MaxCol())
dx = 0; // End column sticky.
- if (dy && bRowRange && aEnd.Row() == MAXROW)
+ if (dy && bRowRange && aEnd.Row() == pDoc->MaxRow())
dy = 0; // End row sticky.
SCTAB nOldTab = aEnd.Tab();
bool b2 = aEnd.Move( dx, dy, dz, rErrorRange.aEnd );
if (!b2)
{
// End column or row of a range may have become sticky.
- bColRange = (!dx || (bColRange && aEnd.Col() == MAXCOL));
+ bColRange = (!dx || (bColRange && aEnd.Col() == pDoc->MaxCol()));
if (dx && bColRange)
- rErrorRange.aEnd.SetCol(MAXCOL);
- bRowRange = (!dy || (bRowRange && aEnd.Row() == MAXROW));
+ rErrorRange.aEnd.SetCol(pDoc->MaxCol());
+ bRowRange = (!dy || (bRowRange && aEnd.Row() == pDoc->MaxRow()));
if (dy && bRowRange)
- rErrorRange.aEnd.SetRow(MAXROW);
+ rErrorRange.aEnd.SetRow(pDoc->MaxRow());
b2 = bColRange && bRowRange && (aEnd.Tab() - nOldTab == dz);
}
return b1 && b2;
}
-void ScRange::IncColIfNotLessThan(SCCOL nStartCol, SCCOL nOffset)
+void ScRange::IncColIfNotLessThan(const ScDocument* pDoc, SCCOL nStartCol, SCCOL nOffset)
{
if (aStart.Col() >= nStartCol)
{
aStart.IncCol(nOffset);
if (aStart.Col() < 0)
aStart.SetCol(0);
- else if(aStart.Col() > MAXCOL)
- aStart.SetCol(MAXCOL);
+ else if(aStart.Col() > pDoc->MaxCol())
+ aStart.SetCol(pDoc->MaxCol());
}
if (aEnd.Col() >= nStartCol)
{
aEnd.IncCol(nOffset);
if (aEnd.Col() < 0)
aEnd.SetCol(0);
- else if(aEnd.Col() > MAXCOL)
- aEnd.SetCol(MAXCOL);
+ else if(aEnd.Col() > pDoc->MaxCol())
+ aEnd.SetCol(pDoc->MaxCol());
}
}
-void ScRange::IncRowIfNotLessThan(SCROW nStartRow, SCROW nOffset)
+void ScRange::IncRowIfNotLessThan(const ScDocument* pDoc, SCROW nStartRow, SCROW nOffset)
{
if (aStart.Row() >= nStartRow)
{
aStart.IncRow(nOffset);
if (aStart.Row() < 0)
aStart.SetRow(0);
- else if(aStart.Row() > MAXROW)
- aStart.SetRow(MAXROW);
+ else if(aStart.Row() > pDoc->MaxRow())
+ aStart.SetRow(pDoc->MaxRow());
}
if (aEnd.Row() >= nStartRow)
{
aEnd.IncRow(nOffset);
if (aEnd.Row() < 0)
aEnd.SetRow(0);
- else if(aEnd.Row() > MAXROW)
- aEnd.SetRow(MAXROW);
+ else if(aEnd.Row() > pDoc->MaxRow())
+ aEnd.SetRow(pDoc->MaxRow());
}
}
-void ScRange::IncEndColSticky( SCCOL nDelta )
+void ScRange::IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta )
{
SCCOL nCol = aEnd.Col();
if (aStart.Col() >= nCol)
@@ -2435,17 +2443,17 @@ void ScRange::IncEndColSticky( SCCOL nDelta )
return;
}
- if (nCol == MAXCOL)
+ if (nCol == pDoc->MaxCol())
// already sticky
return;
- if (nCol < MAXCOL)
- aEnd.SetCol( ::std::min( static_cast<SCCOL>(nCol + nDelta), MAXCOL));
+ if (nCol < pDoc->MaxCol())
+ aEnd.SetCol( ::std::min( static_cast<SCCOL>(nCol + nDelta), pDoc->MaxCol()));
else
- aEnd.IncCol( nDelta); // was greater than MAXCOL, caller should know...
+ aEnd.IncCol( nDelta); // was greater than pDoc->MaxCol(), caller should know...
}
-void ScRange::IncEndRowSticky( SCROW nDelta )
+void ScRange::IncEndRowSticky( const ScDocument* pDoc, SCROW nDelta )
{
SCROW nRow = aEnd.Row();
if (aStart.Row() >= nRow)
@@ -2455,14 +2463,14 @@ void ScRange::IncEndRowSticky( SCROW nDelta )
return;
}
- if (nRow == MAXROW)
+ if (nRow == pDoc->MaxRow())
// already sticky
return;
- if (nRow < MAXROW)
- aEnd.SetRow( ::std::min( static_cast<SCROW>(nRow + nDelta), MAXROW));
+ if (nRow < pDoc->MaxRow())
+ aEnd.SetRow( ::std::min( static_cast<SCROW>(nRow + nDelta), pDoc->MaxRow()));
else
- aEnd.IncRow( nDelta); // was greater than MAXROW, caller should know...
+ aEnd.IncRow( nDelta); // was greater than pDoc->MaxRow(), caller should know...
}
OUString ScAddress::GetColRowString() const
@@ -2511,13 +2519,13 @@ OUString ScRefAddress::GetRefString( const ScDocument* pDoc, SCTAB nActTab,
return aAdr.Format(nFlags, pDoc, rDetails);
}
-bool AlphaToCol( SCCOL& rCol, const OUString& rStr)
+bool AlphaToCol( const ScDocument* pDoc, SCCOL& rCol, const OUString& rStr)
{
SCCOL nResult = 0;
sal_Int32 nStop = rStr.getLength();
sal_Int32 nPos = 0;
sal_Unicode c;
- while (nResult <= MAXCOL && nPos < nStop && (c = rStr[nPos]) != 0 &&
+ while (nResult <= pDoc->MaxCol() && nPos < nStop && (c = rStr[nPos]) != 0 &&
rtl::isAsciiAlpha(c))
{
if (nPos > 0)
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index 79f164f87a5e..dd19b56985f1 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -595,7 +595,7 @@ void ScChartListenerCollection::SetRangeDirty( const ScRange& rRange )
void ScChartListenerCollection::UpdateChartsContainingTab( SCTAB nTab )
{
- ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
+ ScRange aRange( 0, 0, nTab, pDoc->MaxCol(), pDoc->MaxRow(), nTab );
for (auto const& it : m_Listeners)
{
it.second->UpdateChartIntersecting(aRange);
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 991c25615def..b509b167308f 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -647,15 +647,15 @@ void ScChangeAction::AddDependent( sal_uLong nActionNumber,
}
// ScChangeActionIns
-ScChangeActionIns::ScChangeActionIns( const ScRange& rRange, bool bEndOfList ) :
+ScChangeActionIns::ScChangeActionIns( const ScDocument* pDoc, const ScRange& rRange, bool bEndOfList ) :
ScChangeAction(SC_CAT_NONE, rRange),
mbEndOfList(bEndOfList)
{
- if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL )
+ if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == pDoc->MaxCol() )
{
aBigRange.aStart.SetCol( nInt32Min );
aBigRange.aEnd.SetCol( nInt32Max );
- if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW )
+ if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == pDoc->MaxRow() )
{
SetType( SC_CAT_INSERT_TABS );
aBigRange.aStart.SetRow( nInt32Min );
@@ -664,7 +664,7 @@ ScChangeActionIns::ScChangeActionIns( const ScRange& rRange, bool bEndOfList ) :
else
SetType( SC_CAT_INSERT_ROWS );
}
- else if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW )
+ else if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == pDoc->MaxRow() )
{
SetType( SC_CAT_INSERT_COLS );
aBigRange.aStart.SetRow( nInt32Min );
@@ -763,7 +763,7 @@ bool ScChangeActionIns::Reject( ScDocument* pDoc )
}
// ScChangeActionDel
-ScChangeActionDel::ScChangeActionDel( const ScRange& rRange,
+ScChangeActionDel::ScChangeActionDel( const ScDocument* pDoc, const ScRange& rRange,
SCCOL nDxP, SCROW nDyP, ScChangeTrack* pTrackP )
:
ScChangeAction( SC_CAT_NONE, rRange ),
@@ -774,11 +774,11 @@ ScChangeActionDel::ScChangeActionDel( const ScRange& rRange,
nDx( nDxP ),
nDy( nDyP )
{
- if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL )
+ if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == pDoc->MaxCol() )
{
aBigRange.aStart.SetCol( nInt32Min );
aBigRange.aEnd.SetCol( nInt32Max );
- if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW )
+ if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == pDoc->MaxRow() )
{
SetType( SC_CAT_DELETE_TABS );
aBigRange.aStart.SetRow( nInt32Min );
@@ -787,7 +787,7 @@ ScChangeActionDel::ScChangeActionDel( const ScRange& rRange,
else
SetType( SC_CAT_DELETE_ROWS );
}
- else if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW )
+ else if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == pDoc->MaxRow() )
{
SetType( SC_CAT_DELETE_COLS );
aBigRange.aStart.SetRow( nInt32Min );
@@ -1004,7 +1004,7 @@ bool ScChangeActionDel::Reject( ScDocument* pDoc )
switch ( GetType() )
{
case SC_CAT_DELETE_COLS :
- if ( !(aRange.aStart.Col() == 0 && aRange.aEnd.Col() == MAXCOL) )
+ if ( !(aRange.aStart.Col() == 0 && aRange.aEnd.Col() == pDoc->MaxCol()) )
{ // Only if not TabDelete
bOk = pDoc->CanInsertCol( aRange ) && pDoc->InsertCol( aRange );
}
@@ -1851,14 +1851,14 @@ void ScChangeActionContent::PutValueToDoc(
}
}
-static void lcl_InvalidateReference( formula::FormulaToken& rTok, const ScBigAddress& rPos )
+static void lcl_InvalidateReference( const ScDocument* pDoc, formula::FormulaToken& rTok, const ScBigAddress& rPos )
{
ScSingleRefData& rRef1 = *rTok.GetSingleRef();
- if ( rPos.Col() < 0 || MAXCOL < rPos.Col() )
+ if ( rPos.Col() < 0 || pDoc->MaxCol() < rPos.Col() )
{
rRef1.SetColDeleted( true );
}
- if ( rPos.Row() < 0 || MAXROW < rPos.Row() )
+ if ( rPos.Row() < 0 || pDoc->MaxRow() < rPos.Row() )
{
rRef1.SetRowDeleted( true );
}
@@ -1869,11 +1869,11 @@ static void lcl_InvalidateReference( formula::FormulaToken& rTok, const ScBigAdd
if ( rTok.GetType() == formula::svDoubleRef )
{
ScSingleRefData& rRef2 = rTok.GetDoubleRef()->Ref2;
- if ( rPos.Col() < 0 || MAXCOL < rPos.Col() )
+ if ( rPos.Col() < 0 || pDoc->MaxCol() < rPos.Col() )
{
rRef2.SetColDeleted( true );
}
- if ( rPos.Row() < 0 || MAXROW < rPos.Row() )
+ if ( rPos.Row() < 0 || pDoc->MaxRow() < rPos.Row() )
{
rRef2.SetRowDeleted( true );
}
@@ -1989,10 +1989,10 @@ void ScChangeActionContent::UpdateReference( const ScChangeTrack* pTrack,
ScTokenArray* pArr = maOldCell.mpFormula->GetCode();
formula::FormulaTokenArrayPlainIterator aIter(*pArr);
while ( ( t = aIter.GetNextReference() ) != nullptr )
- lcl_InvalidateReference( *t, rPos );
+ lcl_InvalidateReference( pTrack->GetDocument(), *t, rPos );
aIter.Reset();
while ( ( t = aIter.GetNextReferenceRPN() ) != nullptr )
- lcl_InvalidateReference( *t, rPos );
+ lcl_InvalidateReference( pTrack->GetDocument(), *t, rPos );
}
if ( bNewFormula )
{
@@ -2000,10 +2000,10 @@ void ScChangeActionContent::UpdateReference( const ScChangeTrack* pTrack,
ScTokenArray* pArr = maNewCell.mpFormula->GetCode();
formula::FormulaTokenArrayPlainIterator aIter(*pArr);
while ( ( t = aIter.GetNextReference() ) != nullptr )
- lcl_InvalidateReference( *t, rPos );
+ lcl_InvalidateReference( pTrack->GetDocument(), *t, rPos );
aIter.Reset();
while ( ( t = aIter.GetNextReferenceRPN() ) != nullptr )
- lcl_InvalidateReference( *t, rPos );
+ lcl_InvalidateReference( pTrack->GetDocument(), *t, rPos );
}
}
}
@@ -2220,7 +2220,7 @@ void ScChangeTrack::ConfigurationChanged( utl::ConfigurationBroadcaster*, Config
SfxObjectShell* pDocSh = pDoc->GetDocumentShell();
if (pDocSh)
- pDocSh->Broadcast( ScPaintHint( ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB), PaintPartFlags::Grid ) );
+ pDocSh->Broadcast( ScPaintHint( ScRange(0,0,0,pDoc->MaxCol(),pDoc->MaxRow(),MAXTAB), PaintPartFlags::Grid ) );
}
}
}
@@ -2449,12 +2449,12 @@ void ScChangeTrack::AppendDeleteRange( const ScRange& rRange,
{
if ( !pRefDoc || nTab < pRefDoc->GetTableCount() )
{
- if ( nCol1 == 0 && nCol2 == MAXCOL )
+ if ( nCol1 == 0 && nCol2 == pDoc->MaxCol() )
{ // Whole Row and/or Tables
- if ( nRow1 == 0 && nRow2 == MAXROW )
+ if ( nRow1 == 0 && nRow2 == pDoc->MaxRow() )
{ // Whole Table
// TODO: Can't we do the whole Table as a whole?
- ScRange aRange( 0, 0, nTab, 0, MAXROW, nTab );
+ ScRange aRange( 0, 0, nTab, 0, pDoc->MaxRow(), nTab );
for ( SCCOL nCol = nCol1; nCol <= nCol2; nCol++ )
{ // Column by column is less than row by row
aRange.aStart.SetCol( nCol );
@@ -2470,7 +2470,7 @@ void ScChangeTrack::AppendDeleteRange( const ScRange& rRange,
}
else
{ // Whole rows
- ScRange aRange( 0, 0, nTab, MAXCOL, 0, nTab );
+ ScRange aRange( 0, 0, nTab, pDoc->MaxCol(), 0, nTab );
for ( SCROW nRow = nRow1; nRow <= nRow2; nRow++ )
{
aRange.aStart.SetRow( nRow );
@@ -2482,9 +2482,9 @@ void ScChangeTrack::AppendDeleteRange( const ScRange& rRange,
}
}
}
- else if ( nRow1 == 0 && nRow2 == MAXROW )
+ else if ( nRow1 == 0 && nRow2 == pDoc->MaxRow() )
{ // Whole columns
- ScRange aRange( 0, 0, nTab, 0, MAXROW, nTab );
+ ScRange aRange( 0, 0, nTab, 0, pDoc->MaxRow(), nTab );
for ( SCCOL nCol = nCol1; nCol <= nCol2; nCol++ )
{
aRange.aStart.SetCol( nCol );
@@ -2525,11 +2525,11 @@ void ScChangeTrack::AppendOneDeleteRange( const ScRange& rOrgRange,
aTrackRange.aStart.IncTab( -nDz );
aTrackRange.aEnd.IncTab( -nDz );
}
- ScChangeActionDel* pAct = new ScChangeActionDel( aTrackRange, nDx, nDy,
+ ScChangeActionDel* pAct = new ScChangeActionDel( pRefDoc, aTrackRange, nDx, nDy,
this );
// TabDelete not Contents; they are in separate columns
if ( !(rOrgRange.aStart.Col() == 0 && rOrgRange.aStart.Row() == 0 &&
- rOrgRange.aEnd.Col() == MAXCOL && rOrgRange.aEnd.Row() == MAXROW) )
+ rOrgRange.aEnd.Col() == pDoc->MaxCol() && rOrgRange.aEnd.Row() == pDoc->MaxRow()) )
LookUpContents( rOrgRange, pRefDoc, -nDx, -nDy, -nDz );
if ( nRejectingInsert )
{
@@ -2763,7 +2763,7 @@ void ScChangeTrack::AppendContentRange( const ScRange& rRange,
void ScChangeTrack::AppendContentsIfInRefDoc( ScDocument* pRefDoc,
sal_uLong& nStartAction, sal_uLong& nEndAction )
{
- ScCellIterator aIter(pRefDoc, ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB));
+ ScCellIterator aIter(pRefDoc, ScRange(0,0,0,pDoc->MaxCol(),pDoc->MaxRow(),MAXTAB));
if (aIter.first())
{
nStartAction = GetActionMax() + 1;
@@ -2798,7 +2798,7 @@ ScChangeActionContent* ScChangeTrack::AppendContentOnTheFly(
void ScChangeTrack::AppendInsert( const ScRange& rRange, bool bEndOfList )
{
- ScChangeActionIns* pAct = new ScChangeActionIns(rRange, bEndOfList);
+ ScChangeActionIns* pAct = new ScChangeActionIns(pDoc, rRange, bEndOfList);
Append( pAct );
}
@@ -4284,7 +4284,7 @@ bool ScChangeTrack::Reject(
if ( bOneOk || (bTabDel && bTabDelOk) )
{
// Delete Reject made UpdateReference Undo
- ScChangeActionIns* pReject = new ScChangeActionIns(
+ ScChangeActionIns* pReject = new ScChangeActionIns( pDoc,
aDelRange.MakeRange() );
pReject->SetRejectAction( nRejectAction );
pReject->SetState( SC_CAS_ACCEPTED );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index bede44e52556..c095d3a61c15 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -822,7 +822,7 @@ struct ConventionOOO_A1 : public Convention_A1
}
}
- static SingletonDisplay getSingletonDisplay( const ScAddress& rAbs1, const ScAddress& rAbs2,
+ static SingletonDisplay getSingletonDisplay( const ScDocument* pDoc, const ScAddress& rAbs1, const ScAddress& rAbs2,
const ScComplexRefData& rRef, bool bFromRangeName )
{
// If any part is error, display as such.
@@ -836,7 +836,7 @@ struct ConventionOOO_A1 : public Convention_A1
// Same if not in named expression and both rows of entire columns are
// relative references.
- if (!bFromRangeName && rAbs1.Row() == 0 && rAbs2.Row() == MAXROW &&
+ if (!bFromRangeName && rAbs1.Row() == 0 && rAbs2.Row() == pDoc->MaxRow() &&
rRef.Ref1.IsRowRel() && rRef.Ref2.IsRowRel())
return SINGLETON_COL;
@@ -846,14 +846,16 @@ struct ConventionOOO_A1 : public Convention_A1
// Same if not in named expression and both columns of entire rows are
// relative references.
- if (!bFromRangeName && rAbs1.Col() == 0 && rAbs2.Col() == MAXCOL &&
+ if (!bFromRangeName && rAbs1.Col() == 0 && rAbs2.Col() == pDoc->MaxCol() &&
rRef.Ref1.IsColRel() && rRef.Ref2.IsColRel())
return SINGLETON_ROW;
return SINGLETON_NONE;
}
- virtual void makeRefStr( OUStringBuffer& rBuffer,
+ virtual void makeRefStr(
+ const ScDocument* pDoc,
+ OUStringBuffer& rBuffer,
formula::FormulaGrammar::Grammar /*eGram*/,
const ScAddress& rPos,
const OUString& rErrRef, const std::vector<OUString>& rTabNames,
@@ -868,7 +870,7 @@ struct ConventionOOO_A1 : public Convention_A1
aAbs2 = rRef.Ref2.toAbs(rPos);
SingletonDisplay eSingleton = bSingleRef ? SINGLETON_NONE :
- getSingletonDisplay( aAbs1, aAbs2, rRef, bFromRangeName);
+ getSingletonDisplay( pDoc, aAbs1, aAbs2, rRef, bFromRangeName);
MakeOneRefStrImpl(rBuffer, rErrRef, rTabNames, rRef.Ref1, aAbs1, false, false, eSingleton);
if (!bSingleRef)
{
@@ -997,6 +999,7 @@ struct ConventionOOO_A1 : public Convention_A1
}
virtual void makeExternalRefStr(
+ const ScDocument* /*pDoc*/,
OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const std::vector<OUString>& rTabNames, const OUString& rTabName,
const ScComplexRefData& rRef ) const override
@@ -1009,7 +1012,9 @@ struct ConventionOOO_A1_ODF : public ConventionOOO_A1
{
ConventionOOO_A1_ODF() : ConventionOOO_A1 (FormulaGrammar::CONV_ODF) { }
- virtual void makeRefStr( OUStringBuffer& rBuffer,
+ virtual void makeRefStr(
+ const ScDocument* pDoc,
+ OUStringBuffer& rBuffer,
formula::FormulaGrammar::Grammar eGram,
const ScAddress& rPos,
const OUString& rErrRef, const std::vector<OUString>& rTabNames,
@@ -1035,7 +1040,7 @@ struct ConventionOOO_A1_ODF : public ConventionOOO_A1
else
{
SingletonDisplay eSingleton = bSingleRef ? SINGLETON_NONE :
- getSingletonDisplay( aAbs1, aAbs2, rRef, bFromRangeName);
+ getSingletonDisplay( pDoc, aAbs1, aAbs2, rRef, bFromRangeName);
MakeOneRefStrImpl(rBuffer, rErrRef, rTabNames, rRef.Ref1, aAbs1, false, true, eSingleton);
if (!bSingleRef)
{
@@ -1061,6 +1066,7 @@ struct ConventionOOO_A1_ODF : public ConventionOOO_A1
}
virtual void makeExternalRefStr(
+ const ScDocument* /*pDoc*/,
OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const std::vector<OUString>& rTabNames,
const OUString& rTabName, const ScComplexRefData& rRef ) const override
@@ -1254,7 +1260,9 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
MakeRowStr(rBuf, rAbs.Row());
}
- virtual void makeRefStr( OUStringBuffer& rBuf,
+ virtual void makeRefStr(
+ const ScDocument* pDoc,
+ OUStringBuffer& rBuf,
formula::FormulaGrammar::Grammar /*eGram*/,
const ScAddress& rPos,
const OUString& rErrRef, const std::vector<OUString>& rTabNames,
@@ -1285,7 +1293,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
return;
}
- if (aAbs1.Col() == 0 && aAbs2.Col() >= MAXCOL)
+ if (aAbs1.Col() == 0 && aAbs2.Col() >= pDoc->MaxCol())
{
if (!aRef.Ref1.IsRowRel())
rBuf.append( '$' );
@@ -1297,7 +1305,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
return;
}
- if (aAbs1.Row() == 0 && aAbs2.Row() >= MAXROW)
+ if (aAbs1.Row() == 0 && aAbs2.Row() >= pDoc->MaxRow())
{
if (!aRef.Ref1.IsColRel())
rBuf.append( '$' );
@@ -1376,6 +1384,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
}
virtual void makeExternalRefStr(
+ const ScDocument* /*pDoc*/,
OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const std::vector<OUString>& rTabNames, const OUString& rTabName,
const ScComplexRefData& rRef ) const override
@@ -1399,7 +1408,8 @@ struct ConventionXL_OOX : public ConventionXL_A1
{
ConventionXL_OOX() : ConventionXL_A1( FormulaGrammar::CONV_XL_OOX ) { }
- virtual void makeRefStr( OUStringBuffer& rBuf,
+ virtual void makeRefStr( const ScDocument* pDoc,
+ OUStringBuffer& rBuf,
formula::FormulaGrammar::Grammar eGram,
const ScAddress& rPos,
const OUString& rErrRef, const std::vector<OUString>& rTabNames,
@@ -1430,7 +1440,7 @@ struct ConventionXL_OOX : public ConventionXL_A1
return;
}
- ConventionXL_A1::makeRefStr( rBuf, eGram, aPos, rErrRef, rTabNames, rRef, bSingleRef, bFromRangeName);
+ ConventionXL_A1::makeRefStr( pDoc, rBuf, eGram, aPos, rErrRef, rTabNames, rRef, bSingleRef, bFromRangeName);
}
virtual OUString makeExternalNameStr( sal_uInt16 nFileId, const OUString& /*rFile*/,
@@ -1493,6 +1503,7 @@ struct ConventionXL_OOX : public ConventionXL_A1
}
virtual void makeExternalRefStr(
+ const ScDocument* /*pDoc*/,
OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 nFileId, const OUString& /*rFileName*/,
const std::vector<OUString>& rTabNames, const OUString& rTabName,
const ScComplexRefData& rRef ) const override
@@ -1566,7 +1577,8 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
{
ConventionXL_R1C1() : ScCompiler::Convention( FormulaGrammar::CONV_XL_R1C1 ) { }
- virtual void makeRefStr( OUStringBuffer& rBuf,
+ virtual void makeRefStr( const ScDocument* pDoc,
+ OUStringBuffer& rBuf,
formula::FormulaGrammar::Grammar /*eGram*/,
const ScAddress& rPos,
const OUString& rErrRef, const std::vector<OUString>& rTabNames,
@@ -1595,7 +1607,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
return;
}
- if (aAbsRef.aStart.Col() == 0 && aAbsRef.aEnd.Col() >= MAXCOL)
+ if (aAbsRef.aStart.Col() == 0 && aAbsRef.aEnd.Col() >= pDoc->MaxCol())
{
r1c1_add_row(rBuf, rRef.Ref1, aAbsRef.aStart);
if (aAbsRef.aStart.Row() != aAbsRef.aEnd.Row() ||
@@ -1608,7 +1620,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
}
- if (aAbsRef.aStart.Row() == 0 && aAbsRef.aEnd.Row() >= MAXROW)
+ if (aAbsRef.aStart.Row() == 0 && aAbsRef.aEnd.Row() >= pDoc->MaxRow())
{
r1c1_add_col(rBuf, rRef.Ref1, aAbsRef.aStart);
if (aAbsRef.aStart.Col() != aAbsRef.aEnd.Col() ||
@@ -1692,6 +1704,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
}
virtual void makeExternalRefStr(
+ const ScDocument* pDoc,
OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const std::vector<OUString>& rTabNames, const OUString& rTabName,
const ScComplexRefData& rRef ) const override
@@ -1708,7 +1721,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
return;
}
- if (aAbsRef.aStart.Col() == 0 && aAbsRef.aEnd.Col() >= MAXCOL)
+ if (aAbsRef.aStart.Col() == 0 && aAbsRef.aEnd.Col() >= pDoc->MaxCol())
{
r1c1_add_row(rBuffer, rRef.Ref1, aAbsRef.aStart);
if (aAbsRef.aStart.Row() != aAbsRef.aEnd.Row() || rRef.Ref1.IsRowRel() != rRef.Ref2.IsRowRel())
@@ -1719,7 +1732,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
return;
}
- if (aAbsRef.aStart.Row() == 0 && aAbsRef.aEnd.Row() >= MAXROW)
+ if (aAbsRef.aStart.Row() == 0 && aAbsRef.aEnd.Row() >= pDoc->MaxRow())
{
r1c1_add_col(rBuffer, rRef.Ref1, aAbsRef.aStart);
if (aAbsRef.aStart.Col() != aAbsRef.aEnd.Col() || rRef.Ref1.IsColRel() != rRef.Ref2.IsColRel())
@@ -3569,7 +3582,7 @@ bool ScCompiler::IsColRowName( const OUString& rName )
long nMyRow = static_cast<long>(aPos.Row());
bool bTwo = false;
ScAddress aOne( 0, 0, aPos.Tab() );
- ScAddress aTwo( MAXCOL, MAXROW, aPos.Tab() );
+ ScAddress aTwo( pDoc->MaxCol(), pDoc->MaxRow(), aPos.Tab() );
ScAutoNameCache* pNameCache = pDoc->GetAutoNameCache();
if ( pNameCache )
@@ -3729,7 +3742,7 @@ bool ScCompiler::IsColRowName( const OUString& rName )
else
aAdr = aOne;
aRef.InitAddress( aAdr );
- if ( (aAdr.Row() != MAXROW && pDoc->HasStringData(
+ if ( (aAdr.Row() != pDoc->MaxRow() && pDoc->HasStringData(
aAdr.Col(), aAdr.Row() + 1, aAdr.Tab()))
|| (aAdr.Row() != 0 && pDoc->HasStringData(
aAdr.Col(), aAdr.Row() - 1, aAdr.Tab())))
@@ -4303,7 +4316,7 @@ bool ScCompiler::NextNewToken( bool bInArray )
// If a syntactically correct reference was recognized but invalid
// e.g. because of non-existing sheet name => entire reference
// ocBad to preserve input instead of #REF!.A1
- if (!maRawToken.IsValidReference())
+ if (!maRawToken.IsValidReference(pDoc))
{
aUpper = aOrg; // ensure for ocBad
break; // do; create ocBad token or set error.
@@ -4925,9 +4938,9 @@ void ScCompiler::MoveRelWrap()
for ( auto t: pArr->References() )
{
if ( t->GetType() == svSingleRef || t->GetType() == svExternalSingleRef )
- ScRefUpdate::MoveRelWrap( pDoc, aPos, MAXCOL, MAXROW, SingleDoubleRefModifier( *t->GetSingleRef() ).Ref() );
+ ScRefUpdate::MoveRelWrap( pDoc, aPos, pDoc->MaxCol(), pDoc->MaxRow(), SingleDoubleRefModifier( *t->GetSingleRef() ).Ref() );
else
- ScRefUpdate::MoveRelWrap( pDoc, aPos, MAXCOL, MAXROW, *t->GetDoubleRef() );
+ ScRefUpdate::MoveRelWrap( pDoc, aPos, pDoc->MaxCol(), pDoc->MaxRow(), *t->GetDoubleRef() );
}
}
@@ -4996,7 +5009,7 @@ void ScCompiler::CreateStringFromExternal( OUStringBuffer& rBuffer, const Formul
*pFileName << "' '" << t->GetString().getString() << "'");
pConv->makeExternalRefStr(
- rBuffer, GetPos(), nFileId, *pFileName, aTabNames, t->GetString().getString(),
+ pDoc, rBuffer, GetPos(), nFileId, *pFileName, aTabNames, t->GetString().getString(),
*t->GetDoubleRef());
}
break;
@@ -5098,7 +5111,7 @@ void ScCompiler::CreateStringFromSingleRef( OUStringBuffer& rBuffer, const Formu
else
{
rBuffer.append(ScCompiler::GetNativeSymbol(ocErrName));
- pConv->makeRefStr(rBuffer, meGrammar, aPos, aErrRef,
+ pConv->makeRefStr(pDoc, rBuffer, meGrammar, aPos, aErrRef,
GetSetupTabNames(), aRef, true, (pArr && pArr->IsFromRangeName()));
}
}
@@ -5130,14 +5143,14 @@ void ScCompiler::CreateStringFromSingleRef( OUStringBuffer& rBuffer, const Formu
rBuffer.append(aStr);
}
else
- pConv->makeRefStr(rBuffer, meGrammar, aPos, aErrRef,
+ pConv->makeRefStr(pDoc, rBuffer, meGrammar, aPos, aErrRef,
GetSetupTabNames(), aRef, true, (pArr && pArr->IsFromRangeName()));
}
void ScCompiler::CreateStringFromDoubleRef( OUStringBuffer& rBuffer, const FormulaToken* _pTokenP ) const
{
OUString aErrRef = GetCurrentOpCodeMap()->getSymbol(ocErrRef);
- pConv->makeRefStr(rBuffer, meGrammar, aPos, aErrRef, GetSetupTabNames(),
+ pConv->makeRefStr(pDoc, rBuffer, meGrammar, aPos, aErrRef, GetSetupTabNames(),
*_pTokenP->GetDoubleRef(), false, (pArr && pArr->IsFromRangeName()));
}
@@ -5342,16 +5355,16 @@ bool ScCompiler::HandleColRowName()
if ( bColName )
{ // ColName
SCROW nStartRow = nRow + 1;
- if ( nStartRow > MAXROW )
- nStartRow = MAXROW;
- SCROW nMaxRow = MAXROW;
+ if ( nStartRow > pDoc->MaxRow() )
+ nStartRow = pDoc->MaxRow();
+ SCROW nMaxRow = pDoc->MaxRow();
if ( nMyCol == nCol )
{ // formula cell in same column
if ( nMyRow == nStartRow )
{ // take remainder under name cell
nStartRow++;
- if ( nStartRow > MAXROW )
- nStartRow = MAXROW;
+ if ( nStartRow > pDoc->MaxRow() )
+ nStartRow = pDoc->MaxRow();
}
else if ( nMyRow > nStartRow )
{ // from name cell down to formula cell
@@ -5375,16 +5388,16 @@ bool ScCompiler::HandleColRowName()
else
{ // RowName
SCCOL nStartCol = nCol + 1;
- if ( nStartCol > MAXCOL )
- nStartCol = MAXCOL;
- SCCOL nMaxCol = MAXCOL;
+ if ( nStartCol > pDoc->MaxCol() )
+ nStartCol = pDoc->MaxCol();
+ SCCOL nMaxCol = pDoc->MaxCol();
if ( nMyRow == nRow )
{ // formula cell in same row
if ( nMyCol == nStartCol )
{ // take remainder right from name cell
nStartCol++;
- if ( nStartCol > MAXCOL )
- nStartCol = MAXCOL;
+ if ( nStartCol > pDoc->MaxCol() )
+ nStartCol = pDoc->MaxCol();
}
else if ( nMyCol > nStartCol )
{ // from name cell right to formula cell
@@ -6172,15 +6185,15 @@ bool ScCompiler::AdjustSumRangeShape(const ScComplexRefData& rBaseRange, ScCompl
SCCOL nXInc = nXDelta - nXDeltaSum;
SCROW nYInc = nYDelta - nYDeltaSum;
- // Don't let a valid End[Col,Row] go beyond (MAXCOL,MAXROW) to match
+ // Don't let a valid End[Col,Row] go beyond (pDoc->MaxCol(),pDoc->MaxRow()) to match
// what happens in ScInterpreter::IterateParametersIf(), but there it also shrinks
// the base-range by the (out-of-bound)amount clipped off the sum-range.
// TODO: Probably we can optimize (from threading perspective) rBaseRange
// by shrinking it here correspondingly (?)
- if (nEndCol + nXInc > MAXCOL)
- nXInc = MAXCOL - nEndCol;
- if (nEndRow + nYInc > MAXROW)
- nYInc = MAXROW - nEndRow;
+ if (nEndCol + nXInc > pDoc->MaxCol())
+ nXInc = pDoc->MaxCol() - nEndCol;
+ if (nEndRow + nYInc > pDoc->MaxRow())
+ nYInc = pDoc->MaxRow() - nEndRow;
rSumRange.Ref2.IncCol(nXInc);
rSumRange.Ref2.IncRow(nYInc);
diff --git a/sc/source/core/tool/consoli.cxx b/sc/source/core/tool/consoli.cxx
index 0d1e1f16fddf..dae69f4b01f0 100644
--- a/sc/source/core/tool/consoli.cxx
+++ b/sc/source/core/tool/consoli.cxx
@@ -459,7 +459,7 @@ void ScConsData::OutputToDocument( ScDocument* pDestDoc, SCCOL nCol, SCROW nRow,
if (nNeeded)
{
- pDestDoc->InsertRow( 0,nTab, MAXCOL,nTab, nRow+nArrY, nNeeded );
+ pDestDoc->InsertRow( 0,nTab, pDestDoc->MaxCol(),nTab, nRow+nArrY, nNeeded );
for (nArrX=0; nArrX<nColCount; nArrX++)
if (ppUsed[nArrX][nArrY])
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 656690085cf6..8e77f5410dc4 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -628,11 +628,11 @@ void ScDBData::ExtendDataArea(const ScDocument* pDoc)
SCCOL nOldCol1 = nStartCol, nOldCol2 = nEndCol;
SCROW nOldEndRow = nEndRow;
pDoc->GetDataArea(nTable, nStartCol, nStartRow, nEndCol, nEndRow, false, true);
- // nOldEndRow==MAXROW may easily happen when selecting whole columns and
+ // nOldEndRow==rDoc.MaxRow() may easily happen when selecting whole columns and
// setting an AutoFilter (i.e. creating an anonymous database-range). We
// certainly don't want to iterate over nearly a million empty cells, but
// keep only an intentionally user selected range.
- if (nOldEndRow < MAXROW && nEndRow < nOldEndRow)
+ if (nOldEndRow < pDoc->MaxRow() && nEndRow < nOldEndRow)
nEndRow = nOldEndRow;
if (nStartCol != nOldCol1 || nEndCol != nOldCol2)
{
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 76a42f661005..740a4af583fd 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -1005,7 +1005,7 @@ sal_uInt16 ScDetectiveFunc::InsertSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCo
// over the entire document.
sal_uInt16 nResult = DET_INS_EMPTY;
- ScCellIterator aCellIter(pDoc, ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB)); // all sheets
+ ScCellIterator aCellIter(pDoc, ScRange(0,0,0,pDoc->MaxCol(),pDoc->MaxRow(),MAXTAB)); // all sheets
for (bool bHas = aCellIter.first(); bHas; bHas = aCellIter.next())
{
if (aCellIter.getType() != CELLTYPE_FORMULA)
@@ -1093,7 +1093,7 @@ sal_uInt16 ScDetectiveFunc::FindSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2
sal_uInt16 nResult = nLevel;
bool bDelete = ( nDeleteLevel && nLevel == nDeleteLevel-1 );
- ScCellIterator aCellIter( pDoc, ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab) );
+ ScCellIterator aCellIter( pDoc, ScRange(0, 0, nTab, pDoc->MaxCol(), pDoc->MaxRow(), nTab) );
for (bool bHas = aCellIter.first(); bHas; bHas = aCellIter.next())
{
if (aCellIter.getType() != CELLTYPE_FORMULA)
@@ -1300,7 +1300,7 @@ bool ScDetectiveFunc::MarkInvalid(bool& rOverflow)
long nInsCount = 0;
// search for valid places
- ScDocAttrIterator aAttrIter( pDoc, nTab, 0,0,MAXCOL,MAXROW );
+ ScDocAttrIterator aAttrIter( pDoc, nTab, 0,0,pDoc->MaxCol(),pDoc->MaxRow() );
SCCOL nCol;
SCROW nRow1;
SCROW nRow2;
@@ -1380,7 +1380,7 @@ void ScDetectiveFunc::GetAllSuccs(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW n
aSrcRange.push_back(
ScRefTokenHelper::createRefToken(ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab)));
- ScCellIterator aIter(pDoc, ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab));
+ ScCellIterator aIter(pDoc, ScRange(0, 0, nTab, pDoc->MaxCol(), pDoc->MaxRow(), nTab));
for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
if (aIter.getType() != CELLTYPE_FORMULA)
diff --git a/sc/source/core/tool/formulalogger.cxx b/sc/source/core/tool/formulalogger.cxx
index 31b3fe9f6072..c1ea0d4d39ea 100644
--- a/sc/source/core/tool/formulalogger.cxx
+++ b/sc/source/core/tool/formulalogger.cxx
@@ -78,7 +78,7 @@ struct FormulaLogger::GroupScope::Impl
if (mbOutputEnabled)
{
sc::TokenStringContext aCxt(&rDoc, rDoc.GetGrammar());
- OUString aFormula = rCell.GetCode()->CreateString(aCxt, rCell.aPos);
+ OUString aFormula = rCell.GetCode()->CreateString(&rDoc, aCxt, rCell.aPos);
mrLogger.write(maPrefix);
mrLogger.writeNestLevel();
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index d4e867c05767..9b907f429688 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5430,8 +5430,8 @@ void ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc )
}
else
{
- nMaxCol = MAXCOL;
- nMaxRow = MAXROW;
+ nMaxCol = pDok->MaxCol();
+ nMaxRow = pDok->MaxRow();
}
if (nCol3 + nColDelta > nMaxCol)
{
@@ -7017,7 +7017,7 @@ void ScInterpreter::ScLookup()
if (bResVertical)
{
SCROW nTempRow = static_cast<SCROW>(nResRow1 + nDelta);
- if (nTempRow > MAXROW)
+ if (nTempRow > pDok->MaxRow())
{
PushDouble(0);
return;
@@ -7028,7 +7028,7 @@ void ScInterpreter::ScLookup()
else
{
SCCOL nTempCol = static_cast<SCCOL>(nResCol1 + nDelta);
- if (nTempCol > MAXCOL)
+ if (nTempCol > pDok->MaxCol())
{
PushDouble(0);
return;
@@ -7115,7 +7115,7 @@ void ScInterpreter::ScLookup()
if (bResVertical)
{
SCROW nTempRow = static_cast<SCROW>(nResRow1 + nDelta);
- if (nTempRow > MAXROW)
+ if (nTempRow > pDok->MaxRow())
{
PushDouble(0);
return;
@@ -7126,7 +7126,7 @@ void ScInterpreter::ScLookup()
else
{
SCCOL nTempCol = static_cast<SCCOL>(nResCol1 + nDelta);
- if (nTempCol > MAXCOL)
+ if (nTempCol > pDok->MaxCol())
{
PushDouble(0);
return;
@@ -7176,7 +7176,7 @@ void ScInterpreter::ScLookup()
if (bVertical)
{
SCROW nTempRow = static_cast<SCROW>(nRow1 + nDelta);
- if (nTempRow > MAXROW)
+ if (nTempRow > pDok->MaxRow())
{
PushDouble(0);
return;
@@ -7187,7 +7187,7 @@ void ScInterpreter::ScLookup()
else
{
SCCOL nTempCol = static_cast<SCCOL>(nCol1 + nDelta);
- if (nTempCol > MAXCOL)
+ if (nTempCol > pDok->MaxCol())
{
PushDouble(0);
return;
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 0cbf9b10e154..eb3fb987c034 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3716,8 +3716,8 @@ void ScInterpreter::ScColRowNameAuto()
if ( nMyRow == nStartRow )
{ // take the rest under the name
nStartRow++;
- if ( nStartRow > MAXROW )
- nStartRow = MAXROW;
+ if ( nStartRow > pDok->MaxRow() )
+ nStartRow = pDok->MaxRow();
aAbs.aStart.SetRow(nStartRow);
}
else
@@ -3739,8 +3739,8 @@ void ScInterpreter::ScColRowNameAuto()
if ( nMyCol == nStartCol )
{ // take the rest under the name
nStartCol++;
- if ( nStartCol > MAXCOL )
- nStartCol = MAXCOL;
+ if ( nStartCol > pDok->MaxCol() )
+ nStartCol = pDok->MaxCol();
aAbs.aStart.SetCol(nStartCol);
}
else
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 76e8656a55c9..2ad06e46a8ba 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -419,7 +419,7 @@ void ScRangeData::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nLocal
aPos.SetTab(rCxt.getNewTab(aPos.Tab()));
}
-void ScRangeData::MakeValidName( OUString& rName )
+void ScRangeData::MakeValidName( const ScDocument* pDoc, OUString& rName )
{
// strip leading invalid characters
@@ -451,8 +451,8 @@ void ScRangeData::MakeValidName( OUString& rName )
ScAddress::Details details( static_cast<FormulaGrammar::AddressConvention>( nConv ) );
// Don't check Parse on VALID, any partial only VALID may result in
// #REF! during compile later!
- while (aRange.Parse(rName, nullptr, details) != ScRefFlags::ZERO ||
- aAddr.Parse(rName, nullptr, details) != ScRefFlags::ZERO)
+ while (aRange.Parse(rName, pDoc, details) != ScRefFlags::ZERO ||
+ aAddr.Parse(rName, pDoc, details) != ScRefFlags::ZERO)
{
// Range Parse is partially valid also with invalid sheet name,
// Address Parse dito, during compile name would generate a #REF!
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 4321e96d3e8a..614f266ad1a5 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -22,6 +22,7 @@
#include <algorithm>
#include <refdata.hxx>
+#include <document.hxx>
void ScSingleRefData::InitAddress( const ScAddress& rAdr )
{
@@ -126,37 +127,37 @@ bool ScSingleRefData::IsDeleted() const
return IsColDeleted() || IsRowDeleted() || IsTabDeleted();
}
-bool ScSingleRefData::Valid() const
+bool ScSingleRefData::Valid(const ScDocument* pDoc) const
{
- return ColValid() && RowValid() && TabValid();
+ return ColValid(pDoc) && RowValid(pDoc) && TabValid();
}
-bool ScSingleRefData::ColValid() const
+bool ScSingleRefData::ColValid(const ScDocument* pDoc) const
{
if (Flags.bColRel)
{
- if (mnCol < -MAXCOL || MAXCOL < mnCol)
+ if (mnCol < -pDoc->MaxCol() || pDoc->MaxCol() < mnCol)
return false;
}
else
{
- if (mnCol < 0 || MAXCOL < mnCol)
+ if (mnCol < 0 || pDoc->MaxCol() < mnCol)
return false;
}
return true;
}
-bool ScSingleRefData::RowValid() const
+bool ScSingleRefData::RowValid(const ScDocument* pDoc) const
{
if (Flags.bRowRel)
{
- if (mnRow < -MAXROW || MAXROW < mnRow)
+ if (mnRow < -pDoc->MaxRow() || pDoc->MaxRow() < mnRow)
return false;
}
else
{
- if (mnRow < 0 || MAXROW < mnRow)
+ if (mnRow < 0 || pDoc->MaxRow() < mnRow)
return false;
}
@@ -179,9 +180,9 @@ bool ScSingleRefData::TabValid() const
return true;
}
-bool ScSingleRefData::ValidExternal() const
+bool ScSingleRefData::ValidExternal(const ScDocument* pDoc) const
{
- return ColValid() && RowValid() && mnTab >= -1;
+ return ColValid(pDoc) && RowValid(pDoc) && mnTab >= -1;
}
ScAddress ScSingleRefData::toAbs( const ScAddress& rPos ) const
@@ -469,14 +470,14 @@ ScComplexRefData& ScComplexRefData::Extend( const ScComplexRefData & rRef, const
return Extend( rRef.Ref1, rPos).Extend( rRef.Ref2, rPos);
}
-bool ScComplexRefData::Valid() const
+bool ScComplexRefData::Valid(const ScDocument* pDoc) const
{
- return Ref1.Valid() && Ref2.Valid();
+ return Ref1.Valid(pDoc) && Ref2.Valid(pDoc);
}
-bool ScComplexRefData::ValidExternal() const
+bool ScComplexRefData::ValidExternal(const ScDocument* pDoc) const
{
- return Ref1.ValidExternal() && Ref2.ColValid() && Ref2.RowValid() && Ref1.Tab() <= Ref2.Tab();
+ return Ref1.ValidExternal(pDoc) && Ref2.ColValid(pDoc) && Ref2.RowValid(pDoc) && Ref1.Tab() <= Ref2.Tab();
}
ScRange ScComplexRefData::toAbs( const ScAddress& rPos ) const
@@ -495,7 +496,7 @@ void ScComplexRefData::PutInOrder( const ScAddress& rPos )
ScSingleRefData::PutInOrder( Ref1, Ref2, rPos);
}
-bool ScComplexRefData::IncEndColSticky( SCCOL nDelta, const ScAddress& rPos )
+bool ScComplexRefData::IncEndColSticky( const ScDocument* pDoc, SCCOL nDelta, const ScAddress& rPos )
{
SCCOL nCol1 = Ref1.IsColRel() ? Ref1.Col() + rPos.Col() : Ref1.Col();
SCCOL nCol2 = Ref2.IsColRel() ? Ref2.Col() + rPos.Col() : Ref2.Col();
@@ -506,25 +507,25 @@ bool ScComplexRefData::IncEndColSticky( SCCOL nDelta, const ScAddress& rPos )
return true;
}
- if (nCol2 == MAXCOL)
+ if (nCol2 == pDoc->MaxCol())
// already sticky
return false;
- if (nCol2 < MAXCOL)
+ if (nCol2 < pDoc->MaxCol())
{
- SCCOL nCol = ::std::min( static_cast<SCCOL>(nCol2 + nDelta), MAXCOL);
+ SCCOL nCol = ::std::min( static_cast<SCCOL>(nCol2 + nDelta), pDoc->MaxCol());
if (Ref2.IsColRel())
Ref2.SetRelCol( nCol - rPos.Col());
else
Ref2.SetAbsCol( nCol);
}
else
- Ref2.IncCol( nDelta); // was greater than MAXCOL, caller should know...
+ Ref2.IncCol( nDelta); // was greater than pDoc->.MaxCol(), caller should know...
return true;
}
-bool ScComplexRefData::IncEndRowSticky( SCROW nDelta, const ScAddress& rPos )
+bool ScComplexRefData::IncEndRowSticky( const ScDocument* pDoc, SCROW nDelta, const ScAddress& rPos )
{
SCROW nRow1 = Ref1.IsRowRel() ? Ref1.Row() + rPos.Row() : Ref1.Row();
SCROW nRow2 = Ref2.IsRowRel() ? Ref2.Row() + rPos.Row() : Ref2.Row();
@@ -535,20 +536,20 @@ bool ScComplexRefData::IncEndRowSticky( SCROW nDelta, const ScAddress& rPos )
return true;
}
- if (nRow2 == MAXROW)
+ if (nRow2 == pDoc->MaxRow())
// already sticky
return false;
- if (nRow2 < MAXROW)
+ if (nRow2 < pDoc->MaxRow())
{
- SCROW nRow = ::std::min( static_cast<SCROW>(nRow2 + nDelta), MAXROW);
+ SCROW nRow = ::std::min( static_cast<SCROW>(nRow2 + nDelta), pDoc->MaxRow());
if (Ref2.IsRowRel())
Ref2.SetRelRow( nRow - rPos.Row());
else
Ref2.SetAbsRow( nRow);
}
else
- Ref2.IncRow( nDelta); // was greater than MAXROW, caller should know...
+ Ref2.IncRow( nDelta); // was greater than pDoc->.MaxRow(), caller should know...
return true;
}
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index 02980e056bf8..7ed8db3e2f82 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -77,7 +77,7 @@ void ScRefTokenHelper::compileRangeRepresentation(
case svSingleRef:
{
const ScSingleRefData& rRef = *p->GetSingleRef();
- if (!rRef.Valid())
+ if (!rRef.Valid(pDoc))
bFailure = true;
else if (bOnly3DRef && !rRef.IsFlag3D())
bFailure = true;
@@ -86,7 +86,7 @@ void ScRefTokenHelper::compileRangeRepresentation(
case svDoubleRef:
{
const ScComplexRefData& rRef = *p->GetDoubleRef();
- if (!rRef.Valid())
+ if (!rRef.Valid(pDoc))
bFailure = true;
else if (bOnly3DRef && !rRef.Ref1.IsFlag3D())
bFailure = true;
@@ -94,13 +94,13 @@ void ScRefTokenHelper::compileRangeRepresentation(
break;
case svExternalSingleRef:
{
- if (!p->GetSingleRef()->ValidExternal())
+ if (!p->GetSingleRef()->ValidExternal(pDoc))
bFailure = true;
}
break;
case svExternalDoubleRef:
{
- if (!p->GetDoubleRef()->ValidExternal())
+ if (!p->GetDoubleRef()->ValidExternal(pDoc))
bFailure = true;
}
break;
diff --git a/sc/source/core/tool/refupdat.cxx b/sc/source/core/tool/refupdat.cxx
index f65c5fe965ee..9d1e290569e9 100644
--- a/sc/source/core/tool/refupdat.cxx
+++ b/sc/source/core/tool/refupdat.cxx
@@ -211,8 +211,8 @@ ScRefUpdateRes ScRefUpdate::Update( const ScDocument* pDoc, UpdateRefMode eUpdat
(theTab1 >= nTab1) && (theTab2 <= nTab2))
{
bool bExp = (bExpand && IsExpand( theCol1, theCol2, nCol1, nDx ));
- bCut1 = lcl_MoveStart( theCol1, nCol1, nDx, MAXCOL );
- bCut2 = lcl_MoveEnd( theCol2, nCol1, nDx, MAXCOL );
+ bCut1 = lcl_MoveStart( theCol1, nCol1, nDx, pDoc->MaxCol() );
+ bCut2 = lcl_MoveEnd( theCol2, nCol1, nDx, pDoc->MaxCol() );
if ( theCol2 < theCol1 )
{
eRet = UR_INVALID;
@@ -225,28 +225,28 @@ ScRefUpdateRes ScRefUpdate::Update( const ScDocument* pDoc, UpdateRefMode eUpdat
Expand( theCol1, theCol2, nCol1, nDx );
eRet = UR_UPDATED;
}
- if (eRet != UR_NOTHING && oldCol1 == 0 && oldCol2 == MAXCOL)
+ if (eRet != UR_NOTHING && oldCol1 == 0 && oldCol2 == pDoc->MaxCol())
{
eRet = UR_STICKY;
theCol1 = oldCol1;
theCol2 = oldCol2;
}
- else if (oldCol2 == MAXCOL && oldCol1 < MAXCOL)
+ else if (oldCol2 == pDoc->MaxCol() && oldCol1 < pDoc->MaxCol())
{
// End was sticky, but start may have been moved. Only on range.
theCol2 = oldCol2;
if (eRet == UR_NOTHING)
eRet = UR_STICKY;
}
- // Else, if (bCut2 && theCol2 == MAXCOL) then end becomes sticky,
+ // Else, if (bCut2 && theCol2 == pDoc->MaxCol()) then end becomes sticky,
// but currently there's nothing to do.
}
if ( nDy && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
(theTab1 >= nTab1) && (theTab2 <= nTab2))
{
bool bExp = (bExpand && IsExpand( theRow1, theRow2, nRow1, nDy ));
- bCut1 = lcl_MoveStart( theRow1, nRow1, nDy, MAXROW );
- bCut2 = lcl_MoveEnd( theRow2, nRow1, nDy, MAXROW );
+ bCut1 = lcl_MoveStart( theRow1, nRow1, nDy, pDoc->MaxRow() );
+ bCut2 = lcl_MoveEnd( theRow2, nRow1, nDy, pDoc->MaxRow() );
if ( theRow2 < theRow1 )
{
eRet = UR_INVALID;
@@ -259,20 +259,20 @@ ScRefUpdateRes ScRefUpdate::Update( const ScDocument* pDoc, UpdateRefMode eUpdat
Expand( theRow1, theRow2, nRow1, nDy );
eRet = UR_UPDATED;
}
- if (eRet != UR_NOTHING && oldRow1 == 0 && oldRow2 == MAXROW)
+ if (eRet != UR_NOTHING && oldRow1 == 0 && oldRow2 == pDoc->MaxRow())
{
eRet = UR_STICKY;
theRow1 = oldRow1;
theRow2 = oldRow2;
}
- else if (oldRow2 == MAXROW && oldRow1 < MAXROW)
+ else if (oldRow2 == pDoc->MaxRow() && oldRow1 < pDoc->MaxRow())
{
// End was sticky, but start may have been moved. Only on range.
theRow2 = oldRow2;
if (eRet == UR_NOTHING)
eRet = UR_STICKY;
}
- // Else, if (bCut2 && theRow2 == MAXROW) then end becomes sticky,
+ // Else, if (bCut2 && theRow2 == pDoc->MaxRow()) then end becomes sticky,
// but currently there's nothing to do.
}
if ( nDz && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
@@ -304,11 +304,11 @@ ScRefUpdateRes ScRefUpdate::Update( const ScDocument* pDoc, UpdateRefMode eUpdat
{
if ( nDx )
{
- bCut1 = lcl_MoveItCut( theCol1, nDx, MAXCOL );
- bCut2 = lcl_MoveItCut( theCol2, nDx, MAXCOL );
+ bCut1 = lcl_MoveItCut( theCol1, nDx, pDoc->MaxCol() );
+ bCut2 = lcl_MoveItCut( theCol2, nDx, pDoc->MaxCol() );
if ( bCut1 || bCut2 )
eRet = UR_UPDATED;
- if (eRet != UR_NOTHING && oldCol1 == 0 && oldCol2 == MAXCOL)
+ if (eRet != UR_NOTHING && oldCol1 == 0 && oldCol2 == pDoc->MaxCol())
{
eRet = UR_STICKY;
theCol1 = oldCol1;
@@ -317,11 +317,11 @@ ScRefUpdateRes ScRefUpdate::Update( const ScDocument* pDoc, UpdateRefMode eUpdat
}
if ( nDy )
{
- bCut1 = lcl_MoveItCut( theRow1, nDy, MAXROW );
- bCut2 = lcl_MoveItCut( theRow2, nDy, MAXROW );
+ bCut1 = lcl_MoveItCut( theRow1, nDy, pDoc->MaxRow() );
+ bCut2 = lcl_MoveItCut( theRow2, nDy, pDoc->MaxRow() );
if ( bCut1 || bCut2 )
eRet = UR_UPDATED;
- if (eRet != UR_NOTHING && oldRow1 == 0 && oldRow2 == MAXROW)
+ if (eRet != UR_NOTHING && oldRow1 == 0 && oldRow2 == pDoc->MaxRow())
{
eRet = UR_STICKY;
theRow1 = oldRow1;
diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx
index daef7a95d082..7573534bdd86 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -354,7 +354,7 @@ void SharedFormulaUtil::unshareFormulaCell(const CellStoreType::position_type& a
rCell.SetCellGroup(xNone);
}
-void SharedFormulaUtil::unshareFormulaCells(CellStoreType& rCells, std::vector<SCROW>& rRows)
+void SharedFormulaUtil::unshareFormulaCells(const ScDocument* pDoc, CellStoreType& rCells, std::vector<SCROW>& rRows)
{
if (rRows.empty())
return;
@@ -367,12 +367,12 @@ void SharedFormulaUtil::unshareFormulaCells(CellStoreType& rCells, std::vector<S
std::vector<SCROW> aRows2;
for (const auto& rRow : rRows)
{
- if (rRow > MAXROW)
+ if (rRow > pDoc->MaxRow())
break;
aRows2.push_back(rRow);
- if (rRow < MAXROW)
+ if (rRow < pDoc->MaxRow())
aRows2.push_back(rRow+1);
}
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 475fcf16d189..f1ee8ced4bc1 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -333,14 +333,14 @@ void ScRawToken::SetExternal( const OUString& rStr )
maExternalName = rStr;
}
-bool ScRawToken::IsValidReference() const
+bool ScRawToken::IsValidReference(const ScDocument* pDoc) const
{
switch (eType)
{
case svSingleRef:
- return aRef.Ref1.Valid();
+ return aRef.Ref1.Valid(pDoc);
case svDoubleRef:
- return aRef.Valid();
+ return aRef.Valid(pDoc);
case svExternalSingleRef:
case svExternalDoubleRef:
return true;
@@ -2249,7 +2249,7 @@ void ScTokenArray::AssignXMLString( const OUString &rText, const OUString &rForm
Assign( nTokens, aTokens );
}
-bool ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend,
+bool ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( const ScDocument* pDoc, SCCOLROW& nExtend,
const ScAddress& rPos, ScDirection eDir )
{
SCCOL nCol = 0;
@@ -2257,13 +2257,13 @@ bool ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend,
switch ( eDir )
{
case DIR_BOTTOM :
- if ( rPos.Row() < MAXROW )
+ if ( rPos.Row() < pDoc->MaxRow() )
nRow = (nExtend = rPos.Row()) + 1;
else
return false;
break;
case DIR_RIGHT :
- if ( rPos.Col() < MAXCOL )
+ if ( rPos.Col() < pDoc->MaxCol() )
nCol = static_cast<SCCOL>(nExtend = rPos.Col()) + 1;
else
return false;
@@ -2788,7 +2788,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
// The reference range is truncated on the left.
SCCOL nOffset = rDeletedRange.aStart.Col() - rRefRange.aStart.Col();
SCCOL nDelta = rRefRange.aStart.Col() - rDeletedRange.aEnd.Col() - 1;
- rRefRange.IncEndColSticky(nDelta+nOffset);
+ rRefRange.IncEndColSticky(&rCxt.mrDoc, nDelta+nOffset);
rRefRange.aStart.IncCol(nOffset);
}
}
@@ -2801,7 +2801,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
// Reference is deleted in the middle. Move the last column
// position to the left.
SCCOL nDelta = rDeletedRange.aStart.Col() - rDeletedRange.aEnd.Col() - 1;
- rRefRange.IncEndColSticky(nDelta);
+ rRefRange.IncEndColSticky(&rCxt.mrDoc, nDelta);
}
else
{
@@ -2811,7 +2811,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
// The reference range is truncated on the right.
SCCOL nDelta = rDeletedRange.aStart.Col() - rRefRange.aEnd.Col() - 1;
- rRefRange.IncEndColSticky(nDelta);
+ rRefRange.IncEndColSticky(&rCxt.mrDoc, nDelta);
}
return SHRUNK;
}
@@ -2839,7 +2839,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
// The reference range is truncated on the top.
SCCOL nOffset = rDeletedRange.aStart.Row() - rRefRange.aStart.Row();
SCCOL nDelta = rRefRange.aStart.Row() - rDeletedRange.aEnd.Row() - 1;
- rRefRange.IncEndRowSticky(nDelta+nOffset);
+ rRefRange.IncEndRowSticky(&rCxt.mrDoc, nDelta+nOffset);
rRefRange.aStart.IncRow(nOffset);
}
}
@@ -2852,7 +2852,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
// Reference is deleted in the middle. Move the last row
// position upward.
SCCOL nDelta = rDeletedRange.aStart.Row() - rDeletedRange.aEnd.Row() - 1;
- rRefRange.IncEndRowSticky(nDelta);
+ rRefRange.IncEndRowSticky(&rCxt.mrDoc, nDelta);
}
else
{
@@ -2862,7 +2862,7 @@ ShrinkResult shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange,
// The reference range is truncated on the bottom.
SCCOL nDelta = rDeletedRange.aStart.Row() - rRefRange.aEnd.Row() - 1;
- rRefRange.IncEndRowSticky(nDelta);
+ rRefRange.IncEndRowSticky(&rCxt.mrDoc, nDelta);
}
return SHRUNK;
}
@@ -2906,7 +2906,7 @@ bool expandRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, const Sc
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list