sw/source/core/crsr/swcrsr.cxx | 28 +++++++ sw/source/core/doc/DocumentContentOperationsManager.cxx | 59 ++++++++-------- 2 files changed, 61 insertions(+), 26 deletions(-)
New commits: commit 00abbf7592fc5117fa2bd1c8812e2d2841e90df0 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Fri Nov 6 21:16:20 2020 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Tue Nov 17 22:20:17 2020 +0100 sw_fieldmarkhide: Copy: bookmarks before MakeFrames DocumentContentOperationsManager::CopyWithFlyInFly() needs to copy bookmarks before creating new layout frames. Change-Id: Ib085cd230008149a55f1527b0bbd7bb7323340a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105986 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 1c848cb4d4b9..360b3fae7f9c 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -3468,13 +3468,45 @@ void DocumentContentOperationsManager::CopyWithFlyInFly( if (rRg.aStart != rRg.aEnd) { bool bEndIsEqualEndPos = rInsPos == rRg.aEnd; - bool isRecreateEndNode(false); --aSavePos; SaveRedlEndPosForRestore aRedlRest( rInsPos, 0 ); // insert behind the already copied start node m_rDoc.GetNodes().CopyNodes( rRg, rInsPos, false, true ); aRedlRest.Restore(); + + if (bEndIsEqualEndPos) + { + const_cast<SwNodeIndex&>(rRg.aEnd) = SwNodeIndex(aSavePos, +1); + } + } + + // Also copy all bookmarks + // guess this must be done before the DelDummyNodes below as that + // deletes nodes so would mess up the index arithmetic + // sw_fieldmarkhide: also needs to be done before making frames + if (m_rDoc.getIDocumentMarkAccess()->getAllMarksCount()) + { + SwPaM aRgTmp( rRg.aStart, rRg.aEnd ); + SwPosition targetPos(SwNodeIndex(aSavePos, + rRg.aStart != rRg.aEnd ? +1 : 0)); + if (pCopiedPaM && rRg.aStart != pCopiedPaM->first.Start()->nNode) + { + // there is 1 (partially selected, maybe) paragraph before + assert(SwNodeIndex(rRg.aStart, -1) == pCopiedPaM->first.Start()->nNode); + // only use the passed in target SwPosition if the source PaM point + // is on a different node; if it was the same node then the target + // position was likely moved along by the copy operation and now + // points to the end of the range! + targetPos = pCopiedPaM->second; + } + + sw::CopyBookmarks(pCopiedPaM ? pCopiedPaM->first : aRgTmp, targetPos); + } + + if (rRg.aStart != rRg.aEnd) + { + bool isRecreateEndNode(false); if (bMakeNewFrames) // tdf#130685 only after aRedlRest { // recreate from previous node (could be merged now) if (SwTextNode *const pNode = aSavePos.GetNode().GetTextNode()) @@ -3528,10 +3560,6 @@ void DocumentContentOperationsManager::CopyWithFlyInFly( ? 0 : +1); ::MakeFrames(&rDest, aSavePos, end); } - if (bEndIsEqualEndPos) - { - const_cast<SwNodeIndex&>(rRg.aEnd) = aSavePos; - } } #if OSL_DEBUG_LEVEL > 0 @@ -3568,27 +3596,6 @@ void DocumentContentOperationsManager::CopyWithFlyInFly( SwNodeRange aCpyRange( aSavePos, rInsPos ); - // Also copy all bookmarks - // guess this must be done before the DelDummyNodes below as that - // deletes nodes so would mess up the index arithmetic - if( m_rDoc.getIDocumentMarkAccess()->getAllMarksCount() ) - { - SwPaM aRgTmp( rRg.aStart, rRg.aEnd ); - SwPaM aCpyPaM(aCpyRange.aStart, aCpyRange.aEnd); - if (pCopiedPaM && rRg.aStart != pCopiedPaM->first.Start()->nNode) - { - // there is 1 (partially selected, maybe) paragraph before - assert(SwNodeIndex(rRg.aStart, -1) == pCopiedPaM->first.Start()->nNode); - // only use the passed in target SwPosition if the source PaM point - // is on a different node; if it was the same node then the target - // position was likely moved along by the copy operation and now - // points to the end of the range! - *aCpyPaM.GetPoint() = pCopiedPaM->second; - } - - sw::CopyBookmarks(pCopiedPaM ? pCopiedPaM->first : aRgTmp, *aCpyPaM.Start()); - } - if( bDelRedlines && ( RedlineFlags::DeleteRedlines & rDest.getIDocumentRedlineAccess().GetRedlineFlags() )) lcl_DeleteRedlines( rRg, aCpyRange ); commit 84d7a46aaeb5d112e1588bffdd5020f6245ba504 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Thu Nov 5 20:28:06 2020 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Tue Nov 17 22:20:01 2020 +0100 sw_fieldmarkhide: adapt cursor movement in SwCursor::LeftRight() Jump over the hidden part when moving in from either side. Change-Id: Iff6680249dfe66d6d5b1a39c4543b51a5238b075 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105985 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 78b85050a9e0..4d95fb1b5394 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -1783,6 +1783,20 @@ bool SwCursor::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode, beforeIndex = pFrame->MapModelToViewPos(*GetPoint()); } + if (!bLeft && pLayout && pLayout->GetFieldmarkMode() == sw::FieldmarkMode::ShowResult) + { + SwTextNode const*const pNode(GetPoint()->nNode.GetNode().GetTextNode()); + assert(pNode); + if (pNode->Len() != GetPoint()->nContent.GetIndex() + && pNode->GetText()[GetPoint()->nContent.GetIndex()] == CH_TXT_ATR_FIELDSTART) + { + IDocumentMarkAccess const& rIDMA(*GetDoc().getIDocumentMarkAccess()); + sw::mark::IFieldmark const*const pMark(rIDMA.getFieldmarkAt(*GetPoint())); + assert(pMark); + *GetPoint() = sw::mark::FindFieldSep(*pMark); + } + } + if ( !Move( fnMove, fnGo ) ) break; @@ -1813,6 +1827,20 @@ bool SwCursor::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode, } } + if (bLeft && pLayout && pLayout->GetFieldmarkMode() == sw::FieldmarkMode::ShowCommand) + { + SwTextNode const*const pNode(GetPoint()->nNode.GetNode().GetTextNode()); + assert(pNode); + if (pNode->Len() != GetPoint()->nContent.GetIndex() + && pNode->GetText()[GetPoint()->nContent.GetIndex()] == CH_TXT_ATR_FIELDEND) + { + IDocumentMarkAccess const& rIDMA(*GetDoc().getIDocumentMarkAccess()); + sw::mark::IFieldmark const*const pMark(rIDMA.getFieldmarkAt(*GetPoint())); + assert(pMark); + *GetPoint() = sw::mark::FindFieldSep(*pMark); + } + } + if (isFieldNames) { SwTextNode const*const pNode(GetPoint()->nNode.GetNode().GetTextNode()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits