summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorMatti Tyrväinen <matty@uef.fi>2023-02-13 21:04:56 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-05-19 12:28:35 +0200
commit384a80fc56e75e3d1ee18ffc303db85490716829 (patch)
treeba0f7b3caa753cc6cbbf8970b7894ce9f136c50b /sw/source/uibase
parent595b42b686b33bbba0eeba1740277b5f6e0f5433 (diff)
tdf#81720 Don't expand Reference Marks
Make Reference Marks behave like nesting attributes such as Hyperlinks. This is described as the ideal behavior in <https://bugs.documentfoundation.org/show_bug.cgi?id=81720#c24> Change-Id: I34ddfb3a6aa0147ba4bc281ebbb6342089b7bd08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146941 Reviewed-by: Matti <matty@uef.fi> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/shells/basesh.cxx81
1 files changed, 2 insertions, 79 deletions
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 4add92e90068..9b917005bfed 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -840,45 +840,7 @@ bool UpdateFieldContents(SfxRequest& rReq, SwWrtShell& rWrtSh)
OUString aContent = aMap["Content"].get<OUString>();
auto pTextRefMark = const_cast<SwTextRefMark*>(pRefMark->GetTextRefMark());
- if (!pTextRefMark->End())
- {
- continue;
- }
-
- // Insert markers to remember where the paste positions are.
- const SwTextNode& rTextNode = pTextRefMark->GetTextNode();
- SwPaM aMarkers(SwPosition(rTextNode, *pTextRefMark->End()));
- IDocumentContentOperations& rIDCO = pDoc->getIDocumentContentOperations();
- pTextRefMark->SetDontExpand(false);
- bool bSuccess = rIDCO.InsertString(aMarkers, "XY");
- if (bSuccess)
- {
- SwPaM aPasteEnd(SwPosition(rTextNode, *pTextRefMark->End()));
- aPasteEnd.Move(fnMoveBackward, GoInContent);
-
- // Paste HTML content.
- SwPaM* pCursorPos = rWrtSh.GetCursor();
- *pCursorPos = aPasteEnd;
- SwTranslateHelper::PasteHTMLToPaM(rWrtSh, pCursorPos, aContent.toUtf8(), true);
-
- // Update the refmark to point to the new content.
- sal_Int32 nOldStart = pTextRefMark->GetStart();
- sal_Int32 nNewStart = *pTextRefMark->End();
- // First grow it to include text till the end of the paste position.
- pTextRefMark->SetEnd(aPasteEnd.GetPoint()->GetContentIndex());
- // Then shrink it to only start at the paste start: we know that the refmark was
- // truncated to the paste start, as the refmark has to stay inside a single text node
- pTextRefMark->SetStart(nNewStart);
- rTextNode.GetSwpHints().SortIfNeedBe();
- SwPaM aEndMarker(*aPasteEnd.GetPoint());
- aEndMarker.SetMark();
- aEndMarker.GetMark()->AdjustContent(1);
- SwPaM aStartMarker(SwPosition(rTextNode, nOldStart), SwPosition(rTextNode, nNewStart));
-
- // Remove markers. The start marker includes the old content as well.
- rIDCO.DeleteAndJoin(aStartMarker);
- rIDCO.DeleteAndJoin(aEndMarker);
- }
+ pTextRefMark->UpdateFieldContent(pDoc, rWrtSh, aContent);
}
rWrtSh.EndAction();
@@ -945,46 +907,7 @@ void UpdateFieldContent(SfxRequest& rReq, SwWrtShell& rWrtSh)
OUString aContent = aMap["Content"].get<OUString>();
auto pTextRefMark = const_cast<SwTextRefMark*>(rRefmark.GetTextRefMark());
- if (!pTextRefMark->End())
- {
- return;
- }
-
- // Insert markers to remember where the paste positions are.
- const SwTextNode& rTextNode = pTextRefMark->GetTextNode();
- SwPaM aMarkers(SwPosition(rTextNode, *pTextRefMark->End()));
- IDocumentContentOperations& rIDCO = pDoc->getIDocumentContentOperations();
- pTextRefMark->SetDontExpand(false);
- if (!rIDCO.InsertString(aMarkers, "XY"))
- {
- return;
- }
-
- SwPaM aPasteEnd(SwPosition(rTextNode, *pTextRefMark->End()));
- aPasteEnd.Move(fnMoveBackward, GoInContent);
-
- // Paste HTML content.
- SwPaM* pCursorPos = rWrtSh.GetCursor();
- *pCursorPos = aPasteEnd;
- SwTranslateHelper::PasteHTMLToPaM(rWrtSh, pCursorPos, aContent.toUtf8(), true);
-
- // Update the refmark to point to the new content.
- sal_Int32 nOldStart = pTextRefMark->GetStart();
- sal_Int32 nNewStart = *pTextRefMark->End();
- // First grow it to include text till the end of the paste position.
- pTextRefMark->SetEnd(aPasteEnd.GetPoint()->GetContentIndex());
- // Then shrink it to only start at the paste start: we know that the refmark was
- // truncated to the paste start, as the refmark has to stay inside a single text node
- pTextRefMark->SetStart(nNewStart);
- rTextNode.GetSwpHints().SortIfNeedBe();
- SwPaM aEndMarker(*aPasteEnd.GetPoint());
- aEndMarker.SetMark();
- aEndMarker.GetMark()->AdjustContent(1);
- SwPaM aStartMarker(SwPosition(rTextNode, nOldStart), SwPosition(rTextNode, nNewStart));
-
- // Remove markers. The start marker includes the old content as well.
- rIDCO.DeleteAndJoin(aStartMarker);
- rIDCO.DeleteAndJoin(aEndMarker);
+ pTextRefMark->UpdateFieldContent(pDoc, rWrtSh, aContent);
}
}