summaryrefslogtreecommitdiff
path: root/sc/source/core/data/column4.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/data/column4.cxx')
-rw-r--r--sc/source/core/data/column4.cxx93
1 files changed, 78 insertions, 15 deletions
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index fc4c3a5e38e2..bbae4747a13e 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -100,6 +100,50 @@ void ScColumn::DeleteBeforeCopyFromClip(
if (!rDocument.ValidRow(aRange.mnRow1) || !rDocument.ValidRow(aRange.mnRow2))
return;
+ sc::ColumnBlockPosition* pBlockPos = rCxt.getBlockPosition(nTab, nCol);
+ if (!pBlockPos)
+ return;
+
+ InsertDeleteFlags nDelFlag = rCxt.getDeleteFlag();
+
+ if (!rCxt.isSkipEmptyCells())
+ {
+ // Delete the whole destination range.
+
+ if (nDelFlag & InsertDeleteFlags::CONTENTS)
+ {
+ sc::SingleColumnSpanSet aDeletedRows(GetDoc().GetSheetLimits());
+ DeleteCells(*pBlockPos, aRange.mnRow1, aRange.mnRow2, nDelFlag, aDeletedRows);
+ rBroadcastSpans.set(GetDoc(), nTab, nCol, aDeletedRows, true);
+ }
+
+ if (nDelFlag & InsertDeleteFlags::NOTE)
+ DeleteCellNotes(*pBlockPos, aRange.mnRow1, aRange.mnRow2, false);
+
+ if (nDelFlag & InsertDeleteFlags::EDITATTR)
+ RemoveEditAttribs(*pBlockPos, aRange.mnRow1, aRange.mnRow2);
+
+ if (nDelFlag & InsertDeleteFlags::ATTRIB)
+ {
+ pAttrArray->DeleteArea(aRange.mnRow1, aRange.mnRow2);
+
+ if (rCxt.isTableProtected())
+ {
+ ScPatternAttr aPattern(rDocument.GetPool());
+ aPattern.GetItemSet().Put(ScProtectionAttr(false));
+ ApplyPatternArea(aRange.mnRow1, aRange.mnRow2, aPattern);
+ }
+
+ ScConditionalFormatList* pCondList = rCxt.getCondFormatList();
+ if (pCondList)
+ pCondList->DeleteArea(nCol, aRange.mnRow1, nCol, aRange.mnRow2);
+ }
+ else if ((nDelFlag & InsertDeleteFlags::HARDATTR) == InsertDeleteFlags::HARDATTR)
+ pAttrArray->DeleteHardAttr(aRange.mnRow1, aRange.mnRow2);
+
+ return;
+ }
+
ScRange aClipRange = rCxt.getClipDoc()->GetClipParam().getWholeRange();
SCROW nClipRow1 = aClipRange.aStart.Row();
SCROW nClipRow2 = aClipRange.aEnd.Row();
@@ -149,10 +193,6 @@ void ScColumn::DeleteBeforeCopyFromClip(
nDestOffset += nClipRowLen;
}
- InsertDeleteFlags nDelFlag = rCxt.getDeleteFlag();
- sc::ColumnBlockPosition aBlockPos;
- InitBlockPosition(aBlockPos);
-
for (const auto& rDestSpan : aDestSpans)
{
SCROW nRow1 = rDestSpan.mnRow1;
@@ -161,15 +201,15 @@ void ScColumn::DeleteBeforeCopyFromClip(
if (nDelFlag & InsertDeleteFlags::CONTENTS)
{
sc::SingleColumnSpanSet aDeletedRows(GetDoc().GetSheetLimits());
- DeleteCells(aBlockPos, nRow1, nRow2, nDelFlag, aDeletedRows);
+ DeleteCells(*pBlockPos, nRow1, nRow2, nDelFlag, aDeletedRows);
rBroadcastSpans.set(GetDoc(), nTab, nCol, aDeletedRows, true);
}
if (nDelFlag & InsertDeleteFlags::NOTE)
- DeleteCellNotes(aBlockPos, nRow1, nRow2, false);
+ DeleteCellNotes(*pBlockPos, nRow1, nRow2, false);
if (nDelFlag & InsertDeleteFlags::EDITATTR)
- RemoveEditAttribs(nRow1, nRow2);
+ RemoveEditAttribs(*pBlockPos, nRow1, nRow2);
// Delete attributes just now
if (nDelFlag & InsertDeleteFlags::ATTRIB)
@@ -211,7 +251,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1,
if ((nFlags & InsertDeleteFlags::ATTRIB) != InsertDeleteFlags::NONE)
{
- if (!rCxt.isSkipAttrForEmptyCells() || rSrcCell.meType != CELLTYPE_NONE)
+ if (!rCxt.isSkipEmptyCells() || rSrcCell.meType != CELLTYPE_NONE)
{
const ScPatternAttr* pAttr = (bSameDocPool ? rCxt.getSingleCellPattern(nColOffset) :
rCxt.getSingleCellPattern(nColOffset)->PutInPool( &rDocument, rCxt.getClipDoc()));
@@ -277,7 +317,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1,
std::vector<sc::RowSpan> aRanges;
aRanges.reserve(1);
aRanges.emplace_back(nRow1, nRow2);
- CloneFormulaCell(*rSrcCell.mpFormula, rSrcAttr, aRanges);
+ CloneFormulaCell(*pBlockPos, *rSrcCell.mpFormula, rSrcAttr, aRanges);
}
break;
default:
@@ -536,12 +576,10 @@ void ScColumn::DeleteRanges( const std::vector<sc::RowSpan>& rRanges, InsertDele
}
void ScColumn::CloneFormulaCell(
+ sc::ColumnBlockPosition& rBlockPos,
const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr,
const std::vector<sc::RowSpan>& rRanges )
{
- sc::CellStoreType::iterator itPos = maCells.begin();
- sc::CellTextAttrStoreType::iterator itAttrPos = maCellTextAttrs.begin();
-
SCCOL nMatrixCols = 0;
SCROW nMatrixRows = 0;
ScMatrixMode nMatrixFlag = rSrc.GetMatrixFlag();
@@ -594,10 +632,10 @@ void ScColumn::CloneFormulaCell(
}
}
- itPos = maCells.set(itPos, nRow1, aFormulas.begin(), aFormulas.end());
+ rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow1, aFormulas.begin(), aFormulas.end());
// Join the top and bottom of the pasted formula cells as needed.
- sc::CellStoreType::position_type aPosObj = maCells.position(itPos, nRow1);
+ sc::CellStoreType::position_type aPosObj = maCells.position(rBlockPos.miCellPos, nRow1);
assert(aPosObj.first->type == sc::element_type_formula);
ScFormulaCell* pCell = sc::formula_block::at(*aPosObj.first->data, aPosObj.second);
@@ -609,12 +647,22 @@ void ScColumn::CloneFormulaCell(
JoinNewFormulaCell(aPosObj, *pCell);
std::vector<sc::CellTextAttr> aTextAttrs(nLen, rAttr);
- itAttrPos = maCellTextAttrs.set(itAttrPos, nRow1, aTextAttrs.begin(), aTextAttrs.end());
+ rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
+ rBlockPos.miCellTextAttrPos, nRow1, aTextAttrs.begin(), aTextAttrs.end());
}
CellStorageModified();
}
+void ScColumn::CloneFormulaCell(
+ const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr,
+ const std::vector<sc::RowSpan>& rRanges )
+{
+ sc::ColumnBlockPosition aBlockPos;
+ InitBlockPosition(aBlockPos);
+ CloneFormulaCell(aBlockPos, rSrc, rAttr, rRanges);
+}
+
std::unique_ptr<ScPostIt> ScColumn::ReleaseNote( SCROW nRow )
{
if (!GetDoc().ValidRow(nRow))
@@ -2098,4 +2146,19 @@ void ScColumn::RestoreFromCache(SvStream& rStrm)
}
}
+void ScColumn::CheckIntegrity() const
+{
+ const ScColumn* pColTest = maCells.event_handler().getColumn();
+
+ if (pColTest != this)
+ {
+ std::ostringstream os;
+ os << "cell store's event handler references wrong column instance (this=" << this
+ << "; stored=" << pColTest << ")";
+ throw std::runtime_error(os.str());
+ }
+
+ // Add more integrity checks as needed.
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */