diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 44759890e695..363c37f9d580 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -913,16 +913,6 @@ void UpdateFieldContent(SfxRequest& rReq, SwWrtShell& rWrtSh) uno::Sequence aField; pField->GetValue() >>= aField; - SwDoc* pDoc = rWrtSh.GetDoc(); - pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSBOOKMARK, nullptr); - rWrtSh.StartAction(); - comphelper::ScopeGuard g( - [&rWrtSh] - { - rWrtSh.EndAction(); - rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSBOOKMARK, nullptr); - }); - SwPosition& rCursor = *rWrtSh.GetCursor()->GetPoint(); SwTextNode* pTextNode = rCursor.GetNode().GetTextNode(); std::vector aAttrs @@ -938,6 +928,16 @@ void UpdateFieldContent(SfxRequest& rReq, SwWrtShell& rWrtSh) return; } + SwDoc* pDoc = rWrtSh.GetDoc(); + pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSBOOKMARK, nullptr); + rWrtSh.StartAction(); + comphelper::ScopeGuard g( + [&rWrtSh] + { + rWrtSh.EndAction(); + rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSBOOKMARK, nullptr); + }); + comphelper::SequenceAsHashMap aMap(aField); auto aName = aMap["Name"].get(); rRefmark.GetRefName() = aName;