summaryrefslogtreecommitdiff
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
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>
-rw-r--r--dbaccess/source/ui/misc/UITools.cxx2
-rw-r--r--include/svtools/brwbox.hxx8
-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
7 files changed, 24 insertions, 24 deletions
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index a07d588be2a9..483afced1082 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -929,7 +929,7 @@ void notifySystemWindow(vcl::Window const * _pWindow, vcl::Window* _pToRegister,
void adjustBrowseBoxColumnWidth( ::svt::EditBrowseBox* _pBox, sal_uInt16 _nColId )
{
sal_Int32 nColSize = -1;
- sal_uInt32 nDefaultWidth = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) );
+ ::tools::Long nDefaultWidth = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) );
if ( nDefaultWidth != _pBox->GetColumnWidth( _nColId ) )
{
Size aSizeMM = _pBox->PixelToLogic( Size( _pBox->GetColumnWidth( _nColId ), 0 ), MapMode( MapUnit::MapMM ) );
diff --git a/include/svtools/brwbox.hxx b/include/svtools/brwbox.hxx
index 2bdd2b910465..42155eb1f45e 100644
--- a/include/svtools/brwbox.hxx
+++ b/include/svtools/brwbox.hxx
@@ -510,12 +510,12 @@ public:
{ Control::SetFont( rNewFont ); }
// inserting, changing, removing and freezing of columns
- void InsertHandleColumn( sal_uLong nWidth );
+ void InsertHandleColumn( tools::Long nWidth );
void InsertDataColumn( sal_uInt16 nItemId, const OUString& rText,
tools::Long nSize, HeaderBarItemBits nBits = HeaderBarItemBits::STDSTYLE,
sal_uInt16 nPos = HEADERBAR_APPEND );
void SetColumnTitle( sal_uInt16 nColumnId, const OUString &rTitle );
- void SetColumnWidth( sal_uInt16 nColumnId, sal_uLong nWidth );
+ void SetColumnWidth( sal_uInt16 nColumnId, tools::Long nWidth );
void SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos );
void FreezeColumn( sal_uInt16 nColumnId );
void RemoveColumn( sal_uInt16 nColumnId );
@@ -530,7 +530,7 @@ public:
// access to dynamic values of cursor row
OUString GetColumnTitle( sal_uInt16 nColumnId ) const;
tools::Rectangle GetFieldRect( sal_uInt16 nColumnId ) const;
- sal_uLong GetColumnWidth( sal_uInt16 nColumnId ) const;
+ tools::Long GetColumnWidth( sal_uInt16 nColumnId ) const;
sal_uInt16 GetColumnId( sal_uInt16 nPos ) const;
sal_uInt16 GetColumnPos( sal_uInt16 nColumnId ) const;
bool IsFrozen( sal_uInt16 nColumnId ) const;
@@ -619,7 +619,7 @@ public:
The width is calculated so that the text fits completely, plus some margin.
*/
- sal_uLong GetDefaultColumnWidth( const OUString& _rText ) const;
+ tools::Long GetDefaultColumnWidth( const OUString& _rText ) const;
/** GetCellText returns the text at the given position
@param _nRow
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);