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

Kohei Yoshida kohei.yoshida at collabora.com
Fri May 16 08:20:35 PDT 2014


 sc/source/core/data/conditio.cxx |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

New commits:
commit 5b76a0057a25966f48caed78bcff21b72fdbdda2
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue May 13 22:46:17 2014 -0400

    fdo#76710: Adjust sheet position of conditional format entries.
    
    When inserting or deleting sheets.
    
    Change-Id: Ibf898350e22f092ec38b75ad98957832a5580e6a
    (cherry picked from commit 146f6e7e68ea56f79b72047b97bd9fba66db499d)
    Reviewed-on: https://gerrit.libreoffice.org/9350
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 5e8e549..602446c 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -2004,12 +2004,49 @@ void ScConditionalFormat::InsertCol(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd,
 
 void ScConditionalFormat::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt )
 {
+    for (size_t i = 0, n = maRanges.size(); i < n; ++i)
+    {
+        // We assume that the start and end sheet indices are equal.
+        ScRange* pRange = maRanges[i];
+        SCTAB nTab = pRange->aStart.Tab();
+
+        if (nTab < rCxt.mnInsertPos)
+            // Unaffected.
+            continue;
+
+        pRange->aStart.IncTab(rCxt.mnSheets);
+        pRange->aEnd.IncTab(rCxt.mnSheets);
+    }
+
     for (CondFormatContainer::iterator it = maEntries.begin(); it != maEntries.end(); ++it)
         it->UpdateInsertTab(rCxt);
 }
 
 void ScConditionalFormat::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt )
 {
+    for (size_t i = 0, n = maRanges.size(); i < n; ++i)
+    {
+        // We assume that the start and end sheet indices are equal.
+        ScRange* pRange = maRanges[i];
+        SCTAB nTab = pRange->aStart.Tab();
+
+        if (nTab < rCxt.mnDeletePos)
+            // Left of the deleted sheet(s).  Unaffected.
+            continue;
+
+        if (nTab <= rCxt.mnDeletePos+rCxt.mnSheets-1)
+        {
+            // On the deleted sheet(s).
+            pRange->aStart.SetTab(-1);
+            pRange->aEnd.SetTab(-1);
+            continue;
+        }
+
+        // Right of the deleted sheet(s).  Adjust the sheet indices.
+        pRange->aStart.IncTab(-1*rCxt.mnSheets);
+        pRange->aEnd.IncTab(-1*rCxt.mnSheets);
+    }
+
     for (CondFormatContainer::iterator it = maEntries.begin(); it != maEntries.end(); ++it)
         it->UpdateDeleteTab(rCxt);
 }


More information about the Libreoffice-commits mailing list