summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-12-13 13:07:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-12-14 10:05:50 +0100
commit433fc2214c980abd82fa6240f45e634a53a3c61c (patch)
tree85405a421b5d90daa37bf46ea0979b6ebea51419
parent76de866e162502518acbc0ab020c257b80946c2d (diff)
sal_uIntPtr->sal_Int32 in MultiSelection
also replace the long/size_t with sal_Int32 so we have some consistency Change-Id: I9d3099b881354af7b9f59d312e6b15b213d1e580 Reviewed-on: https://gerrit.libreoffice.org/46395 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/tools/multisel.hxx36
-rw-r--r--svtools/source/brwbox/brwbox1.cxx2
-rw-r--r--sw/source/core/text/porlay.cxx6
-rw-r--r--sw/source/core/txtnode/modeltoviewhelper.cxx2
-rw-r--r--tools/source/memtools/multisel.cxx76
5 files changed, 61 insertions, 61 deletions
diff --git a/include/tools/multisel.hxx b/include/tools/multisel.hxx
index 17c95a93421f..903423ae5d9c 100644
--- a/include/tools/multisel.hxx
+++ b/include/tools/multisel.hxx
@@ -28,23 +28,23 @@
typedef ::std::vector< Range* > ImpSelList;
-#define SFX_ENDOFSELECTION ULONG_MAX
+#define SFX_ENDOFSELECTION SAL_MAX_INT32
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC MultiSelection
{
private:
ImpSelList aSels; // array of SV-selections
Range aTotRange; // total range of indexes
- sal_uIntPtr nCurSubSel; // index in aSels of current selected index
- long nCurIndex; // current selected entry
- sal_uIntPtr nSelCount; // number of selected indexes
+ sal_Int32 nCurSubSel; // index in aSels of current selected index
+ sal_Int32 nCurIndex; // current selected entry
+ sal_Int32 nSelCount; // number of selected indexes
bool bInverseCur;// inverse cursor
bool bCurValid; // are nCurIndex and nCurSubSel valid
TOOLS_DLLPRIVATE void ImplClear();
- TOOLS_DLLPRIVATE size_t ImplFindSubSelection( long nIndex ) const;
- TOOLS_DLLPRIVATE void ImplMergeSubSelections( size_t nPos1, size_t nPos2 );
- TOOLS_DLLPRIVATE long ImplFwdUnselected();
+ TOOLS_DLLPRIVATE sal_Int32 ImplFindSubSelection( sal_Int32 nIndex ) const;
+ TOOLS_DLLPRIVATE void ImplMergeSubSelections( sal_Int32 nPos1, sal_Int32 nPos2 );
+ TOOLS_DLLPRIVATE sal_Int32 ImplFwdUnselected();
public:
MultiSelection();
@@ -55,25 +55,25 @@ public:
MultiSelection& operator= ( const MultiSelection& rOrig );
void SelectAll( bool bSelect = true );
- bool Select( long nIndex, bool bSelect = true );
+ bool Select( sal_Int32 nIndex, bool bSelect = true );
void Select( const Range& rIndexRange, bool bSelect = true );
- bool IsSelected( long nIndex ) const;
+ bool IsSelected( sal_Int32 nIndex ) const;
bool IsAllSelected() const
- { return nSelCount == sal_uIntPtr(aTotRange.Len()); }
- long GetSelectCount() const { return nSelCount; }
+ { return nSelCount == aTotRange.Len(); }
+ sal_Int32 GetSelectCount() const { return nSelCount; }
void SetTotalRange( const Range& rTotRange );
- void Insert( long nIndex, long nCount = 1 );
- void Remove( long nIndex );
+ void Insert( sal_Int32 nIndex, sal_Int32 nCount = 1 );
+ void Remove( sal_Int32 nIndex );
void Reset();
const Range& GetTotalRange() const { return aTotRange; }
- long FirstSelected();
- long LastSelected();
- long NextSelected();
+ sal_Int32 FirstSelected();
+ sal_Int32 LastSelected();
+ sal_Int32 NextSelected();
- size_t GetRangeCount() const { return aSels.size(); }
- const Range& GetRange( size_t nRange ) const { return *aSels[nRange]; }
+ sal_Int32 GetRangeCount() const { return aSels.size(); }
+ const Range& GetRange( sal_Int32 nRange ) const { return *aSels[nRange]; }
};
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC StringRangeEnumerator
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx
index 275e8c9e5fa7..effe4eecf379 100644
--- a/svtools/source/brwbox/brwbox1.cxx
+++ b/svtools/source/brwbox/brwbox1.cxx
@@ -1644,7 +1644,7 @@ void BrowseBox::SelectAll()
tools::Rectangle aHighlightRect;
sal_uInt16 nVisibleRows =
(sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
- for ( long nRow = std::max( nTopRow, uRow.pSel->FirstSelected() );
+ for ( long nRow = std::max<long>( nTopRow, uRow.pSel->FirstSelected() );
nRow != BROWSER_ENDOFSELECTION && nRow < nTopRow + nVisibleRows;
nRow = uRow.pSel->NextSelected() )
aHighlightRect.Union( tools::Rectangle(
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 7834915260b9..526e3e7d846b 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -709,7 +709,7 @@ void SwScriptInfo::InitScriptInfo( const SwTextNode& rNode, bool bRTL )
CalcHiddenRanges( rNode, aHiddenMulti );
aHiddenChg.clear();
- for( size_t i = 0; i < aHiddenMulti.GetRangeCount(); ++i )
+ for( sal_Int32 i = 0; i < aHiddenMulti.GetRangeCount(); ++i )
{
const Range& rRange = aHiddenMulti.GetRange( i );
const sal_Int32 nStart = rRange.Min();
@@ -1453,7 +1453,7 @@ bool SwScriptInfo::GetBoundsOfHiddenRange( const SwTextNode& rNode, sal_Int32 nP
: 0);
MultiSelection aHiddenMulti( aRange );
SwScriptInfo::CalcHiddenRanges( rNode, aHiddenMulti );
- for( size_t i = 0; i < aHiddenMulti.GetRangeCount(); ++i )
+ for( sal_Int32 i = 0; i < aHiddenMulti.GetRangeCount(); ++i )
{
const Range& rRange = aHiddenMulti.GetRange( i );
const sal_Int32 nHiddenStart = rRange.Min();
@@ -1472,7 +1472,7 @@ bool SwScriptInfo::GetBoundsOfHiddenRange( const SwTextNode& rNode, sal_Int32 nP
if ( pList )
{
- for( size_t i = 0; i < aHiddenMulti.GetRangeCount(); ++i )
+ for( sal_Int32 i = 0; i < aHiddenMulti.GetRangeCount(); ++i )
{
const Range& rRange = aHiddenMulti.GetRange( i );
pList->push_back( rRange.Min() );
diff --git a/sw/source/core/txtnode/modeltoviewhelper.cxx b/sw/source/core/txtnode/modeltoviewhelper.cxx
index d6fe28b621c2..c67727362e58 100644
--- a/sw/source/core/txtnode/modeltoviewhelper.cxx
+++ b/sw/source/core/txtnode/modeltoviewhelper.cxx
@@ -99,7 +99,7 @@ ModelToViewHelper::ModelToViewHelper(const SwTextNode &rNode, ExpandMode eMode)
std::vector<block> aBlocks;
sal_Int32 nShownStart = 0;
- for (size_t i = 0; i < aHiddenMulti.GetRangeCount(); ++i)
+ for (sal_Int32 i = 0; i < aHiddenMulti.GetRangeCount(); ++i)
{
const Range& rRange = aHiddenMulti.GetRange(i);
const sal_Int32 nHiddenStart = rRange.Min();
diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx
index e6f6c0af4e84..dfd2fcfaceb5 100644
--- a/tools/source/memtools/multisel.cxx
+++ b/tools/source/memtools/multisel.cxx
@@ -33,20 +33,20 @@ void MultiSelection::ImplClear()
aSels.clear();
}
-size_t MultiSelection::ImplFindSubSelection( long nIndex ) const
+sal_Int32 MultiSelection::ImplFindSubSelection( sal_Int32 nIndex ) const
{
// iterate through the sub selections
- size_t n = 0;
+ sal_Int32 n = 0;
for ( ;
- n < aSels.size() && nIndex > aSels[ n ]->Max();
+ n < sal_Int32(aSels.size()) && nIndex > aSels[ n ]->Max();
++n ) {} /* empty loop */
return n;
}
-void MultiSelection::ImplMergeSubSelections( size_t nPos1, size_t nPos2 )
+void MultiSelection::ImplMergeSubSelections( sal_Int32 nPos1, sal_Int32 nPos2 )
{
// didn't a sub selection at nPos2 exist?
- if ( nPos2 >= aSels.size() )
+ if ( nPos2 >= sal_Int32(aSels.size()) )
return;
// did the sub selections touch each other?
@@ -148,7 +148,7 @@ void MultiSelection::SelectAll( bool bSelect )
}
}
-bool MultiSelection::Select( long nIndex, bool bSelect )
+bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
{
DBG_ASSERT( aTotRange.IsInside(nIndex), "selected index out of range" );
@@ -157,12 +157,12 @@ bool MultiSelection::Select( long nIndex, bool bSelect )
return false;
// find the virtual target position
- size_t nSubSelPos = ImplFindSubSelection( nIndex );
+ sal_Int32 nSubSelPos = ImplFindSubSelection( nIndex );
if ( bSelect )
{
// is it included in the found sub selection?
- if ( nSubSelPos < aSels.size() && aSels[ nSubSelPos ]->IsInside( nIndex ) )
+ if ( nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos ]->IsInside( nIndex ) )
// already selected, nothing to do
return false;
@@ -180,7 +180,7 @@ bool MultiSelection::Select( long nIndex, bool bSelect )
ImplMergeSubSelections( nSubSelPos-1, nSubSelPos );
}
// is it at the beginning of the found sub selection
- else if ( nSubSelPos < aSels.size()
+ else if ( nSubSelPos < sal_Int32(aSels.size())
&& aSels[ nSubSelPos ]->Min() == (nIndex+1)
)
// expand the found sub selection
@@ -188,7 +188,7 @@ bool MultiSelection::Select( long nIndex, bool bSelect )
else
{
// create a new sub selection
- if ( nSubSelPos < aSels.size() ) {
+ if ( nSubSelPos < sal_Int32(aSels.size()) ) {
ImpSelList::iterator it = aSels.begin();
::std::advance( it, nSubSelPos );
aSels.insert( it, new Range( nIndex, nIndex ) );
@@ -202,7 +202,7 @@ bool MultiSelection::Select( long nIndex, bool bSelect )
else
{
// is it excluded from the found sub selection?
- if ( nSubSelPos >= aSels.size()
+ if ( nSubSelPos >= sal_Int32(aSels.size())
|| !aSels[ nSubSelPos ]->IsInside( nIndex )
) {
// not selected, nothing to do
@@ -233,7 +233,7 @@ bool MultiSelection::Select( long nIndex, bool bSelect )
else
{
// split the sub selection
- if ( nSubSelPos < aSels.size() ) {
+ if ( nSubSelPos < sal_Int32(aSels.size()) ) {
ImpSelList::iterator it = aSels.begin();
::std::advance( it, nSubSelPos );
aSels.insert( it, new Range( aSels[ nSubSelPos ]->Min(), nIndex-1 ) );
@@ -250,12 +250,12 @@ bool MultiSelection::Select( long nIndex, bool bSelect )
void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
{
Range* pRange;
- long nOld;
+ sal_Int32 nOld;
- sal_uIntPtr nTmpMin = rIndexRange.Min();
- sal_uIntPtr nTmpMax = rIndexRange.Max();
- sal_uIntPtr nCurMin = FirstSelected();
- sal_uIntPtr nCurMax = LastSelected();
+ sal_Int32 nTmpMin = rIndexRange.Min();
+ sal_Int32 nTmpMax = rIndexRange.Max();
+ sal_Int32 nCurMin = FirstSelected();
+ sal_Int32 nCurMax = LastSelected();
DBG_ASSERT(aTotRange.IsInside(nTmpMax), "selected index out of range" );
DBG_ASSERT(aTotRange.IsInside(nTmpMin), "selected index out of range" );
@@ -286,7 +286,7 @@ void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
{
pRange = aSels.front();
nOld = pRange->Min();
- pRange->Min() = (long)nTmpMin;
+ pRange->Min() = nTmpMin;
nSelCount += ( nOld - nTmpMin );
}
bCurValid = false;
@@ -309,7 +309,7 @@ void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
{
pRange = aSels.back();
nOld = pRange->Max();
- pRange->Max() = (long)nTmpMax;
+ pRange->Max() = nTmpMax;
nSelCount += ( nTmpMax - nOld );
}
bCurValid = false;
@@ -325,26 +325,26 @@ void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
}
}
-bool MultiSelection::IsSelected( long nIndex ) const
+bool MultiSelection::IsSelected( sal_Int32 nIndex ) const
{
// find the virtual target position
- size_t nSubSelPos = ImplFindSubSelection( nIndex );
+ sal_Int32 nSubSelPos = ImplFindSubSelection( nIndex );
- return nSubSelPos < aSels.size() && aSels[ nSubSelPos ]->IsInside(nIndex);
+ return nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos ]->IsInside(nIndex);
}
-void MultiSelection::Insert( long nIndex, long nCount )
+void MultiSelection::Insert( sal_Int32 nIndex, sal_Int32 nCount )
{
// find the virtual target position
- size_t nSubSelPos = ImplFindSubSelection( nIndex );
+ sal_Int32 nSubSelPos = ImplFindSubSelection( nIndex );
// did we need to shift the sub selections?
- if ( nSubSelPos < aSels.size() )
+ if ( nSubSelPos < sal_Int32(aSels.size()) )
{ // did we insert an unselected into an existing sub selection?
if ( aSels[ nSubSelPos ]->Min() != nIndex
&& aSels[ nSubSelPos ]->IsInside(nIndex)
) { // split the sub selection
- if ( nSubSelPos < aSels.size() ) {
+ if ( nSubSelPos < sal_Int32(aSels.size()) ) {
ImpSelList::iterator it = aSels.begin();
::std::advance( it, nSubSelPos );
aSels.insert( it, new Range( aSels[ nSubSelPos ]->Min(), nIndex-1 ) );
@@ -356,7 +356,7 @@ void MultiSelection::Insert( long nIndex, long nCount )
}
// shift the sub selections behind the inserting position
- for ( size_t nPos = nSubSelPos; nPos < aSels.size(); ++nPos )
+ for ( sal_Int32 nPos = nSubSelPos; nPos < sal_Int32(aSels.size()); ++nPos )
{
aSels[ nPos ]->Min() += nCount;
aSels[ nPos ]->Max() += nCount;
@@ -367,13 +367,13 @@ void MultiSelection::Insert( long nIndex, long nCount )
aTotRange.Max() += nCount;
}
-void MultiSelection::Remove( long nIndex )
+void MultiSelection::Remove( sal_Int32 nIndex )
{
// find the virtual target position
- size_t nSubSelPos = ImplFindSubSelection( nIndex );
+ sal_Int32 nSubSelPos = ImplFindSubSelection( nIndex );
// did we remove from an existing sub selection?
- if ( nSubSelPos < aSels.size()
+ if ( nSubSelPos < sal_Int32(aSels.size())
&& aSels[ nSubSelPos ]->IsInside(nIndex)
) {
// does this sub selection only contain the index to be deleted
@@ -393,7 +393,7 @@ void MultiSelection::Remove( long nIndex )
}
// shift the sub selections behind the removed index
- for ( size_t nPos = nSubSelPos; nPos < aSels.size(); ++nPos )
+ for ( sal_Int32 nPos = nSubSelPos; nPos < sal_Int32(aSels.size()); ++nPos )
{
--( aSels[ nPos ]->Min() );
--( aSels[ nPos ]->Max() );
@@ -403,12 +403,12 @@ void MultiSelection::Remove( long nIndex )
aTotRange.Max() -= 1;
}
-long MultiSelection::ImplFwdUnselected()
+sal_Int32 MultiSelection::ImplFwdUnselected()
{
if ( !bCurValid )
return SFX_ENDOFSELECTION;
- if ( ( nCurSubSel < aSels.size() )
+ if ( ( nCurSubSel < sal_Int32(aSels.size()) )
&& ( aSels[ nCurSubSel ]->Min() <= nCurIndex )
)
nCurIndex = aSels[ nCurSubSel++ ]->Max() + 1;
@@ -419,7 +419,7 @@ long MultiSelection::ImplFwdUnselected()
return SFX_ENDOFSELECTION;
}
-long MultiSelection::FirstSelected()
+sal_Int32 MultiSelection::FirstSelected()
{
bInverseCur = false;
nCurSubSel = 0;
@@ -431,7 +431,7 @@ long MultiSelection::FirstSelected()
return SFX_ENDOFSELECTION;
}
-long MultiSelection::LastSelected()
+sal_Int32 MultiSelection::LastSelected()
{
nCurSubSel = aSels.size() - 1;
bCurValid = !aSels.empty();
@@ -442,7 +442,7 @@ long MultiSelection::LastSelected()
return SFX_ENDOFSELECTION;
}
-long MultiSelection::NextSelected()
+sal_Int32 MultiSelection::NextSelected()
{
if ( !bCurValid )
return SFX_ENDOFSELECTION;
@@ -459,7 +459,7 @@ long MultiSelection::NextSelected()
return ++nCurIndex;
// are there further sub selections?
- if ( ++nCurSubSel < aSels.size() )
+ if ( ++nCurSubSel < sal_Int32(aSels.size()) )
return nCurIndex = aSels[ nCurSubSel ]->Min();
// we are at the end!
@@ -492,7 +492,7 @@ void MultiSelection::SetTotalRange( const Range& rTotRange )
}
// adjust upper boundary
- size_t nCount = aSels.size();
+ sal_Int32 nCount = aSels.size();
while( nCount )
{
pRange = aSels[ nCount - 1 ];