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-10 09:54:14 +0200
commit2927f36b3e3cf86228547937cc4c5c8874bc1f85 (patch)
tree4311c37d2627b422a9f1f5c7b0ecb2564fd8fe4a /editeng
parentdd4c68b02578618d861a2df687823eaaa8ab35f8 (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/+/98132 Tested-by: Jenkins 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 e235d4eb74a4..07901c0bd8e9 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -168,6 +168,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
@@ -548,7 +552,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)
@@ -556,6 +561,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
@@ -564,6 +572,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();
@@ -584,7 +593,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());
@@ -592,7 +605,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;
@@ -606,6 +623,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.
@@ -647,6 +667,23 @@ void ImpEditView::ImplDrawHighlightRect( OutputDevice* _pTarget, const Point& rD
if ( rDocPosTopLeft.X() == rDocPosBottomRight.X() )
return;
+ 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 ) );
@@ -1276,12 +1313,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 18e1ea9f9308..430046ddddbf 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -238,6 +238,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;