|
|
135360 |
From 07f52f4e37afec5952dc42a9cafbcaac9c2152ae Mon Sep 17 00:00:00 2001
|
|
|
135360 |
From: Andrzej Hunt <andrzej@ahunt.org>
|
|
|
135360 |
Date: Wed, 4 Nov 2015 17:24:15 +0100
|
|
|
135360 |
Subject: [PATCH 279/398] sc lok: tdf#94605 introduce uno:CellCursor
|
|
|
135360 |
|
|
|
135360 |
This allows the client to rerequest the current cursor position,
|
|
|
135360 |
which is necessary e.g. on zoom-level changes.
|
|
|
135360 |
|
|
|
135360 |
Conflicts:
|
|
|
135360 |
desktop/source/lib/init.cxx
|
|
|
135360 |
sc/inc/docuno.hxx
|
|
|
135360 |
|
|
|
135360 |
Change-Id: I10d81e220a56a36e2ec0c59005cd1d4f134857d5
|
|
|
135360 |
(cherry picked from commit 2bcaffd12263e8f3c2a2fbf8ccc4b9bba2642146)
|
|
|
135360 |
---
|
|
|
135360 |
desktop/source/lib/init.cxx | 43 ++++++++++++++++++++++++++++++++++++++++
|
|
|
135360 |
include/vcl/ITiledRenderable.hxx | 12 +++++++++++
|
|
|
135360 |
sc/inc/docuno.hxx | 6 ++++++
|
|
|
135360 |
sc/source/ui/inc/gridwin.hxx | 9 +++++++++
|
|
|
135360 |
sc/source/ui/unoobj/docuno.cxx | 17 ++++++++++++++++
|
|
|
135360 |
sc/source/ui/view/gridwin.cxx | 36 ++++++++++++++++++++++++++++-----
|
|
|
135360 |
6 files changed, 118 insertions(+), 5 deletions(-)
|
|
|
135360 |
|
|
|
135360 |
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
|
|
|
135360 |
index bf244cd7aefa..3ca554d7e6f9 100644
|
|
|
135360 |
--- a/desktop/source/lib/init.cxx
|
|
|
135360 |
+++ b/desktop/source/lib/init.cxx
|
|
|
135360 |
@@ -31,6 +31,7 @@
|
|
|
135360 |
#include <comphelper/dispatchcommand.hxx>
|
|
|
135360 |
#include <comphelper/lok.hxx>
|
|
|
135360 |
#include <comphelper/processfactory.hxx>
|
|
|
135360 |
+#include <comphelper/string.hxx>
|
|
|
135360 |
|
|
|
135360 |
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
135360 |
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
135360 |
@@ -1208,6 +1209,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
|
|
|
135360 |
{
|
|
|
135360 |
OString aCommand(pCommand);
|
|
|
135360 |
static const OString aViewRowColumnHeaders(".uno:ViewRowColumnHeaders");
|
|
|
135360 |
+ static const OString aCellCursor(".uno:CellCursor");
|
|
|
135360 |
|
|
|
135360 |
if (!strcmp(pCommand, ".uno:CharFontName"))
|
|
|
135360 |
{
|
|
|
135360 |
@@ -1266,6 +1268,47 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
|
|
|
135360 |
|
|
|
135360 |
OUString aHeaders = pDoc->getRowColumnHeaders(aRectangle);
|
|
|
135360 |
OString aString = OUStringToOString(aHeaders, RTL_TEXTENCODING_UTF8);
|
|
|
135360 |
+
|
|
|
135360 |
+ char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
|
|
|
135360 |
+ strcpy(pMemory, aString.getStr());
|
|
|
135360 |
+ return pMemory;
|
|
|
135360 |
+ }
|
|
|
135360 |
+ else if (aCommand.startsWith(aCellCursor)
|
|
|
135360 |
+ {
|
|
|
135360 |
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
|
|
|
135360 |
+ if (!pDoc)
|
|
|
135360 |
+ {
|
|
|
135360 |
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
|
|
|
135360 |
+ return 0;
|
|
|
135360 |
+ }
|
|
|
135360 |
+
|
|
|
135360 |
+ OString aString;
|
|
|
135360 |
+ OString aParams = aCommand.copy(OString(".uno:CellCursor:").getLength());
|
|
|
135360 |
+
|
|
|
135360 |
+ sal_Int32 nIndex = 0;
|
|
|
135360 |
+ OString aOutputWidth = aParams.getToken(0, ',', nIndex);
|
|
|
135360 |
+ OString aOutputHeight = aParams.getToken(0, ',', nIndex);
|
|
|
135360 |
+ OString aTileWidth = aParams.getToken(0, ',', nIndex);
|
|
|
135360 |
+ OString aTileHeight = aParams.getToken(0, ',', nIndex);
|
|
|
135360 |
+
|
|
|
135360 |
+ int nOutputWidth, nOutputHeight;
|
|
|
135360 |
+ long nTileWidth, nTileHeight;
|
|
|
135360 |
+ if (!(comphelper::string::getTokenCount(aParams, ',') == 4
|
|
|
135360 |
+ && !aOutputWidth.isEmpty()
|
|
|
135360 |
+ && (nOutputWidth = aOutputWidth.toInt32()) != 0
|
|
|
135360 |
+ && !aOutputHeight.isEmpty()
|
|
|
135360 |
+ && (nOutputHeight = aOutputHeight.toInt32()) != 0
|
|
|
135360 |
+ && !aTileWidth.isEmpty()
|
|
|
135360 |
+ && (nTileWidth = aTileWidth.toInt64()) != 0
|
|
|
135360 |
+ && !aTileHeight.isEmpty()
|
|
|
135360 |
+ && (nTileHeight = aTileHeight.toInt64()) != 0))
|
|
|
135360 |
+ {
|
|
|
135360 |
+ gImpl->maLastExceptionMsg = "Can't parse arguments for .uno:CellCursor, no cursor returned";
|
|
|
135360 |
+ return NULL;
|
|
|
135360 |
+ }
|
|
|
135360 |
+
|
|
|
135360 |
+ OString aString = pDoc->getCellCursor(nOutputWidth, nOutputHeight, nTileWidth, nTileHeight);
|
|
|
135360 |
+
|
|
|
135360 |
char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
|
|
|
135360 |
strcpy(pMemory, aString.getStr());
|
|
|
135360 |
return pMemory;
|
|
|
135360 |
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
|
|
|
135360 |
index efa9bc272b40..963f1fc7054a 100644
|
|
|
135360 |
--- a/include/vcl/ITiledRenderable.hxx
|
|
|
135360 |
+++ b/include/vcl/ITiledRenderable.hxx
|
|
|
135360 |
@@ -159,6 +159,18 @@ public:
|
|
|
135360 |
return OUString();
|
|
|
135360 |
}
|
|
|
135360 |
|
|
|
135360 |
+ /**
|
|
|
135360 |
+ * Get position and size of cell cursor in Calc.
|
|
|
135360 |
+ * (This could maybe also be used for tables in Writer/Impress in future?)
|
|
|
135360 |
+ */
|
|
|
135360 |
+ virtual OString getCellCursor(int /*nOutputWidth*/,
|
|
|
135360 |
+ int /*nOutputHeight*/,
|
|
|
135360 |
+ long /*nTileWidth*/,
|
|
|
135360 |
+ long /*nTileHeight*/)
|
|
|
135360 |
+ {
|
|
|
135360 |
+ return OString();
|
|
|
135360 |
+ }
|
|
|
135360 |
+
|
|
|
135360 |
/// Sets the clipboard of the component.
|
|
|
135360 |
virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) = 0;
|
|
|
135360 |
|
|
|
135360 |
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
|
|
|
135360 |
index 828fc1af7ea0..70f61ca03548 100644
|
|
|
135360 |
--- a/sc/inc/docuno.hxx
|
|
|
135360 |
+++ b/sc/inc/docuno.hxx
|
|
|
135360 |
@@ -424,6 +424,12 @@ public:
|
|
|
135360 |
|
|
|
135360 |
/// @see vcl::ITiledRenderable::getRowColumnHeaders().
|
|
|
135360 |
virtual OUString getRowColumnHeaders(const Rectangle& rRectangle) override;
|
|
|
135360 |
+
|
|
|
135360 |
+ /// @see vcl::ITiledRenderable::getCellCursor().
|
|
|
135360 |
+ virtual OString getCellCursor( int nOutputWidth,
|
|
|
135360 |
+ int nOutputHeight,
|
|
|
135360 |
+ long nTileWidth,
|
|
|
135360 |
+ long nTileHeight ) override;
|
|
|
135360 |
};
|
|
|
135360 |
|
|
|
135360 |
class ScDrawPagesObj : public cppu::WeakImplHelper2<
|
|
|
135360 |
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
|
|
|
135360 |
index 747ce88c2038..8081f107409c 100644
|
|
|
135360 |
--- a/sc/source/ui/inc/gridwin.hxx
|
|
|
135360 |
+++ b/sc/source/ui/inc/gridwin.hxx
|
|
|
135360 |
@@ -301,6 +301,7 @@ class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSou
|
|
|
135360 |
|
|
|
135360 |
void GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
|
|
|
135360 |
|
|
|
135360 |
+
|
|
|
135360 |
void updateLibreOfficeKitCellCursor();
|
|
|
135360 |
protected:
|
|
|
135360 |
virtual void PrePaint(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
|
|
|
135360 |
@@ -445,6 +446,14 @@ public:
|
|
|
135360 |
void UpdateShrinkOverlay();
|
|
|
135360 |
void UpdateAllOverlays();
|
|
|
135360 |
|
|
|
135360 |
+ /// @see ScModelObj::getCellCursor().
|
|
|
135360 |
+ OString getCellCursor(const Fraction& rZoomX,
|
|
|
135360 |
+ const Fraction& rZoomY);
|
|
|
135360 |
+ OString getCellCursor(int nOutputWidth,
|
|
|
135360 |
+ int nOutputHeight,
|
|
|
135360 |
+ long nTileWidth,
|
|
|
135360 |
+ long nTileHeight);
|
|
|
135360 |
+
|
|
|
135360 |
protected:
|
|
|
135360 |
// #114409#
|
|
|
135360 |
void ImpCreateOverlayObjects();
|
|
|
135360 |
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
|
|
|
135360 |
index 1316fd73d328..66794f3c6f27 100644
|
|
|
135360 |
--- a/sc/source/ui/unoobj/docuno.cxx
|
|
|
135360 |
+++ b/sc/source/ui/unoobj/docuno.cxx
|
|
|
135360 |
@@ -886,6 +886,23 @@ OUString ScModelObj::getRowColumnHeaders(const Rectangle& rRectangle)
|
|
|
135360 |
return pTabView->getRowColumnHeaders(rRectangle);
|
|
|
135360 |
}
|
|
|
135360 |
|
|
|
135360 |
+OString ScModelObj::getCellCursor( int nOutputWidth, int nOutputHeight,
|
|
|
135360 |
+ long nTileWidth, long nTileHeight )
|
|
|
135360 |
+{
|
|
|
135360 |
+ SolarMutexGuard aGuard;
|
|
|
135360 |
+
|
|
|
135360 |
+ ScViewData* pViewData = ScDocShell::GetViewData();
|
|
|
135360 |
+
|
|
|
135360 |
+ if (!pViewData)
|
|
|
135360 |
+ return OString();
|
|
|
135360 |
+
|
|
|
135360 |
+ ScGridWindow* pGridWindow = pViewData->GetActiveWin();
|
|
|
135360 |
+ if (!pGridWindow)
|
|
|
135360 |
+ return OString();
|
|
|
135360 |
+
|
|
|
135360 |
+ return "{ \"commandName\": \".uno:CellCursor\", \"commandValues\": \"" + pGridWindow->getCellCursor( nOutputWidth, nOutputHeight, nTileWidth, nTileHeight ) + "\" }";
|
|
|
135360 |
+}
|
|
|
135360 |
+
|
|
|
135360 |
void ScModelObj::initializeForTiledRendering()
|
|
|
135360 |
{
|
|
|
135360 |
SolarMutexGuard aGuard;
|
|
|
135360 |
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
|
|
|
135360 |
index daca987b14b2..efa8d332ad2a 100644
|
|
|
135360 |
--- a/sc/source/ui/view/gridwin.cxx
|
|
|
135360 |
+++ b/sc/source/ui/view/gridwin.cxx
|
|
|
135360 |
@@ -5784,19 +5784,36 @@ bool ScGridWindow::InsideVisibleRange( SCCOL nPosX, SCROW nPosY )
|
|
|
135360 |
return maVisibleRange.isInside(nPosX, nPosY);
|
|
|
135360 |
}
|
|
|
135360 |
|
|
|
135360 |
-void ScGridWindow::updateLibreOfficeKitCellCursor() {
|
|
|
135360 |
+// Use the same zoom calculations as in paintTile - this
|
|
|
135360 |
+// means the client can ensure they can get the correct
|
|
|
135360 |
+// cursor corresponding to their current tile sizings.
|
|
|
135360 |
+OString ScGridWindow::getCellCursor( int nOutputWidth, int nOutputHeight,
|
|
|
135360 |
+ long nTileWidth, long nTileHeight )
|
|
|
135360 |
+{
|
|
|
135360 |
+ Fraction zoomX = Fraction(long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
|
|
|
135360 |
+ Fraction zoomY = Fraction(long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
|
|
|
135360 |
+ return getCellCursor(zoomX, zoomY);
|
|
|
135360 |
+}
|
|
|
135360 |
+
|
|
|
135360 |
+OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoomY) {
|
|
|
135360 |
ScDocument* pDoc = pViewData->GetDocument();
|
|
|
135360 |
ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
|
|
|
135360 |
|
|
|
135360 |
- if (!pDrawLayer->isTiledRendering())
|
|
|
135360 |
- return;
|
|
|
135360 |
+ // GridWindows stores a shown cell cursor in mpOOCursors, hence
|
|
|
135360 |
+ // we can use that to determine whether we would want to be showing
|
|
|
135360 |
+ // one (client-side) for tiled rendering too.
|
|
|
135360 |
+ if (!pDrawLayer->isTiledRendering() || !mpOOCursors.get())
|
|
|
135360 |
+ {
|
|
|
135360 |
+ return OString("EMPTY");
|
|
|
135360 |
+ }
|
|
|
135360 |
|
|
|
135360 |
SCCOL nX = pViewData->GetCurX();
|
|
|
135360 |
SCROW nY = pViewData->GetCurY();
|
|
|
135360 |
|
|
|
135360 |
Fraction defaultZoomX = pViewData->GetZoomX();
|
|
|
135360 |
Fraction defaultZoomY = pViewData->GetZoomX();
|
|
|
135360 |
- pViewData->SetZoom(mTiledZoomX, mTiledZoomY, true);
|
|
|
135360 |
+
|
|
|
135360 |
+ pViewData->SetZoom(rZoomX, rZoomY, true);
|
|
|
135360 |
|
|
|
135360 |
Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, true );
|
|
|
135360 |
long nSizeXPix;
|
|
|
135360 |
@@ -5810,7 +5827,15 @@ void ScGridWindow::updateLibreOfficeKitCellCursor() {
|
|
|
135360 |
|
|
|
135360 |
pViewData->SetZoom(defaultZoomX, defaultZoomY, true);
|
|
|
135360 |
|
|
|
135360 |
- pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_CELL_CURSOR, aRect.toString().getStr());
|
|
|
135360 |
+ return aRect.toString();
|
|
|
135360 |
+}
|
|
|
135360 |
+
|
|
|
135360 |
+void ScGridWindow::updateLibreOfficeKitCellCursor()
|
|
|
135360 |
+{
|
|
|
135360 |
+ ScDocument* pDoc = pViewData->GetDocument();
|
|
|
135360 |
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
|
|
|
135360 |
+ OString aCursor = getCellCursor(mTiledZoomX, mTiledZoomY);
|
|
|
135360 |
+ pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr());
|
|
|
135360 |
}
|
|
|
135360 |
|
|
|
135360 |
void ScGridWindow::CursorChanged()
|
|
|
135360 |
@@ -6098,6 +6123,7 @@ void ScGridWindow::UpdateCursorOverlay()
|
|
|
135360 |
if ( !aPixelRects.empty() )
|
|
|
135360 |
{
|
|
|
135360 |
if (pDrawLayer->isTiledRendering()) {
|
|
|
135360 |
+ mpOOCursors.reset(new sdr::overlay::OverlayObjectList);
|
|
|
135360 |
updateLibreOfficeKitCellCursor();
|
|
|
135360 |
}
|
|
|
135360 |
else
|
|
|
135360 |
--
|
|
|
135360 |
2.12.0
|
|
|
135360 |
|