tdf#107317 Make undo insert text box to shape display proper message
Instead of Insert $1 -> Insert text box
Change-Id: I2131c3e7a88f005830fd755acc50fd71168fca10
Reviewed-on: https://gerrit.libreoffice.org/77173
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 59bab41..232e673 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -525,6 +525,7 @@
#define STR_UNDO_INDEX_ENTRY_INSERT NC_("STR_UNDO_INDEX_ENTRY_INSERT", "Insert index entry")
#define STR_UNDO_INDEX_ENTRY_DELETE NC_("STR_UNDO_INDEX_ENTRY_DELETE", "Delete index entry")
#define STR_FIELD NC_("STR_FIELD", "field")
#define STR_UNDO_INSERT_TEXTBOX NC_("STR_UNDO_INSERT_TEXTBOX", "text box")
/*undo: STR_PARAGRAPHS, string.text*/
#define STR_PARAGRAPHS NC_("STR_PARAGRAPHS", "Paragraphs")
#define STR_FRAME NC_("STR_FRAME", "frame")
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index a9dd85a..e7ac0b6 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -71,6 +71,8 @@
#include <fmtanchr.hxx>
#include <fmtcntnt.hxx>
#include <ndtxt.hxx>
#include <SwRewriter.hxx>
#include <strings.hrc>
using namespace ::com::sun::star;
@@ -1437,7 +1439,10 @@ SwXText::insertTextContentWithProperties(
throw uno::RuntimeException();
}
m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
SwRewriter aRewriter;
aRewriter.AddRule(UndoArg1, SwResId(STR_UNDO_INSERT_TEXTBOX));
m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, &aRewriter);
// now attach the text content here
insertTextContent( xInsertPosition, xTextContent, false );
@@ -1459,12 +1464,12 @@ SwXText::insertTextContentWithProperties(
catch (const uno::Exception& e)
{
css::uno::Any anyEx = cppu::getCaughtException();
m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, &aRewriter);
throw lang::WrappedTargetRuntimeException( e.Message,
uno::Reference< uno::XInterface >(), anyEx );
}
}
m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, &aRewriter);
return xInsertPosition;
}