summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-02-10 10:45:18 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-02-16 09:20:46 +0100
commitd25f9a01c1ee3b4c46c04cfe66a662a01c11207e (patch)
tree9f42bcd0bc9869cbb6003bdff36e99802ee46679 /sw/source
parent5dee910234067175b8be2fe5a6ea93dd0fdc8de9 (diff)
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
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/crsr/viscrs.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 6d7a96143cf8..0b0d63c6255b 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -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)
{