summaryrefslogtreecommitdiff
path: root/sw/source/uibase/wrtsh
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-07-11 13:04:54 +0200
committerLászló Németh <nemeth@numbertext.org>2021-07-13 13:31:16 +0200
commitb50d386dfa70f7c1d4eb1a49091ec9dd782b767b (patch)
tree6846db5dd09bae72024587c656c465f69434916b /sw/source/uibase/wrtsh
parentb966d6c8f4607b93f9c46a25c573e33fd203f9c3 (diff)
tdf#142701 track changes: fix layout regression of image deletion
Commit d6322bcedc197a654abc7d64bfea8cf570f123bf (tdf#59463 track changes: record deletion of images) converted image anchors to AS_CHAR, which resulted loss of the original layout during rejecting the tracked image deletion. Now keep the original AT_CHAR (also AS_CHAR) anchorings, also convert the AT_PARA and other anchoring types to AT_CHAR using the following workaround: add an invisible text-based anchoring point with ZWJs. Follow-up to commit 8726cf692299ea262a7455adcf6ec25451c7869d (tdf#142700 DOCX: fix lost track changes of images). Change-Id: I29d1e161b5f24c0fed51d40c9a8db82085918d0d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118747 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/uibase/wrtsh')
-rw-r--r--sw/source/uibase/wrtsh/delete.cxx37
1 files changed, 29 insertions, 8 deletions
diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx
index 455b421db158..104d3c0456be 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -35,6 +35,7 @@
#include <rtl/character.hxx>
#include <osl/diagnose.h>
#include <doc.hxx>
+#include <IDocumentRedlineAccess.hxx>
inline void SwWrtShell::OpenMark()
{
@@ -428,18 +429,20 @@ bool SwWrtShell::DelRight()
std::unique_ptr<SwPosition> pAnchor;
RndStdIds eAnchorId = RndStdIds::FLY_AT_PARA;
SwFlyFrame* pFly = GetSelectedFlyFrame();
+ SwFrameFormat* pFormat = nullptr;
if (pFly)
{
- SwFrameFormat* pFormat = pFly->GetFormat();
+ pFormat = pFly->GetFormat();
if (pFormat)
{
eAnchorId = pFormat->GetAnchor().GetAnchorId();
- // as-character anchor conversion at track changes
- if ( IsRedlineOn() && eAnchorId != RndStdIds::FLY_AS_CHAR )
+ // to-character anchor conversion at track changes
+ if ( IsRedlineOn() && (eAnchorId != RndStdIds::FLY_AS_CHAR &&
+ eAnchorId != RndStdIds::FLY_AT_CHAR) )
{
SfxItemSet aSet(GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{});
GetFlyFrameAttr(aSet);
- SwFormatAnchor aAnch(RndStdIds::FLY_AS_CHAR);
+ SwFormatAnchor aAnch(RndStdIds::FLY_AT_CHAR);
aSet.Put(aAnch);
SetFlyFrameAttr(aSet);
eAnchorId = pFormat->GetAnchor().GetAnchorId();
@@ -455,12 +458,30 @@ bool SwWrtShell::DelRight()
}
}
- // track changes: delete the anchor point of the image to record the deletion
- if ( IsRedlineOn() && pAnchor && SelectionType::Graphic & nSelection
- && eAnchorId == RndStdIds::FLY_AS_CHAR )
+ // track changes: create redline at anchor point of the image to record the deletion
+ if ( IsRedlineOn() && pAnchor && SelectionType::Graphic & nSelection && pFormat &&
+ ( eAnchorId == RndStdIds::FLY_AT_CHAR || eAnchorId == RndStdIds::FLY_AS_CHAR ) )
{
+ sal_Int32 nRedlineLength = 1;
+ // create a double ZWJ anchor point of the image to record the deletion, if needed
+ // (otherwise use the existing anchor point of the image anchored *as* character)
+ if ( eAnchorId == RndStdIds::FLY_AT_CHAR )
+ {
+ nRedlineLength = 2;
+ LeaveSelFrameMode();
+ UnSelectFrame();
+ RedlineFlags eOld = GetRedlineFlags();
+ SetRedlineFlags( eOld | RedlineFlags::Ignore );
+ Insert( OUString( u"‍‍" ) );
+ SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR);
+ SwCursorShell::Left(1, CRSR_SKIP_CHARS);
+ anchor.SetAnchor(GetCursor()->GetPoint());
+ GetDoc()->SetAttr(anchor, *pFormat);
+ SetRedlineFlags( eOld );
+ SwCursorShell::Left(1, CRSR_SKIP_CHARS);
+ }
OpenMark();
- SwCursorShell::Right(1, CRSR_SKIP_CHARS);
+ SwCursorShell::Right(nRedlineLength, CRSR_SKIP_CHARS);
bRet = Delete();
CloseMark( bRet );
}