sw/inc/undobj.hxx | 2 +- sw/source/core/doc/DocumentContentOperationsManager.cxx | 2 +- sw/source/core/txtnode/ndtxt.cxx | 2 +- sw/source/core/undo/untblk.cxx | 15 ++++++++------- 4 files changed, 11 insertions(+), 10 deletions(-)
New commits: commit cf4df3e51b609613134e3146f526d8e6b07946c3 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Mar 1 14:30:42 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Mar 4 11:23:44 2024 +0100 sw: for Undo, add FLY_AT_PAGE in GetFlysAnchoredAt() SwUndoInserts::IsCreateUndoForNewFly() now returns true for these, so they get Undo objects on Paste, which is of course wrong. (regression from commit 359e5af31c330a137fed6ba3140b77cd759c28bb) Change-Id: Id5abb38c662a9c55826cde6d8b151613c852de72 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164221 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx index 03ad720aabe7..7fb61309ec29 100644 --- a/sw/inc/undobj.hxx +++ b/sw/inc/undobj.hxx @@ -244,7 +244,7 @@ class SwUndoInsLayFormat; namespace sw { std::optional<std::vector<SwFrameFormat*>> -GetFlysAnchoredAt(SwDoc & rDoc, SwNodeOffset nSttNode); +GetFlysAnchoredAt(SwDoc & rDoc, SwNodeOffset nSttNode, bool isAtPageIncluded); } diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index e799555b9dd7..1c3df58bd6cd 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -5066,7 +5066,7 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo } else { - pFlys = sw::GetFlysAnchoredAt(rDoc, rPos.GetNodeIndex()); + pFlys = sw::GetFlysAnchoredAt(rDoc, rPos.GetNodeIndex(), false); pFlysAtInsPos = pFlys ? &*pFlys : nullptr; } diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index dc2625d33c54..bbb725e5c13c 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -462,7 +462,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, } bool bSplitFly = false; - std::optional<std::vector<SwFrameFormat*>> oFlys = sw::GetFlysAnchoredAt(GetDoc(), GetIndex()); + std::optional<std::vector<SwFrameFormat*>> oFlys = sw::GetFlysAnchoredAt(GetDoc(), GetIndex(), false); if (oFlys.has_value()) { // See if one of the flys is a split fly. If so, we need to keep diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 158167809712..328d901ca482 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -38,7 +38,7 @@ namespace sw { std::optional<std::vector<SwFrameFormat*>> -GetFlysAnchoredAt(SwDoc & rDoc, SwNodeOffset const nSttNode) +GetFlysAnchoredAt(SwDoc & rDoc, SwNodeOffset const nSttNode, bool const isAtPageIncluded) { std::optional<std::vector<SwFrameFormat*>> pFrameFormats; const size_t nArrLen = rDoc.GetSpzFrameFormats()->size(); @@ -47,10 +47,11 @@ GetFlysAnchoredAt(SwDoc & rDoc, SwNodeOffset const nSttNode) SwFrameFormat *const pFormat = (*rDoc.GetSpzFrameFormats())[n]; SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); - if (pAnchorNode - && nSttNode == pAnchorNode->GetIndex() - && ((pAnchor->GetAnchorId() == RndStdIds::FLY_AT_PARA) - || (pAnchor->GetAnchorId() == RndStdIds::FLY_AT_CHAR))) + if ((pAnchorNode + && nSttNode == pAnchorNode->GetIndex() + && ((pAnchor->GetAnchorId() == RndStdIds::FLY_AT_PARA) + || (pAnchor->GetAnchorId() == RndStdIds::FLY_AT_CHAR))) + || (isAtPageIncluded && pAnchor->GetAnchorId() == RndStdIds::FLY_AT_PAGE)) { if (!pFrameFormats) pFrameFormats.emplace(); @@ -89,7 +90,7 @@ SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam ) // These flys will be saved in pFrameFormats array (only flys which exist BEFORE insertion!) // Then in SwUndoInserts::SetInsertRange the flys saved in pFrameFormats will NOT create Undos. // m_FlyUndos will only be filled with newly inserted flys. - m_pFrameFormats = sw::GetFlysAnchoredAt(rDoc, m_nSttNode); + m_pFrameFormats = sw::GetFlysAnchoredAt(rDoc, m_nSttNode, true); } // consider Redline if( rDoc.getIDocumentRedlineAccess().IsRedlineOn() ) @@ -392,7 +393,7 @@ void SwUndoInserts::RedoImpl(::sw::UndoRedoContext & rContext) if( ( m_nSttNode != m_nEndNode || m_nSttContent != m_nEndContent ) && m_oUndoNodeIndex) { auto const pFlysAtInsPos(sw::GetFlysAnchoredAt(rDoc, - rPam.GetPoint()->GetNodeIndex())); + rPam.GetPoint()->GetNodeIndex(), false)); ::std::optional<SwNodeIndex> oMvBkwrd = MovePtBackward(rPam);