sc/inc/document.hxx                    |    4 ++--
 sc/qa/unit/subsequent_filters-test.cxx |    2 +-
 sc/qa/unit/ucalc.cxx                   |    6 +++---
 sc/source/core/data/document.cxx       |   11 ++++-------
 sc/source/ui/view/drawvie4.cxx         |    2 +-
 5 files changed, 11 insertions(+), 14 deletions(-)

New commits:
commit 3fd389ffe987d3b10f55e73b1b61a9babb88785d
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Sep 15 10:02:30 2020 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Sep 16 09:44:34 2020 +0200

    CopyStaticToDocument never passed a null ScDocument*
    
    Change-Id: I1cd3b0f6b17e7b8e3430cb2aaa5cd1c78c8abc46
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102792
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 36bd437c2773..1b756f8e82fb 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1577,9 +1577,9 @@ public:
      *
      * @param rSrcRange source range in the source document
      * @param nDestTab table in the clip document to copy to.
-     * @param pDestDoc document to copy to
+     * @param rDestDoc document to copy to
      */
-    SC_DLLPUBLIC void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB 
nDestTab, ScDocument* pDestDoc);
+    SC_DLLPUBLIC void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB 
nDestTab, ScDocument& rDestDoc);
 
     /**
      * Copy only cell, nothing but cell to another document.
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 0f0f39a419c0..42118a15fc4c 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -3416,7 +3416,7 @@ void ScFiltersTest::testCopyMergedNumberFormats()
 
     ScDocument aCopyDoc;
     aCopyDoc.InsertTab(0, "CopyHere");
-    rDoc.CopyStaticToDocument(ScRange(1,0,0,3,0,0), 0, &aCopyDoc);
+    rDoc.CopyStaticToDocument(ScRange(1,0,0,3,0,0), 0, aCopyDoc);
 
     // Make sure the date formats are copied to the new document.
     CPPUNIT_ASSERT_EQUAL(aStrB1, aCopyDoc.GetString(ScAddress(1,0,0)));
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index bfb741b07166..7d18f131852d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -857,9 +857,9 @@ void Test::testCopyToDocument()
     pDestDoc->InsertTab(0, "src");
     pDestDoc->InitDrawLayer(xDocSh2.get());     // for note caption objects
 
-    m_pDoc->CopyStaticToDocument(ScRange(0,1,0,0,3,0), 0, pDestDoc); // Copy 
A2:A4
-    m_pDoc->CopyStaticToDocument(ScAddress(0,0,0), 0,     pDestDoc); // Copy A1
-    m_pDoc->CopyStaticToDocument(ScRange(0,4,0,0,7,0), 0, pDestDoc); // Copy 
A5:A8
+    m_pDoc->CopyStaticToDocument(ScRange(0,1,0,0,3,0), 0, *pDestDoc); // Copy 
A2:A4
+    m_pDoc->CopyStaticToDocument(ScAddress(0,0,0), 0,     *pDestDoc); // Copy 
A1
+    m_pDoc->CopyStaticToDocument(ScRange(0,4,0,0,7,0), 0, *pDestDoc); // Copy 
A5:A8
 
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,0,0), pDestDoc->GetString(0,0,0));
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,1,0), pDestDoc->GetString(0,1,0));
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 6ccd0dfa9b66..86fe8a318263 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2244,19 +2244,16 @@ void ScDocument::CopyToClip(const ScClipParam& 
rClipParam,
     pClipDoc->ExtendMerge(aClipRange, true);
 }
 
-void ScDocument::CopyStaticToDocument(const ScRange& rSrcRange, SCTAB 
nDestTab, ScDocument* pDestDoc)
+void ScDocument::CopyStaticToDocument(const ScRange& rSrcRange, SCTAB 
nDestTab, ScDocument& rDestDoc)
 {
-    if (!pDestDoc)
-        return;
-
     ScTable* pSrcTab = rSrcRange.aStart.Tab() < 
static_cast<SCTAB>(maTabs.size()) ? maTabs[rSrcRange.aStart.Tab()].get() : 
nullptr;
-    ScTable* pDestTab = nDestTab < static_cast<SCTAB>(pDestDoc->maTabs.size()) 
? pDestDoc->maTabs[nDestTab].get() : nullptr;
+    ScTable* pDestTab = nDestTab < static_cast<SCTAB>(rDestDoc.maTabs.size()) 
? rDestDoc.maTabs[nDestTab].get() : nullptr;
 
     if (!pSrcTab || !pDestTab)
         return;
 
-    pDestDoc->GetFormatTable()->MergeFormatter(*GetFormatTable());
-    SvNumberFormatterMergeMap aMap = 
pDestDoc->GetFormatTable()->ConvertMergeTableToMap();
+    rDestDoc.GetFormatTable()->MergeFormatter(*GetFormatTable());
+    SvNumberFormatterMergeMap aMap = 
rDestDoc.GetFormatTable()->ConvertMergeTableToMap();
 
     pSrcTab->CopyStaticToDocument(
         rSrcRange.aStart.Col(), rSrcRange.aStart.Row(), rSrcRange.aEnd.Col(), 
rSrcRange.aEnd.Row(),
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
index f07c44c6904e..66102caa1b23 100644
--- a/sc/source/ui/view/drawvie4.cxx
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -287,7 +287,7 @@ public:
             // Sheet by this name doesn't exist.
             return;
 
-        mrSrc.CopyStaticToDocument(rRange, nTab, &mrDest);
+        mrSrc.CopyStaticToDocument(rRange, nTab, mrDest);
     }
 };
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to