From 71a24a911bb091885fb03d124d3936d955b13399 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 22 Oct 2021 11:41:26 +0200 Subject: no need to allocate RangeIndexMapPtr separately Change-Id: I0e2aae923530667877bfb111b006b214ca51a730 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124057 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/inc/chart2uno.hxx | 6 +++--- sc/source/ui/unoobj/chart2uno.cxx | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'sc') diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx index b3d80a6ffe02..a5e4f53b032f 100644 --- a/sc/inc/chart2uno.hxx +++ b/sc/inc/chart2uno.hxx @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -366,12 +367,11 @@ private: bool m_bIncludeHiddenCells; // internals - typedef std::unique_ptr > RangeIndexMapPtr; - sal_Int64 m_nObjectId; ScDocument* m_pDocument; std::vector m_aTokens; - RangeIndexMapPtr m_pRangeIndices; + std::optional> + m_oRangeIndices; std::unique_ptr m_pExtRefListener; SfxItemPropertySet m_aPropSet; diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 7f9d23a7d143..6ec3a1e633d1 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2682,7 +2682,7 @@ sal_Int32 ScChart2DataSequence::FillCacheFromExternalRef(const ScTokenRef& pToke void ScChart2DataSequence::UpdateTokensFromRanges(const ScRangeList& rRanges) { - if (!m_pRangeIndices) + if (!m_oRangeIndices) return; for ( size_t i = 0, nCount = rRanges.size(); i < nCount; ++i ) @@ -2691,7 +2691,7 @@ void ScChart2DataSequence::UpdateTokensFromRanges(const ScRangeList& rRanges) const ScRange & rRange = rRanges[i]; ScRefTokenHelper::getTokenFromRange(m_pDocument, pToken, rRange); - sal_uInt32 nOrigPos = (*m_pRangeIndices)[i]; + sal_uInt32 nOrigPos = (*m_oRangeIndices)[i]; m_aTokens[nOrigPos] = pToken; } @@ -2737,8 +2737,8 @@ void ScChart2DataSequence::CopyData(const ScChart2DataSequence& r) m_aHiddenValues = r.m_aHiddenValues; m_aRole = r.m_aRole; - if (r.m_pRangeIndices) - m_pRangeIndices.reset(new vector(*r.m_pRangeIndices)); + if (r.m_oRangeIndices) + m_oRangeIndices = *r.m_oRangeIndices; if (!r.m_pExtRefListener) return; @@ -2764,7 +2764,7 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint // updated, and bring the change back to the token list. ScRangeList aRanges; - m_pRangeIndices.reset(new vector); + m_oRangeIndices.emplace(); vector::const_iterator itrBeg = m_aTokens.begin(), itrEnd = m_aTokens.end(); for (vector::const_iterator itr = itrBeg ;itr != itrEnd; ++itr) { @@ -2774,11 +2774,11 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ScRefTokenHelper::getRangeFromToken(m_pDocument, aRange, *itr, ScAddress()); aRanges.push_back(aRange); sal_uInt32 nPos = distance(itrBeg, itr); - m_pRangeIndices->push_back(nPos); + m_oRangeIndices->push_back(nPos); } } - assert(m_pRangeIndices->size() == aRanges.size() && + assert(m_oRangeIndices->size() == aRanges.size() && "range list and range index list have different sizes."); unique_ptr pUndoRanges; @@ -2791,7 +2791,7 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint if (bChanged) { - assert(m_pRangeIndices->size() == aRanges.size() && + assert(m_oRangeIndices->size() == aRanges.size() && "range list and range index list have different sizes after the reference update."); // Bring the change back from the range list to the token list. @@ -2811,7 +2811,7 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint // The hint object provides the old ranges. Restore the old state // from these ranges. - if (!m_pRangeIndices || m_pRangeIndices->empty()) + if (!m_oRangeIndices || m_oRangeIndices->empty()) { assert(false && " faulty range indices"); break; @@ -2820,7 +2820,7 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint const ScRangeList& rRanges = pUndoHint->GetRanges(); size_t nCount = rRanges.size(); - if (nCount != m_pRangeIndices->size()) + if (nCount != m_oRangeIndices->size()) { assert(false && "range count and range index count differ."); break; -- cgit