[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri May 9 08:45:51 PDT 2014


 sc/qa/unit/ucalc.cxx             |    9 +++++++++
 sc/source/core/data/document.cxx |   20 ++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit a45973a90625f4b9e0f603154194f357ff2418d4
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri May 9 11:44:51 2014 -0400

    fdo#77806: Check the boundaries before accessing an array....
    
    Change-Id: I0878f734599f566cde83183947cd7613c0f8d5c6

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 181f294..414abd4 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6135,14 +6135,30 @@ bool ScDocument::HasNote(const ScAddress& rPos) const
 {
     return HasNote(rPos.Col(), rPos.Row(), rPos.Tab());
 }
+
 bool ScDocument::HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const
 {
-    const ScPostIt* pNote = maTabs[nTab]->aCol[nCol].GetCellNote(nRow);
+    if (!ValidColRow(nCol, nRow))
+        return false;
+
+    const ScTable* pTab = FetchTable(nTab);
+    if (!pTab)
+        return false;
+
+    const ScPostIt* pNote = pTab->aCol[nCol].GetCellNote(nRow);
     return pNote != NULL;
 }
+
 bool ScDocument::HasColNotes(SCCOL nCol, SCTAB nTab) const
 {
-    return maTabs[nTab]->aCol[nCol].HasCellNotes();
+    if (!ValidCol(nCol))
+        return false;
+
+    const ScTable* pTab = FetchTable(nTab);
+    if (!pTab)
+        return false;
+
+    return pTab->aCol[nCol].HasCellNotes();
 }
 
 bool ScDocument::HasTabNotes(SCTAB nTab) const
commit cd87cd92b95861e5cacb111dc33a809a9db884e3
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri May 9 11:44:28 2014 -0400

    fdo#77806: Write test for this.
    
    Change-Id: Ic05b6fec2bfc89688cb1670a163f27caccc7f213

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index d764673..1ca19b8 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5176,6 +5176,15 @@ void Test::testNoteBasic()
 {
     m_pDoc->InsertTab(0, "PostIts");
 
+    CPPUNIT_ASSERT(!m_pDoc->HasNotes());
+
+    // Check for note's presence in all tables before inserting any notes.
+    for (SCTAB i = 0; i <= MAXTAB; ++i)
+    {
+        bool bHasNotes = m_pDoc->HasTabNotes(i);
+        CPPUNIT_ASSERT(!bHasNotes);
+    }
+
     ScAddress aAddr(2, 2, 0); // cell C3
     ScPostIt *pNote = m_pDoc->GetOrCreateNote(aAddr);
 


More information about the Libreoffice-commits mailing list