diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2022-10-25 10:40:05 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2022-11-10 20:46:44 +0100 |
commit | 61d716901def607f01ab272996bf40b55642d650 (patch) | |
tree | f0780ace6355ed8caceb59de016a0d10c604a0f8 /sc | |
parent | 1e5e65715cf053deb7d52e62dd598ac51cea5ee6 (diff) |
lok: sc: render expanded EditEngine when editing in-place
It's regression from:
commit 5a0839e60ac75869ad49685ca74ad6c6b49ef925
sc: lok: fix offset edit output area
When we use two views and one is editing multiline cell
after pressing F2 (in in-place mode) by adding new lines
(ctrl + enter) - we need to expand rendering area and
show additional content (which covers next cells).
This patch makes possible to render expanded are in all the
views, not only for one used for rendering.
Change-Id: Ief2cd391a23e65b3eb7eaf89f2a9f6471b87299f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139924
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142502
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 85 |
1 files changed, 69 insertions, 16 deletions
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index de3006db9a30..6716d2f4c4b9 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -653,6 +653,24 @@ private: const tools::Long mnTileDevOriginX; }; +namespace +{ +int lcl_GetMultiLineHeight(EditEngine* pEditEngine) +{ + int nHeight = 0; + int nParagraphs = pEditEngine->GetParagraphCount(); + if (nParagraphs > 1 || (nParagraphs > 0 && pEditEngine->GetLineCount(0) > 1)) + { + for (int nPara = 0; nPara < nParagraphs; nPara++) + { + nHeight += pEditEngine->GetLineCount(nPara) * pEditEngine->GetLineHeight(nPara); + } + } + + return nHeight; +} +} + void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableInfo, ScOutputData& aOutputData, bool bLogicText) { @@ -1072,7 +1090,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI } } - // paint in-place editing on other views + // paint in-place editing if (bIsTiledRendering) { ScTabViewShell* pThisViewShell = mrViewData.GetViewShell(); @@ -1080,7 +1098,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI while (pViewShell) { - if (pViewShell != pThisViewShell && pViewShell->GetDocId() == pThisViewShell->GetDocId()) + bool bEnterLoop = bIsTiledRendering || pViewShell != pThisViewShell; + if (bEnterLoop && pViewShell->GetDocId() == pThisViewShell->GetDocId()) { ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell); if (pTabViewShell) @@ -1108,6 +1127,13 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI Point aStart = mrViewData.GetScrPos( nCol1, nRow1, eOtherWhich ); Point aEnd = mrViewData.GetScrPos( nCol2+1, nRow2+1, eOtherWhich ); + if (bIsTiledRendering) + { + EditEngine* pEditEngine = pOtherEditView->GetEditEngine(); + if (pEditEngine) + aEnd.AdjustY(lcl_GetMultiLineHeight(pEditEngine)); + } + if (bLokRTL) { // Transform the cell range X coordinates such that the edit cell area is @@ -1147,6 +1173,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI // paint the background rDevice.DrawRect(rDevice.PixelToLogic(aBackground)); + tools::Rectangle aBGAbs(aBackground); tools::Rectangle aEditRect(aBackground); tools::Long nOffsetX = 0, nOffsetY = 0; @@ -1169,12 +1196,42 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI SuppressEditViewMessagesGuard aGuard(*pOtherEditView); aEditRect = rDevice.PixelToLogic(aEditRect); - aEditRect.Intersection(pOtherEditView->GetOutputArea()); + if (bIsTiledRendering) + pOtherEditView->SetOutputArea(aEditRect); + else + aEditRect.Intersection(pOtherEditView->GetOutputArea()); pOtherEditView->Paint(aEditRect, &rDevice); + // EditView will do the cursor notifications correctly if we're in + // print-twips messaging mode. + if (bIsTiledRendering && !comphelper::LibreOfficeKit::isCompatFlagSet( + comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs)) + { + // Now we need to get relative cursor position within the editview. + // This is for sending the pixel-aligned twips position of the cursor to the specific views with + // the same given zoom level. + tools::Rectangle aCursorRect = pOtherEditView->GetEditCursor(); + Point aCursPos = OutputDevice::LogicToLogic(aCursorRect.TopLeft(), + MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + + const MapMode& rDevMM = rDevice.GetMapMode(); + MapMode aMM(MapUnit::MapTwip); + aMM.SetScaleX(rDevMM.GetScaleX()); + aMM.SetScaleY(rDevMM.GetScaleY()); + + aBGAbs.AdjustLeft(1); + aBGAbs.AdjustTop(1); + aCursorRect = GetOutDev()->PixelToLogic(aBGAbs, aMM); + aCursorRect.setWidth(0); + aCursorRect.Move(aCursPos.getX(), 0); + // Sends view cursor position to views of all matching zooms if needed (avoids duplicates). + InvalidateLOKViewCursor(aCursorRect, aMM.GetScaleX(), aMM.GetScaleY()); + } + // Rollback the mapmode and 'output area'. rOtherWin.SetMapMode(aOrigMapMode); - pOtherEditView->SetOutputArea(aOrigOutputArea); + if (!bIsTiledRendering) + pOtherEditView->SetOutputArea(aOrigOutputArea); rDevice.SetMapMode(MapMode(MapUnit::MapPixel)); } } @@ -1252,14 +1309,6 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI rDevice.SetMapMode(aNew); } - // paint the background - tools::Rectangle aLogicRect(rDevice.PixelToLogic(aBackground)); - //tdf#100925, rhbz#1283420, Draw some text here, to get - //X11CairoTextRender::getCairoContext called, so that the forced read - //from the underlying X Drawable gets it to sync. - rDevice.DrawText(aLogicRect.BottomLeft(), " "); - rDevice.DrawRect(aLogicRect); - // paint the editeng text if (bIsTiledRendering) { @@ -1282,10 +1331,6 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI // cursor-messaging done in the non print-twips mode) SuppressEditViewMessagesGuard aGuard(*pEditView); - aEditRect = rDevice.PixelToLogic(aEditRect); - aEditRect.Intersection(pEditView->GetOutputArea()); - pEditView->Paint(aEditRect, &rDevice); - // EditView will do the cursor notifications correctly if we're in // print-twips messaging mode. if (!comphelper::LibreOfficeKit::isCompatFlagSet( @@ -1316,6 +1361,14 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI } else { + // paint the background + tools::Rectangle aLogicRect(rDevice.PixelToLogic(aBackground)); + //tdf#100925, rhbz#1283420, Draw some text here, to get + //X11CairoTextRender::getCairoContext called, so that the forced read + //from the underlying X Drawable gets it to sync. + rDevice.DrawText(aLogicRect.BottomLeft(), " "); + rDevice.DrawRect(aLogicRect); + tools::Rectangle aEditRect(Point(nScrX, nScrY), Size(aOutputData.GetScrW(), aOutputData.GetScrH())); pEditView->Paint(rDevice.PixelToLogic(aEditRect), &rDevice); } |