[Libreoffice-commits] core.git: sc/inc sc/Library_sc.mk sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Sat Feb 1 17:48:36 PST 2014


 sc/Library_sc.mk                         |    1 
 sc/inc/column.hxx                        |    6 +-
 sc/inc/document.hxx                      |   16 +++---
 sc/inc/rowheightcontext.hxx              |   57 ++++++++++++++++++++++++
 sc/inc/table.hxx                         |   21 +++------
 sc/source/core/data/column2.cxx          |   12 ++---
 sc/source/core/data/dociter.cxx          |    9 ++-
 sc/source/core/data/document.cxx         |   23 +++------
 sc/source/core/data/rowheightcontext.cxx |   72 +++++++++++++++++++++++++++++++
 sc/source/core/data/table1.cxx           |   43 ++++++------------
 sc/source/core/data/table2.cxx           |    4 +
 sc/source/filter/rtf/eeimpars.cxx        |    8 ++-
 sc/source/ui/docshell/docfunc.cxx        |   10 ++--
 sc/source/ui/docshell/docsh5.cxx         |    9 ++-
 sc/source/ui/undo/undobase.cxx           |   12 ++---
 sc/source/ui/undo/undoblk.cxx            |   10 ++--
 sc/source/ui/undo/undoblk3.cxx           |    8 ++-
 sc/source/ui/view/viewfun2.cxx           |   11 ++--
 sc/source/ui/view/viewfunc.cxx           |    8 ++-
 19 files changed, 230 insertions(+), 110 deletions(-)

New commits:
commit f74c0a42b0e176771e15458b1bdb85c0a2dc99db
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Sat Feb 1 20:51:29 2014 -0500

    Add RowHeightContext to stuff all parameters for SetOptimalHeights().
    
    To help reduce the number of function arguments.
    
    Change-Id: Ic29fff38f6cd844bdaac8ac4b440dfcaba55df61

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index dcced7f..397ca22 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -169,6 +169,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
     sc/source/core/data/poolhelp \
     sc/source/core/data/postit \
     sc/source/core/data/refupdatecontext \
+    sc/source/core/data/rowheightcontext \
     sc/source/core/data/segmenttree \
     sc/source/core/data/sheetevents \
     sc/source/core/data/simpleformulacalc \
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 7fefa04..835daa8 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -58,6 +58,7 @@ struct NoteEntry;
 class DocumentStreamAccess;
 class CellValues;
 struct RowSpan;
+class RowHeightContext;
 
 }
 
@@ -437,9 +438,8 @@ public:
         bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const;
 
     void GetOptimalHeight(
-        SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHeight, OutputDevice* pDev,
-        double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY,
-        bool bShrink, sal_uInt16 nMinHeight, SCROW nMinStart);
+        sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHeight,
+        sal_uInt16 nMinHeight, SCROW nMinStart );
 
                 /// Including current, may return -1
     SCsROW      GetNextUnprotected( SCROW nRow, bool bUp ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index b241859..2d84ecd 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -72,6 +72,7 @@ struct FormulaGroupContext;
 class DocumentStreamAccess;
 class DocumentLinkManager;
 class CellValues;
+class RowHeightContext;
 
 }
 
@@ -1480,15 +1481,12 @@ public:
                                         bool bFormula,
                                         const ScMarkData* pMarkData = NULL,
                                         const ScColWidthParam* pParam = NULL );
-    SC_DLLPUBLIC bool           SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_uInt16 nExtra,
-                                        OutputDevice* pDev,
-                                        double nPPTX, double nPPTY,
-                                        const Fraction& rZoomX, const Fraction& rZoomY,
-                                        bool bShrink );
-    void            UpdateAllRowHeights( OutputDevice* pDev,
-                                        double nPPTX, double nPPTY,
-                                        const Fraction& rZoomX, const Fraction& rZoomY,
-                                        const ScMarkData* pTabMark = NULL );
+
+    SC_DLLPUBLIC bool SetOptimalHeight(
+        sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab );
+
+    void UpdateAllRowHeights( sc::RowHeightContext& rCxt, const ScMarkData* pTabMark = NULL );
+
     long            GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
                                     OutputDevice* pDev,
                                     double nPPTX, double nPPTY,
diff --git a/sc/inc/rowheightcontext.hxx b/sc/inc/rowheightcontext.hxx
new file mode 100644
index 0000000..7985df3
--- /dev/null
+++ b/sc/inc/rowheightcontext.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_ROWHEIGHTCONTEXT_HXX
+#define SC_ROWHEIGHTCONTEXT_HXX
+
+#include <scdllapi.h>
+
+#include <tools/fract.hxx>
+
+class OutputDevice;
+
+namespace sc {
+
+class SC_DLLPUBLIC RowHeightContext
+{
+    double mfPPTX;
+    double mfPPTY;
+    Fraction maZoomX;
+    Fraction maZoomY;
+    OutputDevice* mpOutDev;
+
+    sal_uInt16 mnExtraHeight;
+    bool mbForceAutoSize; /// whether to set height to optimal even when the manual height flag is set.
+
+public:
+    RowHeightContext(
+        double fPPTX, double fPPTY, const Fraction& rZoomX, const Fraction& rZoomY,
+        OutputDevice* pOutDev );
+
+    ~RowHeightContext();
+
+    double getPPTX() const;
+    double getPPTY() const;
+    const Fraction& getZoomX() const;
+    const Fraction& getZoomY() const;
+
+    OutputDevice* getOutputDevice();
+
+    void setExtraHeight( sal_uInt16 nH );
+    sal_uInt16 getExtraHeight() const;
+
+    void setForceAutoSize( bool b );
+    bool isForceAutoSize() const;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 2621d32..548c6cc 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -69,6 +69,7 @@ struct RefUpdateMoveTabContext;
 struct NoteEntry;
 class DocumentStreamAccess;
 class CellValues;
+class RowHeightContext;
 
 }
 
@@ -661,19 +662,13 @@ public:
                                     const Fraction& rZoomX, const Fraction& rZoomY,
                                     bool bFormula, const ScMarkData* pMarkData,
                                     const ScColWidthParam* pParam );
-    bool        SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtra,
-                                    OutputDevice* pDev,
-                                    double nPPTX, double nPPTY,
-                                    const Fraction& rZoomX, const Fraction& rZoomY,
-                                    bool bForce,
-                                    ScProgress* pOuterProgress = NULL, sal_uLong nProgressStart = 0 );
-
-    void        SetOptimalHeightOnly(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtra,
-                                     OutputDevice* pDev,
-                                     double nPPTX, double nPPTY,
-                                     const Fraction& rZoomX, const Fraction& rZoomY,
-                                     bool bForce,
-                                     ScProgress* pOuterProgress = NULL, sal_uLong nProgressStart = 0 );
+    bool SetOptimalHeight(
+        sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
+        ScProgress* pOuterProgress = NULL, sal_uLong nProgressStart = 0 );
+
+    void SetOptimalHeightOnly(
+        sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
+        ScProgress* pOuterProgress = NULL, sal_uLong nProgressStart = 0 );
 
     long        GetNeededSize( SCCOL nCol, SCROW nRow,
                                     OutputDevice* pDev,
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index e1f832d..510ad17 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -43,6 +43,7 @@
 #include "listenercontext.hxx"
 #include "mtvcellfunc.hxx"
 #include "scmatrix.hxx"
+#include <rowheightcontext.hxx>
 
 #include <math.h>
 
@@ -758,9 +759,8 @@ static sal_uInt16 lcl_GetAttribHeight( const ScPatternAttr& rPattern, sal_uInt16
 //  (is only evaluated with bStdAllowed)
 
 void ScColumn::GetOptimalHeight(
-    SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHeight, OutputDevice* pDev,
-    double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY,
-    bool bShrink, sal_uInt16 nMinHeight, SCROW nMinStart)
+    sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHeight,
+    sal_uInt16 nMinHeight, SCROW nMinStart )
 {
     ScAttrIterator aIter( pAttrArray, nStartRow, nEndRow );
 
@@ -917,12 +917,12 @@ void ScColumn::GetOptimalHeight(
                     {
                         //  only calculate the cell height when it's used later (#37928#)
 
-                        if ( bShrink || !(pDocument->GetRowFlags(nRow, nTab) & CR_MANUALSIZE) )
+                        if (rCxt.isForceAutoSize() || !(pDocument->GetRowFlags(nRow, nTab) & CR_MANUALSIZE) )
                         {
                             aOptions.pPattern = pPattern;
                             sal_uInt16 nHeight = (sal_uInt16)
-                                    ( GetNeededSize( nRow, pDev, nPPTX, nPPTY,
-                                                        rZoomX, rZoomY, false, aOptions ) / nPPTY );
+                                    ( GetNeededSize( nRow, rCxt.getOutputDevice(), rCxt.getPPTX(), rCxt.getPPTY(),
+                                                        rCxt.getZoomX(), rCxt.getZoomY(), false, aOptions ) / rCxt.getPPTY() );
                             if (nHeight > pHeight[nRow-nStartRow])
                                 pHeight[nRow-nStartRow] = nHeight;
                         }
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 8fa2c87..188a3fc 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -38,6 +38,7 @@
 #include "editutil.hxx"
 #include "cellvalue.hxx"
 #include "scmatrix.hxx"
+#include <rowheightcontext.hxx>
 
 #include "tools/fract.hxx"
 #include "editeng/editobj.hxx"
@@ -2440,6 +2441,7 @@ void ScDocRowHeightUpdater::update()
     Fraction aZoom(1, 1);
     itr = mpTabRangesArray->begin();
     sal_uInt32 nProgressStart = 0;
+    sc::RowHeightContext aCxt(mfPPTX, mfPPTY, aZoom, aZoom, mpOutDev);
     for (; itr != itrEnd; ++itr)
     {
         SCTAB nTab = itr->mnTab;
@@ -2454,7 +2456,7 @@ void ScDocRowHeightUpdater::update()
                 continue;
 
             mrDoc.maTabs[nTab]->SetOptimalHeight(
-                aData.mnRow1, aData.mnRow2, 0, mpOutDev, mfPPTX, mfPPTY, aZoom, aZoom, false, &aProgress, nProgressStart);
+                aCxt, aData.mnRow1, aData.mnRow2, &aProgress, nProgressStart);
 
             nProgressStart += aData.mnRow2 - aData.mnRow1 + 1;
         }
@@ -2475,15 +2477,14 @@ void ScDocRowHeightUpdater::updateAll()
     ScProgress aProgress(mrDoc.GetDocumentShell(), ScGlobal::GetRscString(STR_PROGRESS_HEIGHTING), nCellCount);
 
     Fraction aZoom(1, 1);
+    sc::RowHeightContext aCxt(mfPPTX, mfPPTY, aZoom, aZoom, mpOutDev);
     sal_uLong nProgressStart = 0;
     for (SCTAB nTab = 0; nTab < mrDoc.GetTableCount(); ++nTab)
     {
         if (!ValidTab(nTab) || !mrDoc.maTabs[nTab])
             continue;
 
-        mrDoc.maTabs[nTab]->SetOptimalHeight(
-            0, MAXROW, 0, mpOutDev, mfPPTX, mfPPTY, aZoom, aZoom, false, &aProgress, nProgressStart);
-
+        mrDoc.maTabs[nTab]->SetOptimalHeight(aCxt, 0, MAXROW, &aProgress, nProgressStart);
         nProgressStart += mrDoc.maTabs[nTab]->GetWeightedCount();
     }
 }
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 94167a5..432888b 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3986,23 +3986,17 @@ long ScDocument::GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
 }
 
 
-bool ScDocument::SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_uInt16 nExtra,
-                                    OutputDevice* pDev,
-                                    double nPPTX, double nPPTY,
-                                    const Fraction& rZoomX, const Fraction& rZoomY,
-                                    bool bShrink )
+bool ScDocument::SetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab )
 {
-//! MarkToMulti();
-    if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
-        return maTabs[nTab]->SetOptimalHeight( nStartRow, nEndRow, nExtra,
-                                                pDev, nPPTX, nPPTY, rZoomX, rZoomY, bShrink );
-    OSL_FAIL("wrong table number");
-    return false;
+    ScTable* pTab = FetchTable(nTab);
+    if (!pTab)
+        return false;
+
+    return pTab->SetOptimalHeight(rCxt, nStartRow, nEndRow);
 }
 
 
-void ScDocument::UpdateAllRowHeights( OutputDevice* pDev, double nPPTX, double nPPTY,
-                                    const Fraction& rZoomX, const Fraction& rZoomY, const ScMarkData* pTabMark )
+void ScDocument::UpdateAllRowHeights( sc::RowHeightContext& rCxt, const ScMarkData* pTabMark )
 {
     // one progress across all (selected) sheets
 
@@ -4017,8 +4011,7 @@ void ScDocument::UpdateAllRowHeights( OutputDevice* pDev, double nPPTX, double n
     for ( SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++ )
         if ( maTabs[nTab] && ( !pTabMark || pTabMark->GetTableSelect(nTab) ) )
         {
-            maTabs[nTab]->SetOptimalHeightOnly( 0, MAXROW, 0,
-                        pDev, nPPTX, nPPTY, rZoomX, rZoomY, false, &aProgress, nProgressStart );
+            maTabs[nTab]->SetOptimalHeightOnly(rCxt, 0, MAXROW, &aProgress, nProgressStart);
             maTabs[nTab]->SetDrawPageSize(true, true);
             nProgressStart += maTabs[nTab]->GetWeightedCount();
         }
diff --git a/sc/source/core/data/rowheightcontext.cxx b/sc/source/core/data/rowheightcontext.cxx
new file mode 100644
index 0000000..9fa96d1
--- /dev/null
+++ b/sc/source/core/data/rowheightcontext.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <rowheightcontext.hxx>
+
+namespace sc {
+
+RowHeightContext::RowHeightContext(
+    double fPPTX, double fPPTY, const Fraction& rZoomX, const Fraction& rZoomY,
+    OutputDevice* pOutDev ) :
+    mfPPTX(fPPTX), mfPPTY(fPPTY),
+    maZoomX(rZoomX), maZoomY(rZoomY),
+    mpOutDev(pOutDev),
+    mnExtraHeight(0),
+    mbForceAutoSize(false) {}
+
+RowHeightContext::~RowHeightContext() {}
+
+double RowHeightContext::getPPTX() const
+{
+    return mfPPTX;
+}
+
+double RowHeightContext::getPPTY() const
+{
+    return mfPPTY;
+}
+
+const Fraction& RowHeightContext::getZoomX() const
+{
+    return maZoomX;
+}
+
+const Fraction& RowHeightContext::getZoomY() const
+{
+    return maZoomY;
+}
+
+OutputDevice* RowHeightContext::getOutputDevice()
+{
+    return mpOutDev;
+}
+
+void RowHeightContext::setExtraHeight( sal_uInt16 nH )
+{
+    mnExtraHeight = nH;
+}
+
+sal_uInt16 RowHeightContext::getExtraHeight() const
+{
+    return mnExtraHeight;
+}
+
+void RowHeightContext::setForceAutoSize( bool b )
+{
+    mbForceAutoSize = b;
+}
+
+bool RowHeightContext::isForceAutoSize() const
+{
+    return mbForceAutoSize;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 37417ac..6d60bde 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -48,6 +48,7 @@
 #include "cellvalue.hxx"
 #include "scmatrix.hxx"
 #include "refupdatecontext.hxx"
+#include <rowheightcontext.hxx>
 
 #include "formula/vectortoken.hxx"
 
@@ -79,9 +80,8 @@ ScProgress* GetProgressBar(
 }
 
 void GetOptimalHeightsInColumn(
-    ScColumn* pCol, SCROW nStartRow, SCROW nEndRow, vector<sal_uInt16>& aHeights,
-    OutputDevice* pDev, double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY, bool bForce,
-    ScProgress* pProgress, sal_uInt32 nProgressStart)
+    sc::RowHeightContext& rCxt, ScColumn* pCol, SCROW nStartRow, SCROW nEndRow,
+    vector<sal_uInt16>& aHeights, ScProgress* pProgress, sal_uInt32 nProgressStart )
 {
     SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
 
@@ -89,8 +89,7 @@ void GetOptimalHeightsInColumn(
     //  (mit der letzten Spalte in der Hoffnung, dass die am ehesten noch auf
     //   Standard formatiert ist)
 
-    pCol[MAXCOL].GetOptimalHeight(
-            nStartRow, nEndRow, &aHeights[0], pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce, 0, 0 );
+    pCol[MAXCOL].GetOptimalHeight(rCxt, nStartRow, nEndRow, &aHeights[0], 0, 0);
 
     //  daraus Standardhoehe suchen, die im unteren Bereich gilt
 
@@ -103,9 +102,7 @@ void GetOptimalHeightsInColumn(
     sal_uLong nWeightedCount = 0;
     for (SCCOL nCol=0; nCol<MAXCOL; nCol++)     // MAXCOL schon oben
     {
-        pCol[nCol].GetOptimalHeight(
-            nStartRow, nEndRow, &aHeights[0], pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce,
-            nMinHeight, nMinStart );
+        pCol[nCol].GetOptimalHeight(rCxt, nStartRow, nEndRow, &aHeights[0], nMinHeight, nMinStart);
 
         if (pProgress)
         {
@@ -455,11 +452,9 @@ long ScTable::GetNeededSize( SCCOL nCol, SCROW nRow,
         ( nRow, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bWidth, aOptions );
 }
 
-bool ScTable::SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtra,
-                                OutputDevice* pDev,
-                                double nPPTX, double nPPTY,
-                                const Fraction& rZoomX, const Fraction& rZoomY,
-                                bool bForce, ScProgress* pOuterProgress, sal_uLong nProgressStart )
+bool ScTable::SetOptimalHeight(
+    sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
+    ScProgress* pOuterProgress, sal_uLong nProgressStart )
 {
     OSL_ENSURE( nExtra==0 || bForce, "automatic OptimalHeight with Extra" );
 
@@ -474,13 +469,11 @@ bool ScTable::SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtr
 
     vector<sal_uInt16> aHeights(nCount, 0);
 
-    GetOptimalHeightsInColumn(
-        aCol, nStartRow, nEndRow, aHeights, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce,
-        pProgress, nProgressStart);
+    GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, aHeights, pProgress, nProgressStart);
 
-    SetRowHeightRangeFunc aFunc(this, nPPTX, nPPTY);
+    SetRowHeightRangeFunc aFunc(this, rCxt.getPPTX(), rCxt.getPPTY());
     bool bChanged = SetOptimalHeightsToRows(
-        aFunc, pRowFlags, nStartRow, nEndRow, nExtra, aHeights, bForce);
+        aFunc, pRowFlags, nStartRow, nEndRow, rCxt.getExtraHeight(), aHeights, rCxt.isForceAutoSize());
 
     if ( pProgress != pOuterProgress )
         delete pProgress;
@@ -488,11 +481,9 @@ bool ScTable::SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtr
     return bChanged;
 }
 
-void ScTable::SetOptimalHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtra,
-                                OutputDevice* pDev,
-                                double nPPTX, double nPPTY,
-                                const Fraction& rZoomX, const Fraction& rZoomY,
-                                bool bForce, ScProgress* pOuterProgress, sal_uLong nProgressStart )
+void ScTable::SetOptimalHeightOnly(
+    sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
+    ScProgress* pOuterProgress, sal_uLong nProgressStart )
 {
     OSL_ENSURE( nExtra==0 || bForce, "automatic OptimalHeight with Extra" );
 
@@ -505,13 +496,11 @@ void ScTable::SetOptimalHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 n
 
     vector<sal_uInt16> aHeights(nCount, 0);
 
-    GetOptimalHeightsInColumn(
-        aCol, nStartRow, nEndRow, aHeights, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce,
-        pProgress, nProgressStart);
+    GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, aHeights, pProgress, nProgressStart);
 
     SetRowHeightOnlyFunc aFunc(this);
     SetOptimalHeightsToRows(
-        aFunc, pRowFlags, nStartRow, nEndRow, nExtra, aHeights, bForce);
+        aFunc, pRowFlags, nStartRow, nEndRow, rCxt.getExtraHeight(), aHeights, rCxt.isForceAutoSize());
 
     if ( pProgress != pOuterProgress )
         delete pProgress;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index ce4871a..8a16e49 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -49,6 +49,7 @@
 #include "mtvcellfunc.hxx"
 #include "refupdatecontext.hxx"
 #include "scopetools.hxx"
+#include <rowheightcontext.hxx>
 
 #include "scitems.hxx"
 #include <editeng/boxitem.hxx>
@@ -2526,6 +2527,7 @@ void ScTable::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRem
     for (SCCOL i = 0; i <= MAXCOL; ++i)
         aCol[i].FindStyleSheet(pStyleSheet, aUsedRows, bRemoved);
 
+    sc::RowHeightContext aCxt(nPPTX, nPPTY, rZoomX, rZoomY, pDev);
     SCROW nRow = 0;
     while (nRow <= MAXROW)
     {
@@ -2536,7 +2538,7 @@ void ScTable::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRem
 
         SCROW nEndRow = aData.mnRow2;
         if (aData.mbValue)
-            SetOptimalHeight(nRow, nEndRow, 0, pDev, nPPTX, nPPTY, rZoomX, rZoomY, false);
+            SetOptimalHeight(aCxt, nRow, nEndRow);
 
         nRow = nEndRow + 1;
     }
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index 79c0662..8da6661 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -52,6 +52,7 @@
 #include "rangenam.hxx"
 #include "progress.hxx"
 #include "stringutil.hxx"
+#include <rowheightcontext.hxx>
 
 #include "globstr.hrc"
 
@@ -441,9 +442,10 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
         double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom / nOutputFactor;
         double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom;
         VirtualDevice aVirtDev;
-        mpDoc->SetOptimalHeight( 0, nEndRow, 0,
-            static_cast< sal_uInt16 >( ScGlobal::nLastRowHeightExtra ), &aVirtDev,
-            nPPTX, nPPTY, aZoom, aZoom, false );
+        sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoom, aZoom, &aVirtDev);
+        aCxt.setExtraHeight(ScGlobal::nLastRowHeightExtra);
+        mpDoc->SetOptimalHeight(aCxt, 0, nEndRow, 0);
+
         if ( !maRowHeights.empty() )
         {
             for ( SCROW nRow = nStartRow; nRow <= nEndRow; nRow++ )
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index f0ad671..9553a98 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -83,6 +83,7 @@
 #include "stringutil.hxx"
 #include "cellvalue.hxx"
 #include "tokenarray.hxx"
+#include <rowheightcontext.hxx>
 
 #include <memory>
 #include <basic/basmgr.hxx>
@@ -156,8 +157,8 @@ sal_Bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, sal_Bool bPaint )
     ScSizeDeviceProvider aProv( &rDocShell );
     Fraction aOne(1,1);
 
-    sal_Bool bChanged = pDoc->SetOptimalHeight( nStartRow, nEndRow, nTab, 0, aProv.GetDevice(),
-                                            aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, false );
+    sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, aProv.GetDevice());
+    bool bChanged = pDoc->SetOptimalHeight(aCxt, nStartRow, nEndRow, nTab);
 
     if ( bPaint && bChanged )
         rDocShell.PostPaint(ScRange(0, nStartRow, nTab, MAXCOL, MAXROW, nTab),
@@ -3472,8 +3473,9 @@ sal_Bool ScDocFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOL
 
                 ScSizeDeviceProvider aProv( &rDocShell );
                 Fraction aOne(1,1);
-                pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, aProv.GetDevice(),
-                                        aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, bAll );
+                sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, aProv.GetDevice());
+                aCxt.setForceAutoSize(bAll);
+                pDoc->SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab);
 
                 if (bAll)
                     pDoc->ShowRows( nStartNo, nEndNo, nTab, true );
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 6d64711..c933f2e 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -47,6 +47,7 @@
 #include "waitoff.hxx"
 #include "sizedev.hxx"
 #include "clipparam.hxx"
+#include <rowheightcontext.hxx>
 
 // defined in docfunc.cxx
 void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, const OUString& sModuleName, const OUString& sModuleSource );
@@ -372,8 +373,9 @@ sal_Bool ScDocShell::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab
 {
     ScSizeDeviceProvider aProv(this);
     Fraction aZoom(1,1);
-    sal_Bool bChange = aDocument.SetOptimalHeight( nStartRow,nEndRow, nTab, 0, aProv.GetDevice(),
-                                                aProv.GetPPTX(),aProv.GetPPTY(), aZoom,aZoom, false );
+    sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
+    bool bChange = aDocument.SetOptimalHeight(aCxt, nStartRow,nEndRow, nTab);
+
     if (bChange)
         PostPaint( 0,nStartRow,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID|PAINT_LEFT );
 
@@ -386,7 +388,8 @@ void ScDocShell::UpdateAllRowHeights( const ScMarkData* pTabMark )
 
     ScSizeDeviceProvider aProv(this);
     Fraction aZoom(1,1);
-    aDocument.UpdateAllRowHeights( aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, pTabMark );
+    sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
+    aDocument.UpdateAllRowHeights(aCxt, pTabMark);
 }
 
 void ScDocShell::UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore )
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index 16cabf6..57e24e8 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -31,6 +31,7 @@
 #include "subtotalparam.hxx"
 #include "bcaslot.hxx"
 #include "globstr.hrc"
+#include <rowheightcontext.hxx>
 
 // STATIC DATA -----------------------------------------------------------
 
@@ -234,9 +235,9 @@ sal_Bool ScBlockUndo::AdjustHeight()
         nPPTY = ScGlobal::nScreenPPTY;
     }
 
-    sal_Bool bRet = pDoc->SetOptimalHeight( aBlockRange.aStart.Row(), aBlockRange.aEnd.Row(),
-/*!*/                                   aBlockRange.aStart.Tab(), 0, &aVirtDev,
-                                        nPPTX, nPPTY, aZoomX, aZoomY, false );
+    sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, &aVirtDev);
+    bool bRet = pDoc->SetOptimalHeight(
+        aCxt, aBlockRange.aStart.Row(), aBlockRange.aEnd.Row(), aBlockRange.aStart.Tab());
 
     if (bRet)
         pDocShell->PostPaint( 0,      aBlockRange.aStart.Row(), aBlockRange.aStart.Tab(),
@@ -332,12 +333,11 @@ void ScMultiBlockUndo::AdjustHeight()
         nPPTY = ScGlobal::nScreenPPTY;
     }
 
+    sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, &aVirtDev);
     for (size_t i = 0, n = maBlockRanges.size(); i < n; ++i)
     {
         const ScRange& r = *maBlockRanges[i];
-        bool bRet = pDoc->SetOptimalHeight(
-            r.aStart.Row(), r.aEnd.Row(), r.aStart.Tab(), 0, &aVirtDev,
-            nPPTX, nPPTY, aZoomX, aZoomY, false);
+        bool bRet = pDoc->SetOptimalHeight(aCxt, r.aStart.Row(), r.aEnd.Row(), r.aStart.Tab());
 
         if (bRet)
             pDocShell->PostPaint(
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 13f529e..5b8643c 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -47,6 +47,7 @@
 #include "undoolk.hxx"
 #include "clipparam.hxx"
 #include "sc.hrc"
+#include <rowheightcontext.hxx>
 
 #include <set>
 
@@ -1179,12 +1180,11 @@ void ScUndoDragDrop::PaintArea( ScRange aRange, sal_uInt16 nExtFlags ) const
     {
         VirtualDevice aVirtDev;
         ScViewData* pViewData = pViewShell->GetViewData();
+        sc::RowHeightContext aCxt(
+            pViewData->GetPPTX(), pViewData->GetPPTY(), pViewData->GetZoomX(), pViewData->GetZoomY(),
+            &aVirtDev);
 
-        if ( pDoc->SetOptimalHeight( aRange.aStart.Row(), aRange.aEnd.Row(),
-                                     aRange.aStart.Tab(), 0, &aVirtDev,
-                                     pViewData->GetPPTX(),  pViewData->GetPPTY(),
-                                     pViewData->GetZoomX(), pViewData->GetZoomY(),
-                                     false ) )
+        if (pDoc->SetOptimalHeight(aCxt, aRange.aStart.Row(), aRange.aEnd.Row(), aRange.aStart.Tab()))
         {
             aRange.aStart.SetCol(0);
             aRange.aEnd.SetCol(MAXCOL);
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 2be77bf..95949b8 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -51,6 +51,7 @@
 #include "progress.hxx"
 #include "editutil.hxx"
 #include "editdataarray.hxx"
+#include <rowheightcontext.hxx>
 
 // STATIC DATA ---------------------------------------------------------------
 
@@ -849,8 +850,9 @@ void ScUndoAutoFormat::Redo()
             nPPTY = ScGlobal::nScreenPPTY;
         }
 
-        sal_Bool bFormula = false;  // remember
+        bool bFormula = false;  // remember
 
+        sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, &aVirtDev);
         for (SCTAB nTab=nStartZ; nTab<=nEndZ; nTab++)
         {
             ScMarkData aDestMark;
@@ -866,8 +868,8 @@ void ScUndoAutoFormat::Redo()
                 if ( !bHidden && ( nOld & CR_MANUALSIZE ) )
                     pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE );
             }
-            pDoc->SetOptimalHeight( nStartY, nEndY, nTab, 0, &aVirtDev,
-                                        nPPTX, nPPTY, aZoomX, aZoomY, false );
+
+            pDoc->SetOptimalHeight(aCxt, nStartY, nEndY, nTab);
 
             for (SCCOL nCol=nStartX; nCol<=nEndX; nCol++)
                 if (!pDoc->ColHidden(nCol, nTab))
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 9415fe2..2a0b118 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -82,6 +82,7 @@
 #include "searchresults.hxx"
 #include "tokenarray.hxx"
 #include <columnspanset.hxx>
+#include <rowheightcontext.hxx>
 
 #include <boost/scoped_ptr.hpp>
 #include <vector>
@@ -129,7 +130,8 @@ sal_Bool ScViewFunc::AdjustBlockHeight( sal_Bool bPaint, ScMarkData* pMarkData )
         aZoomX = aZoomY = Fraction( 1, 1 );
     }
 
-    sal_Bool bAnyChanged = false;
+    sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice());
+    bool bAnyChanged = false;
     ScMarkData::iterator itr = pMarkData->begin(), itrEnd = pMarkData->end();
     for (; itr != itrEnd; ++itr)
     {
@@ -141,8 +143,7 @@ sal_Bool ScViewFunc::AdjustBlockHeight( sal_Bool bPaint, ScMarkData* pMarkData )
         {
             SCROW nStartNo = itRows->mnRow1;
             SCROW nEndNo = itRows->mnRow2;
-            if (pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, aProv.GetDevice(),
-                                        nPPTX, nPPTY, aZoomX, aZoomY, false ))
+            if (pDoc->SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab))
             {
                 if (!bChanged)
                     nPaintY = nStartNo;
@@ -183,8 +184,8 @@ sal_Bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, sal_Bool b
         nPPTY = aProv.GetPPTY();
         aZoomX = aZoomY = Fraction( 1, 1 );
     }
-    sal_Bool bChanged = pDoc->SetOptimalHeight( nStartRow, nEndRow, nTab, 0, aProv.GetDevice(),
-                                            nPPTX, nPPTY, aZoomX, aZoomY, false );
+    sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice());
+    bool bChanged = pDoc->SetOptimalHeight(aCxt, nStartRow, nEndRow, nTab);
 
     if (bChanged && ( nStartRow == nEndRow ))
     {
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index b967526..982a17c 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -75,7 +75,7 @@
 #include "docuno.hxx"
 #include "cellsuno.hxx"
 #include "tokenarray.hxx"
-
+#include <rowheightcontext.hxx>
 
 //==================================================================
 
@@ -2084,8 +2084,10 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR
                         aZoomX = aZoomY = Fraction( 1, 1 );
                     }
 
-                    pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, nSizeTwips, aProv.GetDevice(),
-                                                nPPTX, nPPTY, aZoomX, aZoomY, bAll );
+                    sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice());
+                    aCxt.setForceAutoSize(bAll);
+                    aCxt.setExtraHeight(nSizeTwips);
+                    pDoc->SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab);
                     if (bAll)
                         pDoc->ShowRows( nStartNo, nEndNo, nTab, true );
 


More information about the Libreoffice-commits mailing list