summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-09-01 20:51:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-02 11:23:51 +0200
commit70cab065b4bfc2e68838b0056c52741eab8e32de (patch)
treecf001e6b3968c2be452545f17fa4a1d5acc4e039 /sc
parentb5c039a58dde8992c41f7d7e22cf393a15e1033e (diff)
no need to use unique_ptr for this map in sc::ScRangeName
map is already a node based data structure, so the values will stay in the same place in memory Change-Id: I774368091ace3775d9d63b3ed561e323ad3adb9b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139236 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/document.hxx4
-rw-r--r--sc/inc/undorangename.hxx8
-rw-r--r--sc/qa/unit/ucalc_sharedformula.cxx4
-rw-r--r--sc/source/core/data/documen3.cxx14
-rw-r--r--sc/source/core/data/document10.cxx8
-rw-r--r--sc/source/ui/docshell/docfunc.cxx2
-rw-r--r--sc/source/ui/inc/docfunc.hxx2
-rw-r--r--sc/source/ui/inc/namedlg.hxx7
-rw-r--r--sc/source/ui/inc/namemgrtable.hxx4
-rw-r--r--sc/source/ui/inc/namepast.hxx2
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx2
-rw-r--r--sc/source/ui/namedlg/namedlg.cxx10
-rw-r--r--sc/source/ui/namedlg/namemgrtable.cxx14
-rw-r--r--sc/source/ui/namedlg/namepast.cxx2
-rw-r--r--sc/source/ui/undo/undorangename.cxx8
-rw-r--r--sc/source/ui/view/tabvwshc.cxx4
16 files changed, 45 insertions, 50 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 41b7d71a63e7..1767f8c4e5f0 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -662,7 +662,7 @@ public:
* non-empty range name set.
*/
SC_DLLPUBLIC void GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rRangeNames) const;
- SC_DLLPUBLIC void SetAllRangeNames(const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap);
+ SC_DLLPUBLIC void SetAllRangeNames(const std::map<OUString, ScRangeName>& rRangeMap);
SC_DLLPUBLIC void GetRangeNameMap(std::map<OUString, ScRangeName*>& rRangeName);
SC_DLLPUBLIC ScRangeName* GetRangeName(SCTAB nTab) const;
SC_DLLPUBLIC ScRangeName* GetRangeName() const;
@@ -774,7 +774,7 @@ public:
/**
* Call this immediately before updating all named ranges.
*/
- SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate( const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap );
+ SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate( const std::map<OUString, ScRangeName>& rRangeMap );
SC_DLLPUBLIC void PreprocessRangeNameUpdate();
SC_DLLPUBLIC void PreprocessDBDataUpdate();
/**
diff --git a/sc/inc/undorangename.hxx b/sc/inc/undorangename.hxx
index f09ced1417af..cbe1a2a1e544 100644
--- a/sc/inc/undorangename.hxx
+++ b/sc/inc/undorangename.hxx
@@ -23,7 +23,7 @@ class ScUndoAllRangeNames final : public ScSimpleUndo
{
public:
ScUndoAllRangeNames(ScDocShell* pDocSh, const std::map<OUString, ScRangeName*>& rOldNames,
- const std::map<OUString, std::unique_ptr<ScRangeName>>& rNewNames);
+ const std::map<OUString, ScRangeName>& rNewNames);
virtual ~ScUndoAllRangeNames() override;
@@ -34,11 +34,11 @@ public:
virtual OUString GetComment() const override;
private:
- void DoChange(const std::map<OUString, std::unique_ptr<ScRangeName>>& rNames);
+ void DoChange(const std::map<OUString, ScRangeName>& rNames);
private:
- std::map<OUString, std::unique_ptr<ScRangeName>> m_OldNames;
- std::map<OUString, std::unique_ptr<ScRangeName>> m_NewNames;
+ std::map<OUString, ScRangeName> m_OldNames;
+ std::map<OUString, ScRangeName> m_NewNames;
};
class ScUndoAddRangeData final : public ScSimpleUndo
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx
index e670af33f1fc..254269bf9716 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -1685,10 +1685,10 @@ void TestSharedFormula::testSharedFormulaUpdateOnNamedRangeChange()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pNames->size());
ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
- typedef std::map<OUString, std::unique_ptr<ScRangeName>> NameMapType;
+ typedef std::map<OUString, ScRangeName> NameMapType;
NameMapType aNewNames;
OUString aScope(STR_GLOBAL_RANGE_NAME);
- aNewNames.insert(std::make_pair(aScope, std::move(pNames)));
+ aNewNames.insert(std::make_pair(aScope, std::move(*pNames)));
rFunc.ModifyAllRangeNames(aNewNames);
// Check to make sure all displayed formulas are still good.
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index ecc93881c0bf..c0b6984008b7 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -126,27 +126,25 @@ void ScDocument::GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rNames) const
rNames.swap(aNames);
}
-void ScDocument::SetAllRangeNames(const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap)
+void ScDocument::SetAllRangeNames(const std::map<OUString, ScRangeName>& rRangeMap)
{
- for (const auto& [rName, rxRangeName] : rRangeMap)
+ for (const auto& [rName, rRangeName] : rRangeMap)
{
if (rName == STR_GLOBAL_RANGE_NAME)
{
pRangeName.reset();
- const ScRangeName *const pName = rxRangeName.get();
- if (!pName->empty())
- pRangeName.reset( new ScRangeName( *pName ) );
+ if (!rRangeName.empty())
+ pRangeName.reset( new ScRangeName( rRangeName ) );
}
else
{
- const ScRangeName *const pName = rxRangeName.get();
SCTAB nTab;
bool bFound = GetTable(rName, nTab);
assert(bFound); (void)bFound; // fouled up?
- if (pName->empty())
+ if (rRangeName.empty())
SetRangeName( nTab, nullptr );
else
- SetRangeName( nTab, std::unique_ptr<ScRangeName>(new ScRangeName( *pName )) );
+ SetRangeName( nTab, std::unique_ptr<ScRangeName>(new ScRangeName( rRangeName )) );
}
}
}
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index ec61fa530952..e0eb8d46bd28 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -246,7 +246,7 @@ void ScDocument::SwapNonEmpty( sc::TableValues& rValues )
aEndCxt.purgeEmptyBroadcasters();
}
-void ScDocument::PreprocessAllRangeNamesUpdate( const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap )
+void ScDocument::PreprocessAllRangeNamesUpdate( const std::map<OUString, ScRangeName>& rRangeMap )
{
// Update all existing names with new names.
// The prerequisites are that the name dialog preserves ScRangeData index
@@ -266,9 +266,7 @@ void ScDocument::PreprocessAllRangeNamesUpdate( const std::map<OUString, std::un
if (itNewTab == rRangeMap.end())
continue;
- const ScRangeName* pNewRangeNames = itNewTab->second.get();
- if (!pNewRangeNames)
- continue;
+ const ScRangeName& rNewRangeNames = itNewTab->second;
for (const auto& rEntry : *pOldRangeNames)
{
@@ -276,7 +274,7 @@ void ScDocument::PreprocessAllRangeNamesUpdate( const std::map<OUString, std::un
if (!pOldData)
continue;
- const ScRangeData* pNewData = pNewRangeNames->findByIndex( pOldData->GetIndex());
+ const ScRangeData* pNewData = rNewRangeNames.findByIndex( pOldData->GetIndex());
if (pNewData)
pOldData->SetNewName( pNewData->GetName());
}
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index b9424a4a92da..9b7c64eabc79 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5184,7 +5184,7 @@ void ScDocFunc::SetNewRangeNames( std::unique_ptr<ScRangeName> pNewRanges, bool
}
}
-void ScDocFunc::ModifyAllRangeNames(const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap)
+void ScDocFunc::ModifyAllRangeNames(const std::map<OUString, ScRangeName>& rRangeMap)
{
ScDocShellModificator aModificator(rDocShell);
ScDocument& rDoc = rDocShell.GetDocument();
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index f7ca3e422bc8..7779564db716 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -212,7 +212,7 @@ public:
* passed as arguments (it creates copies); the caller is responsible for
* destroying them.
*/
- void ModifyAllRangeNames(const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap);
+ void ModifyAllRangeNames(const std::map<OUString, ScRangeName>& rRangeMap);
bool CreateNames( const ScRange& rRange, CreateNameFlags nFlags, bool bApi, SCTAB nTab = -1 ); // -1 for global range names
bool InsertNameList( const ScAddress& rStartPos, bool bApi );
diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index 73b8dbcd756a..eadde5349618 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -46,7 +46,7 @@ private:
//ugly hack to call DefineNames from ManageNames
bool mbCloseWithoutUndo;
- typedef std::map<OUString, std::unique_ptr<ScRangeName>> RangeNameContainer;
+ typedef std::map<OUString, ScRangeName> RangeNameContainer;
RangeNameContainer m_RangeMap;
@@ -107,8 +107,7 @@ protected:
public:
ScNameDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, ScViewData& rViewData,
- const ScAddress& aCursorPos,
- std::map<OUString, std::unique_ptr<ScRangeName>>* pRangeMap = nullptr);
+ const ScAddress& aCursorPos, std::map<OUString, ScRangeName>* pRangeMap = nullptr);
virtual ~ScNameDlg() override;
virtual void SetReference(const ScRange& rRef, ScDocument& rDoc) override;
@@ -117,7 +116,7 @@ public:
virtual void SetActive() override;
virtual void Close() override;
- void GetRangeNames(std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap);
+ void GetRangeNames(std::map<OUString, ScRangeName>& rRangeMap);
void SetEntry(const OUString& rName, const OUString& rScope);
};
diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx
index da5b93dfb679..347fbac3db69 100644
--- a/sc/source/ui/inc/namemgrtable.hxx
+++ b/sc/source/ui/inc/namemgrtable.hxx
@@ -35,7 +35,7 @@ private:
OUString maGlobalString;
// should be const because we should not modify it here
- const std::map<OUString, std::unique_ptr<ScRangeName>>& m_RangeMap;
+ const std::map<OUString, ScRangeName>& m_RangeMap;
// for performance, save which entries already have the formula entry
// otherwise opening the dialog with a lot of range names is extremely slow because
// we would calculate all formula strings during opening
@@ -55,7 +55,7 @@ private:
public:
ScRangeManagerTable(std::unique_ptr<weld::TreeView>,
- const std::map<OUString, std::unique_ptr<ScRangeName>>& rTabRangeNames,
+ const std::map<OUString, ScRangeName>& rTabRangeNames,
const ScAddress& rPos);
void CheckForFormulaString();
diff --git a/sc/source/ui/inc/namepast.hxx b/sc/source/ui/inc/namepast.hxx
index 79947bbcd78c..b155dfacc627 100644
--- a/sc/source/ui/inc/namepast.hxx
+++ b/sc/source/ui/inc/namepast.hxx
@@ -39,7 +39,7 @@ private:
std::unique_ptr<ScRangeManagerTable> m_xTable;
std::vector<OUString> maSelectedNames;
- std::map<OUString, std::unique_ptr<ScRangeName>> m_RangeMap;
+ std::map<OUString, ScRangeName> m_RangeMap;
OUString m_aSheetSep;
public:
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index d1a7e5ef89d6..a1688fb11f83 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -162,7 +162,7 @@ private:
std::unique_ptr<SfxBroadcaster> pAccessibilityBroadcaster;
// ugly hack for Add button in ScNameDlg
- std::map<OUString, std::unique_ptr<ScRangeName>> m_RangeMap;
+ std::map<OUString, ScRangeName> m_RangeMap;
bool mbInSwitch;
OUString maName;
OUString maScope;
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 05094b81069d..652f0f1125bb 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -43,7 +43,7 @@
ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent,
ScViewData& rViewData,
const ScAddress& aCursorPos,
- std::map<OUString, std::unique_ptr<ScRangeName>> *const pRangeMap)
+ std::map<OUString, ScRangeName> *const pRangeMap)
: ScAnyRefDlgController(pB, pCW, pParent, "modules/scalc/ui/managenamesdialog.ui",
"ManageNamesDialog")
@@ -84,7 +84,7 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParen
mrDoc.GetRangeNameMap(aRangeMap);
for (const auto& [aTemp, pRangeName] : aRangeMap)
{
- m_RangeMap.insert(std::make_pair(aTemp, std::make_unique<ScRangeName>(*pRangeName)));
+ m_RangeMap.insert(std::make_pair(aTemp, *pRangeName));
}
}
else
@@ -281,9 +281,9 @@ bool ScNameDlg::IsFormulaValid()
ScRangeName* ScNameDlg::GetRangeName(const OUString& rScope)
{
if (rScope == maGlobalNameStr)
- return m_RangeMap.find(OUString(STR_GLOBAL_RANGE_NAME))->second.get();
+ return &m_RangeMap.find(OUString(STR_GLOBAL_RANGE_NAME))->second;
else
- return m_RangeMap.find(rScope)->second.get();
+ return &m_RangeMap.find(rScope)->second;
}
void ScNameDlg::ShowOptions(const ScRangeNameLine& rLine)
@@ -446,7 +446,7 @@ void ScNameDlg::ScopeChanged()
NameModified();
}
-void ScNameDlg::GetRangeNames(std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap)
+void ScNameDlg::GetRangeNames(std::map<OUString, ScRangeName>& rRangeMap)
{
m_RangeMap.swap(rRangeMap);
}
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index 0e5d98856e7c..fbf6b64d3a1f 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -53,9 +53,9 @@ void ScRangeManagerTable::SetEntry(const ScRangeNameLine& rLine)
}
}
-ScRangeManagerTable::ScRangeManagerTable(
- std::unique_ptr<weld::TreeView> xTreeView,
- const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap, const ScAddress& rPos)
+ScRangeManagerTable::ScRangeManagerTable(std::unique_ptr<weld::TreeView> xTreeView,
+ const std::map<OUString, ScRangeName>& rRangeMap,
+ const ScAddress& rPos)
: m_xTreeView(std::move(xTreeView))
, maGlobalString(ScResId(STR_GLOBAL_SCOPE))
, m_RangeMap(rRangeMap)
@@ -83,9 +83,9 @@ const ScRangeData* ScRangeManagerTable::findRangeData(const ScRangeNameLine& rLi
{
const ScRangeName* pRangeName;
if (rLine.aScope == maGlobalString)
- pRangeName = m_RangeMap.find(OUString(STR_GLOBAL_RANGE_NAME))->second.get();
+ pRangeName = &m_RangeMap.find(OUString(STR_GLOBAL_RANGE_NAME))->second;
else
- pRangeName = m_RangeMap.find(rLine.aScope)->second.get();
+ pRangeName = &m_RangeMap.find(rLine.aScope)->second;
return pRangeName->findByUpperName(ScGlobal::getCharClass().uppercase(rLine.aName));
}
@@ -144,13 +144,13 @@ void ScRangeManagerTable::Init()
m_xTreeView->clear();
for (auto const& itr : m_RangeMap)
{
- const ScRangeName* const pLocalRangeName = itr.second.get();
+ const ScRangeName& rLocalRangeName = itr.second;
ScRangeNameLine aLine;
if (itr.first == STR_GLOBAL_RANGE_NAME)
aLine.aScope = maGlobalString;
else
aLine.aScope = itr.first;
- for (const auto& rEntry : *pLocalRangeName)
+ for (const auto& rEntry : rLocalRangeName)
{
if (!rEntry.second->HasType(ScRangeData::Type::Database))
{
diff --git a/sc/source/ui/namedlg/namepast.cxx b/sc/source/ui/namedlg/namepast.cxx
index c6851abcc426..491ebe7f79f0 100644
--- a/sc/source/ui/namedlg/namepast.cxx
+++ b/sc/source/ui/namedlg/namepast.cxx
@@ -40,7 +40,7 @@ ScNamePasteDlg::ScNamePasteDlg(weld::Window* pParent, ScDocShell* pShell)
rDoc.GetRangeNameMap(aCopyMap);
for (const auto & [ aTemp, pName ] : aCopyMap)
{
- m_RangeMap.insert(std::make_pair(aTemp, std::make_unique<ScRangeName>(*pName)));
+ m_RangeMap.insert(std::make_pair(aTemp, *pName));
}
ScViewData* pViewData = ScDocShell::GetViewData();
diff --git a/sc/source/ui/undo/undorangename.cxx b/sc/source/ui/undo/undorangename.cxx
index 1b9efafaeeef..30e8d509f0ef 100644
--- a/sc/source/ui/undo/undorangename.cxx
+++ b/sc/source/ui/undo/undorangename.cxx
@@ -21,17 +21,17 @@ using ::std::unique_ptr;
ScUndoAllRangeNames::ScUndoAllRangeNames(
ScDocShell* pDocSh,
const std::map<OUString, ScRangeName*>& rOldNames,
- const std::map<OUString, std::unique_ptr<ScRangeName>>& rNewNames)
+ const std::map<OUString, ScRangeName>& rNewNames)
: ScSimpleUndo(pDocSh)
{
for (const auto& [rName, pRangeName] : rOldNames)
{
- m_OldNames.insert(std::make_pair(rName, std::make_unique<ScRangeName>(*pRangeName)));
+ m_OldNames.insert(std::make_pair(rName, *pRangeName));
}
for (auto const& it : rNewNames)
{
- m_NewNames.insert(std::make_pair(it.first, std::make_unique<ScRangeName>(*it.second)));
+ m_NewNames.insert(std::make_pair(it.first, it.second));
}
}
@@ -63,7 +63,7 @@ OUString ScUndoAllRangeNames::GetComment() const
return ScResId(STR_UNDO_RANGENAMES);
}
-void ScUndoAllRangeNames::DoChange(const std::map<OUString, std::unique_ptr<ScRangeName>>& rNames)
+void ScUndoAllRangeNames::DoChange(const std::map<OUString, ScRangeName>& rNames)
{
ScDocument& rDoc = pDocShell->GetDocument();
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index e4d95ed5541d..0a636c0b2f33 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -224,9 +224,9 @@ std::shared_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont
else
{
std::map<OUString, ScRangeName*> aRangeMap;
- for (auto const& itr : m_RangeMap)
+ for (auto& itr : m_RangeMap)
{
- aRangeMap.insert(std::pair<OUString, ScRangeName*>(itr.first, itr.second.get()));
+ aRangeMap.insert(std::pair<OUString, ScRangeName*>(itr.first, &itr.second));
}
xResult = std::make_shared<ScNameDefDlg>(pB, pCW, pParent, GetViewData(), std::move(aRangeMap),
ScAddress(GetViewData().GetCurX(),