sc/source/ui/view/tabview.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
New commits: commit 349593166af244566fe0a8d2c11f3bcd73048c1d Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Mon Jan 10 12:03:54 2022 +0530 Commit: Dennis Francis <dennis.fran...@collabora.com> CommitDate: Sat Feb 5 09:59:49 2022 +0100 lokCalcRTL: fix chart insertion position Change-Id: I573cb19643d7a048f3313aba90fa9b5514c9cc74 (cherry picked from commit f1ff0ec57914e8871f8563cd26ee1b87d562f1c8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129365 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 8d8412d3673e..8f0ce9d9bd06 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -1704,9 +1704,12 @@ Point ScTabView::GetChartInsertPos( const Size& rSize, const ScRange& rCellRange ActivatePart( eUsedPart ); // get the visible rectangle in logic units - + bool bLOKActive = comphelper::LibreOfficeKit::isActive(); MapMode aDrawMode = pWin->GetDrawMapMode(); - tools::Rectangle aVisible( pWin->PixelToLogic( tools::Rectangle( Point(0,0), pWin->GetOutputSizePixel() ), aDrawMode ) ); + tools::Rectangle aVisible( + bLOKActive ? + OutputDevice::LogicToLogic( aViewData.getLOKVisibleArea(), MapMode(MapUnit::MapTwip), MapMode(MapUnit::Map100thMM) ) + : pWin->PixelToLogic( tools::Rectangle( Point(0,0), pWin->GetOutputSizePixel() ), aDrawMode ) ); ScDocument& rDoc = aViewData.GetDocument(); SCTAB nTab = aViewData.GetTabNo(); @@ -1730,6 +1733,14 @@ Point ScTabView::GetChartInsertPos( const Size& rSize, const ScRange& rCellRange tools::Rectangle aSelection = rDoc.GetMMRect( rCellRange.aStart.Col(), rCellRange.aStart.Row(), rCellRange.aEnd.Col(), rCellRange.aEnd.Row(), nTab ); + if (bLOKActive && bLayoutRTL) + { + // In this case we operate in negative X coordinates. The rectangle aSelection already + // has negative X coordinates. So the x coordinates in the rectangle aVisible(from getLOKVisibleArea) + // need be negated to match. + aVisible = tools::Rectangle(-aVisible.Right(), aVisible.Top(), -aVisible.Left(), aVisible.Bottom()); + } + tools::Long nLeftSpace = aSelection.Left() - aVisible.Left(); tools::Long nRightSpace = aVisible.Right() - aSelection.Right(); tools::Long nTopSpace = aSelection.Top() - aVisible.Top(); @@ -1756,7 +1767,6 @@ Point ScTabView::GetChartInsertPos( const Size& rSize, const ScRange& rCellRange else if ( nTopSpace >= nNeededHeight || nBottomSpace >= nNeededHeight ) { // second preference: completely above or below the selection - if ( nBottomSpace > nNeededHeight ) // bottom is preferred aInsertPos.setY( aSelection.Bottom() + 1 ); else