diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-03-16 09:30:20 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-03-16 09:30:20 +0100 |
commit | a6ded3b0137f378a9e7a83903193d6e3fd9b0126 (patch) | |
tree | 3707745222b1a37adc153c4ad1ca118af0ecc268 | |
parent | 3a122347b9a47f1ff7103364e90b77bc605fafce (diff) |
Clean up integers representing positions in SwOutlineNodes vectors
Change-Id: If1a6a9cb61ffd355a85835127e7c893969833587
26 files changed, 108 insertions, 101 deletions
diff --git a/include/o3tl/sorted_vector.hxx b/include/o3tl/sorted_vector.hxx index a2267c005003..f18ff04588b6 100644 --- a/include/o3tl/sorted_vector.hxx +++ b/include/o3tl/sorted_vector.hxx @@ -37,6 +37,7 @@ private: typedef typename std::vector<Value>::iterator iterator; public: typedef typename std::vector<Value>::const_iterator const_iterator; + typedef typename std::vector<Value>::difference_type difference_type; typedef typename std::vector<Value>::size_type size_type; // MODIFIERS diff --git a/sw/inc/IDocumentOutlineNodes.hxx b/sw/inc/IDocumentOutlineNodes.hxx index f4aa9b2fb259..6b69da672d30 100644 --- a/sw/inc/IDocumentOutlineNodes.hxx +++ b/sw/inc/IDocumentOutlineNodes.hxx @@ -23,6 +23,7 @@ #include <rtl/ustring.hxx> #include <sal/types.h> #include <vector> + class SwTextNode; /** Provides outline nodes of a document. @@ -32,14 +33,14 @@ class IDocumentOutlineNodes public: typedef std::vector< const SwTextNode* > tSortedOutlineNodeList; - virtual sal_Int32 getOutlineNodesCount() const = 0; + virtual tSortedOutlineNodeList::size_type getOutlineNodesCount() const = 0; - virtual int getOutlineLevel( const sal_Int32 nIdx ) const = 0; - virtual OUString getOutlineText( const sal_Int32 nIdx, + virtual int getOutlineLevel( const tSortedOutlineNodeList::size_type nIdx ) const = 0; + virtual OUString getOutlineText( const tSortedOutlineNodeList::size_type nIdx, const bool bWithNumber = true, const bool bWithSpacesForLevel = false, const bool bWithFootnote = true ) const = 0; - virtual SwTextNode* getOutlineNode( const sal_Int32 nIdx ) const = 0; + virtual SwTextNode* getOutlineNode( const tSortedOutlineNodeList::size_type nIdx ) const = 0; virtual void getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList& orOutlineNodeList ) const = 0; diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 37a14b7b2eb5..feafb1a2207a 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -600,12 +600,12 @@ public: bool GotoOutline( const OUString& rName ); // to the next/previous or the given OutlineNode - void GotoOutline( sal_uInt16 nIdx ); + void GotoOutline( SwOutlineNodes::size_type nIdx ); // find the "outline position" in the nodes array of the current chapter - sal_uInt16 GetOutlinePos( sal_uInt8 nLevel = UCHAR_MAX ); + SwOutlineNodes::size_type GetOutlinePos( sal_uInt8 nLevel = UCHAR_MAX ); // select the given range of OutlineNodes. Optionally including the children // the sal_uInt16s are the positions in OutlineNodes-Array (EditShell) - bool MakeOutlineSel( sal_uInt16 nSttPos, sal_uInt16 nEndPos, + bool MakeOutlineSel( SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos, bool bWithChildren ); bool GotoNextOutline(); diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index bc20780a04de..6b0d0c3e9321 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1043,7 +1043,7 @@ public: bool OutlineUpDown( const SwPaM& rPam, short nOffset ); // Ountline - move up / move down. - bool MoveOutlinePara( const SwPaM& rPam, short nOffset); + bool MoveOutlinePara( const SwPaM& rPam, SwOutlineNodes::difference_type nOffset); bool GotoOutline( SwPosition& rPos, const OUString& rName ) const; diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index c352a647ab5e..762389448461 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -462,7 +462,7 @@ public: bool OutlineUpDown( short nOffset = 1 ); - bool MoveOutlinePara( short nOffset = 1); + bool MoveOutlinePara( SwOutlineNodes::difference_type nOffset = 1); bool IsProtectedOutlinePara() const; @@ -800,8 +800,8 @@ public: /** May an outline be moved or copied? Check whether it's in text body, not in table, and not read-only (move). */ - bool IsOutlineMovable( sal_uInt16 nIdx ) const; - bool IsOutlineCopyable( sal_uInt16 nIdx ) const; + bool IsOutlineMovable( SwOutlineNodes::size_type nIdx ) const; + bool IsOutlineCopyable( SwOutlineNodes::size_type nIdx ) const; sal_uInt16 GetLineCount(); diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index 978d814dfe4b..adf94d7b4948 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -20,6 +20,9 @@ #ifndef INCLUDED_SW_INC_NDARR_HXX #define INCLUDED_SW_INC_NDARR_HXX +#include <sal/config.h> + +#include <limits> #include <vector> #include <memory> @@ -79,7 +82,9 @@ struct CompareSwOutlineNodes class SwOutlineNodes : public o3tl::sorted_vector<SwNode*, CompareSwOutlineNodes> { public: - bool Seek_Entry(SwNode* rP, sal_uInt16* pnPos) const; + static constexpr auto npos = std::numeric_limits<size_type>::max(); + + bool Seek_Entry(SwNode* rP, size_type* pnPos) const; }; struct SwTableToTextSave; diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 80d9823c2a09..7e48aaa7f704 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -18,6 +18,7 @@ */ #include <memory> +#include <utility> #include <hintids.hxx> #include <comphelper/string.hxx> #include <svl/itemiter.hxx> @@ -910,7 +911,7 @@ sal_Int32 SwCursorShell::EndOfInputFieldAtPos( const SwPosition& rPos ) return *(pTextInputField->End()); } -void SwCursorShell::GotoOutline( sal_uInt16 nIdx ) +void SwCursorShell::GotoOutline( SwOutlineNodes::size_type nIdx ) { SwCursor* pCursor = getShellCursor( true ); @@ -951,7 +952,7 @@ bool SwCursorShell::GotoNextOutline() const SwNodes& rNds = GetDoc()->GetNodes(); SwNode* pNd = &(pCursor->GetNode()); - sal_uInt16 nPos; + SwOutlineNodes::size_type nPos; if( rNds.GetOutLineNds().Seek_Entry( pNd, &nPos )) ++nPos; @@ -979,7 +980,7 @@ bool SwCursorShell::GotoPrevOutline() const SwNodes& rNds = GetDoc()->GetNodes(); SwNode* pNd = &(pCursor->GetNode()); - sal_uInt16 nPos; + SwOutlineNodes::size_type nPos; bool bRet = rNds.GetOutLineNds().Seek_Entry(pNd, &nPos); if (bRet && nPos) { @@ -1003,13 +1004,13 @@ bool SwCursorShell::GotoPrevOutline() } /// search "outline position" before previous outline node at given level -sal_uInt16 SwCursorShell::GetOutlinePos( sal_uInt8 nLevel ) +SwOutlineNodes::size_type SwCursorShell::GetOutlinePos( sal_uInt8 nLevel ) { SwPaM* pCursor = getShellCursor( true ); const SwNodes& rNds = GetDoc()->GetNodes(); SwNode* pNd = &(pCursor->GetNode()); - sal_uInt16 nPos; + SwOutlineNodes::size_type nPos; if( rNds.GetOutLineNds().Seek_Entry( pNd, &nPos )) nPos++; // is at correct position; take next for while @@ -1021,10 +1022,10 @@ sal_uInt16 SwCursorShell::GetOutlinePos( sal_uInt8 nLevel ) return nPos; } - return USHRT_MAX; // no more left + return SwOutlineNodes::npos; // no more left } -bool SwCursorShell::MakeOutlineSel( sal_uInt16 nSttPos, sal_uInt16 nEndPos, +bool SwCursorShell::MakeOutlineSel( SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos, bool bWithChildren ) { const SwNodes& rNds = GetDoc()->GetNodes(); @@ -1038,9 +1039,7 @@ bool SwCursorShell::MakeOutlineSel( sal_uInt16 nSttPos, sal_uInt16 nEndPos, if( nSttPos > nEndPos ) // parameters switched? { OSL_ENSURE( false, "Start > End for array access" ); - sal_uInt16 nTmp = nSttPos; - nSttPos = nEndPos; - nEndPos = nTmp; + std::swap(nSttPos, nEndPos); } SwNode* pSttNd = rOutlNds[ nSttPos ]; diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx index 249401305d91..c996ed76f62b 100644 --- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx +++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx @@ -507,7 +507,7 @@ bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr, const int nLvl = pNd->GetTextNode()->GetAttrOutlineLevel()-1; const SwOutlineNodes& rOutlNds = m_rDoc.GetNodes().GetOutLineNds(); - sal_uInt16 nTmpPos; + SwOutlineNodes::size_type nTmpPos; (void)rOutlNds.Seek_Entry( pNd, &nTmpPos ); rpRange = new SwNodeRange( aPos.nNode, 0, aPos.nNode ); diff --git a/sw/source/core/doc/DocumentOutlineNodesManager.cxx b/sw/source/core/doc/DocumentOutlineNodesManager.cxx index 95d0789fe849..c129887b7f68 100644 --- a/sw/source/core/doc/DocumentOutlineNodesManager.cxx +++ b/sw/source/core/doc/DocumentOutlineNodesManager.cxx @@ -27,18 +27,18 @@ DocumentOutlineNodesManager::DocumentOutlineNodesManager( SwDoc& i_rSwdoc ) : m_ { } -sal_Int32 DocumentOutlineNodesManager::getOutlineNodesCount() const +IDocumentOutlineNodes::tSortedOutlineNodeList::size_type DocumentOutlineNodesManager::getOutlineNodesCount() const { return m_rDoc.GetNodes().GetOutLineNds().size(); } -int DocumentOutlineNodesManager::getOutlineLevel( const sal_Int32 nIdx ) const +int DocumentOutlineNodesManager::getOutlineLevel( const tSortedOutlineNodeList::size_type nIdx ) const { return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]-> GetTextNode()->GetAttrOutlineLevel()-1; } -OUString DocumentOutlineNodesManager::getOutlineText( const sal_Int32 nIdx, +OUString DocumentOutlineNodesManager::getOutlineText( const tSortedOutlineNodeList::size_type nIdx, const bool bWithNumber, const bool bWithSpacesForLevel, const bool bWithFootnote ) const @@ -48,7 +48,7 @@ OUString DocumentOutlineNodesManager::getOutlineText( const sal_Int32 nIdx, bWithNumber, bWithSpacesForLevel, bWithFootnote ); } -SwTextNode* DocumentOutlineNodesManager::getOutlineNode( const sal_Int32 nIdx ) const +SwTextNode* DocumentOutlineNodesManager::getOutlineNode( const tSortedOutlineNodeList::size_type nIdx ) const { return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->GetTextNode(); } @@ -58,8 +58,8 @@ void DocumentOutlineNodesManager::getOutlineNodes( IDocumentOutlineNodes::tSorte orOutlineNodeList.clear(); orOutlineNodeList.reserve( getOutlineNodesCount() ); - const sal_Int32 nOutlCount = getOutlineNodesCount(); - for ( sal_Int32 i = 0; i < nOutlCount; ++i ) + const tSortedOutlineNodeList::size_type nOutlCount = getOutlineNodesCount(); + for ( tSortedOutlineNodeList::size_type i = 0; i < nOutlCount; ++i ) { orOutlineNodeList.push_back( m_rDoc.GetNodes().GetOutLineNds()[i]->GetTextNode() ); diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index 479a7611a172..4facb1feac1f 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -83,7 +83,7 @@ bool SwDoc::GenerateHTMLDoc( const OUString& rPath, } // two helpers for outline mode -SwNodePtr GetStartNode( SwOutlineNodes* pOutlNds, int nOutlineLevel, sal_uInt16* nOutl ) +SwNodePtr GetStartNode( SwOutlineNodes* pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type* nOutl ) { SwNodePtr pNd; @@ -96,7 +96,7 @@ SwNodePtr GetStartNode( SwOutlineNodes* pOutlNds, int nOutlineLevel, sal_uInt16* return nullptr; } -SwNodePtr GetEndNode( SwOutlineNodes* pOutlNds, int nOutlineLevel, sal_uInt16* nOutl ) +SwNodePtr GetEndNode( SwOutlineNodes* pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type* nOutl ) { SwNodePtr pNd; @@ -116,7 +116,7 @@ SwNodePtr GetEndNode( SwOutlineNodes* pOutlNds, int nOutlineLevel, sal_uInt16* n } // two helpers for collection mode -SwNodePtr GetStartNode( const SwOutlineNodes* pOutlNds, const SwTextFormatColl* pSplitColl, sal_uInt16* nOutl ) +SwNodePtr GetStartNode( const SwOutlineNodes* pOutlNds, const SwTextFormatColl* pSplitColl, SwOutlineNodes::size_type* nOutl ) { SwNodePtr pNd; for( ; *nOutl < pOutlNds->size(); ++(*nOutl) ) @@ -129,7 +129,7 @@ SwNodePtr GetStartNode( const SwOutlineNodes* pOutlNds, const SwTextFormatColl* return nullptr; } -SwNodePtr GetEndNode( const SwOutlineNodes* pOutlNds, const SwTextFormatColl* pSplitColl, sal_uInt16* nOutl ) +SwNodePtr GetEndNode( const SwOutlineNodes* pOutlNds, const SwTextFormatColl* pSplitColl, SwOutlineNodes::size_type* nOutl ) { SwNodePtr pNd; @@ -160,7 +160,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline, ( SPLITDOC_TO_GLOBALDOC == eDocType && GetDocumentSettingManager().get(DocumentSettingId::GLOBAL_DOCUMENT) ) ) return false; - sal_uInt16 nOutl = 0; + SwOutlineNodes::size_type nOutl = 0; SwOutlineNodes* pOutlNds = const_cast<SwOutlineNodes*>(&GetNodes().GetOutLineNds()); std::unique_ptr<SwOutlineNodes> xTmpOutlNds; SwNodePtr pStartNd; @@ -401,7 +401,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline, // it has to be a bug! if( !pOutlNds->Seek_Entry( pStartNd, &nOutl )) pStartNd = nullptr; - ++nOutl; + ++nOutl ; } break; diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index e3585a1954a9..6002bd928e14 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -183,7 +183,7 @@ bool SwDoc::OutlineUpDown( const SwPaM& rPam, short nOffset ) const SwOutlineNodes& rOutlNds = GetNodes().GetOutLineNds(); const SwNodePtr pSttNd = &rPam.Start()->nNode.GetNode(); const SwNodePtr pEndNd = &rPam.End()->nNode.GetNode(); - sal_uInt16 nSttPos, nEndPos; + SwOutlineNodes::size_type nSttPos, nEndPos; if( !rOutlNds.Seek_Entry( pSttNd, &nSttPos ) && !nSttPos-- ) @@ -411,7 +411,7 @@ bool SwDoc::OutlineUpDown( const SwPaM& rPam, short nOffset ) } // Move up/down -bool SwDoc::MoveOutlinePara( const SwPaM& rPam, short nOffset ) +bool SwDoc::MoveOutlinePara( const SwPaM& rPam, SwOutlineNodes::difference_type nOffset ) { // Do not move to special sections in the nodes array const SwPosition& rStt = *rPam.Start(), @@ -424,7 +424,7 @@ bool SwDoc::MoveOutlinePara( const SwPaM& rPam, short nOffset ) return false; } - sal_uInt16 nAktPos = 0; + SwOutlineNodes::size_type nAktPos = 0; SwNodeIndex aSttRg( rStt.nNode ), aEndRg( rEnd.nNode ); int nOutLineLevel = MAXLEVEL; @@ -444,7 +444,7 @@ bool SwDoc::MoveOutlinePara( const SwPaM& rPam, short nOffset ) else aSttRg = *GetNodes().GetEndOfContent().StartOfSectionNode(); } - sal_uInt16 nTmpPos = 0; + SwOutlineNodes::size_type nTmpPos = 0; // If the given range ends at an outlined text node we have to decide if it has to be a part of // the moving range or not. Normally it will be a sub outline of our chapter // and has to be moved, too. But if the chapter ends with a table(or a section end), @@ -498,9 +498,9 @@ bool SwDoc::MoveOutlinePara( const SwPaM& rPam, short nOffset ) ++aEndRg; // calculation of the new position - if( nOffset < 0 && nAktPos < sal_uInt16(-nOffset) ) + if( nOffset < 0 && nAktPos < SwOutlineNodes::size_type(-nOffset) ) pNd = GetNodes().GetEndOfContent().StartOfSectionNode(); - else if( nAktPos + nOffset >= (sal_uInt16)GetNodes().GetOutLineNds().size() ) + else if( nAktPos + nOffset >= GetNodes().GetOutLineNds().size() ) pNd = &GetNodes().GetEndOfContent(); else pNd = GetNodes().GetOutLineNds()[ nAktPos + nOffset ]; diff --git a/sw/source/core/docnode/ndnum.cxx b/sw/source/core/docnode/ndnum.cxx index 6e19eb04f6c2..c65986e9145f 100644 --- a/sw/source/core/docnode/ndnum.cxx +++ b/sw/source/core/docnode/ndnum.cxx @@ -30,7 +30,7 @@ bool CompareSwOutlineNodes::operator()( SwNode* const& lhs, SwNode* const& rhs) return lhs->GetIndex() < rhs->GetIndex(); } -bool SwOutlineNodes::Seek_Entry(SwNode* rP, sal_uInt16* pnPos) const +bool SwOutlineNodes::Seek_Entry(SwNode* rP, size_type* pnPos) const { const_iterator it = lower_bound(rP); *pnPos = it - begin(); @@ -80,7 +80,7 @@ void SwNodes::UpdateOutlineIdx( const SwNode& rNd ) const SwNodePtr pSrch = const_cast<SwNodePtr>(&rNd); - sal_uInt16 nPos; + SwOutlineNodes::size_type nPos; if (!m_pOutlineNodes->Seek_Entry(pSrch, &nPos)) return; if( nPos == m_pOutlineNodes->size() ) // none present for updating ? diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index f985634ed09d..4962f734223c 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -763,7 +763,7 @@ const SwTextNode* SwNode::FindOutlineNodeOfLevel( sal_uInt8 nLvl ) const const SwOutlineNodes& rONds = GetNodes().GetOutLineNds(); if( MAXLEVEL > nLvl && !rONds.empty() ) { - sal_uInt16 nPos; + SwOutlineNodes::size_type nPos; SwNode* pNd = const_cast<SwNode*>(this); bool bCheckFirst = false; if( !rONds.Seek_Entry( pNd, &nPos )) @@ -1868,7 +1868,7 @@ bool SwContentNode::IsAnyCondition( SwCollCondition& rTmp ) const } { - sal_uInt16 nPos; + SwOutlineNodes::size_type nPos; const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds(); if( !rOutlNds.empty() ) { diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 1f69c67e9a81..ccc50ee39f72 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -1117,7 +1117,7 @@ void SwNodes::Delete(const SwNodeIndex &rIndex, sal_uLong nNodes) pTableNd->DelFrames(); SwNode *pNd, *pChkNd = pAktNode->m_pStartOfSection; - sal_uInt16 nIdxPos; + SwOutlineNodes::size_type nIdxPos; do { pNd = &aRg.aEnd.GetNode(); @@ -1384,7 +1384,7 @@ void SwNodes::DelNodes( const SwNodeIndex & rStart, sal_uLong nCnt ) if (pNd->IsTextNode() && pNd->GetTextNode()->IsOutline()) { // remove the outline indices - sal_uInt16 nIdxPos; + SwOutlineNodes::size_type nIdxPos; if( m_pOutlineNodes->Seek_Entry( pNd, &nIdxPos )) { m_pOutlineNodes->erase(nIdxPos); diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index 4236b5bd2c85..70f9541ccb04 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -545,7 +545,7 @@ bool SwEditShell::OutlineUpDown( short nOffset ) return bRet; } -bool SwEditShell::MoveOutlinePara( short nOffset ) +bool SwEditShell::MoveOutlinePara( SwOutlineNodes::difference_type nOffset ) { StartAllAction(); bool bRet = GetDoc()->MoveOutlinePara( *GetCursor(), nOffset ); @@ -563,7 +563,7 @@ bool SwEditShell::IsProtectedOutlinePara() const const SwOutlineNodes& rOutlNd = GetDoc()->GetNodes().GetOutLineNds(); SwNodePtr pNd = const_cast<SwNodePtr>(&rNd); bool bFirst = true; - sal_uInt16 nPos; + SwOutlineNodes::size_type nPos; int nLvl(0); if( !rOutlNd.Seek_Entry( pNd, &nPos ) && nPos ) --nPos; @@ -608,7 +608,7 @@ bool SwEditShell::IsProtectedOutlinePara() const * 2) outline must not be within table * 3) if bCopy is set, outline must not be write protected */ -static bool lcl_IsOutlineMoveAndCopyable( const SwDoc* pDoc, sal_uInt16 nIdx, bool bCopy ) +static bool lcl_IsOutlineMoveAndCopyable( const SwDoc* pDoc, SwOutlineNodes::size_type nIdx, bool bCopy ) { const SwNodes& rNds = pDoc->GetNodes(); const SwNode* pNd = rNds.GetOutLineNds()[ nIdx ]; @@ -617,12 +617,12 @@ static bool lcl_IsOutlineMoveAndCopyable( const SwDoc* pDoc, sal_uInt16 nIdx, bo ( bCopy || !pNd->IsProtect() ); // 3) write } -bool SwEditShell::IsOutlineMovable( sal_uInt16 nIdx ) const +bool SwEditShell::IsOutlineMovable( SwOutlineNodes::size_type nIdx ) const { return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, false ); } -bool SwEditShell::IsOutlineCopyable( sal_uInt16 nIdx ) const +bool SwEditShell::IsOutlineCopyable( SwOutlineNodes::size_type nIdx ) const { return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, true ); } diff --git a/sw/source/core/inc/DocumentOutlineNodesManager.hxx b/sw/source/core/inc/DocumentOutlineNodesManager.hxx index cc47324fab65..b2322d452e81 100644 --- a/sw/source/core/inc/DocumentOutlineNodesManager.hxx +++ b/sw/source/core/inc/DocumentOutlineNodesManager.hxx @@ -35,14 +35,14 @@ public: //typedef std::vector< const SwTextNode* > tSortedOutlineNodeList; - sal_Int32 getOutlineNodesCount() const override; + tSortedOutlineNodeList::size_type getOutlineNodesCount() const override; - int getOutlineLevel( const sal_Int32 nIdx ) const override; - OUString getOutlineText( const sal_Int32 nIdx, + int getOutlineLevel( const tSortedOutlineNodeList::size_type nIdx ) const override; + OUString getOutlineText( const tSortedOutlineNodeList::size_type nIdx, const bool bWithNumber = true, const bool bWithSpacesForLevel = false, const bool bWithFootnote = true ) const override; - SwTextNode* getOutlineNode( const sal_Int32 nIdx ) const override; + SwTextNode* getOutlineNode( const tSortedOutlineNodeList::size_type nIdx ) const override; void getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList& orOutlineNodeList ) const override; virtual ~DocumentOutlineNodesManager() override; diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 24adab070a1c..0d39d8319176 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -2023,9 +2023,9 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() std::stack< StackEntry > aOutlineStack; aOutlineStack.push( StackEntry( -1, -1 ) ); // push default value - const sal_uInt16 nOutlineCount = - static_cast<sal_uInt16>(mrSh.getIDocumentOutlineNodesAccess()->getOutlineNodesCount()); - for ( sal_uInt16 i = 0; i < nOutlineCount; ++i ) + const SwOutlineNodes::size_type nOutlineCount = + mrSh.getIDocumentOutlineNodesAccess()->getOutlineNodesCount(); + for ( SwOutlineNodes::size_type i = 0; i < nOutlineCount; ++i ) { // Check if outline is hidden const SwTextNode* pTNd = mrSh.GetNodes().GetOutLineNds()[ i ]->GetTextNode(); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index c31f0b26325c..94d33494610d 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -260,7 +260,7 @@ SwTextNode::~SwTextNode() // must be removed from outline nodes by now #if OSL_DEBUG_LEVEL > 0 - sal_uInt16 foo; + SwOutlineNodes::size_type foo; assert(!GetNodes().GetOutLineNds().Seek_Entry(this, &foo)); #endif diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx index 75393aebff2c..5cb3d369d13d 100644 --- a/sw/source/ui/misc/outline.cxx +++ b/sw/source/ui/misc/outline.cxx @@ -804,9 +804,9 @@ void SwOutlineSettingsTabPage::SetWrtShell(SwWrtShell* pShell) } m_pNumberBox->SelectNumberingType(rNumFormat.GetNumberingType()); - sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL); + SwOutlineNodes::size_type nOutlinePos = pSh->GetOutlinePos(MAXLEVEL); sal_uInt16 nTmp = 0; - if(nOutlinePos != USHRT_MAX) + if(nOutlinePos != SwOutlineNodes::npos) { nTmp = static_cast<sal_uInt16>(pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos)); } diff --git a/sw/source/uibase/inc/content.hxx b/sw/source/uibase/inc/content.hxx index 74123da60820..690b99ab2d82 100644 --- a/sw/source/uibase/inc/content.hxx +++ b/sw/source/uibase/inc/content.hxx @@ -35,13 +35,13 @@ class SwRangeRedline; class SwOutlineContent : public SwContent { - sal_uInt16 nOutlinePos; + SwOutlineNodes::size_type nOutlinePos; sal_uInt8 nOutlineLevel; bool bIsMoveable; public: SwOutlineContent( const SwContentType* pCnt, const OUString& rName, - sal_uInt16 nArrPos, + SwOutlineNodes::size_type nArrPos, sal_uInt8 nLevel, bool bMove, long nYPos) : diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx index 4915ce94998c..534c3ed78c4a 100644 --- a/sw/source/uibase/inc/navipi.hxx +++ b/sw/source/uibase/inc/navipi.hxx @@ -29,6 +29,7 @@ #include <sfx2/tbxctrl.hxx> #include <svx/sidebar/PanelLayout.hxx> #include <conttree.hxx> +#include <ndarr.hxx> class SwWrtShell; class SwNavigationPI; @@ -135,7 +136,7 @@ public: virtual void dispose() override; void UpdateListBox(); - void MoveOutline(sal_uInt16 nSource, sal_uInt16 nTarget, bool bWithCilds); + void MoveOutline(SwOutlineNodes::size_type nSource, SwOutlineNodes::size_type nTarget, bool bWithCilds); virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override; diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx index 2a7a21673b3d..07e052827a5b 100644 --- a/sw/source/uibase/inc/wrtsh.hxx +++ b/sw/source/uibase/inc/wrtsh.hxx @@ -456,7 +456,7 @@ typedef bool (SwWrtShell:: *FNSimpleMove)(); bool GotoFly( const OUString& rName, FlyCntType eType = FLYCNTTYPE_ALL, bool bSelFrame = true ); bool GotoINetAttr( const SwTextINetFormat& rAttr ); - void GotoOutline( sal_uInt16 nIdx ); + void GotoOutline( SwOutlineNodes::size_type nIdx ); bool GotoOutline( const OUString& rName ); bool GotoRegion( const OUString& rName ); void GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType = 0, diff --git a/sw/source/uibase/shells/listsh.cxx b/sw/source/uibase/shells/listsh.cxx index 995dac23a58f..786dfe23f7d3 100644 --- a/sw/source/uibase/shells/listsh.cxx +++ b/sw/source/uibase/shells/listsh.cxx @@ -65,8 +65,8 @@ void SwListShell::InitInterface_Impl() // function is quite similar the code in SwContentTree::ExecCommand. static void lcl_OutlineUpDownWithSubPoints( SwWrtShell& rSh, bool bMove, bool bUp ) { - const sal_uInt16 nActPos = rSh.GetOutlinePos(); - if ( nActPos < USHRT_MAX && rSh.IsOutlineMovable( nActPos ) ) + const SwOutlineNodes::size_type nActPos = rSh.GetOutlinePos(); + if ( nActPos < SwOutlineNodes::npos && rSh.IsOutlineMovable( nActPos ) ) { rSh.Push(); rSh.MakeOutlineSel( nActPos, nActPos, true ); @@ -75,8 +75,8 @@ static void lcl_OutlineUpDownWithSubPoints( SwWrtShell& rSh, bool bMove, bool bU { const IDocumentOutlineNodes* pIDoc( rSh.getIDocumentOutlineNodesAccess() ); const int nActLevel = pIDoc->getOutlineLevel( nActPos ); - sal_Int32 nActEndPos = nActPos + 1; - sal_Int16 nDir = 0; + SwOutlineNodes::size_type nActEndPos = nActPos + 1; + SwOutlineNodes::difference_type nDir = 0; if ( !bUp ) { @@ -90,7 +90,7 @@ static void lcl_OutlineUpDownWithSubPoints( SwWrtShell& rSh, bool bMove, bool bU // The current subpoint which should be moved // starts at nActPos and ends at nActEndPos - 1 --nActEndPos; - sal_Int32 nDest = nActEndPos + 2; + SwOutlineNodes::size_type nDest = nActEndPos + 2; while ( nDest < pIDoc->getOutlineNodesCount() && pIDoc->getOutlineLevel( nDest ) > nActLevel ) ++nDest; @@ -104,7 +104,7 @@ static void lcl_OutlineUpDownWithSubPoints( SwWrtShell& rSh, bool bMove, bool bU if ( nActPos > 0 ) { --nActEndPos; - sal_Int32 nDest = nActPos - 1; + SwOutlineNodes::size_type nDest = nActPos - 1; while ( nDest > 0 && pIDoc->getOutlineLevel( nDest ) > nActLevel ) --nDest; diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 8288f5445217..f399699081be 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1054,7 +1054,7 @@ static void* lcl_GetOutlineKey( SwContentTree* pTree, SwOutlineContent* pContent if( pTree && pContent ) { SwWrtShell* pShell = pTree->GetWrtShell(); - sal_Int32 nPos = pContent->GetYPos(); + long nPos = pContent->GetYPos(); key = static_cast<void*>(pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos )); @@ -1435,7 +1435,7 @@ bool SwContentTree::Expand( SvTreeListEntry* pParent ) if(pChild->HasChildren()) { assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pChild->GetUserData()))); - sal_Int32 nPos = static_cast<SwContent*>(pChild->GetUserData())->GetYPos(); + long nPos = static_cast<SwContent*>(pChild->GetUserData())->GetYPos(); void* key = static_cast<void*>(pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos )); aCurrOutLineNodeMap.insert(std::map<void*, bool>::value_type( key, false ) ); std::map<void*, bool>::iterator iter = mOutLineNodeMap.find( key ); @@ -1456,7 +1456,7 @@ bool SwContentTree::Expand( SvTreeListEntry* pParent ) { SwWrtShell* pShell = GetWrtShell(); assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pParent->GetUserData()))); - sal_Int32 nPos = static_cast<SwContent*>(pParent->GetUserData())->GetYPos(); + long nPos = static_cast<SwContent*>(pParent->GetUserData())->GetYPos(); void* key = static_cast<void*>(pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos )); mOutLineNodeMap[key] = true; } @@ -1489,7 +1489,7 @@ bool SwContentTree::Collapse( SvTreeListEntry* pParent ) { SwWrtShell* pShell = GetWrtShell(); assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pParent->GetUserData()))); - sal_Int32 nPos = static_cast<SwContent*>(pParent->GetUserData())->GetYPos(); + long nPos = static_cast<SwContent*>(pParent->GetUserData())->GetYPos(); void* key = static_cast<void*>(pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos )); mOutLineNodeMap[key] = false; } @@ -1717,7 +1717,7 @@ void SwContentTree::Display( bool bActive ) if (m_nRootType == ContentTypeId::OUTLINE && State::ACTIVE == m_eState) { // find out where the cursor is - const sal_uInt16 nActPos = pShell->GetOutlinePos(MAXLEVEL); + const SwOutlineNodes::size_type nActPos = pShell->GetOutlinePos(MAXLEVEL); SvTreeListEntry* pEntry = First(); while( nullptr != (pEntry = Next(pEntry)) ) @@ -1797,7 +1797,7 @@ bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer, { case ContentTypeId::OUTLINE: { - const sal_uInt16 nPos = static_cast<SwOutlineContent*>(pCnt)->GetPos(); + const SwOutlineNodes::size_type nPos = static_cast<SwOutlineContent*>(pCnt)->GetPos(); OSL_ENSURE(nPos < pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount(), "outlinecnt changed"); @@ -2010,8 +2010,8 @@ bool SwContentTree::HasContentChanged() const auto nSelLevel = static_cast<SwOutlineContent*>(pFirstSel->GetUserData())->GetOutlineLevel(); SwWrtShell* pSh = GetWrtShell(); - const sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL); - if (nOutlinePos != USHRT_MAX && + const SwOutlineNodes::size_type nOutlinePos = pSh->GetOutlinePos(MAXLEVEL); + if (nOutlinePos != SwOutlineNodes::npos && pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos) != nSelLevel) bRepaint = true; } @@ -2043,7 +2043,7 @@ bool SwContentTree::HasContentChanged() if( !bRepaint && bOutline ) { // find out where the cursor is - const sal_uInt16 nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL); + const SwOutlineNodes::size_type nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL); SvTreeListEntry* pFirstEntry = First(); while( nullptr != (pFirstEntry = Next(pFirstEntry)) ) @@ -2302,7 +2302,7 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) SwWrtShell *const pShell = GetWrtShell(); sal_Int8 nActOutlineLevel = m_nOutlineLevel; - sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel); + SwOutlineNodes::size_type nActPos = pShell->GetOutlinePos(nActOutlineLevel); std::vector<SvTreeListEntry*> selected; for (SvTreeListEntry * pEntry = FirstSelected(); pEntry; pEntry = NextSelected(pEntry)) @@ -2346,7 +2346,7 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) nActPos = static_cast<SwOutlineContent*>(pCurrentEntry->GetUserData())->GetPos(); } } - if (nActPos == USHRT_MAX || (bUpDown && !pShell->IsOutlineMovable(nActPos))) + if (nActPos == SwOutlineNodes::npos || (bUpDown && !pShell->IsOutlineMovable(nActPos))) { continue; } @@ -2362,7 +2362,7 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) pShell->MakeOutlineSel(nActPos, nActPos, bOutlineWithChildren); if (bUpDown) { - short nDir = bUp ? -1 : 1; + SwOutlineNodes::difference_type nDir = bUp ? -1 : 1; if (!bOutlineWithChildren && ((nDir == -1 && nActPos > 0) || (nDir == 1 && nActPos < GetEntryCount() - 2))) { @@ -2372,7 +2372,7 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) } else if (bOutlineWithChildren && pCurrentEntry) { - sal_uInt16 nActEndPos = nActPos; + SwOutlineNodes::size_type nActEndPos = nActPos; SvTreeListEntry* pEntry = pCurrentEntry; assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pCurrentEntry->GetUserData()))); const auto nActLevel = static_cast<SwOutlineContent*>( @@ -2396,7 +2396,7 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) { // pEntry now points to the entry following the last // selected entry. - sal_uInt16 nDest = nActEndPos + 1; + SwOutlineNodes::size_type nDest = nActEndPos + 1; // here needs to found the next entry after next. // The selection must be inserted in front of that. while (pEntry) @@ -2421,7 +2421,7 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) } else { - sal_uInt16 nDest = nActPos; + SwOutlineNodes::size_type nDest = nActPos; pEntry = pCurrentEntry; while (pEntry && nDest) { @@ -2464,7 +2464,7 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) Display(true); if (!m_bIsRoot) { - const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL); + const SwOutlineNodes::size_type nCurrPos = pShell->GetOutlinePos(MAXLEVEL); SvTreeListEntry* pFirst = First(); while (nullptr != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst)) @@ -2569,18 +2569,18 @@ TriState SwContentTree::NotifyMoving( SvTreeListEntry* pTarget, { if(!m_bDocChgdInDragging) { - sal_uInt16 nTargetPos = 0; + SwOutlineNodes::size_type nTargetPos = 0; assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData()))); - sal_uInt16 nSourcePos = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetPos(); + SwOutlineNodes::size_type nSourcePos = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetPos(); if(!lcl_IsContent(pTarget)) - nTargetPos = USHRT_MAX; + nTargetPos = SwOutlineNodes::npos; else { assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pTarget->GetUserData()))); nTargetPos = static_cast<SwOutlineContent*>(pTarget->GetUserData())->GetPos(); } if( MAXLEVEL > m_nOutlineLevel && // Not all layers are displayed. - nTargetPos != USHRT_MAX) + nTargetPos != SwOutlineNodes::npos) { SvTreeListEntry* pNext = Next(pTarget); if(pNext) @@ -2613,11 +2613,11 @@ TriState SwContentTree::NotifyCopying( SvTreeListEntry* pTarget, { if(!m_bDocChgdInDragging) { - sal_uInt16 nTargetPos = 0; + SwOutlineNodes::size_type nTargetPos = 0; assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData()))); - sal_uInt16 nSourcePos = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetPos(); + SwOutlineNodes::size_type nSourcePos = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetPos(); if(!lcl_IsContent(pTarget)) - nTargetPos = USHRT_MAX; + nTargetPos = SwOutlineNodes::npos; else { assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pTarget->GetUserData()))); @@ -2625,7 +2625,7 @@ TriState SwContentTree::NotifyCopying( SvTreeListEntry* pTarget, } if( MAXLEVEL > m_nOutlineLevel && // Not all layers are displayed. - nTargetPos != USHRT_MAX) + nTargetPos != SwOutlineNodes::npos) { SvTreeListEntry* pNext = Next(pTarget); if(pNext) diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx index 68a410d5b405..fe05f73da6a9 100644 --- a/sw/source/uibase/utlui/navipi.cxx +++ b/sw/source/uibase/utlui/navipi.cxx @@ -96,22 +96,22 @@ OUString SwNavigationPI::CleanEntry(const OUString& rEntry) // Execution of the drag operation with and without the children. -void SwNavigationPI::MoveOutline(sal_uInt16 nSource, sal_uInt16 nTarget, +void SwNavigationPI::MoveOutline(SwOutlineNodes::size_type nSource, SwOutlineNodes::size_type nTarget, bool bWithChildren) { SwView *pView = GetCreateView(); SwWrtShell &rSh = pView->GetWrtShell(); - if(nTarget < nSource || nTarget == USHRT_MAX) + if(nTarget < nSource || nTarget == SwOutlineNodes::npos) nTarget ++; if ( rSh.IsOutlineMovable( nSource )) { - short nMove = nTarget-nSource; //( nDir<0 ) ? 1 : 0 ; + SwOutlineNodes::difference_type nMove = nTarget-nSource; //( nDir<0 ) ? 1 : 0 ; rSh.GotoOutline(nSource); if (bWithChildren) rSh.MakeOutlineSel(nSource, nSource, true); // While moving, the selected children does not counting. - const sal_uInt16 nLastOutlinePos = rSh.GetOutlinePos(MAXLEVEL); + const SwOutlineNodes::size_type nLastOutlinePos = rSh.GetOutlinePos(MAXLEVEL); if(bWithChildren && nMove > 1 && nLastOutlinePos < nTarget) { diff --git a/sw/source/uibase/wrtsh/move.cxx b/sw/source/uibase/wrtsh/move.cxx index 7399043f27b6..34ac8058f95e 100644 --- a/sw/source/uibase/wrtsh/move.cxx +++ b/sw/source/uibase/wrtsh/move.cxx @@ -608,7 +608,7 @@ bool SwWrtShell::GotoINetAttr( const SwTextINetFormat& rAttr ) return bRet; } -void SwWrtShell::GotoOutline( sal_uInt16 nIdx ) +void SwWrtShell::GotoOutline( SwOutlineNodes::size_type nIdx ) { addCurrentPosition(); SwCursorShell::GotoOutline (nIdx); |