diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-10-07 11:16:10 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-10-29 12:36:19 +0100 |
commit | a9d7ac5c8f7af0051b0df1c8a298f9823cd134aa (patch) | |
tree | 3e900977d34e36f4fc982b39af8670d7fe7fb2b7 /sw | |
parent | 4692b33314669515a973f69cddd27b688327ca99 (diff) |
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 <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 3eae55420d1d8daee6efad456f651a9ff189723b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175752
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/docvw/AnnotationWin2.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/shells/textfld.cxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh1.cxx | 29 |
3 files changed, 30 insertions, 11 deletions
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index 236fc9990fb0..b3634148e7fe 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -1059,7 +1059,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 7a7e410590f7..554ccb610a7c 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> @@ -513,6 +514,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 50d054b86ba8..c447eff36ca8 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> @@ -2272,14 +2273,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() ) @@ -2341,12 +2353,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 |