summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/gridwin4.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/view/gridwin4.cxx')
-rw-r--r--sc/source/ui/view/gridwin4.cxx57
1 files changed, 41 insertions, 16 deletions
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 4f1f1cc49130..c48b206ef891 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -627,6 +627,34 @@ private:
}
+/**
+ * Used to store the necessary information about the (combined-)tile
+ * area relevant to coordinate transformations in RTL mode.
+ */
+class ScLokRTLContext
+{
+public:
+ ScLokRTLContext(const ScOutputData& rOutputData, const tools::Long nTileDeviceOriginPixelX):
+ mrOutputData(rOutputData),
+ mnTileDevOriginX(nTileDeviceOriginPixelX)
+ {}
+
+ /**
+ * Converts from document x pixel position to the
+ * corresponding pixel position w.r.t the tile device origin.
+ */
+ tools::Long docToTilePos(tools::Long nPosX) const
+ {
+ tools::Long nMirrorX = (-2 * mnTileDevOriginX) + mrOutputData.GetScrW();
+ return nMirrorX - 1 - nPosX;
+ }
+
+
+private:
+ const ScOutputData& mrOutputData;
+ const tools::Long mnTileDevOriginX;
+};
+
void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableInfo, ScOutputData& aOutputData,
bool bLogicText)
{
@@ -708,6 +736,10 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
}
tools::Rectangle aDrawingRectLogic;
bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
+ std::unique_ptr<ScLokRTLContext> pLokRTLCtxt(
+ bIsTiledRendering && bLayoutRTL ?
+ new ScLokRTLContext(aOutputData, o3tl::convert(aOriginalMode.GetOrigin().X(), o3tl::Length::twip, o3tl::Length::px)) :
+ nullptr);
{
// get drawing pixel rect
@@ -899,9 +931,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
else
pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
- // Autofilter- and Pivot-Buttons
-
- DrawButtons(nX1, nX2, rTableInfo, pContentDev); // Pixel
+ // Autofilter- and Pivot-Buttons
+ DrawButtons(nX1, nX2, rTableInfo, pContentDev, pLokRTLCtxt.get()); // Pixel
pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
@@ -1067,12 +1098,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
{
// Transform the cell range X coordinates such that the edit cell area is
// horizontally mirrored w.r.t the (combined-)tile.
- tools::Long nStartTileX = -o3tl::convert(aOriginalMode.GetOrigin().X(), o3tl::Length::twip, o3tl::Length::px);
- // Note: nStartTileX is scaled by 2 only to offset for the addition of
- // the -ve of the same qty (and nScrX) few lines below.
- tools::Long nMirrorX = 2 * nStartTileX + aOutputData.GetScrW();
- aStart.setX(nMirrorX - 1 - aStart.X());
- aEnd.setX(nMirrorX - 1 - aEnd.X());
+ aStart.setX(pLokRTLCtxt->docToTilePos(aStart.X()));
+ aEnd.setX(pLokRTLCtxt->docToTilePos(aEnd.X()));
}
// don't overwrite grid
@@ -1165,12 +1192,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
{
// Transform the cell range X coordinates such that the edit cell area is
// horizontally mirrored w.r.t the (combined-)tile.
- tools::Long nStartTileX = -o3tl::convert(aOriginalMode.GetOrigin().X(), o3tl::Length::twip, o3tl::Length::px);
- // Note: nStartTileX is scaled by 2 only to offset for the addition of
- // the -ve of the same qty (and nScrX) few lines below.
- tools::Long nMirrorX = 2 * nStartTileX + aOutputData.GetScrW();
- aStart.setX(nMirrorX - 1 - aStart.X());
- aEnd.setX(nMirrorX - 1 - aEnd.X());
+ aStart.setX(pLokRTLCtxt->docToTilePos(aStart.X()));
+ aEnd.setX(pLokRTLCtxt->docToTilePos(aEnd.X()));
}
// don't overwrite grid
@@ -1960,7 +1983,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
}
}
-void ScGridWindow::DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo, OutputDevice* pContentDev)
+void ScGridWindow::DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo, OutputDevice* pContentDev, ScLokRTLContext* pLokRTLContext)
{
aComboButton.SetOutputDevice( pContentDev );
@@ -2054,6 +2077,8 @@ void ScGridWindow::DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo
mrViewData.GetMergeSizePixel( nStartCol, nStartRow, nSizeX, nSizeY );//get nSizeX
nSizeY = ScViewData::ToPixel(rDoc.GetRowHeight(nRow, nTab), mrViewData.GetPPTY());
Point aScrPos = mrViewData.GetScrPos( nCol, nRow, eWhich );
+ if (pLokRTLContext)
+ aScrPos.setX(pLokRTLContext->docToTilePos(aScrPos.X()));
aCellBtn.setBoundingBox(aScrPos, Size(nSizeX-1, nSizeY-1), bLayoutRTL);
aCellBtn.setPopupLeft(bLayoutRTL); // #i114944# AutoFilter button is left-aligned in RTL