summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Yin <steve_y@apache.org>2014-01-03 08:48:02 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-01-03 14:00:20 +0000
commit6b8704d974abd4ab7fb58036a961fa0b7136aaa7 (patch)
tree2ad6cfca91976a6fbedda63a2589647c939e66b3
parent1cedea0eef581bccb5767bca49875261d2308326 (diff)
Resolves: #i123909# Select one column, paste cell range...
with merged cell in, no response (cherry picked from commit acc76cb44c51fbefc8f34009300acb9382c3ad27) Conflicts: sc/inc/attarray.hxx sc/inc/column.hxx sc/inc/document.hxx sc/source/core/data/attarray.cxx sc/source/core/data/column2.cxx sc/source/core/data/documen3.cxx sc/source/core/data/document.cxx sc/source/core/data/table4.cxx Change-Id: Id9c1e0fe86876da6e39ea2b34a484d69eb5d8633
-rw-r--r--sc/inc/attarray.hxx5
-rw-r--r--sc/inc/column.hxx3
-rw-r--r--sc/inc/document.hxx3
-rw-r--r--sc/inc/table.hxx3
-rw-r--r--sc/source/core/data/attarray.cxx32
-rw-r--r--sc/source/core/data/column2.cxx13
-rw-r--r--sc/source/core/data/documen3.cxx24
-rw-r--r--sc/source/core/data/document.cxx35
-rw-r--r--sc/source/core/data/table4.cxx23
9 files changed, 138 insertions, 3 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index c4f514bf145f..c2789b3013f7 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -187,6 +187,11 @@ public:
SCROW nStartRow, SCROW nEndRow, long nDy, ScAttrArray& rAttrArray, sal_Int16 nStripFlags = 0) const;
void DeleteHardAttr( SCROW nStartRow, SCROW nEndRow );
+
+ /* 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 );
};
// Iterator for attributes
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index b7f48db2c39f..6ec33360b2c3 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -541,6 +541,9 @@ public:
void DumpFormulaGroups() const;
#endif
+ SCSIZE GetPatternCount( );
+ SCSIZE GetPatternCount( SCROW nRw1, SCROW nRw2 );
+ bool ReservedPatternCount( SCSIZE nReserved );
private:
sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 8d528301fb01..95443b5d9745 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2108,6 +2108,9 @@ private: // CLOOK-Impl-methods
std::map< SCTAB, ScSortParam > mSheetSortParams;
+ 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 1a80f909b824..09d541b304d6 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -346,6 +346,9 @@ public:
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 SetRawString( SCCOL nCol, SCROW nRow, const OUString& rStr );
void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index cee38bb8823d..2bfccee1ef15 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -376,6 +376,25 @@ void ScAttrArray::RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow,
}
}
+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,
bool bPutToPool, ScEditDataArray* pDataArray )
{
@@ -2439,4 +2458,17 @@ bool ScAttrArray::SearchStyleRange(
return false;
}
+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;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 2092406b54b7..60b7b42ab0f7 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -3523,8 +3523,19 @@ sal_uInt32 ScColumn::GetCodeCount() const
return aFunc.getCount();
}
+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;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index e76b78ccd7dd..0b681386341d 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -2016,4 +2016,28 @@ void ScDocument::ExtendPrintArea( OutputDevice* pDev, SCTAB nTab,
maTabs[nTab]->ExtendPrintArea( pDev, nStartCol, nStartRow, rEndCol, nEndRow );
}
+SCSIZE ScDocument::GetPatternCount( SCTAB nTab, SCCOL nCol )
+{
+ if( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
+ return maTabs[nTab]->GetPatternCount( nCol );
+ else
+ return 0;
+}
+
+SCSIZE ScDocument::GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRw1, SCROW nRw2 )
+{
+ if( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
+ return maTabs[nTab]->GetPatternCount( nCol, nRw1, nRw2 );
+ else
+ return 0;
+}
+
+bool ScDocument::ReservedPatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserved )
+{
+ if( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
+ return maTabs[nTab]->ReservedPatternCount( nCol, nReserved );
+ else
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9f36896206b4..3ed9907a65d7 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2698,6 +2698,26 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
if (nR2 > nRow2)
nR2 = nRow2;
+ const SCCOLROW 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 = aCxt.getTabStart(); i <= aCxt.getTabEnd(); ++i)
+ if (maTabs[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
@@ -2731,6 +2751,21 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
nC2 = nC1 + nXw;
if (nC2 > nCol2)
nC2 = nCol2;
+
+ if (bNeedPerformanceOptimization4Pattern && !vvPatternCount.empty())
+ {
+ 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 = std::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 b7112bbc661b..3afef713bb4f 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -2076,9 +2076,28 @@ 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;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */