diff options
63 files changed, 409 insertions, 369 deletions
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 // Move the last column position to the right. SCCOL nDelta = rSelectedRange.aEnd.Col() - rSelectedRange.aStart.Col() + 1; - rRefRange.IncEndColSticky(nDelta); + rRefRange.IncEndColSticky(&rCxt.mrDoc, nDelta); return true; } else if (rCxt.mnRowDelta > 0) @@ -2939,7 +2939,7 @@ bool expandRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, const Sc // Move the last row position down. SCROW nDelta = rSelectedRange.aEnd.Row() - rSelectedRange.aStart.Row() + 1; - rRefRange.IncEndRowSticky(nDelta); + rRefRange.IncEndRowSticky(&rCxt.mrDoc, nDelta); return true; } return false; @@ -2986,7 +2986,7 @@ bool expandRangeByEdge( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, co // Move the last column position to the right. SCCOL nDelta = rSelectedRange.aEnd.Col() - rSelectedRange.aStart.Col() + 1; - rRefRange.IncEndColSticky(nDelta); + rRefRange.IncEndColSticky(&rCxt.mrDoc, nDelta); return true; } else if (rCxt.mnRowDelta > 0) @@ -3013,7 +3013,7 @@ bool expandRangeByEdge( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, co // Move the last row position down. SCROW nDelta = rSelectedRange.aEnd.Row() - rSelectedRange.aStart.Row() + 1; - rRefRange.IncEndRowSticky(nDelta); + rRefRange.IncEndRowSticky(&rCxt.mrDoc, nDelta); return true; } @@ -3202,7 +3202,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon else { ScRange aErrorRange( ScAddress::UNINITIALIZED ); - if (!aAbs.MoveSticky(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta, aErrorRange)) + if (!aAbs.MoveSticky(&rCxt.mrDoc, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta, aErrorRange)) aAbs = aErrorRange; aRes.mbReferenceModified = true; } @@ -3555,7 +3555,7 @@ bool adjustSingleRefInName( { if (pEndOfComplex) { - if (pEndOfComplex->IncEndColSticky( rCxt.mnColDelta, rPos)) + if (pEndOfComplex->IncEndColSticky( &rCxt.mrDoc, rCxt.mnColDelta, rPos)) bChanged = true; } else @@ -3573,7 +3573,7 @@ bool adjustSingleRefInName( { if (pEndOfComplex) { - if (pEndOfComplex->IncEndRowSticky( rCxt.mnRowDelta, rPos)) + if (pEndOfComplex->IncEndRowSticky( &rCxt.mrDoc, rCxt.mnRowDelta, rPos)) bChanged = true; } else @@ -3612,7 +3612,7 @@ bool adjustDoubleRefInName( { // Selection intersects the referenced range. Only expand the // bottom position. - rRef.IncEndRowSticky(rCxt.mnRowDelta, rPos); + rRef.IncEndRowSticky(&rCxt.mrDoc, rCxt.mnRowDelta, rPos); return true; } } @@ -3629,7 +3629,7 @@ bool adjustDoubleRefInName( { // Selection intersects the referenced range. Only expand the // right position. - rRef.IncEndColSticky(rCxt.mnColDelta, rPos); + rRef.IncEndColSticky(&rCxt.mrDoc, rCxt.mnColDelta, rPos); return true; } } @@ -4812,7 +4812,7 @@ void appendString( OUStringBuffer& rBuf, const OUString& rStr ) rBuf.append('"'); } -void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, const FormulaToken& rToken,\ +void appendTokenByType( const ScDocument* pDoc, sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, const FormulaToken& rToken, const ScAddress& rPos, bool bFromRangeName ) { if (rToken.IsExternalRef()) @@ -4843,7 +4843,7 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons return; rCxt.mpRefConv->makeExternalRefStr( - rBuf, rPos, nFileId, aFileName, it->second, aTabName, + pDoc, rBuf, rPos, nFileId, aFileName, it->second, aTabName, *rToken.GetDoubleRef()); } break; @@ -4881,7 +4881,7 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons ScComplexRefData aRef; aRef.Ref1 = rRef; aRef.Ref2 = rRef; - rCxt.mpRefConv->makeRefStr(rBuf, rCxt.meGram, rPos, rCxt.maErrRef, rCxt.maTabNames, aRef, true, + rCxt.mpRefConv->makeRefStr(pDoc, rBuf, rCxt.meGram, rPos, rCxt.maErrRef, rCxt.maTabNames, aRef, true, bFromRangeName); } else @@ -4893,7 +4893,7 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons if (rCxt.mpRefConv) { const ScComplexRefData& rRef = *rToken.GetDoubleRef(); - rCxt.mpRefConv->makeRefStr(rBuf, rCxt.meGram, rPos, rCxt.maErrRef, rCxt.maTabNames, rRef, false, + rCxt.mpRefConv->makeRefStr(pDoc, rBuf, rCxt.meGram, rPos, rCxt.maErrRef, rCxt.maTabNames, rRef, false, bFromRangeName); } else @@ -5090,7 +5090,7 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons } -OUString ScTokenArray::CreateString( sc::TokenStringContext& rCxt, const ScAddress& rPos ) const +OUString ScTokenArray::CreateString( const ScDocument* pDoc, sc::TokenStringContext& rCxt, const ScAddress& rPos ) const { if (!nLen) return OUString(); @@ -5113,7 +5113,7 @@ OUString ScTokenArray::CreateString( sc::TokenStringContext& rCxt, const ScAddre if (eOp < rCxt.mxOpCodeMap->getSymbolCount()) aBuf.append(rCxt.mxOpCodeMap->getSymbol(eOp)); - appendTokenByType(rCxt, aBuf, *pToken, rPos, IsFromRangeName()); + appendTokenByType(pDoc, rCxt, aBuf, *pToken, rPos, IsFromRangeName()); } return aBuf.makeStringAndClear(); diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index b4da8ba38617..4fbe955d8b52 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -484,7 +484,7 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) XML_hashValue, rProt.maPasswordHash.maHashValue.isEmpty() ? nullptr : rProt.maPasswordHash.maHashValue.toUtf8().getStr(), XML_saltValue, rProt.maPasswordHash.maSaltValue.isEmpty() ? nullptr : rProt.maPasswordHash.maSaltValue.toUtf8().getStr(), XML_spinCount, rProt.maPasswordHash.mnSpinCount ? OString::number( rProt.maPasswordHash.mnSpinCount).getStr() : nullptr, - XML_sqref, rProt.maRangeList.is() ? XclXmlUtils::ToOString( *rProt.maRangeList).getStr() : nullptr); + XML_sqref, rProt.maRangeList.is() ? XclXmlUtils::ToOString( &rStrm.GetRoot().GetDoc(), *rProt.maRangeList).getStr() : nullptr); } rWorksheet->endElement( XML_protectedRanges); } @@ -986,7 +986,7 @@ void ExcAutoFilterRecs::SaveXml( XclExpXmlStream& rStrm ) return; sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); - rWorksheet->startElement(XML_autoFilter, XML_ref, XclXmlUtils::ToOString(maRef)); + rWorksheet->startElement(XML_autoFilter, XML_ref, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), maRef)); // OOXTODO: XML_extLst, XML_sortState if( !maFilterList.IsEmpty() ) maFilterList.SaveXml( rStrm ); diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 38155ca6eaa8..d1fa70c52dd5 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -309,7 +309,8 @@ void XclExpMergedcells::SaveXml( XclExpXmlStream& rStrm ) for( size_t i = 0; i < nCount; ++i ) { const ScRange & rRange = maMergedRanges[ i ]; - rWorksheet->singleElement(XML_mergeCell, XML_ref, XclXmlUtils::ToOString(rRange)); + rWorksheet->singleElement(XML_mergeCell, XML_ref, + XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), rRange)); } rWorksheet->endElement( XML_mergeCells ); } @@ -521,7 +522,7 @@ void XclExpHyperlink::SaveXml( XclExpXmlStream& rStrm ) oox::getRelationship(Relationship::HYPERLINK), msTarget, true ) : OUString(); rStrm.GetCurrentStream()->singleElement( XML_hyperlink, - XML_ref, XclXmlUtils::ToOString(maScPos), + XML_ref, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), maScPos), FSNS( XML_r, XML_id ), !sId.isEmpty() ? sId.toUtf8().getStr() : nullptr, @@ -1356,7 +1357,7 @@ XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat else if(pFormatEntry->GetType() == ScFormatEntry::Type::Date) maCFList.AppendNewRecord( new XclExpDateFormat( GetRoot(), static_cast<const ScCondDateFormatEntry&>(*pFormatEntry), ++rIndex ) ); } - aScRanges.Format( msSeqRef, ScRefFlags::VALID, nullptr, formula::FormulaGrammar::CONV_XL_OOX, ' ', true ); + aScRanges.Format( msSeqRef, ScRefFlags::VALID, &GetDoc(), formula::FormulaGrammar::CONV_XL_OOX, ' ', true ); if(!aExtEntries.empty() && xExtLst.get()) { @@ -1850,7 +1851,7 @@ void XclExpDV::SaveXml( XclExpXmlStream& rStrm ) XML_showDropDown, ToPsz( ::get_flag( mnFlags, EXC_DV_SUPPRESSDROPDOWN ) ), XML_showErrorMessage, ToPsz( ::get_flag( mnFlags, EXC_DV_SHOWERROR ) ), XML_showInputMessage, ToPsz( ::get_flag( mnFlags, EXC_DV_SHOWPROMPT ) ), - XML_sqref, XclXmlUtils::ToOString(maScRanges), + XML_sqref, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), maScRanges), XML_type, lcl_GetValidationType(mnFlags) ); if( !msFormula1.isEmpty() ) { diff --git a/sc/source/filter/excel/xedbdata.cxx b/sc/source/filter/excel/xedbdata.cxx index 416cb34da9a6..7dfb44eec058 100644 --- a/sc/source/filter/excel/xedbdata.cxx +++ b/sc/source/filter/excel/xedbdata.cxx @@ -182,7 +182,7 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, const Entry& rEntry ) XML_id, OString::number( rEntry.mnTableId), XML_name, rData.GetName().toUtf8(), XML_displayName, rData.GetName().toUtf8(), - XML_ref, XclXmlUtils::ToOString(aRange), + XML_ref, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), aRange), XML_headerRowCount, ToPsz10(rData.HasHeader()), XML_totalsRowCount, ToPsz10(rData.HasTotals()), XML_totalsRowShown, ToPsz10(rData.HasTotals()) // we don't support that but if there are totals they are shown diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 097eabd9f575..c49e6a709177 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1146,6 +1146,7 @@ const css::uno::Reference<css::chart::XChartDocument>& XclExpChartObj::GetChartD XclExpNote::XclExpNote(const XclExpRoot& rRoot, const ScAddress& rScPos, const ScPostIt* pScNote, const OUString& rAddText) : XclExpRecord(EXC_ID_NOTE) + , mrRoot(rRoot) , maScPos(rScPos) , mnObjId(EXC_OBJ_INVALID_ID) , mbVisible(pScNote && pScNote->IsCaptionShown()) @@ -1284,7 +1285,7 @@ void XclExpNote::WriteXml( sal_Int32 nAuthorId, XclExpXmlStream& rStrm ) sax_fastparser::FSHelperPtr rComments = rStrm.GetCurrentStream(); rComments->startElement( XML_comment, - XML_ref, XclXmlUtils::ToOString(maScPos), + XML_ref, XclXmlUtils::ToOString(&mrRoot.GetDoc(), maScPos), XML_authorId, OString::number(nAuthorId) // OOXTODO: XML_guid ); diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx index c2764b43da26..a3c25320ff72 100644 --- a/sc/source/filter/excel/xeextlst.cxx +++ b/sc/source/filter/excel/xeextlst.cxx @@ -464,7 +464,7 @@ void XclExpExtConditionalFormatting::SaveXml( XclExpXmlStream& rStrm ) maCfRules.SaveXml( rStrm ); rWorksheet->startElementNS(XML_xm, XML_sqref); - rWorksheet->write(XclXmlUtils::ToOString(maRange)); + rWorksheet->write(XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), maRange)); rWorksheet->endElementNS( XML_xm, XML_sqref ); diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 20fe2c914553..70603454b68d 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -1230,26 +1230,26 @@ void XclExpCrn::SaveXml( XclExpXmlStream& rStrm ) if (rtl::math::isFinite( fVal)) { // t='n' is omitted - pFS->startElement(XML_cell, XML_r, XclXmlUtils::ToOString(aAdr)); + pFS->startElement(XML_cell, XML_r, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), aAdr)); pFS->startElement(XML_v); pFS->write( fVal ); } else { - pFS->startElement(XML_cell, XML_r, XclXmlUtils::ToOString(aAdr), XML_t, "e"); + pFS->startElement(XML_cell, XML_r, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), aAdr), XML_t, "e"); pFS->startElement(XML_v); pFS->write( "#VALUE!" ); // OOXTODO: support other error values } } else if( rValue.has< OUString >() ) { - pFS->startElement(XML_cell, XML_r, XclXmlUtils::ToOString(aAdr), XML_t, "str"); + pFS->startElement(XML_cell, XML_r, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), aAdr), XML_t, "str"); pFS->startElement(XML_v); pFS->write( rValue.get< OUString >() ); } else if( rValue.has< bool >() ) { - pFS->startElement(XML_cell, XML_r, XclXmlUtils::ToOString(aAdr), XML_t, "b"); + pFS->startElement(XML_cell, XML_r, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), aAdr), XML_t, "b"); pFS->startElement(XML_v); pFS->write( rValue.get< bool >() ? "1" : "0" ); } diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx index f39bab0e63bf..e5af3d924863 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -271,7 +271,7 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr OUString aSheetName; GetDoc().GetName(rEntry.maSrcRange.aStart.Tab(), aSheetName); pDefStrm->singleElement(XML_worksheetSource, - XML_ref, XclXmlUtils::ToOString(rEntry.maSrcRange), + XML_ref, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), rEntry.maSrcRange), XML_sheet, aSheetName.toUtf8()); pDefStrm->endElement(XML_cacheSource); @@ -864,7 +864,7 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP pPivotStrm->write("<")->writeId(XML_location); rStrm.WriteAttributes(XML_ref, - XclXmlUtils::ToOString(aOutRange), + XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), aOutRange), XML_firstHeaderRow, OUString::number(nFirstHeaderRow), XML_firstDataRow, OUString::number(nFirstDataRow), XML_firstDataCol, OUString::number(nFirstDataCol)); diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index 937a7d0c8ed2..2a2518840828 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -718,18 +718,18 @@ OString XclXmlUtils::ToOString( const ScfUInt16Vec& rBuffer ) RTL_TEXTENCODING_UTF8); } -OString XclXmlUtils::ToOString( const ScRange& rRange, bool bFullAddressNotation ) +OString XclXmlUtils::ToOString( const ScDocument* pDoc, const ScRange& rRange, bool bFullAddressNotation ) { - OUString sRange(rRange.Format( ScRefFlags::VALID, nullptr, + OUString sRange(rRange.Format( ScRefFlags::VALID, pDoc, ScAddress::Details( FormulaGrammar::CONV_XL_A1 ), bFullAddressNotation ) ); return sRange.toUtf8(); } -OString XclXmlUtils::ToOString( const ScRangeList& rRangeList ) +OString XclXmlUtils::ToOString( const ScDocument* pDoc, const ScRangeList& rRangeList ) { OUString s; - rRangeList.Format(s, ScRefFlags::VALID, nullptr, FormulaGrammar::CONV_XL_OOX, ' '); + rRangeList.Format(s, ScRefFlags::VALID, pDoc, FormulaGrammar::CONV_XL_OOX, ' '); return s.toUtf8(); } @@ -768,14 +768,14 @@ static ScRange lcl_ToRange( const XclRange& rRange ) return aRange; } -OString XclXmlUtils::ToOString( const XclRangeList& rRanges ) +OString XclXmlUtils::ToOString( const ScDocument* pDoc, const XclRangeList& rRanges ) { ScRangeList aRanges; for( const auto& rRange : rRanges ) { aRanges.push_back( lcl_ToRange( rRange ) ); } - return ToOString( aRanges ); + return ToOString( pDoc, aRanges ); } OUString XclXmlUtils::ToOUString( const char* s ) diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index d7a3adf8f7e6..27c7a4960da5 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -1480,6 +1480,7 @@ void XclExpGuts::WriteBody( XclExpStream& rStrm ) } XclExpDimensions::XclExpDimensions( const XclExpRoot& rRoot ) : + mrRoot(rRoot), mnFirstUsedXclRow( 0 ), mnFirstFreeXclRow( 0 ), mnFirstUsedXclCol( 0 ), @@ -1523,7 +1524,7 @@ void XclExpDimensions::SaveXml( XclExpXmlStream& rStrm ) // To be compatible with MS Office 2007, // we need full address notation format // e.g. "A1:AMJ177" and not partial like: "1:177". - XML_ref, XclXmlUtils::ToOString(aRange, true) ); + XML_ref, XclXmlUtils::ToOString(&mrRoot.GetDoc(), aRange, true) ); } void XclExpDimensions::WriteBody( XclExpStream& rStrm ) diff --git a/sc/source/filter/excel/xeview.cxx b/sc/source/filter/excel/xeview.cxx index 91a372700560..b7efb0ac1a27 100644 --- a/sc/source/filter/excel/xeview.cxx +++ b/sc/source/filter/excel/xeview.cxx @@ -232,7 +232,7 @@ void XclExpSelection::SaveXml( XclExpXmlStream& rStrm ) XML_pane, lcl_GetActivePane( mnPane ), XML_activeCell, XclXmlUtils::ToOString( rStrm.GetRoot().GetStringBuf(), maSelData.maXclCursor ).getStr(), XML_activeCellId, OString::number(maSelData.mnCursorIdx), - XML_sqref, XclXmlUtils::ToOString(maSelData.maXclSelection) ); + XML_sqref, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), maSelData.maXclSelection) ); } void XclExpSelection::WriteBody( XclExpStream& rStrm ) diff --git a/sc/source/filter/inc/xeescher.hxx b/sc/source/filter/inc/xeescher.hxx index 880545307751..62660b8e1b9e 100644 --- a/sc/source/filter/inc/xeescher.hxx +++ b/sc/source/filter/inc/xeescher.hxx @@ -347,6 +347,7 @@ private: virtual void WriteBody( XclExpStream& rStrm ) override; private: + const XclExpRoot& mrRoot; XclExpString maAuthor; /// Name of the author. OString maNoteText; /// Main text of the note (<=BIFF7). XclExpStringRef mpNoteContents; /// Text and formatting data (OOXML) diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx index 36e1543f5269..2a2a07bcca61 100644 --- a/sc/source/filter/inc/xestream.hxx +++ b/sc/source/filter/inc/xestream.hxx @@ -254,11 +254,11 @@ public: static OString ToOString( const Color& rColor ); static OString ToOString( const ScfUInt16Vec& rBuffer ); static OStringBuffer& ToOString( OStringBuffer& s, const ScAddress& rRange ); - static OString ToOString( const ScRange& rRange, bool bFullAddressNotation = false ); - static OString ToOString( const ScRangeList& rRangeList ); + static OString ToOString( const ScDocument* pDoc, const ScRange& rRange, bool bFullAddressNotation = false ); + static OString ToOString( const ScDocument* pDoc, const ScRangeList& rRangeList ); static OStringBuffer& ToOString( OStringBuffer& s, const XclAddress& rAddress ); static OString ToOString( const XclExpString& s ); - static OString ToOString( const XclRangeList& rRangeList ); + static OString ToOString( const ScDocument* pDoc, const XclRangeList& rRangeList ); static OUString ToOUString( const char* s ); static OUString ToOUString( const ScfUInt16Vec& rBuffer, sal_Int32 nStart = 0, sal_Int32 nLength = -1 ); diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx index f64bfe0794a3..bf3d4cccab5a 100644 --- a/sc/source/filter/inc/xetable.hxx +++ b/sc/source/filter/inc/xetable.hxx @@ -655,6 +655,7 @@ private: virtual void WriteBody( XclExpStream& rStrm ) override; private: + const XclExpRoot& mrRoot; sal_uInt32 mnFirstUsedXclRow; /// First used row. sal_uInt32 mnFirstFreeXclRow; /// First unused row after used area. sal_uInt16 mnFirstUsedXclCol; /// First used column. diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index b7c537b21f0b..ffc60099eba8 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -54,7 +54,7 @@ public: }; explicit CachedTokenArray( ScDocument& rDoc ) : - maCxt(&rDoc, formula::FormulaGrammar::GRAM_OOXML) {} + maCxt(&rDoc, formula::FormulaGrammar::GRAM_OOXML), mpDoc(&rDoc) {} Item* get( const ScAddress& rPos, const OUString& rFormula ) { @@ -65,7 +65,7 @@ public: Item& rCached = *it->second; const ScTokenArray& rCode = *rCached.mpCell->GetCode(); - OUString aPredicted = rCode.CreateString(maCxt, rPos); + OUString aPredicted = rCode.CreateString(mpDoc, maCxt, rPos); if (rFormula == aPredicted) return &rCached; @@ -96,6 +96,7 @@ private: typedef std::unordered_map<SCCOL, std::unique_ptr<Item>> ColCacheType; ColCacheType maCache; sc::TokenStringContext maCxt; + const ScDocument* mpDoc; }; void applySharedFormulas( diff --git a/sc/source/filter/oox/revisionfragment.cxx b/sc/source/filter/oox/revisionfragment.cxx index afbbfa1af5c2..937c63a2010a 100644 --- a/sc/source/filter/oox/revisionfragment.cxx +++ b/sc/source/filter/oox/revisionfragment.cxx @@ -164,7 +164,7 @@ private: OUString aRefStr = rAttribs.getString(XML_r, OUString()); if (!aRefStr.isEmpty()) { - mrPos.Parse(aRefStr, nullptr, formula::FormulaGrammar::CONV_XL_OOX); + mrPos.Parse(aRefStr, &getScDocument(), formula::FormulaGrammar::CONV_XL_OOX); if (mnSheetIndex != -1) mrPos.SetTab(mnSheetIndex-1); } diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx index ba33eee4510c..b8d1cef7ada2 100644 --- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx @@ -992,7 +992,7 @@ static void lcl_WriteCell( XclExpXmlStream& rStrm, sal_Int32 nElement, const ScA sax_fastparser::FSHelperPtr pStream = rStrm.GetCurrentStream(); pStream->startElement(nElement, - XML_r, XclXmlUtils::ToOString(rPosition), + XML_r, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), rPosition), XML_s, nullptr, // OOXTODO: not supported XML_t, lcl_GetType(pData), XML_cm, nullptr, // OOXTODO: not supported @@ -1053,7 +1053,7 @@ void XclExpChTrCellContent::SaveXml( XclExpXmlStream& rRevisionLogStrm ) lcl_WriteCell( rRevisionLogStrm, XML_oc, aPosition, pOldData.get() ); if (!pNewData) { - pStream->singleElement(XML_nc, XML_r, XclXmlUtils::ToOString(aPosition)); + pStream->singleElement(XML_nc, XML_r, XclXmlUtils::ToOString(&rRevisionLogStrm.GetRoot().GetDoc(), aPosition)); } } if( pNewData ) @@ -1169,7 +1169,7 @@ void XclExpChTrInsert::SaveXml( XclExpXmlStream& rRevisionLogStrm ) XML_ra, nullptr, // OOXTODO: RRD.fUndoAction? Or RRD.fAccepted? XML_sId, OString::number(GetTabId(aRange.aStart.Tab())), XML_eol, ToPsz10(mbEndOfList), - XML_ref, XclXmlUtils::ToOString(aRange), + XML_ref, XclXmlUtils::ToOString(&rRevisionLogStrm.GetRoot().GetDoc(), aRange), XML_action, lcl_GetAction( nOpCode ), XML_edge, nullptr); // OOXTODO: ??? @@ -1293,8 +1293,8 @@ void XclExpChTrMoveRange::SaveXml( XclExpXmlStream& rRevisionLogStrm ) XML_ua, ToPsz( GetAccepted () ), // OOXTODO? bAccepted == ua or ra; not sure. XML_ra, nullptr, // OOXTODO: RRD.fUndoAction? Or RRD.fAccepted? XML_sheetId, OString::number(GetTabId(aDestRange.aStart.Tab())), - XML_source, XclXmlUtils::ToOString(aSourceRange), - XML_destination, XclXmlUtils::ToOString(aDestRange), + XML_source, XclXmlUtils::ToOString(&rRevisionLogStrm.GetRoot().GetDoc(), aSourceRange), + XML_destination, XclXmlUtils::ToOString(&rRevisionLogStrm.GetRoot().GetDoc(), aDestRange), XML_sourceSheetId, OString::number(GetTabId(aSourceRange.aStart.Tab())) ); // OOXTODO: does this handle XML_rfmt, XML_undo? XclExpChTrAction* pAction = GetAddAction(); @@ -1343,7 +1343,7 @@ void XclExpChTr0x014A::SaveXml( XclExpXmlStream& rStrm ) XML_sheetId, OString::number(GetTabId(aRange.aStart.Tab())), XML_xfDxf, nullptr, // OOXTODO: not supported XML_s, nullptr, // OOXTODO: style - XML_sqref, XclXmlUtils::ToOString(aRange), + XML_sqref, XclXmlUtils::ToOString(&rStrm.GetRoot().GetDoc(), aRange), XML_start, nullptr, // OOXTODO: for string changes XML_length, nullptr); // OOXTODO: for string changes // OOXTODO: XML_dxf, XML_extLst diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 3384e305185e..5597b635ecbd 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -1338,7 +1338,7 @@ void ExcEScenarioCell::SaveXml( XclExpXmlStream& rStrm ) const rStrm.GetCurrentStream()->singleElement( XML_inputCells, // OOXTODO: XML_deleted, // OOXTODO: XML_numFmtId, - XML_r, XclXmlUtils::ToOString( ScAddress( nCol, nRow, 0 ) ), + XML_r, XclXmlUtils::ToOString( &rStrm.GetRoot().GetDoc(), ScAddress( nCol, nRow, 0 ) ), // OOXTODO: XML_undone, XML_val, XclXmlUtils::ToOString( sText ) ); } diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index c1ca7b44f2c5..957b515759fb 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -5165,7 +5165,7 @@ void ScDocFunc::CreateOneName( ScRangeName& rList, if (!rDoc.HasValueData( nPosX, nPosY, nTab )) { OUString aName = rDoc.GetString(nPosX, nPosY, nTab); - ScRangeData::MakeValidName(aName); + ScRangeData::MakeValidName(&rDoc, aName); if (!aName.isEmpty()) { OUString aContent(ScRange( nX1, nY1, nTab, nX2, nY2, nTab ).Format(ScRefFlags::RANGE_ABS_3D, &rDoc)); diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index 784281c57185..697d407d6f4f 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -347,7 +347,7 @@ bool ScFormulaDlg::calculateValue( const OUString& rStrExp, OUString& rStrResult } ScRange aTestRange; - if ( bColRowName || (aTestRange.Parse(rStrExp) & ScRefFlags::VALID) ) + if ( bColRowName || (aTestRange.Parse(rStrExp, m_pDoc) & ScRefFlags::VALID) ) rStrResult += " ..."; // area } diff --git a/sc/source/ui/inc/navipi.hxx b/sc/source/ui/inc/navipi.hxx index 40f28e091c03..a434df66e57f 100644 --- a/sc/source/ui/inc/navipi.hxx +++ b/sc/source/ui/inc/navipi.hxx @@ -112,9 +112,10 @@ class ColumnEdit : public SpinField public: ColumnEdit(Window* pParent, WinBits nWinBits); ~ColumnEdit() override; - void SetNavigatorDlg(ScNavigatorDlg *pNaviDlg) + void SetNavigatorDlg(ScNavigatorDlg *pNaviDlg, const ScDocument* pDoc) { xDlg = pNaviDlg; + mpDoc = pDoc; } SCCOL GetCol() const { return nCol; } void SetCol( SCCOL nColNo ); @@ -129,12 +130,13 @@ protected: virtual void dispose() override; private: + const ScDocument* mpDoc; VclPtr<ScNavigatorDlg> xDlg; SCCOL nCol; void EvalText(); void ExecuteCol(); - static SCCOL AlphaToNum ( OUString& rStr ); + static SCCOL AlphaToNum ( const ScDocument* pDoc, OUString& rStr ); static SCCOL NumStrToAlpha ( OUString& rStr ); static SCCOL NumToAlpha ( SCCOL nColNo, OUString& rStr ); }; diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx index 3b27a6b4ad5c..063823d594c2 100644 --- a/sc/source/ui/navipi/navipi.cxx +++ b/sc/source/ui/navipi/navipi.cxx @@ -68,8 +68,8 @@ void ScNavigatorDlg::ReleaseFocus() } ColumnEdit::ColumnEdit(Window* pParent, WinBits nWinBits) - : SpinField(pParent, nWinBits) - , nCol(0) + : SpinField(pParent, nWinBits), + nCol(0) { SetMaxTextLen(SCNAV_COLDIGITS); // 1...256...18278 or A...IV...ZZZ } @@ -162,7 +162,7 @@ void ColumnEdit::EvalText() if ( CharClass::isAsciiNumeric(aStrCol) ) nCol = NumStrToAlpha( aStrCol ); else - nCol = AlphaToNum( aStrCol ); + nCol = AlphaToNum( mpDoc, aStrCol ); } else nCol = 0; @@ -197,7 +197,7 @@ void ColumnEdit::SetCol( SCCOL nColNo ) } } -SCCOL ColumnEdit::AlphaToNum( OUString& rStr ) +SCCOL ColumnEdit::AlphaToNum( const ScDocument* pDoc, OUString& rStr ) { SCCOL nColumn = 0; @@ -205,7 +205,7 @@ SCCOL ColumnEdit::AlphaToNum( OUString& rStr ) { rStr = rStr.toAsciiUpperCase(); - if (::AlphaToCol( nColumn, rStr)) + if (::AlphaToCol( pDoc, nColumn, rStr)) ++nColumn; if ( (rStr.getLength() > SCNAV_COLLETTERS) || (nColumn > SCNAV_MAXCOL) ) @@ -459,7 +459,8 @@ ScNavigatorDlg::ScNavigatorDlg(SfxBindings* pB, vcl::Window* pParent) { get(aLbDocuments, "documents"); get(aEdCol, "column"); - aEdCol->SetNavigatorDlg(this); + ScTabViewShell* pViewSh = GetTabViewShell(); + aEdCol->SetNavigatorDlg(this, pViewSh->GetViewData().GetDocument()); get(aEdRow, "row"); aEdRow->SetNavigatorDlg(this); get(aTbxCmd, "toolbox"); diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx index 015535adf644..c6a1d2dfa88f 100644 --- a/sc/source/ui/pagedlg/areasdlg.cxx +++ b/sc/source/ui/pagedlg/areasdlg.cxx @@ -585,7 +585,7 @@ IMPL_LINK( ScPrintAreasDlg, Impl_ModifyHdl, formula::RefEdit&, rEd, void ) // TODO: It might make sense to move these functions to address.?xx. -kohei -static bool lcl_CheckOne_OOO( const OUString& rStr, bool bIsRow, SCCOLROW& rVal ) +static bool lcl_CheckOne_OOO( const ScDocument* pDoc, const OUString& rStr, bool bIsRow, SCCOLROW& rVal ) { // Allowed syntax for rStr: // Row: [$]1-MAXTAB @@ -617,7 +617,7 @@ static bool lcl_CheckOne_OOO( const OUString& rStr, bool bIsRow, SCCOLROW& rVal else { SCCOL nCol = 0; - bStrOk = ::AlphaToCol( nCol, aStr); + bStrOk = ::AlphaToCol( pDoc, nCol, aStr); nNum = nCol; } } @@ -628,10 +628,10 @@ static bool lcl_CheckOne_OOO( const OUString& rStr, bool bIsRow, SCCOLROW& rVal return bStrOk; } -static bool lcl_CheckOne_XL_A1( const OUString& rStr, bool bIsRow, SCCOLROW& rVal ) +static bool lcl_CheckOne_XL_A1( const ScDocument* pDoc, const OUString& rStr, bool bIsRow, SCCOLROW& rVal ) { // XL A1 style is identical to OOO one for print range formats. - return lcl_CheckOne_OOO(rStr, bIsRow, rVal); + return lcl_CheckOne_OOO(pDoc, rStr, bIsRow, rVal); } static bool lcl_CheckOne_XL_R1C1( const OUString& rStr, bool bIsRow, SCCOLROW& rVal ) @@ -662,14 +662,14 @@ static bool lcl_CheckOne_XL_R1C1( const OUString& rStr, bool bIsRow, SCCOLROW& r return true; } -static bool lcl_CheckRepeatOne( const OUString& rStr, formula::FormulaGrammar::AddressConvention eConv, bool bIsRow, SCCOLROW& rVal ) +static bool lcl_CheckRepeatOne( const ScDocument* pDoc, const OUString& rStr, formula::FormulaGrammar::AddressConvention eConv, bool bIsRow, SCCOLROW& rVal ) { switch (eConv) { case formula::FormulaGrammar::CONV_OOO: - return lcl_CheckOne_OOO(rStr, bIsRow, rVal); + return lcl_CheckOne_OOO(pDoc, rStr, bIsRow, rVal); case formula::FormulaGrammar::CONV_XL_A1: - return lcl_CheckOne_XL_A1(rStr, bIsRow, rVal); + return lcl_CheckOne_XL_A1(pDoc, rStr, bIsRow, rVal); case formula::FormulaGrammar::CONV_XL_R1C1: return lcl_CheckOne_XL_R1C1(rStr, bIsRow, rVal); default: @@ -714,7 +714,7 @@ static bool lcl_CheckRepeatString( const OUString& rStr, const ScDocument* pDoc, if (aBuf.isEmpty()) return false; - bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal); + bool bRes = lcl_CheckRepeatOne(pDoc, aBuf, eConv, bIsRow, nVal); if (!bRes) return false; @@ -741,7 +741,7 @@ static bool lcl_CheckRepeatString( const OUString& rStr, const ScDocument* pDoc, if (!aBuf.isEmpty()) { - bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal); + bool bRes = lcl_CheckRepeatOne(pDoc, aBuf, eConv, bIsRow, nVal); if (!bRes) return false; diff --git a/sc/source/ui/sidebar/ScPanelFactory.hxx b/sc/source/ui/sidebar/ScPanelFactory.hxx index ea5d28d53877..ca2eb6ae100b 100644 --- a/sc/source/ui/sidebar/ScPanelFactory.hxx +++ b/sc/source/ui/sidebar/ScPanelFactory.hxx @@ -24,7 +24,6 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/ui/XUIElementFactory.hpp> - namespace sc { namespace sidebar { typedef ::cppu::WeakComponentImplHelper < diff --git a/sc/source/ui/uitest/uiobject.cxx b/sc/source/ui/uitest/uiobject.cxx index d606e67cd4bc..58aef21c8e8b 100644 --- a/sc/source/ui/uitest/uiobject.cxx +++ b/sc/source/ui/uitest/uiobject.cxx @@ -25,19 +25,19 @@ namespace { -ScAddress get_address_from_string(const OUString& rStr) +ScAddress get_address_from_string(const ScDocument* pDoc, const OUString& rStr) { ScAddress aAddr; sal_Int32 nOffset = 0; - ScRangeStringConverter::GetAddressFromString(aAddr, rStr, nullptr, formula::FormulaGrammar::CONV_OOO, nOffset); + ScRangeStringConverter::GetAddressFromString(aAddr, rStr, pDoc, formula::FormulaGrammar::CONV_OOO, nOffset); return aAddr; } -ScRange get_range_from_string(const OUString& rStr) +ScRange get_range_from_string(const ScDocument* pDoc, const OUString& rStr) { ScRange aRange; sal_Int32 nOffset = 0; - ScRangeStringConverter::GetRangeFromString(aRange, rStr, nullptr, formula::FormulaGrammar::CONV_OOO, nOffset); + ScRangeStringConverter::GetRangeFromString(aRange, rStr, pDoc, formula::FormulaGrammar::CONV_OOO, nOffset); return aRange; } @@ -113,7 +113,7 @@ void ScGridWinUIObject::execute(const OUString& rAction, { auto itr = rParameters.find("CELL"); const OUString& rStr = itr->second; - ScAddress aAddr = get_address_from_string(rStr); + ScAddress aAddr = get_address_from_string(mxGridWindow->getViewData()->GetDocument(), rStr); ScDBFunc* pFunc = getDBFunc(); pFunc->MarkRange(ScRange(aAddr), true, bExtend); mxGridWindow->CursorChanged(); @@ -122,7 +122,7 @@ void ScGridWinUIObject::execute(const OUString& rAction, { auto itr = rParameters.find("RANGE"); const OUString rStr = itr->second; - ScRange aRange = get_range_from_string(rStr); + ScRange aRange = get_range_from_string(mxGridWindow->getViewData()->GetDocument(), rStr); ScDBFunc* pFunc = getDBFunc(); pFunc->MarkRange(aRange, true, bExtend); mxGridWindow->CursorChanged(); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index b30cbd61ddbc..689b785ab982 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -3872,7 +3872,7 @@ ScTableColumnObj* ScTableColumnsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) con ScTableColumnObj* ScTableColumnsObj::GetObjectByName_Impl(const OUString& aName) const { SCCOL nCol = 0; - if ( ::AlphaToCol( nCol, aName) ) + if ( ::AlphaToCol( &pDocShell->GetDocument(), nCol, aName) ) if ( pDocShell && nCol >= nStartCol && nCol <= nEndCol ) return new ScTableColumnObj( pDocShell, nCol, nTab ); @@ -3982,7 +3982,7 @@ sal_Bool SAL_CALL ScTableColumnsObj::hasByName( const OUString& aName ) { SolarMutexGuard aGuard; SCCOL nCol = 0; - if ( ::AlphaToCol( nCol, aName) ) + if ( ::AlphaToCol( &pDocShell->GetDocument(), nCol, aName) ) if ( pDocShell && nCol >= nStartCol && nCol <= nEndCol ) return true; diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 4dc452bb4844..e658059837aa 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -2121,12 +2121,13 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) // Performance: Use a common helper method for ScVbaRange::Cells and ScVbaWorksheet::Cells, // instead of creating a new ScVbaRange object in often-called ScVbaWorksheet::Cells - return CellsHelper( mxParent, mxContext, mxRange, nRowIndex, nColumnIndex ); + return CellsHelper( &getScDocument(), mxParent, mxContext, mxRange, nRowIndex, nColumnIndex ); } // static uno::Reference< excel::XRange > -ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent, +ScVbaRange::CellsHelper( const ScDocument* pDoc, + const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< css::table::XCellRange >& xRange, const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) @@ -2160,7 +2161,7 @@ ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent, { ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); ScRange tmpRange; - ScRefFlags flags = tmpRange.ParseCols( sCol, dDetails ); + ScRefFlags flags = tmpRange.ParseCols( pDoc, sCol, dDetails ); if ( (flags & ScRefFlags::COL_VALID) == ScRefFlags::ZERO ) throw uno::RuntimeException(); nColumn = tmpRange.aStart.Col() + 1; @@ -2335,7 +2336,7 @@ ScVbaRange::Rows(const uno::Any& aIndex ) { ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); ScRange tmpRange; - tmpRange.ParseRows( sAddress, dDetails ); + tmpRange.ParseRows( &getScDocument(), sAddress, dDetails ); SCROW nStartRow = tmpRange.aStart.Row(); SCROW nEndRow = tmpRange.aEnd.Row(); @@ -2379,7 +2380,7 @@ ScVbaRange::Columns(const uno::Any& aIndex ) { ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); ScRange tmpRange; - tmpRange.ParseCols( sAddress, dDetails ); + tmpRange.ParseCols( &getScDocument(), sAddress, dDetails ); SCCOL nStartCol = tmpRange.aStart.Col(); SCCOL nEndCol = tmpRange.aEnd.Col(); diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index 9cc7f6ded196..2e91dbf1a892 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -163,6 +163,7 @@ public: /// @throws css::uno::RuntimeException static css::uno::Reference< ov::excel::XRange > CellsHelper( + const ScDocument* pDoc, const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::table::XCellRange >& xRange, diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 8621d4b2fecf..05be52562e50 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -673,7 +673,9 @@ ScVbaWorksheet::Cells( const ::uno::Any &nRow, const ::uno::Any &nCol ) // Performance optimization for often-called Cells method: // Use a common helper method instead of creating a new ScVbaRange object uno::Reference< table::XCellRange > xRange( getSheet(), uno::UNO_QUERY_THROW ); - return ScVbaRange::CellsHelper( this, mxContext, xRange, nRow, nCol ); + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW ); + ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); + return ScVbaRange::CellsHelper( &rDoc, this, mxContext, xRange, nRow, nCol ); } uno::Reference< excel::XRange > diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index b572bbe601a0..f2fab305f9aa 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -3074,7 +3074,7 @@ void ScCellShell::ExecuteFillSingleEdit() aInit = "="; const ScTokenArray* pCode = aCell.mpFormula->GetCode(); sc::TokenStringContext aCxt(pDoc, pDoc->GetGrammar()); - aInit += pCode->CreateString(aCxt, aCurPos); + aInit += pCode->CreateString(pDoc, aCxt, aCurPos); } else aInit = aCell.getString(pDoc); diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index c026b077b8ec..0ab2d088b0e7 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -267,7 +267,7 @@ static ScAutoSum lcl_IsAutoSumData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, default : break; } - if ( pCode->GetAdjacentExtendOfOuterFuncRefs( nExtend, + if ( pCode->GetAdjacentExtendOfOuterFuncRefs( pDoc, nExtend, ScAddress( nCol, nRow, nTab ), eDir ) ) return val; } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 5bd55068f04f..a2218c8ddcbf 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1503,7 +1503,7 @@ void ScViewFunc::OnLOKInsertDeleteColumn(SCCOL nStartCol, long nOffset) aMultiMark.MarkToMulti(); if (aMultiMark.IsMultiMarked()) { - aMultiMark.ShiftCols(nStartCol, nOffset); + aMultiMark.ShiftCols(pTabViewShell->GetViewData().GetDocument(), nStartCol, nOffset); pTabViewShell->SetMarkData(aMultiMark); } } @@ -1558,7 +1558,7 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset) aMultiMark.MarkToMulti(); if (aMultiMark.IsMultiMarked()) { - aMultiMark.ShiftRows(nStartRow, nOffset); + aMultiMark.ShiftRows(pTabViewShell->GetViewData().GetDocument(), nStartRow, nOffset); pTabViewShell->SetMarkData(aMultiMark); } } |