summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-02-23 18:41:44 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-02-24 00:51:41 -0500
commitd473a3699befc388d49bdba491a543d88bcf0778 (patch)
tree45bec6fd52621619476574eb3a4b66eb48bd67f3 /sc
parent513edaa41ddb4dfdf6e3ec1efd44f56ff959ef26 (diff)
Modify dup count correctly when dimensions are removed.
Though normally dimensions don't get removed, since the entire save data gets re-built whenever the pivot model is modified. So, this is probably for limited use cases...
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/dputil.hxx2
-rw-r--r--sc/source/core/data/dpsave.cxx23
-rw-r--r--sc/source/core/data/dputil.cxx12
3 files changed, 31 insertions, 6 deletions
diff --git a/sc/inc/dputil.hxx b/sc/inc/dputil.hxx
index d33d344b6bcb..46ffa6b24cfe 100644
--- a/sc/inc/dputil.hxx
+++ b/sc/inc/dputil.hxx
@@ -37,6 +37,8 @@ public:
static bool isDuplicateDimension(const rtl::OUString& rName);
static rtl::OUString getSourceDimensionName(const rtl::OUString& rName);
+
+ static rtl::OUString createDuplicateDimensionName(const rtl::OUString& rOriginal, size_t nDupCount);
};
#endif
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index ef8cb5e1255c..ec466049012e 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -1277,12 +1277,7 @@ void ScDPSaveData::CheckDuplicateName(ScDPSaveDimension& rDim)
DupNameCountType::iterator it = maDupNameCounts.find(aName);
if (it != maDupNameCounts.end())
{
- it->second = it->second + 1;
- // This is a duplicate name. Up the counter and append '*' to make the name unique.
- rtl::OUStringBuffer aBuf(aName);
- for (size_t i = 0, n = it->second; i < n; ++i)
- aBuf.append(sal_Unicode('*'));
- rDim.SetName(aBuf.makeStringAndClear());
+ rDim.SetName(ScDPUtil::createDuplicateDimensionName(aName, ++it->second));
rDim.SetDupFlag(true);
}
else
@@ -1292,6 +1287,22 @@ void ScDPSaveData::CheckDuplicateName(ScDPSaveDimension& rDim)
void ScDPSaveData::RemoveDuplicateNameCount(const rtl::OUString& rName)
{
+ rtl::OUString aCoreName = rName;
+ if (ScDPUtil::isDuplicateDimension(rName))
+ aCoreName = ScDPUtil::getSourceDimensionName(rName);
+
+ DupNameCountType::iterator it = maDupNameCounts.find(aCoreName);
+ if (it == maDupNameCounts.end())
+ return;
+
+ if (!it->second)
+ {
+ maDupNameCounts.erase(it);
+ return;
+ }
+
+ --it->second;
+ return;
}
ScDPSaveDimension* ScDPSaveData::AppendNewDimension(const rtl::OUString& rName, bool bDataLayout)
diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx
index f04a5870a2aa..65a1ee51d297 100644
--- a/sc/source/core/data/dputil.cxx
+++ b/sc/source/core/data/dputil.cxx
@@ -44,4 +44,16 @@ rtl::OUString ScDPUtil::getSourceDimensionName(const rtl::OUString& rName)
return comphelper::string::removeTrailingChars(rName, sal_Unicode('*'));
}
+rtl::OUString ScDPUtil::createDuplicateDimensionName(const rtl::OUString& rOriginal, size_t nDupCount)
+{
+ if (!nDupCount)
+ return rOriginal;
+
+ rtl::OUStringBuffer aBuf(rOriginal);
+ for (size_t i = 0; i < nDupCount; ++i)
+ aBuf.append(sal_Unicode('*'));
+
+ return aBuf.makeStringAndClear();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */