diff options
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 3 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 31 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 7 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 13 | ||||
-rw-r--r-- | vcl/source/window/seleng.cxx | 11 |
5 files changed, 63 insertions, 2 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index f819443473d7..1f3365faf2f9 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2867,10 +2867,11 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(57), offsetof(struct _LibreOfficeKitDocumentClass, renderFontOrientation)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), offsetof(struct _LibreOfficeKitDocumentClass, paintWindowForView)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), offsetof(struct _LibreOfficeKitDocumentClass, completeFunction)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(60), offsetof(struct _LibreOfficeKitDocumentClass, setWindowTextSelection)); // Extending is fine, update this, and add new assert for the offsetof the // new method - CPPUNIT_ASSERT_EQUAL(documentClassOffset(60), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 656d7d32a40f..35964dae4447 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -988,6 +988,11 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, bool bNotifyWhenFinished); +static void doc_setWindowTextSelection(LibreOfficeKitDocument* pThis, + unsigned nLOKWindowId, + bool swap, + int nX, + int nY); static void doc_setTextSelection (LibreOfficeKitDocument* pThis, int nType, int nX, @@ -1203,6 +1208,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->sendDialogEvent = doc_sendDialogEvent; m_pDocumentClass->postUnoCommand = doc_postUnoCommand; m_pDocumentClass->setTextSelection = doc_setTextSelection; + m_pDocumentClass->setWindowTextSelection = doc_setWindowTextSelection; m_pDocumentClass->getTextSelection = doc_getTextSelection; m_pDocumentClass->getSelectionType = doc_getSelectionType; m_pDocumentClass->getClipboard = doc_getClipboard; @@ -3885,6 +3891,31 @@ static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int n pDoc->setTextSelection(nType, nX, nY); } +static void doc_setWindowTextSelection(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, bool swap, int nX, int nY) +{ + comphelper::ProfileZone aZone("doc_setWindowTextSelection"); + + SolarMutexGuard aGuard; + SetLastExceptionMsg(); + + VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId); + if (!pWindow) + { + SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found."); + return; + } + + + Size aOffset(pWindow->GetOutOffXPixel(), pWindow->GetOutOffYPixel()); + Point aCursorPos(nX, nY); + aCursorPos.Move(aOffset); + sal_uInt16 nModifier = swap ? KEY_MOD1 + KEY_MOD2 : KEY_SHIFT; + + MouseEvent aCursorEvent(aCursorPos, 1, MouseEventModifiers::SIMPLECLICK, 0, nModifier); + Application::PostMouseEvent(VclEventId::WindowMouseButtonDown, pWindow, &aCursorEvent); + Application::PostMouseEvent(VclEventId::WindowMouseButtonUp, pWindow, &aCursorEvent); +} + static bool getFromTransferrable( const css::uno::Reference<css::datatransfer::XTransferable> &xTransferable, const OString &aInMimeType, OString &aRet); diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index b4278625ccb0..6203c11fb044 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -439,6 +439,13 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::completeFunction(). void (*completeFunction) (LibreOfficeKitDocument* pThis, int nIndex); + /// @see lok::Document::setWindowTextSelection + void (*setWindowTextSelection) (LibreOfficeKitDocument* pThis, + unsigned nWindowId, + bool bSwap, + int nX, + int nY); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index d50ef4823f81..b80a35209bc3 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -767,6 +767,19 @@ public: mpDoc->pClass->completeFunction(mpDoc, nIndex); } + /** + * Sets the start or end of a text selection for a dialog. + * + * @param nWindowId + * @param bSwap swap anchor and cursor position of current selection + * @param nX horizontal position in document coordinates + * @param nY vertical position in document coordinates + */ + void setWindowTextSelection(unsigned nWindowId, bool bSwap, int nX, int nY) + { + mpDoc->pClass->setWindowTextSelection(mpDoc, nWindowId, bSwap, nX, nY); + } + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/vcl/source/window/seleng.cxx b/vcl/source/window/seleng.cxx index 8e81ce88d095..e659db7a5875 100644 --- a/vcl/source/window/seleng.cxx +++ b/vcl/source/window/seleng.cxx @@ -119,7 +119,9 @@ bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt ) return false; sal_uInt16 nModifier = rMEvt.GetModifier() | nLockedMods; - if ( nModifier & KEY_MOD2 ) + bool nSwap = comphelper::LibreOfficeKit::isActive() && (nModifier & KEY_MOD1) && (nModifier & KEY_MOD2); + + if ( !nSwap && (nModifier & KEY_MOD2) ) return false; // in SingleSelection: filter Control-Key, // so that a D&D can be also started with a Ctrl-Click @@ -139,6 +141,13 @@ bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt ) nModifier = 0; } + if (nSwap) + { + pFunctionSet->CreateAnchor(); + pFunctionSet->SetCursorAtPoint( aPos ); + return true; + } + switch ( nModifier ) { case 0: // KEY_NO_KEY |