sc/source/ui/inc/viewfunc.hxx  |    2 +-
 sc/source/ui/view/viewfunc.cxx |    5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

New commits:
commit 30a104c06de0edce56000d1b638a15e8183bea97
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Oct 24 15:23:05 2025 +0500
Commit:     Miklos Vajna <[email protected]>
CommitDate: Thu Oct 30 10:25:10 2025 +0100

    cool#13279: Pass ScMarkData to ScViewFunc::GetOptimalColWidth
    
    GetOptimalColWidth is only used from SetWidthOrHeight. Mark data
    is used both in SetWidthOrHeight itself, to iterate marked tabs;
    and in ScColumn::GetOptimalColWidth, to limit to marked area. As
    the mark data can be passed to SetWidthOrHeight directly, it is
    wrong to use potentially different data at different stages.
    
    Change-Id: I04ac571d7608b37f97e78f61f62e83ee18faf8b2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192953
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index aa101cbed3e2..55249ad75ea8 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -409,7 +409,7 @@ private:
                                         SCCOL nPosX, SCROW nPosY,
                                         bool bAllowDialogs, 
TransferableDataHelper& rDataHelper );
 
-    sal_uInt16      GetOptimalColWidth( SCCOL nCol, SCTAB nTab, bool bFormula 
);
+    sal_uInt16 GetOptimalColWidth(SCCOL nCol, SCTAB nTab, bool bFormula, const 
ScMarkData& rMark);
 
     void            StartFormatArea();
 
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 730e58c2ca42..ae1863d8866d 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -332,11 +332,10 @@ void 
ScViewData::setupSizeDeviceProviderForColWidth(ScSizeDeviceProvider& rProv,
     }
 }
 
-sal_uInt16 ScViewFunc::GetOptimalColWidth( SCCOL nCol, SCTAB nTab, bool 
bFormula )
+sal_uInt16 ScViewFunc::GetOptimalColWidth(SCCOL nCol, SCTAB nTab, bool 
bFormula, const ScMarkData& rMark)
 {
     ScDocShell* pDocSh = GetViewData().GetDocShell();
     ScDocument& rDoc = pDocSh->GetDocument();
-    ScMarkData& rMark = GetViewData().GetMarkData();
 
     ScSizeDeviceProvider aProv(pDocSh);
 
@@ -2573,7 +2572,7 @@ void ScViewFunc::SetWidthOrHeight(
                         sal_uInt16 nThisSize = nSizeTwips;
 
                         if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
-                            nThisSize = nSizeTwips + GetOptimalColWidth( nCol, 
nTab, bFormula );
+                            nThisSize = nSizeTwips + GetOptimalColWidth(nCol, 
nTab, bFormula, aMarkData);
                         if ( nThisSize )
                             rDoc.SetColWidth( nCol, nTab, nThisSize );
 

Reply via email to