diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-05-13 22:46:17 -0400 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2014-05-16 15:20:02 +0000 |
commit | 5b76a0057a25966f48caed78bcff21b72fdbdda2 (patch) | |
tree | d6cbf03bf7bb7c441185498e0b7a0e3fb45b8408 | |
parent | f12631e960a2b4123c96e96d2af7d43741d8e6a5 (diff) |
fdo#76710: Adjust sheet position of conditional format entries.
When inserting or deleting sheets.
Change-Id: Ibf898350e22f092ec38b75ad98957832a5580e6a
(cherry picked from commit 146f6e7e68ea56f79b72047b97bd9fba66db499d)
Reviewed-on: https://gerrit.libreoffice.org/9350
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r-- | sc/source/core/data/conditio.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 5e8e5491fb03..602446ca9272 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -2004,12 +2004,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); } |