[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sat Sep 4 20:00:40 UTC 2021
sc/inc/formulacell.hxx | 20 ++++++++--
sc/source/core/data/formulacell.cxx | 68 +++++++++++++-----------------------
sc/source/filter/excel/frmbase.cxx | 10 ++---
sc/source/filter/inc/formel.hxx | 2 -
4 files changed, 47 insertions(+), 53 deletions(-)
New commits:
commit b68e82b17998ff7ce7e5b08419ecad6b54153566
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Sep 4 16:57:04 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Sep 4 22:00:17 2021 +0200
no need to allocate RangeListType with unique_ptr
Change-Id: I18681749501bb6750912c79b9ff04f5ffc4f0364
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121644
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/filter/excel/frmbase.cxx b/sc/source/filter/excel/frmbase.cxx
index 35bba553997e..d7144c5edea2 100644
--- a/sc/source/filter/excel/frmbase.cxx
+++ b/sc/source/filter/excel/frmbase.cxx
@@ -55,7 +55,7 @@ void ScRangeListTabs::Append( const ScAddress& aSRD, SCTAB nTab )
{
// No entry for this table yet. Insert a new one.
std::pair<TabRangeType::iterator, bool> r =
- m_TabRanges.insert(std::make_pair(nTab, std::make_unique<RangeListType>()));
+ m_TabRanges.insert(std::make_pair(nTab, RangeListType()));
if (!r.second)
// Insertion failed.
@@ -63,7 +63,7 @@ void ScRangeListTabs::Append( const ScAddress& aSRD, SCTAB nTab )
itr = r.first;
}
- itr->second->push_back(ScRange(a.Col(),a.Row(),a.Tab()));
+ itr->second.push_back(ScRange(a.Col(),a.Row(),a.Tab()));
}
void ScRangeListTabs::Append( const ScRange& aCRD, SCTAB nTab )
@@ -113,7 +113,7 @@ void ScRangeListTabs::Append( const ScRange& aCRD, SCTAB nTab )
{
// No entry for this table yet. Insert a new one.
std::pair<TabRangeType::iterator, bool> r =
- m_TabRanges.insert(std::make_pair(nTab, std::make_unique<RangeListType>()));
+ m_TabRanges.insert(std::make_pair(nTab, RangeListType()));
if (!r.second)
// Insertion failed.
@@ -121,7 +121,7 @@ void ScRangeListTabs::Append( const ScRange& aCRD, SCTAB nTab )
itr = r.first;
}
- itr->second->push_back(a);
+ itr->second.push_back(a);
}
const ScRange* ScRangeListTabs::First( SCTAB n )
@@ -133,7 +133,7 @@ const ScRange* ScRangeListTabs::First( SCTAB n )
// No range list exists for this table.
return nullptr;
- const RangeListType& rList = *itr->second;
+ const RangeListType& rList = itr->second;
maItrCur = rList.begin();
maItrCurEnd = rList.end();
return rList.empty() ? nullptr : &(*maItrCur);
diff --git a/sc/source/filter/inc/formel.hxx b/sc/source/filter/inc/formel.hxx
index 9af9158c9cfe..d9dcec6ec15b 100644
--- a/sc/source/filter/inc/formel.hxx
+++ b/sc/source/filter/inc/formel.hxx
@@ -54,7 +54,7 @@ enum FORMULA_TYPE
class ScRangeListTabs
{
typedef ::std::vector<ScRange> RangeListType;
- typedef ::std::map<SCTAB, std::unique_ptr<RangeListType>> TabRangeType;
+ typedef ::std::map<SCTAB, RangeListType> TabRangeType;
TabRangeType m_TabRanges;
RangeListType::const_iterator maItrCur;
RangeListType::const_iterator maItrCurEnd;
commit 9484b56401b6f544eabb3ab9f91d9fecf95242e1
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Sep 4 15:11:13 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Sep 4 22:00:01 2021 +0200
flatten ScFormulaCellGroup
Change-Id: Ie33a6de78bd120f143da35ffc26af94178c734c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121643
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 19983961825d..b685bbbf7b35 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -19,6 +19,7 @@
#pragma once
+#include <map>
#include <memory>
#include <formula/tokenarray.hxx>
@@ -51,12 +52,23 @@ class ScProgress;
class ScTokenArray;
enum class SvNumFormatType : sal_Int16;
-struct SC_DLLPUBLIC ScFormulaCellGroup
+struct AreaListenerKey
{
-private:
- struct Impl;
- std::unique_ptr<Impl> mpImpl;
+ ScRange maRange;
+ bool mbStartFixed;
+ bool mbEndFixed;
+
+ AreaListenerKey( const ScRange& rRange, bool bStartFixed, bool bEndFixed ) :
+ maRange(rRange), mbStartFixed(bStartFixed), mbEndFixed(bEndFixed) {}
+
+ bool operator < ( const AreaListenerKey& r ) const;
+};
+
+typedef std::map<AreaListenerKey, std::unique_ptr<sc::FormulaGroupAreaListener>> AreaListenersType;
+struct SC_DLLPUBLIC ScFormulaCellGroup
+{
+ AreaListenersType m_AreaListeners;
public:
mutable size_t mnRefCount;
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 7304ca033acd..e60768aadb99 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -478,49 +478,31 @@ void adjustDBRange(formula::FormulaToken* pToken, ScDocument& rNewDoc, const ScD
pToken->SetIndex(pNewDBData->GetIndex());
}
-struct AreaListenerKey
-{
- ScRange maRange;
- bool mbStartFixed;
- bool mbEndFixed;
-
- AreaListenerKey( const ScRange& rRange, bool bStartFixed, bool bEndFixed ) :
- maRange(rRange), mbStartFixed(bStartFixed), mbEndFixed(bEndFixed) {}
-
- bool operator < ( const AreaListenerKey& r ) const
- {
- if (maRange.aStart.Tab() != r.maRange.aStart.Tab())
- return maRange.aStart.Tab() < r.maRange.aStart.Tab();
- if (maRange.aStart.Col() != r.maRange.aStart.Col())
- return maRange.aStart.Col() < r.maRange.aStart.Col();
- if (maRange.aStart.Row() != r.maRange.aStart.Row())
- return maRange.aStart.Row() < r.maRange.aStart.Row();
- if (maRange.aEnd.Tab() != r.maRange.aEnd.Tab())
- return maRange.aEnd.Tab() < r.maRange.aEnd.Tab();
- if (maRange.aEnd.Col() != r.maRange.aEnd.Col())
- return maRange.aEnd.Col() < r.maRange.aEnd.Col();
- if (maRange.aEnd.Row() != r.maRange.aEnd.Row())
- return maRange.aEnd.Row() < r.maRange.aEnd.Row();
- if (mbStartFixed != r.mbStartFixed)
- return r.mbStartFixed;
- if (mbEndFixed != r.mbEndFixed)
- return r.mbEndFixed;
-
- return false;
- }
-};
+}
-typedef std::map<AreaListenerKey, std::unique_ptr<sc::FormulaGroupAreaListener>> AreaListenersType;
+bool AreaListenerKey::operator < ( const AreaListenerKey& r ) const
+{
+ if (maRange.aStart.Tab() != r.maRange.aStart.Tab())
+ return maRange.aStart.Tab() < r.maRange.aStart.Tab();
+ if (maRange.aStart.Col() != r.maRange.aStart.Col())
+ return maRange.aStart.Col() < r.maRange.aStart.Col();
+ if (maRange.aStart.Row() != r.maRange.aStart.Row())
+ return maRange.aStart.Row() < r.maRange.aStart.Row();
+ if (maRange.aEnd.Tab() != r.maRange.aEnd.Tab())
+ return maRange.aEnd.Tab() < r.maRange.aEnd.Tab();
+ if (maRange.aEnd.Col() != r.maRange.aEnd.Col())
+ return maRange.aEnd.Col() < r.maRange.aEnd.Col();
+ if (maRange.aEnd.Row() != r.maRange.aEnd.Row())
+ return maRange.aEnd.Row() < r.maRange.aEnd.Row();
+ if (mbStartFixed != r.mbStartFixed)
+ return r.mbStartFixed;
+ if (mbEndFixed != r.mbEndFixed)
+ return r.mbEndFixed;
+ return false;
}
-struct ScFormulaCellGroup::Impl
-{
- AreaListenersType m_AreaListeners;
-};
-
ScFormulaCellGroup::ScFormulaCellGroup() :
- mpImpl(new Impl),
mnRefCount(0),
mpTopCell(nullptr),
mnLength(0),
@@ -576,11 +558,11 @@ sc::FormulaGroupAreaListener* ScFormulaCellGroup::getAreaListener(
{
AreaListenerKey aKey(rRange, bStartFixed, bEndFixed);
- AreaListenersType::iterator it = mpImpl->m_AreaListeners.lower_bound(aKey);
- if (it == mpImpl->m_AreaListeners.end() || mpImpl->m_AreaListeners.key_comp()(aKey, it->first))
+ AreaListenersType::iterator it = m_AreaListeners.lower_bound(aKey);
+ if (it == m_AreaListeners.end() || m_AreaListeners.key_comp()(aKey, it->first))
{
// Insert a new one.
- it = mpImpl->m_AreaListeners.insert(
+ it = m_AreaListeners.insert(
it, std::make_pair(aKey, std::make_unique<sc::FormulaGroupAreaListener>(
rRange, (*ppTopCell)->GetDocument(), (*ppTopCell)->aPos, mnLength, bStartFixed, bEndFixed)));
}
@@ -590,7 +572,7 @@ sc::FormulaGroupAreaListener* ScFormulaCellGroup::getAreaListener(
void ScFormulaCellGroup::endAllGroupListening( ScDocument& rDoc )
{
- for (const auto& rEntry : mpImpl->m_AreaListeners)
+ for (const auto& rEntry : m_AreaListeners)
{
sc::FormulaGroupAreaListener *const pListener = rEntry.second.get();
ScRange aListenRange = pListener->getListeningRange();
@@ -599,7 +581,7 @@ void ScFormulaCellGroup::endAllGroupListening( ScDocument& rDoc )
rDoc.EndListeningArea(aListenRange, bGroupListening, pListener);
}
- mpImpl->m_AreaListeners.clear();
+ m_AreaListeners.clear();
}
ScFormulaCell::ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos ) :
More information about the Libreoffice-commits
mailing list