desktop/qa/desktop_lib/test_desktop_lib.cxx | 2 desktop/source/lib/init.cxx | 40 ------------------ include/vcl/ITiledRenderable.hxx | 8 +-- sc/inc/docuno.hxx | 5 -- sc/source/ui/inc/gridwin.hxx | 9 ---- sc/source/ui/inc/viewdata.hxx | 10 +--- sc/source/ui/unoobj/docuno.cxx | 5 -- sc/source/ui/view/gridwin.cxx | 61 +--------------------------- sc/source/ui/view/viewdata.cxx | 33 ++++++++++++++- 9 files changed, 49 insertions(+), 124 deletions(-)
New commits: commit 0b245e26dab8f40693fdb7e8e08e662bdba7590e Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Tue Dec 3 10:55:35 2019 +0000 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Wed Dec 4 12:38:10 2019 +0100 lok: cleanup getCellCursor Switching the zoom is no longer necessary - we now have a known and fixed zoom per view now (as the core has), that saves some complexity. Change-Id: I14c952ca1e06fae016faa8b6ee07115c56312ed6 Reviewed-on: https://gerrit.libreoffice.org/84372 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Michael Meeks <michael.me...@collabora.com> diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 1effbc2669b8..232d8cb3073a 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -815,7 +815,7 @@ void DesktopLOKTest::testCellCursor() OString aRectangle(aTree.get<std::string>("commandValues").c_str()); // cell cursor geometry + col + row - CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1279, 255, 0, 0"), aRectangle); + CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1274, 254, 0, 0"), aRectangle); } void DesktopLOKTest::testCommandResult() diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index e5f9d6893bf2..679c4f95b471 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -4524,44 +4524,8 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } - - // Command has parameters. - int nOutputWidth = 0; - int nOutputHeight = 0; - long nTileWidth = 0; - long nTileHeight = 0; - if (aCommand.getLength() > aCellCursor.getLength()) - { - OString aArguments = aCommand.copy(aCellCursor.getLength() + 1); - sal_Int32 nParamIndex = 0; - do - { - OString aParamToken = aArguments.getToken(0, '&', nParamIndex); - sal_Int32 nIndex = 0; - OString aKey; - OString aValue; - do - { - OString aToken = aParamToken.getToken(0, '=', nIndex); - if (!aKey.getLength()) - aKey = aToken; - else - aValue = aToken; - } - while (nIndex >= 0); - if (aKey == "outputWidth") - nOutputWidth = aValue.toInt32(); - else if (aKey == "outputHeight") - nOutputHeight = aValue.toInt32(); - else if (aKey == "tileWidth") - nTileWidth = aValue.toInt64(); - else if (aKey == "tileHeight") - nTileHeight = aValue.toInt64(); - } - while (nParamIndex >= 0); - } - - return convertOString(pDoc->getCellCursor(nOutputWidth, nOutputHeight, nTileWidth, nTileHeight)); + // Ignore command's deprecated parameters. + return convertOString(pDoc->getCellCursor()); } else if (aCommand.startsWith(aFontSubset)) { diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index e26c1387b6e1..163be5f55213 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -175,13 +175,11 @@ public: } /** - * Get position and size of cell cursor in Calc. + * Get position and size of cell cursor in Calc - as JSON in the + * current' views' co-ordinate system. * (This could maybe also be used for tables in Writer/Impress in future?) */ - virtual OString getCellCursor(int /*nOutputWidth*/, - int /*nOutputHeight*/, - long /*nTileWidth*/, - long /*nTileHeight*/) + virtual OString getCellCursor() { return OString(); } diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 207940f731b8..b80933783761 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -367,10 +367,7 @@ public: virtual OUString getRowColumnHeaders(const tools::Rectangle& rRectangle) override; /// @see vcl::ITiledRenderable::getCellCursor(). - virtual OString getCellCursor( int nOutputWidth, - int nOutputHeight, - long nTileWidth, - long nTileHeight ) override; + virtual OString getCellCursor() override; /// @see vcl::ITiledRenderable::getPointer(). virtual PointerStyle getPointer() override; diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index a03b40e6685d..f64bfaa8d667 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -430,13 +430,8 @@ public: void UpdateShrinkOverlay(); void UpdateAllOverlays(); - /// @see ScModelObj::getCellCursor(). - OString getCellCursor(const Fraction& rZoomX, - const Fraction& rZoomY) const; - OString getCellCursor(int nOutputWidth, - int nOutputHeight, - long nTileWidth, - long nTileHeight); + /// get Cell cursor in this view's co-ordinate system @see ScModelObj::getCellCursor(). + OString getCellCursor() const; void updateLibreOfficeKitCellCursor(const SfxViewShell* pOtherShell) const; /// Same as MouseButtonDown(), but coordinates are in logic unit. diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index a01720498893..162ff01492ea 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -599,6 +599,10 @@ public: Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScHSplitPos eWhich ) const; Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) const; + /// return json for our cursor position. + OString describeCellCursor() const { return describeCellCursorAt(GetCurX(), GetCurY()); } + OString describeCellCursorAt(SCCOL nCol, SCROW nRow) const; + SCCOL CellsAtX( SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeY = SC_SIZE_NONE ) const; SCROW CellsAtY( SCROW nPosY, SCROW nDir, ScVSplitPos eWhichY, sal_uInt16 nScrSizeX = SC_SIZE_NONE ) const; diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index eb1e35383c61..04c5bcbe400f 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -902,8 +902,7 @@ OUString ScModelObj::getRowColumnHeaders(const tools::Rectangle& rRectangle) return pTabView->getRowColumnHeaders(rRectangle); } -OString ScModelObj::getCellCursor( int nOutputWidth, int nOutputHeight, - long nTileWidth, long nTileHeight ) +OString ScModelObj::getCellCursor() { SolarMutexGuard aGuard; @@ -916,7 +915,7 @@ OString ScModelObj::getCellCursor( int nOutputWidth, int nOutputHeight, if (!pGridWindow) return OString(); - return "{ \"commandName\": \".uno:CellCursor\", \"commandValues\": \"" + pGridWindow->getCellCursor( nOutputWidth, nOutputHeight, nTileWidth, nTileHeight ) + "\" }"; + return "{ \"commandName\": \".uno:CellCursor\", \"commandValues\": \"" + pGridWindow->getCellCursor() + "\" }"; } PointerStyle ScModelObj::getPointer() diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 67eb99627cc4..d634c4a853f8 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5681,68 +5681,20 @@ bool ScGridWindow::InsideVisibleRange( SCCOL nPosX, SCROW nPosY ) return maVisibleRange.isInside(nPosX, nPosY); } -// 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(long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth); - Fraction zoomY(long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight); - return getCellCursor(zoomX, zoomY); -} - -OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoomY) const +OString ScGridWindow::getCellCursor() const { // GridWindow 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 (!mpOOCursors) - { return "EMPTY"; - } - - SCCOL nX = pViewData->GetCurX(); - SCROW nY = pViewData->GetCurY(); - - Fraction defaultZoomX = pViewData->GetZoomX(); - Fraction defaultZoomY = pViewData->GetZoomY(); - - pViewData->SetZoom(rZoomX, rZoomY, true); - - Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, true ); - long nSizeXPix; - long nSizeYPix; - pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); - - double fPPTX = pViewData->GetPPTX(); - double fPPTY = pViewData->GetPPTY(); - - // make it a slim cell cursor, but not empty - if (nSizeXPix == 0) - nSizeXPix = 1; - - if (nSizeYPix == 0) - nSizeYPix = 1; - - long nPosXTw = rtl::math::round(aScrPos.getX() / fPPTX); - long nPosYTw = rtl::math::round(aScrPos.getY() / fPPTY); - // look at Rectangle( const Point& rLT, const Size& rSize ) for the '- 1' - long nSizeXTw = rtl::math::round(nSizeXPix / fPPTX) - 1; - long nSizeYTw = rtl::math::round(nSizeYPix / fPPTY) - 1; - - std::stringstream ss; - ss << nPosXTw << ", " << nPosYTw << ", " << nSizeXTw << ", " << nSizeYTw << ", " - << nX << ", " << nY; - - pViewData->SetZoom(defaultZoomX, defaultZoomY, true); - return ss.str().c_str(); + return pViewData->describeCellCursor(); } void ScGridWindow::updateLibreOfficeKitCellCursor(const SfxViewShell* pOtherShell) const { - OString aCursor = getCellCursor(pViewData->GetZoomX(), pViewData->GetZoomY()); + OString aCursor = getCellCursor(); ScTabViewShell* pViewShell = pViewData->GetViewShell(); if (pOtherShell) { diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index c740e7465769..d10e1d8be8ed 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2207,6 +2207,37 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, return Point( nScrPosX, nScrPosY ); } +OString ScViewData::describeCellCursorAt(SCCOL nX, SCROW nY) const +{ + Point aScrPos = GetScrPos( nX, nY, SC_SPLIT_BOTTOMRIGHT, true ); + + long nSizeXPix; + long nSizeYPix; + GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); + + double fPPTX = GetPPTX(); + double fPPTY = GetPPTY(); + + // make it a slim cell cursor, but not empty + if (nSizeXPix == 0) + nSizeXPix = 1; + + if (nSizeYPix == 0) + nSizeYPix = 1; + + long nPosXTw = rtl::math::round(aScrPos.getX() / fPPTX); + long nPosYTw = rtl::math::round(aScrPos.getY() / fPPTY); + // look at Rectangle( const Point& rLT, const Size& rSize ) for the '- 1' + long nSizeXTw = rtl::math::round(nSizeXPix / fPPTX) - 1; + long nSizeYTw = rtl::math::round(nSizeYPix / fPPTY) - 1; + + std::stringstream ss; + ss << nPosXTw << ", " << nPosYTw << ", " << nSizeXTw << ", " << nSizeYTw << ", " + << nX << ", " << nY; + + return ss.str().c_str(); +} + // Number of cells on a screen SCCOL ScViewData::CellsAtX( SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeX ) const { commit fae63aea208990590d98990e332f88b24c2958e7 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Tue Dec 3 11:18:33 2019 +0000 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Wed Dec 4 12:37:57 2019 +0100 revert optimization - 31b7dc19c32f42197c481cb7d2f44c600b755e2b Doing faster lookups across the calc data structrures is far more effective than complex caching of this kind. Change-Id: I43d3ee948ae817ec1d196acc6e5603e6acf1970c Reviewed-on: https://gerrit.libreoffice.org/84371 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Michael Meeks <michael.me...@collabora.com> diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 1edfdeebd222..a01720498893 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -234,8 +234,6 @@ private: SCROW nCurY; SCCOL nOldCurX; SCROW nOldCurY; - SCCOL nLOKOldCurX; - SCROW nLOKOldCurY; ScPositionHelper aWidthHelper; ScPositionHelper aHeightHelper; @@ -405,8 +403,6 @@ public: SCROW GetCurYForTab( SCTAB nTabIndex ) const; SCCOL GetOldCurX() const; SCROW GetOldCurY() const; - SCCOL GetLOKOldCurX() const { return pThisTab->nLOKOldCurX; } - SCROW GetLOKOldCurY() const { return pThisTab->nLOKOldCurY; } long GetLOKDocWidthPixel() const { return pThisTab->aWidthHelper.getPosition(pThisTab->nMaxTiledCol); } long GetLOKDocHeightPixel() const { return pThisTab->aHeightHelper.getPosition(pThisTab->nMaxTiledRow); } @@ -437,8 +433,6 @@ public: void SetCurYForTab( SCCOL nNewCurY, SCTAB nTabIndex ); void SetOldCursor( SCCOL nNewX, SCROW nNewY ); void ResetOldCursor(); - void SetLOKOldCurX( SCCOL nCurX ) { pThisTab->nLOKOldCurX = nCurX; } - void SetLOKOldCurY( SCROW nCurY ) { pThisTab->nLOKOldCurY = nCurY; } void SetHSplitMode( ScSplitMode eMode ) { pThisTab->eHSplitMode = eMode; } void SetVSplitMode( ScSplitMode eMode ) { pThisTab->eVSplitMode = eMode; } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index f6b63b2186da..67eb99627cc4 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5737,13 +5737,6 @@ OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoo pViewData->SetZoom(defaultZoomX, defaultZoomY, true); - pViewData->GetLOKWidthHelper().removeByIndex(pViewData->GetLOKOldCurX() - 1); - pViewData->GetLOKWidthHelper().insert(nX - 1, aScrPos.getX()); - pViewData->SetLOKOldCurX(nX); - pViewData->GetLOKHeightHelper().removeByIndex(pViewData->GetLOKOldCurY() - 1); - pViewData->GetLOKHeightHelper().insert(nY - 1, aScrPos.getY()); - pViewData->SetLOKOldCurY(nY); - return ss.str().c_str(); } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 7c4b719f2e33..c740e7465769 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -497,8 +497,6 @@ ScViewDataTable::ScViewDataTable(ScDocument *pDoc) : nCurY( 0 ), nOldCurX( 0 ), nOldCurY( 0 ), - nLOKOldCurX( 0 ), - nLOKOldCurY( 0 ), aWidthHelper(pDoc, true), aHeightHelper(pDoc, false), nMaxTiledCol( 20 ), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits