diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-05-23 11:53:26 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-05-23 13:42:46 +0200 |
commit | b3aeddc5eeea30620c63f685910ccb6b0858f2f2 (patch) | |
tree | c4408e59ea5936f47a2d66c04466608c3e1ffe30 /desktop | |
parent | 544fdb89fa2152d6283825f88856ea5216d4e854 (diff) |
sw: add IgnoreComments parameter to .uno:Paste
Which allows not hardcoding true for LOK.
Conflicts:
sw/source/uibase/dochdl/swdtflvr.cxx
sw/source/uibase/inc/swdtflvr.hxx
Change-Id: I644763ba052b148fc34283e361aa02f9bba2c5ee
Reviewed-on: https://gerrit.libreoffice.org/72833
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 18 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index a00d59f54743..99b6c9f7806f 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -584,6 +584,24 @@ void DesktopLOKTest::testPasteWriter() CPPUNIT_ASSERT(!pDocument->pClass->paste(pDocument, "textt/plain;charset=utf-8", aText.getStr(), aText.getLength())); // Writer is expected to support text/html. CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", aText.getStr(), aText.getLength())); + + // Overwrite doc contents with a HTML paste. + pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", nullptr, false); + Scheduler::ProcessEventsToIdle(); + OString aComment("foo <!-- bar --> baz"); + CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", aComment.getStr(), aComment.getLength())); + + // Check if we have a comment. + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParagraphEnumerationAccess(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParagraphEnumeration = xParagraphEnumerationAccess->createEnumeration(); + uno::Reference<container::XEnumerationAccess> xParagraph(xParagraphEnumeration->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xTextPortionEnumeration = xParagraph->createEnumeration(); + uno::Reference<beans::XPropertySet> xTextPortion(xTextPortionEnumeration->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Text"), xTextPortion->getPropertyValue("TextPortionType").get<OUString>()); + // Without the accompanying fix in place, this test would have failed, as we had a comment + // between "foo" and "baz". + CPPUNIT_ASSERT(!xTextPortionEnumeration->hasMoreElements()); } void DesktopLOKTest::testPasteWriterJPEG() diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index da372deedda4..3d30f5d637ea 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3391,6 +3391,7 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { {"AnchorType", uno::makeAny(static_cast<sal_uInt16>(text::TextContentAnchorType_AS_CHARACTER))}, + {"IgnoreComments", uno::makeAny(true)}, })); if (!comphelper::dispatchCommand(".uno:Paste", aPropertyValues)) { |