summaryrefslogtreecommitdiff
path: root/sc/source/core/data/conditio.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-13 22:46:17 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-05-13 22:47:37 -0400
commit146f6e7e68ea56f79b72047b97bd9fba66db499d (patch)
tree5733d2a341dfe33bc489a867e21fd80e303e60c9 /sc/source/core/data/conditio.cxx
parentdff4725f0dbb3bd7c32155e51ba49c05ee104d4f (diff)
fdo#76710: Adjust sheet position of conditional format entries.
When inserting or deleting sheets. Change-Id: Ibf898350e22f092ec38b75ad98957832a5580e6a
Diffstat (limited to 'sc/source/core/data/conditio.cxx')
-rw-r--r--sc/source/core/data/conditio.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 49f2fead4788..80a2b53c26dd 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -2002,12 +2002,49 @@ void ScConditionalFormat::InsertCol(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd,
void ScConditionalFormat::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt )
{
+ for (size_t i = 0, n = maRanges.size(); i < n; ++i)
+ {
+ // We assume that the start and end sheet indices are equal.
+ ScRange* pRange = maRanges[i];
+ SCTAB nTab = pRange->aStart.Tab();
+
+ if (nTab < rCxt.mnInsertPos)
+ // Unaffected.
+ continue;
+
+ pRange->aStart.IncTab(rCxt.mnSheets);
+ pRange->aEnd.IncTab(rCxt.mnSheets);
+ }
+
for (CondFormatContainer::iterator it = maEntries.begin(); it != maEntries.end(); ++it)
it->UpdateInsertTab(rCxt);
}
void ScConditionalFormat::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt )
{
+ for (size_t i = 0, n = maRanges.size(); i < n; ++i)
+ {
+ // We assume that the start and end sheet indices are equal.
+ ScRange* pRange = maRanges[i];
+ SCTAB nTab = pRange->aStart.Tab();
+
+ if (nTab < rCxt.mnDeletePos)
+ // Left of the deleted sheet(s). Unaffected.
+ continue;
+
+ if (nTab <= rCxt.mnDeletePos+rCxt.mnSheets-1)
+ {
+ // On the deleted sheet(s).
+ pRange->aStart.SetTab(-1);
+ pRange->aEnd.SetTab(-1);
+ continue;
+ }
+
+ // Right of the deleted sheet(s). Adjust the sheet indices.
+ pRange->aStart.IncTab(-1*rCxt.mnSheets);
+ pRange->aEnd.IncTab(-1*rCxt.mnSheets);
+ }
+
for (CondFormatContainer::iterator it = maEntries.begin(); it != maEntries.end(); ++it)
it->UpdateDeleteTab(rCxt);
}