diff options
author | Steve Yin <steve_y@apache.org> | 2014-01-03 08:48:02 +0000 |
---|---|---|
committer | Steve Yin <steve_y@apache.org> | 2014-01-03 08:48:02 +0000 |
commit | acc76cb44c51fbefc8f34009300acb9382c3ad27 (patch) | |
tree | 648c78ee5b7b7e4292c9a91bb1cf3a1f158a0b82 /sc | |
parent | 12d51cf294b62453c140a2db2b32aceb9dfb6ea8 (diff) |
Bug 123909 - Select one column, paste cell range with merged cell in, AOO will be not responding
Notes
Notes:
merged as: 6b8704d974abd4ab7fb58036a961fa0b7136aaa7
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/attarray.hxx | 5 | ||||
-rw-r--r-- | sc/inc/column.hxx | 3 | ||||
-rw-r--r-- | sc/inc/document.hxx | 4 | ||||
-rw-r--r-- | sc/inc/table.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/attarray.cxx | 30 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 14 | ||||
-rw-r--r-- | sc/source/core/data/documen3.cxx | 24 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 35 | ||||
-rw-r--r-- | sc/source/core/data/table4.cxx | 24 |
9 files changed, 137 insertions, 5 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx index c4914b230f0a..6771b7cd5cbd 100644 --- a/sc/inc/attarray.hxx +++ b/sc/inc/attarray.hxx @@ -188,6 +188,11 @@ public: void DeleteHardAttr( SCROW nStartRow, SCROW nEndRow ); //UNUSED2008-05 void ConvertFontsAfterLoad(); // old binary file format + + /* i123909: Pre-calculate needed memory, and pre-reserve enough memory */ + bool Reserve( SCSIZE nCount ); + SCSIZE Count() const{ return nCount; } + SCSIZE Count( SCROW nRw1, SCROW nRw2 ); }; diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 45c42f08b91c..e856bf803441 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -404,6 +404,9 @@ public: xub_StrLen GetMaxNumberStringLen( sal_uInt16& nPrecision, SCROW nRowStart, SCROW nRowEnd ) const; + SCSIZE GetPatternCount( ); + SCSIZE GetPatternCount( SCROW nRw1, SCROW nRw2 ); + bool ReservedPatternCount( SCSIZE nReserved ); private: ScBaseCell* CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rDestDoc, const ScAddress& rDestPos); //UNUSED2008-05 void CorrectSymbolCells( CharSet eStreamCharSet ); diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index cf4ac1649839..88980a2a3231 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1908,6 +1908,10 @@ private: // CLOOK-Impl-Methoden public: void FillDPCache( ScDPTableDataCache * pCache, SCTAB nDocTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow ); +private: + SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol ); + SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRw1, SCROW nRw2 ); + bool ReservedPatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserved ); }; inline void ScDocument::GetSortParam( ScSortParam& rParam, SCTAB nTab ) { diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 0363eda685aa..052f8733a3ee 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -311,6 +311,9 @@ public: SvNumberFormatter* pFormatter = NULL, bool bDetectNumberFormat = true ); void SetValue( SCCOL nCol, SCROW nRow, const double& rVal ); void SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError); + SCSIZE GetPatternCount( SCCOL nCol ); + SCSIZE GetPatternCount( SCCOL nCol, SCROW nRw1, SCROW nRw2 ); + bool ReservedPatternCount( SCCOL nCol, SCSIZE nReserved ); void GetString( SCCOL nCol, SCROW nRow, String& rString ); void FillDPCache( ScDPTableDataCache * pCache, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow ); diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index 78e15940dfd3..d2dea6d66cf2 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -295,6 +295,24 @@ void ScAttrArray::SetPattern( SCROW nRow, const ScPatternAttr* pPattern, sal_Boo SetPatternArea( nRow, nRow, pPattern, bPutToPool ); } +bool ScAttrArray::Reserve( SCSIZE nReserve ) +{ + if ( nCount <= nReserve ) + { + if( ScAttrEntry* pNewData = new (std::nothrow) ScAttrEntry[nReserve] ) + { + nLimit = nReserve; + memcpy( pNewData, pData, nCount*sizeof(ScAttrEntry) ); + delete[] pData; + pData = pNewData; + return true; + } + else + return false; + } + else + return false; +} void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPatternAttr *pPattern, sal_Bool bPutToPool ) { @@ -2647,3 +2665,15 @@ void ScAttrArray::Load( SvStream& /* rStream */ ) //UNUSED2008-05 } //UNUSED2008-05 } +SCSIZE ScAttrArray::Count( SCROW nStartRow, SCROW nEndRow ) +{ + SCSIZE nIndex1, nIndex2; + + if( !Search( nStartRow, nIndex1 ) ) + return 0; + + if( !Search( nEndRow, nIndex2 ) ) + nIndex2 = this->nCount - 1; + + return nIndex2 - nIndex1 + 1; +} diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 4fa3022e0209..8c3f8fbfb539 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1885,7 +1885,17 @@ sal_uLong ScColumn::GetCodeCount() const return nCodeCount; } +SCSIZE ScColumn::GetPatternCount() +{ + return this->pAttrArray ? this->pAttrArray->Count() : 0; +} +SCSIZE ScColumn::GetPatternCount( SCROW nRw1, SCROW nRw2 ) +{ + return this->pAttrArray ? this->pAttrArray->Count( nRw1, nRw2 ) : 0; +} - - +bool ScColumn::ReservedPatternCount( SCSIZE nReserved ) +{ + return this->pAttrArray ? this->pAttrArray->Reserve( nReserved ) : false; +} diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index df4183e7948f..487eb94d152f 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -2149,3 +2149,27 @@ void ScDocument::GetUsedDPObjectCache( std::list<ScDPTableDataCache*>& usedlist } } // End Comments + +SCSIZE ScDocument::GetPatternCount( SCTAB nTab, SCCOL nCol ) +{ + if( ValidTab(nTab) && pTab[nTab] ) + return pTab[nTab]->GetPatternCount( nCol ); + else + return 0; +} + +SCSIZE ScDocument::GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRw1, SCROW nRw2 ) +{ + if( ValidTab(nTab) && pTab[nTab] ) + return pTab[nTab]->GetPatternCount( nCol, nRw1, nRw2 ); + else + return 0; +} + +bool ScDocument::ReservedPatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserved ) +{ + if( ValidTab(nTab) && pTab[nTab] ) + return pTab[nTab]->ReservedPatternCount( nCol, nReserved ); + else + return false; +} diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index f28599f895f3..2aefa7ab18da 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -2187,6 +2187,26 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar if (nR2 > nRow2) nR2 = nRow2; + const unsigned PERFORMANCEOPTIMIZATION4PATTERNTHRESHOLD = 8192; + bool bNeedPerformanceOptimization4Pattern = nRow2 - nRow1 > PERFORMANCEOPTIMIZATION4PATTERNTHRESHOLD; + std::vector< std::vector< SCSIZE > > vvPatternCount( bNeedPerformanceOptimization4Pattern ? nCol2 - nCol1 + 1 : 0 ); + std::vector< SCTAB > vTables; + + if( bNeedPerformanceOptimization4Pattern ) + { + for (SCTAB i = aCBFCP.nTabStart; i <= aCBFCP.nTabEnd; i++) + if (pTab[i] && rMark.GetTableSelect( i ) ) + vTables.push_back( i ); + + for( SCSIZE i = 0; i < vvPatternCount.size(); i++ ) + { + vvPatternCount[i].resize( vTables.size() ); + + for( std::vector< SCTAB >::size_type j = 0; j<vTables.size(); j++ ) + vvPatternCount[i][j] = this->GetPatternCount( vTables[j], nCol1+i ); + } + } + do { // Pasting is done column-wise, when pasting to a filtered @@ -2223,6 +2243,21 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar nC2 = nC1 + nXw; if (nC2 > nCol2) nC2 = nCol2; + + if( bNeedPerformanceOptimization4Pattern && vvPatternCount.size() ) + { + for( SCSIZE i = 0; i < vvPatternCount.size(); i++ ) + { + vvPatternCount[i].resize( vTables.size() ); + + for( std::vector< SCTAB >::size_type j = 0; j<vTables.size(); j++ ) + this->ReservedPatternCount( vTables[j], nCol1+i, vvPatternCount[i][j] + ( this->GetPatternCount( vTables[j], nCol1+i, nR1, nR2 ) ) * ( ( nRow2 - nRow1 + 1 ) / ( nYw + 1 ) ) ); + } + + bNeedPerformanceOptimization4Pattern = false; + vvPatternCount.clear(); + } + nR1 = nR2 + 1; nR2 = Min((SCROW)(nR1 + nYw), nRow2); } while (nR1 <= nRow2); diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 185b75aa8cbf..d419d6d8cd25 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -2024,8 +2024,26 @@ void ScTable::CompileColRowNameFormula() for (SCCOL i=0; i<=MAXCOL; i++) aCol[i].CompileColRowNameFormula(); } +SCSIZE ScTable::GetPatternCount( SCCOL nCol ) +{ + if( ValidCol( nCol ) ) + return aCol[nCol].GetPatternCount(); + else + return 0; +} +SCSIZE ScTable::GetPatternCount( SCCOL nCol, SCROW nRw1, SCROW nRw2 ) +{ + if( ValidCol( nCol ) && ValidRow( nRw1 ) && ValidRow( nRw2 ) ) + return aCol[nCol].GetPatternCount( nRw1, nRw2 ); + else + return 0; +} - - - +bool ScTable::ReservedPatternCount( SCCOL nCol, SCSIZE nReserved ) +{ + if( ValidCol( nCol ) ) + return aCol[nCol].ReservedPatternCount( nReserved ); + else + return false; +} |