[ooo-build-commit] .: 2 commits - patches/dev300

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Sep 27 22:27:23 PDT 2010


 patches/dev300/apply                                 |    6 
 patches/dev300/calc-perf-adjust-slot-machine.diff    |   26 -
 patches/dev300/calc-perf-ods-import-row-heights.diff |  368 +++++++++++++++++++
 3 files changed, 371 insertions(+), 29 deletions(-)

New commits:
commit d458152dc70565bbf900483d9f85ac997043d791
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Sep 28 01:25:52 2010 -0400

    Removed a patch that's no longer needed.
    
    The slot machine has already been adjusted to handle initial memory
    allocation correctly without the change that the patch introduced.

diff --git a/patches/dev300/apply b/patches/dev300/apply
index db0d1e3..8d1e5bc 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -2732,9 +2732,6 @@ calc-perf-xls-import-cellstyles.diff, n#582693, kohei
 calc-perf-xls-import-cellstyles-fix.diff, n#594266, kohei
 calc-perf-xls-import-cellstyles-fix2.diff, n#594235, kohei
 
-# Adjust the size of the broadcast slot machine to match the new row limit.
-calc-perf-adjust-slot-machine.diff, n#588554, kohei
-
 [ CalcFixes ]
 # Check for separator options' potential conflict with custom locale setting.
 calc-formula-variable-sep-config-check-sfx2.diff, n#556142, i#106959, kohei
diff --git a/patches/dev300/calc-perf-adjust-slot-machine.diff b/patches/dev300/calc-perf-adjust-slot-machine.diff
deleted file mode 100644
index a9f5e1d..0000000
--- a/patches/dev300/calc-perf-adjust-slot-machine.diff
+++ /dev/null
@@ -1,26 +0,0 @@
----
- sc/source/core/data/bcaslot.cxx |    6 +-----
- 1 files changed, 1 insertions(+), 5 deletions(-)
-
-diff --git sc/source/core/data/bcaslot.cxx sc/source/core/data/bcaslot.cxx
-index a917383..cf004e5 100644
---- sc/source/core/data/bcaslot.cxx
-+++ sc/source/core/data/bcaslot.cxx
-@@ -45,13 +45,7 @@
- // Number of slots per dimension
- // must be integer divisors of MAXCOLCOUNT respectively MAXROWCOUNT
- #define BCA_SLOTS_COL ((MAXCOLCOUNT_DEFINE) / 16)
--#if MAXROWCOUNT_DEFINE == 32000
--#define BCA_SLOTS_ROW 256
--#define BCA_SLICE 125
--#else
--#define BCA_SLICE 128
--#define BCA_SLOTS_ROW ((MAXROWCOUNT_DEFINE) / BCA_SLICE)
--#endif
-+#define BCA_SLOTS_ROW 2048
- #define BCA_SLOT_COLS ((MAXCOLCOUNT_DEFINE) / BCA_SLOTS_COL)
- #define BCA_SLOT_ROWS ((MAXROWCOUNT_DEFINE) / BCA_SLOTS_ROW)
- // multiple?
--- 
-1.7.0.1
-
commit f6646397a759c9288a0a79bdbf503f47975dde88
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Sep 28 01:07:43 2010 -0400

    Fixed performance bug on row height adjustments.
    
    Don't adjust the sizes and positions of drawing objects on every row
    height change during import.
    
    See bug n#640112 for details.

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 0c2679d..db0d1e3 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -2979,3 +2979,6 @@ calc-cell-270-degree-fix.diff, n#640128, kohei
 
 # Fix failure to toggle relative/absolute references via Shift-F4.
 calc-toggle-relative-ref-fix.diff, n#634260, kohei
+
+# Fix performance bug on row height adjustments during ods import.
+calc-perf-ods-import-row-heights.diff, n#640112, kohei
diff --git a/patches/dev300/calc-perf-ods-import-row-heights.diff b/patches/dev300/calc-perf-ods-import-row-heights.diff
new file mode 100644
index 0000000..fc6e3a9
--- /dev/null
+++ b/patches/dev300/calc-perf-ods-import-row-heights.diff
@@ -0,0 +1,368 @@
+diff --git sc/inc/table.hxx sc/inc/table.hxx
+index faf3058..4216d2d 100644
+--- sc/inc/table.hxx
++++ sc/inc/table.hxx
+@@ -616,6 +616,14 @@ public:
+                                     const Fraction& rZoomX, const Fraction& rZoomY,
+                                     BOOL bForce,
+                                     ScProgress* pOuterProgress = NULL, ULONG nProgressStart = 0 );
++
++    void        SetOptimalHeightOnly(SCROW nStartRow, SCROW nEndRow, USHORT nExtra,
++                                     OutputDevice* pDev,
++                                     double nPPTX, double nPPTY,
++                                     const Fraction& rZoomX, const Fraction& rZoomY,
++                                     BOOL bForce,
++                                     ScProgress* pOuterProgress = NULL, ULONG nProgressStart = 0 );
++
+     long		GetNeededSize( SCCOL nCol, SCROW nRow,
+                                     OutputDevice* pDev,
+                                     double nPPTX, double nPPTY,
+diff --git sc/source/core/data/document.cxx sc/source/core/data/document.cxx
+index 01fbaa2..5599db5 100644
+--- sc/source/core/data/document.cxx
++++ sc/source/core/data/document.cxx
+@@ -3413,8 +3413,9 @@ void ScDocument::UpdateAllRowHeights( OutputDevice* pDev, double nPPTX, double n
+     for ( SCTAB nTab=0; nTab<=MAXTAB; nTab++ )
+         if ( pTab[nTab] && ( !pTabMark || pTabMark->GetTableSelect(nTab) ) )
+         {
+-            pTab[nTab]->SetOptimalHeight( 0, MAXROW, 0,
++            pTab[nTab]->SetOptimalHeightOnly( 0, MAXROW, 0,
+                         pDev, nPPTX, nPPTY, rZoomX, rZoomY, FALSE, &aProgress, nProgressStart );
++            pTab[nTab]->SetDrawPageSize(true, true);
+             nProgressStart += pTab[nTab]->GetWeightedCount();
+         }
+ }
+diff --git sc/source/core/data/table1.cxx sc/source/core/data/table1.cxx
+index a94888b..5f4075f 100644
+--- sc/source/core/data/table1.cxx
++++ sc/source/core/data/table1.cxx
+@@ -53,6 +53,177 @@
+ #include "sheetevents.hxx"
+ #include "segmenttree.hxx"
+ 
++#include <vector>
++
++using ::std::vector;
++
++namespace {
++
++ScProgress* GetProgressBar(
++    SCSIZE nCount, SCSIZE nTotalCount, ScProgress* pOuterProgress, ScDocument* pDoc)
++{
++    if (nTotalCount < 1000)
++    {
++        // if the total number of rows is less than 1000, don't even bother
++        // with the progress bar because drawing progress bar can be very
++        // expensive especially in GTK.
++        return NULL;
++    }
++
++    if (pOuterProgress)
++        return pOuterProgress;
++
++    if (nCount > 1)
++        return new ScProgress(
++            pDoc->GetDocumentShell(), ScGlobal::GetRscString(STR_PROGRESS_HEIGHTING), nTotalCount);
++
++    return NULL;
++}
++
++void GetOptimalHeightsInColumn(
++    ScColumn* pCol, SCROW nStartRow, SCROW nEndRow, vector<USHORT>& aHeights, 
++    OutputDevice* pDev, double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY, bool bForce, 
++    ScProgress* pProgress, sal_uInt32 nProgressStart)
++{
++    SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
++
++    //	zuerst einmal ueber den ganzen Bereich
++    //	(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 );
++
++    //	daraus Standardhoehe suchen, die im unteren Bereich gilt
++
++    USHORT nMinHeight = aHeights[nCount-1];
++    SCSIZE nPos = nCount-1;
++    while ( nPos && aHeights[nPos-1] >= nMinHeight )
++        --nPos;
++    SCROW nMinStart = nStartRow + nPos;
++
++    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 );
++
++        if (pProgress)
++        {
++            ULONG nWeight = pCol[nCol].GetWeightedCount();
++            if (nWeight)		// nochmal denselben Status muss auch nicht sein
++            {
++                nWeightedCount += nWeight;
++                pProgress->SetState( nWeightedCount + nProgressStart );
++            }
++        }
++    }
++}
++
++struct OptimalHeightsFuncObjBase
++{
++    virtual ~OptimalHeightsFuncObjBase() {}
++    virtual bool operator() (SCROW nStartRow, SCROW nEndRow, USHORT nHeight) = 0;
++};
++
++struct SetRowHeightOnlyFunc : public OptimalHeightsFuncObjBase
++{
++    ScTable* mpTab;
++    SetRowHeightOnlyFunc(ScTable* pTab) : 
++        mpTab(pTab)
++    {}
++
++    virtual bool operator() (SCROW nStartRow, SCROW nEndRow, USHORT nHeight)
++    {
++        mpTab->SetRowHeightOnly(nStartRow, nEndRow, nHeight);
++        return false;
++    }
++};
++
++struct SetRowHeightRangeFunc : public OptimalHeightsFuncObjBase
++{
++    ScTable* mpTab;
++    double mnPPTX;
++    double mnPPTY;
++
++    SetRowHeightRangeFunc(ScTable* pTab, double nPPTX, double nPPTY) : 
++        mpTab(pTab),
++        mnPPTX(nPPTX),
++        mnPPTY(nPPTY)
++    {}
++
++    virtual bool operator() (SCROW nStartRow, SCROW nEndRow, USHORT nHeight)
++    {
++        return mpTab->SetRowHeightRange(nStartRow, nEndRow, nHeight, mnPPTX, mnPPTY);
++    }
++};
++
++bool SetOptimalHeightsToRows(OptimalHeightsFuncObjBase& rFuncObj,
++    ScBitMaskCompressedArray<SCROW, BYTE>* pRowFlags, SCROW nStartRow, SCROW nEndRow, USHORT nExtra,
++    const vector<USHORT>& aHeights, bool bForce)
++{
++    SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
++    bool bChanged = false;
++    SCROW nRngStart = 0;
++    SCROW nRngEnd = 0;
++    USHORT nLast = 0;
++    for (SCSIZE i=0; i<nCount; i++)
++    {
++        size_t nIndex;
++        SCROW nRegionEndRow;
++        BYTE nRowFlag = pRowFlags->GetValue( nStartRow+i, nIndex, nRegionEndRow );
++        if ( nRegionEndRow > nEndRow )
++            nRegionEndRow = nEndRow;
++        SCSIZE nMoreRows = nRegionEndRow - ( nStartRow+i );     // additional equal rows after first
++
++        bool bAutoSize = ((nRowFlag & CR_MANUALSIZE) == 0);
++        if ( bAutoSize || bForce )
++        {
++            if (nExtra)
++            {
++                if (bAutoSize)
++                    pRowFlags->SetValue( nStartRow+i, nRegionEndRow, nRowFlag | CR_MANUALSIZE);
++            }
++            else if (!bAutoSize)
++                pRowFlags->SetValue( nStartRow+i, nRegionEndRow, nRowFlag & ~CR_MANUALSIZE);
++
++            for (SCSIZE nInner = i; nInner <= i + nMoreRows; ++nInner)
++            {
++                if (nLast)
++                {
++                    if (aHeights[nInner]+nExtra == nLast)
++                        nRngEnd = nStartRow+nInner;
++                    else
++                    {
++                        bChanged |= rFuncObj(nRngStart, nRngEnd, nLast);
++                        nLast = 0;
++                    }
++                }
++                if (!nLast)
++                {
++                    nLast = aHeights[nInner]+nExtra;
++                    nRngStart = nStartRow+nInner;
++                    nRngEnd = nStartRow+nInner;
++                }
++            }
++        }
++        else
++        {
++            if (nLast)
++                bChanged |= rFuncObj(nRngStart, nRngEnd, nLast);
++            nLast = 0;
++        }
++        i += nMoreRows;     // already handled - skip
++    }
++    if (nLast)
++        bChanged |= rFuncObj(nRngStart, nRngEnd, nLast);
++
++    return bChanged;
++}
++
++}
++
+ // -----------------------------------------------------------------------
+ 
+ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName,
+@@ -290,120 +461,53 @@ BOOL ScTable::SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, USHORT nExtra,
+         return FALSE;
+     }
+ 
+-    BOOL    bChanged = FALSE;
+     SCSIZE  nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
+ 
+-    ULONG nTotalCount = GetWeightedCount();
+-    ScProgress* pProgress = NULL;
+-    if (nTotalCount >= 1000)
+-    {
+-        // if the total number of rows is less than 1000, don't even bother
+-        // with the progress bar because drawing progress bar can be very
+-        // expensive especially in GTK.
++    ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, pDocument);
+ 
+-        if ( pOuterProgress )
+-            pProgress = pOuterProgress;
+-        else if ( nCount > 1 )
+-            pProgress = new ScProgress(
+-                pDocument->GetDocumentShell(),
+-                ScGlobal::GetRscString(STR_PROGRESS_HEIGHTING), nTotalCount );
+-    }
++    vector<USHORT> aHeights(nCount, 0);
+ 
+-    USHORT* pHeight = new USHORT[nCount];                   // Twips !
+-    memset( pHeight, 0, sizeof(USHORT) * nCount );
++    GetOptimalHeightsInColumn(
++        aCol, nStartRow, nEndRow, aHeights, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce, 
++        pProgress, nProgressStart);
+ 
+-    //	zuerst einmal ueber den ganzen Bereich
+-    //	(mit der letzten Spalte in der Hoffnung, dass die am ehesten noch auf
+-    //	 Standard formatiert ist)
++    SetRowHeightRangeFunc aFunc(this, nPPTX, nPPTY);
++    bool bChanged = SetOptimalHeightsToRows(
++        aFunc, pRowFlags, nStartRow, nEndRow, nExtra, aHeights, bForce);
+ 
+-    aCol[MAXCOL].GetOptimalHeight(
+-            nStartRow, nEndRow, pHeight, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce, 0, 0 );
++    if ( pProgress != pOuterProgress )
++        delete pProgress;
+ 
+-    //	daraus Standardhoehe suchen, die im unteren Bereich gilt
++    return bChanged;
++}
+ 
+-    USHORT nMinHeight = pHeight[nCount-1];
+-    SCSIZE nPos = nCount-1;
+-    while ( nPos && pHeight[nPos-1] >= nMinHeight )
+-        --nPos;
+-    SCROW nMinStart = nStartRow + nPos;
++void ScTable::SetOptimalHeightOnly( SCROW nStartRow, SCROW nEndRow, USHORT nExtra,
++                                OutputDevice* pDev,
++                                double nPPTX, double nPPTY,
++                                const Fraction& rZoomX, const Fraction& rZoomY,
++                                BOOL bForce, ScProgress* pOuterProgress, ULONG nProgressStart )
++{
++    DBG_ASSERT( nExtra==0 || bForce, "autom. OptimalHeight mit Extra" );
+ 
+-    ULONG nWeightedCount = 0;
+-    for (SCCOL nCol=0; nCol<MAXCOL; nCol++)		// MAXCOL schon oben
+-    {
+-        aCol[nCol].GetOptimalHeight(
+-            nStartRow, nEndRow, pHeight, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce,
+-            nMinHeight, nMinStart );
++    if ( !pDocument->IsAdjustHeightEnabled() )
++        return;
+ 
+-        if (pProgress)
+-        {
+-            ULONG nWeight = aCol[nCol].GetWeightedCount();
+-            if (nWeight)		// nochmal denselben Status muss auch nicht sein
+-            {
+-                nWeightedCount += nWeight;
+-                pProgress->SetState( nWeightedCount + nProgressStart );
+-            }
+-        }
+-    }
++    SCSIZE  nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
+ 
+-    SCROW nRngStart = 0;
+-    SCROW nRngEnd = 0;
+-    USHORT nLast = 0;
+-    for (SCSIZE i=0; i<nCount; i++)
+-    {
+-        size_t nIndex;
+-        SCROW nRegionEndRow;
+-        BYTE nRowFlag = pRowFlags->GetValue( nStartRow+i, nIndex, nRegionEndRow );
+-        if ( nRegionEndRow > nEndRow )
+-            nRegionEndRow = nEndRow;
+-        SCSIZE nMoreRows = nRegionEndRow - ( nStartRow+i );     // additional equal rows after first
++    ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, pDocument);
+ 
+-        bool bAutoSize = ((nRowFlag & CR_MANUALSIZE) == 0);
+-        if ( bAutoSize || bForce )
+-        {
+-            if (nExtra)
+-            {
+-                if (bAutoSize)
+-                    pRowFlags->SetValue( nStartRow+i, nRegionEndRow, nRowFlag | CR_MANUALSIZE);
+-            }
+-            else if (!bAutoSize)
+-                pRowFlags->SetValue( nStartRow+i, nRegionEndRow, nRowFlag & ~CR_MANUALSIZE);
++    vector<USHORT> aHeights(nCount, 0);
+ 
+-            for (SCSIZE nInner = i; nInner <= i + nMoreRows; ++nInner)
+-            {
+-                if (nLast)
+-                {
+-                    if (pHeight[nInner]+nExtra == nLast)
+-                        nRngEnd = nStartRow+nInner;
+-                    else
+-                    {
+-                        bChanged |= SetRowHeightRange( nRngStart, nRngEnd, nLast, nPPTX, nPPTY );
+-                        nLast = 0;
+-                    }
+-                }
+-                if (!nLast)
+-                {
+-                    nLast = pHeight[nInner]+nExtra;
+-                    nRngStart = nStartRow+nInner;
+-                    nRngEnd = nStartRow+nInner;
+-                }
+-            }
+-        }
+-        else
+-        {
+-            if (nLast)
+-                bChanged |= SetRowHeightRange( nRngStart, nRngEnd, nLast, nPPTX, nPPTY );
+-            nLast = 0;
+-        }
+-        i += nMoreRows;     // already handled - skip
+-    }
+-    if (nLast)
+-        bChanged |= SetRowHeightRange( nRngStart, nRngEnd, nLast, nPPTX, nPPTY );
++    GetOptimalHeightsInColumn(
++        aCol, nStartRow, nEndRow, aHeights, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce, 
++        pProgress, nProgressStart);
++
++    SetRowHeightOnlyFunc aFunc(this);
++    SetOptimalHeightsToRows(
++        aFunc, pRowFlags, nStartRow, nEndRow, nExtra, aHeights, bForce);
+ 
+-    delete[] pHeight;
+     if ( pProgress != pOuterProgress )
+         delete pProgress;
+-
+-    return bChanged;
+ }
+ 
+ BOOL ScTable::GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const


More information about the ooo-build-commit mailing list