Kaydet (Commit) 65726aae authored tarafından Miklos Vajna's avatar Miklos Vajna

LOK: add lok::Document::setGraphicSelection() API and implement it for Writer

Change-Id: I115cf7e7978622d5108c4c792f7de861beb6efb6
üst c08069f2
......@@ -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);
......
......@@ -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
};
......
......@@ -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
};
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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: */
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment