summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2019-12-09 15:40:24 +0000
committerMichael Meeks <michael.meeks@collabora.com>2019-12-16 14:13:23 +0100
commitd1064efc84c151630c0294a92b4caa08be676d8b (patch)
treeb3be4f963b1f4c796ff11bc39fd6c5c74b69afaf /sc/source/ui
parent6c844f9bbc76f615d9a49526670538f045d82e0b (diff)
lok: calc - update our version of the other view's selections on zoom.
Change-Id: I4d23bb77045b41d04109e7dd70a1f47bca8aaa56 Reviewed-on: https://gerrit.libreoffice.org/84767 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/84768 Tested-by: Jenkins
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/inc/gridwin.hxx1
-rw-r--r--sc/source/ui/unoobj/docuno.cxx3
-rw-r--r--sc/source/ui/view/gridwin.cxx35
3 files changed, 37 insertions, 2 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index faea326a7cc1..f66e419ebc9c 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -440,6 +440,7 @@ public:
void updateKitCellCursor(const SfxViewShell* pOtherShell) const;
/// notify this view with new positions for other view's cursors (after zoom)
void updateKitOtherCursors() const;
+ void updateOtherKitSelections() const;
/// Same as MouseButtonDown(), but coordinates are in logic unit.
virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index cae9343550f6..7877fdd30bcf 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -887,8 +887,9 @@ void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int
pViewData->SetZoom(Fraction(nTilePixelWidth_ * TWIPS_PER_PIXEL, nTileTwipWidth_),
Fraction(nTilePixelHeight_ * TWIPS_PER_PIXEL, nTileTwipHeight_), true);
- // refresh our view's take on other view's cursors
+ // refresh our view's take on other view's cursors & selections
pViewData->GetActiveWin()->updateKitOtherCursors();
+ pViewData->GetActiveWin()->updateOtherKitSelections();
}
OUString ScModelObj::getRowColumnHeaders(const tools::Rectangle& rRectangle)
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index b358d9605caf..28fbef5fb1f7 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5910,7 +5910,7 @@ static OString rectanglesToString(const std::vector<tools::Rectangle> &rLogicRec
}
/**
- * Turn the selection ranges rRectangles into the LibreOfficeKit selection, and call the callback.
+ * Turn the selection ranges rRectangles into the LibreOfficeKit selection, and send to other views.
*
* @param pLogicRects - if set then don't invoke the callback, just collect the rectangles in the pointed vector.
*/
@@ -5956,6 +5956,39 @@ void ScGridWindow::UpdateKitSelection(const std::vector<tools::Rectangle>& rRect
}
}
+/**
+ * Fetch the selection ranges for other views into the LibreOfficeKit selection,
+ * map them into our view co-ordinates and send to our view.
+ */
+void ScGridWindow::updateOtherKitSelections() const
+{
+ ScTabViewShell* pViewShell = pViewData->GetViewShell();
+
+ for (SfxViewShell* it = SfxViewShell::GetFirst(); it;
+ it = SfxViewShell::GetNext(*it))
+ {
+ auto pOther = dynamic_cast<const ScTabViewShell *>(it);
+ assert(pOther);
+ if (!pOther)
+ return;
+
+ // Fetch pixels & convert for each view separately.
+ tools::Rectangle aBoundingBox;
+ std::vector<tools::Rectangle> aPixelRects;
+ GetPixelRectsFor(pOther->GetViewData().GetMarkData() /* theirs */, aPixelRects);
+ auto aOtherLogicRects = convertPixelToLogical(&pViewShell->GetViewData(), aPixelRects, aBoundingBox);
+ OString aRectsString = rectanglesToString(aOtherLogicRects);
+ if (it == pViewShell)
+ {
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, aBoundingBox.toString().getStr());
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aRectsString.getStr());
+ }
+ else
+ SfxLokHelper::notifyOtherView(it, pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION,
+ "selection", aRectsString.getStr());
+ }
+}
+
namespace
{