sc/source/core/data/conditio.cxx | 13 +++++++++++++ sc/source/core/tool/rangelst.cxx | 31 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
New commits: commit 73a465ed443e820974600ee291e21ed6413ecb9d Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Jul 24 08:54:58 2012 +0200 delete conditional format entries that are removed, fdo#52351 Change-Id: I9ab70d2b7a557ae5f717898edfb6c363343462f6 Signed-off-by: Kohei Yoshida <kohei.yosh...@gmail.com> Signed-off-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index a5ed065..97ffd61 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1650,6 +1650,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 16f9eca..88f9727 100644 --- a/sc/source/core/tool/rangelst.cxx +++ b/sc/source/core/tool/rangelst.cxx @@ -150,6 +150,29 @@ private: bool mbFirst; }; +class FindDeletedRange : public ::std::unary_function<const ScRange*, bool> +{ +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 ==================================================== @@ -384,6 +407,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) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits