diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-07-24 08:54:58 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-07-25 20:11:51 +0200 |
commit | 76f56b5e8d4abf17682aa75b7cf183b883809234 (patch) | |
tree | 39e74817c8fc562281d22b34b91d862e91a8a541 /sc | |
parent | d619f3a6da2481c6739818a74a328df9ec2bd24d (diff) |
delete conditional format entries that are removed, fdo#52351
Change-Id: I9ab70d2b7a557ae5f717898edfb6c363343462f6
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/conditio.cxx | 13 | ||||
-rw-r--r-- | sc/source/core/tool/rangelst.cxx | 31 |
2 files changed, 44 insertions, 0 deletions
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 74448336ae2c..3d3611b0badd 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1588,6 +1588,19 @@ void ScConditionalFormatList::UpdateReference( UpdateRefMode eUpdateRefMode, { for( iterator itr = begin(); itr != end(); ++itr) itr->UpdateReference( eUpdateRefMode, rRange, nDx, nDy, nDz ); + + if( eUpdateRefMode == URM_INSDEL ) + { + // need to check which must be deleted + iterator itr = begin(); + while(itr != end()) + { + if(itr->GetRange().empty()) + maConditionalFormats.erase(itr++); + else + ++itr; + } + } } void ScConditionalFormatList::RenameCellStyle( const String& rOld, const String& rNew ) diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx index d2bdec33b640..4ff6ff0491d0 100644 --- a/sc/source/core/tool/rangelst.cxx +++ b/sc/source/core/tool/rangelst.cxx @@ -146,6 +146,29 @@ private: bool mbFirst; }; +class FindDeletedRange : public ::std::unary_function<bool, const ScRange*> +{ +public: + FindDeletedRange( SCsCOL nDx, SCsROW nDy): mnDx(nDx), mnDy(nDy) {} + FindDeletedRange( const FindDeletedRange& r) : mnDx(r.mnDx), mnDy(r.mnDy) {} + bool operator() (const ScRange* p) + { + ScAddress rStart = p->aStart; + ScAddress rEnd = p->aEnd; + + if( rEnd.Col() +mnDx < rStart.Col() ) + return true; + if( rEnd.Row() + mnDy < rStart.Row() ) + return true; + + return false; + } + +private: + SCsCOL mnDx; + SCsROW mnDy; +}; + } // === ScRangeList ==================================================== @@ -380,6 +403,14 @@ bool ScRangeList::UpdateReference( SCTAB nTab2; rWhere.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); + // delete all entries that are fully deleted + if( eUpdateRefMode == URM_INSDEL && (nDx < 0 || nDy < 0) ) + { + vector<ScRange*>::iterator itr = std::remove_if(maRanges.begin(), maRanges.end(), FindDeletedRange(nDx, nDy)); + for_each(itr, maRanges.end(), ScDeleteObjectByPtr<ScRange>()); + maRanges.erase(itr, maRanges.end()); + } + vector<ScRange*>::iterator itr = maRanges.begin(), itrEnd = maRanges.end(); for (; itr != itrEnd; ++itr) { |