summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-10-25 10:40:05 +0200
committerGökay ŞATIR <gokaysatir@collabora.com>2022-11-04 10:22:50 +0100
commit9257486636dfe95b73e5690462ba6e8408a12166 (patch)
treeb1372b0f13dc43d4873dcd657b49827cd73f80b4
parent8548e3caa8ed6d4e77d136e1b8d3c3b18cf074bb (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>
-rw-r--r--sc/source/ui/view/gridwin4.cxx85
1 files changed, 69 insertions, 16 deletions
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index ddafacfac577..970a4591411f 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -654,6 +654,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)
{
@@ -1070,7 +1088,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();
@@ -1078,7 +1096,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)
@@ -1106,6 +1125,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
@@ -1145,6 +1171,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;
@@ -1167,12 +1194,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));
}
}
@@ -1250,14 +1307,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)
{
@@ -1280,10 +1329,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(
@@ -1315,6 +1360,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);
}