summaryrefslogtreecommitdiff
path: root/sw/source/uibase/wrtsh/delete.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-07-03 14:05:05 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-07-03 16:34:19 +0200
commit86fd893e32ef7a737b2c4b60e0938146b102fc07 (patch)
tree7e54b236e4d3159a2683f6cc2f4c34d8543b180a /sw/source/uibase/wrtsh/delete.cxx
parent5cee586a97a11c23dd252accc42099bd5e9b4187 (diff)
sw comments on frames: delete comment of frame when deleting frame
Also group the two actions together, so only 1 undo action is visible to the user, not 2. Change-Id: Idba5a63b1653e96db4f9567a38b3f4ca740eb1df Reviewed-on: https://gerrit.libreoffice.org/75045 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/uibase/wrtsh/delete.cxx')
-rw-r--r--sw/source/uibase/wrtsh/delete.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx
index 4675bcad5149..e783037c9bb9 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -23,6 +23,10 @@
#include <view.hxx>
#include <drawbase.hxx>
#include <unobaseclass.hxx>
+#include <fmtanchr.hxx>
+#include <flyfrm.hxx>
+#include <ndtxt.hxx>
+#include <IDocumentUndoRedo.hxx>
#include <i18nutil/unicode.hxx>
#include <rtl/character.hxx>
@@ -394,8 +398,44 @@ bool SwWrtShell::DelRight()
// #108205# Remember object's position.
Point aTmpPt = GetObjRect().TopLeft();
+ // Remember the anchof of the selected object before deletion.
+ std::unique_ptr<SwPosition> pAnchor;
+ SwFlyFrame* pFly = GetSelectedFlyFrame();
+ if (pFly)
+ {
+ SwFrameFormat* pFormat = pFly->GetFormat();
+ if (pFormat && pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR)
+ {
+ if (pFormat->GetAnchor().GetContentAnchor())
+ {
+ pAnchor.reset(new SwPosition(*pFormat->GetAnchor().GetContentAnchor()));
+ }
+ }
+ }
+
+ // Group deletion of the object and its comment together.
+ mxDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr);
+
DelSelectedObj();
+ if (pAnchor)
+ {
+ SwTextNode* pTextNode = pAnchor->nNode.GetNode().GetTextNode();
+ if (pTextNode)
+ {
+ const SwTextField* pField(
+ pTextNode->GetFieldTextAttrAt(pAnchor->nContent.GetIndex(), true));
+ if (pField)
+ {
+ // Remove the comment of the deleted object.
+ *GetCurrentShellCursor().GetPoint() = *pAnchor;
+ DelRight();
+ }
+ }
+ }
+
+ mxDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::EMPTY, nullptr);
+
// #108205# Set cursor to remembered position.
SetCursor(&aTmpPt);