summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2021-11-19 10:21:46 +0530
committerDennis Francis <dennis.francis@collabora.com>2022-01-29 05:01:16 +0100
commit09ed49ae42b7c5368d0ef2774ba4e04aeb9bafdb (patch)
treed92e54e93c11745dce69a32c37b7cbfd430e7d6c /sc/source/ui
parent651ff4f195804b206941e6316c5120a914d28b6b (diff)
lokCalcRTL: fix editcell tile painting
Don't use internal gridwindow width to invert the edit area coordinates. The gridwin width is not in sync with lok client width, and it seems making them in sync is non-trivial as it currently breaks other things. For tile-painting, always use the width of visible columns in the (combined-)tile area as the mirror width. In the case of LOK + RTL, because we avoid coordinate mirroring based on gridwin-width, any corresponding adjustments in edit engine paper-size, output area, visible area are done appropriately. Advantage of this approach is that the invalidation rectangles sent are in the document coordinates which is exactly what the client expects! So no additional coordinate reversal needed in core or in lok client for invalidation. Change-Id: I0b687a12dc9344fba9ee772111e7598888fa16bf (cherry picked from commit 8266f569c864ae309f362088d42dfb3b952c4267) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128896 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/view/gridwin4.cxx16
-rw-r--r--sc/source/ui/view/viewdata.cxx21
2 files changed, 26 insertions, 11 deletions
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 4ae520a429fc..ddd1cff08964 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1146,6 +1146,18 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
Point aStart = mrViewData.GetScrPos( nCol1, nRow1, eWhich );
Point aEnd = mrViewData.GetScrPos( nCol2+1, nRow2+1, eWhich );
+ if (bIsTiledRendering && bLayoutRTL)
+ {
+ // 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());
+ }
+
// don't overwrite grid
tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
aEnd.AdjustX( -(2 * nLayoutSign) );
@@ -1153,7 +1165,9 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
// set the correct mapmode
tools::Rectangle aBackground(aStart, aEnd);
- tools::Rectangle aBGAbs(aStart, aEnd);
+ if (bIsTiledRendering && bLayoutRTL)
+ aBackground.Justify();
+ tools::Rectangle aBGAbs(aBackground);
if (bIsTiledRendering)
{
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 422b56074ae4..6f51cd24037d 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1648,6 +1648,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
// (existing or started) with default alignment extend to the right.
bool bGrowCentered = ( eJust == SvxCellHorJustify::Center );
bool bGrowToLeft = ( eJust == SvxCellHorJustify::Right ); // visual left
+ bool bLOKRTLInvert = (bLOKActive && bLayoutRTL);
if ( bAsianVertical )
bGrowCentered = bGrowToLeft = false; // keep old behavior for asian mode
@@ -1691,7 +1692,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
nSizeXPTwips = aPTwipsRect.GetWidth() + 2 * std::min(nLeftPTwips, nRightPTwips);
}
}
- else if ( bGrowToLeft )
+ else if ( (bGrowToLeft && !bLOKRTLInvert) || (!bGrowToLeft && bLOKRTLInvert) )
{
nSizeXPix = aPixRect.Right(); // space that's available in the window when growing to the left
if (bLOKPrintTwips)
@@ -1928,12 +1929,12 @@ void ScViewData::EditGrowX()
nLogicRightPTwips = nColWidth;
}
- aArea.AdjustLeft( -(bLayoutRTL ? nLogicRight : nLogicLeft) );
- aArea.AdjustRight(bLayoutRTL ? nLogicLeft : nLogicRight );
+ aArea.AdjustLeft( -((bLayoutRTL && !bLOKActive) ? nLogicRight : nLogicLeft) );
+ aArea.AdjustRight((bLayoutRTL && !bLOKActive) ? nLogicLeft : nLogicRight );
if (bLOKPrintTwips)
{
- aAreaPTwips.AdjustLeft( -(bLayoutRTL ? nLogicRightPTwips : nLogicLeftPTwips) );
- aAreaPTwips.AdjustRight(bLayoutRTL ? nLogicLeftPTwips : nLogicRightPTwips );
+ aAreaPTwips.AdjustLeft( -((bLayoutRTL && !bLOKActive) ? nLogicRightPTwips : nLogicLeftPTwips) );
+ aAreaPTwips.AdjustRight((bLayoutRTL && !bLOKActive) ? nLogicLeftPTwips : nLogicRightPTwips );
}
if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
@@ -1967,7 +1968,7 @@ void ScViewData::EditGrowX()
tools::Long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
tools::Long& nLogicWidthPTwips = nColWidth;
- if ( !bLayoutRTL )
+ if ( !bLayoutRTL || bLOKActive )
{
aArea.AdjustLeft( -nLogicWidth );
if (bLOKPrintTwips)
@@ -1982,7 +1983,7 @@ void ScViewData::EditGrowX()
if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
{
- if ( !bLayoutRTL )
+ if ( !bLayoutRTL || bLOKActive )
{
aArea.SetLeft( aArea.Right() - aSize.Width() + 1 );
if (bLOKPrintTwips)
@@ -2008,7 +2009,7 @@ void ScViewData::EditGrowX()
tools::Long nPix = ToPixel( nColWidth, nPPTX );
tools::Long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
tools::Long& nLogicWidthPTwips = nColWidth;
- if ( bLayoutRTL )
+ if ( bLayoutRTL && !bLOKActive )
{
aArea.AdjustLeft( -nLogicWidth );
if (bLOKPrintTwips)
@@ -2023,7 +2024,7 @@ void ScViewData::EditGrowX()
if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
{
- if ( bLayoutRTL )
+ if ( bLayoutRTL && !bLOKActive )
{
aArea.SetLeft( aArea.Right() - aSize.Width() + 1 );
if (bLOKPrintTwips)
@@ -2516,7 +2517,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
}
}
- if (mrDoc.IsLayoutRTL(nForTab))
+ if (mrDoc.IsLayoutRTL(nForTab) && !bIsTiledRendering)
{
// mirror horizontal position
nScrPosX = aScrSize.Width() - 1 - nScrPosX;