diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-09-05 13:05:53 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-09-05 14:36:55 +0200 |
commit | 5d9e062a68eaf7544d02501d7b221150d74f7555 (patch) | |
tree | 2dc3c1dfae3e2eab701875240c36e2d59a2dc278 /sc/source/core/tool/rangelst.cxx | |
parent | dcc05d40c6fdb41a4193072d6b72456d75269ba3 (diff) |
increase conditional format range during inserting rows/cols, fdo#67783
Change-Id: Ib74667fb958aa9bbbcae3a0289b3cbd6edf8fb37
Diffstat (limited to 'sc/source/core/tool/rangelst.cxx')
-rw-r--r-- | sc/source/core/tool/rangelst.cxx | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx index 8abb3474eee2..00a9ca025dca 100644 --- a/sc/source/core/tool/rangelst.cxx +++ b/sc/source/core/tool/rangelst.cxx @@ -459,6 +459,68 @@ bool ScRangeList::UpdateReference( return bChanged; } +void ScRangeList::InsertRow( SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, SCROW nRowPos, SCSIZE nSize ) +{ + std::vector<ScRange> aNewRanges; + for(iterator it = maRanges.begin(), itEnd = maRanges.end(); it != itEnd; + ++it) + { + ScRange* pRange = *it; + if(pRange->aStart.Tab() <= nTab && pRange->aEnd.Tab() >= nTab) + { + if(pRange->aEnd.Row() == nRowPos - 1 && (nColStart <= pRange->aEnd.Col() || nColEnd >= pRange->aStart.Col())) + { + SCCOL nNewRangeStartCol = std::max<SCCOL>(nColStart, pRange->aStart.Col()); + SCCOL nNewRangeEndCol = std::min<SCCOL>(nColEnd, pRange->aEnd.Col()); + SCROW nNewRangeStartRow = pRange->aEnd.Row() + 1; + SCROW nNewRangeEndRow = nRowPos + nSize - 1; + aNewRanges.push_back(ScRange(nNewRangeStartCol, nNewRangeStartRow, nTab, nNewRangeEndCol, + nNewRangeEndRow, nTab)); + } + } + } + + for(std::vector<ScRange>::const_iterator it = aNewRanges.begin(), itEnd = aNewRanges.end(); + it != itEnd; ++it) + { + if(!it->IsValid()) + continue; + + Join(*it); + } +} + +void ScRangeList::InsertCol( SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, SCCOL nColPos, SCSIZE nSize ) +{ + std::vector<ScRange> aNewRanges; + for(iterator it = maRanges.begin(), itEnd = maRanges.end(); it != itEnd; + ++it) + { + ScRange* pRange = *it; + if(pRange->aStart.Tab() <= nTab && pRange->aEnd.Tab() >= nTab) + { + if(pRange->aEnd.Col() == nColPos - 1 && (nRowStart <= pRange->aEnd.Row() || nRowEnd >= pRange->aStart.Row())) + { + SCROW nNewRangeStartRow = std::max<SCROW>(nRowStart, pRange->aStart.Row()); + SCROW nNewRangeEndRow = std::min<SCROW>(nRowEnd, pRange->aEnd.Row()); + SCCOL nNewRangeStartCol = pRange->aEnd.Col() + 1; + SCCOL nNewRangeEndCol = nColPos + nSize - 1; + aNewRanges.push_back(ScRange(nNewRangeStartCol, nNewRangeStartRow, nTab, nNewRangeEndCol, + nNewRangeEndRow, nTab)); + } + } + } + + for(std::vector<ScRange>::const_iterator it = aNewRanges.begin(), itEnd = aNewRanges.end(); + it != itEnd; ++it) + { + if(!it->IsValid()) + continue; + + Join(*it); + } +} + namespace { /** |