diff options
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/tiledrendering/data/paste-undo.fodp | 34 | ||||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 41 |
2 files changed, 75 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/data/paste-undo.fodp b/sd/qa/unit/tiledrendering/data/paste-undo.fodp new file mode 100644 index 000000000000..2615d1e11445 --- /dev/null +++ b/sd/qa/unit/tiledrendering/data/paste-undo.fodp @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.presentation"> + <office:styles> + <style:presentation-page-layout style:name="AL1T0"> + <presentation:placeholder presentation:object="title" svg:x="2.058cm" svg:y="1.743cm" svg:width="23.912cm" svg:height="3.507cm"/> + <presentation:placeholder presentation:object="subtitle" svg:x="2.058cm" svg:y="5.838cm" svg:width="23.912cm" svg:height="13.23cm"/> + </style:presentation-page-layout> + </office:styles> + <office:automatic-styles> + <style:page-layout style:name="PM0"> + <style:page-layout-properties fo:margin-top="0cm" fo:margin-bottom="0cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:page-width="21cm" fo:page-height="29.7cm" style:print-orientation="portrait"/> + </style:page-layout> + <style:page-layout style:name="PM1"> + <style:page-layout-properties fo:margin-top="0cm" fo:margin-bottom="0cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:page-width="28cm" fo:page-height="15.75cm" style:print-orientation="landscape"/> + </style:page-layout> + <style:style style:name="dp3" style:family="drawing-page"> + </style:style> + <style:style style:name="gr3" style:family="graphic" style:parent-style-name="standard"> + <style:graphic-properties draw:stroke="none" svg:stroke-color="#000000" draw:fill="none" draw:fill-color="#ffffff" draw:auto-grow-height="true" draw:auto-grow-width="false" fo:max-height="0cm" fo:min-height="0.712cm"/> + <style:paragraph-properties style:writing-mode="lr-tb"/> + </style:style> + </office:automatic-styles> + <office:body> + <office:presentation> + <draw:page draw:name="page1" draw:style-name="dp3" draw:master-page-name="Default" presentation:presentation-page-layout-name="AL1T0"> + <draw:frame draw:style-name="gr3" draw:text-style-name="P7" draw:layer="layout" svg:width="7.5cm" svg:height="0.962cm" svg:x="3.5cm" svg:y="3.5cm"> + <draw:text-box> + <text:p>world</text:p> + </draw:text-box> + </draw:frame> + </draw:page> + </office:presentation> + </office:body> +</office:document> diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 02856dd0043e..1bdd4c30386a 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -8,6 +8,9 @@ */ #include "../sdmodeltestbase.hxx" + +#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp> + #include <app.hrc> #include <test/bootstrapfixture.hxx> #include <test/helper/transferable.hxx> @@ -53,6 +56,7 @@ #include <vcl/cursor.hxx> #include <vcl/scheduler.hxx> #include <vcl/vclevent.hxx> +#include <vcl/unohelp2.hxx> #include <chrono> #include <cstdlib> @@ -133,6 +137,7 @@ public: void testSlideDuplicateUndo(); void testMoveShapeHandle(); void testDeleteTable(); + void testPasteUndo(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testCreateDestroy); @@ -190,6 +195,7 @@ public: CPPUNIT_TEST(testSlideDuplicateUndo); CPPUNIT_TEST(testMoveShapeHandle); CPPUNIT_TEST(testDeleteTable); + CPPUNIT_TEST(testPasteUndo); CPPUNIT_TEST_SUITE_END(); @@ -2679,6 +2685,41 @@ void SdTiledRenderingTest::testMoveShapeHandle() } } + +void SdTiledRenderingTest::testPasteUndo() +{ + // Given a document with a textbox, containing "world": + SdXImpressDocument* pXImpressDocument = createDoc("paste-undo.fodp"); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + SdPage* pActualPage = pViewShell->GetActualPage(); + SdrObject* pObject = pActualPage->GetObj(0); + SdrView* pView = pViewShell->GetView(); + pView->MarkObj(pObject, pView->GetSdrPageView()); + pView->SdrBeginTextEdit(pObject); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_HOME); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_HOME); + EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView(); + ESelection aWordSelection(0, 0, 0, 1); // "w" of "world" + rEditView.SetSelection(aWordSelection); + comphelper::dispatchCommand(".uno:Cut", {}); + Scheduler::ProcessEventsToIdle(); + + // When undoing a paste: + comphelper::dispatchCommand(".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + comphelper::dispatchCommand(".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + // Then make sure the cursor position is still at the beginning: + ESelection aSelection = rEditView.GetSelection(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 4 + // i.e. the cursor position after undo was at the end of the line, not at the start, as + // expected. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aSelection.nStartPos); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); |