sw/source/uibase/docvw/AnnotationWin2.cxx | 2 +- sw/source/uibase/shells/textfld.cxx | 10 ++++++++++ sw/source/uibase/wrtsh/wrtsh1.cxx | 29 +++++++++++++++++++---------- 3 files changed, 30 insertions(+), 11 deletions(-)
New commits: commit 3eae55420d1d8daee6efad456f651a9ff189723b Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Oct 7 11:16:10 2024 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Oct 15 08:22:12 2024 +0200 Allow replies with rich text content from command arguments Change-Id: I46d200048bdfef767882e94c7544f40f2e0b3c8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174593 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index d4d53ef6aefc..c42cd5fc593b 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -1052,7 +1052,7 @@ void SwAnnotationWin::ExecuteCommand(sal_uInt16 nSlot) const bool bReply = nSlot == FN_REPLY; // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note // will be created - if (!mpOutliner->GetEditEngine().GetText().isEmpty()) + if (!mrMgr.IsAnswer() && !mpOutliner->GetEditEngine().GetText().isEmpty()) { OutlinerParaObject aPara(GetOutlinerView()->GetEditView().CreateTextObject()); mrMgr.RegisterAnswer(aPara); diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index 02d3b7a09a06..fb5617e8a999 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -27,6 +27,7 @@ #include <txtfld.hxx> #include <svl/itempool.hxx> #include <svl/numformat.hxx> +#include <editeng/editobj.hxx> #include <tools/lineend.hxx> #include <svl/whiter.hxx> #include <svl/eitem.hxx> @@ -501,6 +502,15 @@ void SwTextShell::ExecField(SfxRequest &rReq) auto pWin = pMgr->GetAnnotationWin(pIdItem->GetValue().toUInt32()); if(pWin) { + if (const SvxPostItTextItem* pHtmlItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_HTML)) + { + SwDocShell* pDocSh = GetView().GetDocShell(); + Outliner aOutliner(&pDocSh->GetPool(), OutlinerMode::TextObject); + SwPostItHelper::ImportHTML(aOutliner, pHtmlItem->GetValue()); + if (std::optional<OutlinerParaObject> oPara = aOutliner.CreateParaObject()) + pMgr->RegisterAnswer(oPara.value()); + } + OUString sText; if(const auto pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT)) sText = pTextItem->GetValue(); diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 3e6363c9d4a3..92554cbfc715 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -36,6 +36,7 @@ #include <tools/bigint.hxx> #include <svtools/insdlg.hxx> #include <sfx2/ipclient.hxx> +#include <editeng/editobj.hxx> #include <editeng/formatbreakitem.hxx> #include <editeng/svxacorr.hxx> #include <editeng/ulspitem.hxx> @@ -2259,14 +2260,25 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, const SfxRequest& rReq) if ( pTextItem ) sText = pTextItem->GetValue(); - const SvxPostItTextItem* pHtmlItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_HTML); + std::optional<OutlinerParaObject> oTextPara; + if (const SvxPostItTextItem* pHtmlItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_HTML)) + { + SwDocShell* pDocSh = GetView().GetDocShell(); + Outliner aOutliner(&pDocSh->GetPool(), OutlinerMode::TextObject); + SwPostItHelper::ImportHTML(aOutliner, pHtmlItem->GetValue()); + oTextPara = aOutliner.CreateParaObject(); + } // If we have a text already registered for answer, use that - if (GetView().GetPostItMgr()->IsAnswer() && !GetView().GetPostItMgr()->GetAnswerText().isEmpty()) + SwPostItMgr* pPostItMgr = GetView().GetPostItMgr(); + if (OutlinerParaObject* pAnswer = pPostItMgr->IsAnswer()) { - sText = GetView().GetPostItMgr()->GetAnswerText(); - GetView().GetPostItMgr()->RegisterAnswerText(OUString()); - pHtmlItem = nullptr; + if (!pPostItMgr->GetAnswerText().isEmpty()) + { + sText = GetView().GetPostItMgr()->GetAnswerText(); + pPostItMgr->RegisterAnswerText(OUString()); + } + oTextPara = *pAnswer; } if ( HasSelection() && !IsTableMode() ) @@ -2328,12 +2340,9 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, const SfxRequest& rReq) SwCursorShell::Left(1, SwCursorSkipMode::Chars); pPostIt = static_cast<SwPostItField*>(rFieldMgr.GetCurField()); - if (pPostIt && pHtmlItem) + if (pPostIt && oTextPara) { - SwDocShell* pDocSh = GetView().GetDocShell(); - Outliner aOutliner(&pDocSh->GetPool(), OutlinerMode::TextObject); - SwPostItHelper::ImportHTML(aOutliner, pHtmlItem->GetValue()); - pPostIt->SetTextObject(aOutliner.CreateParaObject()); + pPostIt->SetTextObject(*oTextPara); } Pop(SwCursorShell::PopMode::DeleteCurrent); // Restore cursor position