[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Fri Jul 26 12:52:29 PDT 2013
sc/source/filter/excel/xechart.cxx | 20 ++++++++++----------
sc/source/filter/excel/xeformula.cxx | 8 ++++----
sc/source/filter/excel/xelink.cxx | 32 ++++++++++++++++----------------
sc/source/filter/excel/xichart.cxx | 10 +++++-----
sc/source/filter/inc/xelink.hxx | 4 ++--
5 files changed, 37 insertions(+), 37 deletions(-)
New commits:
commit 8dff0bd635701e2c7d0600778b4dc72782dcb353
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Jul 26 15:52:53 2013 -0400
More on removing direct access to reference data members.
Change-Id: I9bb682da0408df76794a1bbf9d48995cd1633d99
diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index 92bb939..64e3f0d 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -941,20 +941,20 @@ sal_uInt16 XclExpChSourceLink::ConvertDataSequence( Reference< XDataSequence > x
{
// split 3-dimensional ranges into single sheets
const ScComplexRefData& rComplexRef = static_cast< const ScToken* >( pToken )->GetDoubleRef();
- const ScSingleRefData& rRef1 = rComplexRef.Ref1;
- const ScSingleRefData& rRef2 = rComplexRef.Ref2;
- for( SCsTAB nScTab = rRef1.nTab; nScTab <= rRef2.nTab; ++nScTab )
+ ScAddress aAbs1 = rComplexRef.Ref1.toAbs(ScAddress());
+ ScAddress aAbs2 = rComplexRef.Ref2.toAbs(ScAddress());
+ for (SCsTAB nScTab = aAbs1.Tab(); nScTab <= aAbs2.Tab(); ++nScTab)
{
// split 2-dimensional ranges into single columns
- if( bSplitToColumns && (rRef1.nCol < rRef2.nCol) && (rRef1.nRow < rRef2.nRow) )
- for( SCsCOL nScCol = rRef1.nCol; nScCol <= rRef2.nCol; ++nScCol )
- lclAddDoubleRefData( aArray, *pToken, nScTab, nScCol, rRef1.nRow, nScTab, nScCol, rRef2.nRow );
+ if (bSplitToColumns && (aAbs1.Col() < aAbs2.Col()) && (aAbs1.Row() < aAbs2.Row()))
+ for (SCCOL nScCol = aAbs1.Col(); nScCol <= aAbs2.Col(); ++nScCol)
+ lclAddDoubleRefData(aArray, *pToken, nScTab, nScCol, aAbs1.Row(), nScTab, nScCol, aAbs2.Row());
else
- lclAddDoubleRefData( aArray, *pToken, nScTab, rRef1.nCol, rRef1.nRow, nScTab, rRef2.nCol, rRef2.nRow );
+ lclAddDoubleRefData(aArray, *pToken, nScTab, aAbs1.Col(), aAbs1.Row(), nScTab, aAbs2.Col(), aAbs2.Row());
}
- sal_uInt32 nTabs = static_cast< sal_uInt32 >( rRef2.nTab - rRef1.nTab + 1 );
- sal_uInt32 nCols = static_cast< sal_uInt32 >( rRef2.nCol - rRef1.nCol + 1 );
- sal_uInt32 nRows = static_cast< sal_uInt32 >( rRef2.nRow - rRef1.nRow + 1 );
+ 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);
nValueCount += nCols * nRows * nTabs;
}
break;
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index 32d3d75..a803002 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -1879,8 +1879,8 @@ void XclExpFmlaCompImpl::ConvertRefData(
{
// convert start and end of the range
ConvertRefData( rRefData.Ref1, rXclRange.maFirst, bNatLangRef, false, false );
- bool bTruncMaxCol = !rRefData.Ref1.IsColDeleted() && (rRefData.Ref1.nCol == 0);
- bool bTruncMaxRow = !rRefData.Ref1.IsRowDeleted() && (rRefData.Ref1.nRow == 0);
+ bool bTruncMaxCol = !rRefData.Ref1.IsColDeleted() && (rXclRange.maFirst.mnCol == 0);
+ bool bTruncMaxRow = !rRefData.Ref1.IsRowDeleted() && (rXclRange.maFirst.mnRow == 0);
ConvertRefData( rRefData.Ref2, rXclRange.maLast, bNatLangRef, bTruncMaxCol, bTruncMaxRow );
}
@@ -1916,7 +1916,7 @@ void XclExpFmlaCompImpl::ProcessCellRef( const XclExpScToken& rTokData )
{
// store external cell contents in CRN records
if( mxData->mrCfg.mbFromCell && mxData->mpLinkMgr && mxData->mpScBasePos )
- mxData->mpLinkMgr->StoreCell( aRefData );
+ mxData->mpLinkMgr->StoreCell(aRefData, *mxData->mpScBasePos);
// create the tRef, tRefErr, tRefN, tRef3d, or tRefErr3d token
if( !mxData->mrCfg.mb3DRefOnly && IsRef2D( aRefData ) )
@@ -1961,7 +1961,7 @@ void XclExpFmlaCompImpl::ProcessRangeRef( const XclExpScToken& rTokData )
// store external cell contents in CRN records
if( mxData->mrCfg.mbFromCell && mxData->mpLinkMgr && mxData->mpScBasePos )
- mxData->mpLinkMgr->StoreCellRange( aRefData );
+ mxData->mpLinkMgr->StoreCellRange(aRefData, *mxData->mpScBasePos);
// create the tArea, tAreaErr, tAreaN, tArea3d, or tAreaErr3d token
if( !mxData->mrCfg.mb3DRefOnly && IsRef2D( aRefData ) )
diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx
index 8c1e16b..2c00f9f 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -470,7 +470,7 @@ public:
XclExpRefLogEntry* pRefLogEntry ) = 0;
/** 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 StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2, const ScAddress& rPos ) = 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;
@@ -518,7 +518,7 @@ public:
sal_uInt16& rnExtSheet, sal_uInt16& rnFirstSBTab, sal_uInt16& rnLastSBTab,
XclExpRefLogEntry* pRefLogEntry );
- virtual void StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 );
+ virtual void StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2, const ScAddress& rPos );
virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScAddress& rPos );
virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange );
@@ -588,7 +588,7 @@ public:
sal_uInt16& rnExtSheet, sal_uInt16& rnFirstSBTab, sal_uInt16& rnLastSBTab,
XclExpRefLogEntry* pRefLogEntry );
- virtual void StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 );
+ virtual void StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2, const ScAddress& rPos );
virtual void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScAddress& rPos );
virtual void StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange );
@@ -1959,7 +1959,7 @@ void XclExpLinkManagerImpl5::FindExtSheet(
// not implemented
}
-void XclExpLinkManagerImpl5::StoreCellRange( const ScSingleRefData& /*rRef1*/, const ScSingleRefData& /*rRef2*/ )
+void XclExpLinkManagerImpl5::StoreCellRange( const ScSingleRefData& /*rRef1*/, const ScSingleRefData& /*rRef2*/, const ScAddress& /*rPos*/ )
{
// not implemented
}
@@ -2140,17 +2140,17 @@ void XclExpLinkManagerImpl8::FindExtSheet(
rnLastSBTab = aXti.mnLastSBTab;
}
-void XclExpLinkManagerImpl8::StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2 )
+void XclExpLinkManagerImpl8::StoreCellRange( const ScSingleRefData& rRef1, const ScSingleRefData& rRef2, const ScAddress& rPos )
{
- if( !rRef1.IsDeleted() && !rRef2.IsDeleted() && (rRef1.nTab >= 0) && (rRef2.nTab >= 0) )
+ ScAddress aAbs1 = rRef1.toAbs(rPos);
+ ScAddress aAbs2 = rRef2.toAbs(rPos);
+ if (!rRef1.IsDeleted() && !rRef2.IsDeleted() && (aAbs1.Tab() >= 0) && (aAbs2.Tab() >= 0))
{
const XclExpTabInfo& rTabInfo = GetTabInfo();
- SCTAB nFirstScTab = static_cast< SCTAB >( rRef1.nTab );
- SCTAB nLastScTab = static_cast< SCTAB >( rRef2.nTab );
- ScRange aRange(
- static_cast< SCCOL >( rRef1.nCol ), static_cast< SCROW >( rRef1.nRow ), 0,
- static_cast< SCCOL >( rRef2.nCol ), static_cast< SCROW >( rRef2.nRow ), 0 );
- for( SCTAB nScTab = nFirstScTab; nScTab <= nLastScTab; ++nScTab )
+ SCTAB nFirstScTab = aAbs1.Tab();
+ SCTAB nLastScTab = aAbs2.Tab();
+ ScRange aRange(aAbs1.Col(), aAbs1.Row(), 0, aAbs2.Col(), aAbs2.Row(), 0);
+ for (SCTAB nScTab = nFirstScTab; nScTab <= nLastScTab; ++nScTab)
{
if( rTabInfo.IsExternalTab( nScTab ) )
{
@@ -2297,14 +2297,14 @@ void XclExpLinkManager::FindExtSheet( sal_uInt16 nFileId, const String& rTabName
mxImpl->FindExtSheet( nFileId, rTabName, nXclTabSpan, rnExtSheet, rnFirstSBTab, rnLastSBTab, pRefLogEntry );
}
-void XclExpLinkManager::StoreCell( const ScSingleRefData& rRef )
+void XclExpLinkManager::StoreCell( const ScSingleRefData& rRef, const ScAddress& rPos )
{
- mxImpl->StoreCellRange( rRef, rRef );
+ mxImpl->StoreCellRange(rRef, rRef, rPos);
}
-void XclExpLinkManager::StoreCellRange( const ScComplexRefData& rRef )
+void XclExpLinkManager::StoreCellRange( const ScComplexRefData& rRef, const ScAddress& rPos )
{
- mxImpl->StoreCellRange( rRef.Ref1, rRef.Ref2 );
+ mxImpl->StoreCellRange(rRef.Ref1, rRef.Ref2, rPos);
}
void XclExpLinkManager::StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScAddress& rPos )
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 2ccd8c5..fb16dda 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -802,11 +802,11 @@ sal_uInt16 XclImpChSourceLink::GetCellCount() const
{
// cell range
const ScComplexRefData& rComplexRef = static_cast< const ScToken* >( pToken )->GetDoubleRef();
- const ScSingleRefData& rRef1 = rComplexRef.Ref1;
- const ScSingleRefData& rRef2 = rComplexRef.Ref2;
- sal_uInt32 nTabs = static_cast< sal_uInt32 >( rRef2.nTab - rRef1.nTab + 1 );
- sal_uInt32 nCols = static_cast< sal_uInt32 >( rRef2.nCol - rRef1.nCol + 1 );
- sal_uInt32 nRows = static_cast< sal_uInt32 >( rRef2.nRow - rRef1.nRow + 1 );
+ ScAddress aAbs1 = rComplexRef.Ref1.toAbs(ScAddress());
+ ScAddress aAbs2 = rComplexRef.Ref2.toAbs(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);
nCellCount += nCols * nRows * nTabs;
}
break;
diff --git a/sc/source/filter/inc/xelink.hxx b/sc/source/filter/inc/xelink.hxx
index cdf65d3..8331aa9 100644
--- a/sc/source/filter/inc/xelink.hxx
+++ b/sc/source/filter/inc/xelink.hxx
@@ -166,9 +166,9 @@ public:
XclExpRefLogEntry* pRefLogEntry = NULL );
/** Stores the cell with the given address in a CRN record list. */
- void StoreCell( const ScSingleRefData& rRef );
+ void StoreCell( const ScSingleRefData& rRef, const ScAddress& rPos );
/** Stores all cells in the given range in a CRN record list. */
- void StoreCellRange( const ScComplexRefData& rRef );
+ void StoreCellRange( const ScComplexRefData& rRef, const ScAddress& rPos );
void StoreCell( sal_uInt16 nFileId, const String& rTabName, const ScAddress& rPos );
More information about the Libreoffice-commits
mailing list