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 | 105 ++++++++-------------------- sc/source/ui/view/viewdata.cxx | 33 ++++++++ 9 files changed, 78 insertions(+), 139 deletions(-)
New commits: commit c6b18508aec0e609b4c3c000faf89c21e93620bd Author: Michael Meeks <[email protected]> AuthorDate: Tue Dec 3 12:18:37 2019 +0000 Commit: Michael Meeks <[email protected]> CommitDate: Tue Dec 3 17:54:48 2019 +0000 lok: send other views our cursor position in their view co-ordinates. Change-Id: If8d84a04e8d7b4863dcb9bc9058939b1eb793266 diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 7064457290e3..a4ce729b3e2f 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5664,28 +5664,42 @@ OString ScGridWindow::getCellCursor() const return pViewData->describeCellCursor(); } -void ScGridWindow::updateLibreOfficeKitCellCursor(const SfxViewShell* pOtherShell) const -{ - OString aCursor = getCellCursor(); +// Send our cursor details to a view described by @pOtherShell, or all views +// if @pOtherShell is null. In each case send the current view a cell-cursor +// event, and others a cell_view_cursor event. +// +// NB. we need to re-construct the cursor details for each other view in their +// own zoomed co-ordinate system. +void ScGridWindow::updateLibreOfficeKitCellCursor(const SfxViewShell* pForShell) const +{ + if (!pForShell) // recurse with it set + { + for (SfxViewShell* it = SfxViewShell::GetFirst(); it; + it = SfxViewShell::GetNext(*it)) + updateLibreOfficeKitCellCursor(it); + return; + } + ScTabViewShell* pViewShell = pViewData->GetViewShell(); - if (pOtherShell) + if (pForShell == pViewShell) { - if (pOtherShell == pViewShell) - { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr()); - - if (bListValButton && aListValPos == pViewData->GetCurPos()) - updateLOKValListButton(true, aListValPos); - } - else - { - SfxLokHelper::notifyOtherView(pViewShell, pOtherShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor); - } + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, getCellCursor().getStr()); + if (bListValButton && aListValPos == pViewData->GetCurPos()) + updateLOKValListButton(true, aListValPos); } else { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr()); - SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor); + OString aCursor("EMPTY"); + if (mpOOCursors) // cf. getCellCursor above + { + auto pOther = dynamic_cast<const ScTabViewShell *>(pForShell); + assert(pOther); + if (!pOther) + return; + aCursor = pOther->GetViewData().describeCellCursorAt( + pViewData->GetCurX(), pViewData->GetCurY()); // our position. + } + SfxLokHelper::notifyOtherView(pViewShell, pForShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor); } } commit db6a4e91f09870d1f279f628bff786b862894639 Author: Michael Meeks <[email protected]> AuthorDate: Tue Dec 3 10:55:35 2019 +0000 Commit: Michael Meeks <[email protected]> CommitDate: Tue Dec 3 17:54:45 2019 +0000 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 diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index eff6e15c6994..2d2278d6701f 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -818,7 +818,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 f3520a7e83dd..949f8fe0e93e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -4511,44 +4511,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 c1c5c1c0d924..63646d5c5df0 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -228,13 +228,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 88d463569144..5a5cf33bd3e9 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 Pointer getPointer() override; diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 37ff1afeebb6..050ce492fe1e 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -428,13 +428,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 473a1ef020ec..1c8fa028f355 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -596,6 +596,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 44d66e768404..13e3938a30a0 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -908,8 +908,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; @@ -922,7 +921,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() + "\" }"; } Pointer ScModelObj::getPointer() diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index cec4f8c3ac00..7064457290e3 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5653,68 +5653,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 = 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) 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 OString("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 4414902c8c28..28ae0b54fbf6 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2176,6 +2176,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 67ea3986d1662d11bf1f41c86ec86de809c4347b Author: Michael Meeks <[email protected]> AuthorDate: Tue Dec 3 11:18:33 2019 +0000 Commit: Michael Meeks <[email protected]> CommitDate: Tue Dec 3 17:53:36 2019 +0000 revert optimization - 31b7dc19c32f42197c481cb7d2f44c600b755e2b Doing faster lookups across the calc data structrures is far more effective than complex caching of this kind. Change-Id: I43d3ee948ae817ec1d196acc6e5603e6acf1970c diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index b0b6a44f055e..473a1ef020ec 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -233,8 +233,6 @@ private: SCROW nCurY; SCCOL nOldCurX; SCROW nOldCurY; - SCCOL nLOKOldCurX; - SCROW nLOKOldCurY; ScPositionHelper aWidthHelper; ScPositionHelper aHeightHelper; @@ -402,8 +400,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); } @@ -434,8 +430,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 4719c08cc235..cec4f8c3ac00 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5709,13 +5709,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 d6b7c041cecd..4414902c8c28 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -479,8 +479,6 @@ ScViewDataTable::ScViewDataTable() : nCurY( 0 ), nOldCurX( 0 ), nOldCurY( 0 ), - nLOKOldCurX( 0 ), - nLOKOldCurY( 0 ), aWidthHelper(true), aHeightHelper(false), nMaxTiledCol( 20 ), _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
