summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2021-11-19 10:21:46 +0530
committerAndras Timar <andras.timar@collabora.com>2022-01-11 11:18:06 +0100
commit8266f569c864ae309f362088d42dfb3b952c4267 (patch)
treeddcc6a5626e08c6d441c4d91311ec9d63d7f8784
parentlokCalcRTL: incorrect invalidation rectangle for... (diff)
downloadcore-8266f569c864ae309f362088d42dfb3b952c4267.tar.gz
core-8266f569c864ae309f362088d42dfb3b952c4267.zip
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
-rw-r--r--sc/source/core/tool/editutil.cxx6
-rw-r--r--sc/source/ui/view/gridwin4.cxx16
-rw-r--r--sc/source/ui/view/viewdata.cxx21
3 files changed, 30 insertions, 13 deletions
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index be3f6a5e9d2e..2167cbbc971a 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -35,6 +35,7 @@
#include <svl/inethist.hxx>
#include <unotools/syslocale.hxx>
#include <sfx2/objsh.hxx>
+#include <comphelper/lok.hxx>
#include <osl/diagnose.h>
#include <com/sun/star/text/textfield/Type.hpp>
@@ -324,9 +325,10 @@ tools::Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, bool bF
pPattern = pDoc->GetPattern( nCol, nRow, nTab );
Point aStartPos = aCellPos;
+ bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
- tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
+ tools::Long nLayoutSign = (bLayoutRTL && !bIsTiledRendering) ? -1 : 1;
const ScMergeAttr* pMerge = &pPattern->GetItem(ATTR_MERGE);
tools::Long nCellX = pDoc->GetColWidth(nCol,nTab);
@@ -425,7 +427,7 @@ tools::Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, bool bF
aStartPos.AdjustY(nDifY );
nCellY -= nDifY;
- if ( bLayoutRTL )
+ if ( bLayoutRTL && !bIsTiledRendering )
aStartPos.AdjustX( -(nCellX - 2) ); // excluding grid on both sides
// -1 -> don't overwrite grid
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 6a644786906d..ded37621e12f 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1129,6 +1129,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 = -aOriginalMode.GetOrigin().X() / TWIPS_PER_PIXEL;
+ // 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) );
@@ -1136,7 +1148,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 a2bf70ff6199..6e2bf8ee0aa4 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1647,6 +1647,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
@@ -1690,7 +1691,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)
@@ -1925,12 +1926,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 )
@@ -1964,7 +1965,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)
@@ -1979,7 +1980,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)
@@ -2005,7 +2006,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)
@@ -2020,7 +2021,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)
@@ -2513,7 +2514,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;