summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2021-11-24 16:09:29 +0530
committerDennis Francis <dennis.francis@collabora.com>2022-01-31 05:55:54 +0100
commit324b76a3f76acd2bd00c2023a3fe990d4eefd12d (patch)
treef875570b04487424fb6290f7e1d640e092881c64 /sc/source/ui
parent5c138ac6a8334825ef171ac6291b66b277eb4288 (diff)
lokCalcRTL: draw autofilter buttons at correct coordinates
Factor out the transformation from document coordinates to tile device coordinates in ScLokRTLContext. Conflicts: sc/source/ui/view/gridwin4.cxx Change-Id: I426a179bff253233f6d45b67ddfde8b3bb1344a1 (cherry picked from commit 0145c2c0e4c69d486693488fa24490ee4458349a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128901 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/inc/gridwin.hxx4
-rw-r--r--sc/source/ui/view/gridwin4.cxx57
2 files changed, 44 insertions, 17 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index e1ab39eb2446..0aa1d55272c9 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -52,6 +52,7 @@ class ScNoteMarker;
class SdrHdlList;
class ScTransferObj;
struct SpellCallbackInfo;
+class ScLokRTLContext;
// mouse status (nMouseStatus)
@@ -416,7 +417,8 @@ public:
void DPLaunchFieldPopupMenu(const Point& rScrPos, const Size& rScrSize,
tools::Long nDimIndex, ScDPObject* pDPObj);
- void DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo, OutputDevice* pContentDev);
+ void DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo, OutputDevice* pContentDev,
+ ScLokRTLContext* pLokRTLContext);
using Window::Draw;
void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
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