summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2020-06-06 19:49:07 +0530
committerDennis Francis <dennis.francis@collabora.com>2020-07-06 17:46:35 +0200
commit711c45449847fb95e8ee68ff578389ea903c0378 (patch)
tree9621bc33753c25d743a06cdac2b0556ef33ab1aa /editeng
parent1a6642319631e50c83564de453298930e1f5b17a (diff)
lokit: editeng: Use 'special-positioning' data for selections
For Calc, this means the LOK clients get selection rectangle coordinates in print-twips when special positioning is enabled. Change-Id: Ib26341f888cedcde2e2755ea57be0623884bb097 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98068 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/impedit.cxx52
-rw-r--r--editeng/source/editeng/impedit.hxx2
2 files changed, 46 insertions, 8 deletions
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 8f4be0685c0c..2b3ca365ada9 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -171,6 +171,10 @@ tools::Rectangle LOKSpecialPositioning::convertUnit(const tools::Rectangle& rRec
return OutputDevice::LogicToLogic(rRect, MapMode(eRectUnit), MapMode(meUnit));
}
+Point LOKSpecialPositioning::GetRefPoint() const
+{
+ return maOutArea.TopLeft();
+}
// class ImpEditView
@@ -553,7 +557,8 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
}
}
- bool bMm100ToTwip = pOutWin->GetMapMode().GetMapUnit() == MapUnit::Map100thMM;
+ bool bMm100ToTwip = !mpLOKSpecialPositioning &&
+ (pOutWin->GetMapMode().GetMapUnit() == MapUnit::Map100thMM);
Point aOrigin;
if (pOutWin->GetMapMode().GetMapUnit() == MapUnit::MapTwip)
@@ -561,6 +566,9 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
aOrigin = pOutWin->GetMapMode().GetOrigin();
OString sRectangle;
+ OString sRefPoint;
+ if (mpLOKSpecialPositioning)
+ sRefPoint = mpLOKSpecialPositioning->GetRefPoint().toString();
// If we are not in selection mode, then the exported own selection should be empty.
// This is needed always in Online, regardless whether in "selection mode" (whatever
// that is) or not, for tdf#125568, but I don't have the clout to make this completely
@@ -569,6 +577,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
{
std::vector<tools::Rectangle> aRectangles;
pRegion->GetRegionRectangles(aRectangles);
+
if (pOutWin->IsChart())
{
const vcl::Window* pViewShellWindow = mpViewShell->GetEditWindowForActiveOLEObj();
@@ -589,7 +598,11 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
aStart = OutputDevice::LogicToLogic(aStart, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
aStart.Move(aOrigin.getX(), aOrigin.getY());
- mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, aStart.toString().getStr());
+ OString aPayload = aStart.toString();
+ if (mpLOKSpecialPositioning)
+ aPayload += ":: " + sRefPoint;
+
+ mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, aPayload.getStr());
tools::Rectangle& rEnd = aRectangles.back();
tools::Rectangle aEnd(rEnd.Right() - 1, rEnd.Top(), rEnd.Right(), rEnd.Bottom());
@@ -597,7 +610,11 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
aEnd = OutputDevice::LogicToLogic(aEnd, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
aEnd.Move(aOrigin.getX(), aOrigin.getY());
- mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, aEnd.toString().getStr());
+ aPayload = aEnd.toString();
+ if (mpLOKSpecialPositioning)
+ aPayload += ":: " + sRefPoint;
+
+ mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, aPayload.getStr());
}
std::vector<OString> v;
@@ -611,6 +628,9 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
sRectangle = comphelper::string::join("; ", v);
}
+ if (mpLOKSpecialPositioning && !sRectangle.isEmpty())
+ sRectangle += ":: " + sRefPoint;
+
if (mpOtherShell)
{
// Another shell wants to know about our existing selection.
@@ -651,6 +671,23 @@ void ImpEditView::ImplDrawHighlightRect( OutputDevice* _pTarget, const Point& rD
{
if ( rDocPosTopLeft.X() != rDocPosBottomRight.X() )
{
+ if (mpLOKSpecialPositioning && pPolyPoly)
+ {
+ MapUnit eDevUnit = _pTarget->GetMapMode().GetMapUnit();
+ tools::Rectangle aSelRect(rDocPosTopLeft, rDocPosBottomRight);
+ aSelRect = mpLOKSpecialPositioning->GetWindowPos(aSelRect, eDevUnit);
+ const Point aRefPoint = mpLOKSpecialPositioning->GetRefPoint();
+ aSelRect.Move(-aRefPoint.X(), -aRefPoint.Y());
+
+ tools::Polygon aTmpPoly(4);
+ aTmpPoly[0] = aSelRect.TopLeft();
+ aTmpPoly[1] = aSelRect.TopRight();
+ aTmpPoly[2] = aSelRect.BottomRight();
+ aTmpPoly[3] = aSelRect.BottomLeft();
+ pPolyPoly->Insert(aTmpPoly);
+ return;
+ }
+
bool bPixelMode = _pTarget->GetMapMode().GetMapUnit() == MapUnit::MapPixel;
Point aPnt1( GetWindowPos( rDocPosTopLeft ) );
@@ -1280,12 +1317,11 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
tools::Rectangle aCursorRectPureLogical(aEditCursor.TopLeft(), GetCursor()->GetSize());
// Get rectangle in window-coordinates from editeng(doc) coordinates.
aCursorRectPureLogical = mpLOKSpecialPositioning->GetWindowPos(aCursorRectPureLogical, eDevUnit);
- // Lets use the editeng(doc) origin as the refpoint.
- const Point aCursorOrigin = mpLOKSpecialPositioning->GetOutputArea().TopLeft();
- // Get the relative coordinates w.r.t aCursorOrigin.
- aCursorRectPureLogical.Move(-aCursorOrigin.X(), -aCursorOrigin.Y());
+ const Point aRefPoint = mpLOKSpecialPositioning->GetRefPoint();
+ // Get the relative coordinates w.r.t rRefPoint.
+ aCursorRectPureLogical.Move(-aRefPoint.X(), -aRefPoint.Y());
aMessageParams.put("relrect", aCursorRectPureLogical.toString());
- aMessageParams.put("refpoint", aCursorOrigin.toString());
+ aMessageParams.put("refpoint", aRefPoint.toString());
}
if (pOutWin && pOutWin->IsChart())
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 4297206d4be9..fce1687e1ea3 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -244,6 +244,8 @@ public:
Point GetWindowPos(const Point& rDocPos, MapUnit eDocPosUnit) const;
tools::Rectangle GetWindowPos(const tools::Rectangle& rDocRect, MapUnit eDocRectUnit) const;
+ Point GetRefPoint() const;
+
private:
Point convertUnit(const Point& rPos, MapUnit ePosUnit) const;
tools::Rectangle convertUnit(const tools::Rectangle& rRect, MapUnit eRectUnit) const;