Kaydet (Commit) 2fdd5760 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Complete the transition of SwRedlineTable::size_type

...from 9ca8a63f "Use consistent integer types
in the SwRedlineTable interface".  This all started as an attempt to reduce the
number of places a to-be-committed improved loplugin:loopvartoosmall complains
about.  Lets see where it ends...

SwRedlineTable::size_type is now the size_type of the underlying std::vector, no
longer sal_uInt16 from ancient times.  I tried hard to find all places that are
affected by this change, changing types of affected variables and non-static
data members as needed.  Some notes:

* The original code used USHRT_MAX as a "not found" value.  I replaced that with
  a new SwRedlineTable::npos, of type SwRedlineTable::size_type but still for
  now of value USHRT_MAX.  This should eventually be changed to something more
  sensible, like std::numeric_limits<SwRedlineTable::size_type>::max() (which is
  best done after we have constexpr support in all toolchains, so that npos can
  be constexpr).  It is important that the value of npos is towards positive
  infinity, as many places in the code use

    for (i = f(); // may return npos
         i < table.size(); ++i)
      table[i] ...

* There are some borders where values of SwRedlineTable::size_type are converted
  into different types, for various reasons.  But all of those other types
  should be large enough for practical purposes (at least 32 bits wide):

    MakrEntry::m_nIdx: long int
    SvxRedlinTable::InsertEntry: sal_uIntPtr nPos
    SwRangeRedline: size_t
    SwRedlineItr: sal_Int32
    SwVbaRevision::GetPosition: sal_Int32
    SwXRedlines: sal_Int32

* .uno:TrackedChangeIndex= transports textual representations of such values.
   libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx treats them purely as
   strings, while SwTiledRenderingTest converts them to int.

* TODO:  The one place I'm unsure about is SfxUInt16Items with IDs
  FN_REDLINE_ACCEPT_DIRECT, FN_REDLINE_REJECT_DIRECT, and FN_REDLINE_NEXT_CHANGE
  in sw/source/uibase/uiview/view2.cxx.  For now, I kept those as
  SfxUInt16Items and take care to "map" USHRT_MAX to npos when reading from
  those items.  But I have no idea where instances of those items would actually
  be created, and what it would mean to change those items' types?

Change-Id: Ib7a14dc67e2b970766966e43f4732abd9f045ff8
Reviewed-on: https://gerrit.libreoffice.org/34775Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 64cca8d6
......@@ -28,6 +28,8 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <docary.hxx>
class SwRangeRedline;
class SwTableRowRedline;
class SwTableCellRedline;
......@@ -163,7 +165,7 @@ public:
/*[in]*/bool bSaveInUndo,
/*[in]*/sal_uInt16 nDelType) = 0;
virtual sal_uInt16 GetRedlinePos(
virtual SwRedlineTable::size_type GetRedlinePos(
/*[in]*/const SwNode& rNode,
/*[in]*/sal_uInt16 nType) const = 0;
......@@ -171,17 +173,17 @@ public:
virtual const SwRangeRedline* GetRedline(
/*[in]*/const SwPosition& rPos,
/*[in]*/sal_uInt16* pFndPos) const = 0;
/*[in]*/SwRedlineTable::size_type* pFndPos) const = 0;
virtual bool IsRedlineMove() const = 0;
virtual void SetRedlineMove(/*[in]*/bool bFlag) = 0;
virtual bool AcceptRedline(/*[in]*/sal_uInt16 nPos, /*[in]*/bool bCallDelete) = 0;
virtual bool AcceptRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) = 0;
virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) = 0;
virtual bool RejectRedline(/*[in]*/sal_uInt16 nPos, /*[in]*/bool bCallDelete) = 0;
virtual bool RejectRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) = 0;
virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) = 0;
......
......@@ -28,6 +28,7 @@
#include <IShellCursorSupplier.hxx>
#include "swdllapi.h"
#include <docary.hxx>
#include <swtypes.hxx>
#include <viewsh.hxx>
#include <calbck.hxx>
......@@ -267,7 +268,7 @@ private:
typedef bool (SwCursor:: *FNCursor)();
SAL_DLLPRIVATE bool CallCursorFN( FNCursor );
SAL_DLLPRIVATE const SwRangeRedline* GotoRedline_( sal_uInt16 nArrPos, bool bSelect );
SAL_DLLPRIVATE const SwRangeRedline* GotoRedline_( SwRedlineTable::size_type nArrPos, bool bSelect );
protected:
......@@ -797,7 +798,7 @@ public:
const SwRangeRedline* SelNextRedline();
const SwRangeRedline* SelPrevRedline();
const SwRangeRedline* GotoRedline( sal_uInt16 nArrPos, bool bSelect );
const SwRangeRedline* GotoRedline( SwRedlineTable::size_type nArrPos, bool bSelect );
// is cursor or the point in/over a vertical formatted text?
bool IsInVerticalText( const Point* pPt = nullptr ) const;
......
......@@ -318,35 +318,34 @@ class SwRedlineTable
public:
typedef o3tl::sorted_vector<SwRangeRedline*, CompareSwRedlineTable,
o3tl::find_partialorder_ptrequals> vector_type;
typedef sal_uInt16 size_type;
//TOOD: should be vector_type::size_type, but then all the uses of
// sal_uInt16 in this class that represent positions in maVector need to
// be changed, too
typedef vector_type::size_type size_type;
static SAL_CONSTEXPR size_type const npos = USHRT_MAX;
//TODO: std::numeric_limits<size_type>::max()
private:
vector_type maVector;
public:
~SwRedlineTable();
bool Contains(const SwRangeRedline* p) const { return maVector.find(const_cast<SwRangeRedline* const>(p)) != maVector.end(); }
sal_uInt16 GetPos(const SwRangeRedline* p) const;
size_type GetPos(const SwRangeRedline* p) const;
bool Insert( SwRangeRedline* p );
bool Insert( SwRangeRedline* p, sal_uInt16& rInsPos );
bool InsertWithValidRanges( SwRangeRedline* p, sal_uInt16* pInsPos = nullptr );
bool Insert( SwRangeRedline* p, size_type& rInsPos );
bool InsertWithValidRanges( SwRangeRedline* p, size_type* pInsPos = nullptr );
void Remove( sal_uInt16 nPos );
void Remove( size_type nPos );
bool Remove( const SwRangeRedline* p );
void DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen = 1 );
void DeleteAndDestroy( size_type nPos, size_type nLen = 1 );
void DeleteAndDestroyAll();
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
sal_uInt16 FindNextOfSeqNo( sal_uInt16 nSttPos ) const;
sal_uInt16 FindPrevOfSeqNo( sal_uInt16 nSttPos ) const;
size_type FindNextOfSeqNo( size_type nSttPos ) const;
size_type FindPrevOfSeqNo( size_type nSttPos ) const;
/** Search next or previous Redline with the same Seq. No.
Search can be restricted via Lookahead.
Using 0 makes search the whole array. */
sal_uInt16 FindNextSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos ) const;
sal_uInt16 FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos ) const;
size_type FindNextSeqNo( sal_uInt16 nSeqNo, size_type nSttPos ) const;
size_type FindPrevSeqNo( sal_uInt16 nSeqNo, size_type nSttPos ) const;
/**
Find the redline at the given position.
......@@ -355,7 +354,7 @@ public:
redline (or the next redline after the given position if not found)
@param next true: redline starts at position and ends after, false: redline starts before position and ends at or after
*/
const SwRangeRedline* FindAtPosition( const SwPosition& startPosition, sal_uInt16& tableIndex, bool next = true ) const;
const SwRangeRedline* FindAtPosition( const SwPosition& startPosition, size_type& tableIndex, bool next = true ) const;
bool empty() const { return maVector.empty(); }
size_type size() const { return maVector.size(); }
......
......@@ -889,16 +889,16 @@ public:
RedlineFlags GetRedlineFlags() const;
void SetRedlineFlags( RedlineFlags eMode );
bool IsRedlineOn() const;
sal_uInt16 GetRedlineCount() const;
const SwRangeRedline& GetRedline( sal_uInt16 nPos ) const;
bool AcceptRedline( sal_uInt16 nPos );
bool RejectRedline( sal_uInt16 nPos );
SwRedlineTable::size_type GetRedlineCount() const;
const SwRangeRedline& GetRedline( SwRedlineTable::size_type nPos ) const;
bool AcceptRedline( SwRedlineTable::size_type nPos );
bool RejectRedline( SwRedlineTable::size_type nPos );
bool AcceptRedlinesInSelection();
bool RejectRedlinesInSelection();
/** Search Redline for this Data and @return position in array.
If not found, return USHRT_MAX. */
sal_uInt16 FindRedlineOfData( const SwRedlineData& ) const;
If not found, return SwRedlineTable::npos. */
SwRedlineTable::size_type FindRedlineOfData( const SwRedlineData& ) const;
/// Set comment to Redline at position.
bool SetRedlineComment( const OUString& rS );
......
......@@ -19,6 +19,9 @@
#ifndef INCLUDED_SW_INC_UNOREDLINES_HXX
#define INCLUDED_SW_INC_UNOREDLINES_HXX
#include <sal/config.h>
#include <docary.hxx>
#include <unocoll.hxx>
#include <unobaseclass.hxx>
#include <com/sun/star/container/XEnumerationAccess.hpp>
......@@ -69,7 +72,7 @@ class SwXRedlineEnumeration
, public SwClient
{
SwDoc* pDoc;
sal_uInt16 nCurrentIndex;
SwRedlineTable::size_type nCurrentIndex;
protected:
virtual ~SwXRedlineEnumeration() override;
public:
......
......@@ -56,9 +56,9 @@ namespace {
return;
}
const sal_uInt16 nIdxOfFirstRedlineForTextNode =
const SwRedlineTable::size_type nIdxOfFirstRedlineForTextNode =
rIDocChangeTrack.GetRedlinePos( rTextNode, USHRT_MAX );
if ( nIdxOfFirstRedlineForTextNode == USHRT_MAX )
if ( nIdxOfFirstRedlineForTextNode == SwRedlineTable::npos )
{
// nothing to do --> empty change track text markup lists.
return;
......@@ -73,8 +73,8 @@ namespace {
// iteration over the redlines which overlap with the text node.
const SwRedlineTable& rRedlineTable = rIDocChangeTrack.GetRedlineTable();
const sal_uInt16 nRedlineCount( rRedlineTable.size() );
for ( sal_uInt16 nActRedline = nIdxOfFirstRedlineForTextNode;
const SwRedlineTable::size_type nRedlineCount( rRedlineTable.size() );
for ( SwRedlineTable::size_type nActRedline = nIdxOfFirstRedlineForTextNode;
nActRedline < nRedlineCount;
++nActRedline)
{
......
......@@ -2009,7 +2009,7 @@ const SwRangeRedline* SwCursorShell::SelPrevRedline()
return pFnd;
}
const SwRangeRedline* SwCursorShell::GotoRedline_( sal_uInt16 nArrPos, bool bSelect )
const SwRangeRedline* SwCursorShell::GotoRedline_( SwRedlineTable::size_type nArrPos, bool bSelect )
{
const SwRangeRedline* pFnd = nullptr;
SwCallLink aLk( *this ); // watch Cursor-Moves
......@@ -2077,7 +2077,7 @@ const SwRangeRedline* SwCursorShell::GotoRedline_( sal_uInt16 nArrPos, bool bSel
return pFnd;
}
const SwRangeRedline* SwCursorShell::GotoRedline( sal_uInt16 nArrPos, bool bSelect )
const SwRangeRedline* SwCursorShell::GotoRedline( SwRedlineTable::size_type nArrPos, bool bSelect )
{
const SwRangeRedline* pFnd = nullptr;
if( !IsTableMode() )
......@@ -2091,7 +2091,7 @@ const SwRangeRedline* SwCursorShell::GotoRedline( sal_uInt16 nArrPos, bool bSele
{
bool bCheck = false;
int nLoopCnt = 2;
sal_uInt16 nArrSavPos = nArrPos;
SwRedlineTable::size_type nArrSavPos = nArrPos;
do {
pTmp = GotoRedline_( nArrPos, true );
......@@ -2160,11 +2160,11 @@ const SwRangeRedline* SwCursorShell::GotoRedline( sal_uInt16 nArrPos, bool bSele
}
}
sal_uInt16 nFndPos = 2 == nLoopCnt
SwRedlineTable::size_type nFndPos = 2 == nLoopCnt
? rTable.FindNextOfSeqNo( nArrPos )
: rTable.FindPrevOfSeqNo( nArrPos );
if( USHRT_MAX != nFndPos ||
( 0 != ( --nLoopCnt ) && USHRT_MAX != (
if( SwRedlineTable::npos != nFndPos ||
( 0 != ( --nLoopCnt ) && SwRedlineTable::npos != (
nFndPos = rTable.FindPrevOfSeqNo( nArrSavPos ))) )
{
if( pTmp )
......
......@@ -1431,7 +1431,7 @@ static OUString lcl_MaskDeletedRedlines( const SwTextNode* pTextNd )
const bool bShowChg = IDocumentRedlineAccess::IsShowChanges( rDoc.getIDocumentRedlineAccess().GetRedlineFlags() );
if ( bShowChg )
{
sal_uInt16 nAct = rDoc.getIDocumentRedlineAccess().GetRedlinePos( *pTextNd, USHRT_MAX );
SwRedlineTable::size_type nAct = rDoc.getIDocumentRedlineAccess().GetRedlinePos( *pTextNd, USHRT_MAX );
for ( ; nAct < rDoc.getIDocumentRedlineAccess().GetRedlineTable().size(); nAct++ )
{
const SwRangeRedline* pRed = rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ nAct ];
......
......@@ -335,7 +335,7 @@ namespace
sal_uLong nDelCount;
SwNodeIndex aCorrIdx(InitDelCount(rPam, nDelCount));
sal_uInt16 n = 0;
SwRedlineTable::size_type n = 0;
pSrcDoc->getIDocumentRedlineAccess().GetRedline( *pStt, &n );
for( ; n < rTable.size(); ++n )
{
......@@ -663,7 +663,7 @@ namespace
const SwPosition* pEnd = aPam.End();
// get first relevant redline
sal_uInt16 nCurrentRedline;
SwRedlineTable::size_type nCurrentRedline;
pDoc->getIDocumentRedlineAccess().GetRedline( *pStart, &nCurrentRedline );
if( nCurrentRedline > 0)
nCurrentRedline--;
......@@ -738,7 +738,7 @@ namespace
void lcl_SaveRedlines(const SwNodeRange& rRg, SaveRedlines_t& rArr)
{
SwDoc* pDoc = rRg.aStart.GetNode().GetDoc();
sal_uInt16 nRedlPos;
SwRedlineTable::size_type nRedlPos;
SwPosition aSrchPos( rRg.aStart ); aSrchPos.nNode--;
aSrchPos.nContent.Assign( aSrchPos.nNode.GetNode().GetContentNode(), 0 );
if( pDoc->getIDocumentRedlineAccess().GetRedline( aSrchPos, &nRedlPos ) && nRedlPos )
......@@ -2222,8 +2222,8 @@ bool DocumentContentOperationsManager::MoveNodeRange( SwNodeRange& rRange, SwNod
// Find all RedLines that end at the InsPos.
// These have to be moved back to the "old" position after the Move.
sal_uInt16 nRedlPos = m_rDoc.getIDocumentRedlineAccess().GetRedlinePos( rPos.GetNode(), USHRT_MAX );
if( USHRT_MAX != nRedlPos )
SwRedlineTable::size_type nRedlPos = m_rDoc.getIDocumentRedlineAccess().GetRedlinePos( rPos.GetNode(), USHRT_MAX );
if( SwRedlineTable::npos != nRedlPos )
{
const SwPosition *pRStt, *pREnd;
do {
......
......@@ -1950,7 +1950,7 @@ sal_uInt16 SaveMergeRedline::InsertRedline(SwPaM* pLastDestRedline)
// If there already is a deleted or inserted one at the same position, we have to split it!
SwPosition* pDStt = pDestRedl->GetMark(),
* pDEnd = pDestRedl->GetPoint();
sal_uInt16 n = 0;
SwRedlineTable::size_type n = 0;
// find the first redline for StartPos
if( !pDoc->getIDocumentRedlineAccess().GetRedline( *pDStt, &n ) && n )
......@@ -2008,7 +2008,7 @@ sal_uInt16 SaveMergeRedline::InsertRedline(SwPaM* pLastDestRedline)
*pDStt = *pREnd;
// we should start over now
n = USHRT_MAX;
n = SwRedlineTable::npos;
}
break;
......
......@@ -246,7 +246,7 @@ SaveRedlEndPosForRestore::SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx,
SwDoc* pDest = rNd.GetDoc();
if( !pDest->getIDocumentRedlineAccess().GetRedlineTable().empty() )
{
sal_uInt16 nFndPos;
SwRedlineTable::size_type nFndPos;
const SwPosition* pEnd;
SwPosition aSrcPos( rInsIdx, SwIndex( rNd.GetContentNode(), nCnt ));
pDest->getIDocumentRedlineAccess().GetRedline( aSrcPos, &nFndPos );
......
......@@ -1796,8 +1796,8 @@ bool SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, bool bIsOutlMv )
// Test for Redlining - Can the Selection be moved at all, actually?
if( !getIDocumentRedlineAccess().IsIgnoreRedline() )
{
sal_uInt16 nRedlPos = getIDocumentRedlineAccess().GetRedlinePos( pStt->nNode.GetNode(), nsRedlineType_t::REDLINE_DELETE );
if( USHRT_MAX != nRedlPos )
SwRedlineTable::size_type nRedlPos = getIDocumentRedlineAccess().GetRedlinePos( pStt->nNode.GetNode(), nsRedlineType_t::REDLINE_DELETE );
if( SwRedlineTable::npos != nRedlPos )
{
SwPosition aStPos( *pStt ), aEndPos( *pEnd );
aStPos.nContent = 0;
......@@ -1853,8 +1853,8 @@ bool SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, bool bIsOutlMv )
if( getIDocumentRedlineAccess().IsRedlineOn() )
{
// If the range is completely in the own Redline, we can move it!
sal_uInt16 nRedlPos = getIDocumentRedlineAccess().GetRedlinePos( pStt->nNode.GetNode(), nsRedlineType_t::REDLINE_INSERT );
if( USHRT_MAX != nRedlPos )
SwRedlineTable::size_type nRedlPos = getIDocumentRedlineAccess().GetRedlinePos( pStt->nNode.GetNode(), nsRedlineType_t::REDLINE_INSERT );
if( SwRedlineTable::npos != nRedlPos )
{
SwRangeRedline* pTmp = getIDocumentRedlineAccess().GetRedlineTable()[ nRedlPos ];
const SwPosition *pRStt = pTmp->Start(), *pREnd = pTmp->End();
......@@ -1870,7 +1870,7 @@ bool SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, bool bIsOutlMv )
: !pREnd->nContent.GetIndex() )) )
{
pOwnRedl = pTmp;
if( nRedlPos + 1 < (sal_uInt16)getIDocumentRedlineAccess().GetRedlineTable().size() )
if( nRedlPos + 1 < getIDocumentRedlineAccess().GetRedlineTable().size() )
{
pTmp = getIDocumentRedlineAccess().GetRedlineTable()[ nRedlPos+1 ];
if( *pTmp->Start() == *pREnd )
......
......@@ -301,7 +301,7 @@ bool SwExtraRedlineTable::DeleteTableCellRedline( SwDoc* pDoc, const SwTableBox&
}
/// Emits LOK notification about one addition / removal of a redline item.
static void lcl_RedlineNotification(RedlineNotification nType, size_t nPos, SwRangeRedline* pRedline)
static void lcl_RedlineNotification(RedlineNotification nType, SwRedlineTable::size_type nPos, SwRangeRedline* pRedline)
{
if (!comphelper::LibreOfficeKit::isActive())
return;
......@@ -336,7 +336,7 @@ bool SwRedlineTable::Insert( SwRangeRedline* p )
if( p->HasValidRange() )
{
std::pair<vector_type::const_iterator, bool> rv = maVector.insert( p );
size_t nP = rv.first - begin();
size_type nP = rv.first - begin();
lcl_RedlineNotification(RedlineNotification::Add, nP, p);
p->CallDisplayFunc(nP);
return rv.second;
......@@ -344,7 +344,7 @@ bool SwRedlineTable::Insert( SwRangeRedline* p )
return InsertWithValidRanges( p );
}
bool SwRedlineTable::Insert( SwRangeRedline* p, sal_uInt16& rP )
bool SwRedlineTable::Insert( SwRangeRedline* p, size_type& rP )
{
if( p->HasValidRange() )
{
......@@ -356,7 +356,7 @@ bool SwRedlineTable::Insert( SwRangeRedline* p, sal_uInt16& rP )
return InsertWithValidRanges( p, &rP );
}
bool SwRedlineTable::InsertWithValidRanges( SwRangeRedline* p, sal_uInt16* pInsPos )
bool SwRedlineTable::InsertWithValidRanges( SwRangeRedline* p, size_type* pInsPos )
{
// Create valid "sub-ranges" from the Selection
bool bAnyIns = false;
......@@ -376,7 +376,7 @@ bool SwRedlineTable::InsertWithValidRanges( SwRangeRedline* p, sal_uInt16* pInsP
}
SwRangeRedline* pNew = nullptr;
sal_uInt16 nInsPos;
size_type nInsPos;
if( aNewStt < *pEnd )
do {
......@@ -478,24 +478,24 @@ SwRedlineTable::~SwRedlineTable()
maVector.DeleteAndDestroyAll();
}
sal_uInt16 SwRedlineTable::GetPos(const SwRangeRedline* p) const
SwRedlineTable::size_type SwRedlineTable::GetPos(const SwRangeRedline* p) const
{
vector_type::const_iterator it = maVector.find(const_cast<SwRangeRedline* const>(p));
if( it == maVector.end() )
return USHRT_MAX;
return npos;
return it - maVector.begin();
}
bool SwRedlineTable::Remove( const SwRangeRedline* p )
{
const sal_uInt16 nPos = GetPos(p);
if (nPos == USHRT_MAX)
const size_type nPos = GetPos(p);
if (nPos == npos)
return false;
Remove(nPos);
return true;
}
void SwRedlineTable::Remove( sal_uInt16 nP )
void SwRedlineTable::Remove( size_type nP )
{
lcl_RedlineNotification(RedlineNotification::Remove, nP, maVector[nP]);
SwDoc* pDoc = nullptr;
......@@ -515,7 +515,7 @@ void SwRedlineTable::DeleteAndDestroyAll()
DeleteAndDestroy(0, size());
}
void SwRedlineTable::DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL )
void SwRedlineTable::DeleteAndDestroy( size_type nP, size_type nL )
{
SwDoc* pDoc = nullptr;
if( !nP && nL && nL == size() )
......@@ -536,29 +536,29 @@ void SwRedlineTable::DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL )
pSh->InvalidateWindows( SwRect( 0, 0, SAL_MAX_INT32, SAL_MAX_INT32 ) );
}
sal_uInt16 SwRedlineTable::FindNextOfSeqNo( sal_uInt16 nSttPos ) const
SwRedlineTable::size_type SwRedlineTable::FindNextOfSeqNo( size_type nSttPos ) const
{
return static_cast<size_t>(nSttPos) + 1 < size()
return nSttPos + 1 < size()
? FindNextSeqNo( operator[]( nSttPos )->GetSeqNo(), nSttPos+1 )
: USHRT_MAX;
: npos;
}
sal_uInt16 SwRedlineTable::FindPrevOfSeqNo( sal_uInt16 nSttPos ) const
SwRedlineTable::size_type SwRedlineTable::FindPrevOfSeqNo( size_type nSttPos ) const
{
return nSttPos ? FindPrevSeqNo( operator[]( nSttPos )->GetSeqNo(), nSttPos-1 )
: USHRT_MAX;
: npos;
}
/// Find the next or preceding Redline with the same seq.no.
/// We can limit the search using look ahead (0 searches the whole array).
sal_uInt16 SwRedlineTable::FindNextSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos ) const
SwRedlineTable::size_type SwRedlineTable::FindNextSeqNo( sal_uInt16 nSeqNo, size_type nSttPos ) const
{
sal_uInt16 nLookahead = 20;
sal_uInt16 nRet = USHRT_MAX;
auto const nLookahead = 20;
size_type nRet = npos;
if( nSeqNo && nSttPos < size() )
{
size_t nEnd = size();
const size_t nTmp = static_cast<size_t>(nSttPos)+ static_cast<size_t>(nLookahead);
size_type nEnd = size();
const size_type nTmp = nSttPos + nLookahead;
if (nTmp < nEnd)
{
nEnd = nTmp;
......@@ -574,13 +574,13 @@ sal_uInt16 SwRedlineTable::FindNextSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos
return nRet;
}
sal_uInt16 SwRedlineTable::FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos ) const
SwRedlineTable::size_type SwRedlineTable::FindPrevSeqNo( sal_uInt16 nSeqNo, size_type nSttPos ) const
{
sal_uInt16 nLookahead = 20;
sal_uInt16 nRet = USHRT_MAX;
auto const nLookahead = 20;
size_type nRet = npos;
if( nSeqNo && nSttPos < size() )
{
size_t nEnd = 0;
size_type nEnd = 0;
if( nSttPos > nLookahead )
nEnd = nSttPos - nLookahead;
......@@ -596,7 +596,7 @@ sal_uInt16 SwRedlineTable::FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos
}
const SwRangeRedline* SwRedlineTable::FindAtPosition( const SwPosition& rSttPos,
sal_uInt16& rPos,
size_type& rPos,
bool bNext ) const
{
const SwRangeRedline* pFnd = nullptr;
......
......@@ -1283,7 +1283,7 @@ static SpellContentPositions lcl_CollectDeletedRedlines(SwEditShell* pSh)
const SwPosition* pStartPos = pCursor->Start();
const SwTextNode* pTextNode = pCursor->GetNode().GetTextNode();
sal_uInt16 nAct = pDoc->getIDocumentRedlineAccess().GetRedlinePos( *pTextNode, USHRT_MAX );
SwRedlineTable::size_type nAct = pDoc->getIDocumentRedlineAccess().GetRedlinePos( *pTextNode, USHRT_MAX );
const sal_Int32 nStartIndex = pStartPos->nContent.GetIndex();
for ( ; nAct < pDoc->getIDocumentRedlineAccess().GetRedlineTable().size(); nAct++ )
{
......
......@@ -47,12 +47,12 @@ bool SwEditShell::IsRedlineOn() const
return GetDoc()->getIDocumentRedlineAccess().IsRedlineOn();
}
sal_uInt16 SwEditShell::GetRedlineCount() const
SwRedlineTable::size_type SwEditShell::GetRedlineCount() const
{
return GetDoc()->getIDocumentRedlineAccess().GetRedlineTable().size();
}
const SwRangeRedline& SwEditShell::GetRedline( sal_uInt16 nPos ) const
const SwRangeRedline& SwEditShell::GetRedline( SwRedlineTable::size_type nPos ) const
{
return *GetDoc()->getIDocumentRedlineAccess().GetRedlineTable()[ nPos ];
}
......@@ -66,7 +66,7 @@ static void lcl_InvalidateAll( SwViewShell* pSh )
}
}
bool SwEditShell::AcceptRedline( sal_uInt16 nPos )
bool SwEditShell::AcceptRedline( SwRedlineTable::size_type nPos )
{
SET_CURR_SHELL( this );
StartAllAction();
......@@ -77,7 +77,7 @@ bool SwEditShell::AcceptRedline( sal_uInt16 nPos )
return bRet;
}
bool SwEditShell::RejectRedline( sal_uInt16 nPos )
bool SwEditShell::RejectRedline( SwRedlineTable::size_type nPos )
{
SET_CURR_SHELL( this );
StartAllAction();
......@@ -138,16 +138,16 @@ void SwEditShell::UpdateRedlineAttr()
/** Search the Redline of the data given
*
* @return Returns the Pos of the Array, or USHRT_MAX if not present
* @return Returns the Pos of the Array, or SwRedlineTable::npos if not present
*/
sal_uInt16 SwEditShell::FindRedlineOfData( const SwRedlineData& rData ) const
SwRedlineTable::size_type SwEditShell::FindRedlineOfData( const SwRedlineData& rData ) const
{
const SwRedlineTable& rTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
for( sal_uInt16 i = 0, nCnt = rTable.size(); i < nCnt; ++i )
for( SwRedlineTable::size_type i = 0, nCnt = rTable.size(); i < nCnt; ++i )
if( &rTable[ i ]->GetRedlineData() == &rData )
return i;
return USHRT_MAX;
return SwRedlineTable::npos;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -67,7 +67,7 @@ public:
/*[in]*/bool bSaveInUndo,
/*[in]*/sal_uInt16 nDelType) override;
virtual sal_uInt16 GetRedlinePos(
virtual SwRedlineTable::size_type GetRedlinePos(
/*[in]*/const SwNode& rNode,
/*[in]*/sal_uInt16 nType) const override;
......@@ -75,17 +75,17 @@ public:
virtual const SwRangeRedline* GetRedline(
/*[in]*/const SwPosition& rPos,
/*[in]*/sal_uInt16* pFndPos) const override;
/*[in]*/SwRedlineTable::size_type* pFndPos) const override;
virtual bool IsRedlineMove() const override;
virtual void SetRedlineMove(/*[in]*/bool bFlag) override;
virtual bool AcceptRedline(/*[in]*/sal_uInt16 nPos, /*[in]*/bool bCallDelete) override;
virtual bool AcceptRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) override;
virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) override;
virtual bool RejectRedline(/*[in]*/sal_uInt16 nPos, /*[in]*/bool bCallDelete) override;
virtual bool RejectRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) override;
virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) override;
......
......@@ -387,7 +387,7 @@ void SwTextFrame::PaintExtraData( const SwRect &rRect ) const
}
else
{
if ( USHRT_MAX == rIDRA.GetRedlinePos(rTextNode, USHRT_MAX) )
if ( SwRedlineTable::npos == rIDRA.GetRedlinePos(rTextNode, USHRT_MAX) )
bRedLine = false;
if( bLineNum && rLineInf.IsCountBlankLines() &&
......@@ -484,8 +484,8 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const
const IDocumentRedlineAccess& rIDRA = rTextNode.getIDocumentRedlineAccess();
if( IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) )
{
const sal_uInt16 nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
if( USHRT_MAX != nRedlPos )
const SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
if( SwRedlineTable::npos != nRedlPos )
{
SwAttrHandler aAttrHandler;
aAttrHandler.Init( rTextNode.GetSwAttrSet(),
......
......@@ -2162,7 +2162,7 @@ void SwScriptInfo::selectRedLineDeleted(const SwTextNode& rNode, MultiSelection
const IDocumentRedlineAccess& rIDRA = rNode.getIDocumentRedlineAccess();
if ( IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) )
{
sal_uInt16 nAct = rIDRA.GetRedlinePos( rNode, USHRT_MAX );
SwRedlineTable::size_type nAct = rIDRA.GetRedlinePos( rNode, USHRT_MAX );
for ( ; nAct < rIDRA.GetRedlineTable().size(); nAct++ )
{
......
......@@ -252,8 +252,8 @@ SwTwips SwTextFrame::EmptyHeight() const
const IDocumentRedlineAccess& rIDRA = rTextNode.getIDocumentRedlineAccess();
if( IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) )
{
const sal_uInt16 nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
if( USHRT_MAX != nRedlPos )
const SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
if( SwRedlineTable::npos != nRedlPos )
{
SwAttrHandler aAttrHandler;
aAttrHandler.Init( GetTextNode()->GetSwAttrSet(),
......
......@@ -134,8 +134,8 @@ void SwAttrIter::CtorInitAttrIter( SwTextNode& rTextNode, SwScriptInfo& rScrInf,
const bool bShow = IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() );
if( pExtInp || bShow )
{
const sal_uInt16 nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
if( pExtInp || USHRT_MAX != nRedlPos )
const SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
if( pExtInp || SwRedlineTable::npos != nRedlPos )
{
const std::vector<ExtTextInputAttr> *pArr = nullptr;
sal_Int32 nInputStt = 0;
......
......@@ -3212,8 +3212,8 @@ OUString SwTextNode::GetRedlineText() const
{
std::vector<sal_Int32> aRedlArr;
const SwDoc* pDoc = GetDoc();
sal_uInt16 nRedlPos = pDoc->getIDocumentRedlineAccess().GetRedlinePos( *this, nsRedlineType_t::REDLINE_DELETE );
if( USHRT_MAX != nRedlPos )
SwRedlineTable::size_type nRedlPos = pDoc->getIDocumentRedlineAccess().GetRedlinePos( *this, nsRedlineType_t::REDLINE_DELETE );
if( SwRedlineTable::npos != nRedlPos )
{
// some redline-delete object exists for the node
const sal_uLong nNdIdx = GetIndex();
......
......@@ -135,7 +135,7 @@ lcl_MaskRedlines( const SwTextNode& rNode, OUStringBuffer& rText,
const SwDoc& rDoc = *rNode.GetDoc();
for ( size_t nAct = rDoc.getIDocumentRedlineAccess().GetRedlinePos( rNode, USHRT_MAX ); nAct < rDoc.getIDocumentRedlineAccess().GetRedlineTable().size(); ++nAct )
for ( SwRedlineTable::size_type nAct = rDoc.getIDocumentRedlineAccess().GetRedlinePos( rNode, USHRT_MAX ); nAct < rDoc.getIDocumentRedlineAccess().GetRedlineTable().size(); ++nAct )
{
const SwRangeRedline* pRed = rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ nAct ];
......
......@@ -999,7 +999,7 @@ bool SwUndo::FillSaveData(
const SwPosition* pStt = rRange.Start();
const SwPosition* pEnd = rRange.End();
const SwRedlineTable& rTable = rRange.GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
sal_uInt16 n = 0;
SwRedlineTable::size_type n = 0;
rRange.GetDoc()->getIDocumentRedlineAccess().GetRedline( *pStt, &n );
for ( ; n < rTable.size(); ++n )
{
......@@ -1031,7 +1031,7 @@ bool SwUndo::FillSaveDataForFormat(
const SwPosition *pStt = rRange.Start(), *pEnd = rRange.End();
const SwRedlineTable& rTable = rRange.GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
sal_uInt16 n = 0;
SwRedlineTable::size_type n = 0;
rRange.GetDoc()->getIDocumentRedlineAccess().GetRedline( *pStt, &n );
for ( ; n < rTable.size(); ++n )
{
......
......@@ -238,10 +238,10 @@ void SwUndoRedlineSort::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
// Search both Redline objects and make them visible to make the nodes
// consistent again. The 'delete' one is hidden, thus search for the
// 'insert' Redline object. The former is located directly after the latter.
sal_uInt16 nFnd = rDoc.getIDocumentRedlineAccess().GetRedlinePos(
SwRedlineTable::size_type nFnd = rDoc.getIDocumentRedlineAccess().GetRedlinePos(
*rDoc.GetNodes()[ nSttNode + 1 ],
nsRedlineType_t::REDLINE_INSERT );