diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-12-13 09:16:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-12-13 08:58:00 +0100 |
commit | 0cb4b2a18b790ff74a6893781beba2c4a4a8ce8f (patch) | |
tree | faa05b38a89863b372d8675d69b2aa2e16035a40 /sc/source | |
parent | d59987b164bc32efe8f99ad49c139b4fc7ca3c2f (diff) |
sc: rowcol: tdf#50916 pass ScDocument* around in filter/
Change-Id: Id328ee85b852eddf755876d2cde9ef75b40cfca1
Reviewed-on: https://gerrit.libreoffice.org/85090
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source')
27 files changed, 167 insertions, 116 deletions
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx index 614f266ad1a5..3d9bfd29818e 100644 --- a/sc/source/core/tool/refdata.cxx +++ b/sc/source/core/tool/refdata.cxx @@ -205,6 +205,26 @@ ScAddress ScSingleRefData::toAbs( const ScAddress& rPos ) const return aAbs; } +ScAddress ScSingleRefData::toAbs( const ScDocument* pDoc, const ScAddress& rPos ) const +{ + SCCOL nRetCol = Flags.bColRel ? mnCol + rPos.Col() : mnCol; + SCROW nRetRow = Flags.bRowRel ? mnRow + rPos.Row() : mnRow; + SCTAB nRetTab = Flags.bTabRel ? mnTab + rPos.Tab() : mnTab; + + ScAddress aAbs(ScAddress::INITIALIZE_INVALID); + + if (pDoc->ValidCol(nRetCol)) + aAbs.SetCol(nRetCol); + + if (pDoc->ValidRow(nRetRow)) + aAbs.SetRow(nRetRow); + + if (ValidTab(nRetTab)) + aAbs.SetTab(nRetTab); + + return aAbs; +} + void ScSingleRefData::SetAddress( const ScAddress& rAddr, const ScAddress& rPos ) { if (Flags.bColRel) @@ -232,6 +252,33 @@ void ScSingleRefData::SetAddress( const ScAddress& rAddr, const ScAddress& rPos SetTabDeleted(true); } +void ScSingleRefData::SetAddress( const ScDocument* pDoc, const ScAddress& rAddr, const ScAddress& rPos ) +{ + if (Flags.bColRel) + mnCol = rAddr.Col() - rPos.Col(); + else + mnCol = rAddr.Col(); + + if (!pDoc->ValidCol(rAddr.Col())) + SetColDeleted(true); + + if (Flags.bRowRel) + mnRow = rAddr.Row() - rPos.Row(); + else + mnRow = rAddr.Row(); + + if (!pDoc->ValidRow(rAddr.Row())) + SetRowDeleted(true); + + if (Flags.bTabRel) + mnTab = rAddr.Tab() - rPos.Tab(); + else + mnTab = rAddr.Tab(); + + if (!ValidTab( rAddr.Tab(), MAXTAB)) + SetTabDeleted(true); +} + SCROW ScSingleRefData::Row() const { if (Flags.bRowDeleted) @@ -485,6 +532,11 @@ ScRange ScComplexRefData::toAbs( const ScAddress& rPos ) const return ScRange(Ref1.toAbs(rPos), Ref2.toAbs(rPos)); } +ScRange ScComplexRefData::toAbs( const ScDocument* pDoc, const ScAddress& rPos ) const +{ + return ScRange(Ref1.toAbs(pDoc, rPos), Ref2.toAbs(pDoc, rPos)); +} + void ScComplexRefData::SetRange( const ScRange& rRange, const ScAddress& rPos ) { Ref1.SetAddress(rRange.aStart, rPos); diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx index 1d92ed568204..be95f26b06a4 100644 --- a/sc/source/filter/dif/difimp.cxx +++ b/sc/source/filter/dif/difimp.cxx @@ -151,20 +151,20 @@ ErrCode ScFormatFilterPluginImpl::ScImportDif(SvStream& rIn, ScDocument* pDoc, c if( nColCnt == SCCOL_MAX ) nColCnt = nBaseCol; - if( ValidCol(nColCnt) && ValidRow(nRowCnt) ) + if( pDoc->ValidCol(nColCnt) && pDoc->ValidRow(nRowCnt) ) { pDoc->EnsureTable(nBaseTab); if( DifParser::IsV( aData.getStr() ) ) { pDoc->SetValue(aPos, aDifParser.fVal); - aAttrCache.SetNumFormat( nColCnt, nRowCnt, + aAttrCache.SetNumFormat( pDoc, nColCnt, nRowCnt, aDifParser.nNumFormat ); } else if( aData == pKeyTRUE || aData == pKeyFALSE ) { pDoc->SetValue(aPos, aDifParser.fVal); - aAttrCache.SetNumFormat( nColCnt, nRowCnt, + aAttrCache.SetNumFormat( pDoc, nColCnt, nRowCnt, aDifParser.nNumFormat ); } else if( aData == pKeyNA || aData == pKeyERROR ) @@ -186,7 +186,7 @@ ErrCode ScFormatFilterPluginImpl::ScImportDif(SvStream& rIn, ScDocument* pDoc, c if( nColCnt == SCCOL_MAX ) nColCnt = nBaseCol; - if( ValidCol(nColCnt) && ValidRow(nRowCnt) ) + if( pDoc->ValidCol(nColCnt) && pDoc->ValidRow(nRowCnt) ) { if (!aData.isEmpty()) { @@ -612,9 +612,9 @@ DifColumn::DifColumn () { } -void DifColumn::SetNumFormat( SCROW nRow, const sal_uInt32 nNumFormat ) +void DifColumn::SetNumFormat( const ScDocument* pDoc, SCROW nRow, const sal_uInt32 nNumFormat ) { - OSL_ENSURE( ValidRow(nRow), "*DifColumn::SetNumFormat(): Row too big!" ); + OSL_ENSURE( pDoc->ValidRow(nRow), "*DifColumn::SetNumFormat(): Row too big!" ); if( nNumFormat > 0 ) { @@ -672,14 +672,14 @@ DifAttrCache::~DifAttrCache() { } -void DifAttrCache::SetNumFormat( const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat ) +void DifAttrCache::SetNumFormat( const ScDocument* pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat ) { - OSL_ENSURE( ValidCol(nCol), "-DifAttrCache::SetNumFormat(): Col too big!" ); + OSL_ENSURE( pDoc->ValidCol(nCol), "-DifAttrCache::SetNumFormat(): Col too big!" ); if( !maColMap.count(nCol) ) maColMap[ nCol ].reset( new DifColumn ); - maColMap[ nCol ]->SetNumFormat( nRow, nNumFormat ); + maColMap[ nCol ]->SetNumFormat( pDoc, nRow, nNumFormat ); } void DifAttrCache::Apply( ScDocument& rDoc, SCTAB nTab ) diff --git a/sc/source/filter/excel/colrowst.cxx b/sc/source/filter/excel/colrowst.cxx index b0e7495485a9..e325c73e61e9 100644 --- a/sc/source/filter/excel/colrowst.cxx +++ b/sc/source/filter/excel/colrowst.cxx @@ -82,7 +82,7 @@ void XclImpColRowSettings::SetWidthRange( SCCOL nCol1, SCCOL nCol2, sal_uInt16 n void XclImpColRowSettings::HideCol( SCCOL nCol ) { - if (!ValidCol(nCol)) + if (!GetDoc().ValidCol(nCol)) return; ApplyColFlag(nCol, ExcColRowFlags::Hidden); @@ -111,7 +111,7 @@ void XclImpColRowSettings::SetDefHeight( sal_uInt16 nDefHeight, sal_uInt16 nFlag void XclImpColRowSettings::SetHeight( SCROW nScRow, sal_uInt16 nHeight ) { - if (!ValidRow(nScRow)) + if (!GetDoc().ValidRow(nScRow)) return; sal_uInt16 nRawHeight = nHeight & EXC_ROW_HEIGHTMASK; @@ -132,7 +132,7 @@ void XclImpColRowSettings::SetHeight( SCROW nScRow, sal_uInt16 nHeight ) void XclImpColRowSettings::SetRowSettings( SCROW nScRow, sal_uInt16 nHeight, sal_uInt16 nFlags ) { - if (!ValidRow(nScRow)) + if (!GetDoc().ValidRow(nScRow)) return; SetHeight(nScRow, nHeight); @@ -152,7 +152,7 @@ void XclImpColRowSettings::SetRowSettings( SCROW nScRow, sal_uInt16 nHeight, sal void XclImpColRowSettings::SetManualRowHeight( SCROW nScRow ) { - if (!ValidRow(nScRow)) + if (!GetDoc().ValidRow(nScRow)) return; ExcColRowFlags nFlagVal = ExcColRowFlags::NONE; @@ -167,7 +167,7 @@ void XclImpColRowSettings::SetDefaultXF( SCCOL nCol1, SCCOL nCol2, sal_uInt16 nX { /* assign the default column formatting here to ensure that explicit cell formatting is not overwritten. */ - OSL_ENSURE( (nCol1 <= nCol2) && ValidCol( nCol2 ), "XclImpColRowSettings::SetDefaultXF - invalid column index" ); + OSL_ENSURE( (nCol1 <= nCol2) && GetDoc().ValidCol( nCol2 ), "XclImpColRowSettings::SetDefaultXF - invalid column index" ); nCol2 = ::std::min( nCol2, GetDoc().MaxCol() ); nCol1 = ::std::min( nCol1, nCol2 ); XclImpXFRangeBuffer& rXFRangeBuffer = GetXFRangeBuffer(); diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 6dbb629fc7c7..2d156acf77d9 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -1050,7 +1050,7 @@ ConvErr ExcelToSc::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std: ExcRelToScRel( nUINT16, nByte, aSRD, bRangeName ); - rRangeList.Append(aSRD.toAbs(aEingPos), nTab); + rRangeList.Append(aSRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); break; } case 0x45: @@ -1080,7 +1080,7 @@ ConvErr ExcelToSc::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std: else if( IsComplRowRange( nRowFirst, nRowLast ) ) SetComplRow( aCRD ); - rRangeList.Append(aCRD.toAbs(aEingPos), nTab); + rRangeList.Append(aCRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } break; case 0x46: @@ -1117,7 +1117,7 @@ ConvErr ExcelToSc::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std: ExcRelToScRel( nUINT16, nByte, aSRD, bRNorSF ); - rRangeList.Append(aSRD.toAbs(aEingPos), nTab); + rRangeList.Append(aSRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); break; } case 0x4D: @@ -1145,7 +1145,7 @@ ConvErr ExcelToSc::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std: else if( IsComplRowRange( nRowFirst, nRowLast ) ) SetComplRow( aCRD ); - rRangeList.Append(aCRD.toAbs(aEingPos), nTab); + rRangeList.Append(aCRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } break; case 0x49: @@ -1215,10 +1215,10 @@ ConvErr ExcelToSc::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std: aCRD.Ref2.SetAbsTab(static_cast<SCTAB>(nTabLast)); b3D = ( static_cast<SCTAB>(nTabLast) != aEingPos.Tab() ); aCRD.Ref2.SetFlag3D( b3D ); - rRangeList.Append(aCRD.toAbs(aEingPos), nTab); + rRangeList.Append(aCRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } else - rRangeList.Append(aSRD.toAbs(aEingPos), nTab); + rRangeList.Append(aSRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } } @@ -1275,7 +1275,7 @@ ConvErr ExcelToSc::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std: else if( IsComplRowRange( nRowFirst, nRowLast ) ) SetComplRow( aCRD ); - rRangeList.Append(aCRD.toAbs(aEingPos), nTab); + rRangeList.Append(aCRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); }//END in current Workbook } break; diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx index beee318fcd0c..fbe1151e595f 100644 --- a/sc/source/filter/excel/excform8.cxx +++ b/sc/source/filter/excel/excform8.cxx @@ -152,7 +152,7 @@ ConvErr ExcelToSc8::Convert( std::unique_ptr<ScTokenArray>& rpTokArray, XclImpSt { aPool.Store( "-/-" ); aPool >> aStack; - rpTokArray = aPool.GetTokenArray(&GetDocImport().getDoc(), aStack.Get()); + rpTokArray = aPool.GetTokenArray( &GetDocImport().getDoc(), aStack.Get()); return ConvErr::OK; } @@ -318,7 +318,7 @@ ConvErr ExcelToSc8::Convert( std::unique_ptr<ScTokenArray>& rpTokArray, XclImpSt else aSRD.SetColRel(true); - aSRD.SetAddress(aAddr, aEingPos); + aSRD.SetAddress(&GetDocImport().getDoc(), aAddr, aEingPos); aStack << aPool.StoreNlf( aSRD ); @@ -332,7 +332,7 @@ ConvErr ExcelToSc8::Convert( std::unique_ptr<ScTokenArray>& rpTokArray, XclImpSt ScAddress aAddr(static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab()); aSRD.InitAddress(aAddr); aSRD.SetColRel(true); - aSRD.SetAddress(aAddr, aEingPos); + aSRD.SetAddress(&GetDocImport().getDoc(), aAddr, aEingPos); aStack << aPool.StoreNlf( aSRD ); @@ -1066,7 +1066,7 @@ ConvErr ExcelToSc8::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std ExcRelToScRel8( nRow, nCol, aSRD, bRangeName ); - rRangeList.Append(aSRD.toAbs(aEingPos), nTab); + rRangeList.Append(aSRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } break; case 0x45: @@ -1096,7 +1096,7 @@ ConvErr ExcelToSc8::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std else if( IsComplRowRange( nRowFirst, nRowLast ) ) SetComplRow( aCRD ); - rRangeList.Append(aCRD.toAbs(aEingPos), nTab); + rRangeList.Append(aCRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } break; case 0x46: @@ -1140,7 +1140,7 @@ ConvErr ExcelToSc8::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std ExcRelToScRel8( nRow, nCol, aSRD, bRNorSF ); - rRangeList.Append(aSRD.toAbs(aEingPos), nTab); + rRangeList.Append(aSRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } break; case 0x4D: @@ -1168,7 +1168,7 @@ ConvErr ExcelToSc8::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std else if( IsComplRowRange( nRowFirst, nRowLast ) ) SetComplRow( aCRD ); - rRangeList.Append(aCRD.toAbs(aEingPos), nTab); + rRangeList.Append(aCRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } break; case 0x4E: @@ -1210,10 +1210,10 @@ ConvErr ExcelToSc8::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std aCRD.Ref1 = aSRD; aCRD.Ref2 = aSRD; aCRD.Ref2.SetAbsTab(nLastScTab); - rRangeList.Append(aCRD.toAbs(aEingPos), nTab); + rRangeList.Append(aCRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } else - rRangeList.Append(aSRD.toAbs(aEingPos), nTab); + rRangeList.Append(aSRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } } break; @@ -1248,7 +1248,7 @@ ConvErr ExcelToSc8::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std else if( IsComplRowRange( nRw1, nRw2 ) ) SetComplRow( aCRD ); - rRangeList.Append(aCRD.toAbs(aEingPos), nTab); + rRangeList.Append(aCRD.toAbs(&GetDocImport().getDoc(), aEingPos), nTab); } } break; diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index 5c0f1c8acadc..16676c8f0192 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -398,7 +398,7 @@ void ImportExcel::Row25() nRow = aIn.ReaduInt16(); aIn.Ignore( 4 ); - if( ValidRow( nRow ) ) + if( GetRoot().GetDoc().ValidRow( nRow ) ) { nRowHeight = aIn.ReaduInt16(); // specify direct in Twips aIn.Ignore( 2 ); @@ -515,7 +515,7 @@ void ImportExcel::Array25() std::unique_ptr<ScTokenArray> pResult; - if (ValidColRow(nLastCol, nLastRow)) + if (GetRoot().GetDoc().ValidColRow(nLastCol, nLastRow)) { // the read mark is now on the formula, length in nFormLen @@ -960,7 +960,7 @@ void ImportExcel::Row34() SCROW nScRow = static_cast< SCROW >( nRow ); - if( ValidRow( nScRow ) ) + if( GetRoot().GetDoc().ValidRow( nScRow ) ) { nRowHeight = aIn.ReaduInt16(); // specify direct in Twips aIn.Ignore( 4 ); @@ -1013,7 +1013,7 @@ void ImportExcel::Array34() std::unique_ptr<ScTokenArray> pResult; - if( ValidColRow( nLastCol, nLastRow ) ) + if( GetRoot().GetDoc().ValidColRow( nLastCol, nLastRow ) ) { // the read mark is now on the formula, length in nFormLen @@ -1070,7 +1070,7 @@ void ImportExcel::TableOp() nLastRow = std::min<sal_uInt16>(nLastRow, MAXROW_30); } - if( ValidColRow( nLastCol, nLastRow ) ) + if( GetRoot().GetDoc().ValidColRow( nLastCol, nLastRow ) ) { if( nFirstCol && nFirstRow ) { diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx index f42e9f96b770..bd9e3d767e47 100644 --- a/sc/source/filter/excel/xechart.cxx +++ b/sc/source/filter/excel/xechart.cxx @@ -917,8 +917,8 @@ sal_uInt16 XclExpChSourceLink::ConvertDataSequence( Reference< XDataSequence > c { // split 3-dimensional ranges into single sheets const ScComplexRefData& rComplexRef = *pToken->GetDoubleRef(); - ScAddress aAbs1 = rComplexRef.Ref1.toAbs(ScAddress()); - ScAddress aAbs2 = rComplexRef.Ref2.toAbs(ScAddress()); + ScAddress aAbs1 = rComplexRef.Ref1.toAbs(&GetRoot().GetDoc(), ScAddress()); + ScAddress aAbs2 = rComplexRef.Ref2.toAbs(&GetRoot().GetDoc(), ScAddress()); for (SCTAB nScTab = aAbs1.Tab(); nScTab <= aAbs2.Tab(); ++nScTab) { // split 2-dimensional ranges into single columns diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx index 2f24b1b2c723..11ed534a387e 100644 --- a/sc/source/filter/excel/xeformula.cxx +++ b/sc/source/filter/excel/xeformula.cxx @@ -1810,7 +1810,7 @@ SCTAB XclExpFmlaCompImpl::GetScTab( const ScSingleRefData& rRefData ) const if (!mxData->mpScBasePos) return SCTAB_INVALID; - return rRefData.toAbs(*mxData->mpScBasePos).Tab(); + return rRefData.toAbs(&GetRoot().GetDoc(), *mxData->mpScBasePos).Tab(); } bool XclExpFmlaCompImpl::IsRef2D( const ScSingleRefData& rRefData, bool bCheck3DFlag ) const @@ -1847,7 +1847,7 @@ void XclExpFmlaCompImpl::ConvertRefData( if( mxData->mpScBasePos ) { // *** reference position exists (cell, matrix) - convert to absolute *** - ScAddress aAbs = rRefData.toAbs(*mxData->mpScBasePos); + ScAddress aAbs = rRefData.toAbs(&GetRoot().GetDoc(), *mxData->mpScBasePos); // convert column index if (bTruncMaxCol && (aAbs.Col() == mnMaxScCol)) @@ -1864,7 +1864,7 @@ void XclExpFmlaCompImpl::ConvertRefData( rXclPos.mnRow = static_cast<sal_uInt32>(aAbs.Row()) & mnMaxRowMask; // Update the reference. - rRefData.SetAddress(aAbs, *mxData->mpScBasePos); + rRefData.SetAddress(&GetRoot().GetDoc(), aAbs, *mxData->mpScBasePos); } else { @@ -2031,7 +2031,7 @@ void XclExpFmlaCompImpl::ProcessExternalCellRef( const XclExpScToken& rTokData ) sal_uInt16 nFileId = rTokData.mpScToken->GetIndex(); OUString aTabName = rTokData.mpScToken->GetString().getString(); if( mxData->mrCfg.mbFromCell && mxData->mpScBasePos ) - mxData->mpLinkMgr->StoreCell(nFileId, aTabName, aRefData.toAbs(*mxData->mpScBasePos)); + mxData->mpLinkMgr->StoreCell(nFileId, aTabName, aRefData.toAbs(&GetRoot().GetDoc(), *mxData->mpScBasePos)); // 1-based EXTERNSHEET index and 0-based Excel sheet indexes sal_uInt16 nExtSheet, nFirstSBTab, nLastSBTab; @@ -2067,7 +2067,7 @@ void XclExpFmlaCompImpl::ProcessExternalRangeRef( const XclExpScToken& rTokData sal_uInt16 nFileId = rTokData.mpScToken->GetIndex(); OUString aTabName = rTokData.mpScToken->GetString().getString(); if( mxData->mrCfg.mbFromCell && mxData->mpScBasePos ) - mxData->mpLinkMgr->StoreCellRange(nFileId, aTabName, aRefData.toAbs(*mxData->mpScBasePos)); + mxData->mpLinkMgr->StoreCellRange(nFileId, aTabName, aRefData.toAbs(&GetRoot().GetDoc(), *mxData->mpScBasePos)); // 1-based EXTERNSHEET index and 0-based Excel sheet indexes sal_uInt16 nExtSheet, nFirstSBTab, nLastSBTab; @@ -2146,14 +2146,14 @@ void XclExpFmlaCompImpl::ProcessExternalName( const XclExpScToken& rTokData ) { ScSingleRefData aRefData = *pScToken->GetSingleRef(); mxData->mpLinkMgr->StoreCell( - nFileId, pScToken->GetString().getString(), aRefData.toAbs(*mxData->mpScBasePos)); + nFileId, pScToken->GetString().getString(), aRefData.toAbs(&GetRoot().GetDoc(), *mxData->mpScBasePos)); } break; case svExternalDoubleRef: { ScComplexRefData aRefData = *pScToken->GetDoubleRef(); mxData->mpLinkMgr->StoreCellRange( - nFileId, pScToken->GetString().getString(), aRefData.toAbs(*mxData->mpScBasePos)); + nFileId, pScToken->GetString().getString(), aRefData.toAbs(&GetRoot().GetDoc(), *mxData->mpScBasePos)); } break; default: diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 3dd30eb9a9fa..542e7ba9bd0e 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -2397,8 +2397,8 @@ void XclExpLinkManagerImpl8::FindExtSheet( void XclExpLinkManagerImpl8::StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2, const ScAddress& rPos ) { - ScAddress aAbs1 = rRef1.toAbs(rPos); - ScAddress aAbs2 = rRef2.toAbs(rPos); + ScAddress aAbs1 = rRef1.toAbs(&GetRoot().GetDoc(), rPos); + ScAddress aAbs2 = rRef2.toAbs(&GetRoot().GetDoc(), rPos); if (!rRef1.IsDeleted() && !rRef2.IsDeleted() && (aAbs1.Tab() >= 0) && (aAbs2.Tab() >= 0)) { const XclExpTabInfo& rTabInfo = GetTabInfo(); diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index ff1b455899da..f1c597843945 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -167,7 +167,7 @@ XclExpArrayRef XclExpArrayBuffer::FindArray( const ScTokenArray& rScTokArr, cons return xRec; const ScSingleRefData& rRef = *pToken->GetSingleRef(); - ScAddress aAbsPos = rRef.toAbs(rBasePos); + ScAddress aAbsPos = rRef.toAbs(&GetRoot().GetDoc(), rBasePos); XclExpArrayMap::const_iterator it = maRecMap.find(aAbsPos); return (it == maRecMap.end()) ? xRec : xRec = it->second; @@ -454,7 +454,7 @@ XclExpTableopRef XclExpTableopBuffer::CreateOrExtendTableop( // try to extract cell references of a multiple operations formula XclMultipleOpRefs aRefs; - if (XclTokenArrayHelper::GetMultipleOpRefs(aRefs, rScTokArr, rScPos)) + if (XclTokenArrayHelper::GetMultipleOpRefs(&GetDoc(), aRefs, rScTokArr, rScPos)) { // try to find an existing TABLEOP record for this cell position for( size_t nPos = 0, nSize = maTableopList.GetSize(); !xRec && (nPos < nSize); ++nPos ) @@ -968,7 +968,7 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm ) rStrm.GetRoot().GetAddressConverter().ValidateRange( aMatScRange, true ); OStringBuffer sFmlaCellRange; - if (ValidRange(aMatScRange)) + if (rStrm.GetRoot().GetDoc().ValidRange(aMatScRange)) { // calculate the cell range. sFmlaCellRange.append( XclXmlUtils::ToOString( diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx index 4f78956a9d7f..95de26eb643f 100644 --- a/sc/source/filter/excel/xichart.cxx +++ b/sc/source/filter/excel/xichart.cxx @@ -798,8 +798,8 @@ sal_uInt16 XclImpChSourceLink::GetCellCount() const { // cell range const ScComplexRefData& rComplexRef = *pToken->GetDoubleRef(); - ScAddress aAbs1 = rComplexRef.Ref1.toAbs(ScAddress()); - ScAddress aAbs2 = rComplexRef.Ref2.toAbs(ScAddress()); + ScAddress aAbs1 = rComplexRef.Ref1.toAbs(&GetRoot().GetDoc(), ScAddress()); + ScAddress aAbs2 = rComplexRef.Ref2.toAbs(&GetRoot().GetDoc(), ScAddress()); sal_uInt32 nTabs = static_cast<sal_uInt32>(aAbs2.Tab() - aAbs1.Tab() + 1); sal_uInt32 nCols = static_cast<sal_uInt32>(aAbs2.Col() - aAbs1.Col() + 1); sal_uInt32 nRows = static_cast<sal_uInt32>(aAbs2.Row() - aAbs1.Row() + 1); diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index 4665f6dde359..c4037b4c9d91 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -922,14 +922,14 @@ void XclTokenArrayHelper::ConvertStringToList( namespace { -bool lclGetAddress( ScAddress& rAddress, const FormulaToken& rToken, const ScAddress& rPos ) +bool lclGetAddress( const ScDocument* pDoc, ScAddress& rAddress, const FormulaToken& rToken, const ScAddress& rPos ) { OpCode eOpCode = rToken.GetOpCode(); bool bIsSingleRef = (eOpCode == ocPush) && (rToken.GetType() == svSingleRef); if( bIsSingleRef ) { const ScSingleRefData& rRef = *rToken.GetSingleRef(); - rAddress = rRef.toAbs(rPos); + rAddress = rRef.toAbs(pDoc, rPos); bIsSingleRef = !rRef.IsDeleted(); } return bIsSingleRef; @@ -938,6 +938,7 @@ bool lclGetAddress( ScAddress& rAddress, const FormulaToken& rToken, const ScAdd } // namespace bool XclTokenArrayHelper::GetMultipleOpRefs( + const ScDocument* pDoc, XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr, const ScAddress& rScPos ) { rRefs.mbDblRefMode = false; @@ -960,32 +961,32 @@ bool XclTokenArrayHelper::GetMultipleOpRefs( eState = (eOpCode == ocOpen) ? stOpen : stError; break; case stOpen: - eState = lclGetAddress(rRefs.maFmlaScPos, *aIt, rScPos) ? stFormula : stError; + eState = lclGetAddress(pDoc, rRefs.maFmlaScPos, *aIt, rScPos) ? stFormula : stError; break; case stFormula: eState = bIsSep ? stFormulaSep : stError; break; case stFormulaSep: - eState = lclGetAddress(rRefs.maColFirstScPos, *aIt, rScPos) ? stColFirst : stError; + eState = lclGetAddress(pDoc, rRefs.maColFirstScPos, *aIt, rScPos) ? stColFirst : stError; break; case stColFirst: eState = bIsSep ? stColFirstSep : stError; break; case stColFirstSep: - eState = lclGetAddress(rRefs.maColRelScPos, *aIt, rScPos) ? stColRel : stError; + eState = lclGetAddress(pDoc, rRefs.maColRelScPos, *aIt, rScPos) ? stColRel : stError; break; case stColRel: eState = bIsSep ? stColRelSep : ((eOpCode == ocClose) ? stClose : stError); break; case stColRelSep: - eState = lclGetAddress(rRefs.maRowFirstScPos, *aIt, rScPos) ? stRowFirst : stError; + eState = lclGetAddress(pDoc, rRefs.maRowFirstScPos, *aIt, rScPos) ? stRowFirst : stError; rRefs.mbDblRefMode = true; break; case stRowFirst: eState = bIsSep ? stRowFirstSep : stError; break; case stRowFirstSep: - eState = lclGetAddress(rRefs.maRowRelScPos, *aIt, rScPos) ? stRowRel : stError; + eState = lclGetAddress(pDoc, rRefs.maRowRelScPos, *aIt, rScPos) ? stRowRel : stError; break; case stRowRel: eState = (eOpCode == ocClose) ? stClose : stError; diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index a45f497c5e56..412150a2204c 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -431,7 +431,7 @@ void ScHTMLLayoutParser::ModifyOffset( ScHTMLColOffset* pOffset, sal_uInt16& nOl void ScHTMLLayoutParser::SkipLocked( ScEEParseEntry* pE, bool bJoin ) { - if ( ValidCol(pE->nCol) ) + if ( mpDoc->ValidCol(pE->nCol) ) { // Or else this would create a wrong value at ScAddress (chance for an infinite loop)! bool bBadCol = false; bool bAgain; diff --git a/sc/source/filter/inc/dif.hxx b/sc/source/filter/inc/dif.hxx index 33524d1a4067..f6cb8302bd5d 100644 --- a/sc/source/filter/inc/dif.hxx +++ b/sc/source/filter/inc/dif.hxx @@ -140,7 +140,7 @@ class DifColumn DifColumn(); - void SetNumFormat( SCROW nRow, const sal_uInt32 nNumFormat ); + void SetNumFormat( const ScDocument* pDoc, SCROW nRow, const sal_uInt32 nNumFormat ); void NewEntry( const SCROW nPos, const sal_uInt32 nNumFormat ); @@ -155,7 +155,7 @@ public: ~DifAttrCache(); - void SetNumFormat( const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat ); + void SetNumFormat( const ScDocument* pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat ); void Apply( ScDocument&, SCTAB nTab ); diff --git a/sc/source/filter/inc/lotattr.hxx b/sc/source/filter/inc/lotattr.hxx index cdeebbd79c9b..38fce32474fb 100644 --- a/sc/source/filter/inc/lotattr.hxx +++ b/sc/source/filter/inc/lotattr.hxx @@ -102,7 +102,7 @@ private: class LotAttrCol { public: - void SetAttr (const SCROW nRow, const ScPatternAttr&); + void SetAttr (const ScDocument* pDoc, const SCROW nRow, const ScPatternAttr&); void Apply(LotusContext& rContext, const SCCOL nCol, const SCTAB nTab); private: @@ -122,7 +122,7 @@ class LotAttrTable public: LotAttrTable(LotusContext& rContext); - void SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& ); + void SetAttr(LotusContext& rContext, const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& ); void Apply(LotusContext& rContext, const SCTAB nTabNum); diff --git a/sc/source/filter/inc/lotform.hxx b/sc/source/filter/inc/lotform.hxx index a352b5c9bd91..e87b36ed3ce3 100644 --- a/sc/source/filter/inc/lotform.hxx +++ b/sc/source/filter/inc/lotform.hxx @@ -75,8 +75,8 @@ private: bool bWK3; // alternative Code translation for < WK1 bool bWK123; // alternative for 123 - void ReadSRD( ScSingleRefData& rSRD, sal_uInt8 nFlags ); - inline void ReadCRD( ScComplexRefData& rCRD, sal_uInt8 nFlags ); + void ReadSRD( const ScDocument* pDoc, ScSingleRefData& rSRD, sal_uInt8 nFlags ); + inline void ReadCRD( const ScDocument* pDoc, ScComplexRefData& rCRD, sal_uInt8 nFlags ); void IncToken( TokenId &rParam ); // Attention: here the Token-chain is extended in Pool // with '(<rParam>)+1' and finished with Store() ! @@ -98,13 +98,13 @@ private: using LotusConverterBase::Reset; }; -inline void LotusToSc::ReadCRD( ScComplexRefData& rCRD, sal_uInt8 nRelBit ) +inline void LotusToSc::ReadCRD( const ScDocument* pDoc, ScComplexRefData& rCRD, sal_uInt8 nRelBit ) { // 1st part - ReadSRD( rCRD.Ref1, nRelBit ); + ReadSRD( pDoc, rCRD.Ref1, nRelBit ); // 2nd part - ReadSRD( rCRD.Ref2, nRelBit >> 3 ); + ReadSRD( pDoc, rCRD.Ref2, nRelBit >> 3 ); } inline void LotusToSc::SetWK3() diff --git a/sc/source/filter/inc/lotrange.hxx b/sc/source/filter/inc/lotrange.hxx index 5dc145bb0429..2e73f43a192c 100644 --- a/sc/source/filter/inc/lotrange.hxx +++ b/sc/source/filter/inc/lotrange.hxx @@ -23,8 +23,6 @@ #include <refdata.hxx> #include <types.hxx> -struct LOTUS_ROOT; - typedef sal_uInt16 LR_ID; #define ID_FAIL 0xFFFF diff --git a/sc/source/filter/inc/namebuff.hxx b/sc/source/filter/inc/namebuff.hxx index 2bf50c652946..123a1486b898 100644 --- a/sc/source/filter/inc/namebuff.hxx +++ b/sc/source/filter/inc/namebuff.hxx @@ -99,13 +99,13 @@ private: public: RangeNameBufferWK3(const ScDocument* pDoc); ~RangeNameBufferWK3(); - void Add( const OUString& rName, const ScComplexRefData& rCRD ); - inline void Add( const OUString& rName, const ScRange& aScRange ); + void Add( const ScDocument* pDoc, const OUString& rName, const ScComplexRefData& rCRD ); + inline void Add( const ScDocument* pDoc, const OUString& rName, const ScRange& aScRange ); bool FindRel( const OUString& rRef, sal_uInt16& rIndex ); bool FindAbs( const OUString& rRef, sal_uInt16& rIndex ); }; -inline void RangeNameBufferWK3::Add( const OUString& rName, const ScRange& aScRange ) +inline void RangeNameBufferWK3::Add( const ScDocument* pDoc, const OUString& rName, const ScRange& aScRange ) { ScComplexRefData aCRD; ScSingleRefData* pSRD; @@ -118,7 +118,7 @@ inline void RangeNameBufferWK3::Add( const OUString& rName, const ScRange& aScRa pSRD->InitAddress(aScRange.aEnd); pSRD->SetFlag3D(true); - Add( rName, aCRD ); + Add( pDoc, rName, aCRD ); } class ExtSheetBuffer : public ExcRoot diff --git a/sc/source/filter/inc/qproform.hxx b/sc/source/filter/inc/qproform.hxx index ee0fe9cce378..667bb665e8c0 100644 --- a/sc/source/filter/inc/qproform.hxx +++ b/sc/source/filter/inc/qproform.hxx @@ -60,7 +60,7 @@ public: QProToSc( SvStream &aStr, svl::SharedStringPool& rSPool, const ScAddress& rRefPos ); ConvErr Convert( const ScDocument* pDoc, std::unique_ptr<ScTokenArray>& pArray ); void DoFunc( DefTokenId eOc, sal_uInt16 nArgs, const sal_Char* pExtString ); - void ReadSRD( ScSingleRefData& rR, sal_Int8 nPage, sal_Int8 nCol, sal_uInt16 rRel ); + void ReadSRD( const ScDocument* pDoc, ScSingleRefData& rR, sal_Int8 nPage, sal_Int8 nCol, sal_uInt16 rRel ); void IncToken( TokenId &aParam ); static DefTokenId IndexToToken( sal_uInt16 nToken ); static QPRO_FUNC_TYPE IndexToType( sal_uInt8 nToken ); diff --git a/sc/source/filter/inc/xlformula.hxx b/sc/source/filter/inc/xlformula.hxx index 07a584c46d58..e281615bd3eb 100644 --- a/sc/source/filter/inc/xlformula.hxx +++ b/sc/source/filter/inc/xlformula.hxx @@ -532,7 +532,7 @@ public: @descr Requires that the formula contains a single MULTIPLE.OPERATION function call. Spaces in the formula are silently ignored. @return true = Multiple operation found, and all references successfully extracted. */ - static bool GetMultipleOpRefs( XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr, const ScAddress& rScPos ); + static bool GetMultipleOpRefs( const ScDocument* pDoc, XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr, const ScAddress& rScPos ); }; inline sal_uInt8 XclTokenArrayHelper::GetTokenId( sal_uInt8 nBaseId, sal_uInt8 nTokenClass ) diff --git a/sc/source/filter/lotus/lotattr.cxx b/sc/source/filter/lotus/lotattr.cxx index 725ac276d7d7..8082d4cbcca1 100644 --- a/sc/source/filter/lotus/lotattr.cxx +++ b/sc/source/filter/lotus/lotattr.cxx @@ -180,11 +180,11 @@ const Color& LotAttrCache::GetColor( const sal_uInt8 nLotIndex ) const return pColTab[ nLotIndex ]; } -void LotAttrCol::SetAttr( const SCROW nRow, const ScPatternAttr& rAttr ) +void LotAttrCol::SetAttr( const ScDocument* pDoc, const SCROW nRow, const ScPatternAttr& rAttr ) { // Actually with the current implementation of MAXROWCOUNT>=64k and nRow // being read as sal_uInt16 there's no chance that nRow would be invalid... - SAL_WARN_IF( !ValidRow(nRow), "sc.filter", "*LotAttrCol::SetAttr(): ... and failed?!" ); + SAL_WARN_IF( !pDoc->ValidRow(nRow), "sc.filter", "*LotAttrCol::SetAttr(): ... and failed?!" ); std::vector<std::unique_ptr<ENTRY> >::reverse_iterator iterLast = aEntries.rbegin(); @@ -228,7 +228,7 @@ LotAttrTable::LotAttrTable(LotusContext& rContext): { } -void LotAttrTable::SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, +void LotAttrTable::SetAttr( LotusContext& rContext, const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& rAttr ) { // With the current implementation of MAXCOLCOUNT>=1024 and nColFirst and @@ -238,7 +238,7 @@ void LotAttrTable::SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const S SCCOL nColCnt; for( nColCnt = nColFirst ; nColCnt <= nColLast ; nColCnt++ ) - pCols[ nColCnt ].SetAttr( nRow, rPattAttr ); + pCols[ nColCnt ].SetAttr( rContext.pDoc, nRow, rPattAttr ); } void LotAttrTable::Apply(LotusContext& rContext, const SCTAB nTabNum) diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx index f0088500f5eb..d92a34151242 100644 --- a/sc/source/filter/lotus/lotform.cxx +++ b/sc/source/filter/lotus/lotform.cxx @@ -316,7 +316,7 @@ void LotusToSc::LotusRelToScRel( sal_uInt16 nCol, sal_uInt16 nRow, ScSingleRefDa rSRD.SetAbsRow(static_cast<SCROW>(nRow)); } -void LotusToSc::ReadSRD( ScSingleRefData& rSRD, sal_uInt8 nRelBit ) +void LotusToSc::ReadSRD( const ScDocument* pDoc, ScSingleRefData& rSRD, sal_uInt8 nRelBit ) { sal_uInt8 nTab, nCol; sal_uInt16 nRow; @@ -332,7 +332,7 @@ void LotusToSc::ReadSRD( ScSingleRefData& rSRD, sal_uInt8 nRelBit ) rSRD.SetTabRel( ( ( nRelBit & 0x04) != 0 ) || !b3D ); rSRD.SetFlag3D( b3D ); - rSRD.SetAddress(ScAddress(nCol, nRow, nTab), aEingPos); + rSRD.SetAddress(pDoc, ScAddress(nCol, nRow, nTab), aEingPos); } void LotusToSc::IncToken( TokenId &rParam ) @@ -551,12 +551,12 @@ void LotusToSc::Convert( std::unique_ptr<ScTokenArray>& rpErg, sal_Int32& rRest // for > WK3 case FT_Cref: Read( nRelBits ); - ReadSRD( rR, nRelBits ); + ReadSRD( m_rContext.pDoc, rR, nRelBits ); aStack << aPool.Store( rR ); break; case FT_Rref: Read( nRelBits ); - ReadCRD( aCRD, nRelBits ); + ReadCRD( m_rContext.pDoc, aCRD, nRelBits ); aStack << aPool.Store( aCRD ); break; case FT_Nrref: @@ -654,7 +654,7 @@ void LotusToSc::Convert( std::unique_ptr<ScTokenArray>& rpErg, sal_Int32& rRest } } - rpErg = aPool.GetTokenArray(m_rContext.pDoc, aStack.Get()); + rpErg = aPool.GetTokenArray( m_rContext.pDoc, aStack.Get()); SAL_WARN_IF( nBytesLeft < 0, "sc.filter", "*LotusToSc::Convert(): processed too much!"); SAL_WARN_IF( nBytesLeft > 0, "sc.filter", "*LotusToSc::Convert(): what happens with the rest?" ); diff --git a/sc/source/filter/lotus/lotimpop.cxx b/sc/source/filter/lotus/lotimpop.cxx index 2b6c5afa6f7c..73ab64c29559 100644 --- a/sc/source/filter/lotus/lotimpop.cxx +++ b/sc/source/filter/lotus/lotimpop.cxx @@ -167,7 +167,7 @@ void ImportLotus::Userrange() Read( aScRange ); LotusContext &rContext = aConv.getContext(); - rContext.pRngNmBffWK3->Add( aName, aScRange ); + rContext.pRngNmBffWK3->Add( rContext.pDoc, aName, aScRange ); } void ImportLotus::Errcell() @@ -368,10 +368,11 @@ void ImportLotus::Row_( const sal_uInt16 nRecLen ) bool bCenter = false; SCCOL nCenterStart = 0, nCenterEnd = 0; + LotusContext &rContext = aConv.getContext(); sal_uInt16 nTmpRow(0); Read(nTmpRow); - SCROW nRow(SanitizeRow(static_cast<SCROW>(nTmpRow))); + SCROW nRow(rContext.pDoc->SanitizeRow(static_cast<SCROW>(nTmpRow))); sal_uInt16 nHeight(0); Read(nHeight); @@ -383,7 +384,6 @@ void ImportLotus::Row_( const sal_uInt16 nRecLen ) if( nHeight ) pD->SetRowHeight(nRow, nDestTab, nHeight); - LotusContext &rContext = aConv.getContext(); while( nCntDwn ) { Read( aAttr ); @@ -391,7 +391,7 @@ void ImportLotus::Row_( const sal_uInt16 nRecLen ) if( aAttr.HasStyles() ) rContext.maAttrTable.SetAttr( - nColCnt, static_cast<SCCOL> ( nColCnt + nRepeats ), nRow, aAttr ); + rContext, nColCnt, static_cast<SCCOL> ( nColCnt + nRepeats ), nRow, aAttr ); // Do this here and NOT in class LotAttrTable, as we only add attributes if the other // attributes are set diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx index 6d99a18dea98..c2043a00ccdf 100644 --- a/sc/source/filter/lotus/op.cxx +++ b/sc/source/filter/lotus/op.cxx @@ -74,7 +74,7 @@ void OP_Integer(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/) SCCOL nCol(static_cast<SCCOL>(nTmpCol)); SCROW nRow(static_cast<SCROW>(nTmpRow)); - if (ValidColRow(nCol, nRow)) + if (rContext.pDoc->ValidColRow(nCol, nRow)) { rContext.pDoc->EnsureTable(0); rContext.pDoc->SetValue(ScAddress(nCol, nRow, 0), static_cast<double>(nValue)); @@ -93,7 +93,7 @@ void OP_Number(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/) SCCOL nCol(static_cast<SCCOL>(nTmpCol)); SCROW nRow(static_cast<SCROW>(nTmpRow)); - if (ValidColRow(nCol, nRow)) + if (rContext.pDoc->ValidColRow(nCol, nRow)) { fValue = ::rtl::math::round( fValue, 15 ); rContext.pDoc->EnsureTable(0); @@ -117,7 +117,7 @@ void OP_Label(LotusContext& rContext, SvStream& r, sal_uInt16 n) r.ReadBytes(pText.get(), n); pText[n] = 0; - if (ValidColRow(nCol, nRow)) + if (rContext.pDoc->ValidColRow(nCol, nRow)) { nFormat &= 0x80; // don't change Bit 7 nFormat |= 0x75; // protected does not matter, special-text is set @@ -151,7 +151,7 @@ void OP_Formula(LotusContext &rContext, SvStream& r, sal_uInt16 /*n*/) if (!aConv.good()) return; - if (ValidColRow(nCol, nRow)) + if (rContext.pDoc->ValidColRow(nCol, nRow)) { ScFormulaCell* pCell = new ScFormulaCell(rContext.pDoc, aAddress, std::move(pResult)); pCell->AddRecalcMode( ScRecalcMode::ONLOAD_ONCE ); @@ -170,9 +170,9 @@ void OP_ColumnWidth(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/) r.ReadUInt16(nTmpCol).ReadUChar(nWidthSpaces); SCCOL nCol(static_cast<SCCOL>(nTmpCol)); - if (ValidCol(nCol)) + if (rContext.pDoc->ValidCol(nCol)) { - nCol = SanitizeCol(nCol); + nCol = rContext.pDoc->SanitizeCol(nCol); sal_uInt16 nBreite; if( nWidthSpaces ) @@ -199,7 +199,7 @@ void OP_NamedRange(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/) r.ReadUInt16( nColSt ).ReadUInt16( nRowSt ).ReadUInt16( nColEnd ).ReadUInt16( nRowEnd ); - if (ValidColRow( static_cast<SCCOL>(nColSt), nRowSt) && ValidColRow( static_cast<SCCOL>(nColEnd), nRowEnd)) + if (rContext.pDoc->ValidColRow( static_cast<SCCOL>(nColSt), nRowSt) && rContext.pDoc->ValidColRow( static_cast<SCCOL>(nColEnd), nRowEnd)) { std::unique_ptr<LotusRange> pRange; @@ -238,7 +238,7 @@ void OP_SymphNamedRange(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/) r.ReadUInt16( nColSt ).ReadUInt16( nRowSt ).ReadUInt16( nColEnd ).ReadUInt16( nRowEnd ).ReadUChar( nType ); - if (ValidColRow( static_cast<SCCOL>(nColSt), nRowSt) && ValidColRow( static_cast<SCCOL>(nColEnd), nRowEnd)) + if (rContext.pDoc->ValidColRow( static_cast<SCCOL>(nColSt), nRowSt) && rContext.pDoc->ValidColRow( static_cast<SCCOL>(nColEnd), nRowEnd)) { std::unique_ptr<LotusRange> pRange; @@ -380,7 +380,7 @@ void OP_Number123(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/) SCCOL nCol(static_cast<SCCOL>(nTmpCol)); SCROW nRow(static_cast<SCROW>(nTmpRow)); - if (ValidColRow(nCol, nRow) && nTab <= rContext.pDoc->GetMaxTableNumber()) + if (rContext.pDoc->ValidColRow(nCol, nRow) && nTab <= rContext.pDoc->GetMaxTableNumber()) { double fValue = Snum32ToDouble( nValue ); rContext.pDoc->EnsureTable(nTab); @@ -409,7 +409,7 @@ void OP_Formula123(LotusContext& rContext, SvStream& r, sal_uInt16 n) if (!aConv.good()) return; - if (ValidColRow(nCol, nRow) && nTab <= rContext.pDoc->GetMaxTableNumber()) + if (rContext.pDoc->ValidColRow(nCol, nRow) && nTab <= rContext.pDoc->GetMaxTableNumber()) { ScFormulaCell* pCell = new ScFormulaCell(rContext.pDoc, aAddress, std::move(pResult)); pCell->AddRecalcMode( ScRecalcMode::ONLOAD_ONCE ); @@ -428,7 +428,7 @@ void OP_IEEENumber123(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/) SCCOL nCol(static_cast<SCCOL>(nTmpCol)); SCROW nRow(static_cast<SCROW>(nTmpRow)); - if (ValidColRow(nCol, nRow) && nTab <= rContext.pDoc->GetMaxTableNumber()) + if (rContext.pDoc->ValidColRow(nCol, nRow) && nTab <= rContext.pDoc->GetMaxTableNumber()) { rContext.pDoc->EnsureTable(nTab); rContext.pDoc->SetValue(ScAddress(nCol,nRow,nTab), dValue); diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx index 908e7bacfabb..0c5fcbc0df7c 100644 --- a/sc/source/filter/lotus/tool.cxx +++ b/sc/source/filter/lotus/tool.cxx @@ -75,8 +75,8 @@ void PutFormString(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, s if (!pString) return; - nCol = SanitizeCol(nCol); - nRow = SanitizeRow(nRow); + nCol = rContext.pDoc->SanitizeCol(nCol); + nRow = rContext.pDoc->SanitizeRow(nRow); nTab = SanitizeTab(nTab); rContext.pDoc->ApplyAttr( nCol, nRow, nTab, *pJustify ); @@ -87,8 +87,8 @@ void PutFormString(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, s void SetFormat(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt) { - nCol = SanitizeCol(nCol); - nRow = SanitizeRow(nRow); + nCol = rContext.pDoc->SanitizeCol(nCol); + nRow = rContext.pDoc->SanitizeRow(nRow); nTab = SanitizeTab(nTab); // PREC: nSt = default number of decimal places @@ -436,7 +436,7 @@ RangeNameBufferWK3::~RangeNameBufferWK3() { } -void RangeNameBufferWK3::Add( const OUString& rOrgName, const ScComplexRefData& rCRD ) +void RangeNameBufferWK3::Add( const ScDocument* pDoc, const OUString& rOrgName, const ScComplexRefData& rCRD ) { Entry aInsert( rOrgName, rCRD ); @@ -444,8 +444,8 @@ void RangeNameBufferWK3::Add( const OUString& rOrgName, const ScComplexRefData& const ScSingleRefData& rRef1 = rCRD.Ref1; const ScSingleRefData& rRef2 = rCRD.Ref2; - ScAddress aAbs1 = rRef1.toAbs(ScAddress()); - ScAddress aAbs2 = rRef2.toAbs(ScAddress()); + ScAddress aAbs1 = rRef1.toAbs(pDoc, ScAddress()); + ScAddress aAbs2 = rRef2.toAbs(pDoc, ScAddress()); if (aAbs1 == aAbs2) { pScTokenArray->AddSingleReference( rCRD.Ref1 ); diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx index c56599d6c963..6c2d46a9f874 100644 --- a/sc/source/filter/qpro/qproform.cxx +++ b/sc/source/filter/qpro/qproform.cxx @@ -26,7 +26,7 @@ #include <formel.hxx> #include <tokstack.hxx> -void QProToSc::ReadSRD( ScSingleRefData& rSRD, sal_Int8 nPage, sal_Int8 nCol, sal_uInt16 nRelBit ) +void QProToSc::ReadSRD( const ScDocument* pDoc, ScSingleRefData& rSRD, sal_Int8 nPage, sal_Int8 nCol, sal_uInt16 nRelBit ) { sal_uInt16 nTmp = nRelBit & 0x1fff; rSRD.InitAddress( ScAddress( nCol, (~nTmp + 1), 0 ) ); @@ -57,7 +57,7 @@ void QProToSc::ReadSRD( ScSingleRefData& rSRD, sal_Int8 nPage, sal_Int8 nCol, sa { rSRD.SetAbsTab(nPage); } - if (rSRD.toAbs(aEingPos).Tab() != aEingPos.Tab()) + if (rSRD.toAbs(pDoc, aEingPos).Tab() != aEingPos.Tab()) rSRD.SetFlag3D(true); } @@ -320,17 +320,17 @@ ConvErr QProToSc::Convert( const ScDocument* pDoc, std::unique_ptr<ScTokenArray> case FT_Cref : // Single cell reference maIn.ReadUInt16( nNote ).ReadSChar( nCol ).ReadSChar( nPage ).ReadUInt16( nRelBits ); SAFEREAD_OR_BREAK( maIn, i, nRef, eRet, ConvErr::Count); - ReadSRD( aSRD, nPage, nCol, nRelBits ); + ReadSRD( pDoc, aSRD, nPage, nCol, nRelBits ); aStack << aPool.Store( aSRD ); break; case FT_Range: // Block reference maIn.ReadUInt16( nNote ).ReadSChar( nCol ).ReadSChar( nPage ).ReadUInt16( nRelBits ); SAFEREAD_OR_BREAK( maIn, i, nRef, eRet, ConvErr::Count); - ReadSRD( aCRD.Ref1, nPage, nCol, nRelBits ); + ReadSRD( pDoc, aCRD.Ref1, nPage, nCol, nRelBits ); maIn.ReadSChar( nCol ).ReadSChar( nPage ).ReadUInt16( nRelBits ); SAFEREAD_OR_BREAK( maIn, i, nRef, eRet, ConvErr::Count); - ReadSRD( aCRD.Ref2, nPage, nCol, nRelBits ); + ReadSRD( pDoc, aCRD.Ref2, nPage, nCol, nRelBits ); // Sheet name of second corner is not displayed if identical if (aCRD.Ref1.IsFlag3D() && aCRD.Ref1.Tab() == aCRD.Ref2.Tab() && aCRD.Ref1.IsTabRel() == aCRD.Ref2.IsTabRel()) diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index 2e10e8d0a2fc..58cf4e18f29d 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -149,7 +149,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu SCCOL nCol = nStartCol + pE->nCol + nMergeColAdd; // Determine RowMerge // Pure ColMerge and ColMerge of the first MergeRow already done during parsing - if (nRow <= nOverlapRowMax && ValidCol(nCol)) + if (nRow <= nOverlapRowMax && mpDoc->ValidCol(nCol)) { while ( nCol <= mpDoc->MaxCol() && mpDoc->HasAttrib( nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::Overlapped ) ) @@ -162,7 +162,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu // Add for second run pE->nCol = nCol; pE->nRow = nRow; - if ( ValidCol(nCol) && ValidRow(nRow) ) + if ( mpDoc->ValidCol(nCol) && mpDoc->ValidRow(nRow) ) { SfxItemSet aSet = mpEngine->GetAttribs( pE->aSel ); // Remove default: we set left/right ourselves depending on Text or @@ -471,7 +471,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu { SCCOL nCol = pE->nCol; SCROW nRow = pE->nRow; - if ( ValidCol(nCol) && ValidRow(nRow) ) + if ( mpDoc->ValidCol(nCol) && mpDoc->ValidRow(nRow) ) InsertGraphic( nCol, nRow, nTab, pE ); } } |