diff options
Diffstat (limited to 'sw/inc')
-rw-r--r-- | sw/inc/IDocumentFieldsAccess.hxx | 5 | ||||
-rw-r--r-- | sw/inc/SwUndoField.hxx | 2 | ||||
-rw-r--r-- | sw/inc/ToxTabStopTokenHandler.hxx | 5 | ||||
-rw-r--r-- | sw/inc/crsrsh.hxx | 2 | ||||
-rw-r--r-- | sw/inc/ddefld.hxx | 4 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 8 | ||||
-rw-r--r-- | sw/inc/edglbldc.hxx | 6 | ||||
-rw-r--r-- | sw/inc/edimp.hxx | 4 | ||||
-rw-r--r-- | sw/inc/editsh.hxx | 2 | ||||
-rw-r--r-- | sw/inc/fldbas.hxx | 3 | ||||
-rw-r--r-- | sw/inc/fmtfld.hxx | 5 | ||||
-rw-r--r-- | sw/inc/ndarr.hxx | 21 | ||||
-rw-r--r-- | sw/inc/ndindex.hxx | 96 | ||||
-rw-r--r-- | sw/inc/ndtxt.hxx | 2 | ||||
-rw-r--r-- | sw/inc/node.hxx | 23 | ||||
-rw-r--r-- | sw/inc/nodeoffset.hxx | 39 | ||||
-rw-r--r-- | sw/inc/pam.hxx | 5 | ||||
-rw-r--r-- | sw/inc/postithelper.hxx | 3 | ||||
-rw-r--r-- | sw/inc/redline.hxx | 2 | ||||
-rw-r--r-- | sw/inc/shellio.hxx | 2 | ||||
-rw-r--r-- | sw/inc/swbaslnk.hxx | 2 | ||||
-rw-r--r-- | sw/inc/swcrsr.hxx | 6 | ||||
-rw-r--r-- | sw/inc/swtable.hxx | 9 | ||||
-rw-r--r-- | sw/inc/undobj.hxx | 37 |
24 files changed, 172 insertions, 121 deletions
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; |