sc/inc/chartlis.hxx                           |    4 +--
 sc/source/core/tool/chartlis.cxx              |   27 ++++++++++++--------------
 sc/source/filter/excel/xichart.cxx            |    8 +++----
 sc/source/filter/xml/XMLTableShapeResizer.cxx |    8 +++----
 4 files changed, 23 insertions(+), 24 deletions(-)

New commits:
commit a57209bf4b7aa442757c57b542512fb7ecc9b23d
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon May 30 16:17:12 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon May 30 19:17:42 2022 +0200

    no need to use unique_ptr for tokens in ScChartListener
    
    since vector is a moveable type, and we always initialise this field
    
    Change-Id: Icd598ad942dcfbdf77c7c8eef9fa0b6b7c6fe1be
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135134
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/inc/chartlis.hxx b/sc/inc/chartlis.hxx
index 7e351082f4f7..d140531a9451 100644
--- a/sc/inc/chartlis.hxx
+++ b/sc/inc/chartlis.hxx
@@ -62,7 +62,7 @@ public:
 private:
 
     std::unique_ptr<ExternalRefListener> mpExtRefListener;
-    std::unique_ptr<std::vector<ScTokenRef> > mpTokens;
+    std::vector<ScTokenRef> maTokens;
 
     OUString maName;
     std::unique_ptr<ScChartUnoData> pUnoData;
@@ -76,7 +76,7 @@ public:
     ScChartListener( const OUString& rName, ScDocument& rDoc,
                      const ScRangeListRef& rRangeListRef );
     ScChartListener( const OUString& rName, ScDocument& rDoc,
-                     std::unique_ptr<::std::vector<ScTokenRef>> pTokens );
+                     ::std::vector<ScTokenRef> aTokens );
     ScChartListener( const ScChartListener& ) = delete;
     virtual ~ScChartListener() override;
 
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index 3566e357f67b..2fe7f97ee7ac 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -97,17 +97,16 @@ void 
ScChartListener::ExternalRefListener::removeFileId(sal_uInt16 nFileId)
 
 ScChartListener::ScChartListener( const OUString& rName, ScDocument& rDocP,
         const ScRangeListRef& rRangeList ) :
-    mpTokens(new vector<ScTokenRef>),
     maName(rName),
     mrDoc( rDocP ),
     bUsed( false ),
     bDirty( false )
 {
-    ScRefTokenHelper::getTokensFromRangeList(&rDocP, *mpTokens, *rRangeList);
+    ScRefTokenHelper::getTokensFromRangeList(&rDocP, maTokens, *rRangeList);
 }
 
-ScChartListener::ScChartListener( const OUString& rName, ScDocument& rDocP, 
std::unique_ptr<vector<ScTokenRef>> pTokens ) :
-    mpTokens(std::move(pTokens)),
+ScChartListener::ScChartListener( const OUString& rName, ScDocument& rDocP, 
vector<ScTokenRef> aTokens ) :
+    maTokens(std::move(aTokens)),
     maName(rName),
     mrDoc( rDocP ),
     bUsed( false ),
@@ -187,7 +186,7 @@ void ScChartListener::Update()
 ScRangeListRef ScChartListener::GetRangeList() const
 {
     ScRangeListRef aRLRef(new ScRangeList);
-    ScRefTokenHelper::getRangeListFromTokens(&mrDoc, *aRLRef, *mpTokens, 
ScAddress());
+    ScRefTokenHelper::getRangeListFromTokens(&mrDoc, *aRLRef, maTokens, 
ScAddress());
     return aRLRef;
 }
 
@@ -195,7 +194,7 @@ void ScChartListener::SetRangeList( const ScRangeListRef& 
rNew )
 {
     vector<ScTokenRef> aTokens;
     ScRefTokenHelper::getTokensFromRangeList(&mrDoc, aTokens, *rNew);
-    mpTokens->swap(aTokens);
+    maTokens.swap(aTokens);
 }
 
 namespace {
@@ -264,20 +263,20 @@ private:
 
 void ScChartListener::StartListeningTo()
 {
-    if (!mpTokens || mpTokens->empty())
+    if (maTokens.empty())
         // no references to listen to.
         return;
 
-    for_each(mpTokens->begin(), mpTokens->end(), StartEndListening(mrDoc, 
*this, true));
+    for_each(maTokens.begin(), maTokens.end(), StartEndListening(mrDoc, *this, 
true));
 }
 
 void ScChartListener::EndListeningTo()
 {
-    if (!mpTokens || mpTokens->empty())
+    if (maTokens.empty())
         // no references to listen to.
         return;
 
-    for_each(mpTokens->begin(), mpTokens->end(), StartEndListening(mrDoc, 
*this, false));
+    for_each(maTokens.begin(), maTokens.end(), StartEndListening(mrDoc, *this, 
false));
 }
 
 void ScChartListener::ChangeListening( const ScRangeListRef& rRangeListRef,
@@ -295,7 +294,7 @@ void ScChartListener::UpdateChartIntersecting( const 
ScRange& rRange )
     ScTokenRef pToken;
     ScRefTokenHelper::getTokenFromRange(&mrDoc, pToken, rRange);
 
-    if (ScRefTokenHelper::intersects(&mrDoc, *mpTokens, pToken, ScAddress()))
+    if (ScRefTokenHelper::intersects(&mrDoc, maTokens, pToken, ScAddress()))
     {
         // force update (chart has to be loaded), don't use 
ScChartListener::Update
         mrDoc.UpdateChart(GetName());
@@ -318,8 +317,8 @@ void ScChartListener::SetUpdateQueue()
 
 bool ScChartListener::operator==( const ScChartListener& r ) const
 {
-    bool b1 = (mpTokens && !mpTokens->empty());
-    bool b2 = (r.mpTokens && !r.mpTokens->empty());
+    bool b1 = !maTokens.empty();
+    bool b2 = !r.maTokens.empty();
 
     if (&mrDoc != &r.mrDoc || bUsed != r.bUsed || bDirty != r.bDirty ||
         GetName() != r.GetName() || b1 != b2)
@@ -329,7 +328,7 @@ bool ScChartListener::operator==( const ScChartListener& r 
) const
         // both token list instances are empty.
         return true;
 
-    return *mpTokens == *r.mpTokens;
+    return maTokens == r.maTokens;
 }
 
 bool ScChartListener::operator!=( const ScChartListener& r ) const
diff --git a/sc/source/filter/excel/xichart.cxx 
b/sc/source/filter/excel/xichart.cxx
index 38c81adf2dcf..dc14076b7fac 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -4057,12 +4057,12 @@ void XclImpChChart::Convert( const 
Reference<XChartDocument>& xChartDoc,
     if(!pChartCollection)
         return;
 
-    ::std::unique_ptr< ::std::vector< ScTokenRef > > xRefTokens( new 
::std::vector< ScTokenRef > );
+    std::vector< ScTokenRef > aRefTokens;
     for( const auto& rxSeries : maSeries )
-        rxSeries->FillAllSourceLinks( *xRefTokens );
-    if( !xRefTokens->empty() )
+        rxSeries->FillAllSourceLinks( aRefTokens );
+    if( !aRefTokens.empty() )
     {
-        ::std::unique_ptr< ScChartListener > xListener( new ScChartListener( 
rObjName, rDoc, std::move(xRefTokens) ) );
+        ::std::unique_ptr< ScChartListener > xListener( new ScChartListener( 
rObjName, rDoc, std::move(aRefTokens) ) );
         xListener->SetUsed( true );
         xListener->StartListeningTo();
         pChartCollection->insert( xListener.release() );
diff --git a/sc/source/filter/xml/XMLTableShapeResizer.cxx 
b/sc/source/filter/xml/XMLTableShapeResizer.cxx
index 640c9e479cd9..0ff302346f29 100644
--- a/sc/source/filter/xml/XMLTableShapeResizer.cxx
+++ b/sc/source/filter/xml/XMLTableShapeResizer.cxx
@@ -76,15 +76,15 @@ void ScMyOLEFixer::CreateChartListener(ScDocument& rDoc,
     if (!pCollection)
         return;
 
-    unique_ptr< vector<ScTokenRef> > pRefTokens(new vector<ScTokenRef>);
+    vector<ScTokenRef> aRefTokens;
     const sal_Unicode cSep = ScCompiler::GetNativeSymbolChar(ocSep);
     ScRefTokenHelper::compileRangeRepresentation(
-        *pRefTokens, aRangeStr, rDoc, cSep, rDoc.GetGrammar());
-    if (pRefTokens->empty())
+        aRefTokens, aRangeStr, rDoc, cSep, rDoc.GetGrammar());
+    if (aRefTokens.empty())
         return;
 
     OUString sName = !rName.isEmpty() ? rName : 
pCollection->getUniqueName(u"OLEFixer ");
-    ScChartListener* pCL(new ScChartListener(sName, rDoc, 
std::move(pRefTokens)));
+    ScChartListener* pCL(new ScChartListener(sName, rDoc, 
std::move(aRefTokens)));
 
     //for loading binary files e.g.
     //if we have the flat filter we need to set the dirty flag thus the 
visible charts get repainted

Reply via email to