Author: steve_y Date: Fri Jan 3 08:48:02 2014 New Revision: 1555031 URL: http://svn.apache.org/r1555031 Log: Bug 123909 - Select one column, paste cell range with merged cell in, AOO will be not responding
Modified: openoffice/trunk/main/sc/inc/attarray.hxx openoffice/trunk/main/sc/inc/column.hxx openoffice/trunk/main/sc/inc/document.hxx openoffice/trunk/main/sc/inc/table.hxx openoffice/trunk/main/sc/source/core/data/attarray.cxx openoffice/trunk/main/sc/source/core/data/column2.cxx openoffice/trunk/main/sc/source/core/data/documen3.cxx openoffice/trunk/main/sc/source/core/data/document.cxx openoffice/trunk/main/sc/source/core/data/table4.cxx Modified: openoffice/trunk/main/sc/inc/attarray.hxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/inc/attarray.hxx?rev=1555031&r1=1555030&r2=1555031&view=diff ============================================================================== --- openoffice/trunk/main/sc/inc/attarray.hxx (original) +++ openoffice/trunk/main/sc/inc/attarray.hxx Fri Jan 3 08:48:02 2014 @@ -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 ); }; Modified: openoffice/trunk/main/sc/inc/column.hxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/inc/column.hxx?rev=1555031&r1=1555030&r2=1555031&view=diff ============================================================================== --- openoffice/trunk/main/sc/inc/column.hxx (original) +++ openoffice/trunk/main/sc/inc/column.hxx Fri Jan 3 08:48:02 2014 @@ -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 ); Modified: openoffice/trunk/main/sc/inc/document.hxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/inc/document.hxx?rev=1555031&r1=1555030&r2=1555031&view=diff ============================================================================== --- openoffice/trunk/main/sc/inc/document.hxx (original) +++ openoffice/trunk/main/sc/inc/document.hxx Fri Jan 3 08:48:02 2014 @@ -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 ) { Modified: openoffice/trunk/main/sc/inc/table.hxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/inc/table.hxx?rev=1555031&r1=1555030&r2=1555031&view=diff ============================================================================== --- openoffice/trunk/main/sc/inc/table.hxx (original) +++ openoffice/trunk/main/sc/inc/table.hxx Fri Jan 3 08:48:02 2014 @@ -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 ); Modified: openoffice/trunk/main/sc/source/core/data/attarray.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/core/data/attarray.cxx?rev=1555031&r1=1555030&r2=1555031&view=diff ============================================================================== --- openoffice/trunk/main/sc/source/core/data/attarray.cxx (original) +++ openoffice/trunk/main/sc/source/core/data/attarray.cxx Fri Jan 3 08:48:02 2014 @@ -295,6 +295,24 @@ void ScAttrArray::SetPattern( SCROW nRow 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& /* rSt //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; +} Modified: openoffice/trunk/main/sc/source/core/data/column2.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/core/data/column2.cxx?rev=1555031&r1=1555030&r2=1555031&view=diff ============================================================================== --- openoffice/trunk/main/sc/source/core/data/column2.cxx (original) +++ openoffice/trunk/main/sc/source/core/data/column2.cxx Fri Jan 3 08:48:02 2014 @@ -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; +} Modified: openoffice/trunk/main/sc/source/core/data/documen3.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/core/data/documen3.cxx?rev=1555031&r1=1555030&r2=1555031&view=diff ============================================================================== --- openoffice/trunk/main/sc/source/core/data/documen3.cxx (original) +++ openoffice/trunk/main/sc/source/core/data/documen3.cxx Fri Jan 3 08:48:02 2014 @@ -2149,3 +2149,27 @@ void ScDocument::GetUsedDPObjectCache( s } } // 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; +} Modified: openoffice/trunk/main/sc/source/core/data/document.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/core/data/document.cxx?rev=1555031&r1=1555030&r2=1555031&view=diff ============================================================================== --- openoffice/trunk/main/sc/source/core/data/document.cxx (original) +++ openoffice/trunk/main/sc/source/core/data/document.cxx Fri Jan 3 08:48:02 2014 @@ -2187,6 +2187,26 @@ void ScDocument::CopyFromClip( const ScR 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 ScR 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); Modified: openoffice/trunk/main/sc/source/core/data/table4.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/core/data/table4.cxx?rev=1555031&r1=1555030&r2=1555031&view=diff ============================================================================== --- openoffice/trunk/main/sc/source/core/data/table4.cxx (original) +++ openoffice/trunk/main/sc/source/core/data/table4.cxx Fri Jan 3 08:48:02 2014 @@ -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; +}