diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-02-21 13:38:33 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-03-09 12:58:31 +0100 |
commit | 55d6be75732d1bb0067bba9496c74ef30be9a3ec (patch) | |
tree | 281c43cc47c77f1c202708fcf89b66a4798d7946 /sw/source/uibase/shells/textfld.cxx | |
parent | 021332144074a9d20a3eab9ada117acfa7cdbfe0 (diff) |
MSForms: Implement undo / redo for insertion of legacy form fields
Need to handle undo / redo explicitely for form fields, because
there is no a general working undo / redo mechanism for fieldmarks.
During the insertion of the fieldmark, text insertion also happens which
generates an interfering undo action, so we need to disable undoing
temporary.
Also need to invalidta SID_UNDO slot to make the undo toolbar item updated
after we insert a form field.
Change-Id: I358c2704cb30212a38f8a998888a36f72fa404e5
Reviewed-on: https://gerrit.libreoffice.org/68956
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw/source/uibase/shells/textfld.cxx')
-rw-r--r-- | sw/source/uibase/shells/textfld.cxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index dd34a47e16bd..ccf3952aaa97 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -74,6 +74,7 @@ #include <MarkManager.hxx> #include <xmloff/odffields.hxx> #include <IDocumentContentOperations.hxx> +#include <IDocumentUndoRedo.hxx> using namespace nsSwDocInfoSubType; @@ -721,6 +722,8 @@ FIELD_INSERT: case FN_INSERT_TEXT_FORMFIELD: { + rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + SwPaM* pCursorPos = rSh.GetCursor(); if(pCursorPos) { @@ -735,26 +738,39 @@ FIELD_INSERT: pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMTEXT); } } + + rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); } break; case FN_INSERT_CHECKBOX_FORMFIELD: { + rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + SwPaM* pCursorPos = rSh.GetCursor(); if(pCursorPos) { IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMCHECKBOX); } + + rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); } break; case FN_INSERT_DROPDOWN_FORMFIELD: { + rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + SwPaM* pCursorPos = rSh.GetCursor(); if(pCursorPos) { IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMDROPDOWN); } + + rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); } break; default: |