sc/source/ui/inc/viewfunc.hxx  |    3 ++-
 sc/source/ui/view/formatsh.cxx |    9 +++++----
 sc/source/ui/view/viewfunc.cxx |   10 +++++++---
 3 files changed, 14 insertions(+), 8 deletions(-)

New commits:
commit 950cbe4ccf2a95981e40f2a9589b22a403784557
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Mar 17 19:40:03 2025 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Mar 17 21:45:00 2025 +0100

    tdf#144151: do not adjust row height for font / style preview
    
    In commit bcc51fb2ebdf77a1cc089857775fd742085b45b6 (add support for
    in-place style preview, 2013-08-29), a feature of live preview was
    introduced, to see the effect of not-yet-applied font currently
    hovered in the font list. While doing this, it could recalculate
    row heights (e.g., for auto-wrapped cells).
    
    For large selection, this recalculation may take several seconds.
    Also, this may mark document modified, and also result in following
    UI operations slowdown.
    
    This change prevents this recalculation for the preview. The cost
    is that now the preview could be not 100% correct, but hopefully
    this is much less problematic, than the problems it resolves.
    SID_ATTR_CHAR_FONTHEIGHT (.uno:CharFontName) does the height adjust
    anyway.
    
    Change-Id: If347aa7222cb700d8969dd546727ae437f787d14
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183034
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index fed6b7fcf592..e46762e2d992 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -339,7 +339,8 @@ public:
                                     SCROW nEndRow , SCCOL nEndCol ,
                                     
std::vector<std::unique_ptr<ScDataFormFragment>>& rEdits,
                                     sal_uInt16 aColLength);
-    void            UpdateSelectionArea( const ScMarkData& rSel, 
ScPatternAttr* pAttr = nullptr );
+    void UpdateSelectionArea(const ScMarkData& rSel, ScPatternAttr* pAttr = 
nullptr,
+                             bool adjustHeight = true);
 
     void            OnLOKInsertDeleteColumn(SCCOL nStartCol, tools::Long 
nOffset);
     void            OnLOKInsertDeleteRow(SCROW nStartRow, tools::Long nOffset);
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index e8f1baf7e745..e0bf6c0aa445 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -187,7 +187,7 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
                 rNewSet.Put( aItemSet, false );
 
                 rDoc.ApplySelectionPattern( aNewAttrs, 
rDoc.GetPreviewSelection() );
-                pTabViewShell->UpdateSelectionArea( aFuncMark, &aAttr );
+                pTabViewShell->UpdateSelectionArea(aFuncMark, &aAttr, 
/*adjustHeight*/ false);
             }
         }
         else
@@ -209,7 +209,7 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
                 SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
                 rNewSet.Put( aItemSet, false );
                 rDoc.ApplySelectionPattern( aNewAttrs, aPreviewMark );
-                pTabViewShell->UpdateSelectionArea( aPreviewMark, &aAttr );
+                pTabViewShell->UpdateSelectionArea(aPreviewMark, &aAttr, 
/*adjustHeight*/ false);
             }
         }
     }
@@ -936,7 +936,8 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
             case SID_ATTR_CHAR_ENDPREVIEW_FONT:
             {
                 rDoc.SetPreviewFont(nullptr);
-                pTabViewShell->UpdateSelectionArea( rDoc.GetPreviewSelection() 
);
+                pTabViewShell->UpdateSelectionArea(rDoc.GetPreviewSelection(), 
nullptr,
+                                                   /*adjustHeight*/ false);
                 break;
             }
             case SID_ATTR_CHAR_COLOR:
@@ -1017,7 +1018,7 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
                     aFuncMark.SetMarkArea( aRange );
                 }
                 rDoc.SetPreviewSelection( aFuncMark );
-                pTabViewShell->UpdateSelectionArea( aFuncMark );
+                pTabViewShell->UpdateSelectionArea(aFuncMark, nullptr, 
/*adjustHeight*/ false);
                 break;
             }
             case SID_ATTR_CHAR_OVERLINE:
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 1d766741cd99..fd4099ff17d5 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -3246,7 +3246,8 @@ void ScViewFunc::InsertNameList()
         pDocSh->UpdateOle(GetViewData());
 }
 
-void ScViewFunc::UpdateSelectionArea( const ScMarkData& rSel, ScPatternAttr* 
pAttr  )
+void ScViewFunc::UpdateSelectionArea(const ScMarkData& rSel, ScPatternAttr* 
pAttr,
+                                     bool adjustHeight)
 {
     ScDocShell* pDocShell = GetViewData().GetDocShell();
     ScRange aMarkRange;
@@ -3280,8 +3281,11 @@ void ScViewFunc::UpdateSelectionArea( const ScMarkData& 
rSel, ScPatternAttr* pAt
     pDocShell->PostPaint( nStartCol, nStartRow, nStartTab,
         nEndCol,   nEndRow,   nEndTab,
         PaintPartFlags::Grid, nExtFlags | SC_PF_TESTMERGE );
-    ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
-    pTabViewShell->AdjustBlockHeight(false, const_cast<ScMarkData*>(&rSel));
+    if (adjustHeight)
+    {
+        ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
+        pTabViewShell->AdjustBlockHeight(false, 
const_cast<ScMarkData*>(&rSel));
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to