editeng/source/editeng/editview.cxx |   10 +++++++++
 editeng/source/editeng/impedit.cxx  |    3 +-
 editeng/source/editeng/impedit.hxx  |    6 ++++-
 include/editeng/editview.hxx        |    3 ++
 sc/source/ui/view/gridwin4.cxx      |   37 ++++++++++++++++++++++++++++++++++++
 5 files changed, 57 insertions(+), 2 deletions(-)

New commits:
commit 18d8297fe2ae9a312473a0fc4e450fc6dcfa6450
Author:     Dennis Francis <dennis.fran...@collabora.com>
AuthorDate: Wed Jun 3 17:27:28 2020 +0530
Commit:     Dennis Francis <dennis.fran...@collabora.com>
CommitDate: Mon Jul 6 17:44:21 2020 +0200

    lokit: Avoid sending wrong edit-cursor/selection messages when...
    
    the EditView's output-area needs to be tweaked temporarily to render it
    to a tile which is meant for another view.
    
    Change-Id: I2b8fc1986c247ce65c18ea64e3b43d25625c7e9c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98065
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Dennis Francis <dennis.fran...@collabora.com>

diff --git a/editeng/source/editeng/editview.cxx 
b/editeng/source/editeng/editview.cxx
index f96a9f6f5519..23cd5010c1ab 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1606,4 +1606,14 @@ bool EditView::HasLOKSpecialPositioning() const
     return pImpEditView->HasLOKSpecialPositioning();
 }
 
+void EditView::SupressLOKMessages(bool bSet)
+{
+    pImpEditView->SupressLOKMessages(bSet);
+}
+
+bool EditView::IsSupressLOKMessages() const
+{
+    return pImpEditView->IsSupressLOKMessages();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/impedit.cxx 
b/editeng/source/editeng/impedit.cxx
index 27036c689721..ed2c8d43bf9c 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -191,6 +191,7 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* 
pEng, vcl::Window* pWindo
     eAnchorMode         = EEAnchorMode::TopLeft;
     mpEditViewCallbacks = nullptr;
     mbBroadcastLOKViewCursor = comphelper::LibreOfficeKit::isActive();
+    mbSupressLOKMessages = false;
     nInvMore            = 1;
     nTravelXPos         = TRAVEL_X_DONTKNOW;
     nControl            = EVControlBits::AUTOSCROLL | 
EVControlBits::ENABLEPASTE;
@@ -1263,7 +1264,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool 
bForceVisCursor )
 
         GetCursor()->SetSize( aCursorSz );
 
-        if (comphelper::LibreOfficeKit::isActive() && mpViewShell)
+        if (comphelper::LibreOfficeKit::isActive() && mpViewShell && 
!mbSupressLOKMessages)
         {
             Point aPos = GetCursor()->GetPos();
             boost::property_tree::ptree aMessageParams;
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 5568beecd3f5..3e76d820db60 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -309,7 +309,8 @@ private:
     // repaints of the EditView(s)
     const EditViewCallbacks* mpEditViewCallbacks;
     std::unique_ptr<LOKSpecialPositioning> mpLOKSpecialPositioning;
-    bool mbBroadcastLOKViewCursor;
+    bool mbBroadcastLOKViewCursor:1;
+    bool mbSupressLOKMessages:1;
 
     const EditViewCallbacks* getEditViewCallbacks() const
     {
@@ -469,6 +470,9 @@ public:
     void SetLOKSpecialVisArea(const tools::Rectangle& rVisArea);
     tools::Rectangle GetLOKSpecialVisArea() const;
     bool HasLOKSpecialPositioning() const;
+
+    void SupressLOKMessages(bool bSet) { mbSupressLOKMessages = bSet; }
+    bool IsSupressLOKMessages() const { return mbSupressLOKMessages; }
 };
 
 
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index c8a2e3149a10..a7f3180711f5 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -334,6 +334,9 @@ public:
     void SetLOKSpecialVisArea(const tools::Rectangle& rVisArea);
     tools::Rectangle GetLOKSpecialVisArea() const;
     bool HasLOKSpecialPositioning() const;
+
+    void SupressLOKMessages(bool bSet);
+    bool IsSupressLOKMessages() const;
 };
 
 #endif // INCLUDED_EDITENG_EDITVIEW_HXX
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 4d122af6d269..2a1ac2439b65 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -571,6 +571,32 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, 
SCROW nY2, ScUpdateMod
     rDoc.PrepareFormulaCalc();
 }
 
+namespace {
+
+class SupressEditViewMessagesGuard
+{
+public:
+    SupressEditViewMessagesGuard(EditView& rEditView) :
+        mrEditView(rEditView),
+        mbOrigSupressFlag(rEditView.IsSupressLOKMessages())
+    {
+        if (!mbOrigSupressFlag)
+            mrEditView.SupressLOKMessages(true);
+    }
+
+    ~SupressEditViewMessagesGuard()
+    {
+        if (mrEditView.IsSupressLOKMessages() != mbOrigSupressFlag)
+            mrEditView.SupressLOKMessages(mbOrigSupressFlag);
+    }
+
+private:
+    EditView& mrEditView;
+    const bool mbOrigSupressFlag;
+};
+
+}
+
 void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& 
rTableInfo, ScOutputData& aOutputData,
         bool bLogicText)
 {
@@ -1019,6 +1045,11 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, 
const ScTableInfo& rTableI
                             const tools::Rectangle 
aOrigOutputArea(pOtherEditView->GetOutputArea()); // Not in pixels.
                             const MapMode aOrigMapMode = 
pOtherWin->GetMapMode();
                             pOtherWin->SetMapMode(rDevice.GetMapMode());
+
+                            // Avoid sending wrong cursor/selection messages 
by the 'other' view, as the output-area is going
+                            // to be tweaked temporarily to match the current 
view's zoom.
+                            SupressEditViewMessagesGuard 
aGuard(*pOtherEditView);
+
                             
pOtherEditView->SetOutputArea(rDevice.PixelToLogic(aEditRect));
                             
pOtherEditView->Paint(rDevice.PixelToLogic(aEditRect), &rDevice);
 
@@ -1117,6 +1148,12 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, 
const ScTableInfo& rTableI
             const tools::Rectangle 
aOrigOutputArea(pEditView->GetOutputArea()); // Not in pixels.
             const MapMode aOrigMapMode = GetMapMode();
             SetMapMode(rDevice.GetMapMode());
+
+            // Avoid sending wrong cursor/selection messages by the current 
view, as the output-area is going
+            // to be tweaked temporarily to match other view's zoom. (This 
does not affect the manual
+            // cursor-messaging done in the non print-twips mode)
+            SupressEditViewMessagesGuard aGuard(*pEditView);
+
             pEditView->SetOutputArea(rDevice.PixelToLogic(aEditRect));
             pEditView->Paint(rDevice.PixelToLogic(aEditRect), &rDevice);
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to