summaryrefslogtreecommitdiff
path: root/sw/inc/docary.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-03-02 08:35:18 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-03-02 10:06:34 +0000
commit2fdd5760b402f9e0a8c829bc8aa05c618afc674a (patch)
treea2bfb95c513a43df0050f70373641eb56f0b9f25 /sw/inc/docary.hxx
parent64cca8d6237ef90c3b222df36de257dbb859d99e (diff)
Complete the transition of SwRedlineTable::size_type
...from 9ca8a63fff65acf2ea13b391495ad232f4636548 "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/34775 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sw/inc/docary.hxx')
-rw-r--r--sw/inc/docary.hxx27
1 files changed, 13 insertions, 14 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 2de106f9fc1e..dec10c8e23d9 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -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(); }