editeng/source/editeng/editview.cxx | 27 ++++++++++++++++++++++++--- editeng/source/editeng/impedit.cxx | 16 +++++++++++++--- editeng/source/editeng/impedit.hxx | 4 ++++ include/editeng/editview.hxx | 4 ++++ sc/source/ui/view/gridwin4.cxx | 9 +++++++-- svx/source/svdraw/svdedxv.cxx | 3 +++ 6 files changed, 55 insertions(+), 8 deletions(-)
New commits: commit 226847e385d021bf2feacdfa796b3eb7023d6f0f Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Tue Jan 4 12:55:45 2022 +0530 Commit: Dennis Francis <dennis.fran...@collabora.com> CommitDate: Fri Feb 4 19:21:53 2022 +0100 lokCalcRTL: fix editing of shape text Inform editeng that negated document x coordinates are used in this case and ensure that editeng generated invalidation rectangles always have positive X coordinates. Conflicts: sc/source/ui/view/gridwin4.cxx Change-Id: I2e450707ce02f7bcd8e4d299f857c37ebbd5e2c6 (cherry picked from commit 0fe02bb99e5dfa8379a49de75683fc350e4c4dbd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129360 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 0c2f8f43b2a9..c8d12f0388d3 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -195,20 +195,30 @@ tools::Rectangle EditView::GetInvalidateRect() const } } +namespace { + +tools::Rectangle lcl_negateRectX(const tools::Rectangle& rRect) +{ + return tools::Rectangle(-rRect.Right(), rRect.Top(), -rRect.Left(), rRect.Bottom()); +} + +} + void EditView::InvalidateWindow(const tools::Rectangle& rClipRect) { + bool bNegativeX = IsNegativeX(); if (EditViewCallbacks* pEditViewCallbacks = pImpEditView->getEditViewCallbacks()) { // do not invalidate and trigger a global repaint, but forward // the need for change to the applied EditViewCallback, can e.g. // be used to visualize the active edit text in an OverlayObject - pEditViewCallbacks->EditViewInvalidate(rClipRect); + pEditViewCallbacks->EditViewInvalidate(bNegativeX ? lcl_negateRectX(rClipRect) : rClipRect); } else { // classic mode: invalidate and trigger full repaint // of the changed area - GetWindow()->Invalidate(rClipRect); + GetWindow()->Invalidate(bNegativeX ? lcl_negateRectX(rClipRect) : rClipRect); } } @@ -216,10 +226,11 @@ void EditView::InvalidateOtherViewWindows( const tools::Rectangle& rInvRect ) { if (comphelper::LibreOfficeKit::isActive()) { + bool bNegativeX = IsNegativeX(); for (auto& pWin : pImpEditView->aOutWindowSet) { if (pWin) - pWin->Invalidate( rInvRect ); + pWin->Invalidate( bNegativeX ? lcl_negateRectX(rInvRect) : rInvRect ); } } } @@ -1678,4 +1689,14 @@ bool EditView::IsSuppressLOKMessages() const return pImpEditView->IsSuppressLOKMessages(); } +void EditView::SetNegativeX(bool bSet) +{ + pImpEditView->SetNegativeX(bSet); +} + +bool EditView::IsNegativeX() const +{ + return pImpEditView->IsNegativeX(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 1175c28661cd..cfd6eb5758dc 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -198,7 +198,8 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo eAnchorMode(EEAnchorMode::TopLeft), mpEditViewCallbacks(nullptr), mbBroadcastLOKViewCursor(comphelper::LibreOfficeKit::isActive()), - mbSuppressLOKMessages(false) + mbSuppressLOKMessages(false), + mbNegativeX(false) { aEditSelection.Min() = pEng->GetEditDoc().GetStartPaM(); aEditSelection.Max() = pEng->GetEditDoc().GetEndPaM(); @@ -875,6 +876,15 @@ void ImpEditView::SetOutputArea( const tools::Rectangle& rRect ) SetScrollDiffX( static_cast<sal_uInt16>(aOutArea.GetWidth()) * 2 / 10 ); } +namespace { + +tools::Rectangle lcl_negateRectX(const tools::Rectangle& rRect) +{ + return tools::Rectangle(-rRect.Right(), rRect.Top(), -rRect.Left(), rRect.Bottom()); +} + +} + void ImpEditView::InvalidateAtWindow(const tools::Rectangle& rRect) { if (EditViewCallbacks* pCallbacks = getEditViewCallbacks()) @@ -882,13 +892,13 @@ void ImpEditView::InvalidateAtWindow(const tools::Rectangle& rRect) // do not invalidate and trigger a global repaint, but forward // the need for change to the applied EditViewCallback, can e.g. // be used to visualize the active edit text in an OverlayObject - pCallbacks->EditViewInvalidate(rRect); + pCallbacks->EditViewInvalidate(mbNegativeX ? lcl_negateRectX(rRect) : rRect); } else { // classic mode: invalidate and trigger full repaint // of the changed area - GetWindow()->Invalidate(rRect); + GetWindow()->Invalidate(mbNegativeX ? lcl_negateRectX(rRect) : rRect); } } diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index fd130ffaf768..eb8176561cb1 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -302,6 +302,7 @@ private: std::unique_ptr<LOKSpecialPositioning> mpLOKSpecialPositioning; bool mbBroadcastLOKViewCursor:1; bool mbSuppressLOKMessages:1; + bool mbNegativeX:1; EditViewCallbacks* getEditViewCallbacks() const { @@ -468,6 +469,9 @@ public: void SuppressLOKMessages(bool bSet) { mbSuppressLOKMessages = bSet; } bool IsSuppressLOKMessages() const { return mbSuppressLOKMessages; } + + void SetNegativeX(bool bSet) { mbNegativeX = bSet; } + bool IsNegativeX() const { return mbNegativeX; } }; diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx index f610f5ee6bf5..61b659dfb152 100644 --- a/include/editeng/editview.hxx +++ b/include/editeng/editview.hxx @@ -372,6 +372,10 @@ public: void SuppressLOKMessages(bool bSet); bool IsSuppressLOKMessages() const; + + /// To inform editeng that negated x document coordinates are in use. + void SetNegativeX(bool bSet); + bool IsNegativeX() const; }; #endif // INCLUDED_EDITENG_EDITVIEW_HXX diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 42ce441e53d1..ec77fd12be66 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1039,8 +1039,13 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI if (bIsTiledRendering) { Point aOrigin = aOriginalMode.GetOrigin(); - aOrigin.setX(o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px) - + aOutputData.nScrX); + if (bLayoutRTL) + aOrigin.setX(-o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px) + + aOutputData.nScrX + aOutputData.GetScrW()); + else + aOrigin.setX(o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px) + + aOutputData.nScrX); + aOrigin.setY(o3tl::convert(aOrigin.getY(), o3tl::Length::twip, o3tl::Length::px) + aOutputData.nScrY); const double twipFactor = 15 * 1.76388889; // 26.45833335 diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index ad016b5c4f32..a92651abd785 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -872,6 +872,9 @@ OutlinerView* SdrObjEditView::ImpMakeOutlinerView(vcl::Window* pWin, OutlinerVie pOutlView->SetWindow(pWin); } + if (mbNegativeX) + pOutlView->GetEditView().SetNegativeX(mbNegativeX); + // disallow scrolling EVControlBits nStat = pOutlView->GetControlWord(); nStat &= ~EVControlBits::AUTOSCROLL;