summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-07-24 08:54:58 +0200
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-08-06 12:16:20 -0400
commit73a465ed443e820974600ee291e21ed6413ecb9d (patch)
tree3bbfb78774b73899a6fc0003f07d70e9e6ee19e8 /sc
parent38d7b11915c9c4e5fcebcb7eb3ae1b2846b26267 (diff)
delete conditional format entries that are removed, fdo#52351
Change-Id: I9ab70d2b7a557ae5f717898edfb6c363343462f6 Signed-off-by: Kohei Yoshida <kohei.yoshida@gmail.com> Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/conditio.cxx13
-rw-r--r--sc/source/core/tool/rangelst.cxx31
2 files changed, 44 insertions, 0 deletions
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index a5ed065141af..97ffd6122d3b 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 16f9eca9c4c9..88f9727ad926 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)
{