summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2022-01-10 12:03:54 +0530
committerDennis Francis <dennis.francis@collabora.com>2022-01-11 09:25:22 +0530
commitf2cef4ac748deb0b62a87f947124e854dabce67f (patch)
tree2e3329dc204c003034b4ff79a9e1d1912c1a8992
parent3074e72b4bc41cffbc4103b58132f430e5b0cc81 (diff)
lokCalcRTL: fix chart insertion positionfeature/lok-calc-rtl
Change-Id: I573cb19643d7a048f3313aba90fa9b5514c9cc74
-rw-r--r--sc/source/ui/view/tabview.cxx16
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