summaryrefslogtreecommitdiff
path: root/sw/source/core/undo/unattr.cxx
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2022-12-17 00:21:28 -0900
committerMiklos Vajna <vmiklos@collabora.com>2023-01-16 18:46:52 +0000
commit4eb955f2436ef1c8979bd10d28a77adde3966dd6 (patch)
tree8990ce142a886d1736602fc57b81ae273742969a /sw/source/core/undo/unattr.cxx
parent4a9cc6938b5abe59303b15cb826204035b910df3 (diff)
tdf#140666 Make delete reference possible from the Navigator
This patch makes it possible to delete a reference without having to do the steps given in the help. "References are fields. To remove a reference, delete the field. If you set a longer text as a reference and you do not want to re-enter it after deleting the reference, select the text and copy it to the clipboard. You can then reinsert it as "unformatted text" at the same position using the command Edit - Paste special. The text remains intact while the reference is deleted." (cherry picked from commit 9d387cc1e7848848c41f29ad91fee44ade79f678) Conflicts: sw/source/uibase/utlui/content.cxx sw/uiconfig/swriter/ui/navigatorcontextmenu.ui Change-Id: If363340288de25aacbc28acd5858ce275f309af6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145559 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source/core/undo/unattr.cxx')
-rw-r--r--sw/source/core/undo/unattr.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 9d279860c086..bb2cdcaa34bb 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -55,6 +55,7 @@
#include <charfmt.hxx>
#include <calbck.hxx>
#include <frameformats.hxx>
+#include <editsh.hxx>
SwUndoFormatAttrHelper::SwUndoFormatAttrHelper(SwFormat& rFormat, bool bSvDrwPt)
: SwClient(&rFormat)
@@ -575,6 +576,10 @@ void SwUndoResetAttr::UndoImpl(::sw::UndoRedoContext & rContext)
pTNd->DontExpandFormat( aIdx, false );
}
}
+ else if (m_nFormatId == RES_TXTATR_REFMARK)
+ {
+ rDoc.GetEditShell()->SwViewShell::UpdateFields();
+ }
AddUndoRedoPaM(rContext);
}
@@ -626,6 +631,27 @@ void SwUndoResetAttr::RedoImpl(::sw::UndoRedoContext & rContext)
}
}
break;
+ case RES_TXTATR_REFMARK:
+ {
+ SfxItemPool::Item2Range aRange = rDoc.GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK);
+ SwHistoryHint* pHistoryHint = GetHistory()[0];
+ if (pHistoryHint && HSTRY_SETREFMARKHNT == pHistoryHint->Which())
+ {
+ for (const SfxPoolItem* pItem : aRange)
+ {
+ assert(dynamic_cast<const SwFormatRefMark*>(pItem));
+ const auto pFormatRefMark = static_cast<const SwFormatRefMark*>(pItem);
+ if (static_cast<SwHistorySetRefMark*>(pHistoryHint)->GetRefName() ==
+ pFormatRefMark->GetRefName())
+ {
+ rDoc.DeleteFormatRefMark(pFormatRefMark);
+ rDoc.GetEditShell()->SwViewShell::UpdateFields();
+ break;
+ }
+ }
+ }
+ }
+ break;
}
}