diff options
author | László Németh <nemeth@numbertext.org> | 2021-04-26 09:33:45 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-04-27 16:27:39 +0200 |
commit | d6322bcedc197a654abc7d64bfea8cf570f123bf (patch) | |
tree | 5e37e019e0b8b823658fe222a1b1d0dc05378e00 /sw/source | |
parent | f6b419b8946c5fc2dafa8f4201a4c7379148f306 (diff) |
tdf#59463 track changes: record deletion of images
Instead of deleting the image object without
recording the deletion, delete the anchor point
in the text to record the deletion, if Record
Changes is enabled.
Note: only images anchored as characters can be
recorded this way, so change the anchor before
the deletion, if needed. This less problem, than
hidden, i.e. non-tracked deletion of images.
Change-Id: I7e4bee82b76b4a26e6482a678a2a1ce432980271
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114671
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/uibase/wrtsh/delete.cxx | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx index 7db55f76c627..455b421db158 100644 --- a/sw/source/uibase/wrtsh/delete.cxx +++ b/sw/source/uibase/wrtsh/delete.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <cmdid.h> #include <wrtsh.hxx> #include <swcrsr.hxx> #include <editeng/lrspitem.hxx> @@ -416,30 +417,55 @@ bool SwWrtShell::DelRight() case SelectionType::DrawObjectEditMode: case SelectionType::DbForm: { + // Group deletion of the object and its comment together + // (also as-character anchor conversion at track changes) + mxDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr); + // #108205# Remember object's position. Point aTmpPt = GetObjRect().TopLeft(); // Remember the anchor of the selected object before deletion. std::unique_ptr<SwPosition> pAnchor; + RndStdIds eAnchorId = RndStdIds::FLY_AT_PARA; SwFlyFrame* pFly = GetSelectedFlyFrame(); if (pFly) { SwFrameFormat* pFormat = pFly->GetFormat(); if (pFormat) { - RndStdIds eAnchorId = pFormat->GetAnchor().GetAnchorId(); + eAnchorId = pFormat->GetAnchor().GetAnchorId(); + // as-character anchor conversion at track changes + if ( IsRedlineOn() && eAnchorId != RndStdIds::FLY_AS_CHAR ) + { + SfxItemSet aSet(GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{}); + GetFlyFrameAttr(aSet); + SwFormatAnchor aAnch(RndStdIds::FLY_AS_CHAR); + aSet.Put(aAnch); + SetFlyFrameAttr(aSet); + eAnchorId = pFormat->GetAnchor().GetAnchorId(); + } if ((eAnchorId == RndStdIds::FLY_AS_CHAR || eAnchorId == RndStdIds::FLY_AT_CHAR) && pFormat->GetAnchor().GetContentAnchor()) { pAnchor.reset(new SwPosition(*pFormat->GetAnchor().GetContentAnchor())); + // set cursor before the anchor point + if ( IsRedlineOn() ) + *GetCurrentShellCursor().GetPoint() = *pAnchor; } } } - // Group deletion of the object and its comment together. - mxDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr); - - DelSelectedObj(); + // track changes: delete the anchor point of the image to record the deletion + if ( IsRedlineOn() && pAnchor && SelectionType::Graphic & nSelection + && eAnchorId == RndStdIds::FLY_AS_CHAR ) + { + OpenMark(); + SwCursorShell::Right(1, CRSR_SKIP_CHARS); + bRet = Delete(); + CloseMark( bRet ); + } + else + DelSelectedObj(); if (pAnchor) { |