[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Eike Rathke
erack at redhat.com
Fri Mar 25 21:15:37 UTC 2016
sc/qa/unit/ucalc_formula.cxx | 33 +++++++++++++++++++++++++++++++++
sc/source/core/data/formulacell.cxx | 5 +++--
2 files changed, 36 insertions(+), 2 deletions(-)
New commits:
commit 19567deb49cdb4a49f251b1aacb305f68aee3c4a
Author: Eike Rathke <erack at redhat.com>
Date: Fri Mar 25 22:13:13 2016 +0100
unit test for copying sheet-local names before original position
Change-Id: I3a70539480b5b1d85b717fd6638359aa9ce5075a
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 8e8d092..6c1ac90 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -3183,6 +3183,39 @@ void Test::testFormulaRefUpdateNameCopySheet()
m_pDoc->DeleteTab(2);
m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0);
+
+ m_pDoc->InsertTab(0, "Test2");
+ // Local name referencing sheet Test2.
+ bInserted = m_pDoc->GetRangeName(0)->insert( new ScRangeData( m_pDoc, "localname", "$Test2.$A$1"));
+ CPPUNIT_ASSERT(bInserted);
+ m_pDoc->SetString(ScAddress(0,0,0), "=SHEET()");
+ m_pDoc->SetString(ScAddress(1,0,0), "=localname");
+ nVal = m_pDoc->GetValue(1,0,0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Localname sheet number should be 1", 1.0, nVal);
+
+ // Insert sheet before and shift sheet with local name.
+ m_pDoc->InsertTab(0, "Test1");
+ pName = m_pDoc->GetRangeName(1)->findByUpperName("LOCALNAME");
+ CPPUNIT_ASSERT_MESSAGE("Org sheet-local name should exist", pName);
+ nVal = m_pDoc->GetValue(1,0,1);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Localname sheet number should be 2", 2.0, nVal);
+
+ // Copy sheet before, shifting following now two sheets.
+ m_pDoc->CopyTab(1, 0);
+ pName = m_pDoc->GetRangeName(0)->findByUpperName("LOCALNAME");
+ CPPUNIT_ASSERT_MESSAGE("New sheet-local name should exist", pName);
+ nVal = m_pDoc->GetValue(1,0,0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("New sheet number should be 1", 1.0, nVal);
+ pName = m_pDoc->GetRangeName(1)->findByUpperName("LOCALNAME");
+ CPPUNIT_ASSERT_MESSAGE("Old sheet-local name should not exist", !pName);
+ pName = m_pDoc->GetRangeName(2)->findByUpperName("LOCALNAME");
+ CPPUNIT_ASSERT_MESSAGE("Org sheet-local name should exist", pName);
+ nVal = m_pDoc->GetValue(1,0,2);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("New sheet number should be 3", 3.0, nVal);
+
+ m_pDoc->DeleteTab(2);
+ m_pDoc->DeleteTab(1);
+ m_pDoc->DeleteTab(0);
}
void Test::testFormulaRefUpdateNameDelete()
commit 0189bfe9828c3f52cd72cf2f9da22d110e08c327
Author: Eike Rathke <erack at redhat.com>
Date: Fri Mar 25 21:36:00 2016 +0100
sheet-local names' references of original sheet are updated later
... in contrast to global names that are already updated before content
is copied. So don't modify the token's original sheet number before
adjusting the copied sheet-local names' references.
Change-Id: I3edfb53370a5e8811d7301af95238a865ff38f0c
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 1939f21..a8f8291 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -485,12 +485,13 @@ void adjustRangeName(formula::FormulaToken* pToken, ScDocument& rNewDoc, const S
// Search the name of the RangeName.
if (nOldSheet >= 0)
{
+ SCTAB nOldTab = nOldSheet;
// XXX bGlobalNamesToLocal is also a synonym for copied sheet.
if (bGlobalNamesToLocal && bSameDoc && rNewPos.Tab() <= rOldPos.Tab())
// Sheet was already inserted before old position.
- ++nOldSheet;
+ ++nOldTab;
- const ScRangeName* pRangeName = pOldDoc->GetRangeName(nOldSheet);
+ const ScRangeName* pRangeName = pOldDoc->GetRangeName(nOldTab);
pOldRangeData = pRangeName ? pRangeName->findByIndex(nOldIndex) : nullptr;
if (!pOldRangeData)
return; // might be an error in the formula array
More information about the Libreoffice-commits
mailing list