summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej@ahunt.org>2015-11-04 17:24:15 +0100
committerAndrzej Hunt <andrzej@ahunt.org>2015-11-06 08:02:45 +0100
commit7020080f693ed8e6843c5099f742887395099477 (patch)
tree7fb3426e8503eab5d1a0785dca9fabcd212c2d4a /sc
parent6c1c80e3e82a5557c71e7b38cb15a4fc4c3f2f20 (diff)
sc lok: tdf#94605 introduce uno:CellCursor
This allows the client to rerequest the current cursor position, which is necessary e.g. on zoom-level changes. Conflicts: desktop/source/lib/init.cxx sc/inc/docuno.hxx (cherry picked from commit 2bcaffd12263e8f3c2a2fbf8ccc4b9bba2642146) Conflicts: sc/inc/docuno.hxx Change-Id: I10d81e220a56a36e2ec0c59005cd1d4f134857d5
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/docuno.hxx6
-rw-r--r--sc/source/ui/inc/gridwin.hxx9
-rw-r--r--sc/source/ui/unoobj/docuno.cxx17
-rw-r--r--sc/source/ui/view/gridwin.cxx36
4 files changed, 63 insertions, 5 deletions
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 58363d64231f..b384eded2926 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -424,6 +424,12 @@ public:
/// @see vcl::ITiledRenderable::getRowColumnHeaders().
virtual OUString getRowColumnHeaders(const Rectangle& rRectangle) SAL_OVERRIDE;
+
+ /// @see vcl::ITiledRenderable::getCellCursor().
+ virtual OString getCellCursor( int nOutputWidth,
+ int nOutputHeight,
+ long nTileWidth,
+ long nTileHeight ) SAL_OVERRIDE;
};
class ScDrawPagesObj : public cppu::WeakImplHelper2<
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 5d5a42511f86..b040e928c701 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -300,6 +300,7 @@ class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSou
void GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
+
void updateLibreOfficeKitCellCursor();
protected:
virtual void PrePaint(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
@@ -444,6 +445,14 @@ public:
void UpdateShrinkOverlay();
void UpdateAllOverlays();
+ /// @see ScModelObj::getCellCursor().
+ OString getCellCursor(const Fraction& rZoomX,
+ const Fraction& rZoomY);
+ OString getCellCursor(int nOutputWidth,
+ int nOutputHeight,
+ long nTileWidth,
+ long nTileHeight);
+
protected:
// #114409#
void ImpCreateOverlayObjects();
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index c84b13c4f58e..c216b36bbce8 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -868,6 +868,23 @@ OUString ScModelObj::getRowColumnHeaders(const Rectangle& rRectangle)
return pTabView->getRowColumnHeaders(rRectangle);
}
+OString ScModelObj::getCellCursor( int nOutputWidth, int nOutputHeight,
+ long nTileWidth, long nTileHeight )
+{
+ SolarMutexGuard aGuard;
+
+ ScViewData* pViewData = ScDocShell::GetViewData();
+
+ if (!pViewData)
+ return OString();
+
+ ScGridWindow* pGridWindow = pViewData->GetActiveWin();
+ if (!pGridWindow)
+ return OString();
+
+ return "{ \"commandName\": \".uno:CellCursor\", \"commandValues\": \"" + pGridWindow->getCellCursor( nOutputWidth, nOutputHeight, nTileWidth, nTileHeight ) + "\" }";
+}
+
void ScModelObj::initializeForTiledRendering()
{
SolarMutexGuard aGuard;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index ab76dae5dcdc..079653b4df18 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5784,19 +5784,36 @@ bool ScGridWindow::InsideVisibleRange( SCCOL nPosX, SCROW nPosY )
return maVisibleRange.isInside(nPosX, nPosY);
}
-void ScGridWindow::updateLibreOfficeKitCellCursor() {
+// Use the same zoom calculations as in paintTile - this
+// means the client can ensure they can get the correct
+// cursor corresponding to their current tile sizings.
+OString ScGridWindow::getCellCursor( int nOutputWidth, int nOutputHeight,
+ long nTileWidth, long nTileHeight )
+{
+ Fraction zoomX = Fraction(long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
+ Fraction zoomY = Fraction(long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
+ return getCellCursor(zoomX, zoomY);
+}
+
+OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoomY) {
ScDocument* pDoc = pViewData->GetDocument();
ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
- if (!pDrawLayer->isTiledRendering())
- return;
+ // GridWindows stores a shown cell cursor in mpOOCursors, hence
+ // we can use that to determine whether we would want to be showing
+ // one (client-side) for tiled rendering too.
+ if (!pDrawLayer->isTiledRendering() || !mpOOCursors.get())
+ {
+ return OString("EMPTY");
+ }
SCCOL nX = pViewData->GetCurX();
SCROW nY = pViewData->GetCurY();
Fraction defaultZoomX = pViewData->GetZoomX();
Fraction defaultZoomY = pViewData->GetZoomX();
- pViewData->SetZoom(mTiledZoomX, mTiledZoomY, true);
+
+ pViewData->SetZoom(rZoomX, rZoomY, true);
Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, true );
long nSizeXPix;
@@ -5810,7 +5827,15 @@ void ScGridWindow::updateLibreOfficeKitCellCursor() {
pViewData->SetZoom(defaultZoomX, defaultZoomY, true);
- pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_CELL_CURSOR, aRect.toString().getStr());
+ return aRect.toString();
+}
+
+void ScGridWindow::updateLibreOfficeKitCellCursor()
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ OString aCursor = getCellCursor(mTiledZoomX, mTiledZoomY);
+ pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr());
}
// #114409#
@@ -6099,6 +6124,7 @@ void ScGridWindow::UpdateCursorOverlay()
if ( !aPixelRects.empty() )
{
if (pDrawLayer->isTiledRendering()) {
+ mpOOCursors.reset(new sdr::overlay::OverlayObjectList);
updateLibreOfficeKitCellCursor();
}
else