diff options
-rw-r--r-- | desktop/source/lib/init.cxx | 17 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 5 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 12 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitEnums.h | 25 | ||||
-rw-r--r-- | include/vcl/ITiledRenderable.hxx | 7 | ||||
-rw-r--r-- | sw/inc/unotxdoc.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 18 | ||||
-rw-r--r-- | sw/source/uibase/inc/edtwin.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 19 |
9 files changed, 107 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 922ec882f2ce..bf10c6847d86 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -217,6 +217,10 @@ static void doc_setTextSelection (LibreOfficeKitDocument* pThis, int nType, int nX, int nY); +static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis, + int nType, + int nX, + int nY); struct LibLODocument_Impl : public _LibreOfficeKitDocument { @@ -247,6 +251,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument m_pDocumentClass->postKeyEvent = doc_postKeyEvent; m_pDocumentClass->postMouseEvent = doc_postMouseEvent; m_pDocumentClass->setTextSelection = doc_setTextSelection; + m_pDocumentClass->setGraphicSelection = doc_setGraphicSelection; gDocumentClass = m_pDocumentClass; } @@ -740,6 +745,18 @@ static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int n pDoc->setTextSelection(nType, nX, nY); } +static void doc_setGraphicSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY) +{ + ITiledRenderable* pDoc = getTiledRenderable(pThis); + if (!pDoc) + { + gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + return; + } + + pDoc->setGraphicSelection(nType, nX, nY); +} + static char* lo_getError (LibreOfficeKit *pThis) { LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis); diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index d4b79067640d..29f07b34df1d 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -137,6 +137,11 @@ struct _LibreOfficeKitDocumentClass int nType, int nX, int nY); + /// @see lok::Document::setGraphicSelection + void (*setGraphicSelection)(LibreOfficeKitDocument* pThis, + int nType, + int nX, + int nY); #endif // LOK_USE_UNSTABLE_API }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index a44238236699..2993193fb31e 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -141,6 +141,18 @@ public: { mpDoc->pClass->setTextSelection(mpDoc, nType, nX, nY); } + + /** + * Adjusts the graphic selection. + * + * @param nType @see LibreOfficeKitSetGraphicSelectionType + * @param nX horizontal position in document coordinates + * @param nY vertical position in document coordinates + */ + inline void setGraphicSelection(int nType, int nX, int nY) + { + mpDoc->pClass->setGraphicSelection(mpDoc, nType, nX, nY); + } #endif // LOK_USE_UNSTABLE_API }; diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index b8ab5f627619..671166e079ed 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -135,6 +135,31 @@ typedef enum } LibreOfficeKitSetTextSelectionType; +typedef enum +{ + /** + * A move or a resize action starts. It is assumed that there is a valid + * graphic selection (see LOK_CALLBACK_GRAPHIC_SELECTION) and the supplied + * coordinates are the ones the user tapped on. + * + * The type of the action is move by default, unless the coordinates are + * the position of a handle (see below), in which case it's a resize. + * + * There are 8 handles for a graphic selection: + * - top-left, top-center, top-right + * - middle-left, middle-right + * - bottom-left, bottom-center, bottom-right + */ + LOK_SETGRAPHICSELECTION_START, + /** + * A move or resize action stops. It is assumed that this is always used + * only after a LOK_SETTEXTSELECTION_START. The supplied coordinates are + * the ones where the user released the screen. + */ + LOK_SETGRAPHICSELECTION_END +} +LibreOfficeKitSetGraphicSelectionType; + #endif // LOK_USE_UNSTABLE_API #ifdef __cplusplus diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index ee903ada6584..7f63b1f7d681 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -115,6 +115,13 @@ public: * @see lok::Document::setTextSelection(). */ virtual void setTextSelection(int /*nType*/, int /*nX*/, int /*nY*/) { } + + /** + * Adjusts the graphic selection. + * + * @see lok::Document::setGraphicSelection(). + */ + virtual void setGraphicSelection(int /*nType*/, int /*nX*/, int /*nY*/) { } }; } // namespace vcl diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index e528195de365..b840385b5ac7 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -417,6 +417,8 @@ public: virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE; /// @see vcl::ITiledRenderable::setTextSelection(). virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE; + /// @see vcl::ITiledRenderable::setGraphicSelection(). + virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE; void Invalidate(); void Reactivate(SwDocShell* pNewDocShell); diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 41c4c91e5478..ca6dd8b89a65 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -6283,4 +6283,22 @@ void SwEditWin::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool rShell.getShellCrsr(/*bBlock=*/false)->Exchange(); } +void SwEditWin::SetGraphicLogicPosition(bool bStart, const Point& rPosition) +{ + if (bStart) + { + MouseEvent aClickEvent(rPosition, 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT); + MouseButtonDown(aClickEvent); + MouseEvent aMoveEvent(Point(rPosition.getX() + MIN_MOVE + 1, rPosition.getY()), 0, MouseEventModifiers::SIMPLEMOVE, MOUSE_LEFT); + MouseMove(aMoveEvent); + } + else + { + MouseEvent aMoveEvent(Point(rPosition.getX() - MIN_MOVE - 1, rPosition.getY()), 0, MouseEventModifiers::SIMPLEMOVE, MOUSE_LEFT); + MouseMove(aMoveEvent); + MouseEvent aClickEvent(rPosition, 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT); + MouseButtonUp(aClickEvent); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx index aa6d63b02e74..3aeee1963a14 100644 --- a/sw/source/uibase/inc/edtwin.hxx +++ b/sw/source/uibase/inc/edtwin.hxx @@ -308,6 +308,8 @@ public: void LogicMouseButtonUp(const MouseEvent& rMouseEvent); /// Allows adjusting the point or mark of the selection to a document coordinate. void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark); + /// Allows starting or ending a graphic move or resize action. + void SetGraphicLogicPosition(bool bStart, const Point& rPosition); }; #endif diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 7e3e1d8d32d4..6c0b8932e89d 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3223,6 +3223,25 @@ void SwXTextDocument::setTextSelection(int nType, int nX, int nY) } } +void SwXTextDocument::setGraphicSelection(int nType, int nX, int nY) +{ + SolarMutexGuard aGuard; + + SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin(); + switch (nType) + { + case LOK_SETTEXTSELECTION_START: + rEditWin.SetGraphicLogicPosition(/*bStart=*/true, Point(nX, nY)); + break; + case LOK_SETTEXTSELECTION_END: + rEditWin.SetGraphicLogicPosition(/*bStart=*/false, Point(nX, nY)); + break; + default: + assert(false); + break; + } +} + void * SAL_CALL SwXTextDocument::operator new( size_t t) throw() { return SwXTextDocumentBaseClass::operator new(t); |