summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2018-02-21 03:07:33 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2018-02-21 11:36:20 +0100
commite86fb2edfdca48b92b11c149002ab2b06a630b94 (patch)
tree682a4653e59a00345977f628aa5a4e5ed2269f2d
parentfa775ed30ad8969dacca34ddb63b76a89d8ba7da (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. Change-Id: Ie0c3717d22da6b6a988ab8d566bd9759e03f86c8 Reviewed-on: https://gerrit.libreoffice.org/50074 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r--sd/qa/unit/tiledrendering/data/paste_text_onslide.odpbin0 -> 10587 bytes
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx66
-rw-r--r--sd/source/ui/view/sdview2.cxx8
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
new file mode 100644
index 000000000000..c33b7c110229
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/paste_text_onslide.odp
Binary files differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 162c2f8c2e4f..b7dd2d05d097 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -110,6 +110,7 @@ public:
void testDefaultView();
void testIMESupport();
void testTdf115783();
+ void testPasteTextOnSlide();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -152,6 +153,7 @@ public:
CPPUNIT_TEST(testDefaultView);
CPPUNIT_TEST(testIMESupport);
CPPUNIT_TEST(testTdf115783);
+ CPPUNIT_TEST(testPasteTextOnSlide);
CPPUNIT_TEST_SUITE_END();
@@ -2055,6 +2057,70 @@ void SdTiledRenderingTest::testTdf115783()
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>(12990), aPos.getX(), 100);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<long>(7393), 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 4df02ee52385..7a042c44623a 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -62,6 +62,7 @@
#include <drawview.hxx>
#include <helpids.h>
#include <vcl/svapp.hxx>
+#include <comphelper/lok.hxx>
#include <slideshow.hxx>
#include <memory>
@@ -318,7 +319,12 @@ void View::DoPaste (vcl::Window const * pWindow)
sal_Int8 nDnDAction = DND_ACTION_COPY;
if( pWindow )
- aPos = pWindow->PixelToLogic( ::tools::Rectangle( aPos, pWindow->GetOutputSizePixel() ).Center() );
+ {
+ if (comphelper::LibreOfficeKit::isActive())
+ aPos = ::tools::Rectangle(aPos, GetSdrPageView()->GetPage()->GetSize()).Center();
+ else
+ aPos = pWindow->PixelToLogic( ::tools::Rectangle( aPos, pWindow->GetOutputSizePixel() ).Center() );
+ }
DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>( mpDocSh->GetViewShell() );