summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-07-13 08:17:26 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-07-13 08:34:41 +0200
commit902082656655aeab559c0b5781907ff004179468 (patch)
treed6c316c31816bfd68abbcc05dd22803d8743053c /sc/source
parent68eb65f19d4f3fb564ac993e8b2f37fb33d685c3 (diff)
don't delete ScPatternAttr from doc pool for swap, i#118877
the original apache commit is quite ugly and should not be used!! Change-Id: Id02d2cf474e49b97bfe285fe76867d1b1d944ec3
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/attarray.cxx15
-rw-r--r--sc/source/core/data/column.cxx5
-rw-r--r--sc/source/core/data/table3.cxx6
3 files changed, 22 insertions, 4 deletions
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 6cf487fb612b..e166ea233c68 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -483,6 +483,21 @@ void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPattern
#endif
}
+void ScAttrArray::SwapPattern( ScAttrArray& rArray2, SCROW nRow1, SCROW nRow2, const ScPatternAttr* pPattern1, const ScPatternAttr* pPattern2)
+{
+ if(!VALIDROW(nRow1) || !VALIDROW(nRow2))
+ return;
+
+ SCSIZE nIndex1 = 0;
+ SCSIZE nIndex2 = 0;
+ Search(nRow1, nIndex1);
+ rArray2.Search(nRow2, nIndex2);
+ pData[nIndex1].pPattern = pPattern1;
+ rArray2.pData[nIndex2].pPattern = pPattern2;
+
+ if (pDocument->IsStreamValid(nTab))
+ pDocument->SetStreamValid(nTab, false);
+}
void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle )
{
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index db994622f3cb..adc5eb2c6074 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -652,6 +652,11 @@ void ScColumn::SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr, bool bPutT
pAttrArray->SetPattern( nRow, &rPatAttr, bPutToPool );
}
+void ScColumn::SwapPattern( ScColumn& rCol2, SCROW nRow1, SCROW nRow2, const ScPatternAttr& rPatAttr1, const ScPatternAttr& rPatAttr2 )
+{
+ pAttrArray->SwapPattern( *rCol2.pAttrArray, nRow1, nRow2, &rPatAttr1, &rPatAttr2 );
+}
+
void ScColumn::SetPatternArea( SCROW nStartRow, SCROW nEndRow,
const ScPatternAttr& rPatAttr, bool bPutToPool )
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 85354f3bb27d..6a140cdaf0a4 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -571,8 +571,7 @@ void ScTable::SwapCol(SCCOL nCol1, SCCOL nCol2)
const ScPatternAttr* pPat2 = GetPattern(nCol2, nRow);
if (pPat1 != pPat2)
{
- SetPattern(nCol1, nRow, *pPat2, true);
- SetPattern(nCol2, nRow, *pPat1, true);
+ aCol[nCol1].SwapPattern(aCol[nCol2], nRow, nRow, *pPat1, *pPat2);
}
}
}
@@ -623,8 +622,7 @@ void ScTable::SwapRow(SCROW nRow1, SCROW nRow2)
const ScPatternAttr* pPat2 = GetPattern(nCol, nRow2);
if (pPat1 != pPat2)
{
- SetPattern(nCol, nRow1, *pPat2, true);
- SetPattern(nCol, nRow2, *pPat1, true);
+ aCol[nCol].SwapPattern(aCol[nCol], nRow1, nRow2, *pPat1, *pPat2);
}
}
}