summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-06 11:22:05 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-06 18:38:22 +0200
commita7ff945ca031324f060b0d989f7a89594fcfe9fe (patch)
treeee502330c3e52c59aa2a4c5d97b6307c5a6babe5 /sc/source/core
parent6668b112b341edd24ca77ba88b834108d67b0602 (diff)
add SfxItemPoolDeleter utility
add use so we can hold the pool with std::unique_ptr Change-Id: I685fbc37c0ae145a5b48a66a88eab9fb29a0fc0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115174 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/poolhelp.cxx18
-rw-r--r--sc/source/core/inc/poolhelp.hxx9
2 files changed, 13 insertions, 14 deletions
diff --git a/sc/source/core/data/poolhelp.cxx b/sc/source/core/data/poolhelp.cxx
index 37b64c622d19..2091bf167d9c 100644
--- a/sc/source/core/data/poolhelp.cxx
+++ b/sc/source/core/data/poolhelp.cxx
@@ -27,11 +27,9 @@
#include <stlpool.hxx>
ScPoolHelper::ScPoolHelper( ScDocument& rSourceDoc )
- : pEditPool(nullptr)
- , pEnginePool(nullptr)
+ : pDocPool(new ScDocumentPool)
, m_rSourceDoc(rSourceDoc)
{
- pDocPool = new ScDocumentPool;
pDocPool->FreezeIdRanges();
mxStylePool = new ScStyleSheetPool( *pDocPool, &rSourceDoc );
@@ -39,31 +37,31 @@ ScPoolHelper::ScPoolHelper( ScDocument& rSourceDoc )
ScPoolHelper::~ScPoolHelper()
{
- SfxItemPool::Free(pEnginePool);
- SfxItemPool::Free(pEditPool);
+ pEnginePool.reset();
+ pEditPool.reset();
pFormTable.reset();
mxStylePool.clear();
- SfxItemPool::Free(pDocPool);
+ pDocPool.reset();
}
SfxItemPool* ScPoolHelper::GetEditPool() const
{
if ( !pEditPool )
{
- pEditPool = EditEngine::CreatePool();
+ pEditPool.reset(EditEngine::CreatePool());
pEditPool->SetDefaultMetric( MapUnit::Map100thMM );
pEditPool->FreezeIdRanges();
}
- return pEditPool;
+ return pEditPool.get();
}
SfxItemPool* ScPoolHelper::GetEnginePool() const
{
if ( !pEnginePool )
{
- pEnginePool = EditEngine::CreatePool();
+ pEnginePool.reset(EditEngine::CreatePool());
pEnginePool->SetDefaultMetric( MapUnit::Map100thMM );
pEnginePool->FreezeIdRanges();
} // ifg ( pEnginePool )
- return pEnginePool;
+ return pEnginePool.get();
}
SvNumberFormatter* ScPoolHelper::GetFormTable() const
{
diff --git a/sc/source/core/inc/poolhelp.hxx b/sc/source/core/inc/poolhelp.hxx
index a1e3f92b7f8c..267d60ea8eeb 100644
--- a/sc/source/core/inc/poolhelp.hxx
+++ b/sc/source/core/inc/poolhelp.hxx
@@ -23,6 +23,7 @@
#include <salhelper/simplereferenceobject.hxx>
#include <docoptio.hxx>
#include <osl/mutex.hxx>
+#include <svl/itempool.hxx>
class ScDocument;
class ScDocumentPool;
@@ -35,11 +36,11 @@ class ScPoolHelper final : public salhelper::SimpleReferenceObject
private:
mutable osl::Mutex maMtxCreateNumFormatter;
ScDocOptions aOpt;
- ScDocumentPool* pDocPool;
+ std::unique_ptr<ScDocumentPool, SfxItemPoolDeleter> pDocPool;
rtl::Reference< ScStyleSheetPool > mxStylePool;
mutable std::unique_ptr<SvNumberFormatter> pFormTable;
- mutable SfxItemPool* pEditPool; // EditTextObjectPool
- mutable SfxItemPool* pEnginePool; // EditEnginePool
+ mutable std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pEditPool; // EditTextObjectPool
+ mutable std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pEnginePool; // EditEnginePool
ScDocument& m_rSourceDoc;
public:
@@ -50,7 +51,7 @@ public:
void SourceDocumentGone();
// access to pointers (are never 0):
- ScDocumentPool* GetDocPool() const { return pDocPool; }
+ ScDocumentPool* GetDocPool() const { return pDocPool.get(); }
ScStyleSheetPool* GetStylePool() const { return mxStylePool.get(); }
SvNumberFormatter* GetFormTable() const;
SfxItemPool* GetEditPool() const;