[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/source

Eike Rathke erack at redhat.com
Wed Jun 21 22:49:58 UTC 2017


 sc/source/core/tool/token.cxx |   59 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

New commits:
commit e074090cea379716096d7025a62ad1c756b4d14f
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Jun 21 19:42:36 2017 +0200

    Resolves: tdf#108671 mark named expression single reference #REF! if deleted
    
    Probably broken already since
    
        commit f77c9d5b3cb65d9c2e2417f60bec1113feac50e1
        Date:   Mon Jul 29 14:47:07 2013 -0400
    
    Change-Id: If90a959d000a1bf5ab0804deb22d5cfad413ea5e
    (cherry picked from commit 6580e171ad054dca38f55822e67a400191cecdf5)
    Reviewed-on: https://gerrit.libreoffice.org/39071
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 91100ef32c15..027786958ceb 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -3657,6 +3657,65 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInName(
                 case svSingleRef:
                     {
                         ScSingleRefData& rRef = *p->GetSingleRef();
+                        if (rCxt.mnRowDelta < 0)
+                        {
+                            // row(s) deleted.
+
+                            if (rRef.IsRowRel())
+                                // Don't modify relative references in names.
+                                break;
+
+                            ScAddress aAbs = rRef.toAbs(rPos);
+
+                            if (aAbs.Col() < rCxt.maRange.aStart.Col() || rCxt.maRange.aEnd.Col() < aAbs.Col())
+                                // column of the reference is not in the deleted column range.
+                                break;
+
+                            if (aAbs.Tab() > rCxt.maRange.aEnd.Tab() || aAbs.Tab() < rCxt.maRange.aStart.Tab())
+                                // wrong tables
+                                break;
+
+                            const SCROW nDelStartRow = rCxt.maRange.aStart.Row() + rCxt.mnRowDelta;
+                            const SCROW nDelEndRow = nDelStartRow - rCxt.mnRowDelta - 1;
+
+                            if (nDelStartRow <= aAbs.Row() && aAbs.Row() <= nDelEndRow)
+                            {
+                                // This reference is deleted.
+                                rRef.SetRowDeleted(true);
+                                aRes.mbReferenceModified = true;
+                                break;
+                            }
+                        }
+                        else if (rCxt.mnColDelta < 0)
+                        {
+                            // column(s) deleted.
+
+                            if (rRef.IsColRel())
+                                // Don't modify relative references in names.
+                                break;
+
+                            ScAddress aAbs = rRef.toAbs(rPos);
+
+                            if (aAbs.Row() < rCxt.maRange.aStart.Row() || rCxt.maRange.aEnd.Row() < aAbs.Row())
+                                // row of the reference is not in the deleted row range.
+                                break;
+
+                            if (aAbs.Tab() > rCxt.maRange.aEnd.Tab() || aAbs.Tab() < rCxt.maRange.aStart.Tab())
+                                // wrong tables
+                                break;
+
+                            const SCCOL nDelStartCol = rCxt.maRange.aStart.Col() + rCxt.mnColDelta;
+                            const SCCOL nDelEndCol = nDelStartCol - rCxt.mnColDelta - 1;
+
+                            if (nDelStartCol <= aAbs.Col() && aAbs.Col() <= nDelEndCol)
+                            {
+                                // This reference is deleted.
+                                rRef.SetColDeleted(true);
+                                aRes.mbReferenceModified = true;
+                                break;
+                            }
+                        }
+
                         if (adjustSingleRefInName(rRef, rCxt, rPos, nullptr))
                             aRes.mbReferenceModified = true;
                     }


More information about the Libreoffice-commits mailing list