summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svl/stringpool.hxx34
-rw-r--r--sc/inc/formulagroup.hxx7
-rw-r--r--sc/source/core/data/column2.cxx8
-rw-r--r--sc/source/core/tool/formulagroup.cxx17
-rw-r--r--svl/Library_svl.mk1
-rw-r--r--svl/source/misc/stringpool.cxx35
6 files changed, 77 insertions, 25 deletions
diff --git a/include/svl/stringpool.hxx b/include/svl/stringpool.hxx
new file mode 100644
index 000000000000..643c8466c0bc
--- /dev/null
+++ b/include/svl/stringpool.hxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SVL_STRINGPOOL_HXX
+#define SVL_STRINGPOOL_HXX
+
+#include "svl/svldllapi.h"
+#include "rtl/ustring.hxx"
+
+#include <boost/unordered_set.hpp>
+
+namespace svl {
+
+class SVL_DLLPUBLIC StringPool
+{
+ typedef boost::unordered_set<OUString, OUStringHash> StrHashType;
+ StrHashType maStrPool;
+public:
+ StringPool();
+
+ rtl_uString* intern( const OUString& rStr );
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index e7c13cd15562..a8d20bb9890a 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -14,6 +14,8 @@
#include "types.hxx"
#include "platforminfo.hxx"
+#include "svl/stringpool.hxx"
+
#include <vector>
#include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
@@ -26,17 +28,14 @@ namespace sc {
struct FormulaGroupContext : boost::noncopyable
{
- typedef boost::unordered_set<OUString, OUStringHash> StrHashType;
typedef std::vector<double> NumArrayType;
typedef std::vector<rtl_uString*> StrArrayType;
typedef boost::ptr_vector<NumArrayType> NumArrayStoreType;
typedef boost::ptr_vector<StrArrayType> StrArrayStoreType;
- StrHashType maStrPool;
+ svl::StringPool maStrPool;
NumArrayStoreType maNumArrays;
StrArrayStoreType maStrArrays;
-
- rtl_uString* intern( const OUString& rStr );
};
/**
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index eda83ffe7bbf..96015833f31b 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2174,7 +2174,7 @@ bool appendStrings(
getBlockIterators<sc::string_block>(it, nLenRemain, itData, itDataEnd);
for (; itData != itDataEnd; ++itData)
- rArray.push_back(rCxt.intern(*itData));
+ rArray.push_back(rCxt.maStrPool.intern(*itData));
}
break;
case sc::element_type_edittext:
@@ -2185,7 +2185,7 @@ bool appendStrings(
for (; itData != itDataEnd; ++itData)
{
OUString aStr = ScEditUtil::GetString(**itData, pDoc);
- rArray.push_back(rCxt.intern(aStr));
+ rArray.push_back(rCxt.maStrPool.intern(aStr));
}
}
break;
@@ -2210,7 +2210,7 @@ bool appendStrings(
return false;
}
- rArray.push_back(rCxt.intern(aStr));
+ rArray.push_back(rCxt.maStrPool.intern(aStr));
}
}
break;
@@ -2250,7 +2250,7 @@ void copyFirstBlock( sc::FormulaGroupContext& rCxt, size_t nLen, const sc::CellS
const OUString* p = &sc::string_block::at(*rPos.first->data, rPos.second);
const OUString* pEnd = p + nLen;
for (; p != pEnd; ++p)
- rArray.push_back(rCxt.intern(*p));
+ rArray.push_back(rCxt.maStrPool.intern(*p));
}
}
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 677ac9f9057e..98ae0b4aede5 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -38,23 +38,6 @@ extern "C" void compileOpenCLKernels(const OUString*);
namespace sc {
-rtl_uString* FormulaGroupContext::intern( const OUString& rStr )
-{
- StrHashType::iterator it = maStrPool.find(rStr);
- if (it == maStrPool.end())
- {
- // Not yet in the pool.
- std::pair<StrHashType::iterator, bool> r = maStrPool.insert(rStr.intern());
- if (!r.second)
- // Insertion failed.
- return NULL;
-
- it = r.first;
- }
-
- return it->pData;
-}
-
namespace {
/**
diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk
index 277be91d2f74..eddabf0a259d 100644
--- a/svl/Library_svl.mk
+++ b/svl/Library_svl.mk
@@ -110,6 +110,7 @@ $(eval $(call gb_Library_add_exception_objects,svl,\
svl/source/misc/lockfilecommon \
svl/source/misc/ownlist \
svl/source/misc/sharecontrolfile \
+ svl/source/misc/stringpool \
svl/source/misc/strmadpt \
svl/source/misc/urihelper \
svl/source/notify/brdcst \
diff --git a/svl/source/misc/stringpool.cxx b/svl/source/misc/stringpool.cxx
new file mode 100644
index 000000000000..f8ddda9b0acd
--- /dev/null
+++ b/svl/source/misc/stringpool.cxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "svl/stringpool.hxx"
+
+namespace svl {
+
+StringPool::StringPool() {}
+
+rtl_uString* StringPool::intern( const OUString& rStr )
+{
+ StrHashType::iterator it = maStrPool.find(rStr);
+ if (it == maStrPool.end())
+ {
+ // Not yet in the pool.
+ std::pair<StrHashType::iterator, bool> r = maStrPool.insert(rStr.intern());
+ if (!r.second)
+ // Insertion failed.
+ return NULL;
+
+ it = r.first;
+ }
+
+ return it->pData;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */