summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-05-21 17:44:32 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-05-21 21:09:57 +0200
commit2634bc59092b24217d984a5845365d703bdb08d2 (patch)
treea3b7324d54aefb57d5f012c7aeb1b80d07fce75b /sw/source/core
parentc912c4b02b2dc4cd5aa62d77e92e1731c6cbde65 (diff)
sw: replace most static_cast<sal_uInt16>() calls with o3tl::narrowing()
o3tl::narrowing() is a better way to handle this, as that way the integer conversion is still implicit, which allows detecting integer truncation at runtime (with suitable compiler flags). Change-Id: I499abda3be6943e8c111c56df390e72939586221 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115948 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/SwNumberTree/SwNodeNum.cxx2
-rw-r--r--sw/source/core/access/accportions.cxx2
-rw-r--r--sw/source/core/crsr/crsrsh.cxx4
-rw-r--r--sw/source/core/crsr/swcrsr.cxx4
-rw-r--r--sw/source/core/crsr/trvltbl.cxx2
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx2
-rw-r--r--sw/source/core/doc/DocumentFieldsManager.cxx2
-rw-r--r--sw/source/core/doc/DocumentLayoutManager.cxx2
-rw-r--r--sw/source/core/doc/DocumentStylePoolManager.cxx8
-rw-r--r--sw/source/core/doc/doc.cxx4
-rw-r--r--sw/source/core/doc/docdesc.cxx4
-rw-r--r--sw/source/core/doc/docdraw.cxx6
-rw-r--r--sw/source/core/doc/docfmt.cxx2
-rw-r--r--sw/source/core/doc/docftn.cxx10
-rw-r--r--sw/source/core/doc/doclay.cxx2
-rw-r--r--sw/source/core/doc/docnum.cxx6
-rw-r--r--sw/source/core/doc/docsort.cxx2
-rw-r--r--sw/source/core/doc/doctxm.cxx4
-rw-r--r--sw/source/core/doc/fmtcol.cxx2
-rw-r--r--sw/source/core/doc/htmltbl.cxx66
-rw-r--r--sw/source/core/doc/notxtfrm.cxx2
-rw-r--r--sw/source/core/doc/number.cxx6
-rw-r--r--sw/source/core/doc/tblcpy.cxx8
-rw-r--r--sw/source/core/doc/tblrwcl.cxx24
-rw-r--r--sw/source/core/doc/textboxhelper.cxx20
-rw-r--r--sw/source/core/docnode/ndtbl.cxx12
-rw-r--r--sw/source/core/docnode/ndtbl1.cxx4
-rw-r--r--sw/source/core/docnode/section.cxx2
-rw-r--r--sw/source/core/edit/autofmt.cxx20
-rw-r--r--sw/source/core/edit/edattr.cxx8
-rw-r--r--sw/source/core/edit/edfld.cxx2
-rw-r--r--sw/source/core/edit/editsh.cxx2
-rw-r--r--sw/source/core/edit/ednumber.cxx2
-rw-r--r--sw/source/core/fields/dbfld.cxx2
-rw-r--r--sw/source/core/fields/expfld.cxx8
-rw-r--r--sw/source/core/frmedt/fetab.cxx8
-rw-r--r--sw/source/core/frmedt/tblsel.cxx2
-rw-r--r--sw/source/core/graphic/grfatr.cxx2
-rw-r--r--sw/source/core/inc/tblrwcl.hxx2
-rw-r--r--sw/source/core/inc/wrong.hxx2
-rw-r--r--sw/source/core/layout/atrfrm.cxx10
-rw-r--r--sw/source/core/layout/dbg_lay.cxx2
-rw-r--r--sw/source/core/layout/wsfrm.cxx4
-rw-r--r--sw/source/core/table/swnewtable.cxx6
-rw-r--r--sw/source/core/table/swtable.cxx12
-rw-r--r--sw/source/core/text/EnhancedPDFExportHelper.cxx4
-rw-r--r--sw/source/core/text/frmcrsr.cxx2
-rw-r--r--sw/source/core/text/inftxt.cxx4
-rw-r--r--sw/source/core/text/itradj.cxx4
-rw-r--r--sw/source/core/text/itratr.cxx4
-rw-r--r--sw/source/core/text/itrcrsr.cxx4
-rw-r--r--sw/source/core/text/itrform2.cxx24
-rw-r--r--sw/source/core/text/porfld.cxx12
-rw-r--r--sw/source/core/text/porfly.cxx6
-rw-r--r--sw/source/core/text/porlin.cxx4
-rw-r--r--sw/source/core/text/pormulti.cxx10
-rw-r--r--sw/source/core/text/porrst.cxx4
-rw-r--r--sw/source/core/text/portxt.cxx2
-rw-r--r--sw/source/core/text/txtdrop.cxx12
-rw-r--r--sw/source/core/text/txtfly.cxx2
-rw-r--r--sw/source/core/text/txtfrm.cxx8
-rw-r--r--sw/source/core/text/txtftn.cxx2
-rw-r--r--sw/source/core/text/txttab.cxx8
-rw-r--r--sw/source/core/text/wrong.cxx8
-rw-r--r--sw/source/core/tox/ToxTextGenerator.cxx2
-rw-r--r--sw/source/core/tox/tox.cxx8
-rw-r--r--sw/source/core/tox/txmsrt.cxx4
-rw-r--r--sw/source/core/txtnode/atrftn.cxx4
-rw-r--r--sw/source/core/txtnode/fntcache.cxx32
-rw-r--r--sw/source/core/txtnode/fntcap.cxx2
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx12
-rw-r--r--sw/source/core/txtnode/swfont.cxx2
-rw-r--r--sw/source/core/txtnode/thints.cxx6
-rw-r--r--sw/source/core/txtnode/txtatr2.cxx2
-rw-r--r--sw/source/core/undo/undobj1.cxx2
-rw-r--r--sw/source/core/undo/undraw.cxx2
-rw-r--r--sw/source/core/undo/unnum.cxx2
-rw-r--r--sw/source/core/undo/untbl.cxx2
-rw-r--r--sw/source/core/unocore/unocoll.cxx2
-rw-r--r--sw/source/core/unocore/unoframe.cxx8
-rw-r--r--sw/source/core/unocore/unoidx.cxx8
-rw-r--r--sw/source/core/unocore/unoobj.cxx4
-rw-r--r--sw/source/core/unocore/unosett.cxx6
-rw-r--r--sw/source/core/unocore/unotbl.cxx12
-rw-r--r--sw/source/core/view/pagepreviewlayout.cxx4
85 files changed, 279 insertions, 279 deletions
diff --git a/sw/source/core/SwNumberTree/SwNodeNum.cxx b/sw/source/core/SwNumberTree/SwNodeNum.cxx
index 6bf92d3eb73a..af92fe21ddc8 100644
--- a/sw/source/core/SwNumberTree/SwNodeNum.cxx
+++ b/sw/source/core/SwNumberTree/SwNodeNum.cxx
@@ -273,7 +273,7 @@ SwNumberTree::tSwNumTreeNumber SwNodeNum::GetStartValue() const
if (nLevel >= 0 && nLevel < MAXLEVEL)
{
- const SwNumFormat * pFormat = pRule->GetNumFormat( static_cast<sal_uInt16>(nLevel));
+ const SwNumFormat * pFormat = pRule->GetNumFormat( o3tl::narrowing<sal_uInt16>(nLevel));
if (pFormat)
aResult = pFormat->GetStart();
diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx
index 9310a290a184..b1da888d5af7 100644
--- a/sw/source/core/access/accportions.cxx
+++ b/sw/source/core/access/accportions.cxx
@@ -615,7 +615,7 @@ TextFrameIndex SwAccessiblePortionData::FillSpecialPos(
// (if necessary)
size_t nRefLine = FindBreak( m_aLineBreaks, nRefPos );
size_t nMyLine = FindBreak( m_aLineBreaks, nPos );
- sal_uInt16 nLineOffset = static_cast<sal_uInt16>( nMyLine - nRefLine );
+ sal_uInt16 nLineOffset = o3tl::narrowing<sal_uInt16>( nMyLine - nRefLine );
if( nLineOffset != 0 )
nRefPos = m_aLineBreaks[ nMyLine ];
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index a7d4d2474613..6f5516d69c1f 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -523,7 +523,7 @@ bool SwCursorShell::UpDown( bool bUp, sal_uInt16 nCnt )
if( !bTableMode )
eUpdateMode = static_cast<CursorFlag>(eUpdateMode
| SwCursorShell::UPDOWN | SwCursorShell::CHKRANGE);
- UpdateCursor( static_cast<sal_uInt16>(eUpdateMode) );
+ UpdateCursor( o3tl::narrowing<sal_uInt16>(eUpdateMode) );
}
}
return bRet;
@@ -2435,7 +2435,7 @@ void SwCursorShell::ShellGetFocus()
m_bHasFocus = true;
if( !m_bBasicHideCursor && VisArea().Width() )
{
- UpdateCursor( static_cast<sal_uInt16>( SwCursorShell::CHKRANGE ) );
+ UpdateCursor( o3tl::narrowing<sal_uInt16>( SwCursorShell::CHKRANGE ) );
ShowCursors( m_bSVCursorVis );
}
}
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index 847a019cf1b9..5ae9e5c78e76 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -1891,7 +1891,7 @@ bool SwCursor::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode,
{
pTableBox = & pTableBox->FindEndOfRowSpan(
pOldTabSttNode->GetTable(),
- static_cast<sal_uInt16>(pTableBox->getRowSpan() + m_nRowSpanOffset));
+ o3tl::narrowing<sal_uInt16>(pTableBox->getRowSpan() + m_nRowSpanOffset));
SwNodeIndex& rPtIdx = GetPoint()->nNode;
SwNodeIndex aNewIdx( *pTableBox->GetSttNd() );
rPtIdx = aNewIdx;
@@ -2212,7 +2212,7 @@ bool SwCursor::GoPrevNextCell( bool bNext, sal_uInt16 nCnt )
if ( pTableBox && pTableBox->getRowSpan() > 1 )
{
pTableBox = & pTableBox->FindEndOfRowSpan( pTableNd->GetTable(),
- static_cast<sal_uInt16>(pTableBox->getRowSpan() + m_nRowSpanOffset));
+ o3tl::narrowing<sal_uInt16>(pTableBox->getRowSpan() + m_nRowSpanOffset));
SwNodeIndex aNewIdx( *pTableBox->GetSttNd() );
rPtIdx = aNewIdx;
pTableBoxStartNode = rPtIdx.GetNode().FindTableBoxStartNode();
diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx
index 5f26c9f23788..8bffbe3505fb 100644
--- a/sw/source/core/crsr/trvltbl.cxx
+++ b/sw/source/core/crsr/trvltbl.cxx
@@ -61,7 +61,7 @@ bool SwCursorShell::GoNextCell( bool bAppendLine )
pTableNd = IsCursorInTable();
assert (pTableNd);
pTableBox = & pTableBox->FindEndOfRowSpan( pTableNd->GetTable(),
- static_cast<sal_uInt16>(pTableBox->getRowSpan() + pCursor->GetCursorRowSpanOffset() ) );
+ o3tl::narrowing<sal_uInt16>(pTableBox->getRowSpan() + pCursor->GetCursorRowSpanOffset() ) );
pTableBoxStartNode = pTableBox->GetSttNd();
}
}
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 88fd7872a41b..254d0fc00085 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -1348,7 +1348,7 @@ namespace //local functions originally from docfmt.cxx
if (nLevel >= MAXLEVEL)
nLevel = MAXLEVEL - 1;
- SwNumFormat aNumFormat = pNumRule->Get(static_cast<sal_uInt16>(nLevel));
+ SwNumFormat aNumFormat = pNumRule->Get(o3tl::narrowing<sal_uInt16>(nLevel));
SwCharFormat * pCharFormat =
rDoc.FindCharFormatByName(aNumFormat.GetCharFormatName());
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index b187e709e9b0..aa52a22be144 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -929,7 +929,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl(
// Hash table for all string replacements is filled on-the-fly.
// Try to fabricate an uneven number.
const SwFieldTypes::size_type nHashSize {(( mpFieldTypes->size() / 7 ) + 1 ) * 7};
- const sal_uInt16 nStrFormatCnt = static_cast<sal_uInt16>(nHashSize);
+ const sal_uInt16 nStrFormatCnt = o3tl::narrowing<sal_uInt16>(nHashSize);
OSL_ENSURE( nStrFormatCnt == nHashSize, "Downcasting to sal_uInt16 lost information!" );
SwHashTable<HashStr> aHashStrTable(nStrFormatCnt);
diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx
index d4a92a09a69c..1266e3ea719f 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -135,7 +135,7 @@ SwFrameFormat *DocumentLayoutManager::MakeLayoutFormat( RndStdIds eRequest, cons
m_rDoc.GetNodes().MakeTextSection
( aTmpIdx,
bHeader ? SwHeaderStartNode : SwFooterStartNode,
- m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(static_cast<sal_uInt16>( bHeader
+ m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(o3tl::narrowing<sal_uInt16>( bHeader
? ( eRequest == RndStdIds::HEADERL
? RES_POOLCOLL_HEADERL
: eRequest == RndStdIds::HEADERR
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx
index 5df33094c073..ff0657aaff48 100644
--- a/sw/source/core/doc/DocumentStylePoolManager.cxx
+++ b/sw/source/core/doc/DocumentStylePoolManager.cxx
@@ -1753,8 +1753,8 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool
}
SvxULSpaceItem aUL( RES_UL_SPACE );
{
- aUL.SetUpper( static_cast<sal_uInt16>(aLR.GetLeft()) );
- aUL.SetLower( static_cast<sal_uInt16>(aLR.GetLeft()) );
+ aUL.SetUpper( o3tl::narrowing<sal_uInt16>(aLR.GetLeft()) );
+ aUL.SetLower( o3tl::narrowing<sal_uInt16>(aLR.GetLeft()) );
}
SwAttrSet aSet( m_rDoc.GetAttrPool(), aPgFrameFormatSetRange );
@@ -1824,8 +1824,8 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool
{
lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
aLR.SetRight(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip));
- aUL.SetUpper( static_cast<sal_uInt16>(aLR.GetRight()) );
- aUL.SetLower( static_cast<sal_uInt16>(aLR.GetRight()) );
+ aUL.SetUpper( o3tl::narrowing<sal_uInt16>(aLR.GetRight()) );
+ aUL.SetLower( o3tl::narrowing<sal_uInt16>(aLR.GetRight()) );
aSet.Put( aLR );
aSet.Put( aUL );
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 9b3b3bb70991..8fb7040348e2 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -503,7 +503,7 @@ sal_uInt16 PostItField_::GetPageNo(
sal_uInt16 nPgNo = pFrame->GetPhyPageNum();
if( rRangeEnum.hasValue( nPgNo, &rPossiblePages ))
{
- rLineNo = static_cast<sal_uInt16>(pFrame->GetLineCount( nPos ) +
+ rLineNo = o3tl::narrowing<sal_uInt16>(pFrame->GetLineCount( nPos ) +
pFrame->GetAllLines() - pFrame->GetThisLines());
rVirtPgNo = pFrame->GetVirtPageNum();
return nPgNo;
@@ -1271,7 +1271,7 @@ void SwDoc::Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImp
{
SwTextFormatColl* pMyColl = pNd->GetTextColl();
- const sal_uInt16 nHeadLine = static_cast<sal_uInt16>(
+ const sal_uInt16 nHeadLine = o3tl::narrowing<sal_uInt16>(
!pMyColl->IsAssignedToListLevelOfOutlineStyle()
? RES_POOLCOLL_HEADLINE2
: RES_POOLCOLL_HEADLINE1 );
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index b417ab0add9a..6b63e7a300c3 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -107,8 +107,8 @@ static void lcl_DefaultPageFormat( sal_uInt16 nPoolFormatId,
SvxLRSpaceItem aLR( RES_LR_SPACE );
SvxULSpaceItem aUL( RES_UL_SPACE );
- aUL.SetUpper( static_cast<sal_uInt16>(nMinTop) );
- aUL.SetLower( static_cast<sal_uInt16>(nMinBottom) );
+ aUL.SetUpper( o3tl::narrowing<sal_uInt16>(nMinTop) );
+ aUL.SetLower( o3tl::narrowing<sal_uInt16>(nMinBottom) );
aLR.SetRight( nMinRight );
aLR.SetLeft( nMinLeft );
diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx
index c450f4213dc3..edc3a145c11c 100644
--- a/sw/source/core/doc/docdraw.cxx
+++ b/sw/source/core/doc/docdraw.cxx
@@ -199,7 +199,7 @@ SwDrawContact* SwDoc::GroupSelection( SdrView& rDrawView )
std::unique_ptr<SwUndoDrawGroup> pUndo;
if (GetIDocumentUndoRedo().DoesUndo())
- pUndo.reset(new SwUndoDrawGroup( static_cast<sal_uInt16>(rMrkList.GetMarkCount()), *this));
+ pUndo.reset(new SwUndoDrawGroup( o3tl::narrowing<sal_uInt16>(rMrkList.GetMarkCount()), *this));
// #i53320#
bool bGroupMembersNotPositioned( false );
@@ -335,7 +335,7 @@ void SwDoc::UnGroupSelection( SdrView& rDrawView )
pFormatsAndObjs[i].emplace_back( pFormat, pSubObj );
if( bUndo )
- pUndo->AddObj( static_cast<sal_uInt16>(i2), pFormat );
+ pUndo->AddObj( o3tl::narrowing<sal_uInt16>(i2), pFormat );
}
}
}
@@ -419,7 +419,7 @@ bool SwDoc::DeleteSelection( SwDrawView& rDrawView )
{
std::unique_ptr<SwUndoDrawDelete> pUndo;
if (GetIDocumentUndoRedo().DoesUndo())
- pUndo.reset(new SwUndoDrawDelete( static_cast<sal_uInt16>(rMrkList.GetMarkCount()), *this ));
+ pUndo.reset(new SwUndoDrawDelete( o3tl::narrowing<sal_uInt16>(rMrkList.GetMarkCount()), *this ));
// Destroy ContactObjects, save formats.
for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 8b1b4b2a9bc0..bd0fb7dff196 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1675,7 +1675,7 @@ void SwDoc::MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus,
const int nListLevel = pTNd->GetActualListLevel();
if ( nListLevel >= 0 )
{
- const SwNumFormat& rFormat = pRule->Get(static_cast<sal_uInt16>(nListLevel));
+ const SwNumFormat& rFormat = pRule->Get(o3tl::narrowing<sal_uInt16>(nListLevel));
if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
{
aLS.SetTextLeft( rFormat.GetIndentAt() );
diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx
index 286f0b4ad47f..7f2b30ddc615 100644
--- a/sw/source/core/doc/docftn.cxx
+++ b/sw/source/core/doc/docftn.cxx
@@ -106,7 +106,7 @@ SwPageDesc* SwEndNoteInfo::GetPageDesc(SwDoc& rDoc) const
{
if(!m_pPageDesc)
{
- m_pPageDesc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( static_cast<sal_uInt16>(
+ m_pPageDesc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( o3tl::narrowing<sal_uInt16>(
m_bEndNote ? RES_POOLPAGE_ENDNOTE : RES_POOLPAGE_FOOTNOTE ) );
m_aDepends.StartListening(m_pPageDesc);
}
@@ -139,7 +139,7 @@ void SwEndNoteInfo::SetFootnoteTextColl(SwTextFormatColl& rFormat)
SwCharFormat* SwEndNoteInfo::GetCharFormat(SwDoc& rDoc) const
{
- auto pCharFormatFromDoc = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast<sal_uInt16>(
+ auto pCharFormatFromDoc = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( o3tl::narrowing<sal_uInt16>(
m_bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE ) );
if (m_pCharFormat != pCharFormatFromDoc)
{
@@ -172,7 +172,7 @@ namespace
void SwEndNoteInfo::SetCharFormat(SwCharFormat* pFormat)
{
lcl_ResetPoolIdForDocAndSync(
- static_cast<sal_uInt16>(m_bEndNote
+ o3tl::narrowing<sal_uInt16>(m_bEndNote
? RES_POOLCHR_ENDNOTE
: RES_POOLCHR_FOOTNOTE),
pFormat,
@@ -181,7 +181,7 @@ void SwEndNoteInfo::SetCharFormat(SwCharFormat* pFormat)
SwCharFormat* SwEndNoteInfo::GetAnchorCharFormat(SwDoc& rDoc) const
{
- auto pAnchorFormatFromDoc = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast<sal_uInt16>(
+ auto pAnchorFormatFromDoc = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( o3tl::narrowing<sal_uInt16>(
m_bEndNote ? RES_POOLCHR_ENDNOTE_ANCHOR : RES_POOLCHR_FOOTNOTE_ANCHOR ) );
if(m_pAnchorFormat != pAnchorFormatFromDoc)
{
@@ -195,7 +195,7 @@ SwCharFormat* SwEndNoteInfo::GetAnchorCharFormat(SwDoc& rDoc) const
void SwEndNoteInfo::SetAnchorCharFormat(SwCharFormat* pFormat)
{
lcl_ResetPoolIdForDocAndSync(
- static_cast<sal_uInt16>(m_bEndNote
+ o3tl::narrowing<sal_uInt16>(m_bEndNote
? RES_POOLCHR_ENDNOTE_ANCHOR
: RES_POOLCHR_FOOTNOTE_ANCHOR),
pFormat,
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 2da94ef4699c..43b4408ec080 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -311,7 +311,7 @@ SwFlyFrameFormat* SwDoc::MakeFlySection( RndStdIds eAnchorType,
if( !pFrameFormat )
pFrameFormat = getIDocumentStylePoolAccess().GetFrameFormatFromPool( RES_POOLFRM_FRAME );
- sal_uInt16 nCollId = static_cast<sal_uInt16>(
+ sal_uInt16 nCollId = o3tl::narrowing<sal_uInt16>(
GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE) ? RES_POOLCOLL_TEXT : RES_POOLCOLL_FRAME );
/* If there is no adjust item in the paragraph style for the content node of the new fly section
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 5e287e84f19d..2420532c5bee 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -246,7 +246,7 @@ bool SwDoc::OutlineUpDown(const SwPaM& rPam, short nOffset,
n++;
SwTextFormatColl *aTmpColl =
- getIDocumentStylePoolAccess().GetTextCollFromPool(static_cast<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + n));
+ getIDocumentStylePoolAccess().GetTextCollFromPool(o3tl::narrowing<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + n));
if( aTmpColl->IsAssignedToListLevelOfOutlineStyle() &&
aTmpColl->GetAssignedOutlineStyleLevel() == n )
@@ -275,7 +275,7 @@ bool SwDoc::OutlineUpDown(const SwPaM& rPam, short nOffset,
n--;
SwTextFormatColl *aTmpColl =
- getIDocumentStylePoolAccess().GetTextCollFromPool(static_cast<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + n));
+ getIDocumentStylePoolAccess().GetTextCollFromPool(o3tl::narrowing<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + n));
if( aTmpColl->IsAssignedToListLevelOfOutlineStyle() &&
aTmpColl->GetAssignedOutlineStyleLevel() == n )
@@ -2556,7 +2556,7 @@ OUString SwDoc::GetUniqueNumRuleName( const OUString* pChkStr, bool bAutoNum ) c
if( sNm.startsWith( aName ) )
{
// Determine Number and set the Flag
- nNum = static_cast<sal_uInt16>(sNm.copy( nNmLen ).toInt32());
+ nNum = o3tl::narrowing<sal_uInt16>(sNm.copy( nNmLen ).toInt32());
if( nNum-- && nNum < mpNumRuleTable->size() )
pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
}
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index 25a664d17bf8..3c2f8c1f019c 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -555,7 +555,7 @@ bool SwDoc::SortTable(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt)
std::multiset<SwSortBoxElement> aSortList;
// When sorting, do not include the first row if the HeaderLine is repeated
- for( sal_uInt16 i = static_cast<sal_uInt16>(nStart); i < nCount; ++i)
+ for( sal_uInt16 i = o3tl::narrowing<sal_uInt16>(nStart); i < nCount; ++i)
{
aSortList.insert(SwSortBoxElement(i));
}
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index d8e7d30e80e1..2c3ed6902f13 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -1520,7 +1520,7 @@ void SwTOXBaseSection::UpdateContent( SwTOXElement eMyType,
std::unique_ptr<SwTOXPara> pNew( MakeSwTOXSortTabBase<SwTOXPara>(
pLayout, *pCNd, eMyType,
( USHRT_MAX != nSetLevel )
- ? static_cast<sal_uInt16>(nSetLevel)
+ ? o3tl::narrowing<sal_uInt16>(nSetLevel)
: FORM_ALPHA_DELIMITER ) );
InsertSorted( std::move(pNew) );
}
@@ -1570,7 +1570,7 @@ void SwTOXBaseSection::UpdateTable(const SwTextNode* pOwnChapterNode,
if( pOutlNd->GetTextColl()->IsAssignedToListLevelOfOutlineStyle())
{
const int nTmp = pOutlNd->GetTextColl()->GetAttrOutlineLevel();
- pNew->SetLevel(static_cast<sal_uInt16>(nTmp));
+ pNew->SetLevel(o3tl::narrowing<sal_uInt16>(nTmp));
}
}
}
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx
index 6a91ac469294..a0dcda5cff88 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -588,7 +588,7 @@ void SwTextFormatColl::SetAttrOutlineLevel( int nLevel)
{
OSL_ENSURE( 0 <= nLevel && nLevel <= MAXLEVEL ,"SwTextFormatColl: Level Out Of Range" );
SetFormatAttr( SfxUInt16Item( RES_PARATR_OUTLINELEVEL,
- static_cast<sal_uInt16>(nLevel) ) );
+ o3tl::narrowing<sal_uInt16>(nLevel) ) );
}
int SwTextFormatColl::GetAttrOutlineLevel() const
diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx
index 67dc9b9c56b5..41a10d34c10b 100644
--- a/sw/source/core/doc/htmltbl.cxx
+++ b/sw/source/core/doc/htmltbl.cxx
@@ -314,7 +314,7 @@ sal_uInt16 SwHTMLTableLayout::GetBrowseWidthByVisArea( const SwDoc& rDoc )
SwViewShell const *pVSh = rDoc.getIDocumentLayoutAccess().GetCurrentViewShell();
if( pVSh )
{
- return static_cast<sal_uInt16>(pVSh->GetBrowseWidth());
+ return o3tl::narrowing<sal_uInt16>(pVSh->GetBrowseWidth());
}
return 0;
@@ -328,7 +328,7 @@ sal_uInt16 SwHTMLTableLayout::GetBrowseWidth( const SwDoc& rDoc )
{
const SwFrame *pPageFrame = pRootFrame->GetLower();
if( pPageFrame )
- return static_cast<sal_uInt16>(pPageFrame->getFramePrintArea().Width());
+ return o3tl::narrowing<sal_uInt16>(pPageFrame->getFramePrintArea().Width());
}
// #i91658#
@@ -367,7 +367,7 @@ sal_uInt16 SwHTMLTableLayout::GetBrowseWidthByTabFrame(
rTabFrame.CalcFlyOffsets( nUpperDummy, nLeftOffset, nRightOffset );
nWidth -= (nLeftOffset + nRightOffset);
- return static_cast<sal_uInt16>(std::min(nWidth, SwTwips(SAL_MAX_UINT16)));
+ return o3tl::narrowing<sal_uInt16>(std::min(nWidth, SwTwips(SAL_MAX_UINT16)));
}
sal_uInt16 SwHTMLTableLayout::GetBrowseWidthByTable( const SwDoc& rDoc ) const
@@ -985,7 +985,7 @@ void SwHTMLTableLayout::AutoLayoutPass1()
{
// the next column gets the rest
sal_uInt16 nColWidth =
- static_cast<sal_uInt16>((pColumn->GetMax() * nRelLeft) / nFixMax);
+ o3tl::narrowing<sal_uInt16>((pColumn->GetMax() * nRelLeft) / nFixMax);
pColumn->SetWidthOption( nColWidth );
}
}
@@ -1112,8 +1112,8 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
{
sal_uLong nAbsLeftFillL = nAbsLeftFill, nAbsRightFillL = nAbsRightFill;
- m_nRelLeftFill = static_cast<sal_uInt16>((nAbsLeftFillL * nRelAvail) / nAbsAvail);
- m_nRelRightFill = static_cast<sal_uInt16>((nAbsRightFillL * nRelAvail) / nAbsAvail);
+ m_nRelLeftFill = o3tl::narrowing<sal_uInt16>((nAbsLeftFillL * nRelAvail) / nAbsAvail);
+ m_nRelRightFill = o3tl::narrowing<sal_uInt16>((nAbsRightFillL * nRelAvail) / nAbsAvail);
nAbsAvail -= (nAbsLeftFill + nAbsRightFill);
if( nRelAvail )
@@ -1145,7 +1145,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
// Let's play such games now anyway. We had a graphic in a 1% wide
// table and it didn't fit in of course.
- nAbsTabWidth = static_cast<sal_uInt16>( (static_cast<sal_uLong>(nAbsAvail) * m_nWidthOption) / 100 );
+ nAbsTabWidth = o3tl::narrowing<sal_uInt16>( (static_cast<sal_uLong>(nAbsAvail) * m_nWidthOption) / 100 );
if( IsTopTable() &&
( /*MayBeInFlyFrame() ||*/ static_cast<sal_uLong>(nAbsTabWidth) > m_nMin ) )
{
@@ -1214,17 +1214,17 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
if( nColMin <= USHRT_MAX )
{
pColumn->SetAbsColWidth(
- static_cast<sal_uInt16>((nColMin * nAbsTabWidth) / m_nMin) );
+ o3tl::narrowing<sal_uInt16>((nColMin * nAbsTabWidth) / m_nMin) );
pColumn->SetRelColWidth(
- static_cast<sal_uInt16>((nColMin * m_nRelTabWidth) / m_nMin) );
+ o3tl::narrowing<sal_uInt16>((nColMin * m_nRelTabWidth) / m_nMin) );
}
else
{
double nColMinD = nColMin;
pColumn->SetAbsColWidth(
- static_cast<sal_uInt16>((nColMinD * nAbsTabWidth) / m_nMin) );
+ o3tl::narrowing<sal_uInt16>((nColMinD * nAbsTabWidth) / m_nMin) );
pColumn->SetRelColWidth(
- static_cast<sal_uInt16>((nColMinD * m_nRelTabWidth) / m_nMin) );
+ o3tl::narrowing<sal_uInt16>((nColMinD * m_nRelTabWidth) / m_nMin) );
}
nAbs = nAbs + pColumn->GetAbsColWidth();
@@ -1251,17 +1251,17 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
if( nColMin <= USHRT_MAX )
{
pColumn->SetAbsColWidth(
- static_cast<sal_uInt16>((((nColMin-nRealColMin) * nDistAbs) / nDistMin) + nRealColMin) );
+ o3tl::narrowing<sal_uInt16>((((nColMin-nRealColMin) * nDistAbs) / nDistMin) + nRealColMin) );
pColumn->SetRelColWidth(
- static_cast<sal_uInt16>((((nColMin-nRealColMin) * nDistRel) / nDistMin) + nRealColMin) );
+ o3tl::narrowing<sal_uInt16>((((nColMin-nRealColMin) * nDistRel) / nDistMin) + nRealColMin) );
}
else
{
double nColMinD = nColMin;
pColumn->SetAbsColWidth(
- static_cast<sal_uInt16>((((nColMinD-nRealColMin) * nDistAbs) / nDistMin) + nRealColMin) );
+ o3tl::narrowing<sal_uInt16>((((nColMinD-nRealColMin) * nDistAbs) / nDistMin) + nRealColMin) );
pColumn->SetRelColWidth(
- static_cast<sal_uInt16>((((nColMinD-nRealColMin) * nDistRel) / nDistMin) + nRealColMin) );
+ o3tl::narrowing<sal_uInt16>((((nColMinD-nRealColMin) * nDistRel) / nDistMin) + nRealColMin) );
}
nAbs = nAbs + pColumn->GetAbsColWidth();
@@ -1284,7 +1284,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
// No fixed width, use the maximum.
if( !nAbsTabWidth )
- nAbsTabWidth = static_cast<sal_uInt16>(m_nMax);
+ nAbsTabWidth = o3tl::narrowing<sal_uInt16>(m_nMax);
// A top table may also get wider then the available space.
if( nAbsTabWidth > nAbsAvail )
@@ -1301,7 +1301,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
{
if (nAbsAvail == 0)
throw o3tl::divide_by_zero();
- m_nRelTabWidth = static_cast<sal_uInt16>((nAbsTabWidthL * nRelAvail) / nAbsAvail);
+ m_nRelTabWidth = o3tl::narrowing<sal_uInt16>((nAbsTabWidthL * nRelAvail) / nAbsAvail);
}
else
m_nRelTabWidth = nAbsTabWidth;
@@ -1339,7 +1339,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
// The column keeps its width.
nFixedCols++;
sal_uLong nColMax = pColumn->GetMax();
- pColumn->SetAbsColWidth( static_cast<sal_uInt16>(nColMax) );
+ pColumn->SetAbsColWidth( o3tl::narrowing<sal_uInt16>(nColMax) );
sal_uLong nRelColWidth =
(nColMax * m_nRelTabWidth) / nAbsTabWidth;
@@ -1349,10 +1349,10 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
nRelColWidth++;
else if( nChkWidth > nColMax )
nRelColWidth--;
- pColumn->SetRelColWidth( static_cast<sal_uInt16>(nRelColWidth) );
+ pColumn->SetRelColWidth( o3tl::narrowing<sal_uInt16>(nRelColWidth) );
- nAbs = nAbs + static_cast<sal_uInt16>(nColMax);
- nRel = nRel + static_cast<sal_uInt16>(nRelColWidth);
+ nAbs = nAbs + o3tl::narrowing<sal_uInt16>(nColMax);
+ nRel = nRel + o3tl::narrowing<sal_uInt16>(nRelColWidth);
}
}
@@ -1381,9 +1381,9 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
{
sal_uLong nColMax = pColumn->GetMax();
pColumn->SetAbsColWidth(
- static_cast<sal_uInt16>((nColMax * nDistAbsTabWidth) / nDistMax) );
+ o3tl::narrowing<sal_uInt16>((nColMax * nDistAbsTabWidth) / nDistMax) );
pColumn->SetRelColWidth(
- static_cast<sal_uInt16>((nColMax * nDistRelTabWidth) / nDistMax) );
+ o3tl::narrowing<sal_uInt16>((nColMax * nDistRelTabWidth) / nDistMax) );
}
nAbs = nAbs + pColumn->GetAbsColWidth();
nRel = nRel + pColumn->GetRelColWidth();
@@ -1400,9 +1400,9 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
{
sal_uLong nColMax = GetColumn( i )->GetMax();
GetColumn( i )->SetAbsColWidth(
- static_cast<sal_uInt16>((nColMax * nAbsTabWidth) / m_nMax) );
+ o3tl::narrowing<sal_uInt16>((nColMax * nAbsTabWidth) / m_nMax) );
GetColumn( i )->SetRelColWidth(
- static_cast<sal_uInt16>((nColMax * m_nRelTabWidth) / m_nMax) );
+ o3tl::narrowing<sal_uInt16>((nColMax * m_nRelTabWidth) / m_nMax) );
}
}
}
@@ -1413,7 +1413,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
if( !nAbsTabWidth )
nAbsTabWidth = nAbsAvail;
if( nAbsTabWidth < m_nMin )
- nAbsTabWidth = static_cast<sal_uInt16>(m_nMin);
+ nAbsTabWidth = o3tl::narrowing<sal_uInt16>(m_nMin);
if( nAbsTabWidth > nAbsAvail )
{
@@ -1427,7 +1427,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
{
if (nAbsAvail == 0)
throw o3tl::divide_by_zero();
- m_nRelTabWidth = static_cast<sal_uInt16>((nAbsTabWidthL * nRelAvail) / nAbsAvail);
+ m_nRelTabWidth = o3tl::narrowing<sal_uInt16>((nAbsTabWidthL * nRelAvail) / nAbsAvail);
}
else
m_nRelTabWidth = nAbsTabWidth;
@@ -1442,10 +1442,10 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
? (nAbsColWidth * m_nRelTabWidth) / nAbsTabWidth
: nAbsColWidth;
- GetColumn( i )->SetAbsColWidth( static_cast<sal_uInt16>(nAbsColWidth) );
- GetColumn( i )->SetRelColWidth( static_cast<sal_uInt16>(nRelColWidth) );
- nAbs = nAbs + static_cast<sal_uInt16>(nAbsColWidth);
- nRel = nRel + static_cast<sal_uInt16>(nRelColWidth);
+ GetColumn( i )->SetAbsColWidth( o3tl::narrowing<sal_uInt16>(nAbsColWidth) );
+ GetColumn( i )->SetRelColWidth( o3tl::narrowing<sal_uInt16>(nRelColWidth) );
+ nAbs = nAbs + o3tl::narrowing<sal_uInt16>(nAbsColWidth);
+ nRel = nRel + o3tl::narrowing<sal_uInt16>(nRelColWidth);
}
GetColumn( m_nCols-1 )->SetAbsColWidth( nAbsTabWidth - nAbs );
GetColumn( m_nCols-1 )->SetRelColWidth( m_nRelTabWidth - nRel );
@@ -1462,8 +1462,8 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
// Calculate the width of additional cells we use for
// aligning inner tables.
- sal_uInt16 nAbsDist = static_cast<sal_uInt16>(nAbsAvail-nAbsTabWidth);
- sal_uInt16 nRelDist = static_cast<sal_uInt16>(nRelAvail-m_nRelTabWidth);
+ sal_uInt16 nAbsDist = o3tl::narrowing<sal_uInt16>(nAbsAvail-nAbsTabWidth);
+ sal_uInt16 nRelDist = o3tl::narrowing<sal_uInt16>(nRelAvail-m_nRelTabWidth);
sal_uInt16 nParentInhAbsLeftSpace = 0, nParentInhAbsRightSpace = 0;
// Calculate the size and position of the additional cells.
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 76fe94181f0f..e4f2e071afba 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -131,7 +131,7 @@ static void lcl_PaintReplacement( const SwRect &rRect, const OUString &rText,
else if ( !rURL.GetURL().isEmpty() )
bVisited = rSh.GetDoc()->IsVisitedURL( rURL.GetURL() );
- SwFormat *pFormat = rSh.GetDoc()->getIDocumentStylePoolAccess().GetFormatFromPool( static_cast<sal_uInt16>
+ SwFormat *pFormat = rSh.GetDoc()->getIDocumentStylePoolAccess().GetFormatFromPool( o3tl::narrowing<sal_uInt16>
(bVisited ? RES_POOLCHR_INET_VISIT : RES_POOLCHR_INET_NORMAL ) );
aCol = pFormat->GetColor().GetValue();
eUnderline = pFormat->GetUnderline().GetLineStyle();
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index ecd1b119b95e..eb84b1b63a68 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -659,7 +659,7 @@ OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVecto
if (nLevel < MAXLEVEL)
{
- const SwNumFormat& rMyNFormat = Get( static_cast<sal_uInt16>(nLevel) );
+ const SwNumFormat& rMyNFormat = Get( o3tl::narrowing<sal_uInt16>(nLevel) );
{
css::lang::Locale aLocale( LanguageTag::convertToLocale(nLang));
@@ -789,7 +789,7 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
if (nListLevel >= MAXLEVEL)
nListLevel = MAXLEVEL - 1;
- SwNumFormat aFormat( Get( static_cast<sal_uInt16>(nListLevel) ) );
+ SwNumFormat aFormat( Get( o3tl::narrowing<sal_uInt16>(nListLevel) ) );
bMakeNumStringForPhantom = aFormat.IsEnumeration() &&
SVX_NUM_NUMBER_NONE != aFormat.GetNumberingType();
@@ -834,7 +834,7 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
if ( bInclSuperiorNumLabels && pWorkingNodeNum->GetLevelInListTree() > 0 )
{
- sal_uInt8 n = Get( static_cast<sal_uInt16>(pWorkingNodeNum->GetLevelInListTree()) ).GetIncludeUpperLevels();
+ sal_uInt8 n = Get( o3tl::narrowing<sal_uInt16>(pWorkingNodeNum->GetLevelInListTree()) ).GetIncludeUpperLevels();
pWorkingNodeNum = dynamic_cast<SwNodeNum*>(pWorkingNodeNum->GetParent());
// skip parents, whose list label is already contained in the actual list label.
while ( pWorkingNodeNum && n > 1 )
diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx
index 6bc270801873..337c7bcef619 100644
--- a/sw/source/core/doc/tblcpy.cxx
+++ b/sw/source/core/doc/tblcpy.cxx
@@ -225,7 +225,7 @@ namespace
}
if( bNoSelection && mnStartCol < USHRT_MAX )
{
- sal_uInt16 nIdx = std::min(mnStartCol, static_cast<sal_uInt16>(maLines[0].size()));
+ sal_uInt16 nIdx = std::min(mnStartCol, o3tl::narrowing<sal_uInt16>(maLines[0].size()));
mnStartCol = std::accumulate(maLines[0].begin(), maLines[0].begin() + nIdx, sal_uInt16(0),
[](sal_uInt16 sum, const BoxSpanInfo& rInfo) { return sum + rInfo.mnColSpan; });
}
@@ -298,7 +298,7 @@ namespace
aInfo.mbSelected = true;
if( mnStartCol == USHRT_MAX )
{
- mnStartCol = static_cast<sal_uInt16>(maLines[nLine].size());
+ mnStartCol = o3tl::narrowing<sal_uInt16>(maLines[nLine].size());
if( pSelBoxes->size() < 2 )
{
pSelBoxes = nullptr;
@@ -352,7 +352,7 @@ namespace
const sal_uInt16 nLineCount = rLines.size();
if( nLineCount < mnAddLine )
mnAddLine = nLineCount;
- sal_uInt16 nLine = static_cast<sal_uInt16>(maLines.size());
+ sal_uInt16 nLine = o3tl::narrowing<sal_uInt16>(maLines.size());
maLines.resize( nLine + mnAddLine );
while( mnAddLine )
{
@@ -591,7 +591,7 @@ static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox,
: RES_POOLCOLL_TABLE_HDLN == nPoolId ) )
{
SwTextFormatColl* pColl = pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(
- static_cast<sal_uInt16>(
+ o3tl::narrowing<sal_uInt16>(
RES_POOLCOLL_TABLE == nPoolId
? RES_POOLCOLL_TABLE_HDLN
: RES_POOLCOLL_TABLE ) );
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 818782a5ff1b..18eab679a289 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -672,7 +672,7 @@ void DeleteBox_( SwTable& rTable, SwTableBox* pBox, SwUndo* pUndo,
// JP 02.04.97: 1st part for Bug 36271
// First the left/right edges
- if( nDelPos + 1 < static_cast<sal_uInt16>(rTableBoxes.size()) )
+ if( nDelPos + 1 < o3tl::narrowing<sal_uInt16>(rTableBoxes.size()) )
{
SwTableBox* pNxtBox = rTableBoxes[ nDelPos + 1 ];
const SvxBoxItem& rNxtBoxItem = pNxtBox->GetFrameFormat()->GetBox();
@@ -698,7 +698,7 @@ void DeleteBox_( SwTable& rTable, SwTableBox* pBox, SwUndo* pUndo,
SwTableBox* pPrvBox = rTableBoxes[ nDelPos - 1 ];
const SvxBoxItem& rPrvBoxItem = pPrvBox->GetFrameFormat()->GetBox();
- SwTableBox* pNxtBox = nDelPos + 1 < static_cast<sal_uInt16>(rTableBoxes.size())
+ SwTableBox* pNxtBox = nDelPos + 1 < o3tl::narrowing<sal_uInt16>(rTableBoxes.size())
? rTableBoxes[ nDelPos + 1 ] : nullptr;
if( pPrvBox->GetSttNd() && !rPrvBoxItem.GetRight() &&
@@ -854,7 +854,7 @@ lcl_FndNxtPrvDelBox( const SwTableLines& rTableLns,
--*pCurPos;
pAllDelBoxes->erase( pAllDelBoxes->begin() + nFndPos );
}
- } while( bNxt ? ( nLinePos + 1 < static_cast<sal_uInt16>(rTableLns.size()) ) : nLinePos != 0 );
+ } while( bNxt ? ( nLinePos + 1 < o3tl::narrowing<sal_uInt16>(rTableLns.size()) ) : nLinePos != 0 );
return pFndBox;
}
@@ -897,7 +897,7 @@ lcl_SaveUpperLowerBorder( SwTable& rTable, const SwTableBox& rBox,
pPrvBox = ::lcl_FndNxtPrvDelBox( *pTableLns, nBoxStt, nBoxWidth,
nLnPos, false, pAllDelBoxes, pCurPos );
- if( nLnPos + 1 < static_cast<sal_uInt16>(pTableLns->size()) ) // Successor?
+ if( nLnPos + 1 < o3tl::narrowing<sal_uInt16>(pTableLns->size()) ) // Successor?
pNxtBox = ::lcl_FndNxtPrvDelBox( *pTableLns, nBoxStt, nBoxWidth,
nLnPos, true, pAllDelBoxes, pCurPos );
@@ -1371,7 +1371,7 @@ static void lcl_Merge_MoveBox(FndBox_ & rFndBox, InsULPara *const pULPara)
{
// if there are Boxes behind it, move them
nPos = pFndTableBox->GetUpper()->GetBoxPos( pFndTableBox );
- if( nPos +1 < static_cast<sal_uInt16>(pBoxes->size()) )
+ if( nPos +1 < o3tl::narrowing<sal_uInt16>(pBoxes->size()) )
{
nInsPos = pULPara->pInsLine->GetTabBoxes().size();
lcl_CpyBoxes( nPos+1, pBoxes->size(),
@@ -1444,7 +1444,7 @@ static void lcl_Merge_MoveLine(FndLine_& rFndLine, InsULPara *const pULPara)
}
else
// If there are Lines after it, move them
- if( (nPos = pLines->GetPos( pFndLn )) + 1 < static_cast<sal_uInt16>(pLines->size()) )
+ if( (nPos = pLines->GetPos( pFndLn )) + 1 < o3tl::narrowing<sal_uInt16>(pLines->size()) )
{
nInsPos = pULPara->pInsBox->GetTabLines().size();
lcl_CpyLines( nPos+1, pLines->size(), *pLines,
@@ -1479,7 +1479,7 @@ static void lcl_Merge_MoveLine(FndLine_& rFndLine, InsULPara *const pULPara)
}
else
// If there are Lines after it, move them
- if( (nPos = pLines->GetPos( pFndLn )) + 1 < static_cast<sal_uInt16>(pLines->size()) )
+ if( (nPos = pLines->GetPos( pFndLn )) + 1 < o3tl::narrowing<sal_uInt16>(pLines->size()) )
lcl_CpyLines( nPos+1, pLines->size(), *pLines,
pLMBox );
lcl_CalcWidth( pLMBox ); // calculate the Box's width
@@ -1678,7 +1678,7 @@ static sal_uInt16 lcl_GetBoxOffset( const FndBox_& rBox )
{
if (pBox==pCmp)
break;
- nRet = nRet + static_cast<sal_uInt16>(pCmp->GetFrameFormat()->GetFrameSize().GetWidth());
+ nRet = nRet + o3tl::narrowing<sal_uInt16>(pCmp->GetFrameFormat()->GetFrameSize().GetWidth());
}
pBox = pBox->GetUpper()->GetUpper();
} while( pBox );
@@ -1690,7 +1690,7 @@ static sal_uInt16 lcl_GetLineWidth( const FndLine_& rLine )
sal_uInt16 nRet = 0;
for( auto n = rLine.GetBoxes().size(); n; )
{
- nRet = nRet + static_cast<sal_uInt16>(rLine.GetBoxes()[--n]->GetBox()
+ nRet = nRet + o3tl::narrowing<sal_uInt16>(rLine.GetBoxes()[--n]->GetBox()
->GetFrameFormat()->GetFrameSize().GetWidth());
}
return nRet;
@@ -2202,7 +2202,7 @@ SwTableBox* SwTableLine::FindNextBox( const SwTable& rTable,
{
nFndPos = GetBoxPos( pSrchBox );
if( USHRT_MAX != nFndPos &&
- nFndPos + 1 != static_cast<sal_uInt16>(GetTabBoxes().size()) )
+ nFndPos + 1 != o3tl::narrowing<sal_uInt16>(GetTabBoxes().size()) )
{
pBox = GetTabBoxes()[ nFndPos + 1 ];
while( !pBox->GetTabLines().empty() )
@@ -2216,7 +2216,7 @@ SwTableBox* SwTableLine::FindNextBox( const SwTable& rTable,
nFndPos = GetUpper()->GetTabLines().GetPos( pLine );
OSL_ENSURE( USHRT_MAX != nFndPos, "Line is not in the Table" );
// Is there another Line?
- if( nFndPos+1 >= static_cast<sal_uInt16>(GetUpper()->GetTabLines().size()) )
+ if( nFndPos+1 >= o3tl::narrowing<sal_uInt16>(GetUpper()->GetTabLines().size()) )
return GetUpper()->GetUpper()->FindNextBox( rTable, GetUpper(), bOvrTableLns );
pLine = GetUpper()->GetTabLines()[nFndPos+1];
}
@@ -2224,7 +2224,7 @@ SwTableBox* SwTableLine::FindNextBox( const SwTable& rTable,
{
// Search for the next Line in the Table
nFndPos = rTable.GetTabLines().GetPos( pLine );
- if( nFndPos + 1 >= static_cast<sal_uInt16>(rTable.GetTabLines().size()) )
+ if( nFndPos + 1 >= o3tl::narrowing<sal_uInt16>(rTable.GetTabLines().size()) )
return nullptr; // there are no more Boxes
pLine = rTable.GetTabLines()[ nFndPos+1 ];
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 9ad8d8c33d57..cba67e1bf74d 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -575,7 +575,7 @@ void SwTextBoxHelper::getProperty(SwFrameFormat const* pShape, sal_uInt16 nWID,
break;
default:
SAL_WARN("sw.core", "SwTextBoxHelper::getProperty: unhandled member-id: "
- << static_cast<sal_uInt16>(nMemberID));
+ << o3tl::narrowing<sal_uInt16>(nMemberID));
break;
}
}
@@ -633,7 +633,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
break;
default:
SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: "
- << static_cast<sal_uInt16>(nMemberID)
+ << o3tl::narrowing<sal_uInt16>(nMemberID)
<< " (which-id: " << nWID << ")");
break;
}
@@ -650,7 +650,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
break;
default:
SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: "
- << static_cast<sal_uInt16>(nMemberID)
+ << o3tl::narrowing<sal_uInt16>(nMemberID)
<< " (which-id: " << nWID << ")");
break;
}
@@ -674,7 +674,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
break;
default:
SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: "
- << static_cast<sal_uInt16>(nMemberID)
+ << o3tl::narrowing<sal_uInt16>(nMemberID)
<< " (which-id: " << nWID << ")");
break;
}
@@ -714,7 +714,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
break;
default:
SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: "
- << static_cast<sal_uInt16>(nMemberID)
+ << o3tl::narrowing<sal_uInt16>(nMemberID)
<< " (which-id: " << nWID << ")");
break;
}
@@ -743,7 +743,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
break;
default:
SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: "
- << static_cast<sal_uInt16>(nMemberID)
+ << o3tl::narrowing<sal_uInt16>(nMemberID)
<< " (which-id: " << nWID << ")");
break;
}
@@ -768,7 +768,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
break;
default:
SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: "
- << static_cast<sal_uInt16>(nMemberID)
+ << o3tl::narrowing<sal_uInt16>(nMemberID)
<< " (which-id: " << nWID << ")");
break;
}
@@ -787,15 +787,15 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
break;
default:
SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: "
- << static_cast<sal_uInt16>(nMemberID)
+ << o3tl::narrowing<sal_uInt16>(nMemberID)
<< " (which-id: " << nWID << ")");
break;
}
break;
default:
SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled which-id: "
- << nWID << " (member-id: " << static_cast<sal_uInt16>(nMemberID)
- << ")");
+ << nWID << " (member-id: "
+ << o3tl::narrowing<sal_uInt16>(nMemberID) << ")");
break;
}
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 389923d6f415..d11f09ecf69a 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -362,7 +362,7 @@ const SwTable* SwDoc::InsertTable( const SwInsertTableOptions& rInsTableOpts,
if( GetIDocumentUndoRedo().DoesUndo() )
{
GetIDocumentUndoRedo().AppendUndo(
- std::make_unique<SwUndoInsTable>( rPos, nCols, nRows, static_cast<sal_uInt16>(eAdjust),
+ std::make_unique<SwUndoInsTable>( rPos, nCols, nRows, o3tl::narrowing<sal_uInt16>(eAdjust),
rInsTableOpts, pTAFormat, pColArr,
aTableName));
}
@@ -651,7 +651,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTableOpts,
{
GetIDocumentUndoRedo().StartUndo( SwUndoId::TEXTTOTABLE, nullptr );
pUndo = new SwUndoTextToTable( aOriginal, rInsTableOpts, cCh,
- static_cast<sal_uInt16>(eAdjust), pTAFormat );
+ o3tl::narrowing<sal_uInt16>(eAdjust), pTAFormat );
GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) );
// Do not add splitting the TextNode to the Undo history
@@ -1041,13 +1041,13 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
{
// sw_redlinehide: no idea if this makes any sense...
TextFrameIndex const nPos(aFInfo.GetFrame()->MapModelToView(pTextNd, nChPos));
- aPosArr.push_back( static_cast<sal_uInt16>(
+ aPosArr.push_back( o3tl::narrowing<sal_uInt16>(
aFInfo.GetCharPos(nPos+TextFrameIndex(1), false)) );
}
}
aPosArr.push_back(
- static_cast<sal_uInt16>(aFInfo.GetFrame()->IsVertical() ?
+ o3tl::narrowing<sal_uInt16>(aFInfo.GetFrame()->IsVertical() ?
aFInfo.GetFrame()->getFramePrintArea().Bottom() :
aFInfo.GetFrame()->getFramePrintArea().Right()) );
@@ -2921,7 +2921,7 @@ void SwCollectTableLineBoxes::AddBox( const SwTableBox& rBox )
m_aPositionArr.push_back(m_nWidth);
SwTableBox* p = const_cast<SwTableBox*>(&rBox);
m_Boxes.push_back(p);
- m_nWidth = m_nWidth + static_cast<sal_uInt16>(rBox.GetFrameFormat()->GetFrameSize().GetWidth());
+ m_nWidth = m_nWidth + o3tl::narrowing<sal_uInt16>(rBox.GetFrameFormat()->GetFrameSize().GetWidth());
}
const SwTableBox* SwCollectTableLineBoxes::GetBoxOfPos( const SwTableBox& rBox )
@@ -2944,7 +2944,7 @@ const SwTableBox* SwCollectTableLineBoxes::GetBoxOfPos( const SwTableBox& rBox )
if( n >= m_aPositionArr.size() )
--n;
- m_nWidth = m_nWidth + static_cast<sal_uInt16>(rBox.GetFrameFormat()->GetFrameSize().GetWidth());
+ m_nWidth = m_nWidth + o3tl::narrowing<sal_uInt16>(rBox.GetFrameFormat()->GetFrameSize().GetWidth());
pRet = m_Boxes[ n ];
}
return pRet;
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index 9a4f80ee995a..3df6b3272cee 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -1303,7 +1303,7 @@ sal_uInt16 SwDoc::GetBoxAlign( const SwCursor& rCursor )
const SwFormatVertOrient &rOri =
aBoxes[i]->GetFrameFormat()->GetVertOrient();
if( USHRT_MAX == nAlign )
- nAlign = static_cast<sal_uInt16>(rOri.GetVertOrient());
+ nAlign = o3tl::narrowing<sal_uInt16>(rOri.GetVertOrient());
else if( rOri.GetVertOrient() != nAlign )
{
nAlign = USHRT_MAX;
@@ -1339,7 +1339,7 @@ static sal_uInt16 lcl_CalcCellFit( const SwLayoutFrame *pCell )
// To compensate for the accuracy of calculation later on in SwTable::SetTabCols
// we keep adding up a little.
nRet += COLFUZZY;
- return static_cast<sal_uInt16>(std::max( SwTwips(MINLAY), nRet ));
+ return o3tl::narrowing<sal_uInt16>(std::max( SwTwips(MINLAY), nRet ));
}
/* The Line is within the Selection but not outlined by the TabCols.
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index c65afd1e5749..9d300621da0e 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -947,7 +947,7 @@ void SwSectionFormat::UpdateParent()
if(bIsHidden == pSection->IsHiddenFlag())
{
- SwMsgPoolItem aMsgItem(static_cast<sal_uInt16>(bIsHidden
+ SwMsgPoolItem aMsgItem(o3tl::narrowing<sal_uInt16>(bIsHidden
? RES_SECTION_HIDDEN
: RES_SECTION_NOT_HIDDEN));
CallSwClientNotify(sw::LegacyModifyHint(&aMsgItem, &aMsgItem));
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 637f507734a4..b9b4d8480a7a 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -639,7 +639,7 @@ bool SwAutoFormat::DoTable()
case '+':
case '|':
- aPosArr.push_back( static_cast<sal_uInt16>(aInfo.GetCharPos(n)) );
+ aPosArr.push_back( o3tl::narrowing<sal_uInt16>(aInfo.GetCharPos(n)) );
break;
default:
@@ -665,7 +665,7 @@ bool SwAutoFormat::DoTable()
{
eHori = text::HoriOrientation::NONE;
// then - as last - we need to add the current frame width into the array
- aPosArr.push_back( static_cast<sal_uInt16>(m_pCurTextFrame->getFrameArea().Width()) );
+ aPosArr.push_back( o3tl::narrowing<sal_uInt16>(m_pCurTextFrame->getFrameArea().Width()) );
}
else
eHori = text::HoriOrientation::LEFT;
@@ -908,7 +908,7 @@ CHECK_ROMAN_1:
if( nMod5 == ((3 * nVal) + n10 ) ||
nMod5 == ((4 * nVal) + n10 ) ||
nLast == n10 )
- nStart = static_cast<sal_uInt16>(nStart + (n10 * 8));
+ nStart = o3tl::narrowing<sal_uInt16>(nStart + (n10 * 8));
else if( nMod5 == 0 ||
nMod5 == (1 * nVal) ||
nMod5 == (2 * nVal) )
@@ -927,7 +927,7 @@ CHECK_ROMAN_5:
int nMod = nStart % nVal;
int n10 = nVal / 5;
if( n10 == nMod )
- nStart = static_cast<sal_uInt16>(nStart + (3 * n10));
+ nStart = o3tl::narrowing<sal_uInt16>(nStart + (3 * n10));
else if( 0 == nMod )
nStart = nStart + nVal;
else
@@ -1590,7 +1590,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
else
{
bChgBullet = true;
- SetColl( static_cast<sal_uInt16>(RES_POOLCOLL_BULLET_LEVEL1 + ( std::min( nLvl, cnNumBullColls ) * 4 )) );
+ SetColl( o3tl::narrowing<sal_uInt16>(RES_POOLCOLL_BULLET_LEVEL1 + ( std::min( nLvl, cnNumBullColls ) * 4 )) );
}
}
else
@@ -1627,7 +1627,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
{
SwNumFormat aFormat( aRule.Get( nLvl ) );
aFormat.SetPrefix( aPrefix.getToken( 0, u'\x0001', nPrefixIdx ));
- aFormat.SetStart( static_cast<sal_uInt16>(aPrefix.getToken( 0, u'\x0001', nPrefixIdx ).toInt32()));
+ aFormat.SetStart( o3tl::narrowing<sal_uInt16>(aPrefix.getToken( 0, u'\x0001', nPrefixIdx ).toInt32()));
aFormat.SetSuffix( aPostfix.getToken( 0, u'\x0001' ));
aFormat.SetIncludeUpperLevels( 0 );
@@ -1652,7 +1652,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
if( !n )
aFormat.SetPrefix( aPrefix.getToken( 0, u'\x0001', nPrefixIdx )); // token 0, read only on first loop
- aFormat.SetStart( static_cast<sal_uInt16>(aPrefix.getToken( 0, u'\x0001', nPrefixIdx ).toInt32() ));
+ aFormat.SetStart( o3tl::narrowing<sal_uInt16>(aPrefix.getToken( 0, u'\x0001', nPrefixIdx ).toInt32() ));
aFormat.SetSuffix( aPostfix.getToken( 0, u'\x0001', nPostfixIdx ));
aFormat.SetIncludeUpperLevels( MAXLEVEL );
if( n < aNumTypes.getLength() )
@@ -1687,7 +1687,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
}
}
else if( !m_aFlags.bAFormatByInput )
- SetColl( static_cast<sal_uInt16>(RES_POOLCOLL_NUM_LEVEL1 + ( std::min( nLvl, cnNumBullColls ) * 4 ) ));
+ SetColl( o3tl::narrowing<sal_uInt16>(RES_POOLCOLL_NUM_LEVEL1 + ( std::min( nLvl, cnNumBullColls ) * 4 ) ));
else
bChgEnum = false;
}
@@ -1811,7 +1811,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
|| (!nTextPos && IsBlanksInString(*m_pCurTextFrame))
|| IsSentenceAtEnd(*m_pCurTextFrame);
- SetColl( static_cast<sal_uInt16>( nTextPos
+ SetColl( o3tl::narrowing<sal_uInt16>( nTextPos
? RES_POOLCOLL_CONFRONTATION
: RES_POOLCOLL_TEXT_NEGIDENT ) );
@@ -1889,7 +1889,7 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
m_pDoc->GetDocumentRedlineManager().SetAutoFormatRedlineComment( &sText );
}
- SetColl( static_cast<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + nLvl ), true );
+ SetColl( o3tl::narrowing<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + nLvl ), true );
if( m_aFlags.bAFormatByInput )
{
SwTextFormatColl& rNxtColl = m_pCurTextFrame->GetTextNodeForParaProps()->GetTextColl()->GetNextTextFormatColl();
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index dc8769f2a61a..4df2c7db6e47 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -93,7 +93,7 @@ bool SwEditShell::GetPaMAttr( SwPaM* pPaM, SfxItemSet& rSet,
nListLevel = MAXLEVEL - 1;
const OUString & aCharFormatName =
- pNumRule->Get(static_cast<sal_uInt16>(nListLevel)).GetCharFormatName();
+ pNumRule->Get(o3tl::narrowing<sal_uInt16>(nListLevel)).GetCharFormatName();
SwCharFormat * pCharFormat =
GetDoc()->FindCharFormatByName(aCharFormatName);
@@ -504,7 +504,7 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const
bool bRet = true;
const SvxTabStopItem& rTabItem = GetDoc()->GetDefault( RES_PARATR_TABSTOP );
- sal_uInt16 nDefDist = static_cast<sal_uInt16>(rTabItem.Count() ? rTabItem[0].GetTabPos() : 1134);
+ sal_uInt16 nDefDist = o3tl::narrowing<sal_uInt16>(rTabItem.Count() ? rTabItem[0].GetTabPos() : 1134);
if( !nDefDist )
return false;
@@ -533,7 +533,7 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const
SwFrame* pFrame = pCNd->getLayoutFrame( GetLayout() );
if ( pFrame )
{
- const sal_uInt16 nFrameWidth = static_cast<sal_uInt16>( pFrame->IsVertical() ?
+ const sal_uInt16 nFrameWidth = o3tl::narrowing<sal_uInt16>( pFrame->IsVertical() ?
pFrame->getFrameArea().Height() :
pFrame->getFrameArea().Width() );
bRet = nFrameWidth > ( nNext + MM50 );
@@ -614,7 +614,7 @@ static bool lcl_IsNoEndTextAttrAtPos(SwRootFrame const& rLayout,
if (nListLevel >= MAXLEVEL)
nListLevel = MAXLEVEL - 1;
- const SwNumFormat &rNumFormat = pNumRule->Get( static_cast<sal_uInt16>(nListLevel) );
+ const SwNumFormat &rNumFormat = pNumRule->Get( o3tl::narrowing<sal_uInt16>(nListLevel) );
if( SVX_NUM_BITMAP != rNumFormat.GetNumberingType() )
{
if ( SVX_NUM_CHAR_SPECIAL == rNumFormat.GetNumberingType() )
diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx
index 837f37b94e20..b6bb9055f23d 100644
--- a/sw/source/core/edit/edfld.cxx
+++ b/sw/source/core/edit/edfld.cxx
@@ -46,7 +46,7 @@ size_t SwEditShell::GetFieldTypeCount(SwFieldIds nResId ) const
if(nResId == SwFieldIds::Unknown)
{
- return static_cast<sal_uInt16>(pFieldTypes->size());
+ return o3tl::narrowing<sal_uInt16>(pFieldTypes->size());
}
// all types with the same ResId
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 9be63fb05251..eea6cd397b86 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -812,7 +812,7 @@ void SwEditShell::SetNumberingRestart()
nListLevel = MAXLEVEL - 1;
bIsNodeNum = pTextNd->GetNum()->GetNumber() ==
- pNumRule->Get( static_cast<sal_uInt16>(nListLevel) ).GetStart();
+ pNumRule->Get( o3tl::narrowing<sal_uInt16>(nListLevel) ).GetStart();
}
if (bIsNodeNum)
{
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index af7ec8178e41..cd4458c276dd 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -900,7 +900,7 @@ sal_uInt16 SwEditShell::GetNodeNumStart( SwPaM* pPaM ) const
// return USHRT_MAX, if no list restart value is found.
if ( pTextNd && pTextNd->HasAttrListRestartValue() )
{
- return static_cast<sal_uInt16>(pTextNd->GetAttrListRestartValue());
+ return o3tl::narrowing<sal_uInt16>(pTextNd->GetAttrListRestartValue());
}
return USHRT_MAX;
}
diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index b93c30d8f8f4..cb849d8f6230 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -665,7 +665,7 @@ void SwDBNumSetField::Evaluate(const SwDoc& rDoc)
if( m_bCondValid && pMgr && pMgr->IsInMerge() &&
pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand, true))
{ // condition OK -> adjust current Set
- pMgr->ToRecordId(std::max(static_cast<sal_uInt16>(m_aPar2.toInt32()), sal_uInt16(1))-1);
+ pMgr->ToRecordId(std::max(o3tl::narrowing<sal_uInt16>(m_aPar2.toInt32()), sal_uInt16(1))-1);
}
}
diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index ceea88941ddb..6ee39cf4d8a0 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -472,7 +472,7 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
break;
case FIELD_PROP_USHORT1:
rAny >>= nTmp;
- m_nSubType = static_cast<sal_uInt16>(nTmp);
+ m_nSubType = o3tl::narrowing<sal_uInt16>(nTmp);
break;
case FIELD_PROP_PAR1:
{
@@ -484,7 +484,7 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
case FIELD_PROP_SUBTYPE:
nTmp = lcl_APIToSubType(rAny);
if( nTmp >=0 )
- SetSubType( static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp));
+ SetSubType( o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp));
break;
case FIELD_PROP_BOOL2:
if(*o3tl::doAccess<bool>(rAny))
@@ -697,7 +697,7 @@ void SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
{
sal_Int32 nSet = lcl_APIToSubType(rAny);
if(nSet >=0)
- SetType(static_cast<sal_uInt16>(nSet));
+ SetType(o3tl::narrowing<sal_uInt16>(nSet));
}
break;
case FIELD_PROP_PAR2:
@@ -1109,7 +1109,7 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
case FIELD_PROP_SUBTYPE:
nTmp32 = lcl_APIToSubType(rAny);
if(nTmp32 >= 0)
- SetSubType(static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp32));
+ SetSubType(o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp32));
break;
case FIELD_PROP_PAR3:
rAny >>= maPText;
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index bf7f1d2d618e..bd82d5deee2c 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -564,10 +564,10 @@ void SwFEShell::GetTabCols_(SwTabCols &rToFill, const SwFrame *pBox) const
}
if ( !bDel &&
- m_pColumnCache->pLastCols->GetLeftMin () == static_cast<sal_uInt16>(nLeftMin) &&
- m_pColumnCache->pLastCols->GetLeft () == static_cast<sal_uInt16>(aRectFnSet.GetLeft(pTab->getFramePrintArea())) &&
- m_pColumnCache->pLastCols->GetRight () == static_cast<sal_uInt16>(aRectFnSet.GetRight(pTab->getFramePrintArea()))&&
- m_pColumnCache->pLastCols->GetRightMax() == static_cast<sal_uInt16>(nRightMax) - m_pColumnCache->pLastCols->GetLeftMin() )
+ m_pColumnCache->pLastCols->GetLeftMin () == o3tl::narrowing<sal_uInt16>(nLeftMin) &&
+ m_pColumnCache->pLastCols->GetLeft () == o3tl::narrowing<sal_uInt16>(aRectFnSet.GetLeft(pTab->getFramePrintArea())) &&
+ m_pColumnCache->pLastCols->GetRight () == o3tl::narrowing<sal_uInt16>(aRectFnSet.GetRight(pTab->getFramePrintArea()))&&
+ m_pColumnCache->pLastCols->GetRightMax() == o3tl::narrowing<sal_uInt16>(nRightMax) - m_pColumnCache->pLastCols->GetLeftMin() )
{
if (m_pColumnCache->pLastCellFrame != pBox)
{
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index 067786a6c2a2..e5aae5f1a945 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -2364,7 +2364,7 @@ void FndBox_::MakeFrames( SwTable &rTable )
i >= 0 && !pSibling; --i )
{
SwTableLine *pLine = m_pLineBehind ? m_pLineBehind :
- rTable.GetTabLines()[static_cast<sal_uInt16>(i)];
+ rTable.GetTabLines()[o3tl::narrowing<sal_uInt16>(i)];
SwIterator<SwRowFrame,SwFormat> aIter( *pLine->GetFrameFormat() );
pSibling = aIter.First();
while ( pSibling && (
diff --git a/sw/source/core/graphic/grfatr.cxx b/sw/source/core/graphic/grfatr.cxx
index 703a06d69d3d..b267a55c19d2 100644
--- a/sw/source/core/graphic/grfatr.cxx
+++ b/sw/source/core/graphic/grfatr.cxx
@@ -332,7 +332,7 @@ bool SwDrawModeGrf::PutValue( const uno::Any& rVal,
sal_Int32 eVal = SWUnoHelper::GetEnumAsInt32( rVal );
if(eVal >= 0 && eVal <= sal_uInt16(GraphicDrawMode::Watermark))
{
- SetEnumValue(static_cast<sal_uInt16>(eVal));
+ SetEnumValue(o3tl::narrowing<sal_uInt16>(eVal));
return true;
}
return false;
diff --git a/sw/source/core/inc/tblrwcl.hxx b/sw/source/core/inc/tblrwcl.hxx
index cc1f0a514769..addc40804f74 100644
--- a/sw/source/core/inc/tblrwcl.hxx
+++ b/sw/source/core/inc/tblrwcl.hxx
@@ -126,7 +126,7 @@ struct SwGCLineBorder
SwGCLineBorder( const SwTableBox& rBox )
: pLines( &rBox.GetTabLines() ), pShareFormats(nullptr), nLinePos( 0 ) {}
- bool IsLastLine() const { return nLinePos + 1 >= static_cast<sal_uInt16>(pLines->size()); }
+ bool IsLastLine() const { return nLinePos + 1 >= o3tl::narrowing<sal_uInt16>(pLines->size()); }
};
class SwGCBorder_BoxBrd
diff --git a/sw/source/core/inc/wrong.hxx b/sw/source/core/inc/wrong.hxx
index dcd8503ef6aa..3d32eae81e2f 100644
--- a/sw/source/core/inc/wrong.hxx
+++ b/sw/source/core/inc/wrong.hxx
@@ -320,7 +320,7 @@ public:
return nIdx < maList.size() ? maList[nIdx].mnPos : 0;
}
- sal_uInt16 Count() const { return static_cast<sal_uInt16>(maList.size()); }
+ sal_uInt16 Count() const { return o3tl::narrowing<sal_uInt16>(maList.size()); }
void Insert( const OUString& rType,
css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag,
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index fe29ecfe2faa..dd434fb6d90c 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -1098,7 +1098,7 @@ bool SwFormatCol::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
const text::TextColumn* pArray = aSetColumns.getConstArray();
m_aColumns.clear();
//max count is 64k here - this is something the array can't do
- sal_uInt16 nCount = std::min( static_cast<sal_uInt16>(aSetColumns.getLength()),
+ sal_uInt16 nCount = std::min( o3tl::narrowing<sal_uInt16>(aSetColumns.getLength()),
sal_uInt16(0x3fff) );
sal_uInt16 nWidthSum = 0;
// #101224# one column is no column
@@ -2269,7 +2269,7 @@ bool SwTextGridItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
sal_Int16 nTmp = 0;
bRet = (rVal >>= nTmp);
if( bRet && (nTmp >= 0) )
- SetLines( static_cast<sal_uInt16>(nTmp) );
+ SetLines( o3tl::narrowing<sal_uInt16>(nTmp) );
else
bRet = false;
}
@@ -2301,15 +2301,15 @@ bool SwTextGridItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEHEIGHT )
{
nTmp = std::max<sal_Int32>(nTmp, MIN_TEXTGRID_SIZE);
- SetBaseHeight( static_cast<sal_uInt16>(nTmp) );
+ SetBaseHeight( o3tl::narrowing<sal_uInt16>(nTmp) );
}
else if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEWIDTH )
{
nTmp = std::max<sal_Int32>(nTmp, MIN_TEXTGRID_SIZE);
- SetBaseWidth( static_cast<sal_uInt16>(nTmp) );
+ SetBaseWidth( o3tl::narrowing<sal_uInt16>(nTmp) );
}
else
- SetRubyHeight( static_cast<sal_uInt16>(nTmp) );
+ SetRubyHeight( o3tl::narrowing<sal_uInt16>(nTmp) );
}
else
bRet = false;
diff --git a/sw/source/core/layout/dbg_lay.cxx b/sw/source/core/layout/dbg_lay.cxx
index 4f1bc42ecc18..6391f97343d8 100644
--- a/sw/source/core/layout/dbg_lay.cxx
+++ b/sw/source/core/layout/dbg_lay.cxx
@@ -409,7 +409,7 @@ void SwImplProtocol::CheckLine( OString& rLine )
}
break;
case 5:
- m_nMaxLines = static_cast<sal_uInt16>(nVal);
+ m_nMaxLines = o3tl::narrowing<sal_uInt16>(nVal);
break;
case 6:
m_aVars.push_back(nVal);
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index ca8cc3c8ef9b..600125e48b9c 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -3412,10 +3412,10 @@ void SwLayoutFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBord
}
}
- const sal_uInt16 nLeft = static_cast<sal_uInt16>(pAttrs->CalcLeft(this));
+ const sal_uInt16 nLeft = o3tl::narrowing<sal_uInt16>(pAttrs->CalcLeft(this));
const sal_uInt16 nUpper = bHideWhitespace ? 0 : pAttrs->CalcTop();
- const sal_uInt16 nRight = static_cast<sal_uInt16>(pAttrs->CalcRight(this));
+ const sal_uInt16 nRight = o3tl::narrowing<sal_uInt16>(pAttrs->CalcRight(this));
const sal_uInt16 nLower = bHideWhitespace ? 0 : pAttrs->CalcBottom();
const bool bVert = IsVertical() && !IsPageFrame();
diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 85592b9a7458..a2506f59bd7c 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -1062,7 +1062,7 @@ SwTableBox& SwTableBox::FindEndOfRowSpan( const SwTable& rTable, sal_uInt16 nMax
return *this;
if( nMaxStep > --nAbsSpan )
- nMaxStep = static_cast<sal_uInt16>(nAbsSpan);
+ nMaxStep = o3tl::narrowing<sal_uInt16>(nAbsSpan);
const SwTableLine* pMyUpper = GetUpper();
sal_uInt16 nLine = rTable.GetTabLines().GetPos( pMyUpper );
nMaxStep = nLine + nMaxStep;
@@ -1388,7 +1388,7 @@ static sal_uInt16 lcl_LineIndex( const SwTable& rTable, const SwSelBoxes& rBoxes
nSpan = 0;
else if( nSpan )
{
- sal_uInt16 nEndOfRowSpan = static_cast<sal_uInt16>(nPos + nRowSpan - 1);
+ sal_uInt16 nEndOfRowSpan = o3tl::narrowing<sal_uInt16>(nPos + nRowSpan - 1);
if( nEndOfRowSpan > nSpan || nSpan == USHRT_MAX )
nSpan = nEndOfRowSpan;
}
@@ -2101,7 +2101,7 @@ void SwTable::CleanUpBottomRowSpan( sal_uInt16 nDelLines )
if( nRowSp > 1 )
{
lcl_ChangeRowSpan( *this, -static_cast<tools::Long>(nDelLines),
- static_cast<sal_uInt16>(nLastLine), false );
+ o3tl::narrowing<sal_uInt16>(nLastLine), false );
break;
}
}
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index fda4da0b85d9..64632d69e583 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -717,7 +717,7 @@ static void lcl_ProcessBoxSet( SwTableBox *pBox, Parm &rParm )
SwTableBoxes& rTableBoxes = pBox->GetUpper()->GetTabBoxes();
if( nPos && rTableBoxes[ nPos - 1 ]->getRowSpan() != 1 )
nLeftDiff = 0;
- if( nPos + 1 < static_cast<sal_uInt16>(rTableBoxes.size()) &&
+ if( nPos + 1 < o3tl::narrowing<sal_uInt16>(rTableBoxes.size()) &&
rTableBoxes[ nPos + 1 ]->getRowSpan() != 1 )
nRightDiff = 0;
}
@@ -1177,7 +1177,7 @@ void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols &rNew,
nOldPos = lcl_MulDiv64<tools::Long>(nOldPos, rParm.nOldWish, nOldWidth);
if( nOldPos != nNewPos && nNewPos > 0 && nOldPos > 0 )
{
- ColChange aChg( static_cast<sal_uInt16>(nOldPos), static_cast<sal_uInt16>(nNewPos) );
+ ColChange aChg( o3tl::narrowing<sal_uInt16>(nOldPos), o3tl::narrowing<sal_uInt16>(nNewPos) );
aOldNew.push_back( aChg );
}
}
@@ -1218,7 +1218,7 @@ void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols &rNew,
}
aRowSpanPos.clear();
}
- if( nCurr+1 < static_cast<sal_uInt16>(rLines.size()) )
+ if( nCurr+1 < o3tl::narrowing<sal_uInt16>(rLines.size()) )
{
ChangeList aCopy;
sal_uInt16 nPos = 0;
@@ -1236,7 +1236,7 @@ void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols &rNew,
lcl_CalcNewWidths( aRowSpanPos, aCopy, rLines[++j],
rParm.nOldWish, nOldWidth, false );
lcl_AdjustWidthsInLine( rLines[j], aCopy, rParm, 0 );
- bGoOn = !aRowSpanPos.empty() && j+1 < static_cast<sal_uInt16>(rLines.size());
+ bGoOn = !aRowSpanPos.empty() && j+1 < o3tl::narrowing<sal_uInt16>(rLines.size());
}
}
::lcl_AdjustWidthsInLine( rLines[nCurr], aOldNew, rParm, COLFUZZY );
@@ -1305,7 +1305,7 @@ sal_uInt16 SwTable::GetBoxNum( OUString& rStr, bool bFirstPart,
nRet = 0;
if ( !bPerformValidCheck || lcl_IsValidRowName( rStr ) )
{
- nRet = static_cast<sal_uInt16>(rStr.toInt32());
+ nRet = o3tl::narrowing<sal_uInt16>(rStr.toInt32());
}
rStr.clear();
}
@@ -1315,7 +1315,7 @@ sal_uInt16 SwTable::GetBoxNum( OUString& rStr, bool bFirstPart,
const OUString aText( rStr.copy( 0, nPos ) );
if ( !bPerformValidCheck || lcl_IsValidRowName( aText ) )
{
- nRet = static_cast<sal_uInt16>(aText.toInt32());
+ nRet = o3tl::narrowing<sal_uInt16>(aText.toInt32());
}
rStr = rStr.copy( nPos+1 );
}
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 088f21c00b10..ba2f0ad9333f 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -424,7 +424,7 @@ void SwTaggedPDFHelper::BeginTag( vcl::PDFWriter::StructElement eType, const OUS
++m_nEndStructureElement;
#if OSL_DEBUG_LEVEL > 1
- aStructStack.push_back( static_cast<sal_uInt16>(eType) );
+ aStructStack.push_back( o3tl::narrowing<sal_uInt16>(eType) );
#endif
// Store the id of the current structure element if
@@ -1117,7 +1117,7 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
int nRealLevel = pTextNd->GetAttrOutlineLevel()-1;
nRealLevel = std::min(nRealLevel, 5);
- nPDFType = static_cast<sal_uInt16>(vcl::PDFWriter::H1 + nRealLevel);
+ nPDFType = o3tl::narrowing<sal_uInt16>(vcl::PDFWriter::H1 + nRealLevel);
switch(nRealLevel)
{
case 0 :
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index ce29c020fa4a..5f3045f0504b 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -1418,7 +1418,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
if( nDiff > 0 )
{
nDiff /= nDist;
- rFill.Fill().nParaCnt = static_cast<sal_uInt16>(nDiff + 1);
+ rFill.Fill().nParaCnt = o3tl::narrowing<sal_uInt16>(nDiff + 1);
rFill.nLineWidth = 0;
rFill.bInner = false;
rFill.bEmpty = true;
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 344ccede8962..c399ac758a24 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -426,7 +426,7 @@ void SwTextSizeInfo::GetTextSize( const SwScriptInfo* pSI, const TextFrameIndex
aDrawInf.SetSnapToGrid( SnapToGrid() );
aDrawInf.SetKanaComp( nComp );
SwPosSize aSize( m_pFnt->GetTextSize_( aDrawInf ) );
- nMaxSizeDiff = static_cast<sal_uInt16>(aDrawInf.GetKanaDiff());
+ nMaxSizeDiff = o3tl::narrowing<sal_uInt16>(aDrawInf.GetKanaDiff());
nMinSize = aSize.Width();
}
@@ -955,7 +955,7 @@ static void lcl_DrawSpecial( const SwTextPaintInfo& rTextPaintInfo, const SwLine
Point aTmpPos( nX, nY );
rNonConstTextPaintInfo.SetPos( aTmpPos );
sal_uInt16 nOldWidth = rPor.Width();
- const_cast<SwLinePortion&>(rPor).Width( static_cast<sal_uInt16>(aFontSize.Width()) );
+ const_cast<SwLinePortion&>(rPor).Width( o3tl::narrowing<sal_uInt16>(aFontSize.Width()) );
rTextPaintInfo.DrawText( aTmp, rPor );
const_cast<SwLinePortion&>(rPor).Width( nOldWidth );
rNonConstTextPaintInfo.SetFont( const_cast<SwFont*>(pOldFnt) );
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index a5944e49e357..8e7514cf9be3 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -488,7 +488,7 @@ SwTwips SwTextAdjuster::CalcKanaAdj( SwLineLayout* pCurrent )
else
nCompress = 10000 - nCompress;
- ( pCurrent->GetKanaComp() )[ nKanaIdx ] = static_cast<sal_uInt16>(nCompress);
+ ( pCurrent->GetKanaComp() )[ nKanaIdx ] = o3tl::narrowing<sal_uInt16>(nCompress);
nKanaDiffSum = 0;
}
@@ -524,7 +524,7 @@ SwTwips SwTextAdjuster::CalcKanaAdj( SwLineLayout* pCurrent )
}
else if( pPos->InGlueGrp() && pPos->InFixMargGrp() )
{
- pPos->Width( static_cast<sal_uInt16>(pPos->Width() - nDecompress) );
+ pPos->Width( o3tl::narrowing<sal_uInt16>(pPos->Width() - nDecompress) );
if ( pPos->InTabGrp() )
// set fix width to width
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index f6e298b2d3e0..9571324f8dbe 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -1432,7 +1432,7 @@ sal_uInt16 SwTextFrame::GetScalingOfSelectedText(
SwTextIter aLine(this, &aInf);
aLine.CharToLine( nStart );
pOut->SetMapMode( aOldMap );
- return static_cast<sal_uInt16>( nWidth ?
+ return o3tl::narrowing<sal_uInt16>( nWidth ?
( ( 100 * aLine.GetCurr()->Height() ) / nWidth ) : 0 );
}
// no frame or no paragraph, we take the height of the character
@@ -1442,7 +1442,7 @@ sal_uInt16 SwTextFrame::GetScalingOfSelectedText(
pOut->SetMapMode( aOldMap );
SwDrawTextInfo aDrawInf(pSh, *pOut, GetText(), sal_Int32(nStart), 1);
- return static_cast<sal_uInt16>( nWidth ? ((100 * aIter.GetFnt()->GetTextSize_( aDrawInf ).Height()) / nWidth ) : 0 );
+ return o3tl::narrowing<sal_uInt16>( nWidth ? ((100 * aIter.GetFnt()->GetTextSize_( aDrawInf ).Height()) / nWidth ) : 0 );
}
SwTwips SwTextNode::GetWidthOfLeadingTabs() const
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index b728a6ce98ff..f42a84237643 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -142,7 +142,7 @@ namespace {
nListLevel = MAXLEVEL - 1;
const SwNumFormat& rNumFormat =
- rTextNode.GetNumRule()->Get( static_cast<sal_uInt16>(nListLevel) );
+ rTextNode.GetNumRule()->Get( o3tl::narrowing<sal_uInt16>(nListLevel) );
if ( rNumFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
{
bRet = true;
@@ -1625,7 +1625,7 @@ TextFrameIndex SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con
nTmpY = pPor->Height() - nTmpY;
if( nTmpY < 0 )
nTmpY = 0;
- nX = static_cast<sal_uInt16>(nTmpY);
+ nX = o3tl::narrowing<sal_uInt16>(nTmpY);
}
if( static_cast<SwMultiPortion*>(pPor)->HasBrackets() )
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index c61e05ea0ab9..e672eabb3fce 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -235,7 +235,7 @@ SwLinePortion *SwTextFormatter::Underflow( SwTextFormatInfo &rInf )
// line width is adjusted, so that pPor does not fit to current
// line anymore
- rInf.Width( static_cast<sal_uInt16>(rInf.X() + (pPor->Width() ? pPor->Width() - 1 : 0)) );
+ rInf.Width( o3tl::narrowing<sal_uInt16>(rInf.X() + (pPor->Width() ? pPor->Width() - 1 : 0)) );
rInf.SetLen( pPor->GetLen() );
rInf.SetFull( false );
if( pFly )
@@ -424,7 +424,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
{
SwFontScript nNxtActual = rInf.GetFont()->GetActual();
SwFontScript nLstActual = nNxtActual;
- sal_uInt16 nLstHeight = static_cast<sal_uInt16>(rInf.GetFont()->GetHeight());
+ sal_uInt16 nLstHeight = o3tl::narrowing<sal_uInt16>(rInf.GetFont()->GetHeight());
bool bAllowBehind = false;
const CharClass& rCC = GetAppCharClass();
@@ -467,7 +467,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
if ( pTmpFnt )
{
nLstActual = pTmpFnt->GetActual();
- nLstHeight = static_cast<sal_uInt16>(pTmpFnt->GetHeight());
+ nLstHeight = o3tl::narrowing<sal_uInt16>(pTmpFnt->GetHeight());
}
}
}
@@ -528,7 +528,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
const SwTwips nRestWidth = rInf.Width() - rInf.X();
if ( nKernWidth <= nRestWidth )
- pGridKernPortion->Width( static_cast<sal_uInt16>(nKernWidth) );
+ pGridKernPortion->Width( o3tl::narrowing<sal_uInt16>(nKernWidth) );
}
if ( pGridKernPortion != pPor )
@@ -615,7 +615,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
(m_pScriptInfo->ScriptType(nTmp - TextFrameIndex(1)) == css::i18n::ScriptType::ASIAN ||
m_pScriptInfo->ScriptType(nTmp) == css::i18n::ScriptType::ASIAN) )
{
- const sal_uInt16 nDist = static_cast<sal_uInt16>(rInf.GetFont()->GetHeight()/5);
+ const sal_uInt16 nDist = o3tl::narrowing<sal_uInt16>(rInf.GetFont()->GetHeight()/5);
if( nDist )
{
@@ -670,7 +670,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
0;
const SwTwips nTmpWidth = i * nGridWidth;
const SwTwips nKernWidth = std::min(nTmpWidth - nSumWidth, nRestWidth);
- const sal_uInt16 nKernWidth_1 = static_cast<sal_uInt16>(nKernWidth / 2);
+ const sal_uInt16 nKernWidth_1 = o3tl::narrowing<sal_uInt16>(nKernWidth / 2);
OSL_ENSURE( nKernWidth <= nRestWidth,
"Not enough space left for adjusting non-asian text in grid mode" );
@@ -1431,7 +1431,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
PortionType::TabDecimal == pLastTabPortion->GetWhichPor() )
{
OSL_ENSURE( rInf.X() >= pLastTabPortion->GetFix(), "Decimal tab stop position cannot be calculated" );
- const sal_uInt16 nWidthOfPortionsUpToDecimalPosition = static_cast<sal_uInt16>(rInf.X() - pLastTabPortion->GetFix() );
+ const sal_uInt16 nWidthOfPortionsUpToDecimalPosition = o3tl::narrowing<sal_uInt16>(rInf.X() - pLastTabPortion->GetFix() );
static_cast<SwTabDecimalPortion*>(pLastTabPortion)->SetWidthOfPortionsUpToDecimalPosition( nWidthOfPortionsUpToDecimalPosition );
rInf.SetTabDecimal( 0 );
}
@@ -1806,7 +1806,7 @@ void SwTextFormatter::CalcRealHeight( bool bNewLine )
nTmp = 100;
nTmp *= nLineHeight;
- nLineHeight = static_cast<sal_uInt16>(nTmp / 100);
+ nLineHeight = o3tl::narrowing<sal_uInt16>(nTmp / 100);
}
m_pCurr->SetRealHeight( nLineHeight );
@@ -1841,7 +1841,7 @@ void SwTextFormatter::CalcRealHeight( bool bNewLine )
nTmp /= 100;
if( !nTmp )
++nTmp;
- nLineHeight = static_cast<sal_uInt16>(nTmp);
+ nLineHeight = o3tl::narrowing<sal_uInt16>(nTmp);
sal_uInt16 nAsc = ( 4 * nLineHeight ) / 5; // 80%
#if 0
// could do clipping here (like Word does)
@@ -1899,7 +1899,7 @@ void SwTextFormatter::CalcRealHeight( bool bNewLine )
nTmp += nLineHeight;
if (nTmp < 1)
nTmp = 1;
- nLineHeight = static_cast<sal_uInt16>(nTmp);
+ nLineHeight = o3tl::narrowing<sal_uInt16>(nTmp);
break;
}
case SvxInterLineSpaceRule::Fix:
@@ -2465,7 +2465,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
if( bForced )
{
m_pCurr->SetForcedLeftMargin();
- rInf.ForcedLeftMargin( static_cast<sal_uInt16>(aInter.Width()) );
+ rInf.ForcedLeftMargin( o3tl::narrowing<sal_uInt16>(aInter.Width()) );
}
if( bFullLine )
@@ -2555,7 +2555,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
const tools::Long nNewWidth = ( i - 1 ) * nGridWidth - nOfst;
if ( nNewWidth > 0 )
- rInf.Width( static_cast<sal_uInt16>(nNewWidth) );
+ rInf.Width( o3tl::narrowing<sal_uInt16>(nNewWidth) );
else
rInf.Width( 0 );
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index 26f3dcf56c98..4d589427850c 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -785,7 +785,7 @@ SwGrfNumPortion::SwGrfNumPortion(
m_nYPos = 0;
m_eOrient = text::VertOrientation::TOP;
}
- Width( static_cast<sal_uInt16>(rGrfSize.Width() + 2 * GRFNUM_SECURE) );
+ Width( o3tl::narrowing<sal_uInt16>(rGrfSize.Width() + 2 * GRFNUM_SECURE) );
m_nFixWidth = Width();
m_nGrfHeight = rGrfSize.Height() + 2 * GRFNUM_SECURE;
Height( sal_uInt16(m_nGrfHeight) );
@@ -834,7 +834,7 @@ bool SwGrfNumPortion::Format( SwTextFormatInfo &rInf )
if( bFull )
{
- Width( rInf.Width() - static_cast<sal_uInt16>(rInf.X()) );
+ Width( rInf.Width() - o3tl::narrowing<sal_uInt16>(rInf.X()) );
if( bFly )
{
SetLen(TextFrameIndex(0));
@@ -1170,7 +1170,7 @@ bool SwCombinedPortion::Format( SwTextFormatInfo &rInf )
{
rInf.GetOut()->SetFont( rInf.GetFont()->GetFnt( m_aScrType[i] ) );
m_aWidth[ m_aScrType[i] ] =
- static_cast<sal_uInt16>(2 * rInf.GetOut()->GetFontMetric().GetFontSize().Width() / 3);
+ o3tl::narrowing<sal_uInt16>(2 * rInf.GetOut()->GetFontMetric().GetFontSize().Width() / 3);
}
}
}
@@ -1217,7 +1217,7 @@ bool SwCombinedPortion::Format( SwTextFormatInfo &rInf )
SwDrawTextInfo aDrawInf(pSh, *rInf.GetOut(), m_aExpand, i, 1);
Size aSize = aTmpFont.GetTextSize_( aDrawInf );
const sal_uInt16 nAsc = aTmpFont.GetAscent( pSh, *rInf.GetOut() );
- m_aPos[ i ] = static_cast<sal_uInt16>(aSize.Width());
+ m_aPos[ i ] = o3tl::narrowing<sal_uInt16>(aSize.Width());
if( i == nTop ) // enter the second line
{
m_nLowPos = nMaxDescent;
@@ -1232,7 +1232,7 @@ bool SwCombinedPortion::Format( SwTextFormatInfo &rInf )
if( nAsc > nMaxAscent )
nMaxAscent = nAsc;
if( aSize.Height() - nAsc > nMaxDescent )
- nMaxDescent = static_cast<sal_uInt16>(aSize.Height() - nAsc);
+ nMaxDescent = o3tl::narrowing<sal_uInt16>(aSize.Height() - nAsc);
}
// for one or two characters we double the width of the portion
if( nCount < 3 )
@@ -1295,7 +1295,7 @@ bool SwCombinedPortion::Format( SwTextFormatInfo &rInf )
{
if( rInf.GetLineStart() == rInf.GetIdx() && (!rInf.GetLast()->InFieldGrp()
|| !static_cast<SwFieldPortion*>(rInf.GetLast())->IsFollow() ) )
- Width( static_cast<sal_uInt16>( rInf.Width() - rInf.X() ) );
+ Width( o3tl::narrowing<sal_uInt16>( rInf.Width() - rInf.X() ) );
else
{
Truncate();
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index 8fd2bc4c9d3c..71a7021aa6ff 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -57,7 +57,7 @@ bool SwFlyPortion::Format( SwTextFormatInfo &rInf )
rInf.GetLastTab()->FormatEOL( rInf );
rInf.GetLast()->FormatEOL( rInf );
- PrtWidth( static_cast<sal_uInt16>(GetFix() - rInf.X() + PrtWidth()) );
+ PrtWidth( o3tl::narrowing<sal_uInt16>(GetFix() - rInf.X() + PrtWidth()) );
if( !Width() )
{
OSL_ENSURE( Width(), "+SwFlyPortion::Format: a fly is a fly is a fly" );
@@ -81,7 +81,7 @@ bool SwFlyPortion::Format( SwTextFormatInfo &rInf )
SetLen(TextFrameIndex(1));
}
- const sal_uInt16 nNewWidth = static_cast<sal_uInt16>(rInf.X() + PrtWidth());
+ const sal_uInt16 nNewWidth = o3tl::narrowing<sal_uInt16>(rInf.X() + PrtWidth());
if( rInf.Width() <= nNewWidth )
{
Truncate();
@@ -428,7 +428,7 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase,
else
{
mnAscent = 0;
- Height( Height() + static_cast<sal_uInt16>(nRelPos) );
+ Height( Height() + o3tl::narrowing<sal_uInt16>(nRelPos) );
}
}
else
diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx
index 035f670d464b..e0a157d9d579 100644
--- a/sw/source/core/text/porlin.cxx
+++ b/sw/source/core/text/porlin.cxx
@@ -88,7 +88,7 @@ void SwLinePortion::PrePaint( const SwTextPaintInfo& rInf,
sal_uInt16 nLastWidth = pLast->Width();
if ( pLast->InSpaceGrp() && rInf.GetSpaceAdd() )
- nLastWidth = nLastWidth + static_cast<sal_uInt16>(pLast->CalcSpacing( rInf.GetSpaceAdd(), rInf ));
+ nLastWidth = nLastWidth + o3tl::narrowing<sal_uInt16>(pLast->CalcSpacing( rInf.GetSpaceAdd(), rInf ));
sal_uInt16 nPos;
SwTextPaintInfo aInf( rInf );
@@ -246,7 +246,7 @@ bool SwLinePortion::Format( SwTextFormatInfo &rInf )
const SwLinePortion *pLast = rInf.GetLast();
Height( pLast->Height() );
SetAscent( pLast->GetAscent() );
- const sal_uInt16 nNewWidth = static_cast<sal_uInt16>(rInf.X() + PrtWidth());
+ const sal_uInt16 nNewWidth = o3tl::narrowing<sal_uInt16>(rInf.X() + PrtWidth());
// Only portions with true width can return true
// Notes for example never set bFull==true
if( rInf.Width() <= nNewWidth && PrtWidth() && ! IsKernPortion() )
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index 0a6bd2b596dc..0c3297e57207 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -654,9 +654,9 @@ void SwRubyPortion::Adjust_( SwTextFormatInfo &rInf )
TextFrameIndex nSub(0);
switch ( m_nAdjustment )
{
- case css::text::RubyAdjust_CENTER: nRight = static_cast<sal_uInt16>(nLineDiff / 2);
+ case css::text::RubyAdjust_CENTER: nRight = o3tl::narrowing<sal_uInt16>(nLineDiff / 2);
[[fallthrough]];
- case css::text::RubyAdjust_RIGHT: nLeft = static_cast<sal_uInt16>(nLineDiff - nRight); break;
+ case css::text::RubyAdjust_RIGHT: nLeft = o3tl::narrowing<sal_uInt16>(nLineDiff - nRight); break;
case css::text::RubyAdjust_BLOCK: nSub = TextFrameIndex(1);
[[fallthrough]];
case css::text::RubyAdjust_INDENT_BLOCK:
@@ -683,8 +683,8 @@ void SwRubyPortion::Adjust_( SwTextFormatInfo &rInf )
}
if( nLineDiff > 1 )
{
- nRight = static_cast<sal_uInt16>(nLineDiff / 2);
- nLeft = static_cast<sal_uInt16>(nLineDiff - nRight);
+ nRight = o3tl::narrowing<sal_uInt16>(nLineDiff / 2);
+ nLeft = o3tl::narrowing<sal_uInt16>(nLineDiff - nRight);
}
break;
}
@@ -2544,7 +2544,7 @@ SwTextCursorSave::SwTextCursorSave( SwTextCursor* pCursor,
}
if( nSpaceAdd > 0 && !pMulti->HasTabulator() )
- pCursor->m_pCurr->Width( static_cast<sal_uInt16>(nWidth + nSpaceAdd * sal_Int32(nSpaceCnt) / SPACING_PRECISION_FACTOR) );
+ pCursor->m_pCurr->Width( o3tl::narrowing<sal_uInt16>(nWidth + nSpaceAdd * sal_Int32(nSpaceCnt) / SPACING_PRECISION_FACTOR) );
// For a BidiPortion we have to calculate the offset from the
// end of the portion
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index 21a51e135b85..23f837d63051 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -243,7 +243,7 @@ SwArrowPortion::SwArrowPortion( const SwLinePortion &rPortion ) :
SwArrowPortion::SwArrowPortion( const SwTextPaintInfo &rInf )
: m_bLeft( false )
{
- Height( static_cast<sal_uInt16>(rInf.GetTextFrame()->getFramePrintArea().Height()) );
+ Height( o3tl::narrowing<sal_uInt16>(rInf.GetTextFrame()->getFramePrintArea().Height()) );
m_aPos.setX( rInf.GetTextFrame()->getFrameArea().Left() +
rInf.GetTextFrame()->getFramePrintArea().Right() );
m_aPos.setY( rInf.GetTextFrame()->getFrameArea().Top() +
@@ -493,7 +493,7 @@ bool SwTextFrame::FillRegister( SwTwips& rRegStart, sal_uInt16& rRegDiff )
nTmp /= 100;
if( !nTmp )
++nTmp;
- rRegDiff = static_cast<sal_uInt16>(nTmp);
+ rRegDiff = o3tl::narrowing<sal_uInt16>(nTmp);
nNetHeight = rRegDiff;
break;
}
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index ed9d3c517bb5..c1fa69bcfc68 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -221,7 +221,7 @@ void SwTextPortion::BreakCut( SwTextFormatInfo &rInf, const SwTextGuess &rGuess
// The word/char is larger than the line
// Special case 1: The word is larger than the line
// We truncate ...
- const sal_uInt16 nLineWidth = static_cast<sal_uInt16>(rInf.Width() - rInf.X());
+ const sal_uInt16 nLineWidth = o3tl::narrowing<sal_uInt16>(rInf.Width() - rInf.X());
TextFrameIndex nLen = rGuess.CutPos() - rInf.GetIdx();
if (nLen > TextFrameIndex(0))
{
diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx
index e5ac47c692f7..ce39a3e9e1dc 100644
--- a/sw/source/core/text/txtdrop.cxx
+++ b/sw/source/core/text/txtdrop.cxx
@@ -775,7 +775,7 @@ void SwDropCapCache::CalcFontSize( SwDropPortion* pDrop, SwTextFormatInfo &rInf
m_aText[ nTmpIdx ] = aStr;
m_aWishedHeight[ nTmpIdx ] = sal_uInt16(nWishedHeight);
// save initial scaling factor
- m_aFactor[ nTmpIdx ] = static_cast<sal_uInt16>(nFactor);
+ m_aFactor[ nTmpIdx ] = o3tl::narrowing<sal_uInt16>(nFactor);
}
bool bGrow = (pDrop->GetLen() != TextFrameIndex(0));
@@ -925,7 +925,7 @@ void SwDropCapCache::CalcFontSize( SwDropPortion* pDrop, SwTextFormatInfo &rInf
else
{
if ( bUseCache )
- m_aFactor[ nTmpIdx ] = static_cast<sal_uInt16>(nFactor);
+ m_aFactor[ nTmpIdx ] = o3tl::narrowing<sal_uInt16>(nFactor);
nMin = nFactor;
}
@@ -982,7 +982,7 @@ void SwDropCapCache::CalcFontSize( SwDropPortion* pDrop, SwTextFormatInfo &rInf
bool SwDropPortion::Format( SwTextFormatInfo &rInf )
{
bool bFull = false;
- m_nFix = static_cast<sal_uInt16>(rInf.X());
+ m_nFix = o3tl::narrowing<sal_uInt16>(rInf.X());
SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() );
aLayoutModeModifier.SetAuto();
@@ -1020,7 +1020,7 @@ bool SwDropPortion::Format( SwTextFormatInfo &rInf )
Width();
// set values
- pCurrPart->SetWidth( static_cast<sal_uInt16>(nTmpWidth) );
+ pCurrPart->SetWidth( o3tl::narrowing<sal_uInt16>(nTmpWidth) );
// Move
rInf.SetIdx( rInf.GetIdx() + pCurrPart->GetLen() );
@@ -1029,7 +1029,7 @@ bool SwDropPortion::Format( SwTextFormatInfo &rInf )
}
SetJoinBorderWithNext(false);
SetJoinBorderWithPrev(false);
- Width( static_cast<sal_uInt16>(rInf.X() - nOldX) );
+ Width( o3tl::narrowing<sal_uInt16>(rInf.X() - nOldX) );
}
// reset my length
@@ -1066,7 +1066,7 @@ bool SwDropPortion::Format( SwTextFormatInfo &rInf )
else
{
const sal_uInt16 nWant = Width() + GetDistance();
- const sal_uInt16 nRest = static_cast<sal_uInt16>(rInf.Width() - rInf.X());
+ const sal_uInt16 nRest = o3tl::narrowing<sal_uInt16>(rInf.Width() - rInf.X());
if( ( nWant > nRest ) ||
lcl_IsDropFlyInter( rInf, Width() + GetDistance(), m_nDropHeight ) )
m_nDistance = 0;
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index 28ffea4116ab..d91d41ae4a01 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -244,7 +244,7 @@ SwRect SwContourCache::ContourRect( const SwFormat* pFormat,
CacheItem item {
pObj, // due to #37347 the Object must be entered only after GetContour()
std::make_unique<TextRanger>( aPolyPolygon, pPolyPolygon.get(), 20,
- static_cast<sal_uInt16>(rLRSpace.GetLeft()), static_cast<sal_uInt16>(rLRSpace.GetRight()),
+ o3tl::narrowing<sal_uInt16>(rLRSpace.GetLeft()), o3tl::narrowing<sal_uInt16>(rLRSpace.GetRight()),
pFormat->GetSurround().IsOutside(), false, pFrame->IsVertical() )
};
mvItems.insert(mvItems.begin(), std::move(item));
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index d640737b773d..9d7aa1efdec1 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -3330,11 +3330,11 @@ sal_uInt32 SwTextFrame::GetParHeight() const
if( !HasPara() )
{ // For non-empty paragraphs this is a special case
// For UnderSized we can simply just ask 1 Twip more
- sal_uInt16 nRet = static_cast<sal_uInt16>(getFramePrintArea().SSize().Height());
+ sal_uInt16 nRet = o3tl::narrowing<sal_uInt16>(getFramePrintArea().SSize().Height());
if( IsUndersized() )
{
if( IsEmpty() || GetText().isEmpty() )
- nRet = static_cast<sal_uInt16>(EmptyHeight());
+ nRet = o3tl::narrowing<sal_uInt16>(EmptyHeight());
else
++nRet;
}
@@ -3485,7 +3485,7 @@ void SwTextFrame::CalcAdditionalFirstLineOffset()
nListLevel = MAXLEVEL - 1;
const SwNumFormat& rNumFormat =
- pTextNode->GetNumRule()->Get( static_cast<sal_uInt16>(nListLevel) );
+ pTextNode->GetNumRule()->Get( o3tl::narrowing<sal_uInt16>(nListLevel) );
if ( rNumFormat.GetPositionAndSpaceMode() != SvxNumberFormat::LABEL_ALIGNMENT )
return;
@@ -3732,7 +3732,7 @@ sal_uInt16 SwTextFrame::FirstLineHeight() const
if ( !HasPara() )
{
if( IsEmpty() && isFrameAreaDefinitionValid() )
- return IsVertical() ? static_cast<sal_uInt16>(getFramePrintArea().Width()) : static_cast<sal_uInt16>(getFramePrintArea().Height());
+ return IsVertical() ? o3tl::narrowing<sal_uInt16>(getFramePrintArea().Width()) : o3tl::narrowing<sal_uInt16>(getFramePrintArea().Height());
return USHRT_MAX;
}
const SwParaPortion *pPara = GetPara();
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 5b4b9f7492e0..c35388bccb24 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -1181,7 +1181,7 @@ TextFrameIndex SwTextFormatter::FormatQuoVadis(TextFrameIndex const nOffset)
if( nDiff < 0 )
{
nLastLeft = pQuo->GetAscent();
- nQuoWidth = static_cast<sal_uInt16>(-nDiff + nLastLeft);
+ nQuoWidth = o3tl::narrowing<sal_uInt16>(-nDiff + nLastLeft);
}
else
{
diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx
index 8e8203c72270..ae8b69ba3bf9 100644
--- a/sw/source/core/text/txttab.cxx
+++ b/sw/source/core/text/txttab.cxx
@@ -154,7 +154,7 @@ SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto
const SvxTabStopItem& rTab =
m_pFrame->GetAttrSet()->GetPool()->GetDefaultItem( RES_PARATR_TABSTOP );
if( rTab.Count() )
- nDefTabDist = static_cast<sal_uInt16>(rTab[0].GetTabPos());
+ nDefTabDist = o3tl::narrowing<sal_uInt16>(rTab[0].GetTabPos());
else
nDefTabDist = SVX_TAB_DEFDIST;
m_aLineInf.SetDefTabStop( nDefTabDist );
@@ -323,7 +323,7 @@ bool SwTabPortion::PreFormat( SwTextFormatInfo &rInf )
OSL_ENSURE( rInf.X() <= GetTabPos(), "SwTabPortion::PreFormat: rush hour" );
// Here we settle down ...
- SetFix( static_cast<sal_uInt16>(rInf.X()) );
+ SetFix( o3tl::narrowing<sal_uInt16>(rInf.X()) );
IDocumentSettingAccess const& rIDSA(rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess());
const bool bTabCompat = rIDSA.get(DocumentSettingId::TAB_COMPAT);
@@ -387,7 +387,7 @@ bool SwTabPortion::PreFormat( SwTextFormatInfo &rInf )
break;
}
- PrtWidth( static_cast<sal_uInt16>(GetTabPos() - rInf.X()) );
+ PrtWidth( o3tl::narrowing<sal_uInt16>(GetTabPos() - rInf.X()) );
bFull = rInf.Width() <= rInf.X() + PrtWidth();
// In tabulator compatibility mode, we reset the bFull flag
@@ -417,7 +417,7 @@ bool SwTabPortion::PreFormat( SwTextFormatInfo &rInf )
// line if there is a fly reducing the line width:
!rInf.GetFly() )
{
- PrtWidth( static_cast<sal_uInt16>(rInf.Width() - rInf.X()) );
+ PrtWidth( o3tl::narrowing<sal_uInt16>(rInf.Width() - rInf.X()) );
SetFixWidth( PrtWidth() );
}
else
diff --git a/sw/source/core/text/wrong.cxx b/sw/source/core/text/wrong.cxx
index 5a70c7be9507..0022f4e453ea 100644
--- a/sw/source/core/text/wrong.cxx
+++ b/sw/source/core/text/wrong.cxx
@@ -203,7 +203,7 @@ sal_uInt16 SwWrongList::GetWrongPos( sal_Int32 nValue ) const
return (rST.mnPos <= nValue && nValue < rST.mnPos + rST.mnLen)
|| (rST.mnPos > nValue);
});
- return static_cast<sal_uInt16>(std::distance(maList.begin(), aIter));
+ return o3tl::narrowing<sal_uInt16>(std::distance(maList.begin(), aIter));
}
--nMax;
@@ -559,7 +559,7 @@ void SwWrongList::Remove(sal_uInt16 nIdx, sal_uInt16 nLen )
i1 += nIdx;
std::vector<SwWrongArea>::iterator i2 = i1;
- if ( nIdx + nLen >= static_cast<sal_uInt16>(maList.size()) )
+ if ( nIdx + nLen >= o3tl::narrowing<sal_uInt16>(maList.size()) )
i2 = maList.end(); // robust
else
i2 += nLen;
@@ -602,10 +602,10 @@ void SwWrongList::RemoveEntry( sal_Int32 nBegin, sal_Int32 nEnd ) {
return (rST.mnPos != nBegin) || ((rST.mnPos + rST.mnLen) != nEnd);
});
}
- auto nDel = static_cast<sal_uInt16>(std::distance(aDelIter, aIter));
+ auto nDel = o3tl::narrowing<sal_uInt16>(std::distance(aDelIter, aIter));
if( nDel )
{
- auto nDelPos = static_cast<sal_uInt16>(std::distance(maList.cbegin(), aDelIter));
+ auto nDelPos = o3tl::narrowing<sal_uInt16>(std::distance(maList.cbegin(), aDelIter));
Remove( nDelPos, nDel );
}
}
diff --git a/sw/source/core/tox/ToxTextGenerator.cxx b/sw/source/core/tox/ToxTextGenerator.cxx
index df37f294796b..199e30256475 100644
--- a/sw/source/core/tox/ToxTextGenerator.cxx
+++ b/sw/source/core/tox/ToxTextGenerator.cxx
@@ -265,7 +265,7 @@ ToxTextGenerator::GenerateText(SwDoc* pDoc,
aCharStyleName = SwResId(STR_POOLCHR_INET_NORMAL);
mLinkProcessor->StartNewLink(rText.getLength(), aCharStyleName);
}
- rBase.FillText( *pTOXNd, aIdx, static_cast<sal_uInt16>(eField), pLayout );
+ rBase.FillText( *pTOXNd, aIdx, o3tl::narrowing<sal_uInt16>(eField), pLayout );
if (eField == ToxAuthorityField::AUTH_FIELD_URL)
{
// Get the absolute URL, the text may be a relative one.
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index 466b7d6acdd9..021da63a54e3 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -860,7 +860,7 @@ lcl_BuildToken(const OUString & sPattern, sal_Int32 & nCurPatternPos)
eRet.sCharStyleName = sToken.getToken( 0, ',', nIdx );
OUString sTmp( sToken.getToken( 0, ',', nIdx ));
if( !sTmp.isEmpty() )
- eRet.nPoolId = static_cast<sal_uInt16>(sTmp.toInt32());
+ eRet.nPoolId = o3tl::narrowing<sal_uInt16>(sTmp.toInt32());
switch( eTokenType )
{
@@ -870,10 +870,10 @@ lcl_BuildToken(const OUString & sPattern, sal_Int32 & nCurPatternPos)
case TOKEN_ENTRY_NO:
sTmp = sToken.getToken( 0, ',', nIdx ); // token 2
if( !sTmp.isEmpty() )
- eRet.nChapterFormat = static_cast<sal_uInt16>(sTmp.toInt32());
+ eRet.nChapterFormat = o3tl::narrowing<sal_uInt16>(sTmp.toInt32());
sTmp = sToken.getToken( 0, ',', nIdx ); // token 3
if( !sTmp.isEmpty() )
- eRet.nOutlineLevel = static_cast<sal_uInt16>(sTmp.toInt32()); //the maximum outline level to examine
+ eRet.nOutlineLevel = o3tl::narrowing<sal_uInt16>(sTmp.toInt32()); //the maximum outline level to examine
break;
case TOKEN_TEXT:
@@ -911,7 +911,7 @@ lcl_BuildToken(const OUString & sPattern, sal_Int32 & nCurPatternPos)
break;
case TOKEN_AUTHORITY:
- eRet.nAuthorityField = static_cast<sal_uInt16>(sAuthFieldEnum.toInt32());
+ eRet.nAuthorityField = o3tl::narrowing<sal_uInt16>(sAuthFieldEnum.toInt32());
break;
default: break;
}
diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx
index e0ffc1922701..a67906d0e4ad 100644
--- a/sw/source/core/tox/txmsrt.cxx
+++ b/sw/source/core/tox/txmsrt.cxx
@@ -136,7 +136,7 @@ SwTOXSortTabBase::SwTOXSortTabBase( TOXSortType nTyp, const SwContentNode* pNd,
const SwTOXInternational* pInter,
const lang::Locale* pLocale )
: pTOXNd( nullptr ), pTextMark( pMark ), pTOXIntl( pInter ),
- nPos( 0 ), nCntPos( 0 ), nType( static_cast<sal_uInt16>(nTyp) )
+ nPos( 0 ), nCntPos( 0 ), nType( o3tl::narrowing<sal_uInt16>(nTyp) )
, m_bValidText( false )
{
if ( pLocale )
@@ -668,7 +668,7 @@ sal_uInt16 SwTOXPara::GetLevel() const
{
const int nTmp = static_cast<const SwTextNode*>(pNd)->GetAttrOutlineLevel();
if(nTmp != 0 )
- nRet = static_cast<sal_uInt16>(nTmp);
+ nRet = o3tl::narrowing<sal_uInt16>(nTmp);
}
return nRet;
}
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index 884883d10515..2376ca3169c2 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -234,8 +234,8 @@ OUString SwFormatFootnote::GetViewNumStr(const SwDoc& rDoc,
const SwFormatFootnoteEndAtTextEnd& rFootnoteEnd = static_cast<const SwFormatFootnoteEndAtTextEnd&>(
pSectNd->GetSection().GetFormat()->GetFormatAttr(
IsEndNote() ?
- static_cast<sal_uInt16>(RES_END_AT_TXTEND) :
- static_cast<sal_uInt16>(RES_FTN_AT_TXTEND) ) );
+ o3tl::narrowing<sal_uInt16>(RES_END_AT_TXTEND) :
+ o3tl::narrowing<sal_uInt16>(RES_FTN_AT_TXTEND) ) );
if( FTNEND_ATTXTEND_OWNNUMANDFMT == rFootnoteEnd.GetValue() )
{
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index 5e3afe0fce96..1da7a73acdee 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -412,7 +412,7 @@ sal_uInt16 SwFntObj::GetFontAscent( const SwViewShell *pSh, const OutputDevice&
const vcl::Font aOldFnt( rRefDev.GetFont() );
const_cast<OutputDevice&>(rRefDev).SetFont( *m_pPrtFont );
const FontMetric aOutMet( rRefDev.GetFontMetric() );
- m_nPrtAscent = static_cast<sal_uInt16>(aOutMet.GetAscent());
+ m_nPrtAscent = o3tl::narrowing<sal_uInt16>(aOutMet.GetAscent());
const_cast<OutputDevice&>(rRefDev).SetFont( aOldFnt );
}
@@ -448,12 +448,12 @@ sal_uInt16 SwFntObj::GetFontHeight( const SwViewShell* pSh, const OutputDevice&
CreatePrtFont( rOut );
const vcl::Font aOldFnt( rRefDev.GetFont() );
const_cast<OutputDevice&>(rRefDev).SetFont( *m_pPrtFont );
- m_nPrtHeight = static_cast<sal_uInt16>(rRefDev.GetTextHeight());
+ m_nPrtHeight = o3tl::narrowing<sal_uInt16>(rRefDev.GetTextHeight());
#if OSL_DEBUG_LEVEL > 0
// Check if vcl did not change the meaning of GetTextHeight
const FontMetric aOutMet( rRefDev.GetFontMetric() );
- tools::Long nTmpPrtHeight = static_cast<sal_uInt16>(aOutMet.GetAscent()) + aOutMet.GetDescent();
+ tools::Long nTmpPrtHeight = o3tl::narrowing<sal_uInt16>(aOutMet.GetAscent()) + aOutMet.GetDescent();
// #i106098#: do not compare with == here due to rounding error
OSL_ENSURE( std::abs(nTmpPrtHeight - m_nPrtHeight) < 3,
"GetTextHeight != Ascent + Descent" );
@@ -485,7 +485,7 @@ sal_uInt16 SwFntObj::GetFontLeading( const SwViewShell *pSh, const OutputDevice&
const_cast<OutputDevice&>(rOut).SetFont( aOldFnt );
m_bSymbol = RTL_TEXTENCODING_SYMBOL == aMet.GetCharSet();
GuessLeading( *pSh, aMet );
- m_nExtLeading = static_cast<sal_uInt16>(aMet.GetExternalLeading());
+ m_nExtLeading = o3tl::narrowing<sal_uInt16>(aMet.GetExternalLeading());
/* HACK: FIXME There is something wrong with Writer's bullet rendering, causing lines
with bullets to be higher than they should be. I think this is because
Writer uses font's external leading incorrect, as the vertical distance
@@ -569,7 +569,7 @@ void SwFntObj::CreateScrFont( const SwViewShell& rSh, const OutputDevice& rOut )
GuessLeading( rSh, aMet );
if ( USHRT_MAX == m_nExtLeading )
- m_nExtLeading = static_cast<sal_uInt16>(aMet.GetExternalLeading());
+ m_nExtLeading = o3tl::narrowing<sal_uInt16>(aMet.GetExternalLeading());
// reset the original reference device font
pPrt->SetFont( aOldPrtFnt );
@@ -587,9 +587,9 @@ void SwFntObj::CreateScrFont( const SwViewShell& rSh, const OutputDevice& rOut )
m_pScrFont = m_pPrtFont;
}
- m_nScrAscent = static_cast<sal_uInt16>(pOut->GetFontMetric().GetAscent());
+ m_nScrAscent = o3tl::narrowing<sal_uInt16>(pOut->GetFontMetric().GetAscent());
if ( USHRT_MAX == m_nScrHeight )
- m_nScrHeight = static_cast<sal_uInt16>(pOut->GetTextHeight());
+ m_nScrHeight = o3tl::narrowing<sal_uInt16>(pOut->GetTextHeight());
// reset original output device font
pOut->SetFont( aOldOutFont );
@@ -653,7 +653,7 @@ void SwFntObj::GuessLeading( const SwViewShell&
{
OSL_ENSURE( m_nPrtAscent < USHRT_MAX, "GuessLeading: PrtAscent-Fault" );
if ( m_nPrtAscent < USHRT_MAX )
- m_nPrtAscent = m_nPrtAscent + static_cast<sal_uInt16>(( 2 * nDiff ) / 5);
+ m_nPrtAscent = m_nPrtAscent + o3tl::narrowing<sal_uInt16>(( 2 * nDiff ) / 5);
}
}
}
@@ -1175,7 +1175,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
lcl_IsMonoSpaceFont( *(rInf.GetpOut()) ) )
{
pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
- rInf.GetKanaComp(), static_cast<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ) , &aTextOriginPos );
+ rInf.GetKanaComp(), o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ) , &aTextOriginPos );
bSpecialJust = true;
}
///Asian Justification
@@ -1342,7 +1342,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
{
pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
rInf.GetKanaComp(),
- static_cast<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ), &aTextOriginPos );
+ o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ), &aTextOriginPos );
bSpecialJust = true;
}
@@ -1551,10 +1551,10 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
Point aTmpPos( aTextOriginPos );
pSI->Compress( pScrArray.get(), rInf.GetIdx(), rInf.GetLen(),
rInf.GetKanaComp(),
- static_cast<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ), &aTmpPos );
+ o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ), &aTmpPos );
pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
rInf.GetKanaComp(),
- static_cast<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ), &aTextOriginPos );
+ o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ), &aTextOriginPos );
}
// Asian Justification
@@ -2029,7 +2029,7 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
if( bCompress )
rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( pKernArray.get(),
rInf.GetIdx(), nLn, rInf.GetKanaComp(),
- static_cast<sal_uInt16>(m_aFont.GetFontSize().Height()) ,lcl_IsFullstopCentered( rInf.GetOut() ) ) );
+ o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()) ,lcl_IsFullstopCentered( rInf.GetOut() ) ) );
else
rInf.SetKanaDiff( 0 );
@@ -2091,7 +2091,7 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
sal_Int32(rInf.GetIdx()), sal_Int32(nLn));
rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( pKernArray.get(),
rInf.GetIdx(), nLn, rInf.GetKanaComp(),
- static_cast<sal_uInt16>(m_aFont.GetFontSize().Height()) ,lcl_IsFullstopCentered( rInf.GetOut() ) ) );
+ o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()) ,lcl_IsFullstopCentered( rInf.GetOut() ) ) );
aTextSize.setWidth( pKernArray[sal_Int32(nLn) - 1] );
}
else
@@ -2151,7 +2151,7 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
{
pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
rInf.GetKanaComp(),
- static_cast<sal_uInt16>(m_aFont.GetFontSize().Height()),
+ o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()),
lcl_IsFullstopCentered( rInf.GetOut() ) );
}
@@ -2590,7 +2590,7 @@ TextFrameIndex SwFont::GetTextBreak(SwDrawTextInfo const & rInf, tools::Long nTe
rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
sal_Int32(rInf.GetIdx()), sal_Int32(nLn));
if( rInf.GetScriptInfo()->Compress( pKernArray.get(), rInf.GetIdx(), nLn,
- rInf.GetKanaComp(), static_cast<sal_uInt16>(GetHeight( m_nActual )),
+ rInf.GetKanaComp(), o3tl::narrowing<sal_uInt16>(GetHeight( m_nActual )),
lcl_IsFullstopCentered( rInf.GetOut() ) ) )
{
tools::Long nKernAdd = nKern;
diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx
index 66e8014dc183..16b054102c53 100644
--- a/sw/source/core/txtnode/fntcap.cxx
+++ b/sw/source/core/txtnode/fntcap.cxx
@@ -482,7 +482,7 @@ void SwSubFont::DrawStretchCapital( SwDrawTextInfo &rInf )
rInf.SetLen(TextFrameIndex(rInf.GetText().getLength()));
const Point aOldPos = rInf.GetPos();
- const sal_uInt16 nCapWidth = static_cast<sal_uInt16>( GetCapitalSize( rInf ).Width() );
+ const sal_uInt16 nCapWidth = o3tl::narrowing<sal_uInt16>( GetCapitalSize( rInf ).Width() );
rInf.SetPos(aOldPos);
rInf.SetDrawSpace( GetUnderline() != LINESTYLE_NONE ||
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 161c22ea2ea0..93b11b1be028 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -923,7 +923,7 @@ bool HasNumberingWhichNeedsLayoutUpdate(const SwTextNode& rTextNode)
}
const SwNumFormat* pFormat
- = pNumRule->GetNumFormat(static_cast<sal_uInt16>(rTextNode.GetAttrListLevel()));
+ = pNumRule->GetNumFormat(o3tl::narrowing<sal_uInt16>(rTextNode.GetAttrListLevel()));
if (!pFormat)
{
return false;
@@ -3077,7 +3077,7 @@ namespace
sal_uInt16 lcl_BoundListLevel(const int nActualLevel)
{
- return static_cast<sal_uInt16>( std::clamp( nActualLevel, 0, MAXLEVEL-1 ) );
+ return o3tl::narrowing<sal_uInt16>( std::clamp( nActualLevel, 0, MAXLEVEL-1 ) );
}
}
@@ -4030,7 +4030,7 @@ void SwTextNode::SetAttrOutlineLevel(int nLevel)
if ( 0 <= nLevel && nLevel <= MAXLEVEL )
{
SetAttr( SfxUInt16Item( RES_PARATR_OUTLINELEVEL,
- static_cast<sal_uInt16>(nLevel) ) );
+ o3tl::narrowing<sal_uInt16>(nLevel) ) );
}
}
@@ -4204,7 +4204,7 @@ SwNumberTree::tSwNumTreeNumber SwTextNode::GetActualListStartValue() const
if ( pRule )
{
const SwNumFormat* pFormat =
- pRule->GetNumFormat( static_cast<sal_uInt16>(GetAttrListLevel()) );
+ pRule->GetNumFormat( o3tl::narrowing<sal_uInt16>(GetAttrListLevel()) );
if ( pFormat )
{
nListRestartValue = pFormat->GetStart();
@@ -4483,7 +4483,7 @@ bool SwTextNode::GetListTabStopPosition( tools::Long& nListTabStopPosition ) con
const SwNumRule* pNumRule = GetNum() ? GetNum()->GetNumRule() : nullptr;
if ( pNumRule && HasVisibleNumberingOrBullet() && GetActualListLevel() >= 0 )
{
- const SwNumFormat& rFormat = pNumRule->Get( static_cast<sal_uInt16>(GetActualListLevel()) );
+ const SwNumFormat& rFormat = pNumRule->Get( o3tl::narrowing<sal_uInt16>(GetActualListLevel()) );
if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT &&
rFormat.GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
{
@@ -4515,7 +4515,7 @@ OUString SwTextNode::GetLabelFollowedBy() const
const SwNumRule* pNumRule = GetNum() ? GetNum()->GetNumRule() : nullptr;
if ( pNumRule && HasVisibleNumberingOrBullet() && GetActualListLevel() >= 0 )
{
- const SwNumFormat& rFormat = pNumRule->Get( static_cast<sal_uInt16>(GetActualListLevel()) );
+ const SwNumFormat& rFormat = pNumRule->Get( o3tl::narrowing<sal_uInt16>(GetActualListLevel()) );
if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
{
switch ( rFormat.GetLabelFollowedBy() )
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index 967f6336186d..620c0d67682a 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -1081,7 +1081,7 @@ Size SwSubFont::GetTextSize_( SwDrawTextInfo& rInf )
const sal_uInt16 nAscent = pLastFont->GetFontAscent( rInf.GetShell(),
rInf.GetOut() );
aTextSize.setHeight(
- static_cast<tools::Long>(CalcEscHeight( static_cast<sal_uInt16>(aTextSize.Height()), nAscent)) );
+ static_cast<tools::Long>(CalcEscHeight( o3tl::narrowing<sal_uInt16>(aTextSize.Height()), nAscent)) );
}
}
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 41e9adefd9d5..2a97d9017e79 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1863,7 +1863,7 @@ void SwTextNode::TryCharSetExpandToNum(const SfxItemSet& aCharSet)
if (!(nLevel != -1 && pCurrNum))
return;
- const SwNumFormat* pCurrNumFormat = pCurrNum->GetNumFormat(static_cast<sal_uInt16>(nLevel));
+ const SwNumFormat* pCurrNumFormat = pCurrNum->GetNumFormat(o3tl::narrowing<sal_uInt16>(nLevel));
if (!pCurrNumFormat)
return;
@@ -2101,7 +2101,7 @@ static void lcl_MergeListLevelIndentAsLRSpaceItem( const SwTextNode& rTextNode,
const SwNumRule* pRule = rTextNode.GetNumRule();
if ( pRule && rTextNode.GetActualListLevel() >= 0 )
{
- const SwNumFormat& rFormat = pRule->Get(static_cast<sal_uInt16>(rTextNode.GetActualListLevel()));
+ const SwNumFormat& rFormat = pRule->Get(o3tl::narrowing<sal_uInt16>(rTextNode.GetActualListLevel()));
if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
{
SvxLRSpaceItem aLR( RES_LR_SPACE );
@@ -2303,7 +2303,7 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
if( rItemPair.mpItem && !IsInvalidItem(rItemPair.mpItem) )
{
const sal_uInt16 nWh =
- static_cast<sal_uInt16>(n + RES_CHRATR_BEGIN);
+ o3tl::narrowing<sal_uInt16>(n + RES_CHRATR_BEGIN);
if (nEnd <= rItemPair.mnEndPos) // behind or exactly end
{
diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx
index f9d23617ece3..71cbb16e2be7 100644
--- a/sw/source/core/txtnode/txtatr2.cxx
+++ b/sw/source/core/txtnode/txtatr2.cxx
@@ -231,7 +231,7 @@ SwCharFormat* SwTextRuby::GetCharFormat()
const SwDoc& rDoc = GetTextNode().GetDoc();
const OUString& rStr = rFormat.GetCharFormatName();
const sal_uInt16 nId = rStr.isEmpty()
- ? static_cast<sal_uInt16>(RES_POOLCHR_RUBYTEXT)
+ ? o3tl::narrowing<sal_uInt16>(RES_POOLCHR_RUBYTEXT)
: rFormat.GetCharFormatId();
// JP 10.02.2000, Bug 72806: don't modify the doc for getting the
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 40ca36552139..aa2d2d624fd2 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -102,7 +102,7 @@ void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrame)
if (RndStdIds::FLY_AT_PAGE == m_nRndId)
{
- aAnchor.SetPageNum( static_cast<sal_uInt16>(m_nNodePagePos) );
+ aAnchor.SetPageNum( o3tl::narrowing<sal_uInt16>(m_nNodePagePos) );
}
else
{
diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx
index c29e4a9a7713..fc7efcdfec70 100644
--- a/sw/source/core/undo/undraw.cxx
+++ b/sw/source/core/undo/undraw.cxx
@@ -298,7 +298,7 @@ void SwUndoDrawGroup::SetGroupFormat( SwDrawFrameFormat* pFormat )
SwUndoDrawUnGroup::SwUndoDrawUnGroup( SdrObjGroup* pObj, const SwDoc& rDoc )
: SwUndo( SwUndoId::DRAWUNGROUP, &rDoc ), m_bDeleteFormat( false )
{
- m_nSize = static_cast<sal_uInt16>(pObj->GetSubList()->GetObjCount()) + 1;
+ m_nSize = o3tl::narrowing<sal_uInt16>(pObj->GetSubList()->GetObjCount()) + 1;
m_pObjArray.reset( new SwUndoGroupObjImpl[ m_nSize ] );
SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx
index aed2397937c7..cf09ad827d82 100644
--- a/sw/source/core/undo/unnum.cxx
+++ b/sw/source/core/undo/unnum.cxx
@@ -342,7 +342,7 @@ SwUndoNumRuleStart::SwUndoNumRuleStart( const SwPosition& rPos, sal_uInt16 nStt
{
if ( pTextNd->HasAttrListRestartValue() )
{
- m_nOldStart = static_cast<sal_uInt16>(pTextNd->GetAttrListRestartValue());
+ m_nOldStart = o3tl::narrowing<sal_uInt16>(pTextNd->GetAttrListRestartValue());
}
else
{
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 0b806e476f6d..28f54bcd7277 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -929,7 +929,7 @@ sal_uInt16 SaveTable::AddFormat( SwFrameFormat* pFormat, bool bIsLine )
m_aSets.push_back(pSet);
m_aFrameFormats.insert(m_aFrameFormats.begin() + nRet, pFormat);
}
- return static_cast<sal_uInt16>(nRet);
+ return o3tl::narrowing<sal_uInt16>(nRet);
}
void SaveTable::RestoreAttr( SwTable& rTable, bool bMdfyBox )
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 9eaefe985b6f..50f0aa61cf38 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -1860,7 +1860,7 @@ uno::Any SwXReferenceMarks::getByIndex(sal_Int32 nIndex)
if(0 <= nIndex && nIndex < SAL_MAX_UINT16)
{
SwFormatRefMark *const pMark = const_cast<SwFormatRefMark*>(
- GetDoc()->GetRefMark(static_cast<sal_uInt16>(nIndex)));
+ GetDoc()->GetRefMark(o3tl::narrowing<sal_uInt16>(nIndex)));
if(pMark)
{
xRef = SwXReferenceMark::CreateXReferenceMark(*GetDoc(), pMark);
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 894e4db8733b..e5c8fb7e1515 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1409,7 +1409,7 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
}
else if(IsDescriptor())
{
- m_pProps->SetProperty(static_cast<sal_uInt16>(RES_FRAMEDIR), 0, _rValue);
+ m_pProps->SetProperty(o3tl::narrowing<sal_uInt16>(RES_FRAMEDIR), 0, _rValue);
}
return;
}
@@ -1476,16 +1476,16 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
pNoText->SetContour(nullptr);
else if(aValue >>= aParam)
{
- tools::PolyPolygon aPoly(static_cast<sal_uInt16>(aParam.getLength()));
+ tools::PolyPolygon aPoly(o3tl::narrowing<sal_uInt16>(aParam.getLength()));
for(const ::drawing::PointSequence& rPointSeq : std::as_const(aParam))
{
sal_Int32 nPoints = rPointSeq.getLength();
const ::awt::Point* pPoints = rPointSeq.getConstArray();
- tools::Polygon aSet( static_cast<sal_uInt16>(nPoints) );
+ tools::Polygon aSet( o3tl::narrowing<sal_uInt16>(nPoints) );
for(sal_Int32 j = 0; j < nPoints; j++)
{
Point aPoint(pPoints[j].X, pPoints[j].Y);
- aSet.SetPoint(aPoint, static_cast<sal_uInt16>(j));
+ aSet.SetPoint(aPoint, o3tl::narrowing<sal_uInt16>(j));
}
// Close polygon if it isn't closed already.
aSet.Optimize( PolyOptimizeFlags::CLOSE );
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index c4f5ddf17980..418dfce96797 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -2557,7 +2557,7 @@ SwXDocumentIndex::StyleAccess_Impl::replaceByIndex(
SwGetPoolIdFromName::TxtColl);
sSetStyles.append(aString);
}
- rTOXBase.SetStyleNames(sSetStyles.makeStringAndClear(), static_cast<sal_uInt16>(nIndex));
+ rTOXBase.SetStyleNames(sSetStyles.makeStringAndClear(), o3tl::narrowing<sal_uInt16>(nIndex));
}
sal_Int32 SAL_CALL
@@ -2579,7 +2579,7 @@ SwXDocumentIndex::StyleAccess_Impl::getByIndex(sal_Int32 nIndex)
SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
const OUString& rStyles =
- rTOXBase.GetStyleNames(static_cast<sal_uInt16>(nIndex));
+ rTOXBase.GetStyleNames(o3tl::narrowing<sal_uInt16>(nIndex));
const sal_Int32 nStyles = comphelper::string::getTokenCount(rStyles, TOX_STYLE_DELIMITER);
uno::Sequence<OUString> aStyles(nStyles);
OUString* pStyles = aStyles.getArray();
@@ -2842,7 +2842,7 @@ SwXDocumentIndex::TokenAccess_Impl::replaceByIndex(
sPattern.append(aToken.GetString());
}
SwForm aForm(rTOXBase.GetTOXForm());
- aForm.SetPattern(static_cast<sal_uInt16>(nIndex), sPattern.makeStringAndClear());
+ aForm.SetPattern(o3tl::narrowing<sal_uInt16>(nIndex), sPattern.makeStringAndClear());
rTOXBase.SetTOXForm(aForm);
}
@@ -2869,7 +2869,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex)
// #i21237#
SwFormTokens aPattern = rTOXBase.GetTOXForm().
- GetPattern(static_cast<sal_uInt16>(nIndex));
+ GetPattern(o3tl::narrowing<sal_uInt16>(nIndex));
sal_Int32 nTokenCount = 0;
uno::Sequence< beans::PropertyValues > aRetSeq;
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 079e69ba2abc..c96e8ea28ca1 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -310,7 +310,7 @@ lcl_SetNodeNumStart(SwPaM & rCursor, uno::Any const& rValue)
{
sal_Int16 nTmp = 1;
rValue >>= nTmp;
- sal_uInt16 nStt = (nTmp < 0 ? USHRT_MAX : static_cast<sal_uInt16>(nTmp));
+ sal_uInt16 nStt = (nTmp < 0 ? USHRT_MAX : o3tl::narrowing<sal_uInt16>(nTmp));
SwDoc& rDoc = rCursor.GetDoc();
UnoActionContext aAction(&rDoc);
@@ -2787,7 +2787,7 @@ bool SwUnoCursorHelper::ConvertSortProperties(
LanguageTag::convertToLanguageType( pFields[i].CollatorLocale );
aKeys[i]->sSortType = pFields[i].CollatorAlgorithm;
aKeys[i]->nColumnId =
- static_cast<sal_uInt16>(pFields[i].Field);
+ o3tl::narrowing<sal_uInt16>(pFields[i].Field);
aKeys[i]->bIsNumeric = (pFields[i].FieldType ==
table::TableSortFieldType_NUMERIC);
aKeys[i]->eSortOrder = (pFields[i].IsAscending)
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index af6633e05222..eedb0fdbaa2d 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -1251,7 +1251,7 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetNumberingRuleByIndex(
SolarMutexGuard aGuard;
OSL_ENSURE( 0 <= nIndex && nIndex < MAXLEVEL, "index out of range" );
- const SwNumFormat& rFormat = rNumRule.Get( static_cast<sal_uInt16>(nIndex) );
+ const SwNumFormat& rFormat = rNumRule.Get( o3tl::narrowing<sal_uInt16>(nIndex) );
SwCharFormat* pCharFormat = rFormat.GetCharFormat();
OUString CharStyleName;
@@ -1479,7 +1479,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
SolarMutexGuard aGuard;
OSL_ENSURE( 0 <= nIndex && nIndex < MAXLEVEL, "index out of range" );
- SwNumFormat aFormat(rNumRule.Get( static_cast<sal_uInt16>(nIndex) ));
+ SwNumFormat aFormat(rNumRule.Get( o3tl::narrowing<sal_uInt16>(nIndex) ));
OUString sHeadingStyleName;
OUString sParagraphStyleName;
@@ -1525,7 +1525,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
}
}
- rNumRule.Set(static_cast<sal_uInt16>(nIndex), aFormat);
+ rNumRule.Set(o3tl::narrowing<sal_uInt16>(nIndex), aFormat);
}
void SwXNumberingRules::SetPropertiesToNumFormat(
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 0e2cff68a5b5..ee6c41b11911 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -204,7 +204,7 @@ static void lcl_SetSpecialProperty(SwFrameFormat* pFormat,
sal_Int32 nRepeat = 0;
aValue >>= nRepeat;
if( nRepeat >= 0 && nRepeat < SAL_MAX_UINT16 )
- pFormat->GetDoc()->SetRowsToRepeat( *pTable, static_cast<sal_uInt16>(nRepeat) );
+ pFormat->GetDoc()->SetRowsToRepeat( *pTable, o3tl::narrowing<sal_uInt16>(nRepeat) );
}
}
break;
@@ -2031,8 +2031,8 @@ void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC)
{
if (!m_pImpl->IsDescriptor() || nR <= 0 || nC <= 0 || nR >= SAL_MAX_UINT16 || nC >= SAL_MAX_UINT16)
throw uno::RuntimeException();
- m_pImpl->m_nRows = static_cast<sal_uInt16>(nR);
- m_pImpl->m_nColumns = static_cast<sal_uInt16>(nC);
+ m_pImpl->m_nRows = o3tl::narrowing<sal_uInt16>(nR);
+ m_pImpl->m_nColumns = o3tl::narrowing<sal_uInt16>(nC);
}
uno::Reference<table::XTableRows> SAL_CALL SwXTextTable::getRows()
@@ -2636,7 +2636,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
aBoxInfo.SetLine(aVertLine.isEmpty() ? nullptr : &aVertLine, SvxBoxInfoItemLine::VERT);
aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::VERT, aBorder.IsVerticalLineValid);
- aBox.SetAllDistances(static_cast<sal_uInt16>(convertMm100ToTwip(aBorder.Distance)));
+ aBox.SetAllDistances(o3tl::narrowing<sal_uInt16>(convertMm100ToTwip(aBorder.Distance)));
aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::DISTANCE, aBorder.IsDistanceValid);
aSet.Put(aBox);
@@ -3973,7 +3973,7 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
// remove actions - TODO: why?
UnoActionRemoveContext aRemoveContext(&pUnoCursor->GetDoc());
}
- pFrameFormat->GetDoc()->InsertRow(*pUnoCursor, static_cast<sal_uInt16>(nCount), bAppend);
+ pFrameFormat->GetDoc()->InsertRow(*pUnoCursor, o3tl::narrowing<sal_uInt16>(nCount), bAppend);
}
void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
@@ -4129,7 +4129,7 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
UnoActionRemoveContext aRemoveContext(&pUnoCursor->GetDoc());
}
- pFrameFormat->GetDoc()->InsertCol(*pUnoCursor, static_cast<sal_uInt16>(nCount), bAppend);
+ pFrameFormat->GetDoc()->InsertCol(*pUnoCursor, o3tl::narrowing<sal_uInt16>(nCount), bAppend);
}
///@see SwXTableRows::removeByIndex (TODO: seems to be copy and paste programming here)
diff --git a/sw/source/core/view/pagepreviewlayout.cxx b/sw/source/core/view/pagepreviewlayout.cxx
index ac91694845fe..3c37ba2ced2b 100644
--- a/sw/source/core/view/pagepreviewlayout.cxx
+++ b/sw/source/core/view/pagepreviewlayout.cxx
@@ -362,9 +362,9 @@ bool SwPagePreviewLayout::Prepare( const sal_uInt16 _nProposedStartPageNum,
// determine column and row of proposed start position.
// Note: paint starts at point (0,0)
const sal_uInt16 nColOfProposed =
- static_cast<sal_uInt16>(rProposedStartPos.X() / mnColWidth) + 1;
+ o3tl::narrowing<sal_uInt16>(rProposedStartPos.X() / mnColWidth) + 1;
const sal_uInt16 nRowOfProposed =
- static_cast<sal_uInt16>(rProposedStartPos.Y() / mnRowHeight) + 1;
+ o3tl::narrowing<sal_uInt16>(rProposedStartPos.Y() / mnRowHeight) + 1;
// determine start page == page at proposed start position
// leaving left-top-corner blank is
// controlled by <mbBookPreview>.