From 5a7157d319477830426797532e02ac39d3b859f4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 11:29:03 +0200 Subject: Merging upstream version 4:24.2.1. Signed-off-by: Daniel Baumann --- sw/qa/extras/uiwriter/uiwriter9.cxx | 56 ++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'sw/qa/extras/uiwriter/uiwriter9.cxx') diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx index b6dea5a8e7..1a3e49c257 100644 --- a/sw/qa/extras/uiwriter/uiwriter9.cxx +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -68,7 +68,61 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf158785) CPPUNIT_ASSERT_EQUAL(IsAttrAtPos::NONE, aContentAtPos.eContentAtPos); } -} // end of anonymouse namespace +CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf159049) +{ + // The document contains a shape which has a text with a line break. When copying the text to + // clipboard the line break was missing in the RTF flavor of the clipboard. + createSwDoc("tdf159049_LineBreakRTFClipboard.fodt"); + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + selectShape(1); + + // Bring shape into text edit mode + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RETURN); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_RETURN); + Scheduler::ProcessEventsToIdle(); + // Copy text + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Copy", {}); + + // Deactivate text edit mode ... + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_ESCAPE); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_ESCAPE); + Scheduler::ProcessEventsToIdle(); + // ... and deselect shape. + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_ESCAPE); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_ESCAPE); + Scheduler::ProcessEventsToIdle(); + + // Paste special as RTF + uno::Sequence aArgs(comphelper::InitPropertySequence( + { { "SelectedFormat", uno::Any(static_cast(SotClipboardFormatId::RTF)) } })); + dispatchCommand(mxComponent, ".uno:ClipboardFormatItems", aArgs); + // Without fix Actual was "Abreakhere", the line break \n was missing. + CPPUNIT_ASSERT_EQUAL(u"Abreak\nhere"_ustr, getParagraph(1)->getString()); +} + +CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf135083) +{ + createSwDoc("tdf135083-simple-text-plus-list.fodt"); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + dispatchCommand(mxComponent, u".uno:Copy"_ustr, {}); + + // Paste special as RTF + uno::Sequence aArgs(comphelper::InitPropertySequence( + { { u"SelectedFormat"_ustr, + uno::Any(static_cast(SotClipboardFormatId::RTF)) } })); + dispatchCommand(mxComponent, ".uno:ClipboardFormatItems", aArgs); + + auto xLastPara = getParagraph(3); + CPPUNIT_ASSERT_EQUAL(u"dolor"_ustr, xLastPara->getString()); + // Without the fix in place, the last paragraph would loose its settings. ListId would be empty. + CPPUNIT_ASSERT(!getProperty(xLastPara, u"ListId"_ustr).isEmpty()); +} + +} // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3