summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgilssonn <gilsonnyirimana@gmail.com>2023-07-13 23:11:11 -0400
committerAndras Timar <andras.timar@collabora.com>2024-04-15 11:56:32 +0200
commit0ad2652ca77a76aa01693db4bca1b90649d0f598 (patch)
tree3732095bb54016970299bc1f74d87b6acbfbd0a3
parent880d99dadeb4be3a0fa50b14e27522efb7db5f9a (diff)
tdf#114441 Convert use of sal_uLong to better integer types
Reasoning: + For clipcontent.cxx, column3.cxx, dbdocutl.cxx, documen8.cxx,formulacell.cxx, patattr.cxx, stlpool.cxx, table2.cxx, table3.cxx and validat.cxx: + sal_uLong variables and functions are being initialized with/assigned/returning sal_uInt32 or size_t values + For column2.cxx: + The type of the return values of the `getWeight` function are size_t + For document.hxx, documen2.cxx, docsh.hxx, docsh5.cxx, viewfun2.cxx and globstr.hrc + `ScDocument::TransferTab`'s return variable's value is constrained to be either 0 or 1; which is better represented as a boolean Change-Id: If556f7fcc29f7e325618721959ea4e3615b2e755 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154408 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/inc/globstr.hrc2
-rw-r--r--sc/source/core/data/clipcontext.cxx2
-rw-r--r--sc/source/core/data/column2.cxx10
-rw-r--r--sc/source/core/data/column3.cxx4
-rw-r--r--sc/source/core/data/dbdocutl.cxx2
-rw-r--r--sc/source/core/data/documen2.cxx10
-rw-r--r--sc/source/core/data/documen8.cxx4
-rw-r--r--sc/source/core/data/formulacell.cxx2
-rw-r--r--sc/source/core/data/patattr.cxx4
-rw-r--r--sc/source/core/data/stlpool.cxx2
-rw-r--r--sc/source/core/data/table2.cxx2
-rw-r--r--sc/source/core/data/table3.cxx2
-rw-r--r--sc/source/core/data/validat.cxx2
-rw-r--r--sc/source/ui/docshell/docsh5.cxx12
-rw-r--r--sc/source/ui/inc/docsh.hxx2
-rw-r--r--sc/source/ui/view/viewfun2.cxx56
17 files changed, 41 insertions, 79 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 09747bb2c0e7..468f0571c79f 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -982,7 +982,7 @@ public:
bool MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress = nullptr );
SC_DLLPUBLIC bool CopyTab( SCTAB nOldPos, SCTAB nNewPos,
const ScMarkData* pOnlyMarked = nullptr );
- SC_DLLPUBLIC sal_uLong TransferTab(ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
+ SC_DLLPUBLIC bool TransferTab(ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
bool bInsertNew = true,
bool bResultsOnly = false );
SC_DLLPUBLIC void TransferDrawPage(const ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos);
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 6d73c41fdc51..b9993ce2896a 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -320,8 +320,6 @@
#define STR_UNDO_HIDETAB NC_("STR_UNDO_HIDETAB", "Hide sheet")
#define STR_UNDO_HIDETABS NC_("STR_UNDO_HIDETABS", "Hide sheets")
#define STR_UNDO_TAB_RTL NC_("STR_UNDO_TAB_RTL", "Flip sheet")
-#define STR_ABSREFLOST NC_("STR_ABSREFLOST", "The new table contains absolute references to other tables which may be incorrect!")
-#define STR_NAMECONFLICT NC_("STR_NAMECONFLICT", "Due to identical names, an existing range name in the destination document has been altered!")
#define STR_ERR_AUTOFILTER NC_("STR_ERR_AUTOFILTER", "AutoFilter not possible")
#define STR_CREATENAME_REPLACE NC_("STR_CREATENAME_REPLACE", "Replace existing definition of #?")
#define STR_CREATENAME_MARKERR NC_("STR_CREATENAME_MARKERR", "Invalid selection for range names")
diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx
index be145f995451..fc6f136d0372 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -397,7 +397,7 @@ bool CopyFromClipContext::isCloneSparklines() const
bool CopyFromClipContext::isDateCell( const ScColumn& rCol, SCROW nRow ) const
{
- sal_uLong nNumIndex = rCol.GetAttr(nRow, ATTR_VALUE_FORMAT).GetValue();
+ sal_uInt32 nNumIndex = rCol.GetAttr(nRow, ATTR_VALUE_FORMAT).GetValue();
SvNumFormatType nType = mpClipDoc->GetFormatTable()->GetType(nNumIndex);
return (nType == SvNumFormatType::DATE) || (nType == SvNumFormatType::TIME) || (nType == SvNumFormatType::DATETIME);
}
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index c8a0c0821889..0c79029d96c4 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -3722,7 +3722,7 @@ namespace {
class WeightedCounter
{
- sal_uLong mnCount;
+ size_t mnCount;
public:
WeightedCounter() : mnCount(0) {}
@@ -3731,7 +3731,7 @@ public:
mnCount += getWeight(node);
}
- static sal_uLong getWeight(const sc::CellStoreType::value_type& node)
+ static size_t getWeight(const sc::CellStoreType::value_type& node)
{
switch (node.type)
{
@@ -3752,14 +3752,14 @@ public:
}
}
- sal_uLong getCount() const { return mnCount; }
+ size_t getCount() const { return mnCount; }
};
class WeightedCounterWithRows
{
const SCROW mnStartRow;
const SCROW mnEndRow;
- sal_uLong mnCount;
+ size_t mnCount;
public:
WeightedCounterWithRows(SCROW nStartRow, SCROW nEndRow)
@@ -3780,7 +3780,7 @@ public:
}
}
- sal_uLong getCount() const { return mnCount; }
+ size_t getCount() const { return mnCount; }
};
}
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index ac6b6e785731..911e59ac7613 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2570,7 +2570,7 @@ class FilterEntriesHandler
void processCell(const ScColumn& rColumn, SCROW nRow, ScRefCellValue& rCell, bool bIsEmptyCell=false)
{
SvNumberFormatter* pFormatter = mrColumn.GetDoc().GetFormatTable();
- sal_uLong nFormat = mrColumn.GetNumberFormat(mrColumn.GetDoc().GetNonThreadedContext(), nRow);
+ sal_uInt32 nFormat = mrColumn.GetNumberFormat(mrColumn.GetDoc().GetNonThreadedContext(), nRow);
OUString aStr = ScCellFormat::GetInputString(rCell, nFormat, *pFormatter, mrColumn.GetDoc(), mbFiltering);
// Colors
@@ -3159,7 +3159,7 @@ double* ScColumn::GetValueCell( SCROW nRow )
OUString ScColumn::GetInputString( const ScRefCellValue& aCell, SCROW nRow, bool bForceSystemLocale ) const
{
- sal_uLong nFormat = GetNumberFormat(GetDoc().GetNonThreadedContext(), nRow);
+ sal_uInt32 nFormat = GetNumberFormat(GetDoc().GetNonThreadedContext(), nRow);
return ScCellFormat::GetInputString(aCell, nFormat, *(GetDoc().GetFormatTable()), GetDoc(), nullptr, false, bForceSystemLocale);
}
diff --git a/sc/source/core/data/dbdocutl.cxx b/sc/source/core/data/dbdocutl.cxx
index db45170978fe..df373d991d17 100644
--- a/sc/source/core/data/dbdocutl.cxx
+++ b/sc/source/core/data/dbdocutl.cxx
@@ -44,7 +44,7 @@ void ScDatabaseDocUtil::PutData(ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB
bool bValue = false;
bool bEmptyFlag = false;
bool bError = false;
- sal_uLong nFormatIndex = 0;
+ sal_uInt32 nFormatIndex = 0;
// wasNull calls only if null value was found?
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 3b9b24cfec49..6934b05bf144 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -943,13 +943,11 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
return bValid;
}
-sal_uLong ScDocument::TransferTab( ScDocument& rSrcDoc, SCTAB nSrcPos,
+bool ScDocument::TransferTab( ScDocument& rSrcDoc, SCTAB nSrcPos,
SCTAB nDestPos, bool bInsertNew,
bool bResultsOnly )
{
- sal_uLong nRetVal = 1; // 0 => error 1 = ok
- // 3 => NameBox
- // 4 => both
+ bool bRetVal = true;
if (rSrcDoc.mpShell->GetMedium())
{
@@ -1087,7 +1085,7 @@ sal_uLong ScDocument::TransferTab( ScDocument& rSrcDoc, SCTAB nSrcPos,
maTabs[nDestPos]->SetPendingRowHeights( rSrcDoc.maTabs[nSrcPos]->IsPendingRowHeights() );
}
if (!bValid)
- nRetVal = 0;
+ bRetVal = false;
bool bVbaEnabled = IsInVBAMode();
if ( bVbaEnabled )
@@ -1125,7 +1123,7 @@ sal_uLong ScDocument::TransferTab( ScDocument& rSrcDoc, SCTAB nSrcPos,
}
}
- return nRetVal;
+ return bRetVal;
}
void ScDocument::SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError)
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 50748236ee2a..e2522605c9c5 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -248,9 +248,9 @@ void ScDocument::ModifyStyleSheet( SfxStyleSheetBase& rStyleSheet,
if (maTabs[nTab])
maTabs[nTab]->SetStreamValid( false );
- sal_uLong nOldFormat =
+ sal_uInt32 nOldFormat =
rSet.Get( ATTR_VALUE_FORMAT ).GetValue();
- sal_uLong nNewFormat =
+ sal_uInt32 nNewFormat =
rChanges.Get( ATTR_VALUE_FORMAT ).GetValue();
LanguageType eNewLang, eOldLang;
eNewLang = eOldLang = LANGUAGE_DONTKNOW;
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 93d712d106f9..2f0cf6c6bec5 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2273,7 +2273,7 @@ void ScFormulaCell::InterpretTail( ScInterpreterContext& rContext, ScInterpretTa
if ( pCode->IsRecalcModeForced() )
{
- sal_uLong nValidation = rDocument.GetAttr(
+ sal_uInt32 nValidation = rDocument.GetAttr(
aPos.Col(), aPos.Row(), aPos.Tab(), ATTR_VALIDDATA )->GetValue();
if ( nValidation )
{
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index b25f6bda27ec..f3a180f0cd26 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -1108,7 +1108,7 @@ static SfxStyleSheetBase* lcl_CopyStyleToPool
if ( pFormatExchangeList &&
(pSrcItem = rSrcSet.GetItemIfSet( ATTR_VALUE_FORMAT, false )) )
{
- sal_uLong nOldFormat = pSrcItem->GetValue();
+ sal_uInt32 nOldFormat = pSrcItem->GetValue();
SvNumberFormatterIndexTable::const_iterator it = pFormatExchangeList->find(nOldFormat);
if (it != pFormatExchangeList->end())
{
@@ -1184,7 +1184,7 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD
{
// Number format to Exchange List
- sal_uLong nOldFormat = static_cast<const SfxUInt32Item*>(pSrcItem)->GetValue();
+ sal_uInt32 nOldFormat = static_cast<const SfxUInt32Item*>(pSrcItem)->GetValue();
SvNumberFormatterIndexTable::const_iterator it = pDestDoc->GetFormatExchangeList()->find(nOldFormat);
if (it != pDestDoc->GetFormatExchangeList()->end())
{
diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx
index 6fa08b8112de..c338943dc81b 100644
--- a/sc/source/core/data/stlpool.cxx
+++ b/sc/source/core/data/stlpool.cxx
@@ -170,7 +170,7 @@ void ScStyleSheetPool::CopyStyleFrom( SfxStyleSheetBasePool* pSrcPool,
if ( pDoc && pDoc->GetFormatExchangeList() &&
(pItem = rSourceSet.GetItemIfSet( ATTR_VALUE_FORMAT, false )) )
{
- sal_uLong nOldFormat = pItem->GetValue();
+ sal_uInt32 nOldFormat = pItem->GetValue();
SvNumberFormatterIndexTable::const_iterator it = pDoc->GetFormatExchangeList()->find(nOldFormat);
if (it != pDoc->GetFormatExchangeList()->end())
{
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 6d7c5b0ac874..fedd0555767e 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -666,7 +666,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO
{
continue;
}
- sal_uLong nMax = 0;
+ sal_uInt32 nMax = 0;
bool bDuplicate = false;
for(const auto& rxCond : *mpCondFormatList)
{
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 9dfa0ddc24fa..88f77f4dc460 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2765,7 +2765,7 @@ bool ScTable::CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow
}
if (bValid)
{
- sal_uLong nVisible = 0;
+ SCSIZE nVisible = 0;
for ( nCol=nCol1; nCol<=ClampToAllocatedColumns(nCol2); nCol++ )
nVisible += aCol[nCol].VisibleCount( nRow1+1, nRow2 );
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 5a569ef94487..62f057539ccc 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -790,7 +790,7 @@ rtl_uString* ScStringTokenIterator::Next()
}
/** Returns the number format of the passed cell, or the standard format. */
-sal_uLong lclGetCellFormat( const ScDocument& rDoc, const ScAddress& rPos )
+sal_uInt32 lclGetCellFormat( const ScDocument& rDoc, const ScAddress& rPos )
{
const ScPatternAttr* pPattern = rDoc.GetPattern( rPos.Col(), rPos.Row(), rPos.Tab() );
if( !pPattern )
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index e4cec9200c01..9249d92ce873 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -860,7 +860,7 @@ SCTAB ScDocShell::MakeScenario( SCTAB nTab, const OUString& rName, const OUStrin
return nTab;
}
-sal_uLong ScDocShell::TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
+bool ScDocShell::TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
SCTAB nDestPos, bool bInsertNew,
bool bNotifyAndPaint )
{
@@ -872,14 +872,14 @@ sal_uLong ScDocShell::TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
aParam.maRanges.push_back(aRange);
rSrcDoc.SetClipParam(aParam);
- sal_uLong nErrVal = m_pDocument->TransferTab( rSrcDoc, nSrcPos, nDestPos,
+ bool bValid = m_pDocument->TransferTab( rSrcDoc, nSrcPos, nDestPos,
bInsertNew ); // no insert
// TransferTab doesn't copy drawing objects with bInsertNew=FALSE
- if ( nErrVal > 0 && !bInsertNew)
+ if ( bValid && !bInsertNew)
m_pDocument->TransferDrawPage( rSrcDoc, nSrcPos, nDestPos );
- if(nErrVal>0 && rSrcDoc.IsScenario( nSrcPos ))
+ if(bValid && rSrcDoc.IsScenario( nSrcPos ))
{
OUString aComment;
Color aColor;
@@ -896,7 +896,7 @@ sal_uLong ScDocShell::TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
}
- if ( nErrVal > 0 && rSrcDoc.IsTabProtected( nSrcPos ) )
+ if ( bValid && rSrcDoc.IsTabProtected( nSrcPos ) )
m_pDocument->SetTabProtection(nDestPos, rSrcDoc.GetTabProtection(nSrcPos));
if ( bNotifyAndPaint )
{
@@ -904,7 +904,7 @@ sal_uLong ScDocShell::TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
PostPaintExtras();
PostPaintGridAll();
}
- return nErrVal;
+ return bValid;
}
bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord )
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index e3ee48a43ea8..d42ffc9ef8e8 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -281,7 +281,7 @@ public:
ScMarkData& rMark, bool bRecord = true);
void ModifyScenario(SCTAB nTab, const OUString& rName, const OUString& rComment,
const Color& rColor, ScScenarioFlags nFlags);
- sal_uLong TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
+ bool TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
SCTAB nDestPos, bool bInsertNew,
bool bNotifyAndPaint );
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 1aa946d3e9fd..f0bc6e0dd40d 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2754,8 +2754,6 @@ void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
bool bUndo(rDoc.IsUndoEnabled());
bool bError = false;
- bool bRefs = false;
- bool bName = false;
if (rSrcDoc.GetDrawLayer())
pDocSh->MakeDrawLayer();
@@ -2781,23 +2779,12 @@ void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
{
SCTAB nSrcTab = pSrcTabs[i];
SCTAB nDestTab1=nTab+i;
- sal_uLong nErrVal = pDocSh->TransferTab( *pSrcShell, nSrcTab, nDestTab1,
+ bool bValid = pDocSh->TransferTab( *pSrcShell, nSrcTab, nDestTab1,
false, false ); // no insert
- switch (nErrVal)
+ if (!bValid)
{
- case 0: // internal error or full of errors
- bError = true;
- break;
- case 2:
- bRefs = true;
- break;
- case 3:
- bName = true;
- break;
- case 4:
- bRefs = bName = true;
- break;
+ bError = true;
}
}
@@ -2856,11 +2843,6 @@ void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
pDocSh->PostPaintExtras();
pDocSh->PostPaintGridAll();
pDocSh->SetDocumentModified();
-
- if (bRefs)
- ErrorMessage(STR_ABSREFLOST);
- if (bName)
- ErrorMessage(STR_NAMECONFLICT);
}
// Move/Copy table to another document
@@ -2964,7 +2946,7 @@ void ScViewFunc::MoveTable(sal_uInt16 nDestDocNo, SCTAB nDestTab, bool bCopy,
if (!bNewDoc && bUndo)
rDestDoc.BeginDrawUndo(); // drawing layer must do its own undo actions
- sal_uLong nErrVal =1;
+ bool bValid = true;
if(nDestTab==SC_TAB_APPEND)
nDestTab=rDestDoc.GetTableCount();
SCTAB nDestTab1=nDestTab;
@@ -2980,19 +2962,19 @@ void ScViewFunc::MoveTable(sal_uInt16 nDestDocNo, SCTAB nDestTab, bool bCopy,
rDestDoc.CreateValidTabName( aName );
if ( !rDestDoc.InsertTab( nDestTab1, aName ) )
{
- nErrVal = 0; // total error
+ bValid = false; // total error
break; // for
}
ScRange aRange( 0, 0, TheTabs[j], rDoc.MaxCol(), rDoc.MaxRow(), TheTabs[j] );
aParam.maRanges.push_back(aRange);
}
rDoc.SetClipParam(aParam);
- if ( nErrVal > 0 )
+ if ( bValid )
{
nDestTab1 = nDestTab;
for(SCTAB nTab : TheTabs)
{
- nErrVal = pDestShell->TransferTab( *pDocShell, nTab, nDestTab1, false, false );
+ bValid = pDestShell->TransferTab( *pDocShell, nTab, nDestTab1, false, false );
nDestTab1++;
}
}
@@ -3011,27 +2993,11 @@ void ScViewFunc::MoveTable(sal_uInt16 nDestDocNo, SCTAB nDestTab, bool bCopy,
}
GetFrameWin()->LeaveWait();
- switch (nErrVal)
+
+ if (!bValid)
{
- case 0: // internal error or full of errors
- {
- ErrorMessage(STR_TABINSERT_ERROR);
- return;
- }
- case 2:
- ErrorMessage(STR_ABSREFLOST);
- break;
- case 3:
- ErrorMessage(STR_NAMECONFLICT);
- break;
- case 4:
- {
- ErrorMessage(STR_ABSREFLOST);
- ErrorMessage(STR_NAMECONFLICT);
- }
- break;
- default:
- break;
+ ErrorMessage(STR_TABINSERT_ERROR);
+ return;
}
if (!bCopy)