Rebased ref, commits from common ancestor: commit 729105faf8a1aa82f2437e8b8d78e21f3b93aa7d Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Tue Jul 16 00:17:08 2013 -0400
More on replacing CalcAbsIfRel() with toAbs(). Change-Id: I7f658e15a1ab6bdabd5f774e129e12c48a032f1a diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx index d619f4f..74028ac 100644 --- a/sc/inc/refdata.hxx +++ b/sc/inc/refdata.hxx @@ -166,7 +166,7 @@ struct ScComplexRefData tab if one sheet, or >=0 if more than one sheets. */ inline bool ValidExternal() const; - ScRange toAbs( const ScAddress& rPos ) const; + SC_DLLPUBLIC ScRange toAbs( const ScAddress& rPos ) const; /// Absolute references have to be up-to-date when calling this! void PutInOrder(); diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 570b55c..41a53f1 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -643,10 +643,9 @@ void ScFormulaCell::GetFormula( OUStringBuffer& rBuffer, * Can we live without in all cases? */ ScFormulaCell* pCell = NULL; ScSingleRefData& rRef = p->GetSingleRef(); - rRef.CalcAbsIfRel( aPos ); - if ( rRef.Valid() ) - pCell = pDocument->GetFormulaCell( - ScAddress(rRef.nCol, rRef.nRow, rRef.nTab)); + ScAddress aAbs = rRef.toAbs(aPos); + if (ValidAddress(aAbs)) + pCell = pDocument->GetFormulaCell(aAbs); if (pCell) { @@ -1842,10 +1841,10 @@ bool ScFormulaCell::GetMatrixOrigin( ScAddress& rPos ) const if( t ) { ScSingleRefData& rRef = t->GetSingleRef(); - rRef.CalcAbsIfRel( aPos ); - if ( rRef.Valid() ) + ScAddress aAbs = rRef.toAbs(aPos); + if (ValidAddress(aAbs)) { - rPos.Set( rRef.nCol, rRef.nRow, rRef.nTab ); + rPos = aAbs; return true; } } @@ -2229,8 +2228,7 @@ bool ScFormulaCell::UpdateReference( ScSingleRefData& rRef = t->GetSingleRef(); if ( nDy > 0 && rRef.IsColRel() ) { // ColName - rRef.CalcAbsIfRel( aPos ); - ScAddress aAdr( rRef.nCol, rRef.nRow, rRef.nTab ); + ScAddress aAdr = rRef.toAbs(aPos); ScRangePair* pR = pColList->Find( aAdr ); if ( pR ) { // defined @@ -2239,14 +2237,13 @@ bool ScFormulaCell::UpdateReference( } else { // on the fly - if ( rRef.nRow + 1 == nRow1 ) + if (aAdr.Row() + 1 == nRow1) bColRowNameCompile = true; } } if ( nDx > 0 && rRef.IsRowRel() ) { // RowName - rRef.CalcAbsIfRel( aPos ); - ScAddress aAdr( rRef.nCol, rRef.nRow, rRef.nTab ); + ScAddress aAdr = rRef.toAbs(aPos); ScRangePair* pR = pRowList->Find( aAdr ); if ( pR ) { // defined @@ -2255,7 +2252,7 @@ bool ScFormulaCell::UpdateReference( } else { // on the fly - if ( rRef.nCol + 1 == nCol1 ) + if (aAdr.Col() + 1 == nCol1) bColRowNameCompile = true; } } @@ -2275,11 +2272,10 @@ bool ScFormulaCell::UpdateReference( while ( t && !bColRowNameCompile ) { ScSingleRefData& rRef = t->GetSingleRef(); - rRef.CalcAbsIfRel( aPos ); - if ( rRef.Valid() ) + ScAddress aAbs = rRef.toAbs(aPos); + if (ValidAddress(aAbs)) { - ScAddress aAdr( rRef.nCol, rRef.nRow, rRef.nTab ); - if ( rRange.In( aAdr ) ) + if (rRange.In(aAbs)) bColRowNameCompile = true; } t = static_cast<ScToken*>(pCode->GetNextColRowName()); diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx index 97a11cb..a862ae4 100644 --- a/sc/source/filter/excel/xeformula.cxx +++ b/sc/source/filter/excel/xeformula.cxx @@ -2005,7 +2005,7 @@ void XclExpFmlaCompImpl::ProcessExternalCellRef( const XclExpScToken& rTokData ) sal_uInt16 nFileId = rTokData.mpScToken->GetIndex(); const String& rTabName = rTokData.mpScToken->GetString(); if( mxData->mrCfg.mbFromCell && mxData->mpScBasePos ) - mxData->mpLinkMgr->StoreCell( nFileId, rTabName, aRefData ); + mxData->mpLinkMgr->StoreCell(nFileId, rTabName, aRefData.toAbs(*mxData->mpScBasePos)); // 1-based EXTERNSHEET index and 0-based Excel sheet indexes sal_uInt16 nExtSheet, nFirstSBTab, nLastSBTab; @@ -2041,7 +2041,7 @@ void XclExpFmlaCompImpl::ProcessExternalRangeRef( const XclExpScToken& rTokData sal_uInt16 nFileId = rTokData.mpScToken->GetIndex(); const String& rTabName = rTokData.mpScToken->GetString(); if( mxData->mrCfg.mbFromCell && mxData->mpScBasePos ) - mxData->mpLinkMgr->StoreCellRange( nFileId, rTabName, aRefData ); + mxData->mpLinkMgr->StoreCellRange(nFileId, rTabName, aRefData.toAbs(*mxData->mpScBasePos)); // 1-based EXTERNSHEET index and 0-based Excel sheet indexes sal_uInt16 nExtSheet, nFirstSBTab, nLastSBTab; @@ -2119,15 +2119,15 @@ void XclExpFmlaCompImpl::ProcessExternalName( const XclExpScToken& rTokData ) case svExternalSingleRef: { ScSingleRefData aRefData = static_cast< ScToken* >( pScToken )->GetSingleRef(); - aRefData.CalcAbsIfRel( *mxData->mpScBasePos ); - mxData->mpLinkMgr->StoreCell( nFileId, pScToken->GetString(), aRefData ); + mxData->mpLinkMgr->StoreCell( + nFileId, pScToken->GetString(), aRefData.toAbs(*mxData->mpScBasePos)); } break; case svExternalDoubleRef: { ScComplexRefData aRefData = static_cast< ScToken* >( pScToken )->GetDoubleRef(); - aRefData.CalcAbsIfRel( *mxData->mpScBasePos ); - mxData->mpLinkMgr->StoreCellRange( nFileId, pScToken->GetString(), aRefData ); + mxData->mpLinkMgr->StoreCellRange( + nFileId, pScToken->GetString(), aRefData.toAbs(*mxData->mpScBasePos)); } default: ; // nothing, avoid compiler warning diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 6ba0612..90ea02c 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -472,8 +472,8 @@ public: /** Derived classes store all cells in the given range in a CRN record list. */ virtual void StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ) = 0; - virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ) = 0; - virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ) = 0; + virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScAddress& rPos ) = 0; + virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange ) = 0; /** Derived classes find or insert an EXTERNNAME record for an add-in function name. */ virtual bool InsertAddIn( @@ -520,8 +520,8 @@ public: virtual void StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ); - virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ); - virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ); + virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScAddress& rPos ); + virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange ); virtual bool InsertAddIn( sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, @@ -590,8 +590,8 @@ public: virtual void StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ); - virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ); - virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ); + virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScAddress& rPos ); + virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange ); virtual bool InsertAddIn( sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, @@ -1964,12 +1964,12 @@ void XclExpLinkManagerImpl5::StoreCellRange( const ScSingleRefData& /*rRef1*/, c // not implemented } -void XclExpLinkManagerImpl5::StoreCell( sal_uInt16 /*nFileId*/, const String& /*rTabName*/, const ScSingleRefData& /*rRef*/ ) +void XclExpLinkManagerImpl5::StoreCell( sal_uInt16 /*nFileId*/, const String& /*rTabName*/, const ScAddress& /*rPos*/ ) { // not implemented } -void XclExpLinkManagerImpl5::StoreCellRange( sal_uInt16 /*nFileId*/, const String& /*rTabName*/, const ScSingleRefData& /*rRef1*/, const ScSingleRefData& /*rRef2*/ ) +void XclExpLinkManagerImpl5::StoreCellRange( sal_uInt16 /*nFileId*/, const String& /*rTabName*/, const ScRange& /*rRange*/ ) { // not implemented } @@ -2162,17 +2162,14 @@ void XclExpLinkManagerImpl8::StoreCellRange( const ScSingleRefData& rRef1, const } } -void XclExpLinkManagerImpl8::StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ) +void XclExpLinkManagerImpl8::StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScAddress& rPos ) { - ScAddress aAddr(rRef.nCol, rRef.nRow, rRef.nTab); - maSBBuffer.StoreCell(nFileId, rTabName, aAddr); + maSBBuffer.StoreCell(nFileId, rTabName, rPos); } -void XclExpLinkManagerImpl8::StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 ) +void XclExpLinkManagerImpl8::StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange ) { - ScRange aRange(static_cast<SCCOL>(rRef1.nCol), static_cast<SCROW>(rRef1.nRow), static_cast<SCTAB>(rRef1.nTab), - static_cast<SCCOL>(rRef2.nCol), static_cast<SCROW>(rRef2.nRow), static_cast<SCTAB>(rRef2.nTab)); - maSBBuffer.StoreCellRange(nFileId, rTabName, aRange); + maSBBuffer.StoreCellRange(nFileId, rTabName, rRange); } bool XclExpLinkManagerImpl8::InsertAddIn( @@ -2310,14 +2307,14 @@ void XclExpLinkManager::StoreCellRange( const ScComplexRefData& rRef ) mxImpl->StoreCellRange( rRef.Ref1, rRef.Ref2 ); } -void XclExpLinkManager::StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ) +void XclExpLinkManager::StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScAddress& rPos ) { - mxImpl->StoreCell( nFileId, rTabName, rRef ); + mxImpl->StoreCell(nFileId, rTabName, rPos); } -void XclExpLinkManager::StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef ) +void XclExpLinkManager::StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange ) { - mxImpl->StoreCellRange( nFileId, rTabName, rRef.Ref1, rRef.Ref2 ); + mxImpl->StoreCellRange(nFileId, rTabName, rRange); } bool XclExpLinkManager::InsertAddIn( diff --git a/sc/source/filter/inc/xelink.hxx b/sc/source/filter/inc/xelink.hxx index 56cb6f6..cdf65d3 100644 --- a/sc/source/filter/inc/xelink.hxx +++ b/sc/source/filter/inc/xelink.hxx @@ -170,9 +170,9 @@ public: /** Stores all cells in the given range in a CRN record list. */ void StoreCellRange( const ScComplexRefData& rRef ); - void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef ); + void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScAddress& rPos ); - void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef ); + void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange ); /** Finds or inserts an EXTERNNAME record for an add-in function name. @param rnExtSheet (out-param) Returns the index of the EXTSHEET structure for the add-in function name. diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx index 1f5dd65..0278c75 100644 --- a/sc/source/filter/lotus/lotform.cxx +++ b/sc/source/filter/lotus/lotform.cxx @@ -283,9 +283,6 @@ void LotusToSc::LotusRelToScRel( sal_uInt16 nCol, sal_uInt16 nRow, ScSingleRefDa rSRD.nRelRow = static_cast< SCsROW >( static_cast< sal_Int16 >( nRow ) ); else rSRD.nRow = static_cast< SCsROW >( nRow ); - - if( rSRD.IsRowRel() || rSRD.IsColRel() ) - rSRD.CalcAbsIfRel( aEingPos ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits