sc/source/filter/xml/XMLExportIterator.cxx |   17 ++++++-----------
 sc/source/filter/xml/XMLExportIterator.hxx |   11 ++++-------
 sc/source/filter/xml/xmlexprt.cxx          |   29 ++++++++++++++---------------
 sc/source/filter/xml/xmlexprt.hxx          |    7 +++----
 sd/source/ui/view/sdview3.cxx              |    2 +-
 5 files changed, 28 insertions(+), 38 deletions(-)

New commits:
commit cb53c054dd92777bffbe2d33c14f992596b93d64
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Nov 28 12:17:18 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Nov 28 12:16:41 2024 +0100

    Use correct object
    
    A potential dereference of nullptr was introduced as renaming overlook
    in commit 507aced21a19deba279029bbabeca24562381824 (INTEGRATION: CWS
    sdwarningsbegone (1.68.10); FILE MERGED, 2006-12-12).
    
    Change-Id: I4cf787e3ec3e1819040368d17279cae4db391bc7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177461
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 7fa06beb1c1b..e32ba5e13ed9 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -755,7 +755,7 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
 
                             if( bUndo )
                                 BegUndo(SdResId(STR_UNDO_DRAGDROP));
-                            pNewObj->NbcSetLayer( pPickObj->GetLayer() );
+                            pNewObj->NbcSetLayer( pPickObj2->GetLayer() );
                             pWorkPage->InsertObject( pNewObj.get() );
                             if( bUndo )
                             {
commit c70fa22d147db736f06a7513b5e2fa82d66b60bf
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Nov 28 10:50:33 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Nov 28 12:16:28 2024 +0100

    Return from functions, instead of using out arguments
    
    Change-Id: Ie57bf41790800cc3bc83e0785a9063643d700c1f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177458
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/sc/source/filter/xml/XMLExportIterator.cxx 
b/sc/source/filter/xml/XMLExportIterator.cxx
index bff7e8498642..3283a743adcc 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -253,8 +253,10 @@ inline bool ScMyAreaLink::operator<(const ScMyAreaLink& 
rAreaLink ) const
     return aDestRange.aStart.lessThanByRow( rAreaLink.aDestRange.aStart );
 }
 
-ScMyAreaLinksContainer::ScMyAreaLinksContainer()
+ScMyAreaLinksContainer::ScMyAreaLinksContainer(ScMyAreaLinkList&& list)
+    : aAreaLinkList(std::move(list))
 {
+    Sort();
 }
 
 ScMyAreaLinksContainer::~ScMyAreaLinksContainer()
@@ -458,23 +460,16 @@ inline bool ScMyDetectiveOp::operator<( const 
ScMyDetectiveOp& rDetOp) const
     return aPosition.lessThanByRow( rDetOp.aPosition );
 }
 
-ScMyDetectiveOpContainer::ScMyDetectiveOpContainer()
+ScMyDetectiveOpContainer::ScMyDetectiveOpContainer(ScMyDetectiveOpList&& list)
+    : aDetectiveOpList(std::move(list))
 {
+    Sort();
 }
 
 ScMyDetectiveOpContainer::~ScMyDetectiveOpContainer()
 {
 }
 
-void ScMyDetectiveOpContainer::AddOperation( ScDetOpType eOpType, const 
ScAddress& rPosition, sal_uInt32 nIndex )
-{
-    ScMyDetectiveOp aDetOp;
-    aDetOp.eOpType = eOpType;
-    aDetOp.aPosition = rPosition;
-    aDetOp.nIndex = nIndex;
-    aDetectiveOpList.push_back( aDetOp );
-}
-
 bool ScMyDetectiveOpContainer::GetFirstAddress( ScAddress& rCellAddress )
 {
     SCTAB nTable( rCellAddress.Tab() );
diff --git a/sc/source/filter/xml/XMLExportIterator.hxx 
b/sc/source/filter/xml/XMLExportIterator.hxx
index 6690c92c627d..f05e487b8d19 100644
--- a/sc/source/filter/xml/XMLExportIterator.hxx
+++ b/sc/source/filter/xml/XMLExportIterator.hxx
@@ -172,12 +172,10 @@ private:
 protected:
     virtual bool                GetFirstAddress( ScAddress& rCellAddress ) 
override;
 public:
-                                ScMyAreaLinksContainer();
+                                ScMyAreaLinksContainer() = default;
+    explicit                    ScMyAreaLinksContainer(ScMyAreaLinkList&& 
list);
     virtual                     ~ScMyAreaLinksContainer() override;
 
-    void                 AddNewAreaLink( const ScMyAreaLink& rAreaLink )
-                                    { aAreaLinkList.push_back( rAreaLink ); }
-
                                 using ScMyIteratorBase::UpdateAddress;
     virtual void                SetCellData( ScMyCell& rMyCell ) override;
     virtual void                Sort() override;
@@ -262,11 +260,10 @@ private:
 protected:
     virtual bool                GetFirstAddress( ScAddress& rCellAddress ) 
override;
 public:
-                                ScMyDetectiveOpContainer();
+                                ScMyDetectiveOpContainer() = default;
+    explicit                    ScMyDetectiveOpContainer(ScMyDetectiveOpList&& 
list);
     virtual                     ~ScMyDetectiveOpContainer() override;
 
-    void                        AddOperation( ScDetOpType eOpType, const 
ScAddress& rPosition, sal_uInt32 nIndex );
-
                                 using ScMyIteratorBase::UpdateAddress;
     virtual void                SetCellData( ScMyCell& rMyCell ) override;
     virtual void                Sort() override;
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 0bb49fcd738d..8bb83786c7a2 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -33,7 +33,6 @@
 #include "XMLExportDataPilot.hxx"
 #include "XMLExportDatabaseRanges.hxx"
 #include "XMLExportDDELinks.hxx"
-#include "XMLExportIterator.hxx"
 #include "XMLColumnRowGroupExport.hxx"
 #include "XMLStylesExportHelper.hxx"
 #include "XMLChangeTrackingExportHelper.hxx"
@@ -676,14 +675,15 @@ table::CellRangeAddress ScXMLExport::GetEndAddress(const 
uno::Reference<sheet::X
     return aCellAddress;
 }
 
-void ScXMLExport::GetAreaLinks( ScMyAreaLinksContainer& rAreaLinks )
+ScMyAreaLinksContainer ScXMLExport::GetAreaLinks()
 {
     if (!mpDoc)
-        return;
+        return {};
     sfx2::LinkManager* pManager = mpDoc->GetLinkManager();
     if (!pManager)
-        return;
+        return {};
 
+    ScMyAreaLinkList aAreaLinks;
     for (const auto& rLink : pManager->GetLinks())
     {
         if (ScAreaLink* pLink = dynamic_cast<ScAreaLink*>(rLink.get()))
@@ -695,22 +695,23 @@ void ScXMLExport::GetAreaLinks( ScMyAreaLinksContainer& 
rAreaLinks )
             aAreaLink.sFilterOptions = pLink->GetOptions();
             aAreaLink.sURL = pLink->GetFile();
             aAreaLink.nRefreshDelaySeconds = pLink->GetRefreshDelaySeconds();
-            rAreaLinks.AddNewAreaLink( aAreaLink );
+            aAreaLinks.push_back(aAreaLink);
         }
     }
-    rAreaLinks.Sort();
+    return ScMyAreaLinksContainer(std::move(aAreaLinks));
 }
 
 // core implementation
-void ScXMLExport::GetDetectiveOpList( ScMyDetectiveOpContainer& rDetOp )
+ScMyDetectiveOpContainer ScXMLExport::GetDetectiveOpList()
 {
     if (!mpDoc)
-        return;
+        return {};
 
     ScDetOpList* pOpList(mpDoc->GetDetOpList());
     if( !pOpList )
-        return;
+        return {};
 
+    ScMyDetectiveOpList aDetOp;
     size_t nCount = pOpList->Count();
     for (size_t nIndex = 0; nIndex < nCount; ++nIndex )
     {
@@ -719,14 +720,14 @@ void ScXMLExport::GetDetectiveOpList( 
ScMyDetectiveOpContainer& rDetOp )
         SCTAB nTab = rDetPos.Tab();
         if ( nTab < mpDoc->GetTableCount() )
         {
-            rDetOp.AddOperation( rDetData.GetOperation(), rDetPos, 
static_cast<sal_uInt32>( nIndex) );
+            aDetOp.push_back({ rDetPos, rDetData.GetOperation(), 
static_cast<sal_Int32>(nIndex) });
 
             // cells with detective operations are written even if empty
             pSharedData->SetLastColumn( nTab, rDetPos.Col() );
             pSharedData->SetLastRow( nTab, rDetPos.Row() );
         }
     }
-    rDetOp.Sort();
+    return ScMyDetectiveOpContainer(std::move(aDetOp));
 }
 
 void ScXMLExport::WriteSingleColumn(const sal_Int32 nRepeatColumns, const 
sal_Int32 nStyleIndex,
@@ -1898,11 +1899,9 @@ void ScXMLExport::ExportContent_()
         pChangeTrackingExportHelper->CollectAndWriteChanges();
         WriteCalculationSettings(xSpreadDoc);
         sal_Int32 nTableCount(xIndex->getCount());
-        ScMyAreaLinksContainer aAreaLinks;
-        GetAreaLinks( aAreaLinks );
+        ScMyAreaLinksContainer aAreaLinks = GetAreaLinks();
         ScMyEmptyDatabaseRangesContainer 
aEmptyRanges(aExportDatabaseRanges.GetEmptyDatabaseRanges());
-        ScMyDetectiveOpContainer aDetectiveOpContainer;
-        GetDetectiveOpList( aDetectiveOpContainer );
+        ScMyDetectiveOpContainer aDetectiveOpContainer = GetDetectiveOpList();
 
         pMergedRangesContainer->Sort();
         pSharedData->GetDetectiveObjContainer()->Sort();
diff --git a/sc/source/filter/xml/xmlexprt.hxx 
b/sc/source/filter/xml/xmlexprt.hxx
index 310c54b60f7b..cb03a354cb59 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/io/XInputStream.hpp>
 
 #include <address.hxx>
+#include "XMLExportIterator.hxx"
 
 #include <memory>
 #include <unordered_map>
@@ -49,8 +50,6 @@ class ScRowStyles;
 class ScFormatRangeStyles;
 class ScRowFormatRanges;
 class ScMyOpenCloseColumnRowGroup;
-class ScMyAreaLinksContainer;
-class ScMyDetectiveOpContainer;
 struct ScMyCell;
 class ScDocument;
 class ScMySharedData;
@@ -142,8 +141,8 @@ class ScXMLExport : public SvXMLExport
     void CollectInternalShape( css::uno::Reference< css::drawing::XShape > 
const & xShape );
 
     static css::table::CellRangeAddress GetEndAddress(const 
css::uno::Reference<css::sheet::XSpreadsheet>& xTable);
-    void GetAreaLinks( ScMyAreaLinksContainer& rAreaLinks );
-    void GetDetectiveOpList( ScMyDetectiveOpContainer& rDetOp );
+    ScMyAreaLinksContainer GetAreaLinks();
+    ScMyDetectiveOpContainer GetDetectiveOpList();
     void WriteSingleColumn(const sal_Int32 nRepeatColumns, const sal_Int32 
nStyleIndex,
         const sal_Int32 nIndex, const bool bIsAutoStyle, const bool 
bIsVisible);
     void WriteColumn(const sal_Int32 nColumn, const sal_Int32 nRepeatColumns,

Reply via email to