[Libreoffice-commits] core.git: sd/qa sd/source

Tamás Zolnai tamas.zolnai at collabora.com
Wed Feb 21 10:36:44 UTC 2018


 sd/qa/unit/tiledrendering/data/paste_text_onslide.odp |binary
 sd/qa/unit/tiledrendering/tiledrendering.cxx          |   66 ++++++++++++++++++
 sd/source/ui/view/sdview2.cxx                         |    8 +-
 3 files changed, 73 insertions(+), 1 deletion(-)

New commits:
commit e86fb2edfdca48b92b11c149002ab2b06a630b94
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Wed Feb 21 03:07:33 2018 +0100

    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 at libreoffice.org>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

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
Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/paste_text_onslide.odp 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() );
 


More information about the Libreoffice-commits mailing list