tdf#142932: fix crash when pasting cells with comments+"skip empty cells"

See bt here:
https://bugs.documentfoundation.org/attachment.cgi?id=173011

4  0x00007fc4b0cdbb3d in ScColContainer::operator[](unsigned long) (this=0x872e1e0, nIndex=64) at sc/inc/colcontainer.hxx:43
5  0x00007fc4b120d82b in ScTable::DeleteBeforeCopyFromClip(sc::CopyFromClipContext&, ScTable const&, sc::ColumnSpanSet&) (this=0x872e1e0, rCxt=..., rClipTab=..., rBroadcastSpans=...)
   at sc/source/core/data/table7.cxx:118
6  0x00007fc4b0e42939 in ScDocument::DeleteBeforeCopyFromClip(sc::CopyFromClipContext&, ScMarkData const&, sc::ColumnSpanSet&) (this=0x3bffa60, rCxt=..., rMark=..., rBroadcastSpans=...)
   at sc/source/core/data/document10.cxx:75
7  0x00007fc4b0e0b67b in ScDocument::CopyFromClip(ScRange const&, ScMarkData const&, InsertDeleteFlags, ScDocument*, ScDocument*, bool, bool, bool, bool, ScRangeList const*)
   (this=0x3bffa60, rDestRange=..., rMark=..., nInsFlag=7, pRefUndoDoc=0x0, pClipDoc=0x7d3bb40, bResetCut=true, bAsLink=false, bIncludeFiltered=false, bSkipAttrForEmpty=true, pDestRanges=0x7fff4a3da4b0)
   at sc/source/core/data/document.cxx:2916
8  0x00007fc4b2412dc3 in ScViewFunc::PasteFromClip(InsertDeleteFlags, ScDocument*, ScPasteFunc, bool, bool, bool, InsCellCmd, InsertDeleteFlags, bool) (this=
   0x41a29e0, nFlags=7, pClipDoc=0x7d3bb40, nFunction=ScPasteFunc::NONE, bSkipEmpty=true, bTranspose=false, bAsLink=false, eMoveMode=INS_NONE, nUndoExtraFlags=InsertDeleteFlags::NONE, bAllowDialogs=true)
   at sc/source/ui/view/viewfun3.cxx:1312

Change-Id: Ic119cb5d414a35a9ba18b0564d7adf83154eb9d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117497
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit a6d269ed9478b20f611912bf9711c2683e7bc924)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117632
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index 6ec79a9..2ab726e 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -109,7 +109,8 @@ void ScTable::DeleteBeforeCopyFromClip(
    ScRange aClipRange = rCxt.getClipDoc()->GetClipParam().getWholeRange();
    SCCOL nClipCol = aClipRange.aStart.Col();
    {
        for (SCCOL nCol = aRange.mnCol1; nCol <= aRange.mnCol2; ++nCol, ++nClipCol)
        const SCCOL nMaxCol2 = std::min<SCCOL>( aRange.mnCol2, aCol.size() - 1 );
        for (SCCOL nCol = aRange.mnCol1; nCol <= nMaxCol2; ++nCol, ++nClipCol)
        {
            if (nClipCol > aClipRange.aEnd.Col())
                nClipCol = aClipRange.aStart.Col(); // loop through columns.