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

LOK: add LOK_CALLBACK_TEXT_SELECTION_START/END

Without this, it's really hard to figure out where to put selection
handles based on the selection polygon.

Change-Id: I7fde038a33633796a43f0b454a5a7cff701c5dc3
üst 5dee9102
......@@ -75,7 +75,25 @@ typedef enum
* LOK_CALLBACK_INVALIDATE_TILES. When there is no selection, an empty
* string is provided.
*/
LOK_CALLBACK_TEXT_SELECTION
LOK_CALLBACK_TEXT_SELECTION,
/**
* The size and/or the position of the cursor rectangle at the text
* selection start changed.
*
* If this callback is emitted, it's always followed by a
* LOK_CALLBACK_TEXT_SELECTION one. Rectangle format is the same as
* LOK_CALLBACK_INVALIDATE_TILES.
*/
LOK_CALLBACK_TEXT_SELECTION_START,
/**
* The size and/or the position of the cursor rectangle at the text
* selection end changed.
*
* If this callback is emitted, it's always followed by a
* LOK_CALLBACK_TEXT_SELECTION one. Rectangle format is the same as
* LOK_CALLBACK_INVALIDATE_TILES.
*/
LOK_CALLBACK_TEXT_SELECTION_END
}
LibreOfficeKitCallbackType;
......
......@@ -42,6 +42,7 @@
#include <wrtsh.hxx>
#include <comcore.hrc>
#include <view.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <svx/sdr/overlay/overlaymanager.hxx>
#include <svx/sdrpaintwindow.hxx>
......@@ -256,6 +257,23 @@ void SwSelPaintRects::Hide()
SwRects::clear();
}
/**
* Return a layout rectangle (typically with minimal width) that represents a
* cursor at rPosition.
*
* @param rPoint layout position as a hint about what layout frame contains
* rPosition (there might be multiple frames for a single node)
* @param rPosition the doc model position (paragraph / character index)
*/
static SwRect lcl_getLayoutRect(const Point& rPoint, const SwPosition& rPosition)
{
const SwCntntNode* pNode = rPosition.nNode.GetNode().GetCntntNode();
const SwCntntFrm* pFrm = pNode->getLayoutFrm(pNode->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout(), &rPoint, &rPosition);
SwRect aRect;
pFrm->GetCharRect(aRect, rPosition);
return aRect;
}
void SwSelPaintRects::Show()
{
SdrView* pView = (SdrView*)pCShell->GetDrawView();
......@@ -316,6 +334,24 @@ void SwSelPaintRects::Show()
if (GetShell()->isTiledRendering())
{
if (!empty())
{
// The selection may be a complex polygon, emit the logical
// start/end cursor rectangle of the selection as separate
// events, if there is a real selection.
// This can be used to easily show selection handles on the
// client side.
const SwShellCrsr* pCursor = GetShell()->getShellCrsr(false);
SwRect aStartRect = lcl_getLayoutRect(pCursor->GetSttPos(), *pCursor->Start());
std::stringstream ss;
ss << aStartRect.Width() << ", " << aStartRect.Height() << ", " << aStartRect.Left() << ", " << aStartRect.Top();
GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, ss.str().c_str());
SwRect aEndRect = lcl_getLayoutRect(pCursor->GetEndPos(), *pCursor->End());
ss.str("");
ss << aEndRect.Width() << ", " << aEndRect.Height() << ", " << aEndRect.Left() << ", " << aEndRect.Top();
GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, ss.str().c_str());
}
std::stringstream ss;
for (size_type i = 0; i < size(); ++i)
{
......
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