From 50bd0f5f20db0abfe40ec335ec9b39d0e6a16550 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 25 Oct 2018 12:48:17 +0200 Subject: sw_redlinehide_3: adapt some SwEditShell functions SwEditShell::IsOutlineCopyable(), IsOutlineMovable(), IsProtectedOutlinePara(), GetCurrentParaOutlineLevel() all filter. Change-Id: Ie5fb181e21d4bf606482bec9cb108dbd70f4209e --- sw/source/core/edit/ednumber.cxx | 20 ++++++++++++++------ sw/source/core/inc/txtfrm.hxx | 1 + sw/source/core/text/txtfrm.cxx | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) (limited to 'sw') diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index 7734fd03c563..c795e645b374 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -411,8 +412,8 @@ int SwEditShell::GetCurrentParaOutlineLevel( ) const int nLevel = 0; SwPaM* pCursor = GetCursor(); - const SwTextNode* pTextNd = pCursor->GetNode().GetTextNode(); - if( pTextNd ) + const SwTextNode *const pTextNd = sw::GetParaPropsNode(*GetLayout(), pCursor->GetPoint()->nNode); + if (pTextNd) nLevel = pTextNd->GetAttrOutlineLevel(); return nLevel; } @@ -570,6 +571,11 @@ bool SwEditShell::IsProtectedOutlinePara() const { SwNodePtr pTmpNd = rOutlNd[ nPos ]; + if (!sw::IsParaPropsNode(*GetLayout(), *pTmpNd->GetTextNode())) + { + continue; + } + int nTmpLvl = pTmpNd->GetTextNode()->GetAttrOutlineLevel(); OSL_ENSURE( nTmpLvl >= 0 && nTmpLvl <= MAXLEVEL, @@ -606,23 +612,25 @@ 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, SwOutlineNodes::size_type nIdx, bool bCopy ) +static bool lcl_IsOutlineMoveAndCopyable(SwEditShell const& rShell, + SwOutlineNodes::size_type const nIdx, bool const bCopy) { - const SwNodes& rNds = pDoc->GetNodes(); + const SwNodes& rNds = rShell.GetDoc()->GetNodes(); const SwNode* pNd = rNds.GetOutLineNds()[ nIdx ]; return pNd->GetIndex() >= rNds.GetEndOfExtras().GetIndex() && // 1) body !pNd->FindTableNode() && // 2) table + sw::IsParaPropsNode(*rShell.GetLayout(), *pNd->GetTextNode()) && ( bCopy || !pNd->IsProtect() ); // 3) write } bool SwEditShell::IsOutlineMovable( SwOutlineNodes::size_type nIdx ) const { - return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, false ); + return lcl_IsOutlineMoveAndCopyable( *this, nIdx, false ); } bool SwEditShell::IsOutlineCopyable( SwOutlineNodes::size_type nIdx ) const { - return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, true ); + return lcl_IsOutlineMoveAndCopyable( *this, nIdx, true ); } bool SwEditShell::NumOrNoNum( diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx index 831465f8c90b..afdaa6aff8d0 100644 --- a/sw/source/core/inc/txtfrm.hxx +++ b/sw/source/core/inc/txtfrm.hxx @@ -101,6 +101,7 @@ std::unique_ptr CheckParaRedlineMerge(SwTextFrame & rFrame, SwTe bool FrameContainsNode(SwContentFrame const& rFrame, sal_uLong nNodeIndex); bool IsParaPropsNode(SwRootFrame const& rLayout, SwTextNode const& rNode); +SwTextNode * GetParaPropsNode(SwRootFrame const& rLayout, SwNodeIndex const& rNode); TextFrameIndex UpdateMergedParaForDelete(MergedPara & rMerged, bool isRealDelete, diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index cd72ad8ca489..e6142abc24ee 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -324,6 +324,20 @@ namespace sw { return true; } + SwTextNode * + GetParaPropsNode(SwRootFrame const& rLayout, SwNodeIndex const& rPos) + { + SwTextNode *const pTextNode(rPos.GetNode().GetTextNode()); + if (pTextNode && !sw::IsParaPropsNode(rLayout, *pTextNode)) + { + return static_cast(pTextNode->getLayoutFrame(&rLayout))->GetMergedPara()->pParaPropsNode; + } + else + { + return pTextNode; + } + } + } // namespace sw /// Switches width and height of the text frame -- cgit