diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2018-02-21 03:07:33 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-02-21 13:39:15 +0100 |
commit | d6f89b5daccd498fb5af6f47d06b749f92dcdaca (patch) | |
tree | 25ca10573b708b84fdf7311378f4ea3ba5626de2 /sd | |
parent | edca2b8eecf14d6e9b10acb501985d68f6b992d4 (diff) |
sd lok: Fix pasting text on slide
Use the same solution as for images in this commit:
9fee132c18b658c9ea9fb1114c1fefa56b57532a
Place the inserted text shape to the center of the slide
for LOK, because we don't get correct window size here.
Reviewed-on: https://gerrit.libreoffice.org/50074
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit e86fb2edfdca48b92b11c149002ab2b06a630b94)
Change-Id: Ie0c3717d22da6b6a988ab8d566bd9759e03f86c8
Reviewed-on: https://gerrit.libreoffice.org/50097
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/tiledrendering/data/paste_text_onslide.odp | bin | 0 -> 10587 bytes | |||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 66 | ||||
-rw-r--r-- | sd/source/ui/view/sdview2.cxx | 8 |
3 files changed, 73 insertions, 1 deletions
diff --git a/sd/qa/unit/tiledrendering/data/paste_text_onslide.odp b/sd/qa/unit/tiledrendering/data/paste_text_onslide.odp Binary files differnew file mode 100644 index 000000000000..c33b7c110229 --- /dev/null +++ b/sd/qa/unit/tiledrendering/data/paste_text_onslide.odp diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index e23ac2449841..0eabab25fab2 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -103,6 +103,7 @@ public: void testLanguageStatus(); void testDefaultView(); void testIMESupport(); + void testPasteTextOnSlide(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -144,6 +145,7 @@ public: CPPUNIT_TEST(testLanguageStatus); CPPUNIT_TEST(testDefaultView); CPPUNIT_TEST(testIMESupport); + CPPUNIT_TEST(testPasteTextOnSlide); CPPUNIT_TEST_SUITE_END(); @@ -1962,6 +1964,70 @@ void SdTiledRenderingTest::testIMESupport() comphelper::LibreOfficeKit::setActive(false); } +void SdTiledRenderingTest::testPasteTextOnSlide() +{ + // Load the document. + comphelper::LibreOfficeKit::setActive(); + SdXImpressDocument* pXImpressDocument = createDoc("paste_text_onslide.odp"); + + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + + // select second text object + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB); + Scheduler::ProcessEventsToIdle(); + + // step into text editing + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, '1', 0); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, '1', 0); + Scheduler::ProcessEventsToIdle(); + + // select full text + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_LEFT | KEY_SHIFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_LEFT | KEY_SHIFT); + Scheduler::ProcessEventsToIdle(); + + // Copy some text + comphelper::dispatchCommand(".uno:Copy", uno::Sequence<beans::PropertyValue>()); + Scheduler::ProcessEventsToIdle(); + + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::ESCAPE); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::ESCAPE); + Scheduler::ProcessEventsToIdle(); + + // Paste onto the slide + comphelper::dispatchCommand(".uno:Paste", uno::Sequence<beans::PropertyValue>()); + Scheduler::ProcessEventsToIdle(); + + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::ESCAPE); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::ESCAPE); + Scheduler::ProcessEventsToIdle(); + + // Check the position of the newly added text shape, created for pasted text + SdrObject* pObject = pXImpressDocument->GetDocShell()->GetViewShell()->GetActualPage()->GetObj(2); + SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObject); + CPPUNIT_ASSERT(pTextObj); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(OBJ_TEXT), pTextObj->GetObjIdentifier()); + Point aPos = pTextObj->GetLastBoundRect().TopLeft(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<long>(11798), aPos.getX(), 100); + CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<long>(7115), aPos.getY(), 100); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx index ccdf2ada88f6..6b7427f55fad 100644 --- a/sd/source/ui/view/sdview2.cxx +++ b/sd/source/ui/view/sdview2.cxx @@ -63,6 +63,7 @@ #include "drawview.hxx" #include "helpids.h" #include <vcl/svapp.hxx> +#include <comphelper/lok.hxx> #include "slideshow.hxx" #include <memory> @@ -319,7 +320,12 @@ void View::DoPaste (vcl::Window* pWindow) sal_Int8 nDnDAction = DND_ACTION_COPY; if( pWindow ) - aPos = pWindow->PixelToLogic( Rectangle( aPos, pWindow->GetOutputSizePixel() ).Center() ); + { + if (comphelper::LibreOfficeKit::isActive()) + aPos = Rectangle(aPos, GetSdrPageView()->GetPage()->GetSize()).Center(); + else + aPos = pWindow->PixelToLogic( Rectangle( aPos, pWindow->GetOutputSizePixel() ).Center() ); + } DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>( mpDocSh->GetViewShell() ); |