From 4a00c3d74cd2d0d9905224b8f781dcb8d2ff3f1e Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Sat, 21 Jan 2012 00:08:29 -0500 Subject: fdo#44831: Named range should overwrite existing name. When inserting a new named range, it should overwrite any existing name if one exists. That was the old behavior in 3.3 prior to my range name rework, and because of ptr_map not overwriting existing key, that behavior had changed unintentionally. Let's revert to the old behavior. --- sc/inc/rangenam.hxx | 2 +- sc/source/core/tool/rangenam.cxx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'sc') diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx index 0e8de43fc025..ce0e2082e999 100644 --- a/sc/inc/rangenam.hxx +++ b/sc/inc/rangenam.hxx @@ -222,7 +222,7 @@ public: SC_DLLPUBLIC size_t size() const; bool empty() const; - /** Insert object into set if not a duplicate. + /** Insert object into set. @ATTENTION: The underlying ::boost::ptr_set_adapter::insert(p) takes ownership of p and if it can't insert it deletes the object! So, if this insert here returns false the object where p pointed to is gone! diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index 8ebcc7655485..214c17b06f80 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -894,6 +894,7 @@ bool ScRangeName::insert(ScRangeData* p) } rtl::OUString aName(p->GetUpperName()); + maData.erase(aName); // ptr_map won't insert it if a duplicate name exists. pair r = maData.insert(aName, p); if (r.second) { -- cgit