sw, UpdateFieldContent: address a minor performance nit

See
<https://gerrit.libreoffice.org/c/core/+/145459/1#message-fa0ede3525e35014c1f6c99455a96a69bc2a3601>,
it's enough to start grouping undo/redo after we know that there is a
relevant refmark under the cursor.

Change-Id: I53e7e371768480d6b7e968c90bf8c5d9901013b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145555
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
Miklos Vajna 2023-01-16 09:19:36 +01:00
parent 2cf59dee96
commit 0250d6c643

View File

@ -913,16 +913,6 @@ void UpdateFieldContent(SfxRequest& rReq, SwWrtShell& rWrtSh)
uno::Sequence<beans::PropertyValue> 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<SwTextAttr*> 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<OUString>();
rRefmark.GetRefName() = aName;