[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - editeng/source include/editeng sc/source

Marco Cecchetti marco.cecchetti at collabora.com
Fri Oct 14 11:17:41 UTC 2016


 editeng/source/editeng/editview.cxx |   25 ++++++++++++++--
 editeng/source/editeng/impedit.cxx  |    4 ++
 editeng/source/editeng/impedit3.cxx |    8 -----
 include/editeng/editview.hxx        |    2 +
 sc/source/ui/inc/tabview.hxx        |    4 +-
 sc/source/ui/view/tabview3.cxx      |   34 +++++++++++++++++++---
 sc/source/ui/view/tabview5.cxx      |    6 ++--
 sc/source/ui/view/viewdata.cxx      |   54 ++++++++++++++++++++----------------
 8 files changed, 92 insertions(+), 45 deletions(-)

New commits:
commit 2cc717877527d0791cf879c3d9b38b967e0f094f
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Tue Oct 11 22:50:53 2016 +0200

    LOK: Calc: fixed missed tile invalidations on cell text editing
    
    What's new:
    1) when an edit view is killed, the area which was used by the edit
    view is invalidated for both own window and other view windows after
    the edit view has been destroyed;
    
    2) when an edit view is created or its out area is expanded, the
    windows of other views are invalidated too;
    
    3) when a vertical scroll occurs in the edit view area the windows of
    other view are invalidated too;
    
    4) same methods renaming since now we add/remove windows not edit
    views.
    
    Change-Id: Iac54f5b182c9562f08bb724f9ddde1c26cffa2e7
    Reviewed-on: https://gerrit.libreoffice.org/29740
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    Tested-by: Marco Cecchetti <mrcekets at gmail.com>

diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index ba4c4c8..c2cadb8 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -174,10 +174,10 @@ EditEngine* EditView::GetEditEngine() const
     return pImpEditView->pEditEngine;
 }
 
-void EditView::Invalidate()
+Rectangle EditView::GetInvalidateRect() const
 {
     if ( !pImpEditView->DoInvalidateMore() )
-        pImpEditView->GetWindow()->Invalidate( pImpEditView->aOutArea );
+        return pImpEditView->aOutArea;
     else
     {
         Rectangle aRect( pImpEditView->aOutArea );
@@ -186,10 +186,29 @@ void EditView::Invalidate()
         aRect.Right() += nMore;
         aRect.Top() -= nMore;
         aRect.Bottom() += nMore;
-        pImpEditView->GetWindow()->Invalidate( aRect );
+        return aRect;
+    }
+}
+
+void EditView::InvalidateOtherViewWindows( const Rectangle& rInvRect )
+{
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        for (auto& pWin: GetOtherViewWindows())
+        {
+            if (pWin)
+                pWin->Invalidate( rInvRect );
+        }
     }
 }
 
+void EditView::Invalidate()
+{
+    const Rectangle& rInvRect = GetInvalidateRect();
+    pImpEditView->GetWindow()->Invalidate( rInvRect );
+    InvalidateOtherViewWindows( rInvRect );
+}
+
 void EditView::SetReadOnly( bool bReadOnly )
 {
     pImpEditView->bReadOnly = bReadOnly;
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 8e3b093..a4bea11 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -1150,8 +1150,10 @@ Pair ImpEditView::Scroll( long ndX, long ndY, ScrollRangeCheck nRangeCheck )
         pOutWin->Scroll( nRealDiffX, nRealDiffY, aRect, ScrollFlags::Clip );
 
         if (comphelper::LibreOfficeKit::isActive())
+        {
             // Need to invalidate the window, otherwise no tile will be re-painted.
-            pOutWin->Invalidate();
+            pEditView->Invalidate();
+        }
 
         pOutWin->Update();
         pCrsr->SetPos( pCrsr->GetPos() + Point( nRealDiffX, nRealDiffY ) );
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 908bf9f..9bfaa3f 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -292,13 +292,7 @@ void ImpEditEngine::UpdateViews( EditView* pCurView )
             // convert to window coordinates ....
             aClipRect = pView->pImpEditView->GetWindowPos( aClipRect );
             pView->GetWindow()->Invalidate( aClipRect );
-
-            EditView::OutWindowSet& rOutWindowSet = pView->GetOtherViewWindows();
-            for (auto pWin: rOutWindowSet)
-            {
-                if (pWin)
-                    pWin->Invalidate(aClipRect);
-            }
+            pView->InvalidateOtherViewWindows( aClipRect );
         }
     }
 
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 5a3a6a4..d9ed5d1 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -115,6 +115,8 @@ public:
     bool            RemoveOtherViewWindow( vcl::Window* pWin );
 
     void            Paint( const Rectangle& rRect, OutputDevice* pTargetDevice = nullptr );
+    Rectangle       GetInvalidateRect() const;
+    void            InvalidateOtherViewWindows( const Rectangle& rInvRect );
     void            Invalidate();
     Pair            Scroll( long nHorzScroll, long nVertScroll, ScrollRangeCheck nRangeCheck = ScrollRangeCheck::NoNegative );
 
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 4de89b7..43aaf7d 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -489,8 +489,8 @@ public:
     void            InvalidateAttribs();
 
     void            OnLibreOfficeKitTabChanged();
-    void            AddEditViewToOtherView(SfxViewShell* pViewShell, ScSplitPos eWhich);
-    void            RemoveEditViewFromOtherView(SfxViewShell* pViewShell, ScSplitPos eWhich);
+    void            AddWindowToForeignEditView(SfxViewShell* pViewShell, ScSplitPos eWhich);
+    void            RemoveWindowFromForeignEditView(SfxViewShell* pViewShell, ScSplitPos eWhich);
     void            MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW nRow );
     void            KillEditView( bool bNoPaint );
     void            UpdateEditView();
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index f3b56e2..14fbad9 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1915,12 +1915,12 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa
     }
 }
 
-void ScTabView::AddEditViewToOtherView(SfxViewShell* pViewShell, ScSplitPos eWhich)
+void ScTabView::AddWindowToForeignEditView(SfxViewShell* pViewShell, ScSplitPos eWhich)
 {
     aExtraEditViewManager.Add(pViewShell, eWhich);
 }
 
-void ScTabView::RemoveEditViewFromOtherView(SfxViewShell* pViewShell, ScSplitPos eWhich)
+void ScTabView::RemoveWindowFromForeignEditView(SfxViewShell* pViewShell, ScSplitPos eWhich)
 {
     aExtraEditViewManager.Remove(pViewShell, eWhich);
 }
@@ -1942,7 +1942,7 @@ void ScTabView::OnLibreOfficeKitTabChanged()
                         {
                             if (rOtherViewData.HasEditView( (ScSplitPos)(i)))
                             {
-                                pThisViewShell->AddEditViewToOtherView(pOtherViewShell, (ScSplitPos)(i));
+                                pThisViewShell->AddWindowToForeignEditView(pOtherViewShell, (ScSplitPos)(i));
                             }
                         }
                     }
@@ -1952,7 +1952,7 @@ void ScTabView::OnLibreOfficeKitTabChanged()
                         {
                             if (rOtherViewData.HasEditView( (ScSplitPos)(i)))
                             {
-                                pThisViewShell->RemoveEditViewFromOtherView(pOtherViewShell, (ScSplitPos)(i));
+                                pThisViewShell->RemoveWindowFromForeignEditView(pOtherViewShell, (ScSplitPos)(i));
                             }
                         }
                     }
@@ -2044,6 +2044,7 @@ void ScTabView::KillEditView( bool bNoPaint )
     SCROW nRow2 = aViewData.GetEditEndRow();
     bool bPaint[4];
     bool bNotifyAcc = false;
+    Rectangle aRectangle[4];
 
     bool bExtended = nRow1 != nRow2;                    // column is painted to the end anyway
 
@@ -2054,7 +2055,12 @@ void ScTabView::KillEditView( bool bNoPaint )
     {
         bPaint[i] = aViewData.HasEditView( (ScSplitPos) i );
         if (bPaint[i])
+        {
             bNotifyAcc = true;
+
+            EditView* pView = aViewData.GetEditView( (ScSplitPos) i );
+            aRectangle[i] = pView->GetInvalidateRect();
+        }
     }
 
     // #108931#; notify accessibility before all things happen
@@ -2070,8 +2076,26 @@ void ScTabView::KillEditView( bool bNoPaint )
 
                 pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode());
 
+                if (comphelper::LibreOfficeKit::isActive())
+                {
+                    const Rectangle& rInvRect = aRectangle[i];
+                    pGridWin[i]->Invalidate(rInvRect);
+
+                    // invalidate other views
+                    auto lInvalidateWindows =
+                            [&rInvRect] (ScTabView* pTabView)
+                            {
+                                for (ScGridWindow* pWin: pTabView->pGridWin)
+                                {
+                                    if (pWin)
+                                        pWin->Invalidate(rInvRect);
+                                }
+                            };
+
+                    SfxLokHelper::forEachOtherView(GetViewData().GetViewShell(), lInvalidateWindows);
+                }
                 // #i73567# the cell still has to be repainted
-                if (bExtended || ( bAtCursor && !bNoPaint ))
+                else if (bExtended || ( bAtCursor && !bNoPaint ))
                 {
                     pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2 );
                     pGridWin[i]->UpdateSelectionOverlay();
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index 710b6a7..83d9094 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -164,18 +164,18 @@ ScTabView::~ScTabView()
     {
         ScTabViewShell* pThisViewShell = GetViewData().GetViewShell();
 
-        auto lRemoveEditView =
+        auto lRemoveWindows =
                 [pThisViewShell] (ScTabViewShell* pOtherViewShell)
                 {
                     ScViewData& rOtherViewData = pOtherViewShell->GetViewData();
                     for (int k = 0; k < 4; ++k)
                     {
                         if (rOtherViewData.HasEditView((ScSplitPos)(k)))
-                            pThisViewShell->RemoveEditViewFromOtherView(pOtherViewShell, (ScSplitPos)(k));
+                            pThisViewShell->RemoveWindowFromForeignEditView(pOtherViewShell, (ScSplitPos)(k));
                     }
                 };
 
-        SfxLokHelper::forEachOtherView(pThisViewShell, lRemoveEditView);
+        SfxLokHelper::forEachOtherView(pThisViewShell, lRemoveWindows);
     }
 
     aViewData.KillEditView();           // solange GridWin's noch existieren
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index e45a1d5..b14d846 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -77,15 +77,15 @@ using namespace com::sun::star;
 
 namespace {
 
-void lcl_LOKRemoveEditView(ScTabViewShell* pTabViewShell, ScSplitPos eWhich)
+void lcl_LOKRemoveWindow(ScTabViewShell* pTabViewShell, ScSplitPos eWhich)
 {
     if (comphelper::LibreOfficeKit::isActive())
     {
-        auto lRemoveEditView =
+        auto lRemoveWindows =
                 [pTabViewShell, eWhich] (ScTabViewShell* pOtherViewShell)
-                { pOtherViewShell->RemoveEditViewFromOtherView(pTabViewShell, eWhich); };
+                { pOtherViewShell->RemoveWindowFromForeignEditView(pTabViewShell, eWhich); };
 
-        SfxLokHelper::forEachOtherView(pTabViewShell, lRemoveEditView);
+        SfxLokHelper::forEachOtherView(pTabViewShell, lRemoveWindows);
     }
 }
 
@@ -961,13 +961,13 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
         }
         else
         {
-            lcl_LOKRemoveEditView(GetViewShell(), eWhich);
+            lcl_LOKRemoveWindow(GetViewShell(), eWhich);
             pEditView[eWhich]->SetEditEngine(pNewEngine);
         }
 
         if (pEditView[eWhich]->GetWindow() != pWin)
         {
-            lcl_LOKRemoveEditView(GetViewShell(), eWhich);
+            lcl_LOKRemoveWindow(GetViewShell(), eWhich);
             pEditView[eWhich]->SetWindow(pWin);
             OSL_FAIL("EditView Window has changed");
         }
@@ -982,6 +982,23 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
         }
     }
 
+    // add windows from other views
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        ScTabViewShell* pThisViewShell = GetViewShell();
+        SCTAB nThisTabNo = GetTabNo();
+        auto lAddWindows =
+                [pThisViewShell, nThisTabNo, eWhich] (ScTabViewShell* pOtherViewShell)
+                {
+                    ScViewData& rOtherViewData = pOtherViewShell->GetViewData();
+                    SCTAB nOtherTabNo = rOtherViewData.GetTabNo();
+                    if (nThisTabNo == nOtherTabNo)
+                        pOtherViewShell->AddWindowToForeignEditView(pThisViewShell, eWhich);
+                };
+
+        SfxLokHelper::forEachOtherView(pThisViewShell, lAddWindows);
+    }
+
     //  bei IdleFormat wird manchmal ein Cursor gemalt, wenn die View schon weg ist (23576)
 
     EEControlBits nEC = pNewEngine->GetControlWord();
@@ -1137,23 +1154,6 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
 
     pEditView[eWhich]->Invalidate();            //  needed?
     //  needed, wenn position changed
-
-    if (comphelper::LibreOfficeKit::isActive())
-    {
-        ScTabViewShell* pThisViewShell = GetViewShell();
-        SCTAB nThisTabNo = GetTabNo();
-        auto lAddEditView =
-                [pThisViewShell, nThisTabNo, eWhich] (ScTabViewShell* pOtherViewShell)
-                {
-                    ScViewData& rOtherViewData = pOtherViewShell->GetViewData();
-                    SCTAB nOtherTabNo = rOtherViewData.GetTabNo();
-                    if (nThisTabNo == nOtherTabNo)
-                        pOtherViewShell->AddEditViewToOtherView(pThisViewShell, eWhich);
-                };
-
-        SfxLokHelper::forEachOtherView(pThisViewShell, lAddEditView);
-    }
-
 }
 
 IMPL_LINK_TYPED( ScViewData, EditEngineHdl, EditStatus&, rStatus, void )
@@ -1352,6 +1352,9 @@ void ScViewData::EditGrowX()
         else if ( !bAsianVertical && !bGrowToLeft && !bGrowCentered )
             aArea.Left() = nOldRight;
         pWin->Invalidate(aArea);
+
+        // invalidate other views
+        pCurView->InvalidateOtherViewWindows(aArea);
     }
 }
 
@@ -1432,6 +1435,9 @@ void ScViewData::EditGrowY( bool bInitial )
 
         aArea.Top() = nOldBottom;
         pWin->Invalidate(aArea);
+
+        // invalidate other views
+        pCurView->InvalidateOtherViewWindows(aArea);
     }
 }
 
@@ -1443,7 +1449,7 @@ void ScViewData::ResetEditView()
         {
             if (bEditActive[i])
             {
-                lcl_LOKRemoveEditView(GetViewShell(), (ScSplitPos)(i));
+                lcl_LOKRemoveWindow(GetViewShell(), (ScSplitPos)(i));
                 pEngine = pEditView[i]->GetEditEngine();
                 pEngine->RemoveView(pEditView[i]);
                 pEditView[i]->SetOutputArea( Rectangle() );


More information about the Libreoffice-commits mailing list