make ScBigAddress use 64bit

It may points outside of the document, so with huge sheets 32bit
may not be enough.

Change-Id: I7aee1d8e90d6c59b91ec07584aa9f36d9352b55c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129972
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
This commit is contained in:
Luboš Luňák
2022-02-15 21:48:48 +01:00
parent 28cbc0dcb9
commit 6283ac89d7
5 changed files with 53 additions and 53 deletions
+23 -23
View File
@@ -27,13 +27,13 @@
class ScBigAddress
{
sal_Int32 nRow;
sal_Int32 nCol;
sal_Int32 nTab;
sal_Int64 nRow;
sal_Int64 nCol;
sal_Int64 nTab;
public:
ScBigAddress() : nRow(0), nCol(0), nTab(0) {}
ScBigAddress( sal_Int32 nColP, sal_Int32 nRowP, sal_Int32 nTabP )
ScBigAddress( sal_Int64 nColP, sal_Int64 nRowP, sal_Int64 nTabP )
: nRow( nRowP ), nCol( nColP ), nTab( nTabP ) {}
ScBigAddress( const ScBigAddress& r )
: nRow( r.nRow ), nCol( r.nCol ), nTab( r.nTab ) {}
@@ -41,20 +41,20 @@ public:
ScBigAddress( const ScAddress& r )
: nRow( r.Row() ), nCol( r.Col() ), nTab( r.Tab() ) {}
sal_Int32 Col() const { return nCol; }
sal_Int32 Row() const { return nRow; }
sal_Int32 Tab() const { return nTab; }
sal_Int64 Col() const { return nCol; }
sal_Int64 Row() const { return nRow; }
sal_Int64 Tab() const { return nTab; }
void Set( sal_Int32 nColP, sal_Int32 nRowP, sal_Int32 nTabP )
void Set( sal_Int64 nColP, sal_Int64 nRowP, sal_Int64 nTabP )
{ nCol = nColP; nRow = nRowP; nTab = nTabP; }
void SetCol( sal_Int32 nColP ) { nCol = nColP; }
void SetRow( sal_Int32 nRowP ) { nRow = nRowP; }
void SetTab( sal_Int32 nTabP ) { nTab = nTabP; }
void IncCol( sal_Int32 n = 1 ) { nCol += n; }
void IncRow( sal_Int32 n = 1 ) { nRow += n; }
void IncTab( sal_Int32 n = 1 ) { nTab += n; }
void SetCol( sal_Int64 nColP ) { nCol = nColP; }
void SetRow( sal_Int64 nRowP ) { nRow = nRowP; }
void SetTab( sal_Int64 nTabP ) { nTab = nTabP; }
void IncCol( sal_Int64 n = 1 ) { nCol += n; }
void IncRow( sal_Int64 n = 1 ) { nRow += n; }
void IncTab( sal_Int64 n = 1 ) { nTab += n; }
void GetVars( sal_Int32& nColP, sal_Int32& nRowP, sal_Int32& nTabP ) const
void GetVars( sal_Int64& nColP, sal_Int64& nRowP, sal_Int64& nTabP ) const
{ nColP = nCol; nRowP = nRow; nTabP = nTab; }
bool IsValid( const ScDocument& rDoc ) const;
@@ -114,18 +114,18 @@ public:
ScBigRange( ScBigRange&& ) = default;
ScBigRange( const ScRange& r )
: aStart( r.aStart ), aEnd( r.aEnd ) {}
ScBigRange( sal_Int32 nCol1, sal_Int32 nRow1, sal_Int32 nTab1,
sal_Int32 nCol2, sal_Int32 nRow2, sal_Int32 nTab2 )
ScBigRange( sal_Int64 nCol1, sal_Int64 nRow1, sal_Int64 nTab1,
sal_Int64 nCol2, sal_Int64 nRow2, sal_Int64 nTab2 )
: aStart( nCol1, nRow1, nTab1 ),
aEnd( nCol2, nRow2, nTab2 ) {}
void Set( sal_Int32 nCol1, sal_Int32 nRow1, sal_Int32 nTab1,
sal_Int32 nCol2, sal_Int32 nRow2, sal_Int32 nTab2 )
void Set( sal_Int64 nCol1, sal_Int64 nRow1, sal_Int64 nTab1,
sal_Int64 nCol2, sal_Int64 nRow2, sal_Int64 nTab2 )
{ aStart.Set( nCol1, nRow1, nTab1 );
aEnd.Set( nCol2, nRow2, nTab2 ); }
void GetVars( sal_Int32& nCol1, sal_Int32& nRow1, sal_Int32& nTab1,
sal_Int32& nCol2, sal_Int32& nRow2, sal_Int32& nTab2 ) const
void GetVars( sal_Int64& nCol1, sal_Int64& nRow1, sal_Int64& nTab1,
sal_Int64& nCol2, sal_Int64& nRow2, sal_Int64& nTab2 ) const
{ aStart.GetVars( nCol1, nRow1, nTab1 );
aEnd.GetVars( nCol2, nRow2, nTab2 ); }
@@ -147,8 +147,8 @@ public:
{ return !operator==( r ); }
// These are used to define whole rows/cols/tabs.
constexpr static sal_Int32 nRangeMin = 0x80000000;
constexpr static sal_Int32 nRangeMax = 0x7fffffff;
constexpr static sal_Int64 nRangeMin = ::std::numeric_limits<sal_Int64>::min();;
constexpr static sal_Int64 nRangeMax = ::std::numeric_limits<sal_Int64>::max();;
};
inline bool ScBigRange::Contains( const ScBigAddress& rAddr ) const
+2 -2
View File
@@ -506,9 +506,9 @@ OUString ScChangeAction::GetRefString(
aBuf.append(aTmp);
aBuf.append('.');
}
aBuf.append(static_cast<sal_Int32>(aTmpRange.aStart.Row()+1));
aBuf.append(static_cast<sal_Int64>(aTmpRange.aStart.Row()+1));
aBuf.append(':');
aBuf.append(static_cast<sal_Int32>(aTmpRange.aEnd.Row()+1));
aBuf.append(static_cast<sal_Int64>(aTmpRange.aEnd.Row()+1));
break;
default:
{
+5 -5
View File
@@ -154,7 +154,7 @@ static void Expand( R& n1, R& n2, U nStart, S nD )
n1 = sal::static_int_cast<R>( n1 - nD );
}
static bool lcl_IsWrapBig( sal_Int32 nRef, sal_Int32 nDelta )
static bool lcl_IsWrapBig( sal_Int64 nRef, sal_Int32 nDelta )
{
if ( nRef > 0 && nDelta > 0 )
return nRef + nDelta <= 0;
@@ -163,7 +163,7 @@ static bool lcl_IsWrapBig( sal_Int32 nRef, sal_Int32 nDelta )
return false;
}
static bool lcl_MoveBig( sal_Int32& rRef, sal_Int32 nStart, sal_Int32 nDelta )
static bool lcl_MoveBig( sal_Int64& rRef, sal_Int64 nStart, sal_Int32 nDelta )
{
bool bCut = false;
if ( rRef >= nStart )
@@ -178,7 +178,7 @@ static bool lcl_MoveBig( sal_Int32& rRef, sal_Int32 nStart, sal_Int32 nDelta )
return bCut;
}
static bool lcl_MoveItCutBig( sal_Int32& rRef, sal_Int32 nDelta )
static bool lcl_MoveItCutBig( sal_Int64& rRef, sal_Int32 nDelta )
{
bool bCut = lcl_IsWrapBig( rRef, nDelta );
rRef += nDelta;
@@ -382,8 +382,8 @@ ScRefUpdateRes ScRefUpdate::Update( UpdateRefMode eUpdateRefMode,
ScRefUpdateRes eRet = UR_NOTHING;
const ScBigRange aOldRange( rWhat );
sal_Int32 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2;
sal_Int32 theCol1, theRow1, theTab1, theCol2, theRow2, theTab2;
sal_Int64 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2;
sal_Int64 theCol1, theRow1, theTab1, theCol2, theRow2, theTab2;
rWhere.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
rWhat.GetVars( theCol1, theRow1, theTab1, theCol2, theRow2, theTab2 );
@@ -66,12 +66,12 @@ void ScChangeTrackingExportHelper::GetAcceptanceState(const ScChangeAction* pAct
void ScChangeTrackingExportHelper::WriteBigRange(const ScBigRange& rBigRange, XMLTokenEnum aName)
{
sal_Int32 nStartColumn;
sal_Int32 nEndColumn;
sal_Int32 nStartRow;
sal_Int32 nEndRow;
sal_Int32 nStartSheet;
sal_Int32 nEndSheet;
sal_Int64 nStartColumn;
sal_Int64 nEndColumn;
sal_Int64 nStartRow;
sal_Int64 nEndRow;
sal_Int64 nStartSheet;
sal_Int64 nEndSheet;
rBigRange.GetVars(nStartColumn, nStartRow, nStartSheet,
nEndColumn, nEndRow, nEndSheet);
if ((nStartColumn == nEndColumn) && (nStartRow == nEndRow) && (nStartSheet == nEndSheet))
@@ -392,16 +392,16 @@ void ScChangeTrackingExportHelper::WriteContentChange(const ScChangeAction* pAct
void ScChangeTrackingExportHelper::AddInsertionAttributes(const ScChangeAction* pConstAction)
{
sal_Int32 nPosition(0);
sal_Int32 nCount(0);
sal_Int32 nStartPosition(0);
sal_Int32 nEndPosition(0);
sal_Int32 nStartColumn;
sal_Int32 nEndColumn;
sal_Int32 nStartRow;
sal_Int32 nEndRow;
sal_Int32 nStartSheet;
sal_Int32 nEndSheet;
sal_Int64 nPosition(0);
sal_Int64 nCount(0);
sal_Int64 nStartPosition(0);
sal_Int64 nEndPosition(0);
sal_Int64 nStartColumn;
sal_Int64 nEndColumn;
sal_Int64 nStartRow;
sal_Int64 nEndRow;
sal_Int64 nStartSheet;
sal_Int64 nEndSheet;
const ScBigRange& rBigRange = pConstAction->GetBigRange();
rBigRange.GetVars(nStartColumn, nStartRow, nStartSheet,
nEndColumn, nEndRow, nEndSheet);
@@ -460,12 +460,12 @@ void ScChangeTrackingExportHelper::AddDeletionAttributes(const ScChangeActionDel
{
sal_Int32 nPosition(0);
const ScBigRange& rBigRange = pDelAction->GetBigRange();
sal_Int32 nStartColumn(0);
sal_Int32 nEndColumn(0);
sal_Int32 nStartRow(0);
sal_Int32 nEndRow(0);
sal_Int32 nStartSheet(0);
sal_Int32 nEndSheet(0);
sal_Int64 nStartColumn(0);
sal_Int64 nEndColumn(0);
sal_Int64 nStartRow(0);
sal_Int64 nEndRow(0);
sal_Int64 nStartSheet(0);
sal_Int64 nEndSheet(0);
rBigRange.GetVars(nStartColumn, nStartRow, nStartSheet,
nEndColumn, nEndRow, nEndSheet);
switch (pDelAction->GetType())
@@ -650,7 +650,7 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(const ScMyContentAction* pActio
if (!pChangeActionContent->IsTopContent() || pChangeActionContent->IsDeletedIn())
return;
sal_Int32 nCol, nRow, nTab, nCol2, nRow2, nTab2;
sal_Int64 nCol, nRow, nTab, nCol2, nRow2, nTab2;
pAction->aBigRange.GetVars(nCol, nRow, nTab, nCol2, nRow2, nTab2);
if ((nCol >= 0) && (nCol <= rDoc.MaxCol()) &&
(nRow >= 0) && (nRow <= rDoc.MaxRow()) &&