sw/inc/IDocumentFieldsAccess.hxx                            |    5 
 sw/inc/SwUndoField.hxx                                      |    2 
 sw/inc/ToxTabStopTokenHandler.hxx                           |    5 
 sw/inc/crsrsh.hxx                                           |    2 
 sw/inc/ddefld.hxx                                           |    4 
 sw/inc/doc.hxx                                              |    8 
 sw/inc/edglbldc.hxx                                         |    6 
 sw/inc/edimp.hxx                                            |    4 
 sw/inc/editsh.hxx                                           |    2 
 sw/inc/fldbas.hxx                                           |    3 
 sw/inc/fmtfld.hxx                                           |    5 
 sw/inc/ndarr.hxx                                            |   21 -
 sw/inc/ndindex.hxx                                          |   96 +++--
 sw/inc/ndtxt.hxx                                            |    2 
 sw/inc/node.hxx                                             |   23 -
 sw/inc/nodeoffset.hxx                                       |   39 ++
 sw/inc/pam.hxx                                              |    5 
 sw/inc/postithelper.hxx                                     |    3 
 sw/inc/redline.hxx                                          |    2 
 sw/inc/shellio.hxx                                          |    2 
 sw/inc/swbaslnk.hxx                                         |    2 
 sw/inc/swcrsr.hxx                                           |    6 
 sw/inc/swtable.hxx                                          |    9 
 sw/inc/undobj.hxx                                           |   37 +-
 sw/qa/core/frmedt/frmedt.cxx                                |    4 
 sw/qa/core/uwriter.cxx                                      |    2 
 sw/qa/extras/globalfilter/globalfilter.cxx                  |   12 
 sw/qa/extras/htmlimport/htmlimport.cxx                      |    2 
 sw/qa/extras/indexing/SearchResultLocatorTest.cxx           |    4 
 sw/qa/extras/layout/layout.cxx                              |    4 
 sw/qa/extras/mailmerge/mailmerge.cxx                        |   34 +-
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx                  |    6 
 sw/qa/extras/rtfexport/rtfexport4.cxx                       |    6 
 sw/qa/extras/tiledrendering/tiledrendering.cxx              |    4 
 sw/qa/extras/uiwriter/uiwriter.cxx                          |   26 -
 sw/qa/extras/uiwriter/uiwriter2.cxx                         |   14 
 sw/qa/extras/uiwriter/uiwriter4.cxx                         |   89 ++---
 sw/qa/extras/ww8export/ww8export.cxx                        |    2 
 sw/qa/extras/ww8import/ww8import.cxx                        |    4 
 sw/source/core/access/AccessibilityCheck.cxx                |    2 
 sw/source/core/access/accframebase.cxx                      |    6 
 sw/source/core/access/accmap.cxx                            |   10 
 sw/source/core/access/accpara.cxx                           |   24 -
 sw/source/core/attr/hints.cxx                               |    2 
 sw/source/core/bastyp/index.cxx                             |    5 
 sw/source/core/crsr/bookmark.cxx                            |   12 
 sw/source/core/crsr/callnk.cxx                              |    4 
 sw/source/core/crsr/callnk.hxx                              |    3 
 sw/source/core/crsr/crsrsh.cxx                              |   10 
 sw/source/core/crsr/crstrvl.cxx                             |   12 
 sw/source/core/crsr/findtxt.cxx                             |    4 
 sw/source/core/crsr/pam.cxx                                 |   28 -
 sw/source/core/crsr/swcrsr.cxx                              |   34 +-
 sw/source/core/crsr/trvlfnfl.cxx                            |   12 
 sw/source/core/crsr/trvlreg.cxx                             |    8 
 sw/source/core/crsr/trvltbl.cxx                             |   14 
 sw/source/core/doc/CntntIdxStore.cxx                        |   34 +-
 sw/source/core/doc/DocumentContentOperationsManager.cxx     |  134 ++++----
 sw/source/core/doc/DocumentFieldsManager.cxx                |   10 
 sw/source/core/doc/DocumentLayoutManager.cxx                |   10 
 sw/source/core/doc/DocumentLinksAdministrationManager.cxx   |   10 
 sw/source/core/doc/DocumentOutlineNodesManager.cxx          |    2 
 sw/source/core/doc/DocumentRedlineManager.cxx               |   20 -
 sw/source/core/doc/DocumentStatisticsManager.cxx            |    2 
 sw/source/core/doc/dbgoutsw.cxx                             |    6 
 sw/source/core/doc/doc.cxx                                  |   24 -
 sw/source/core/doc/docbm.cxx                                |   12 
 sw/source/core/doc/doccomp.cxx                              |   36 +-
 sw/source/core/doc/docdesc.cxx                              |    6 
 sw/source/core/doc/docedt.cxx                               |   12 
 sw/source/core/doc/docfld.cxx                               |   10 
 sw/source/core/doc/docfly.cxx                               |   10 
 sw/source/core/doc/docfmt.cxx                               |    2 
 sw/source/core/doc/docftn.cxx                               |    8 
 sw/source/core/doc/docglbl.cxx                              |    8 
 sw/source/core/doc/docglos.cxx                              |    4 
 sw/source/core/doc/doclay.cxx                               |   18 -
 sw/source/core/doc/docnew.cxx                               |    8 
 sw/source/core/doc/docnum.cxx                               |   76 ++--
 sw/source/core/doc/docredln.cxx                             |   14 
 sw/source/core/doc/docsort.cxx                              |   22 -
 sw/source/core/doc/doctxm.cxx                               |   28 -
 sw/source/core/doc/extinput.cxx                             |    6 
 sw/source/core/doc/ftnidx.cxx                               |   20 -
 sw/source/core/doc/htmltbl.cxx                              |    4 
 sw/source/core/doc/list.cxx                                 |    4 
 sw/source/core/doc/swserv.cxx                               |    4 
 sw/source/core/doc/tblcpy.cxx                               |    4 
 sw/source/core/doc/tblrwcl.cxx                              |    8 
 sw/source/core/docnode/ndcopy.cxx                           |    6 
 sw/source/core/docnode/ndsect.cxx                           |   38 +-
 sw/source/core/docnode/ndsect.hxx                           |    3 
 sw/source/core/docnode/ndtbl.cxx                            |   90 ++---
 sw/source/core/docnode/node.cxx                             |   24 -
 sw/source/core/docnode/node2lay.cxx                         |   16 
 sw/source/core/docnode/nodes.cxx                            |  194 ++++++------
 sw/source/core/docnode/section.cxx                          |   14 
 sw/source/core/docnode/swbaslnk.cxx                         |    2 
 sw/source/core/edit/acorrect.cxx                            |    2 
 sw/source/core/edit/autofmt.cxx                             |   12 
 sw/source/core/edit/edattr.cxx                              |   30 -
 sw/source/core/edit/edglbldc.cxx                            |   12 
 sw/source/core/edit/editsh.cxx                              |   10 
 sw/source/core/edit/ednumber.cxx                            |   24 -
 sw/source/core/edit/edsect.cxx                              |    2 
 sw/source/core/edit/edtab.cxx                               |   12 
 sw/source/core/edit/edws.cxx                                |    4 
 sw/source/core/fields/ddefld.cxx                            |    4 
 sw/source/core/fields/ddetbl.cxx                            |    2 
 sw/source/core/fields/fldbas.cxx                            |    2 
 sw/source/core/fields/postithelper.cxx                      |    2 
 sw/source/core/frmedt/fecopy.cxx                            |   22 -
 sw/source/core/frmedt/feflyole.cxx                          |    2 
 sw/source/core/frmedt/fetab.cxx                             |    2 
 sw/source/core/frmedt/fews.cxx                              |    4 
 sw/source/core/frmedt/tblsel.cxx                            |    6 
 sw/source/core/inc/DocumentContentOperationsManager.hxx     |    2 
 sw/source/core/inc/DocumentFieldsManager.hxx                |    4 
 sw/source/core/inc/SearchResultLocator.hxx                  |    5 
 sw/source/core/inc/SwUndoTOXChange.hxx                      |    2 
 sw/source/core/inc/UndoAttribute.hxx                        |    6 
 sw/source/core/inc/UndoCore.hxx                             |    4 
 sw/source/core/inc/UndoDelete.hxx                           |    8 
 sw/source/core/inc/UndoInsert.hxx                           |    8 
 sw/source/core/inc/UndoNumbering.hxx                        |   16 
 sw/source/core/inc/UndoOverwrite.hxx                        |    2 
 sw/source/core/inc/UndoRedline.hxx                          |    4 
 sw/source/core/inc/UndoSection.hxx                          |    8 
 sw/source/core/inc/UndoSort.hxx                             |   16 
 sw/source/core/inc/UndoSplitMove.hxx                        |    8 
 sw/source/core/inc/UndoTable.hxx                            |   46 +-
 sw/source/core/inc/acorrect.hxx                             |    5 
 sw/source/core/inc/anchoredobjectposition.hxx               |    3 
 sw/source/core/inc/docfld.hxx                               |    6 
 sw/source/core/inc/docsort.hxx                              |    2 
 sw/source/core/inc/frmtool.hxx                              |    8 
 sw/source/core/inc/mvsave.hxx                               |   12 
 sw/source/core/inc/node2lay.hxx                             |    4 
 sw/source/core/inc/rolbck.hxx                               |   70 ++--
 sw/source/core/inc/txmsrt.hxx                               |    2 
 sw/source/core/inc/txtfly.hxx                               |    3 
 sw/source/core/inc/txtfrm.hxx                               |    5 
 sw/source/core/inc/unoflatpara.hxx                          |    5 
 sw/source/core/layout/atrfrm.cxx                            |    8 
 sw/source/core/layout/calcmove.cxx                          |    2 
 sw/source/core/layout/dbg_lay.cxx                           |    2 
 sw/source/core/layout/flowfrm.cxx                           |    6 
 sw/source/core/layout/fly.cxx                               |    4 
 sw/source/core/layout/frmtool.cxx                           |   20 -
 sw/source/core/layout/hffrm.cxx                             |    2 
 sw/source/core/layout/laycache.cxx                          |   44 +-
 sw/source/core/layout/layhelp.hxx                           |   12 
 sw/source/core/layout/tabfrm.cxx                            |    4 
 sw/source/core/layout/wsfrm.cxx                             |   26 -
 sw/source/core/model/ModelTraverser.cxx                     |    2 
 sw/source/core/model/SearchResultLocator.cxx                |    8 
 sw/source/core/objectpositioning/anchoredobjectposition.cxx |    6 
 sw/source/core/ole/ndole.cxx                                |    4 
 sw/source/core/table/swnewtable.cxx                         |    2 
 sw/source/core/table/swtable.cxx                            |   50 +--
 sw/source/core/text/frmcrsr.cxx                             |    4 
 sw/source/core/text/itratr.cxx                              |    6 
 sw/source/core/text/redlnitr.cxx                            |   16 
 sw/source/core/text/redlnitr.hxx                            |   24 -
 sw/source/core/text/txtfld.cxx                              |    2 
 sw/source/core/text/txtfly.cxx                              |    6 
 sw/source/core/text/txtfrm.cxx                              |   12 
 sw/source/core/text/xmldump.cxx                             |   12 
 sw/source/core/tox/ToxTabStopTokenHandler.cxx               |    4 
 sw/source/core/tox/ToxTextGenerator.cxx                     |    2 
 sw/source/core/tox/txmsrt.cxx                               |    2 
 sw/source/core/txtnode/atrftn.cxx                           |   12 
 sw/source/core/txtnode/ndtxt.cxx                            |   12 
 sw/source/core/txtnode/thints.cxx                           |    6 
 sw/source/core/undo/SwUndoTOXChange.cxx                     |    4 
 sw/source/core/undo/docundo.cxx                             |    2 
 sw/source/core/undo/rolbck.cxx                              |   38 +-
 sw/source/core/undo/unattr.cxx                              |   10 
 sw/source/core/undo/undel.cxx                               |   60 +--
 sw/source/core/undo/undobj.cxx                              |   32 -
 sw/source/core/undo/undobj1.cxx                             |   14 
 sw/source/core/undo/undraw.cxx                              |    6 
 sw/source/core/undo/unins.cxx                               |   14 
 sw/source/core/undo/unmove.cxx                              |    4 
 sw/source/core/undo/unnum.cxx                               |   11 
 sw/source/core/undo/unovwr.cxx                              |    4 
 sw/source/core/undo/unredln.cxx                             |   14 
 sw/source/core/undo/unsect.cxx                              |   12 
 sw/source/core/undo/unsort.cxx                              |   18 -
 sw/source/core/undo/untbl.cxx                               |   80 ++--
 sw/source/core/undo/untblk.cxx                              |   28 -
 sw/source/core/unocore/unochart.cxx                         |    2 
 sw/source/core/unocore/unoflatpara.cxx                      |   10 
 sw/source/core/unocore/unoobj.cxx                           |   10 
 sw/source/core/unocore/unoobj2.cxx                          |   10 
 sw/source/core/unocore/unoredline.cxx                       |    6 
 sw/source/core/unocore/unotbl.cxx                           |    8 
 sw/source/core/unocore/unotext.cxx                          |   10 
 sw/source/filter/ascii/parasc.cxx                           |    2 
 sw/source/filter/ascii/wrtasc.cxx                           |    6 
 sw/source/filter/basflt/fltshell.cxx                        |    8 
 sw/source/filter/basflt/shellio.cxx                         |    6 
 sw/source/filter/docx/swdocxreader.cxx                      |    2 
 sw/source/filter/html/htmlatr.cxx                           |    2 
 sw/source/filter/html/htmlfld.cxx                           |    2 
 sw/source/filter/html/htmlflywriter.cxx                     |   26 -
 sw/source/filter/html/htmlforw.cxx                          |   10 
 sw/source/filter/html/htmlgrin.cxx                          |   12 
 sw/source/filter/html/htmlnumwriter.cxx                     |    8 
 sw/source/filter/html/htmlplug.cxx                          |    4 
 sw/source/filter/html/htmlsect.cxx                          |    4 
 sw/source/filter/html/htmltab.cxx                           |    6 
 sw/source/filter/html/htmltabw.cxx                          |    2 
 sw/source/filter/html/swhtml.cxx                            |   18 -
 sw/source/filter/html/swhtml.hxx                            |    8 
 sw/source/filter/html/wrthtml.cxx                           |   30 -
 sw/source/filter/html/wrthtml.hxx                           |   10 
 sw/source/filter/indexing/IndexingExport.cxx                |   12 
 sw/source/filter/writer/writer.cxx                          |    8 
 sw/source/filter/ww8/docxattributeoutput.cxx                |    6 
 sw/source/filter/ww8/docxsdrexport.cxx                      |   16 
 sw/source/filter/ww8/docxsdrexport.hxx                      |    3 
 sw/source/filter/ww8/rtfattributeoutput.cxx                 |    5 
 sw/source/filter/ww8/rtfexport.cxx                          |    2 
 sw/source/filter/ww8/rtfexport.hxx                          |    4 
 sw/source/filter/ww8/writerhelper.cxx                       |    6 
 sw/source/filter/ww8/wrtw8nds.cxx                           |   18 -
 sw/source/filter/ww8/wrtw8sty.cxx                           |    4 
 sw/source/filter/ww8/wrtww8.cxx                             |   29 -
 sw/source/filter/ww8/wrtww8.hxx                             |   18 -
 sw/source/filter/ww8/ww8atr.cxx                             |   12 
 sw/source/filter/ww8/ww8graf2.cxx                           |    2 
 sw/source/filter/ww8/ww8par.cxx                             |   10 
 sw/source/filter/ww8/ww8par2.cxx                            |    4 
 sw/source/filter/xml/XMLRedlineImportHelper.cxx             |    2 
 sw/source/filter/xml/xmlimp.cxx                             |    6 
 sw/source/filter/xml/xmltbli.cxx                            |    4 
 sw/source/ui/dbui/mmlayoutpage.cxx                          |    8 
 sw/source/uibase/dochdl/swdtflvr.cxx                        |    4 
 sw/source/uibase/docvw/AnnotationWin2.cxx                   |    2 
 sw/source/uibase/docvw/PostItMgr.cxx                        |    2 
 sw/source/uibase/docvw/UnfloatTableButton.cxx               |    3 
 sw/source/uibase/docvw/edtwin.cxx                           |    4 
 sw/source/uibase/shells/textsh1.cxx                         |    2 
 sw/source/uibase/uno/unotxdoc.cxx                           |    2 
 sw/source/uibase/utlui/content.cxx                          |    8 
 246 files changed, 1622 insertions(+), 1556 deletions(-)

New commits:
commit 5f9ffc31cd1b5433c354c7d39ce1d80fa0e57fc8
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Oct 19 09:08:35 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Oct 21 15:25:56 2021 +0200

    introduce SwNodeOffset strong typedef
    
    for indexing into node children. Replaces various usage
    of sal_uLong, tools::Long, sal_uInt32 with an underlying
    type of sal_Int32.
    
    Also add a NODE_OFFSET_MAX constant to replace usage
    of ULONG_MAX
    
    Change-Id: I2f466922e1ebc19029bb2883d2b29aa4c0614170
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123892
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/IDocumentFieldsAccess.hxx b/sw/inc/IDocumentFieldsAccess.hxx
index 99da34854751..fb8af7657132 100644
--- a/sw/inc/IDocumentFieldsAccess.hxx
+++ b/sw/inc/IDocumentFieldsAccess.hxx
@@ -22,6 +22,7 @@
 
 #include <sal/types.h>
 #include <tools/solar.h>
+#include "nodeoffset.hxx"
 
 class SwFieldTypes;
 class SwFieldType;
@@ -114,7 +115,7 @@ namespace com::sun::star::uno { class Any; }
         SwNode (see parameter pChk) is (?) part of the private
         data structure of SwDoc and should not be exposed
     */
-    virtual bool SetFieldsDirty(bool b, const SwNode* pChk, sal_uLong nLen) = 
0;
+    virtual bool SetFieldsDirty(bool b, const SwNode* pChk, SwNodeOffset nLen) 
= 0;
 
     virtual void SetFixFields(const DateTime* pNewDateTime) = 0;
 
@@ -122,7 +123,7 @@ namespace com::sun::star::uno { class Any; }
     // (Node [ + css::ucb::Content]).
     // A generated list of all fields may be passed along too
     // (if the address != 0 and the pointer == 0 a new list will be returned).
-    virtual void FieldsToCalc(SwCalc& rCalc, sal_uLong nLastNd, sal_Int32 
nLastCnt) = 0;
+    virtual void FieldsToCalc(SwCalc& rCalc, SwNodeOffset nLastNd, sal_Int32 
nLastCnt) = 0;
 
     virtual void FieldsToCalc(SwCalc& rCalc, const SetGetExpField& 
rToThisField, SwRootFrame const* pLayout) = 0;
 
diff --git a/sw/inc/SwUndoField.hxx b/sw/inc/SwUndoField.hxx
index 9abf8a49295e..d6145d63127b 100644
--- a/sw/inc/SwUndoField.hxx
+++ b/sw/inc/SwUndoField.hxx
@@ -29,7 +29,7 @@ class SwMsgPoolItem;
 
 class SwUndoField : public SwUndo
 {
-    sal_uLong m_nNodeIndex;
+    SwNodeOffset m_nNodeIndex;
     sal_Int32 m_nOffset;
 
 protected:
diff --git a/sw/inc/ToxTabStopTokenHandler.hxx 
b/sw/inc/ToxTabStopTokenHandler.hxx
index 158c2129b0ef..89a74fe6e65b 100644
--- a/sw/inc/ToxTabStopTokenHandler.hxx
+++ b/sw/inc/ToxTabStopTokenHandler.hxx
@@ -14,6 +14,7 @@
 #include <rtl/ustring.hxx>
 
 #include <editeng/tstpitem.hxx>
+#include "nodeoffset.hxx"
 
 struct SwFormToken;
 class SwPageDesc;
@@ -70,7 +71,7 @@ public:
     * @param tabstopReferencePolicy
     * How tab stops are positioned. (#i21237) The default behavior is to place 
tab stops relative to the page.
     */
-    DefaultToxTabStopTokenHandler(sal_uInt32 indexOfSectionNode, const 
SwPageDesc& defaultPageDescription,
+    DefaultToxTabStopTokenHandler(SwNodeOffset indexOfSectionNode, const 
SwPageDesc& defaultPageDescription,
             bool tabPositionIsRelativeToParagraphIndent,
             TabStopReferencePolicy referencePolicy);
 
@@ -100,7 +101,7 @@ private:
     tools::Long
     CalculatePageMarginFromPageDescription(const SwTextNode& targetNode) const;
 
-    sal_uInt32 mIndexOfSectionNode;
+    SwNodeOffset mIndexOfSectionNode;
     const SwPageDesc& mDefaultPageDescription;
     bool mTabPositionIsRelativeToParagraphIndent;
     TabStopReferencePolicy mTabStopReferencePolicy;
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 14507f20097c..4ff84bff5d93 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -188,7 +188,7 @@ private:
     tools::Long m_nUpDownX;              /**< try to move the cursor on 
up/down always
                                    in the same column */
     tools::Long m_nLeftFramePos;
-    sal_uLong m_nCurrentNode;     // save CursorPos at Start-Action
+    SwNodeOffset m_nCurrentNode;     // save CursorPos at Start-Action
     sal_Int32 m_nCurrentContent;
     SwNodeType m_nCurrentNdTyp;
 
diff --git a/sw/inc/ddefld.hxx b/sw/inc/ddefld.hxx
index 3e7d91479b56..a9ca4db81b52 100644
--- a/sw/inc/ddefld.hxx
+++ b/sw/inc/ddefld.hxx
@@ -40,9 +40,9 @@ namespace sw
     };
     struct InRangeSearchHint final : public SfxHint
     {
-        const sal_uLong m_nSttNd, m_nEndNd;
+        const SwNodeOffset m_nSttNd, m_nEndNd;
         bool& m_rIsInRange;
-        InRangeSearchHint(const sal_uLong nSttNd, const sal_uLong nEndNd, 
bool& rIsInRange)
+        InRangeSearchHint(const SwNodeOffset nSttNd, const SwNodeOffset 
nEndNd, bool& rIsInRange)
             : m_nSttNd(nSttNd), m_nEndNd(nEndNd), m_rIsInRange(rIsInRange) {}
     };
 }
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index a09b74f4b16b..20edaec0d1ed 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -932,7 +932,7 @@ public:
                                             const SfxItemSet* pSet = nullptr,
                                             bool bExpand = false,
                                     SwRootFrame const* pLayout = nullptr );
-    void              InsertTableOf( sal_uLong nSttNd, sal_uLong nEndNd,
+    void              InsertTableOf( SwNodeOffset nSttNd, SwNodeOffset nEndNd,
                                             const SwTOXBase& rTOX,
                                             const SfxItemSet* pSet );
     static SwTOXBase* GetCurTOX( const SwPosition& rPos );
@@ -1144,8 +1144,8 @@ public:
 
     /** Move selected paragraphs (not only numberings)
      according to offsets. (if negative: go to doc start). */
-    bool MoveParagraph(SwPaM&, tools::Long nOffset, bool bIsOutlMv = false);
-    bool MoveParagraphImpl(SwPaM&, tools::Long nOffset, bool bIsOutlMv, 
SwRootFrame const*);
+    bool MoveParagraph(SwPaM&, SwNodeOffset nOffset, bool bIsOutlMv = false);
+    bool MoveParagraphImpl(SwPaM&, SwNodeOffset nOffset, bool bIsOutlMv, 
SwRootFrame const*);
 
     bool NumOrNoNum( const SwNodeIndex& rIdx, bool bDel = false);
 
@@ -1308,7 +1308,7 @@ public:
     // Insert label. If a FlyFormat is created, return it.
     SwFlyFrameFormat* InsertLabel( const SwLabelType eType, const OUString 
&rText, const OUString& rSeparator,
                     const OUString& rNumberingSeparator,
-                    const bool bBefore, const sal_uInt16 nId, const sal_uLong 
nIdx,
+                    const bool bBefore, const sal_uInt16 nId, const 
SwNodeOffset nIdx,
                     const OUString& rCharacterStyle,
                     const bool bCpyBrd );
     SwFlyFrameFormat* InsertDrawLabel(
diff --git a/sw/inc/edglbldc.hxx b/sw/inc/edglbldc.hxx
index 9ab0bf4e4b6b..67dc4e805183 100644
--- a/sw/inc/edglbldc.hxx
+++ b/sw/inc/edglbldc.hxx
@@ -35,14 +35,14 @@ enum GlobalDocContentType {
 class SwGlblDocContent
 {
     GlobalDocContentType m_eType;
-    sal_uLong m_nDocPos;
+    SwNodeOffset m_nDocPos;
     union {
         const SwTOXBase* pTOX;
         const SwSection* pSect;
     } m_PTR;
 
 public:
-    SwGlblDocContent( sal_uLong nPos );
+    SwGlblDocContent( SwNodeOffset nPos );
     SwGlblDocContent( const SwTOXBaseSection* pTOX );
     SwGlblDocContent( const SwSection* pSect );
 
@@ -52,7 +52,7 @@ public:
                             { return GLBLDOC_SECTION == m_eType ? m_PTR.pSect 
: nullptr; }
     const SwTOXBase* GetTOX() const
                             { return GLBLDOC_TOXBASE == m_eType ? m_PTR.pTOX : 
nullptr; }
-    sal_uLong GetDocPos() const { return m_nDocPos; }
+    SwNodeOffset GetDocPos() const { return m_nDocPos; }
 
     /// For sorting.
     bool operator==( const SwGlblDocContent& rCmp ) const
diff --git a/sw/inc/edimp.hxx b/sw/inc/edimp.hxx
index b9bc4a480aa1..a4292dd464be 100644
--- a/sw/inc/edimp.hxx
+++ b/sw/inc/edimp.hxx
@@ -28,9 +28,9 @@ class SwNodeIndex;
 
 struct SwPamRange
 {
-    sal_uLong nStart, nEnd;
+    SwNodeOffset nStart, nEnd;
 
-    SwPamRange( sal_uLong nS, sal_uLong nE ) : nStart( nS ), nEnd( nE ) {}
+    SwPamRange( SwNodeOffset nS, SwNodeOffset nE ) : nStart( nS ), nEnd( nE ) 
{}
 
     bool operator==( const SwPamRange& rRg ) const
         { return nStart == rRg.nStart; }
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index cea1eab10691..f3f645580135 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -521,7 +521,7 @@ public:
 
     void NumUpDown( bool bDown = true );
 
-    bool MoveParagraph( tools::Long nOffset = 1);
+    bool MoveParagraph( SwNodeOffset nOffset = SwNodeOffset(1));
     bool MoveNumParas( bool bUpperLower, bool bUpperLeft );
 
     /// Switch on/off of numbering via Delete/Backspace.
diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index e38122ec390d..5e0dc3378ee4 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -22,6 +22,7 @@
 #include <i18nlangtag/lang.h>
 #include "swdllapi.h"
 #include "calbck.hxx"
+#include "nodeoffset.hxx"
 
 #include <cppuhelper/weakref.hxx>
 #include <editeng/svxenum.hxx>
@@ -278,7 +279,7 @@ public:
     SwFormatField* FindFormatForPostItId(sal_uInt32 nPostItId) const;
     void CollectPostIts(std::vector<SwFormatField*>& rvFormatFields, 
IDocumentRedlineAccess const& rIDRA, bool HideRedlines);
     bool HasHiddenInformationNotes() const;
-    void GatherNodeIndex(std::vector<sal_uLong>& rvNodeIndex);
+    void GatherNodeIndex(std::vector<SwNodeOffset>& rvNodeIndex);
     void GatherRefFields(std::vector<SwGetRefField*>& rvRFields, const 
sal_uInt16 nTyp);
     void GatherFields(std::vector<SwFormatField*>& rvFormatFields, bool 
bCollectOnlyInDocNodes=true) const;
 };
diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx
index 706026120aaa..fdceaeacb73b 100644
--- a/sw/inc/fmtfld.hxx
+++ b/sw/inc/fmtfld.hxx
@@ -27,6 +27,7 @@
 #include "swdllapi.h"
 #include "calbck.hxx"
 #include "reffld.hxx"
+#include "nodeoffset.hxx"
 
 class SwField;
 class SwTextField;
@@ -58,8 +59,8 @@ namespace sw {
         HasHiddenInformationNotesHint(bool& rbHasHiddenInformationNotes) : 
m_rbHasHiddenInformationNotes(rbHasHiddenInformationNotes) {};
     };
     struct GatherNodeIndexHint final : SfxHint {
-        std::vector<sal_uLong>& m_rvNodeIndex;
-        GatherNodeIndexHint(std::vector<sal_uLong>& rvNodeIndex) : 
m_rvNodeIndex(rvNodeIndex) {};
+        std::vector<SwNodeOffset>& m_rvNodeIndex;
+        GatherNodeIndexHint(std::vector<SwNodeOffset>& rvNodeIndex) : 
m_rvNodeIndex(rvNodeIndex) {};
     };
     struct GatherRefFieldsHint final : SfxHint {
         std::vector<SwGetRefField*>& m_rvRFields;
diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx
index dea24da0ca81..5393af72e776 100644
--- a/sw/inc/ndarr.hxx
+++ b/sw/inc/ndarr.hxx
@@ -30,6 +30,7 @@
 #include "ndtyp.hxx"
 #include <rtl/ustring.hxx>
 #include <o3tl/sorted_vector.hxx>
+#include "nodeoffset.hxx"
 
 class Graphic;
 class GraphicObject;
@@ -93,10 +94,10 @@ class SW_DLLPUBLIC SwNodes final
     friend class ::sw::DocumentContentOperationsManager;
 
     SwNodeIndex* m_vIndices; ///< ring of all indices on nodes.
-    void RemoveNode( sal_uLong nDelPos, sal_uLong nLen, bool bDel );
+    void RemoveNode( SwNodeOffset nDelPos, SwNodeOffset nLen, bool bDel );
 
     void InsertNode( SwNode* pNode, const SwNodeIndex& rPos );
-    void InsertNode( SwNode* pNode, sal_uLong nPos );
+    void InsertNode( SwNode* pNode, SwNodeOffset nPos );
 
     SwDoc& m_rMyDoc;                      ///< This Doc contains the 
nodes-array.
 
@@ -112,9 +113,9 @@ class SW_DLLPUBLIC SwNodes final
 
     // Actions on the nodes.
     static void SectionUpDown( const SwNodeIndex & aStart, const SwNodeIndex & 
aEnd );
-    void DelNodes( const SwNodeIndex& rStart, sal_uLong nCnt = 1 );
+    void DelNodes( const SwNodeIndex& rStart, SwNodeOffset nCnt = 
SwNodeOffset(1) );
 
-    void ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSize,
+    void ChgNode( SwNodeIndex const & rDelPos, SwNodeOffset nSize,
                   SwNodeIndex& rInsPos, bool bNewFrames );
 
     void UpdateOutlineIdx( const SwNode& );   ///< Update all OutlineNodes 
starting from Node.
@@ -134,14 +135,14 @@ public:
     typedef std::vector<SwNodeRange> NodeRanges_t;
     typedef std::vector<NodeRanges_t> TableRanges_t;
 
-    SwNode* operator[]( sal_uLong n ) const; // defined in node.hxx
+    SwNode* operator[]( SwNodeOffset n ) const; // defined in node.hxx
 
-    sal_uLong Count() const { return BigPtrArray::Count(); }
+    SwNodeOffset Count() const { return SwNodeOffset(BigPtrArray::Count()); }
     void ForEach( FnForEach_SwNodes fnForEach, void* pArgs = nullptr )
     {
-        ForEach( 0, BigPtrArray::Count(), fnForEach, pArgs );
+        ForEach( SwNodeOffset(0), Count(), fnForEach, pArgs );
     }
-    void ForEach( sal_uLong nStt, sal_uLong nEnd, FnForEach_SwNodes fnForEach, 
void* pArgs );
+    void ForEach( SwNodeOffset nStt, SwNodeOffset nEnd, FnForEach_SwNodes 
fnForEach, void* pArgs );
     void ForEach( const SwNodeIndex& rStart, const SwNodeIndex& rEnd,
                     FnForEach_SwNodes fnForEach, void* pArgs );
 
@@ -164,7 +165,7 @@ public:
     bool IsDocNodes() const;
 
     static sal_uInt16 GetSectionLevel(const SwNodeIndex &rIndex);
-    void Delete(const SwNodeIndex &rPos, sal_uLong nNodes = 1);
+    void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes = 
SwNodeOffset(1));
 
     bool MoveNodes( const SwNodeRange&, SwNodes& rNodes, const SwNodeIndex&,
                 bool bNewFrames = true );
@@ -264,7 +265,7 @@ public:
     bool TableToText( const SwNodeRange& rRange, sal_Unicode cCh,
                         SwUndoTableToText* );
     /// Is in untbl.cxx and may called only by Undo-object.
-    SwTableNode* UndoTableToText( sal_uLong nStt, sal_uLong nEnd,
+    SwTableNode* UndoTableToText( SwNodeOffset nStt, SwNodeOffset nEnd,
                         const SwTableToTextSaves& rSavedData );
 
     /** Insert a new box in the line before InsPos. Its format
diff --git a/sw/inc/ndindex.hxx b/sw/inc/ndindex.hxx
index 303a7801ca6f..7d03b0bcadaf 100644
--- a/sw/inc/ndindex.hxx
+++ b/sw/inc/ndindex.hxx
@@ -26,15 +26,13 @@
 #include "node.hxx"
 #include "ring.hxx"
 #include "ndarr.hxx"
+#include "nodeoffset.hxx"
 
 /// Marks a node in the document model.
 class SW_DLLPUBLIC SwNodeIndex final : public sw::Ring<SwNodeIndex>
 {
     SwNode * m_pNode;
 
-    // These are not allowed!
-    SwNodeIndex( SwNodes& rNds, sal_uInt16 nIdx ) = delete;
-    SwNodeIndex( SwNodes& rNds, int nIdx ) = delete;
     void RegisterIndex( SwNodes& rNodes )
     {
         if(!rNodes.m_vIndices)
@@ -51,12 +49,14 @@ class SW_DLLPUBLIC SwNodeIndex final : public 
sw::Ring<SwNodeIndex>
     }
 
 public:
-    SwNodeIndex( SwNodes& rNds, sal_uLong nIdx = 0 )
+    SwNodeIndex( SwNodes& rNds, sal_Int32 nIdx ) : SwNodeIndex(rNds, 
SwNodeOffset(nIdx)) {}
+    SwNodeIndex( SwNodes& rNds, SwNodeOffset nIdx = SwNodeOffset(0) )
         : m_pNode( rNds[ nIdx ] )
     {
         RegisterIndex( rNds );
     };
-    SwNodeIndex( const SwNodeIndex& rIdx, tools::Long nDiff = 0 )
+    SwNodeIndex( const SwNodeIndex& rIdx, sal_Int32 nDiff ) : 
SwNodeIndex(rIdx, SwNodeOffset(nDiff)) {}
+    SwNodeIndex( const SwNodeIndex& rIdx, SwNodeOffset nDiff = SwNodeOffset(0) 
)
         : sw::Ring<SwNodeIndex>()
     {
         if( nDiff )
@@ -66,7 +66,8 @@ public:
         RegisterIndex( m_pNode->GetNodes() );
     }
 
-    SwNodeIndex( const SwNode& rNd, tools::Long nDiff = 0 )
+    SwNodeIndex( const SwNode& rNd, sal_Int32 nDiff ) : SwNodeIndex(rNd, 
SwNodeOffset(nDiff)) {}
+    SwNodeIndex( const SwNode& rNd, SwNodeOffset nDiff = SwNodeOffset(0) )
     {
         if( nDiff )
             m_pNode = rNd.GetNodes()[ rNd.GetIndex() + nDiff ];
@@ -78,13 +79,13 @@ public:
     virtual  ~SwNodeIndex() override
         { DeRegisterIndex( m_pNode->GetNodes() ); }
 
-    inline sal_uLong operator++();
-    inline sal_uLong operator--();
-    inline sal_uLong operator++(int);
-    inline sal_uLong operator--(int);
+    inline SwNodeOffset operator++();
+    inline SwNodeOffset operator--();
+    inline SwNodeOffset operator++(int);
+    inline SwNodeOffset operator--(int);
 
-    inline sal_uLong operator+=( sal_uLong );
-    inline sal_uLong operator-=( sal_uLong );
+    inline SwNodeOffset operator+=( SwNodeOffset );
+    inline SwNodeOffset operator-=( SwNodeOffset );
 
     inline bool operator< ( const SwNodeIndex& ) const;
     inline bool operator<=( const SwNodeIndex& ) const;
@@ -93,23 +94,24 @@ public:
     inline bool operator==( const SwNodeIndex& ) const;
     inline bool operator!=( const SwNodeIndex& ) const;
 
-    inline bool operator< ( sal_uLong ) const;
-    inline bool operator<=( sal_uLong ) const;
-    inline bool operator> ( sal_uLong ) const;
-    inline bool operator>=( sal_uLong ) const;
-    inline bool operator==( sal_uLong ) const;
-    inline bool operator!=( sal_uLong ) const;
+    inline bool operator< ( SwNodeOffset ) const;
+    inline bool operator<=( SwNodeOffset ) const;
+    inline bool operator> ( SwNodeOffset ) const;
+    inline bool operator>=( SwNodeOffset ) const;
+    inline bool operator==( SwNodeOffset ) const;
+    inline bool operator!=( SwNodeOffset ) const;
 
-    inline SwNodeIndex& operator=( sal_uLong );
+    inline SwNodeIndex& operator=( SwNodeOffset );
     inline SwNodeIndex& operator=( const SwNodeIndex& );
     inline SwNodeIndex& operator=( const SwNode& );
 
-    // Return value of index as sal_uLong.
-    inline sal_uLong GetIndex() const;
+    // Return value of index as SwNodeOffset.
+    inline SwNodeOffset GetIndex() const;
 
     // Enables assignments without creation of a temporary object.
-    inline SwNodeIndex& Assign( SwNodes const & rNds, sal_uLong );
-    inline SwNodeIndex& Assign( const SwNode& rNd, tools::Long nOffset = 0 );
+    inline SwNodeIndex& Assign( SwNodes const & rNds, SwNodeOffset );
+    SwNodeIndex& Assign( const SwNode& rNd, sal_Int32 nOffset ) { return 
Assign(rNd, SwNodeOffset(nOffset)); }
+    inline SwNodeIndex& Assign( const SwNode& rNd, SwNodeOffset nOffset = 
SwNodeOffset(0) );
 
     // Gets pointer on NodesArray.
     inline const SwNodes& GetNodes() const;
@@ -121,7 +123,7 @@ public:
 
 inline std::ostream &operator <<(std::ostream& s, const SwNodeIndex& index)
 {
-    return s << "SwNodeIndex (node " << index.GetIndex() << ")";
+    return s << "SwNodeIndex (node " << sal_Int32(index.GetIndex()) << ")";
 };
 
 // SwRange
@@ -137,19 +139,19 @@ public:
     SwNodeRange( const SwNodeRange &rRange )
         : aStart( rRange.aStart ), aEnd( rRange.aEnd ) {};
 
-    SwNodeRange( SwNodes& rNds, sal_uLong nSttIdx, sal_uLong nEndIdx = 0 )
+    SwNodeRange( SwNodes& rNds, SwNodeOffset nSttIdx, SwNodeOffset nEndIdx = 
SwNodeOffset(0) )
         : aStart( rNds, nSttIdx ), aEnd( rNds, nEndIdx ) {};
 
-    SwNodeRange( const SwNodeIndex& rS, tools::Long nSttDiff, const 
SwNodeIndex& rE, tools::Long nEndDiff = 0 )
+    SwNodeRange( const SwNodeIndex& rS, SwNodeOffset nSttDiff, const 
SwNodeIndex& rE, SwNodeOffset nEndDiff = SwNodeOffset(0) )
         : aStart( rS, nSttDiff ), aEnd( rE, nEndDiff ) {};
-    SwNodeRange( const SwNode& rS, tools::Long nSttDiff, const SwNode& rE, 
tools::Long nEndDiff = 0 )
+    SwNodeRange( const SwNode& rS, SwNodeOffset nSttDiff, const SwNode& rE, 
SwNodeOffset nEndDiff = SwNodeOffset(0) )
         : aStart( rS, nSttDiff ), aEnd( rE, nEndDiff ) {};
 };
 
 // For inlines node.hxx is needed which in turn needs this one.
 // Therefore all inlines accessing m_pNode are implemented here.
 
-inline sal_uLong SwNodeIndex::GetIndex() const
+inline SwNodeOffset SwNodeIndex::GetIndex() const
 {
     return m_pNode->GetIndex();
 }
@@ -161,27 +163,27 @@ inline SwNodes& SwNodeIndex::GetNodes()
 {
     return m_pNode->GetNodes();
 }
-inline bool SwNodeIndex::operator< ( sal_uLong const nOther ) const
+inline bool SwNodeIndex::operator< ( SwNodeOffset const nOther ) const
 {
     return m_pNode->GetIndex() < nOther;
 }
-inline bool SwNodeIndex::operator<=( sal_uLong const nOther ) const
+inline bool SwNodeIndex::operator<=( SwNodeOffset const nOther ) const
 {
     return m_pNode->GetIndex() <= nOther;
 }
-inline bool SwNodeIndex::operator> ( sal_uLong const nOther ) const
+inline bool SwNodeIndex::operator> ( SwNodeOffset const nOther ) const
 {
     return m_pNode->GetIndex() > nOther;
 }
-inline bool SwNodeIndex::operator>=( sal_uLong const nOther ) const
+inline bool SwNodeIndex::operator>=( SwNodeOffset const nOther ) const
 {
     return m_pNode->GetIndex() >= nOther;
 }
-inline bool SwNodeIndex::operator==( sal_uLong const nOther ) const
+inline bool SwNodeIndex::operator==( SwNodeOffset const nOther ) const
 {
     return m_pNode->GetIndex() == nOther;
 }
-inline bool SwNodeIndex::operator!=( sal_uLong const nOther ) const
+inline bool SwNodeIndex::operator!=( SwNodeOffset const nOther ) const
 {
     return m_pNode->GetIndex() != nOther;
 }
@@ -210,41 +212,41 @@ inline bool SwNodeIndex::operator!=( const SwNodeIndex& 
rIdx ) const
     return m_pNode != rIdx.m_pNode;
 }
 
-inline sal_uLong SwNodeIndex::operator++()
+inline SwNodeOffset SwNodeIndex::operator++()
 {
-    m_pNode = GetNodes()[ m_pNode->GetIndex()+1 ];
+    m_pNode = GetNodes()[ m_pNode->GetIndex() + 1 ];
     return m_pNode->GetIndex();
 }
-inline sal_uLong SwNodeIndex::operator--()
+inline SwNodeOffset SwNodeIndex::operator--()
 {
-    m_pNode = GetNodes()[ m_pNode->GetIndex()-1 ];
+    m_pNode = GetNodes()[ m_pNode->GetIndex() - 1 ];
     return m_pNode->GetIndex();
 }
-inline sal_uLong SwNodeIndex::operator++(int)
+inline SwNodeOffset SwNodeIndex::operator++(int)
 {
-    sal_uLong nOldIndex = m_pNode->GetIndex();
+    SwNodeOffset nOldIndex = m_pNode->GetIndex();
     m_pNode = GetNodes()[ nOldIndex + 1 ];
     return nOldIndex;
 }
-inline sal_uLong SwNodeIndex::operator--(int)
+inline SwNodeOffset SwNodeIndex::operator--(int)
 {
-    sal_uLong nOldIndex = m_pNode->GetIndex();
+    SwNodeOffset nOldIndex = m_pNode->GetIndex();
     m_pNode = GetNodes()[ nOldIndex - 1 ];
     return nOldIndex;
 }
 
-inline sal_uLong SwNodeIndex::operator+=( sal_uLong const nOffset )
+inline SwNodeOffset SwNodeIndex::operator+=( SwNodeOffset const nOffset )
 {
     m_pNode = GetNodes()[ m_pNode->GetIndex() + nOffset ];
     return m_pNode->GetIndex();
 }
-inline sal_uLong SwNodeIndex::operator-=( sal_uLong const nOffset )
+inline SwNodeOffset SwNodeIndex::operator-=( SwNodeOffset const nOffset )
 {
     m_pNode = GetNodes()[ m_pNode->GetIndex() - nOffset ];
     return m_pNode->GetIndex();
 }
 
-inline SwNodeIndex& SwNodeIndex::operator=( sal_uLong const nNew )
+inline SwNodeIndex& SwNodeIndex::operator=( SwNodeOffset const nNew )
 {
     m_pNode = GetNodes()[ nNew ];
     return *this;
@@ -269,13 +271,13 @@ SwNodeIndex& SwNodeIndex::operator=( const SwNode& rNd )
     return *this;
 }
 
-SwNodeIndex& SwNodeIndex::Assign( SwNodes const & rNds, sal_uLong nIdx )
+SwNodeIndex& SwNodeIndex::Assign( SwNodes const & rNds, SwNodeOffset nIdx )
 {
     *this = *rNds[ nIdx ];
     return *this;
 }
 
-SwNodeIndex& SwNodeIndex::Assign( const SwNode& rNd, tools::Long nOffset )
+SwNodeIndex& SwNodeIndex::Assign( const SwNode& rNd, SwNodeOffset nOffset )
 {
     *this = rNd;
 
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index d3320d995d06..42360271e808 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -233,7 +233,7 @@ public:
     virtual sal_Int32 Len() const override;
 
     /// Is in itratr.
-    void GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rMax, 
sal_uLong &rAbs ) const;
+    void GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong &rMax, 
sal_uLong &rAbs ) const;
 
     /// overriding to handle change of certain paragraph attributes
     virtual bool SetAttr( const SfxPoolItem& ) override;
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index df30db2b9f9e..bdcc9c801a49 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -28,6 +28,7 @@
 #include "ndtyp.hxx"
 #include "index.hxx"
 #include "fmtcol.hxx"
+#include "nodeoffset.hxx"
 
 #include <memory>
 #include <vector>
@@ -115,7 +116,7 @@ protected:
     SwNode( const SwNodeIndex &rWhere, const SwNodeType nNodeId );
 
     /// for the initial StartNode
-    SwNode( SwNodes& rNodes, sal_uLong nPos, const SwNodeType nNodeId );
+    SwNode( SwNodes& rNodes, SwNodeOffset nPos, const SwNodeType nNodeId );
 
 public:
     /** the = 0 forces the class to be an abstract base class, but the dtor 
can be still called
@@ -128,11 +129,11 @@ public:
 
     sal_uInt16 GetSectionLevel() const;
 
-    inline sal_uLong StartOfSectionIndex() const;
+    inline SwNodeOffset StartOfSectionIndex() const;
     const SwStartNode* StartOfSectionNode() const { return m_pStartOfSection; }
     SwStartNode* StartOfSectionNode() { return m_pStartOfSection; }
 
-    inline sal_uLong EndOfSectionIndex() const;
+    inline SwNodeOffset EndOfSectionIndex() const;
     inline const SwEndNode* EndOfSectionNode() const;
     inline         SwEndNode* EndOfSectionNode();
 
@@ -280,7 +281,7 @@ public:
     /** Search PageDesc with which this node is formatted. If layout is 
existent
        search over layout, else only the hard way is left: search over the 
nodes
        to the front!! */
-    const SwPageDesc* FindPageDesc( size_t* pPgDescNdIdx = nullptr ) const;
+    const SwPageDesc* FindPageDesc( SwNodeOffset* pPgDescNdIdx = nullptr ) 
const;
 
     /// If node is in a fly return the respective format.
     SwFrameFormat* GetFlyFormat() const;
@@ -288,7 +289,7 @@ public:
     /// If node is in a table return the respective table box.
     SwTableBox* GetTableBox() const;
 
-    sal_uLong GetIndex() const { return GetPos(); }
+    SwNodeOffset GetIndex() const { return SwNodeOffset(GetPos()); }
 
     const SwTextNode* FindOutlineNodeOfLevel(sal_uInt8 nLvl, SwRootFrame 
const* pLayout = nullptr) const;
 
@@ -319,7 +320,7 @@ class SAL_DLLPUBLIC_RTTI SwStartNode: public SwNode
     SwStartNodeType m_eStartNodeType;
 
     /// for the initial StartNode
-    SwStartNode( SwNodes& rNodes, sal_uLong nPos );
+    SwStartNode( SwNodes& rNodes, SwNodeOffset nPos );
 
 protected:
     SwStartNode( const SwNodeIndex &rWhere,
@@ -346,7 +347,7 @@ class SwEndNode final : public SwNode
     friend class SwSectionNode;     ///< To enable creation of its EndNote.
 
     /// for the initial StartNode
-    SwEndNode( SwNodes& rNodes, sal_uLong nPos, SwStartNode& rSttNd );
+    SwEndNode( SwNodes& rNodes, SwNodeOffset nPos, SwStartNode& rSttNd );
 
     SwEndNode( const SwNodeIndex &rWhere, SwStartNode& rSttNd );
 
@@ -671,11 +672,11 @@ inline const SwSectionNode* SwNode::FindSectionNode() 
const
 {
     return const_cast<SwNode*>(this)->FindSectionNode();
 }
-inline sal_uLong SwNode::StartOfSectionIndex() const
+inline SwNodeOffset SwNode::StartOfSectionIndex() const
 {
     return m_pStartOfSection->GetIndex();
 }
-inline sal_uLong SwNode::EndOfSectionIndex() const
+inline SwNodeOffset SwNode::EndOfSectionIndex() const
 {
     const SwStartNode* pStNd = IsStartNode() ? static_cast<const 
SwStartNode*>(this) : m_pStartOfSection;
     return pStNd->m_pEndOfSection->GetIndex();
@@ -730,9 +731,9 @@ inline SwPlaceholderNode::SwPlaceholderNode(const 
SwNodeIndex &rWhere)
 {
 }
 
-inline SwNode* SwNodes::operator[]( sal_uLong n ) const
+inline SwNode* SwNodes::operator[]( SwNodeOffset n ) const
 {
-    return static_cast<SwNode*>(BigPtrArray::operator[] ( n ));
+    return static_cast<SwNode*>(BigPtrArray::operator[] ( sal_Int32(n) ));
 }
 
 #endif
diff --git a/sw/inc/nodeoffset.hxx b/sw/inc/nodeoffset.hxx
new file mode 100644
index 000000000000..0911fdb67b23
--- /dev/null
+++ b/sw/inc/nodeoffset.hxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#pragma once
+
+#include <sal/config.h>
+#include "swdllapi.h"
+#include <o3tl/strong_int.hxx>
+#include <iostream>
+
+typedef o3tl::strong_int<sal_Int32, struct Tag_SwNodeOffset> SwNodeOffset;
+
+/* Just to make it easier to write arithmetic with these types */
+template <typename T>
+typename std::enable_if<std::is_signed<T>::value, SwNodeOffset>::type 
operator+(SwNodeOffset a, T n)
+{
+    return a + SwNodeOffset(n);
+}
+
+/* Just to make it easier to write arithmetic with these types */
+template <typename T>
+typename std::enable_if<std::is_signed<T>::value, SwNodeOffset>::type 
operator-(SwNodeOffset a, T n)
+{
+    return a - SwNodeOffset(n);
+}
+
+inline SwNodeOffset abs(const SwNodeOffset& a) { return a > SwNodeOffset(0) ? 
a : -a; }
+inline SwNodeOffset min(const SwNodeOffset& a, const SwNodeOffset& b) { return 
a > b ? a : b; }
+
+constexpr SwNodeOffset NODE_OFFSET_MAX(SAL_MAX_INT32);
+
+SW_DLLPUBLIC std::ostream& operator<<(std::ostream& s, const SwNodeOffset& 
index);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 7e64a4665a9f..7c45c59740d1 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -24,6 +24,7 @@
 #include "index.hxx"
 #include "ndindex.hxx"
 #include "swdllapi.h"
+#include "nodeoffset.hxx"
 
 #include <iostream>
 
@@ -147,9 +148,9 @@ public:
     explicit SwPaM( const SwPosition& rPos, SwPaM* pRing = nullptr );
     SwPaM( const SwPosition& rMk, const SwPosition& rPt, SwPaM* pRing = 
nullptr );
     SwPaM( const SwNodeIndex& rMk, const SwNodeIndex& rPt,
-           tools::Long nMkOffset = 0, tools::Long nPtOffset = 0, SwPaM* pRing 
= nullptr );
+           SwNodeOffset nMkOffset = SwNodeOffset(0), SwNodeOffset nPtOffset = 
SwNodeOffset(0), SwPaM* pRing = nullptr );
     SwPaM( const SwNode& rMk, const SwNode& rPt,
-           tools::Long nMkOffset = 0, tools::Long nPtOffset = 0, SwPaM* pRing 
= nullptr );
+           SwNodeOffset nMkOffset = SwNodeOffset(0), SwNodeOffset nPtOffset = 
SwNodeOffset(0), SwPaM* pRing = nullptr );
     SwPaM(  const SwNodeIndex& rMk, sal_Int32 nMkContent,
             const SwNodeIndex& rPt, sal_Int32 nPtContent, SwPaM* pRing = 
nullptr );
     SwPaM(  const SwNode& rMk, sal_Int32 nMkContent,
diff --git a/sw/inc/postithelper.hxx b/sw/inc/postithelper.hxx
index 5b4f3319ca05..6bc06b60507c 100644
--- a/sw/inc/postithelper.hxx
+++ b/sw/inc/postithelper.hxx
@@ -25,6 +25,7 @@
 #include <vcl/vclptr.hxx>
 #include <tools/solar.h>
 #include "SidebarWindowsTypes.hxx"
+#include "nodeoffset.hxx"
 
 class SfxBroadcaster;
 class SwRootFrame;
@@ -43,7 +44,7 @@ struct SwLayoutInfo
     SwRect mPosition;
 
     // optional start of the annotation
-    sal_uLong mnStartNodeIdx;
+    SwNodeOffset mnStartNodeIdx;
     sal_Int32 mnStartContent;
 
     SwRect mPageFrame;
diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index 5a25a7d83aff..0c5b8408d54c 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -231,7 +231,7 @@ public:
     void ShowOriginal(sal_uInt16 nLoop, size_t nMyPos, bool bForced = false);
 
     /// Calculates the intersection with text node number nNdIdx.
-    void CalcStartEnd(sal_uLong nNdIdx, sal_Int32& rStart, sal_Int32& rEnd) 
const;
+    void CalcStartEnd(SwNodeOffset nNdIdx, sal_Int32& rStart, sal_Int32& rEnd) 
const;
 
     enum class Invalidation { Add, Remove };
     /// Initiate the layout.
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index d1b015a772a8..1c82db956315 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -455,7 +455,7 @@ public:
 
     // Create new PaM at position.
     static std::shared_ptr<SwUnoCursor> NewUnoCursor(SwDoc & rDoc,
-                            sal_uLong const nStartIdx, sal_uLong const 
nEndIdx);
+                            SwNodeOffset const nStartIdx, SwNodeOffset const 
nEndIdx);
 
     // If applicable copy a local file into internet.
     bool CopyLocalFileToINet( OUString& rFileNm );
diff --git a/sw/inc/swbaslnk.hxx b/sw/inc/swbaslnk.hxx
index 3604c15119d6..092994fbfc63 100644
--- a/sw/inc/swbaslnk.hxx
+++ b/sw/inc/swbaslnk.hxx
@@ -54,7 +54,7 @@ public:
     using SvBaseLink::SetObjType;
 
     bool IsRecursion( const SwBaseLink* pChkLnk ) const;
-    virtual bool IsInRange( sal_uLong nSttNd, sal_uLong nEndNd ) const;
+    virtual bool IsInRange( SwNodeOffset nSttNd, SwNodeOffset nEndNd ) const;
 
     void SetNoDataFlag() { m_bNoDataFlag = true; }
     bool ChkNoDataFlag() { const bool bRet = m_bNoDataFlag; m_bNoDataFlag = 
false; return bRet; }
diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx
index cd2b4ac74ed7..f36e0167d5c3 100644
--- a/sw/inc/swcrsr.hxx
+++ b/sw/inc/swcrsr.hxx
@@ -241,7 +241,7 @@ public:
 // internal, used by SwCursor::SaveState() etc.
 struct SwCursor_SavePos final
 {
-    sal_uLong nNode;
+    SwNodeOffset nNode;
     sal_Int32 nContent;
 
     SwCursor_SavePos( const SwCursor& rCursor )
@@ -254,8 +254,8 @@ class SwTableCursor : public virtual SwCursor
 {
 
 protected:
-    sal_uLong m_nTablePtNd;
-    sal_uLong m_nTableMkNd;
+    SwNodeOffset m_nTablePtNd;
+    SwNodeOffset m_nTableMkNd;
     sal_Int32 m_nTablePtCnt;
     sal_Int32 m_nTableMkCnt;
     SwSelBoxes m_SelectedBoxes;
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 3347e04993e1..f358d348ab5f 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -27,6 +27,7 @@
 #include "swrect.hxx"
 #include "swtblfmt.hxx"
 #include "docary.hxx"
+#include "nodeoffset.hxx"
 
 #include <memory>
 #include <vector>
@@ -291,8 +292,8 @@ public:
     void CopyHeadlineIntoTable( SwTableNode& rTableNd );
 
     // Get box, whose start index is set on nBoxStt.
-          SwTableBox* GetTableBox( sal_uLong nSttIdx );
-    const SwTableBox* GetTableBox( sal_uLong nSttIdx ) const
+          SwTableBox* GetTableBox( SwNodeOffset nSttIdx );
+    const SwTableBox* GetTableBox( SwNodeOffset nSttIdx ) const
                         {   return const_cast<SwTable*>(this)->GetTableBox( 
nSttIdx );  }
 
     // Returns true if table contains nestings.
@@ -456,7 +457,7 @@ public:
 
     void RemoveFromTable();
     const SwStartNode *GetSttNd() const { return m_pStartNode; }
-    sal_uLong GetSttIdx() const;
+    SwNodeOffset GetSttIdx() const;
     // it doesn't contain box content
     bool IsEmpty() const;
 
@@ -479,7 +480,7 @@ public:
     // Contains box contents, that can be formatted as a number?
     bool HasNumContent( double& rNum, sal_uInt32& rFormatIndex,
                     bool& rIsEmptyTextNd ) const;
-    sal_uLong IsValidNumTextNd( bool bCheckAttr = true ) const;
+    SwNodeOffset IsValidNumTextNd( bool bCheckAttr = true ) const;
     // If a table formula is set, test if box contents is congruent with 
number.
     // (For Redo of change of NumFormat!).
     bool IsNumberChanged() const;
diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index 2e7ea18740a3..6cf772f7734d 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -26,6 +26,7 @@
 #include <tools/solar.h>
 #include "SwRewriter.hxx"
 #include "swundo.hxx"
+#include "nodeoffset.hxx"
 #include <o3tl/typed_flags_set.hxx>
 #include <optional>
 
@@ -61,9 +62,9 @@ protected:
     bool m_bCacheComment;
     mutable std::optional<OUString> maComment;
 
-    static void RemoveIdxFromSection( SwDoc&, sal_uLong nSttIdx, const 
sal_uLong* pEndIdx = nullptr );
+    static void RemoveIdxFromSection( SwDoc&, SwNodeOffset nSttIdx, const 
SwNodeOffset* pEndIdx = nullptr );
     static void RemoveIdxFromRange( SwPaM& rPam, bool bMoveNext );
-    static void RemoveIdxRel( sal_uLong, const SwPosition& );
+    static void RemoveIdxRel( SwNodeOffset, const SwPosition& );
 
     static bool CanRedlineGroup( SwRedlineSaveDatas& rCurr,
                                 const SwRedlineSaveDatas& rCheck,
@@ -172,10 +173,10 @@ protected:
     // MoveFrom:    moves from the UndoNodesArray into the NodesArray.
     static void MoveToUndoNds( SwPaM& rPam,
                         SwNodeIndex* pNodeIdx,
-                        sal_uLong* pEndNdIdx = nullptr );
-    static void MoveFromUndoNds( SwDoc& rDoc, sal_uLong nNodeIdx,
+                        SwNodeOffset* pEndNdIdx = nullptr );
+    static void MoveFromUndoNds( SwDoc& rDoc, SwNodeOffset nNodeIdx,
                           SwPosition& rInsPos,
-                          const sal_uLong* pEndNdIdx = nullptr,
+                          const SwNodeOffset* pEndNdIdx = nullptr,
                           bool bForceCreateFrames = false);
 
     // These two methods move the SPoint back/forth from PaM. With it
@@ -201,12 +202,12 @@ class SwUndoSaveSection : private SwUndoSaveContent
 {
     std::unique_ptr<SwNodeIndex> m_pMovedStart;
     std::unique_ptr<SwRedlineSaveDatas> m_pRedlineSaveData;
-    sal_uLong m_nMoveLen;           // Index into UndoNodes-Array.
-    sal_uLong m_nStartPos;
+    SwNodeOffset m_nMoveLen;           // Index into UndoNodes-Array.
+    SwNodeOffset m_nStartPos;
 
 protected:
     SwNodeIndex* GetMvSttIdx() const { return m_pMovedStart.get(); }
-    sal_uLong GetMvNodeCnt() const { return m_nMoveLen; }
+    SwNodeOffset GetMvNodeCnt() const { return m_nMoveLen; }
 
 public:
     SwUndoSaveSection();
@@ -227,7 +228,7 @@ public:
 class SwUndRng
 {
 public:
-    sal_uLong m_nSttNode, m_nEndNode;
+    SwNodeOffset m_nSttNode, m_nEndNode;
     sal_Int32 m_nSttContent, m_nEndContent;
 
     SwUndRng();
@@ -244,7 +245,7 @@ class SwUndoInsLayFormat;
 namespace sw {
 
 std::optional<std::vector<SwFrameFormat*>>
-GetFlysAnchoredAt(SwDoc & rDoc, sal_uLong nSttNode);
+GetFlysAnchoredAt(SwDoc & rDoc, SwNodeOffset nSttNode);
 
 }
 
@@ -255,10 +256,10 @@ class SwUndoInserts : public SwUndo, public SwUndRng, 
private SwUndoSaveContent
     std::optional<std::vector<SwFrameFormat*>> m_pFrameFormats;
     std::vector< std::shared_ptr<SwUndoInsLayFormat> > m_FlyUndos;
     std::unique_ptr<SwRedlineData> m_pRedlineData;
-    int m_nDeleteTextNodes;
+    SwNodeOffset m_nDeleteTextNodes;
 
 protected:
-    sal_uLong m_nNodeDiff;
+    SwNodeOffset m_nNodeDiff;
     /// start of Content in UndoNodes for Redo
     std::unique_ptr<SwNodeIndex> m_pUndoNodeIndex;
     sal_uInt16 m_nSetPos;                 // Start in the history list.
@@ -273,10 +274,10 @@ public:
 
     // Set destination range after reading.
     void SetInsertRange( const SwPaM&, bool bScanFlys = true,
-                         int nDeleteTextNodes = 1);
+                         SwNodeOffset nDeleteTextNodes = SwNodeOffset(1));
 
     static bool IsCreateUndoForNewFly(SwFormatAnchor const& rAnchor,
-        sal_uLong const nStartNode, sal_uLong const nEndNode);
+        SwNodeOffset const nStartNode, SwNodeOffset const nEndNode);
     std::vector<SwFrameFormat*> * GetFlysAnchoredAt() { return m_pFrameFormats 
? &*m_pFrameFormats : nullptr; }
 
     void dumpAsXml(xmlTextWriterPtr pWriter) const override;
@@ -298,7 +299,7 @@ class SwUndoFlyBase : public SwUndo, private 
SwUndoSaveSection
 {
 protected:
     SwFrameFormat* m_pFrameFormat;          // The saved FlyFormat.
-    sal_uLong m_nNodePagePos;
+    SwNodeOffset m_nNodePagePos;
     sal_Int32 m_nContentPos;         // Page at/in paragraph.
     RndStdIds m_nRndId;
     bool m_bDelFormat;           // Delete saved format.
@@ -309,7 +310,7 @@ protected:
     SwUndoFlyBase( SwFrameFormat* pFormat, SwUndoId nUndoId );
 
     SwNodeIndex* GetMvSttIdx() const { return 
SwUndoSaveSection::GetMvSttIdx(); }
-    sal_uLong GetMvNodeCnt() const { return SwUndoSaveSection::GetMvNodeCnt(); 
}
+    SwNodeOffset GetMvNodeCnt() const { return 
SwUndoSaveSection::GetMvNodeCnt(); }
 
 public:
     virtual ~SwUndoFlyBase() override;
@@ -319,10 +320,10 @@ public:
 
 class SwUndoInsLayFormat final : public SwUndoFlyBase
 {
-    sal_uLong mnCursorSaveIndexPara;           // Cursor position
+    SwNodeOffset mnCursorSaveIndexPara;        // Cursor position
     sal_Int32 mnCursorSaveIndexPos;            // for undo
 public:
-    SwUndoInsLayFormat( SwFrameFormat* pFormat, sal_uLong nNodeIdx, sal_Int32 
nCntIdx );
+    SwUndoInsLayFormat( SwFrameFormat* pFormat, SwNodeOffset nNodeIdx, 
sal_Int32 nCntIdx );
 
     virtual ~SwUndoInsLayFormat() override;
 
diff --git a/sw/qa/core/frmedt/frmedt.cxx b/sw/qa/core/frmedt/frmedt.cxx
index 174fb70486f2..5742f230c1c4 100644
--- a/sw/qa/core/frmedt/frmedt.cxx
+++ b/sw/qa/core/frmedt/frmedt.cxx
@@ -51,9 +51,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testTextboxReanchor)
     SwFrameFormat* pTextFrameFormat = FindFrameFormat(pTextFrameObj);
     CPPUNIT_ASSERT_EQUAL(OUString("Frame2"), pTextFrameFormat->GetName());
     SwFrameFormat* pDrawShapeFormat = FindFrameFormat(pDrawShape);
-    sal_uLong nOldAnchor = 
pDrawShapeFormat->GetAnchor().GetContentAnchor()->nNode.GetIndex();
+    SwNodeOffset nOldAnchor = 
pDrawShapeFormat->GetAnchor().GetContentAnchor()->nNode.GetIndex();
     pShell->FindAnchorPos(pTextFrameObj->GetLastBoundRect().Center(), true);
-    sal_uLong nNewAnchor = 
pDrawShapeFormat->GetAnchor().GetContentAnchor()->nNode.GetIndex();
+    SwNodeOffset nNewAnchor = 
pDrawShapeFormat->GetAnchor().GetContentAnchor()->nNode.GetIndex();
     // Without the accompanying fix in place, this test would have failed with:
     // - Expected: 6
     // - Actual  : 9
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 4c839d061f0f..c43d068152b6 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1470,7 +1470,7 @@ void SwDocTest::testMarkMove()
     // cut some text
     {
         SwNodeIndex aIdx(m_pDoc->GetNodes().GetEndOfContent(), -1);
-        SwPaM aPaM(aIdx, aIdx, -1);
+        SwPaM aPaM(aIdx, aIdx, SwNodeOffset(-1));
         aPaM.GetPoint()->nContent += 5;
         aPaM.GetMark()->nContent += 6;
         m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPaM);
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx 
b/sw/qa/extras/globalfilter/globalfilter.cxx
index 761cfdf7d4b7..e38df1d0c479 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -198,7 +198,7 @@ void Test::testLinkedGraphicRT()
         // Find the image
         bool bImageFound = false;
         Graphic aGraphic;
-        for (sal_uLong nIndex = 0; nIndex < aNodes.Count(); ++nIndex)
+        for (SwNodeOffset nIndex(0); nIndex < aNodes.Count(); ++nIndex)
         {
             if (aNodes[nIndex]->IsGrfNode())
             {
@@ -1692,7 +1692,7 @@ void Test::testDateFormField()
                 sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 
8194, 8194, 8194, 8194};
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
OUString(vEnSpaces, 5), sCurrentDate);
 
-                CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
sal_uLong(9), pFieldmark->GetMarkStart().nNode.GetIndex());
+                CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
SwNodeOffset(9), pFieldmark->GetMarkStart().nNode.GetIndex());
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
sal_Int32(5), pFieldmark->GetMarkStart().nContent.GetIndex());
             }
             else if (nIndex == 1) // The second has the default format
@@ -1701,7 +1701,7 @@ void Test::testDateFormField()
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
OUString("en-US"), sLang);
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
OUString("06/12/19"), sCurrentDate);
 
-                CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
sal_uLong(9), pFieldmark->GetMarkStart().nNode.GetIndex());
+                CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
SwNodeOffset(9), pFieldmark->GetMarkStart().nNode.GetIndex());
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
sal_Int32(20), pFieldmark->GetMarkStart().nContent.GetIndex());
             }
             else if (nIndex == 2) // The third one has special format
@@ -1710,7 +1710,7 @@ void Test::testDateFormField()
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
OUString("hu-HU"), sLang);
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
OUString("2019. febr. 12."), sCurrentDate);
 
-                CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
sal_uLong(9), pFieldmark->GetMarkStart().nNode.GetIndex());
+                CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
SwNodeOffset(9), pFieldmark->GetMarkStart().nNode.GetIndex());
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
sal_Int32(40), pFieldmark->GetMarkStart().nContent.GetIndex());
 
             }
@@ -1720,7 +1720,7 @@ void Test::testDateFormField()
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
OUString("bm-ML"), sLang);
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
OUString("[select date]"), sCurrentDate);
 
-                CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
sal_uLong(9), pFieldmark->GetMarkStart().nNode.GetIndex());
+                CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
SwNodeOffset(9), pFieldmark->GetMarkStart().nNode.GetIndex());
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
sal_Int32(62), pFieldmark->GetMarkStart().nContent.GetIndex());
 
             }
@@ -1730,7 +1730,7 @@ void Test::testDateFormField()
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
OUString("en-US"), sLang);
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
OUString(""), sCurrentDate);
 
-                CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
sal_uLong(9), pFieldmark->GetMarkStart().nNode.GetIndex());
+                CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
SwNodeOffset(9), pFieldmark->GetMarkStart().nNode.GetIndex());
                 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 
sal_Int32(82), pFieldmark->GetMarkStart().nContent.GetIndex());
 
             }
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx 
b/sw/qa/extras/htmlimport/htmlimport.cxx
index 5490f5178319..86ad0a7b5cfd 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -78,7 +78,7 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testInlinedImage)
     CPPUNIT_ASSERT(xGraphic.is());
     CPPUNIT_ASSERT(xGraphic->getType() != graphic::GraphicType::EMPTY);
 
-    for (int n = 0; ; n++)
+    for (SwNodeOffset n(0); ; n++)
     {
         SwNode* pNode = pDoc->GetNodes()[ n ];
         if (SwGrfNode *pGrfNode = pNode->GetGrfNode())
diff --git a/sw/qa/extras/indexing/SearchResultLocatorTest.cxx 
b/sw/qa/extras/indexing/SearchResultLocatorTest.cxx
index 586c07b1e534..69aeba0003af 100644
--- a/sw/qa/extras/indexing/SearchResultLocatorTest.cxx
+++ b/sw/qa/extras/indexing/SearchResultLocatorTest.cxx
@@ -63,7 +63,7 @@ void SearchResultLocatorTest::testSearchResultLocator()
 
     sw::search::SearchResultLocator aLocator(pDoc);
     std::vector<sw::search::SearchIndexData> aDataVector;
-    aDataVector.emplace_back(sw::search::NodeType::WriterNode, 14);
+    aDataVector.emplace_back(sw::search::NodeType::WriterNode, 
SwNodeOffset(14));
 
     sw::search::LocationResult aResult = aLocator.find(aDataVector);
     CPPUNIT_ASSERT_EQUAL(size_t(1), aResult.maRectangles.size());
@@ -146,7 +146,7 @@ void 
SearchResultLocatorTest::testSearchResultLocatorForSdrObjects()
 
     sw::search::SearchResultLocator aLocator(pDoc);
     std::vector<sw::search::SearchIndexData> aDataVector;
-    aDataVector.emplace_back(sw::search::NodeType::CommonNode, 1, u"Circle");
+    aDataVector.emplace_back(sw::search::NodeType::CommonNode, 
SwNodeOffset(1), u"Circle");
 
     sw::search::LocationResult aResult = aLocator.find(aDataVector);
     CPPUNIT_ASSERT_EQUAL(size_t(1), aResult.maRectangles.size());
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index de9cd406ee90..1b7ad51d71c2 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2735,7 +2735,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testBtlrCell)
     SwPosition aCellStart = *pWrtShell->GetCursor()->Start();
 
     // Test that pressing "up" at the start of the cell goes to the next 
character position.
-    sal_uLong nNodeIndex = pWrtShell->GetCursor()->Start()->nNode.GetIndex();
+    SwNodeOffset nNodeIndex = 
pWrtShell->GetCursor()->Start()->nNode.GetIndex();
     sal_Int32 nIndex = pWrtShell->GetCursor()->Start()->nContent.GetIndex();
     KeyEvent aKeyEvent(0, KEY_UP);
     SwEditWin& rEditWin = pShell->GetView()->GetEditWin();
@@ -3418,7 +3418,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128399)
     SwCursorMoveState aState(CursorMoveState::NONE);
     pLayout->GetModelPositionForViewPoint(&aPosition, aPoint, &aState);
     // Second row is +3: end node, start node and the first text node in the 
2nd row.
-    sal_uLong nExpected = aFirstRow.nNode.GetIndex() + 3;
+    SwNodeOffset nExpected = aFirstRow.nNode.GetIndex() + 3;
 
     // Without the accompanying fix in place, this test would have failed with:
     // - Expected: 14
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx 
b/sw/qa/extras/mailmerge/mailmerge.cxx
index e1d1ed0aa248..e1fee48d74da 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -554,13 +554,13 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf92623, 
"tdf92623.odt", "10-testing-addresses
     // and it's a TEXT_FIELDMARK
     CPPUNIT_ASSERT_EQUAL( 
sal_Int32(IDocumentMarkAccess::MarkType::TEXT_FIELDMARK),
                             sal_Int32(IDocumentMarkAccess::GetType( **mark )) 
);
-    sal_uLong src_pos = (*mark)->GetMarkPos().nNode.GetIndex();
+    SwNodeOffset src_pos = (*mark)->GetMarkPos().nNode.GetIndex();
 
     // Get the size of the document in nodes
     SwDoc *doc = pTextDoc->GetDocShell()->GetDoc();
-    sal_uLong size = doc->GetNodes().GetEndOfContent().GetIndex() - 
doc->GetNodes().GetEndOfExtras().GetIndex();
-    CPPUNIT_ASSERT_EQUAL( sal_uLong(13), size );
-    size -= 2; // For common start and end nodes
+    SwNodeOffset size = doc->GetNodes().GetEndOfContent().GetIndex() - 
doc->GetNodes().GetEndOfExtras().GetIndex();
+    CPPUNIT_ASSERT_EQUAL( SwNodeOffset(13), size );
+    size -= SwNodeOffset(2); // For common start and end nodes
 
     // Iterate over all field marks in the target document and check that they
     // are positioned at a multitude of the document size
@@ -571,15 +571,15 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf92623, 
"tdf92623.odt", "10-testing-addresses
     // as the helping uno bookmark from the mail merge is left in the doc
     // TODO should be fixed!
     CPPUNIT_ASSERT_EQUAL(sal_Int32(20), pIDMA->getAllMarksCount());
-    std::set<sal_uLong> pages;
+    std::set<SwNodeOffset> pages;
     sal_Int32 countFieldMarks = 0;
     for( mark = pIDMA->getAllMarksBegin(); mark != pIDMA->getAllMarksEnd(); 
++mark )
     {
         IDocumentMarkAccess::MarkType markType = IDocumentMarkAccess::GetType( 
**mark );
         if( markType == IDocumentMarkAccess::MarkType::TEXT_FIELDMARK )
         {
-            sal_uLong pos = (*mark)->GetMarkPos().nNode.GetIndex() - src_pos;
-            CPPUNIT_ASSERT_EQUAL(sal_uLong(0), pos % size);
+            SwNodeOffset pos = (*mark)->GetMarkPos().nNode.GetIndex() - 
src_pos;
+            CPPUNIT_ASSERT_EQUAL(SwNodeOffset(0), pos % size);
             CPPUNIT_ASSERT(pages.insert(pos).second);
             countFieldMarks++;
         }
@@ -644,17 +644,17 @@ DECLARE_SHELL_MAILMERGE_TEST(test_sections_first_last, 
"sections_first_last.odt"
 
     // Get the size of the document in nodes
     SwDoc *pDoc = pTextDoc->GetDocShell()->GetDoc();
-    sal_uLong nSize = pDoc->GetNodes().GetEndOfContent().GetIndex() - 
pDoc->GetNodes().GetEndOfExtras().GetIndex();
-    nSize -= 2; // The common start and end node
-    CPPUNIT_ASSERT_EQUAL( sal_uLong(13), nSize );
+    SwNodeOffset nSize = pDoc->GetNodes().GetEndOfContent().GetIndex() - 
pDoc->GetNodes().GetEndOfExtras().GetIndex();
+    nSize -= SwNodeOffset(2); // The common start and end node
+    CPPUNIT_ASSERT_EQUAL( SwNodeOffset(13), nSize );
 
     SwXTextDocument* pTextDocMM = dynamic_cast<SwXTextDocument 
*>(mxMMComponent.get());
     CPPUNIT_ASSERT(pTextDocMM);
 
     SwDoc *pDocMM = pTextDocMM->GetDocShell()->GetDoc();
-    sal_uLong nSizeMM = pDocMM->GetNodes().GetEndOfContent().GetIndex() - 
pDocMM->GetNodes().GetEndOfExtras().GetIndex();
-    nSizeMM -= 2;
-    CPPUNIT_ASSERT_EQUAL( sal_uLong(10 * nSize), nSizeMM );
+    SwNodeOffset nSizeMM = pDocMM->GetNodes().GetEndOfContent().GetIndex() - 
pDocMM->GetNodes().GetEndOfExtras().GetIndex();
+    nSizeMM -= SwNodeOffset(2);
+    CPPUNIT_ASSERT_EQUAL( SwNodeOffset(10) * nSize, nSizeMM );
 
     CPPUNIT_ASSERT_EQUAL( sal_uInt16(19), 
pDocMM->GetDocShell()->GetWrtShell()->GetPhyPageNum() );
 
@@ -950,7 +950,7 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf62364, "tdf62364.odt", 
"10-testing-addresses
     {
         for (int nodeIndex = 0; nodeIndex<4; nodeIndex++)
         {
-            SwNode* aNode = rNodes[9 + pageIndex * 4 + nodeIndex];
+            SwNode* aNode = rNodes[SwNodeOffset(9 + pageIndex * 4 + 
nodeIndex)];
             CPPUNIT_ASSERT_EQUAL(true, aNode->IsTextNode());
 
             const SwTextNode* pTextNode = aNode->GetTextNode();
@@ -974,7 +974,7 @@ DECLARE_SHELL_MAILMERGE_TEST(tdf125522_shell, 
"tdf125522.odt", "10-testing-addre
     CPPUNIT_ASSERT(pTextDoc);
 
     const auto & rNodes = pTextDoc->GetDocShell()->GetDoc()->GetNodes();
-    for (sal_uLong nodeIndex = 0; nodeIndex<rNodes.Count(); nodeIndex++)
+    for (SwNodeOffset nodeIndex(0); nodeIndex<rNodes.Count(); nodeIndex++)
     {
         SwNode* aNode = rNodes[nodeIndex];
         if (aNode->StartOfSectionNode())
@@ -1110,9 +1110,9 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf121168, 
"section_ps.odt", "4_v01.ods", "Tabe
     CPPUNIT_ASSERT_EQUAL(sal_uInt16(7), 
pTextDoc->GetDocShell()->GetWrtShell()->GetPhyPageNum());
 
     SwDoc* pDocMM = pTextDoc->GetDocShell()->GetDoc();
-    sal_uLong nSizeMM = pDocMM->GetNodes().GetEndOfContent().GetIndex()
+    SwNodeOffset nSizeMM = pDocMM->GetNodes().GetEndOfContent().GetIndex()
                         - pDocMM->GetNodes().GetEndOfExtras().GetIndex() - 2;
-    CPPUNIT_ASSERT_EQUAL(sal_uLong(16), nSizeMM);
+    CPPUNIT_ASSERT_EQUAL(SwNodeOffset(16), nSizeMM);
 
     // All even pages should be empty, all sub-documents have one page
     const SwRootFrame* pLayout = 
pDocMM->getIDocumentLayoutAccess().GetCurrentLayout();
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 1eeb60366093..484c5a71b639 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -1050,7 +1050,7 @@ DECLARE_OOXMLEXPORT_TEST(testInvalidDateFormField, 
"invalid_date_form_field.docx
             CPPUNIT_ASSERT_EQUAL(OUString("en-US"), sLang);
             CPPUNIT_ASSERT_EQUAL(OUString(""), sCurrentDate);
 
-            CPPUNIT_ASSERT_EQUAL(sal_uLong(9), 
pFieldmark->GetMarkStart().nNode.GetIndex());
+            CPPUNIT_ASSERT_EQUAL(SwNodeOffset(9), 
pFieldmark->GetMarkStart().nNode.GetIndex());
             CPPUNIT_ASSERT_EQUAL(sal_Int32(5), 
pFieldmark->GetMarkStart().nContent.GetIndex());
         }
         else if (nIndex == 1) // The second has wrong date
@@ -1059,7 +1059,7 @@ DECLARE_OOXMLEXPORT_TEST(testInvalidDateFormField, 
"invalid_date_form_field.docx
             CPPUNIT_ASSERT_EQUAL(OUString("en-US"), sLang);
             CPPUNIT_ASSERT_EQUAL(OUString("2019.06.34"), sCurrentDate);
 
-            CPPUNIT_ASSERT_EQUAL(sal_uLong(9), 
pFieldmark->GetMarkStart().nNode.GetIndex());
+            CPPUNIT_ASSERT_EQUAL(SwNodeOffset(9), 
pFieldmark->GetMarkStart().nNode.GetIndex());
             CPPUNIT_ASSERT_EQUAL(sal_Int32(15), 
pFieldmark->GetMarkStart().nContent.GetIndex());
         }
         else // The third one has wrong local
@@ -1068,7 +1068,7 @@ DECLARE_OOXMLEXPORT_TEST(testInvalidDateFormField, 
"invalid_date_form_field.docx
             CPPUNIT_ASSERT_EQUAL(OUString("xxxx"), sLang);
             CPPUNIT_ASSERT_EQUAL(OUString("2019.06.11"), sCurrentDate);
 
-            CPPUNIT_ASSERT_EQUAL(sal_uLong(9), 
pFieldmark->GetMarkStart().nNode.GetIndex());
+            CPPUNIT_ASSERT_EQUAL(SwNodeOffset(9), 
pFieldmark->GetMarkStart().nNode.GetIndex());
             CPPUNIT_ASSERT_EQUAL(sal_Int32(35), 
pFieldmark->GetMarkStart().nContent.GetIndex());
         }
         ++nIndex;
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx 
b/sw/qa/extras/rtfexport/rtfexport4.cxx
index 7cb2f5cdb5ff..66dda7f8500c 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -113,10 +113,12 @@ DECLARE_RTFEXPORT_TEST(testAnchoredAtSamePosition, 
"anchor.fodt")
 
     sal_Int32 const nIndex(mbExported ? 4 : 3);
     CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_CHAR, 
rFlys[0]->GetAnchor().GetAnchorId());
-    CPPUNIT_ASSERT_EQUAL(sal_uLong(12), 
rFlys[0]->GetAnchor().GetContentAnchor()->nNode.GetIndex());
+    CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12),
+                         
rFlys[0]->GetAnchor().GetContentAnchor()->nNode.GetIndex());
     CPPUNIT_ASSERT_EQUAL(nIndex, 
rFlys[0]->GetAnchor().GetContentAnchor()->nContent.GetIndex());
     CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_CHAR, 
rFlys[1]->GetAnchor().GetAnchorId());
-    CPPUNIT_ASSERT_EQUAL(sal_uLong(12), 
rFlys[1]->GetAnchor().GetContentAnchor()->nNode.GetIndex());
+    CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12),
+                         
rFlys[1]->GetAnchor().GetContentAnchor()->nNode.GetIndex());
     CPPUNIT_ASSERT_EQUAL(nIndex, 
rFlys[1]->GetAnchor().GetContentAnchor()->nContent.GetIndex());
 }
 
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 9eaca7d123a7..3080b0bfd3f2 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -620,12 +620,12 @@ void SwTiledRenderingTest::testSearch()
     SwXTextDocument* pXTextDocument = createDoc("search.odt");
     SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
     pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
-    std::size_t nNode = 
pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex();
+    SwNodeOffset nNode = 
pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex();
 
     // First hit, in the second paragraph, before the shape.
     lcl_search(false);
     CPPUNIT_ASSERT(!pWrtShell->GetDrawView()->GetTextEditObject());
-    std::size_t nActual = 
pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex();
+    SwNodeOffset nActual = 
pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex();
     CPPUNIT_ASSERT_EQUAL(nNode + 1, nActual);
     /// Make sure we get search result selection for normal find as well, not 
only find all.
     CPPUNIT_ASSERT(!m_aSearchResultSelection.empty());
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index dbcb8edd3e1c..f155485eebd2 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -801,7 +801,7 @@ void SwUiWriterTest::testImportRTF()
     CPPUNIT_ASSERT(pRTFReader != nullptr);
     CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, aReader.Read(*pRTFReader));
 
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     CPPUNIT_ASSERT_EQUAL(OUString("fooHello world!"), pDoc->GetNodes()[nIndex 
- 1]->GetTextNode()->GetText());
     CPPUNIT_ASSERT_EQUAL(OUString("bar"), 
pDoc->GetNodes()[nIndex]->GetTextNode()->GetText());
 }
@@ -1150,13 +1150,13 @@ void SwUiWriterTest::testCp1000071()
 
     const SwRedlineTable& rTable = 
pDoc->getIDocumentRedlineAccess().GetRedlineTable();
     CPPUNIT_ASSERT_EQUAL( SwRedlineTable::size_type( 2 ), rTable.size());
-    sal_uLong redlineStart0NodeIndex = rTable[ 0 ]->Start()->nNode.GetIndex();
+    SwNodeOffset redlineStart0NodeIndex = rTable[ 0 
]->Start()->nNode.GetIndex();
     sal_Int32 redlineStart0Index = rTable[ 0 ]->Start()->nContent.GetIndex();
-    sal_uLong redlineEnd0NodeIndex = rTable[ 0 ]->End()->nNode.GetIndex();
+    SwNodeOffset redlineEnd0NodeIndex = rTable[ 0 ]->End()->nNode.GetIndex();
     sal_Int32 redlineEnd0Index = rTable[ 0 ]->End()->nContent.GetIndex();
-    sal_uLong redlineStart1NodeIndex = rTable[ 1 ]->Start()->nNode.GetIndex();
+    SwNodeOffset redlineStart1NodeIndex = rTable[ 1 
]->Start()->nNode.GetIndex();
     sal_Int32 redlineStart1Index = rTable[ 1 ]->Start()->nContent.GetIndex();
-    sal_uLong redlineEnd1NodeIndex = rTable[ 1 ]->End()->nNode.GetIndex();
+    SwNodeOffset redlineEnd1NodeIndex = rTable[ 1 ]->End()->nNode.GetIndex();
     sal_Int32 redlineEnd1Index = rTable[ 1 ]->End()->nContent.GetIndex();
 
     // Change the document layout to be 2 columns, and then undo.
@@ -1397,7 +1397,7 @@ void SwUiWriterTest::testAutoCorr()
     //Normal AutoCorrect
     pWrtShell->Insert("tset");
     pWrtShell->AutoCorrect(corr, cIns);
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     CPPUNIT_ASSERT_EQUAL(OUString("Test "), 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 
     //AutoCorrect with change style to bolt
@@ -1442,7 +1442,7 @@ void SwUiWriterTest::testTdf83260()
         rUndoManager.Undo();
     }
     // check that every text node has a layout frame
-    for (sal_uLong i = 0; i < pDoc->GetNodes().Count(); ++i)
+    for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
     {
         if (SwTextNode const*const pNode = pDoc->GetNodes()[i]->GetTextNode())
         {
@@ -1453,7 +1453,7 @@ void SwUiWriterTest::testTdf83260()
     {
         rUndoManager.Redo();
     }
-    for (sal_uLong i = 0; i < pDoc->GetNodes().Count(); ++i)
+    for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
     {
         if (SwTextNode const*const pNode = pDoc->GetNodes()[i]->GetTextNode())
         {
@@ -1464,7 +1464,7 @@ void SwUiWriterTest::testTdf83260()
     {
         rUndoManager.Undo();
     }
-    for (sal_uLong i = 0; i < pDoc->GetNodes().Count(); ++i)
+    for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
     {
         if (SwTextNode const*const pNode = pDoc->GetNodes()[i]->GetTextNode())
         {
@@ -3213,7 +3213,7 @@ void SwUiWriterTest::testTdf74363()
     const sal_Unicode cChar = ' ';
     pWrtShell->AutoCorrect(corr, cChar);
     //The word should be capitalized due to autocorrect
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     CPPUNIT_ASSERT_EQUAL(OUString("Testing "), 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 }
 
@@ -3470,13 +3470,13 @@ void SwUiWriterTest::testTdf75137()
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(true);
     pWrtShell->InsertFootnote("This is first footnote");
-    sal_uLong firstIndex = pShellCursor->GetNode().GetIndex();
+    SwNodeOffset firstIndex = pShellCursor->GetNode().GetIndex();
     pShellCursor->GotoFootnoteAnchor();
     pWrtShell->InsertFootnote("This is second footnote");
     pWrtShell->Up(false);
-    sal_uLong secondIndex = pShellCursor->GetNode().GetIndex();
+    SwNodeOffset secondIndex = pShellCursor->GetNode().GetIndex();
     pWrtShell->Down(false);
-    sal_uLong thirdIndex = pShellCursor->GetNode().GetIndex();
+    SwNodeOffset thirdIndex = pShellCursor->GetNode().GetIndex();
     CPPUNIT_ASSERT_EQUAL(firstIndex, thirdIndex);
     CPPUNIT_ASSERT(firstIndex != secondIndex);
 }
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index dc7d8b8ecf8e..e64abd60658a 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -576,7 +576,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf136453)
     SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf136453.fodt");
     SwWrtShell* const pWrtShell(pDoc->GetDocShell()->GetWrtShell());
 
-    sal_uLong const nNodes(pDoc->GetNodes().Count());
+    SwNodeOffset const nNodes(pDoc->GetNodes().Count());
 
     pWrtShell->SttEndDoc(false);
     pWrtShell->SetMark();
@@ -1486,8 +1486,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, 
testTdf108687_tabstop)
 {
     SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf108687_tabstop.odt");
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
-    sal_Int32 nStartIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(9), nStartIndex);
+    SwNodeOffset nStartIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    CPPUNIT_ASSERT_EQUAL(SwNodeOffset(9), nStartIndex);
 
     // Now pressing 'tab' should jump to the radio buttons.
     SwXTextDocument* pXTextDocument = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
@@ -4064,7 +4064,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testShapePageMove)
     CPPUNIT_ASSERT(pBodyFrame->IsLayoutFrame());
     SwFrame* pTextFrame = static_cast<SwLayoutFrame*>(pBodyFrame)->GetLower();
     CPPUNIT_ASSERT(pTextFrame->IsTextFrame());
-    sal_uLong nNodeIndex = 
static_cast<SwTextFrame*>(pTextFrame)->GetTextNodeFirst()->GetIndex();
+    SwNodeOffset nNodeIndex = 
static_cast<SwTextFrame*>(pTextFrame)->GetTextNodeFirst()->GetIndex();
 
     // Without the accompanying fix in place, this test would have failed with 
"Expected: 13;
     // Actual: 12", i.e. the shape was anchored to the last paragraph of the 
1st page, not to a
@@ -4906,7 +4906,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf143904)
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
     CPPUNIT_ASSERT(pWrtShell);
 
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
 
     dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {});
     pWrtShell->Down(false);
@@ -4929,7 +4929,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf90069)
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
     CPPUNIT_ASSERT(pWrtShell);
 
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
 
     dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {});
     pWrtShell->Down(false);
@@ -4952,7 +4952,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf109266)
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
     CPPUNIT_ASSERT(pWrtShell);
 
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     SwTextNode* pTextNode = static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex]);
 
     CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum..."), pTextNode->GetText());
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index 94e12529847d..4f8740cf9101 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -2113,14 +2113,13 @@ void 
SwUiWriterTest4::testLinesMoveBackwardsInSectionInTable()
     SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "lines-in-section-in-table.odt");
     xmlDocUniquePtr pXmlDoc = parseLayoutDump();
     assertXPath(pXmlDoc, "/root/page", 2);
-    sal_uInt32 nPara4Node
-        = getXPath(pXmlDoc, 
"/root/page[1]/body/tab/row/cell[1]/section/txt[last()]",
-                   "txtNodeIndex")
-              .toUInt32();
+    SwNodeOffset nPara4Node(
+        getXPath(pXmlDoc, 
"/root/page[1]/body/tab/row/cell[1]/section/txt[last()]", "txtNodeIndex")
+            .toUInt32());
     CPPUNIT_ASSERT_EQUAL(OUString("4"), 
pDoc->GetNodes()[nPara4Node]->GetTextNode()->GetText());
-    sal_uInt32 nPara5Node
-        = getXPath(pXmlDoc, 
"/root/page[2]/body/tab/row/cell[1]/section/txt[1]", "txtNodeIndex")
-              .toUInt32();
+    SwNodeOffset nPara5Node(
+        getXPath(pXmlDoc, "/root/page[2]/body/tab/row/cell[1]/section/txt[1]", 
"txtNodeIndex")
+            .toUInt32());
     CPPUNIT_ASSERT_EQUAL(OUString("5"), 
pDoc->GetNodes()[nPara5Node]->GetTextNode()->GetText());
 
     // Remove paragraph "4".
@@ -2134,10 +2133,9 @@ void 
SwUiWriterTest4::testLinesMoveBackwardsInSectionInTable()
     // Assert that paragraph "5" is now moved back to page 1 and is the last 
paragraph there.
     discardDumpedLayout();
     pXmlDoc = parseLayoutDump();
-    sal_uInt32 nPage1LastNode
-        = getXPath(pXmlDoc, 
"/root/page[1]/body/tab/row/cell[1]/section/txt[last()]",
-                   "txtNodeIndex")
-              .toUInt32();
+    SwNodeOffset nPage1LastNode(
+        getXPath(pXmlDoc, 
"/root/page[1]/body/tab/row/cell[1]/section/txt[last()]", "txtNodeIndex")
+            .toUInt32());
     // This was "3", paragraph "4" was deleted, but "5" was not moved 
backwards from page 2.
     CPPUNIT_ASSERT_EQUAL(OUString("5"), 
pDoc->GetNodes()[nPage1LastNode]->GetTextNode()->GetText());
 #endif
@@ -2266,15 +2264,15 @@ void SwUiWriterTest4::testTdf113686()
     SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf113686.fodt");
     xmlDocUniquePtr pXmlDoc = parseLayoutDump();
     assertXPath(pXmlDoc, "/root/page", 2);
-    sal_uInt32 nPage1LastNode
-        = getXPath(pXmlDoc, 
"/root/page[1]/body/tab/row/cell[1]/tab/row/cell[1]/txt[last()]",
-                   "txtNodeIndex")
-              .toUInt32();
+    SwNodeOffset nPage1LastNode(
+        getXPath(pXmlDoc, 
"/root/page[1]/body/tab/row/cell[1]/tab/row/cell[1]/txt[last()]",
+                 "txtNodeIndex")
+            .toUInt32());
     CPPUNIT_ASSERT_EQUAL(OUString("Table2:A1-P10"),
                          
pDoc->GetNodes()[nPage1LastNode]->GetTextNode()->GetText());
-    sal_uInt32 nPage2FirstNode
-        = getXPath(pXmlDoc, 
"/root/page[2]/body/tab/row/cell[1]/section/txt[1]", "txtNodeIndex")
-              .toUInt32();
+    SwNodeOffset nPage2FirstNode(
+        getXPath(pXmlDoc, "/root/page[2]/body/tab/row/cell[1]/section/txt[1]", 
"txtNodeIndex")
+            .toUInt32());
     CPPUNIT_ASSERT_EQUAL(OUString("Table1:A1"),
                          
pDoc->GetNodes()[nPage2FirstNode]->GetTextNode()->GetText());
 
@@ -2379,17 +2377,16 @@ void SwUiWriterTest4::testSectionInTableInTable4()
     SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf113520.fodt");
     xmlDocUniquePtr pXmlDoc = parseLayoutDump();
     assertXPath(pXmlDoc, "/root/page", 3);
-    sal_uInt32 nPage1LastNode
-        = getXPath(pXmlDoc,
-                   
"/root/page[1]/body/tab/row/cell[1]/tab/row/cell[1]/section/txt[last()]",
-                   "txtNodeIndex")
-              .toUInt32();
+    SwNodeOffset nPage1LastNode(
+        getXPath(pXmlDoc, 
"/root/page[1]/body/tab/row/cell[1]/tab/row/cell[1]/section/txt[last()]",
+                 "txtNodeIndex")
+            .toUInt32());
     CPPUNIT_ASSERT_EQUAL(OUString("Section1:P10"),
                          
pDoc->GetNodes()[nPage1LastNode]->GetTextNode()->GetText());
-    sal_uInt32 nPage3FirstNode
-        = getXPath(pXmlDoc, 
"/root/page[3]/body/tab/row/cell[1]/tab/row/cell[1]/section/txt[1]",
-                   "txtNodeIndex")
-              .toUInt32();
+    SwNodeOffset nPage3FirstNode(
+        getXPath(pXmlDoc, 
"/root/page[3]/body/tab/row/cell[1]/tab/row/cell[1]/section/txt[1]",
+                 "txtNodeIndex")
+            .toUInt32());
     CPPUNIT_ASSERT_EQUAL(OUString("Section1:P23"),
                          
pDoc->GetNodes()[nPage3FirstNode]->GetTextNode()->GetText());
 
@@ -2425,10 +2422,10 @@ void SwUiWriterTest4::testTdf112160()
     // Assert that the A2 cell is on page 1.
     SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf112160.fodt");
     xmlDocUniquePtr pXmlDoc = parseLayoutDump();
-    sal_uInt32 nA2CellNode
-        = getXPath(pXmlDoc, 
"/root/page[1]/body/tab/row[2]/cell[1]/section/txt[last()]",
-                   "txtNodeIndex")
-              .toUInt32();
+    SwNodeOffset nA2CellNode(getXPath(pXmlDoc,
+                                      
"/root/page[1]/body/tab/row[2]/cell[1]/section/txt[last()]",
+                                      "txtNodeIndex")
+                                 .toUInt32());
     CPPUNIT_ASSERT_EQUAL(OUString("Table1.A2"),
                          
pDoc->GetNodes()[nA2CellNode]->GetTextNode()->GetText());
 
@@ -2448,7 +2445,7 @@ void SwUiWriterTest4::testTdf112160()
               .toUInt32();
     // This was Table1.C2, Table1.D2 was moved to the next page, unexpected.
     CPPUNIT_ASSERT_EQUAL(OUString("Table1.D2"),
-                         
pDoc->GetNodes()[nD2CellNode]->GetTextNode()->GetText());
+                         
pDoc->GetNodes()[SwNodeOffset(nD2CellNode)]->GetTextNode()->GetText());
 #endif
 }
 
@@ -2888,7 +2885,7 @@ void SwUiWriterTest4::testTdf51223()
     SwDoc* pDoc = createSwDoc();
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
     sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     pWrtShell->Insert("i");
     pWrtShell->SplitNode(true);
     CPPUNIT_ASSERT_EQUAL(OUString("I"),
@@ -3186,7 +3183,7 @@ void SwUiWriterTest4::testRedlineAutoCorrect()
 
     SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
     pWrtShell->AutoCorrect(corr, ' ');
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
 
     // tdf#83419 This was "Ts " removing the deletion of "t" silently by 
sentence capitalization
     OUString sReplaced("ts ");
@@ -3264,7 +3261,7 @@ void SwUiWriterTest4::testRedlineAutoCorrect2()
     SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
     pWrtShell->Insert("...");
     pWrtShell->AutoCorrect(corr, ' ');
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
 
     // This was "LoremLorem,…," (duplicating the deleted comma, but without 
deletion)
     // Don't replace, if a redline starts or ends within the text.
@@ -3292,7 +3289,7 @@ void SwUiWriterTest4::testEmojiAutoCorrect()
     SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
     pWrtShell->Insert(":snowman");
     pWrtShell->AutoCorrect(corr, ':');
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     OUString sReplaced = u"☃Lorem,";
     nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
@@ -3323,7 +3320,7 @@ void SwUiWriterTest4::testTdf108423()
     const sal_Unicode cChar = '\'';
     pWrtShell->AutoCorrect(corr, cChar);
     // The word "i" should be capitalized due to autocorrect, followed by a 
typographical apostrophe
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     OUString sIApostrophe(u"I\u2019");
     CPPUNIT_ASSERT_EQUAL(sIApostrophe,
                          
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
@@ -3342,7 +3339,7 @@ void SwUiWriterTest4::testTdf106164()
     pWrtShell->Insert(u"we\u2019re");
     const sal_Unicode cChar = ' ';
     pWrtShell->AutoCorrect(corr, cChar);
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     CPPUNIT_ASSERT_EQUAL(OUString(u"We\u2019re "),
                          
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 }
@@ -3356,7 +3353,7 @@ void SwUiWriterTest4::testTdf54409()
     pWrtShell->Insert(u"\u201Ctset");
     const sal_Unicode cChar = ' ';
     pWrtShell->AutoCorrect(corr, cChar);
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     OUString sReplaced(u"\u201Ctest ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
     // testing autocorrect of test" -> test" with typographical double 
quotation mark U+201D
@@ -3380,7 +3377,7 @@ void SwUiWriterTest4::testTdf38394()
     pWrtShell->Insert(u"l\u2019");
     const sal_Unicode cChar = '"';
     pWrtShell->AutoCorrect(corr, cChar);
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     OUString sReplaced(u"l\u2019« ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
     // tdf#132301 autocorrect of qu'«
@@ -3399,7 +3396,7 @@ void SwUiWriterTest4::testTdf59666()
     pWrtShell->Insert(u"\u03C0");
     const sal_Unicode cChar = ' ';
     pWrtShell->AutoCorrect(corr, cChar);
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     CPPUNIT_ASSERT_EQUAL(OUString(u"\u03C0 "),
                          
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 }
@@ -3414,7 +3411,7 @@ void SwUiWriterTest4::testTdf133524()
     // >>
     pWrtShell->Insert(u">");
     pWrtShell->AutoCorrect(corr, '>');
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     OUString sReplaced(u"»");
     CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
     // <<
@@ -3465,7 +3462,7 @@ void SwUiWriterTest4::testTdf133524_Romanian()
     // Example: „Sentence and «word».”
     // opening primary level quote
     pWrtShell->AutoCorrect(corr, '"');
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     OUString sReplaced(u"„");
     CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
     // opening second level quote
@@ -3503,7 +3500,7 @@ void SwUiWriterTest4::testTdf128860()
     SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
     pWrtShell->Insert(u"‚word");
     pWrtShell->AutoCorrect(corr, '\'');
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     OUString sReplaced(u"‚word‘");
     CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
     // Us apostrophe without preceding starting quote: word' -> word’
@@ -3526,7 +3523,7 @@ void SwUiWriterTest4::testTdf123786()
     SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
     pWrtShell->Insert(u"„слово");
     pWrtShell->AutoCorrect(corr, '\'');
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     OUString sReplaced(u"„слово“");
     CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
     // Us apostrophe without preceding starting quote: word' -> word’
@@ -3550,7 +3547,7 @@ void SwUiWriterTest4::testTdf133589()
     SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
     pWrtShell->Insert(u"székely");
     pWrtShell->AutoCorrect(corr, ' ');
-    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     OUString sReplaced(u"𐳥𐳋𐳓𐳉𐳗 ");
     CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
     // disambiguate consonants: asszony -> asz|szony
diff --git a/sw/qa/extras/ww8export/ww8export.cxx 
b/sw/qa/extras/ww8export/ww8export.cxx
index 94f2c1753793..07341ff7e15e 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -1381,7 +1381,7 @@ DECLARE_WW8EXPORT_TEST(testRES_MIRROR_GRAPH_BOTH, 
"tdf56321_flipImage_both.doc")
     SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
     CPPUNIT_ASSERT(pDoc);
 
-    for (int n = 0; ; n++)
+    for (SwNodeOffset n(0); ; n++)
     {
         SwNode* pNode = pDoc->GetNodes()[ n ];
         if (SwGrfNode *pGrfNode = pNode->GetGrfNode())
diff --git a/sw/qa/extras/ww8import/ww8import.cxx 
b/sw/qa/extras/ww8import/ww8import.cxx
index 0a585dc5e43b..7eb0c9f6b221 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -113,7 +113,7 @@ CPPUNIT_TEST_FIXTURE(Test, testImageLazyRead0size)
     // bitmap.
     SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
-    SwNode* pNode = pDoc->GetNodes()[6];
+    SwNode* pNode = pDoc->GetNodes()[SwNodeOffset(6)];
     SwGrfNode* pGrfNode = pNode->GetGrfNode();
     CPPUNIT_ASSERT(pGrfNode);
     // Without the accompanying fix in place, this test would have failed with:
@@ -198,7 +198,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf125281)
     // Load a .doc file which has an embedded .emf image.
     SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
-    SwNode* pNode = pDoc->GetNodes()[6];
+    SwNode* pNode = pDoc->GetNodes()[SwNodeOffset(6)];
     CPPUNIT_ASSERT(pNode->IsGrfNode());
     SwGrfNode* pGrfNode = pNode->GetGrfNode();
     const Graphic& rGraphic = pGrfNode->GetGrf();
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index 071b2baf06c1..03162a0a33ad 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -936,7 +936,7 @@ void AccessibilityCheck::check()
 
     auto const& pNodes = m_pDoc->GetNodes();
     SwNode* pNode = nullptr;
-    for (sal_uLong n = 0; n < pNodes.Count(); ++n)
+    for (SwNodeOffset n(0); n < pNodes.Count(); ++n)
     {
         pNode = pNodes[n];
         if (pNode)
diff --git a/sw/source/core/access/accframebase.cxx 
b/sw/source/core/access/accframebase.cxx
index d2c7aac44a9e..d2d3217c9297 100644
--- a/sw/source/core/access/accframebase.cxx
+++ b/sw/source/core/access/accframebase.cxx
@@ -295,7 +295,7 @@ bool SwAccessibleFrameBase::GetSelectedState( )
         if( pCursor != nullptr )
         {
             const SwTextNode* pNode = pPos->nNode.GetNode().GetTextNode();
-            sal_uLong nHere = pNode->GetIndex();
+            SwNodeOffset nHere = pNode->GetIndex();
 
             // iterate over ring
             SwPaM* pRingStart = pCursor;
@@ -306,9 +306,9 @@ bool SwAccessibleFrameBase::GetSelectedState( )
                 {
                     // check whether nHere is 'inside' pCursor
                     SwPosition* pStart = pCursor->Start();
-                    sal_uLong nStartIndex = pStart->nNode.GetIndex();
+                    SwNodeOffset nStartIndex = pStart->nNode.GetIndex();
                     SwPosition* pEnd = pCursor->End();
-                    sal_uLong nEndIndex = pEnd->nNode.GetIndex();
+                    SwNodeOffset nEndIndex = pEnd->nNode.GetIndex();
                     if( ( nHere >= nStartIndex ) && (nHere <= nEndIndex)  )
                     {
                         if( rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR )
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index c1c4eebcfb2e..62a5f61c5c2b 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -1229,8 +1229,8 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
                     {
                         const SwTextNode* pNode = 
pPos->nNode.GetNode().GetTextNode();
                         SwTextFrame const*const 
pFrame(static_cast<SwTextFrame*>(pNode->getLayoutFrame(pVSh->GetLayout())));
-                        sal_uLong 
nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
-                        sal_uLong nLastNode;
+                        SwNodeOffset 
nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
+                        SwNodeOffset nLastNode;
                         if (sw::MergedPara const*const pMerged = 
pFrame->GetMergedPara())
                         {
                             nLastNode = pMerged->pLastNode->GetIndex();
@@ -1240,7 +1240,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
                             nLastNode = nFirstNode;
                         }
 
-                        sal_uLong nHere = pNode->GetIndex();
+                        SwNodeOffset nHere = pNode->GetIndex();
 
                         for(SwPaM& rTmpCursor : pCursor->GetRingContainer())
                         {
@@ -1250,9 +1250,9 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
                                 bMarked = true;
                                 // check whether nHere is 'inside' pCursor
                                 SwPosition* pStart = rTmpCursor.Start();
-                                sal_uLong nStartIndex = 
pStart->nNode.GetIndex();
+                                SwNodeOffset nStartIndex = 
pStart->nNode.GetIndex();
                                 SwPosition* pEnd = rTmpCursor.End();
-                                sal_uLong nEndIndex = pEnd->nNode.GetIndex();
+                                SwNodeOffset nEndIndex = 
pEnd->nNode.GetIndex();
                                 if ((nStartIndex <= nLastNode) && (nFirstNode 
<= nEndIndex))
                                 {
                                     if( rAnchor.GetAnchorId() == 
RndStdIds::FLY_AS_CHAR )
diff --git a/sw/source/core/access/accpara.cxx 
b/sw/source/core/access/accpara.cxx
index 6be041d8c585..9ac2fa8bfc89 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -2968,8 +2968,8 @@ sal_Int32 SAL_CALL 
SwAccessibleParagraph::getSelectedPortionCount(  )
     {
         // get SwPosition for my node
         SwTextFrame const*const pFrame(static_cast<SwTextFrame 
const*>(GetFrame()));
-        sal_uLong nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
-        sal_uLong nLastNode;
+        SwNodeOffset nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
+        SwNodeOffset nLastNode;
         if (sw::MergedPara const*const pMerged = pFrame->GetMergedPara())
         {
             nLastNode = pMerged->pLastNode->GetIndex();
@@ -2987,9 +2987,9 @@ sal_Int32 SAL_CALL 
SwAccessibleParagraph::getSelectedPortionCount(  )
             {
                 // check whether frame's node(s) are 'inside' pCursor
                 SwPosition* pStart = rTmpCursor.Start();
-                sal_uLong nStartIndex = pStart->nNode.GetIndex();
+                SwNodeOffset nStartIndex = pStart->nNode.GetIndex();
                 SwPosition* pEnd = rTmpCursor.End();
-                sal_uLong nEndIndex = pEnd->nNode.GetIndex();
+                SwNodeOffset nEndIndex = pEnd->nNode.GetIndex();
                 if ((nStartIndex <= nLastNode) && (nFirstNode <= nEndIndex))
                 {
                     nSelected++;
@@ -3042,8 +3042,8 @@ sal_Bool SAL_CALL SwAccessibleParagraph::removeSelection( 
sal_Int32 selectionInd
 
         // get SwPosition for my node
         SwTextFrame const*const pFrame(static_cast<SwTextFrame 
const*>(GetFrame()));
-        sal_uLong nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
-        sal_uLong nLastNode;
+        SwNodeOffset nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
+        SwNodeOffset nLastNode;
         if (sw::MergedPara const*const pMerged = pFrame->GetMergedPara())
         {
             nLastNode = pMerged->pLastNode->GetIndex();
@@ -3062,9 +3062,9 @@ sal_Bool SAL_CALL SwAccessibleParagraph::removeSelection( 
sal_Int32 selectionInd
             {
                 // check whether frame's node(s) are 'inside' pCursor
                 SwPosition* pStart = pCursor->Start();
-                sal_uLong nStartIndex = pStart->nNode.GetIndex();
+                SwNodeOffset nStartIndex = pStart->nNode.GetIndex();
                 SwPosition* pEnd = pCursor->End();
-                sal_uLong nEndIndex = pEnd->nNode.GetIndex();
+                SwNodeOffset nEndIndex = pEnd->nNode.GetIndex();
                 if ((nStartIndex <= nLastNode) && (nFirstNode <= nEndIndex))
                 {
                     if( nSelected == 0 )
@@ -3348,8 +3348,8 @@ bool SwAccessibleParagraph::GetSelectionAtIndex(
     {
         // get SwPosition for my node
         SwTextFrame const*const pFrame(static_cast<SwTextFrame 
const*>(GetFrame()));
-        sal_uLong nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
-        sal_uLong nLastNode;
+        SwNodeOffset nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
+        SwNodeOffset nLastNode;
         if (sw::MergedPara const*const pMerged = pFrame->GetMergedPara())
         {
             nLastNode = pMerged->pLastNode->GetIndex();
@@ -3367,9 +3367,9 @@ bool SwAccessibleParagraph::GetSelectionAtIndex(
             {
                 // check whether frame's node(s) are 'inside' pCursor
                 SwPosition* pStart = rTmpCursor.Start();
-                sal_uLong nStartIndex = pStart->nNode.GetIndex();
+                SwNodeOffset nStartIndex = pStart->nNode.GetIndex();
                 SwPosition* pEnd = rTmpCursor.End();
-                sal_uLong nEndIndex = pEnd->nNode.GetIndex();
+                SwNodeOffset nEndIndex = pEnd->nNode.GetIndex();
                 if ((nStartIndex <= nLastNode) && (nFirstNode <= nEndIndex))
                 {
                     if (!pSelection || *pSelection == 0)
diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx
index 56288c840bbe..81685b777033 100644
--- a/sw/source/core/attr/hints.cxx
+++ b/sw/source/core/attr/hints.cxx
@@ -179,7 +179,7 @@ void SwFindNearestNode::CheckNode( const SwNode& rNd )
 {
     if( &m_pNode->GetNodes() == &rNd.GetNodes() )
     {
-        sal_uLong nIdx = rNd.GetIndex();
+        SwNodeOffset nIdx = rNd.GetIndex();
         if( nIdx < m_pNode->GetIndex() &&
             ( !m_pFound || nIdx > m_pFound->GetIndex() ) &&
             nIdx > rNd.GetNodes().GetEndOfExtras().GetIndex() )
diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx
index 7fe9b5571a43..3fa1eaec186e 100644
--- a/sw/source/core/bastyp/index.cxx
+++ b/sw/source/core/bastyp/index.cxx
@@ -388,4 +388,9 @@ std::ostream& operator <<(std::ostream& s, const SwIndex& 
index)
     return s << "SwIndex offset (" << index.GetIndex() << ")";
 }
 
+std::ostream& operator <<(std::ostream& s, const SwNodeOffset& index)
+{
+    return s << sal_Int32(index);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/crsr/bookmark.cxx b/sw/source/core/crsr/bookmark.cxx
index 6e7863d7dc7d..2945b018bb8b 100644
--- a/sw/source/core/crsr/bookmark.cxx
+++ b/sw/source/core/crsr/bookmark.cxx
@@ -59,11 +59,11 @@ namespace sw::mark
         SwPosition const& rStartPos(rMark.GetMarkStart());
         SwPosition const& rEndPos(rMark.GetMarkEnd());
         SwNodes const& rNodes(rStartPos.nNode.GetNodes());
-        sal_uLong const nStartNode(rStartPos.nNode.GetIndex());
-        sal_uLong const nEndNode(rEndPos.nNode.GetIndex());
+        SwNodeOffset const nStartNode(rStartPos.nNode.GetIndex());
+        SwNodeOffset const nEndNode(rEndPos.nNode.GetIndex());
         int nFields(0);
         std::optional<SwPosition> ret;
-        for (sal_uLong n = nEndNode; nStartNode <= n; --n)
+        for (SwNodeOffset n = nEndNode; nStartNode <= n; --n)
         {
             SwNode *const pNode(rNodes[n]);
             if (pNode->IsTextNode())
@@ -292,7 +292,7 @@ namespace sw::mark
     OUString MarkBase::ToString( ) const
     {
         return "Mark: ( Name, [ Node1, Index1 ] ): ( " + m_aName + ", [ "
-            + OUString::number( GetMarkPos().nNode.GetIndex( ) )  + ", "
+            + OUString::number( sal_Int32(GetMarkPos().nNode.GetIndex()) )  + 
", "
             + OUString::number( GetMarkPos().nContent.GetIndex( ) ) + " ] )";
     }
 
@@ -513,9 +513,9 @@ namespace sw::mark
     OUString Fieldmark::ToString( ) const
     {
         return "Fieldmark: ( Name, Type, [ Nd1, Id1 ], [ Nd2, Id2 ] ): ( " + 
m_aName + ", "
-            + m_aFieldname + ", [ " + OUString::number( 
GetMarkPos().nNode.GetIndex( ) )
+            + m_aFieldname + ", [ " + OUString::number( 
sal_Int32(GetMarkPos().nNode.GetIndex( )) )
             + ", " + OUString::number( GetMarkPos( ).nContent.GetIndex( ) ) + 
" ], ["
-            + OUString::number( GetOtherMarkPos().nNode.GetIndex( ) ) + ", "
+            + OUString::number( sal_Int32(GetOtherMarkPos().nNode.GetIndex( )) 
) + ", "
             + OUString::number( GetOtherMarkPos( ).nContent.GetIndex( ) ) + " 
] ) ";
     }
 
diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index 955622409af8..50a1fc99eec9 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -106,7 +106,7 @@ SwCallLink::~SwCallLink() COVERITY_NOEXCEPT_FALSE
 
     const SwDoc *pDoc=m_rShell.GetDoc();
     const SwContentNode *pNode = nullptr;
-    if ( pDoc && m_nNode < pDoc->GetNodes( ).Count( ) )
+    if ( pDoc && sal_Int32(m_nNode) < sal_Int32(pDoc->GetNodes( ).Count( )) )
     {
         pNode = pDoc->GetNodes()[m_nNode]->GetContentNode();
     }
@@ -114,7 +114,7 @@ SwCallLink::~SwCallLink() COVERITY_NOEXCEPT_FALSE
 
     sal_Int32 nCmp, nCurrentContent = 
pCurrentCursor->GetPoint()->nContent.GetIndex();
     SwNodeType nNdWhich = pCNd->GetNodeType();
-    sal_uLong nCurrentNode = pCurrentCursor->GetPoint()->nNode.GetIndex();
+    SwNodeOffset nCurrentNode = pCurrentCursor->GetPoint()->nNode.GetIndex();
 
     // Register the Shell as dependent at the current Node. By doing this all
     // attribute changes can be signaled over the link.
diff --git a/sw/source/core/crsr/callnk.hxx b/sw/source/core/crsr/callnk.hxx
index e3875ddfa08b..ccac918e51ca 100644
--- a/sw/source/core/crsr/callnk.hxx
+++ b/sw/source/core/crsr/callnk.hxx
@@ -23,6 +23,7 @@
 #include <tools/long.hxx>
 #include <tools/solar.h>
 #include <ndtyp.hxx>
+#include <nodeoffset.hxx>
 
 class SwCursorShell;
 class SwTextNode;
@@ -32,7 +33,7 @@ class SwCallLink
 {
 public:
     SwCursorShell & m_rShell;
-    sal_uLong m_nNode;
+    SwNodeOffset m_nNode;
     tools::Long m_nLeftFramePos;
     sal_Int32 m_nContent;
     SwNodeType m_nNodeType;
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 1a59b16ba2de..ae7b2c81133d 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2549,7 +2549,7 @@ OUString SwCursorShell::GetSelText() const
             OUStringBuffer buf;
             SwPosition const*const pStart(m_pCurrentCursor->Start());
             SwPosition const*const pEnd(m_pCurrentCursor->End());
-            for (sal_uLong i = pStart->nNode.GetIndex(); i <= 
pEnd->nNode.GetIndex(); ++i)
+            for (SwNodeOffset i = pStart->nNode.GetIndex(); i <= 
pEnd->nNode.GetIndex(); ++i)
             {
                 SwNode const& rNode(*pStart->nNode.GetNodes()[i]);
                 assert(!rNode.IsEndNode());
@@ -2849,7 +2849,7 @@ void SwCursorShell::ParkPams( SwPaM* pDelRg, 
SwShellCursor** ppDelRing )
             else
             {
                 pTmpDel->GetPoint()->nContent.Assign(nullptr, 0);
-                pTmpDel->GetPoint()->nNode = 0;
+                pTmpDel->GetPoint()->nNode = SwNodeOffset(0);
                 pTmpDel->DeleteMark();
             }
             pTmpDel = nullptr;
@@ -2911,7 +2911,7 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
                 if ( pTableNd )
                 {
                     pTCursor->GetPoint()->nContent.Assign(nullptr, 0);
-                    pTCursor->GetPoint()->nNode = 0;
+                    pTCursor->GetPoint()->nNode = SwNodeOffset(0);
                     pTCursor->DeleteMark();
                     pSh->m_pCurrentCursor->GetPoint()->nNode = *pTableNd;
                 }
@@ -3056,7 +3056,7 @@ bool SwCursorShell::ShouldWait() const
         return true;
 
     SwPaM* pPam = GetCursor();
-    return pPam->Start()->nNode.GetIndex() + 10 <
+    return pPam->Start()->nNode.GetIndex() + SwNodeOffset(10) <
             pPam->End()->nNode.GetIndex();
 }
 
@@ -3124,7 +3124,7 @@ bool SwCursorShell::FindValidContentNode( bool bOnlyText )
 
     // first check for frames
     SwNodeIndex& rNdIdx = m_pCurrentCursor->GetPoint()->nNode;
-    sal_uLong nNdIdx = rNdIdx.GetIndex(); // keep backup
+    SwNodeOffset nNdIdx = rNdIdx.GetIndex(); // keep backup
     SwNodes& rNds = mxDoc->GetNodes();
     SwContentNode* pCNd = rNdIdx.GetNode().GetContentNode();
     const SwContentFrame * pFrame;
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index e2e5822a3103..b7ec27fcb6a2 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -400,7 +400,7 @@ bool SwCursorShell::GotoNxtPrvTableFormula( bool bNext, 
bool bOnlyErrors )
     Point aPt;
     SwPosition aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
     if( !bNext )
-        aFndPos.nNode = 0;
+        aFndPos.nNode = SwNodeOffset(0);
     SetGetExpField aFndGEF( aFndPos ), aCurGEF( rPos );
 
     {
@@ -466,7 +466,7 @@ bool SwCursorShell::GotoNxtPrvTableFormula( bool bNext, 
bool bOnlyErrors )
                 {
                     if( bNext )
                     {
-                        rPos.nNode = 0;
+                        rPos.nNode = SwNodeOffset(0);
                         rPos.nContent = 0;
                         aCurGEF = SetGetExpField( rPos );
                         SvxSearchDialogWrapper::SetSearchLabel( 
SearchLabel::EndWrapped );
@@ -518,7 +518,7 @@ bool SwCursorShell::GotoNxtPrvTOXMark( bool bNext )
     Point aPt;
     SwPosition aFndPos( GetDoc()->GetNodes().GetEndOfContent() );
     if( !bNext )
-        aFndPos.nNode = 0;
+        aFndPos.nNode = SwNodeOffset(0);
     SetGetExpField aFndGEF( aFndPos ), aCurGEF( rPos );
 
     if( rPos.nNode.GetIndex() < 
GetDoc()->GetNodes().GetEndOfExtras().GetIndex() )
@@ -568,7 +568,7 @@ bool SwCursorShell::GotoNxtPrvTOXMark( bool bNext )
                 {
                     if ( bNext )
                     {
-                        rPos.nNode = 0;
+                        rPos.nNode = SwNodeOffset(0);
                         rPos.nContent = 0;
                         aCurGEF = SetGetExpField( rPos );
                         SvxSearchDialogWrapper::SetSearchLabel( 
SearchLabel::EndWrapped );
@@ -1828,7 +1828,7 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
                     pTextNd->SwContentNode::GetAttr( aSet );
 
                 rContentAtPos.sStr = "Pos: (";
-                rContentAtPos.sStr += OUString::number( aPos.nNode.GetIndex());
+                rContentAtPos.sStr += OUString::number( 
sal_Int32(aPos.nNode.GetIndex()));
                 rContentAtPos.sStr += ":";
                 rContentAtPos.sStr += OUString::number( 
aPos.nContent.GetIndex());
                 rContentAtPos.sStr += ")";
@@ -2463,7 +2463,7 @@ bool SwCursorShell::SelectNxtPrvHyperlink( bool bNext )
     SwNodes& rNds = GetDoc()->GetNodes();
     const SwNode* pBodyEndNd = &rNds.GetEndOfContent();
     const SwNode* pBodySttNd = pBodyEndNd->StartOfSectionNode();
-    sal_uLong nBodySttNdIdx = pBodySttNd->GetIndex();
+    SwNodeOffset nBodySttNdIdx = pBodySttNd->GetIndex();
     Point aPt;
 
     SetGetExpField aCmpPos( SwPosition( bNext ? *pBodyEndNd : *pBodySttNd ) );
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 79405979143b..9cd8a59dbd06 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -903,8 +903,8 @@ bool DoSearch(SwPaM & rSearchPam,
         if( (bSrchForward || pSttNd != &rNdIdx.GetNode()) &&
             rSearchPam.Move(fnMoveForward, GoInContent) &&

... etc. - the rest is truncated

Reply via email to