summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorYli875 <qq3202390739@gmail.com>2023-10-01 22:08:43 -0700
committerHossein <hossein@libreoffice.org>2023-11-09 13:45:47 +0100
commit38f9bc92401899489c94276f8647a747f17598e1 (patch)
tree89e642e56e2ba6ab43a83a8d1469dba96b15f379 /svtools
parent8ccd386b0793b14859ba2031b34853715606828c (diff)
tdf#114441 Convert sal_uLong to better integer types
The maximum value of the width in BrowserColumn is LONG_MAX. tools::Long value range is the closest among other integer types. It is widely used in these files. Also, other parameter types and return types have been changed to match the width type. Change-Id: Ia8b941a8ea02075a0d9b4d44675d5809005738bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157477 Tested-by: Hossein <hossein@libreoffice.org> Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/brwbox/brwbox1.cxx14
-rw-r--r--svtools/source/brwbox/brwbox2.cxx8
-rw-r--r--svtools/source/brwbox/datwin.cxx4
-rw-r--r--svtools/source/brwbox/datwin.hxx10
-rw-r--r--svtools/source/brwbox/editbrowsebox.cxx2
5 files changed, 19 insertions, 19 deletions
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx
index 509d1265649f..cc78b514f7a6 100644
--- a/svtools/source/brwbox/brwbox1.cxx
+++ b/svtools/source/brwbox/brwbox1.cxx
@@ -272,13 +272,13 @@ const vcl::Font& BrowseBox::GetFont() const
return pDataWin->GetFont();
}
-sal_uLong BrowseBox::GetDefaultColumnWidth( const OUString& _rText ) const
+tools::Long BrowseBox::GetDefaultColumnWidth( const OUString& _rText ) const
{
return pDataWin->GetTextWidth( _rText ) + pDataWin->GetTextWidth(OUString('0')) * 4;
}
-void BrowseBox::InsertHandleColumn( sal_uLong nWidth )
+void BrowseBox::InsertHandleColumn( tools::Long nWidth )
{
#if OSL_DEBUG_LEVEL > 0
@@ -570,7 +570,7 @@ void BrowseBox::SetColumnTitle( sal_uInt16 nItemId, const OUString& rTitle )
}
-void BrowseBox::SetColumnWidth( sal_uInt16 nItemId, sal_uLong nWidth )
+void BrowseBox::SetColumnWidth( sal_uInt16 nItemId, tools::Long nWidth )
{
// get the position in the current array
@@ -591,7 +591,7 @@ void BrowseBox::SetColumnWidth( sal_uInt16 nItemId, sal_uLong nWidth )
nMaxWidth -= pDataWin->bAutoSizeLastCol
? GetFieldRect(nItemId).Left()
: GetFrozenWidth();
- if ( pDataWin->bAutoSizeLastCol || nWidth > o3tl::make_unsigned(nMaxWidth) )
+ if ( pDataWin->bAutoSizeLastCol || nWidth > nMaxWidth )
{
nWidth = nMaxWidth > 16 ? nMaxWidth : nOldWidth;
}
@@ -600,7 +600,7 @@ void BrowseBox::SetColumnWidth( sal_uInt16 nItemId, sal_uLong nWidth )
// OV
// In AutoSizeLastColumn(), we call SetColumnWidth with nWidth==0xffff.
// Thus, check here, if the width has actually changed.
- if( static_cast<sal_uLong>(nOldWidth) == nWidth )
+ if( nOldWidth == nWidth )
return;
// do we want to display the change immediately?
@@ -638,13 +638,13 @@ void BrowseBox::SetColumnWidth( sal_uInt16 nItemId, sal_uLong nWidth )
if( GetBackground().IsScrollable() )
{
- tools::Rectangle aScrRect( nX + std::min( static_cast<sal_uLong>(nOldWidth), nWidth ), 0,
+ tools::Rectangle aScrRect( nX + std::min( nOldWidth, nWidth ), 0,
GetSizePixel().Width() , // the header is longer than the datawin
pDataWin->GetPosPixel().Y() - 1 );
Control::Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
aScrRect.SetBottom( pDataWin->GetSizePixel().Height() );
pDataWin->Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
- tools::Rectangle aInvRect( nX, 0, nX + std::max( nWidth, static_cast<sal_uLong>(nOldWidth) ), USHRT_MAX );
+ tools::Rectangle aInvRect( nX, 0, nX + std::max( nWidth, nOldWidth ), USHRT_MAX );
Control::Invalidate( aInvRect, InvalidateFlags::NoChildren );
pDataWin->Invalidate( aInvRect );
}
diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx
index 33f0990de6e9..08bfe6c7f460 100644
--- a/svtools/source/brwbox/brwbox2.cxx
+++ b/svtools/source/brwbox/brwbox2.cxx
@@ -366,7 +366,7 @@ void BrowseBox::DrawCursor()
}
-sal_uLong BrowseBox::GetColumnWidth( sal_uInt16 nId ) const
+tools::Long BrowseBox::GetColumnWidth( sal_uInt16 nId ) const
{
sal_uInt16 nItemPos = GetColumnPos( nId );
@@ -1382,7 +1382,7 @@ void BrowseBox::MouseMove( const MouseEvent& rEvt )
sal_uInt16 nX = 0;
for ( size_t nCol = 0;
nCol < mvCols.size() &&
- ( nX + mvCols[ nCol ]->Width() ) < o3tl::make_unsigned(GetOutputSizePixel().Width());
+ ( nX + mvCols[ nCol ]->Width() ) < GetOutputSizePixel().Width();
++nCol )
// is this column visible?
if ( mvCols[ nCol ]->IsFrozen() || nCol >= nFirstCol )
@@ -1405,7 +1405,7 @@ void BrowseBox::MouseMove( const MouseEvent& rEvt )
nDragX = std::max( rEvt.GetPosPixel().X(), nMinResizeX );
tools::Long nDeltaX = nDragX - nResizeX;
sal_uInt16 nId = GetColumnId(nResizeCol);
- sal_uLong nOldWidth = GetColumnWidth(nId);
+ tools::Long nOldWidth = GetColumnWidth(nId);
nDragX = nOldWidth + nDeltaX + nResizeX - nOldWidth;
// draw new auxiliary line
@@ -1433,7 +1433,7 @@ void BrowseBox::MouseButtonUp( const MouseEvent & rEvt )
// width changed?
nDragX = std::max( rEvt.GetPosPixel().X(), nMinResizeX );
- if ( (nDragX - nResizeX) != static_cast<tools::Long>(mvCols[ nResizeCol ]->Width()) )
+ if ( (nDragX - nResizeX) != mvCols[ nResizeCol ]->Width() )
{
// resize column
tools::Long nMaxX = pDataWin->GetSizePixel().Width();
diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx
index d0144a9d4f7c..c818bb9d829d 100644
--- a/svtools/source/brwbox/datwin.cxx
+++ b/svtools/source/brwbox/datwin.cxx
@@ -88,7 +88,7 @@ void ButtonFrame::Draw( OutputDevice& rDev )
}
BrowserColumn::BrowserColumn( sal_uInt16 nItemId,
- OUString aTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom )
+ OUString aTitle, tools::Long nWidthPixel, const Fraction& rCurrentZoom )
: _nId( nItemId ),
_nWidth( nWidthPixel ),
_aTitle(std::move( aTitle )),
@@ -106,7 +106,7 @@ BrowserColumn::~BrowserColumn()
{
}
-void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom)
+void BrowserColumn::SetWidth(tools::Long nNewWidthPixel, const Fraction& rCurrentZoom)
{
_nWidth = nNewWidthPixel;
// Avoid overflow when called with LONG_MAX from
diff --git a/svtools/source/brwbox/datwin.hxx b/svtools/source/brwbox/datwin.hxx
index a345d28fee48..29e0ac301bda 100644
--- a/svtools/source/brwbox/datwin.hxx
+++ b/svtools/source/brwbox/datwin.hxx
@@ -53,19 +53,19 @@ public:
class BrowserColumn final
{
sal_uInt16 _nId;
- sal_uLong _nOriginalWidth;
- sal_uLong _nWidth;
+ tools::Long _nOriginalWidth;
+ tools::Long _nWidth;
OUString _aTitle;
bool _bFrozen;
public:
BrowserColumn( sal_uInt16 nItemId,
- OUString aTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom );
+ OUString aTitle, tools::Long nWidthPixel, const Fraction& rCurrentZoom );
~BrowserColumn();
sal_uInt16 GetId() const { return _nId; }
- sal_uLong Width() const { return _nWidth; }
+ tools::Long Width() const { return _nWidth; }
OUString& Title() { return _aTitle; }
bool IsFrozen() const { return _bFrozen; }
@@ -74,7 +74,7 @@ public:
void Draw( BrowseBox const & rBox, OutputDevice& rDev,
const Point& rPos );
- void SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom);
+ void SetWidth(tools::Long nNewWidthPixel, const Fraction& rCurrentZoom);
void ZoomChanged(const Fraction& rNewZoom);
};
diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx
index 46f3379b7847..927e203dd14a 100644
--- a/svtools/source/brwbox/editbrowsebox.cxx
+++ b/svtools/source/brwbox/editbrowsebox.cxx
@@ -65,7 +65,7 @@ namespace svt
sal_uInt16 nColId = GetCurItemId();
if (nColId)
{
- sal_uInt32 nAutoWidth = static_cast<EditBrowseBox*>(GetParent())->GetAutoColumnWidth(nColId);
+ tools::Long nAutoWidth = static_cast<EditBrowseBox*>(GetParent())->GetAutoColumnWidth(nColId);
if (nAutoWidth != static_cast<EditBrowseBox*>(GetParent())->GetColumnWidth(nColId))
{
static_cast<EditBrowseBox*>(GetParent())->SetColumnWidth(nColId, nAutoWidth);