don't bother tracking changes if both cells are empty (tdf#141174)

AppendContent() does something only if the cells differ, which can't
be the case if they're both empty, so skip unallocated cells.

Change-Id: I367801bac30a8ee641b4ce608392124bac6ef47a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131060
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index ab0cd2a..55530e4 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -2689,10 +2689,15 @@ void ScChangeTrack::AppendContentRange( const ScRange& rRange,
        for ( SCTAB nTab = nTab1; nTab <= nTab2; nTab++ )
        {
            aPos.SetTab( nTab );
            for ( SCCOL nCol = nCol1; nCol <= nCol2; nCol++ )
            // AppendContent() is a no-op if both cells are empty.
            SCCOL lastCol = std::max( pRefDoc->ClampToAllocatedColumns( nTab, nCol2 ),
                                      rDoc.ClampToAllocatedColumns( nTab, nCol2 ));
            for ( SCCOL nCol = nCol1; nCol <= lastCol; nCol++ )
            {
                aPos.SetCol( nCol );
                for ( SCROW nRow = nRow1; nRow <= nRow2; nRow++ )
                SCROW lastRow = std::max( pRefDoc->GetLastDataRow( nTab, nCol, nCol, nRow2 ),
                                          rDoc.GetLastDataRow( nTab, nCol, nCol, nRow2 ));
                for ( SCROW nRow = nRow1; nRow <= lastRow; nRow++ )
                {
                    aPos.SetRow( nRow );
                    AppendContent( aPos, pRefDoc );