[Libreoffice-commits] core.git: Branch 'private/kohei/calc-shared-string' - 2 commits - editeng/source include/editeng include/svl sc/inc sc/source svl/Library_svl.mk svl/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Oct 1 18:51:06 PDT 2013
editeng/source/editeng/editobj.cxx | 21 +++++++++++++++++++++
editeng/source/editeng/editobj2.hxx | 10 ++++++++++
include/editeng/editobj.hxx | 13 +++++++++++++
include/svl/stringpool.hxx | 34 ++++++++++++++++++++++++++++++++++
sc/inc/formulagroup.hxx | 7 +++----
sc/source/core/data/column2.cxx | 8 ++++----
sc/source/core/tool/formulagroup.cxx | 17 -----------------
svl/Library_svl.mk | 1 +
svl/source/misc/stringpool.cxx | 35 +++++++++++++++++++++++++++++++++++
9 files changed, 121 insertions(+), 25 deletions(-)
New commits:
commit 19f7989c1689b009d1cd15e88d2b5386ee23165c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 1 21:51:50 2013 -0400
Add method to normalize strings in EditTextObject.
Change-Id: I1adb57279db0afeb8387599ec11984380e5a2e4a
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 8e35a57..aaf5e5f 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -44,6 +44,7 @@
#include <vcl/graph.hxx>
#include <svl/intitem.hxx>
+#include "svl/stringpool.hxx"
#include <unotools/fontcvt.hxx>
#include <tools/tenccvt.hxx>
@@ -148,6 +149,11 @@ ContentInfo::~ContentInfo()
aAttribs.clear();
}
+void ContentInfo::NormalizeString( svl::StringPool& rPool )
+{
+ aText = OUString(rPool.intern(aText));
+}
+
const WrongList* ContentInfo::GetWrongList() const
{
return mpWrongs.get();
@@ -316,6 +322,11 @@ editeng::FieldUpdater EditTextObject::GetFieldUpdater()
return mpImpl->GetFieldUpdater();
}
+void EditTextObject::NormalizeString( svl::StringPool& rPool )
+{
+ mpImpl->NormalizeString(rPool);
+}
+
const SfxItemPool* EditTextObject::GetPool() const
{
return mpImpl->GetPool();
@@ -602,6 +613,16 @@ void EditTextObjectImpl::SetUserType( sal_uInt16 n )
nUserType = n;
}
+void EditTextObjectImpl::NormalizeString( svl::StringPool& rPool )
+{
+ ContentInfosType::iterator it = aContents.begin(), itEnd = aContents.end();
+ for (; it != itEnd; ++it)
+ {
+ ContentInfo& rInfo = *it;
+ rInfo.NormalizeString(rPool);
+ }
+}
+
bool EditTextObjectImpl::IsVertical() const
{
return bVertical;
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index b704e48..c331134 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -35,6 +35,12 @@ struct Section;
}
+namespace svl {
+
+class StringPool;
+
+}
+
class XEditAttribute
{
private:
@@ -136,6 +142,8 @@ private:
public:
~ContentInfo();
+ void NormalizeString( svl::StringPool& rPool );
+
const XEditAttributesType& GetAttribs() const { return aAttribs; }
XEditAttributesType& GetAttribs() { return aAttribs; }
@@ -198,6 +206,8 @@ public:
sal_uInt16 GetUserType() const;
void SetUserType( sal_uInt16 n );
+ void NormalizeString( svl::StringPool& rPool );
+
bool IsVertical() const;
void SetVertical( bool b );
diff --git a/include/editeng/editobj.hxx b/include/editeng/editobj.hxx
index cdb8fbb..36392e2 100644
--- a/include/editeng/editobj.hxx
+++ b/include/editeng/editobj.hxx
@@ -49,6 +49,12 @@ struct Section;
}
+namespace svl {
+
+class StringPool;
+
+}
+
class EditTextObjectImpl;
class EDITENG_DLLPUBLIC EditTextObject : public SfxItemPoolUser
@@ -72,6 +78,13 @@ public:
EditTextObject( const EditTextObject& r );
virtual ~EditTextObject();
+ /**
+ * Set paragraph strings to the shared string pool.
+ *
+ * @param rPool shared string pool.
+ */
+ void NormalizeString( svl::StringPool& rPool );
+
const SfxItemPool* GetPool() const;
sal_uInt16 GetUserType() const; // For OutlinerMode, it can however not save in compatible format
void SetUserType( sal_uInt16 n );
commit 703f13ca8545271c5b4265d4e9ff18f751f30d9f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 1 20:57:56 2013 -0400
Move this string pool code to svl.
Change-Id: I1379fbc377607be8831133d64db2e14f8c75bff8
diff --git a/include/svl/stringpool.hxx b/include/svl/stringpool.hxx
new file mode 100644
index 0000000..643c846
--- /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 e7c13cd..a8d20bb 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 eda83ff..9601583 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 677ac9f..98ae0b4 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 277be91..eddabf0 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 0000000..f8ddda9
--- /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: */
More information about the Libreoffice-commits
mailing list