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

Bartosz Kosiorek gang65 at poczta.onet.pl
Thu Jan 12 21:04:26 UTC 2017


 sc/source/core/data/table2.cxx |   69 ++++++++++++++++++++---------------------
 sc/source/core/data/table4.cxx |    8 ++--
 sc/source/core/data/table6.cxx |   23 ++++++++-----
 sc/source/core/data/table7.cxx |    6 +--
 4 files changed, 57 insertions(+), 49 deletions(-)

New commits:
commit 5e223be2102a171c857be8db1327f23faea0ef78
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
Date:   Tue Jan 3 23:25:51 2017 +0100

    tdf#50916 Use aCol.size() instead of MAXCOL to increase max number of column
    
    Currently when we are increasing MAXCOL variable, the memory usage and
    performance are increase dramatically. To resolve that, columns
    needs to be created dynamically according to needs.
    This patch replace hardcoded MAXCOL with aCol.size().
    It is next step to make creation of columns dynamic.
    
    Change-Id: Ic7b7a76863e063a607165629bdf82699eaa847b3
    Reviewed-on: https://gerrit.libreoffice.org/32708
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index f94e732..9814b65 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -716,7 +716,7 @@ void ScTable::MixMarked(
     sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction,
     bool bSkipEmpty, const ScTable* pSrcTab )
 {
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].MixMarked(rCxt, rMark, nFunction, bSkipEmpty, pSrcTab->aCol[i]);
 }
 
@@ -1036,7 +1036,7 @@ void ScTable::StartListeners( sc::StartListeningContext& rCxt, bool bAll )
     std::shared_ptr<const sc::ColumnSet> pColSet = rCxt.getColumnSet();
     if (!pColSet)
     {
-        for (SCCOL i=0; i<=MAXCOL; i++)
+        for (SCCOL i=0; i < aCol.size(); i++)
             aCol[i].StartListeners(rCxt, bAll);
     }
     else if (pColSet->hasTab( nTab))
@@ -1045,7 +1045,7 @@ void ScTable::StartListeners( sc::StartListeningContext& rCxt, bool bAll )
         pColSet->getColumns( nTab, aColumns);
         for (auto i : aColumns)
         {
-            if (0 <= i && i <= MAXCOL)
+            if (0 <= i && i < aCol.size())
                 aCol[i].StartListeners(rCxt, bAll);
         }
     }
@@ -1238,7 +1238,7 @@ void ScTable::UndoToTable(
         bool bWidth  = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth);
         bool bHeight = (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pDestTab->mpRowHeights);
 
-        for ( SCCOL i = 0; i <= MAXCOL; i++)
+        for ( SCCOL i = 0; i < aCol.size(); i++)
         {
             if ( i >= nCol1 && i <= nCol2 )
                 aCol[i].UndoToColumn(rCxt, nRow1, nRow2, nFlags, bMarked, pDestTab->aCol[i]);
@@ -1268,7 +1268,7 @@ void ScTable::UndoToTable(
 
 void ScTable::CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const
 {
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].CopyUpdated( pPosTab->aCol[i], pDestTab->aCol[i] );
 }
 
@@ -1286,7 +1286,7 @@ void ScTable::CopyScenarioTo( ScTable* pDestTab ) const
 {
     OSL_ENSURE( bScenario, "bScenario == FALSE" );
 
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].CopyScenarioTo( pDestTab->aCol[i] );
 }
 
@@ -1294,7 +1294,7 @@ void ScTable::CopyScenarioFrom( const ScTable* pSrcTab )
 {
     OSL_ENSURE( bScenario, "bScenario == FALSE" );
 
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].CopyScenarioFrom( pSrcTab->aCol[i] );
 }
 
@@ -1305,7 +1305,7 @@ void ScTable::MarkScenarioIn( ScMarkData& rDestMark, ScScenarioFlags nNeededBits
     if ( ( nScenarioFlags & nNeededBits ) != nNeededBits )  // Are all Bits set?
         return;
 
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].MarkScenarioIn( rDestMark );
 }
 
@@ -1360,7 +1360,7 @@ bool ScTable::TestCopyScenarioTo( const ScTable* pDestTab ) const
         return true;
 
     bool bOk = true;
-    for (SCCOL i=0; i<=MAXCOL && bOk; i++)
+    for (SCCOL i=0; i < aCol.size() && bOk; i++)
         bOk = aCol[i].TestCopyScenarioTo( pDestTab->aCol[i] );
     return bOk;
 }
@@ -1583,7 +1583,7 @@ SCROW ScTable::GetNotePosition( SCCOL nCol, size_t nIndex ) const
 
 void ScTable::CreateAllNoteCaptions()
 {
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
         aCol[i].CreateAllNoteCaptions();
 }
 
@@ -1598,7 +1598,7 @@ void ScTable::ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW n
 
 void ScTable::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const
 {
-    for (SCCOL nCol = 0; nCol < MAXCOLCOUNT; ++nCol)
+    for (SCCOL nCol = 0; nCol < aCol.size(); ++nCol)
         aCol[nCol].GetAllNoteEntries(rNotes);
 }
 
@@ -1645,10 +1645,10 @@ void ScTable::GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const
 {
     rCol = 0;
     rRow = MAXROW+1;
-    while (aCol[rCol].IsEmptyData() && rCol < MAXCOL)
+    while (aCol[rCol].IsEmptyData() && rCol < aCol.size() - 1 )
         ++rCol;
     SCCOL nCol = rCol;
-    while (nCol <= MAXCOL && rRow > 0)
+    while (nCol < aCol.size() && rRow > 0)
     {
         if (!aCol[nCol].IsEmptyData())
             rRow = ::std::min( rRow, aCol[nCol].GetFirstDataPos());
@@ -1658,7 +1658,7 @@ void ScTable::GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const
 
 void ScTable::GetLastDataPos(SCCOL& rCol, SCROW& rRow) const
 {
-    rCol = MAXCOL;
+    rCol = aCol.size() - 1;
     rRow = 0;
     while (aCol[rCol].IsEmptyData() && (rCol > 0))
         rCol--;
@@ -1704,7 +1704,7 @@ bool ScTable::HasStringCells( SCCOL nStartCol, SCROW nStartRow,
 
 void ScTable::SetDirtyVar()
 {
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].SetDirtyVar();
 }
 
@@ -1712,7 +1712,7 @@ void ScTable::CheckVectorizationState()
 {
     sc::AutoCalcSwitch aACSwitch(*pDocument, false);
 
-    for (SCCOL i = 0; i <= MAXCOL; i++)
+    for (SCCOL i = 0; i < aCol.size(); i++)
         aCol[i].CheckVectorizationState();
 }
 
@@ -1720,7 +1720,7 @@ void ScTable::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt )
 {
     sc::AutoCalcSwitch aACSwitch(*pDocument, false);
 
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].SetAllFormulasDirty(rCxt);
 }
 
@@ -1748,7 +1748,7 @@ void ScTable::SetDirtyAfterLoad()
 {
     bool bOldAutoCalc = pDocument->GetAutoCalc();
     pDocument->SetAutoCalc( false );    // avoid multiple recalculations
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].SetDirtyAfterLoad();
     pDocument->SetAutoCalc( bOldAutoCalc );
 }
@@ -1757,7 +1757,7 @@ void ScTable::SetDirtyIfPostponed()
 {
     bool bOldAutoCalc = pDocument->GetAutoCalc();
     pDocument->SetAutoCalc( false );    // avoid multiple recalculations
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].SetDirtyIfPostponed();
     pDocument->SetAutoCalc( bOldAutoCalc );
 }
@@ -1765,7 +1765,7 @@ void ScTable::SetDirtyIfPostponed()
 void ScTable::BroadcastRecalcOnRefMove()
 {
     sc::AutoCalcSwitch aSwitch(*pDocument, false);
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
         aCol[i].BroadcastRecalcOnRefMove();
 }
 
@@ -1798,12 +1798,13 @@ void ScTable::SetLoadingMedium(bool bLoading)
 
 void ScTable::CalcAll()
 {
-    for (SCCOL i=0; i<=MAXCOL; i++) aCol[i].CalcAll();
+    for (SCCOL i=0; i < aCol.size(); i++)
+        aCol[i].CalcAll();
 }
 
 void ScTable::CompileAll( sc::CompileFormulaContext& rCxt )
 {
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
         aCol[i].CompileAll(rCxt);
 
     if(mpCondFormatList)
@@ -1815,7 +1816,7 @@ void ScTable::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress
     if (mpRangeName)
         mpRangeName->CompileUnresolvedXML(rCxt);
 
-    for (SCCOL i=0; i <= MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
     {
         aCol[i].CompileXML(rCxt, rProgress);
     }
@@ -1827,7 +1828,7 @@ void ScTable::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress
 bool ScTable::CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode )
 {
     bool bCompiled = false;
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
     {
         if (aCol[i].CompileErrorCells(rCxt, nErrCode))
             bCompiled = true;
@@ -1838,7 +1839,7 @@ bool ScTable::CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError n
 
 void ScTable::CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening )
 {
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
         aCol[i].CalcAfterLoad(rCxt, bStartListening);
 }
 
@@ -2400,7 +2401,7 @@ void ScTable::UnlockTable()
 
 void ScTable::MergeSelectionPattern( ScMergePatternState& rState, const ScMarkData& rMark, bool bDeep ) const
 {
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].MergeSelectionPattern( rState, rMark, bDeep );
 }
 
@@ -2518,7 +2519,7 @@ void ScTable::ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, S
 
 void ScTable::ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark)
 {
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].ApplySelectionStyle( rStyle, rMark );
 }
 
@@ -2528,7 +2529,7 @@ void ScTable::ApplySelectionLineStyle( const ScMarkData& rMark,
     if ( bColorOnly && !pLine )
         return;
 
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].ApplySelectionLineStyle( rMark, pLine, bColorOnly );
 }
 
@@ -2550,7 +2551,7 @@ const ScStyleSheet* ScTable::GetSelectionStyle( const ScMarkData& rMark, bool& r
     const ScStyleSheet* pStyle = nullptr;
     const ScStyleSheet* pNewStyle;
 
-    for (SCCOL i=0; i<=MAXCOL && bEqual; i++)
+    for (SCCOL i=0; i < aCol.size() && bEqual; i++)
         if (rMark.HasMultiMarks(i))
         {
             pNewStyle = aCol[i].GetSelectionStyle( rMark, bColFound );
@@ -2596,7 +2597,7 @@ bool ScTable::IsStyleSheetUsed( const ScStyleSheet& rStyle ) const
 {
     bool bIsUsed = false;
 
-    for ( SCCOL i=0; i<=MAXCOL; i++ )
+    for ( SCCOL i=0; i < aCol.size(); i++ )
     {
         if ( aCol[i].IsStyleSheetUsed( rStyle ) )
         {
@@ -2613,7 +2614,7 @@ void ScTable::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRem
                                 const Fraction& rZoomX, const Fraction& rZoomY )
 {
     ScFlatBoolRowSegments aUsedRows;
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
         aCol[i].FindStyleSheet(pStyleSheet, aUsedRows, bRemoved);
 
     sc::RowHeightContext aCxt(nPPTX, nPPTY, rZoomX, rZoomY, pDev);
@@ -2668,19 +2669,19 @@ void ScTable::ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr )
 void ScTable::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark,
                                    ScEditDataArray* pDataArray )
 {
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].ApplySelectionCache( pCache, rMark, pDataArray );
 }
 
 void ScTable::ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark )
 {
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].ChangeSelectionIndent( bIncrement, rMark );
 }
 
 void ScTable::ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark )
 {
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].ClearSelectionItems( pWhich, rMark );
 }
 
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index aa7e442..693106d 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -2226,7 +2226,7 @@ void ScTable::SetError( SCCOL nCol, SCROW nRow, FormulaError nError)
 
 void ScTable::UpdateInsertTabAbs(SCTAB nTable)
 {
-    for (SCCOL i=0; i <= MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         aCol[i].UpdateInsertTabAbs(nTable);
 }
 
@@ -2274,20 +2274,20 @@ bool ScTable::GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel,
 
 void ScTable::TestTabRefAbs(SCTAB nTable) const
 {
-    for (SCCOL i=0; i <= MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); i++)
         if (aCol[i].TestTabRefAbs(nTable))
             return;
 }
 
 void ScTable::CompileDBFormula( sc::CompileFormulaContext& rCxt )
 {
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
         aCol[i].CompileDBFormula(rCxt);
 }
 
 void ScTable::CompileColRowNameFormula( sc::CompileFormulaContext& rCxt )
 {
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
         aCol[i].CompileColRowNameFormula(rCxt);
 }
 
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 636ca56..9539311 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -631,21 +631,28 @@ bool ScTable::SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW&
         }
         while (!bFound && ValidCol(nCol));
     }
-    else                                            // by column
+    else                                    // by column
     {
-        SCsROW nNextRows[MAXCOLCOUNT];
+        SCsCOL aColSize = aCol.size();
+        std::vector< SCsROW > nNextRows ( aColSize );
         SCsCOL i;
-        for (i=0; i<=MAXCOL; i++)
+        for (i=0; i < aColSize; ++i)
         {
             SCsROW nSRow = nRow;
-            if (bBack)  { if (i>=nCol) --nSRow; }
-            else        { if (i<=nCol) ++nSRow; }
+            if (bBack)
+            {
+                if (i>=nCol) --nSRow;
+            }
+            else
+            {
+                if (i<=nCol) ++nSRow;
+            }
             nNextRows[i] = aCol[i].SearchStyle( nSRow, pSearchStyle, bBack, bSelect, rMark );
         }
         if (bBack)                          // backwards
         {
             nRow = -1;
-            for (i=MAXCOL; i>=0; i--)
+            for (i = aColSize - 1; i>=0; --i)
                 if (nNextRows[i]>nRow)
                 {
                     nCol = i;
@@ -656,7 +663,7 @@ bool ScTable::SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW&
         else                                // forwards
         {
             nRow = MAXROW+1;
-            for (i=0; i<=MAXCOL; i++)
+            for (i=0; i < aColSize; ++i)
                 if (nNextRows[i]<nRow)
                 {
                     nCol = i;
@@ -711,7 +718,7 @@ bool ScTable::SearchAllStyle(
     bool bBack = rSearchItem.GetBackward();
     bool bEverFound = false;
 
-    for (SCCOL i=0; i<=MAXCOL; i++)
+    for (SCCOL i=0; i < aCol.size(); ++i)
     {
         bool bFound = true;
         SCsROW nRow = 0;
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index d4cd767..a849429 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -124,21 +124,21 @@ void ScTable::SwapNonEmpty(
 void ScTable::PreprocessRangeNameUpdate(
     sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt )
 {
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
         aCol[i].PreprocessRangeNameUpdate(rEndListenCxt, rCompileCxt);
 }
 
 void ScTable::PreprocessDBDataUpdate(
     sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt )
 {
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
         aCol[i].PreprocessDBDataUpdate(rEndListenCxt, rCompileCxt);
 }
 
 void ScTable::CompileHybridFormula(
     sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt )
 {
-    for (SCCOL i = 0; i <= MAXCOL; ++i)
+    for (SCCOL i = 0; i < aCol.size(); ++i)
         aCol[i].CompileHybridFormula(rStartListenCxt, rCompileCxt);
 }
 


More information about the Libreoffice-commits mailing list