diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2022-01-10 12:03:54 +0530 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-01-11 11:18:10 +0100 |
commit | f1ff0ec57914e8871f8563cd26ee1b87d562f1c8 (patch) | |
tree | 2e3329dc204c003034b4ff79a9e1d1912c1a8992 /sc | |
parent | c2cbe0dbe4c9e4ce8014e881ba3663add77f7aca (diff) |
lokCalcRTL: fix chart insertion position
Change-Id: I573cb19643d7a048f3313aba90fa9b5514c9cc74
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/view/tabview.cxx | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index f1aa58eabaf3..4dda1b46aa50 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -1703,9 +1703,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(); @@ -1729,6 +1732,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(); @@ -1755,7 +1766,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 |