undo/redo of comment insertion assumes Par2 content matches TextObject
contents (as much as conversion to plain text makes possible) To make things easier, add an EditTextObject::GetText() like EditEngine::GetText() that serializes multiple paragraphs in an equivalent way so there isn't a need to create an editengine just to do this conversion. Modify and extend DesktopLOKTest::testCommentsCallbacksWriter to use a html payload and add a undo/redo to it. Change-Id: I4d895138e919bab54ebbbcb966f9b9faef574086 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179594 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180377 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Tested-by: Jenkins
This commit is contained in:
@@ -2595,7 +2595,7 @@ void DesktopLOKTest::testCommentsCallbacksWriter()
|
||||
CPPUNIT_ASSERT_EQUAL(nCommentId2, aView2.m_aCommentCallbackResult.get<int>("id"));
|
||||
|
||||
// Reply to nCommentId1 again
|
||||
aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId1) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Reply comment again\" } }";
|
||||
aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId1) + "\" }, \"Html\": { \"type\": \"string\", \"value\": \"Reply comment again\" } }";
|
||||
pDocument->pClass->postUnoCommand(pDocument, ".uno:ReplyComment", aCommandArgs.getStr(), false);
|
||||
Scheduler::ProcessEventsToIdle();
|
||||
|
||||
@@ -2607,6 +2607,15 @@ void DesktopLOKTest::testCommentsCallbacksWriter()
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("<div>Reply comment again</div>"), aView1.m_aCommentCallbackResult.get<std::string>("html"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("<div>Reply comment again</div>"), aView2.m_aCommentCallbackResult.get<std::string>("html"));
|
||||
|
||||
// Ensure that an undo and redo restores the html contents
|
||||
aView1.m_aCommentCallbackResult.clear();
|
||||
aView2.m_aCommentCallbackResult.clear();
|
||||
pDocument->pClass->postUnoCommand(pDocument, ".uno:Undo", "", false);
|
||||
pDocument->pClass->postUnoCommand(pDocument, ".uno:Redo", "", false);
|
||||
Scheduler::ProcessEventsToIdle();
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("<div>Reply comment again</div>"), aView1.m_aCommentCallbackResult.get<std::string>("html"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("<div>Reply comment again</div>"), aView2.m_aCommentCallbackResult.get<std::string>("html"));
|
||||
|
||||
// .uno:ViewAnnotations returns total of 5 comments
|
||||
boost::property_tree::ptree aTree;
|
||||
char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewAnnotations");
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include <editeng/flditem.hxx>
|
||||
|
||||
#include <svl/sharedstringpool.hxx>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
|
||||
#include <libxml/xmlwriter.h>
|
||||
#include <algorithm>
|
||||
@@ -398,6 +399,26 @@ OUString EditTextObjectImpl::GetText(sal_Int32 nPara) const
|
||||
return maContents[nPara]->GetText();
|
||||
}
|
||||
|
||||
OUString EditTextObjectImpl::GetText(LineEnd eEnd) const
|
||||
{
|
||||
const size_t nParas = maContents.size();
|
||||
if (nParas == 0)
|
||||
return OUString();
|
||||
|
||||
const OUString aSep = EditDoc::GetSepStr(eEnd);
|
||||
|
||||
OUStringBuffer aBuffer;
|
||||
|
||||
for (size_t nPara = 0; nPara < nParas; ++nPara)
|
||||
{
|
||||
if (!aSep.isEmpty() && nPara > 0)
|
||||
aBuffer.append(aSep);
|
||||
aBuffer.append(maContents[nPara]->GetText());
|
||||
}
|
||||
|
||||
return aBuffer.makeStringAndClear();
|
||||
}
|
||||
|
||||
sal_Int32 EditTextObjectImpl::GetTextLen(sal_Int32 nPara ) const
|
||||
{
|
||||
if (nPara < 0 || o3tl::make_unsigned(nPara) >= maContents.size())
|
||||
|
@@ -227,6 +227,7 @@ public:
|
||||
|
||||
virtual sal_Int32 GetParagraphCount() const override;
|
||||
virtual OUString GetText(sal_Int32 nParagraph) const override;
|
||||
virtual OUString GetText(LineEnd eEnd = LINEEND_LF) const override;
|
||||
virtual sal_Int32 GetTextLen(sal_Int32 nParagraph) const override;
|
||||
|
||||
virtual void ClearPortionInfo() override;
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <editeng/editengdllapi.h>
|
||||
#include <editeng/macros.hxx>
|
||||
#include <svl/languageoptions.hxx>
|
||||
#include <tools/lineend.hxx>
|
||||
|
||||
#include <com/sun/star/text/textfield/Type.hpp>
|
||||
|
||||
@@ -87,6 +88,8 @@ public:
|
||||
|
||||
virtual OUString GetText(sal_Int32 nPara) const = 0;
|
||||
|
||||
virtual OUString GetText(LineEnd eEnd = LINEEND_LF) const = 0;
|
||||
|
||||
virtual sal_Int32 GetTextLen(sal_Int32 nPara) const = 0;
|
||||
|
||||
bool HasText(sal_Int32 nPara) const { return GetTextLen(nPara) > 0; }
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include <tools/bigint.hxx>
|
||||
#include <svtools/insdlg.hxx>
|
||||
#include <sfx2/ipclient.hxx>
|
||||
#include <editeng/editeng.hxx>
|
||||
#include <editeng/editobj.hxx>
|
||||
#include <editeng/formatbreakitem.hxx>
|
||||
#include <editeng/svxacorr.hxx>
|
||||
@@ -2278,6 +2279,7 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, const SfxRequest& rReq)
|
||||
Outliner aOutliner(&pDocSh->GetPool(), OutlinerMode::TextObject);
|
||||
SwPostItHelper::ImportHTML(aOutliner, pHtmlItem->GetValue());
|
||||
oTextPara = aOutliner.CreateParaObject();
|
||||
sText = aOutliner.GetEditEngine().GetText();
|
||||
}
|
||||
|
||||
// If we have a text already registered for answer, use that
|
||||
@@ -2291,7 +2293,10 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, const SfxRequest& rReq)
|
||||
}
|
||||
const EditTextObject& rTextObject = pAnswer->GetTextObject();
|
||||
if (rTextObject.GetParagraphCount() != 1 || !rTextObject.GetText(0).isEmpty())
|
||||
{
|
||||
oTextPara = *pAnswer;
|
||||
sText = rTextObject.GetText();
|
||||
}
|
||||
}
|
||||
|
||||
if ( HasSelection() && !IsTableMode() )
|
||||
|
Reference in New Issue
Block a user