diff options
Diffstat (limited to 'sw/source/core')
-rw-r--r-- | sw/source/core/doc/doc.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/inc/rolbck.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/undo/unattr.cxx | 26 |
3 files changed, 51 insertions, 1 deletions
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 571a9bb75c4c..938986058a72 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -68,6 +68,8 @@ #include <pam.hxx> #include <ndtxt.hxx> #include <swundo.hxx> +#include <rolbck.hxx> +#include <UndoAttribute.hxx> #include <UndoCore.hxx> #include <UndoTable.hxx> #include <pagedesc.hxx> @@ -1114,6 +1116,28 @@ sal_uInt16 SwDoc::GetRefMarks( std::vector<OUString>* pNames ) const return nCount; } +void SwDoc::DeleteFormatRefMark(const SwFormatRefMark* pFormatRefMark) +{ + const SwTextRefMark* pTextRefMark = pFormatRefMark->GetTextRefMark(); + SwTextNode& rTextNd = const_cast<SwTextNode&>(pTextRefMark->GetTextNode()); + std::unique_ptr<SwRegHistory> aRegHistory; + if (GetIDocumentUndoRedo().DoesUndo()) + { + SwUndoResetAttr* pUndo = new SwUndoResetAttr(SwPosition(rTextNd, pTextRefMark->GetStart()), + RES_TXTATR_REFMARK); + GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo)); + aRegHistory.reset(new SwRegHistory(rTextNd, &pUndo->GetHistory())); + rTextNd.GetpSwpHints()->Register(aRegHistory.get()); + } + rTextNd.DeleteAttribute(const_cast<SwTextRefMark*>(pTextRefMark)); + if (GetIDocumentUndoRedo().DoesUndo()) + { + if (rTextNd.GetpSwpHints()) + rTextNd.GetpSwpHints()->DeRegister(); + } + getIDocumentState().SetModified(); +} + static bool lcl_SpellAndGrammarAgain( SwNode* pNd, void* pArgs ) { SwTextNode *pTextNode = pNd->GetTextNode(); diff --git a/sw/source/core/inc/rolbck.hxx b/sw/source/core/inc/rolbck.hxx index 75554884341e..fb03e76fa8ea 100644 --- a/sw/source/core/inc/rolbck.hxx +++ b/sw/source/core/inc/rolbck.hxx @@ -160,7 +160,7 @@ class SwHistorySetRefMark final : public SwHistoryHint public: SwHistorySetRefMark( const SwTextRefMark* pTextHt, SwNodeOffset nNode ); virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; - + const OUString& GetRefName() {return m_RefName;} }; class SwHistorySetTOXMark final : public SwHistoryHint 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; } } |