[Libreoffice-commits] core.git: sc/inc sc/Library_scopencl.mk sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Wed Oct 23 12:42:39 PDT 2013


 sc/Library_scopencl.mk            |    1 
 sc/inc/column.hxx                 |   37 +++++++-----
 sc/inc/document.hxx               |   30 +++++----
 sc/inc/postit.hxx                 |   12 +++
 sc/inc/table.hxx                  |   36 +++++++----
 sc/source/core/data/column2.cxx   |   76 ++++++++++++++++++++++++
 sc/source/core/data/document.cxx  |   72 +++++++++++++++++++----
 sc/source/core/data/postit.cxx    |    8 ++
 sc/source/core/data/table2.cxx    |   22 +++++++
 sc/source/filter/excel/excdoc.cxx |   34 +----------
 sc/source/ui/navipi/content.cxx   |  116 +++++---------------------------------
 sc/source/ui/unoobj/docuno.cxx    |   41 +------------
 12 files changed, 269 insertions(+), 216 deletions(-)

New commits:
commit 3347f41a9b13c317c1d001e7ff501a4b0ee8f896
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Oct 23 13:17:00 2013 -0400

    Avoid exposing the internal cell note storage outside ScDocument.
    
    Let's try to avoid including mtvelements.hxx in document.hxx...
    
    mtvelements.hxx is very parser-heavy, and document.hxx is included
    everywhere...
    
    Change-Id: I2768ba6e25f8ff10f61f9cfd4a7cbc4844230630

diff --git a/sc/Library_scopencl.mk b/sc/Library_scopencl.mk
index 75dcaf0..cb702e8 100644
--- a/sc/Library_scopencl.mk
+++ b/sc/Library_scopencl.mk
@@ -21,7 +21,6 @@ $(eval $(call gb_Library_use_sdk_api,scopencl))
 
 $(eval $(call gb_Library_use_externals,scopencl,\
         boost_headers \
-		mdds_headers \
 ))
 
 $(eval $(call gb_Library_use_libraries,scopencl,\
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 042cd72..ca0374e 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -38,21 +38,24 @@ namespace editeng { class SvxBorderLine; }
 namespace formula { struct VectorRefArray; }
 
 namespace sc {
-    struct FormulaGroupContext;
-    class StartListeningContext;
-    class EndListeningContext;
-    class CopyFromClipContext;
-    class CopyToClipContext;
-    class CopyToDocContext;
-    class MixDocContext;
-    class ColumnSpanSet;
-    struct ColumnBlockPosition;
-    class SingleColumnSpanSet;
-    struct RefUpdateContext;
-    struct RefUpdateInsertTabContext;
-    struct RefUpdateDeleteTabContext;
-    struct RefUpdateMoveTabContext;
-    class EditTextIterator;
+
+struct FormulaGroupContext;
+class StartListeningContext;
+class EndListeningContext;
+class CopyFromClipContext;
+class CopyToClipContext;
+class CopyToDocContext;
+class MixDocContext;
+class ColumnSpanSet;
+struct ColumnBlockPosition;
+class SingleColumnSpanSet;
+struct RefUpdateContext;
+struct RefUpdateInsertTabContext;
+struct RefUpdateDeleteTabContext;
+struct RefUpdateMoveTabContext;
+class EditTextIterator;
+struct NoteEntry;
+
 }
 
 class Fraction;
@@ -500,6 +503,10 @@ public:
     void SetCellNote( SCROW nRow, ScPostIt* pNote);
     bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
 
+    size_t GetNoteCount() const;
+    SCROW GetNotePosition( size_t nIndex ) const;
+    void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
+
     SCROW GetCellNotesMaxRow() const;
     SCROW GetCellNotesMinRow() const;
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 516ccc0..752984d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -48,8 +48,6 @@
 #include <boost/scoped_ptr.hpp>
 #include "markdata.hxx"
 
-#include "mtvelements.hxx"
-
 namespace editeng { class SvxBorderLine; }
 namespace formula { struct VectorRefArray; }
 namespace svl {
@@ -60,14 +58,17 @@ class SharedStringPool;
 }
 
 namespace sc {
-    struct FormulaGroupContext;
-    class StartListeningContext;
-    class EndListeningContext;
-    class CopyFromClipContext;
-    class ColumnSpanSet;
-    struct ColumnBlockPosition;
-    struct RefUpdateContext;
-    class EditTextIterator;
+
+struct FormulaGroupContext;
+class StartListeningContext;
+class EndListeningContext;
+class CopyFromClipContext;
+class ColumnSpanSet;
+struct ColumnBlockPosition;
+struct RefUpdateContext;
+class EditTextIterator;
+struct NoteEntry;
+
 }
 
 class SvxFontItem;
@@ -905,8 +906,13 @@ public:
     SC_DLLPUBLIC ScPostIt*       ReleaseNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
     SC_DLLPUBLIC ScPostIt*       GetOrCreateNote(const ScAddress& rPos);
     SC_DLLPUBLIC ScPostIt*       CreateNote(const ScAddress& rPos);
-    sal_uLong                    CountNotes();
-    SC_DLLPUBLIC sc::CellNoteStoreType&  GetColNotes(SCCOL nCol, SCTAB nTab);
+    size_t CountNotes() const;
+    size_t GetNoteCount( SCTAB nTab, SCCOL nCol ) const;
+
+    ScAddress GetNotePosition( size_t nIndex ) const;
+    SCROW GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const;
+
+    SC_DLLPUBLIC void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
 
     SC_DLLPUBLIC void            SetDrawPageSize(SCTAB nTab);
 
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index 9a7c60a..d31dcfd 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -244,5 +244,17 @@ public:
 
 };
 
+namespace sc {
+
+struct NoteEntry
+{
+    ScAddress maPos;
+    const ScPostIt* mpNote;
+
+    NoteEntry( const ScAddress& rPos, const ScPostIt* pNote );
+};
+
+}
+
 #endif
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 586cf82..3c7aa0e 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -51,20 +51,23 @@ namespace com { namespace sun { namespace star {
 
 namespace formula { struct VectorRefArray; }
 namespace sc {
-    struct FormulaGroupContext;
-    class StartListeningContext;
-    class EndListeningContext;
-    class CopyFromClipContext;
-    class CopyToClipContext;
-    class CopyToDocContext;
-    class MixDocContext;
-    class ColumnSpanSet;
-    class ColumnSet;
-    struct ColumnBlockPosition;
-    struct RefUpdateContext;
-    struct RefUpdateInsertTabContext;
-    struct RefUpdateDeleteTabContext;
-    struct RefUpdateMoveTabContext;
+
+struct FormulaGroupContext;
+class StartListeningContext;
+class EndListeningContext;
+class CopyFromClipContext;
+class CopyToClipContext;
+class CopyToDocContext;
+class MixDocContext;
+class ColumnSpanSet;
+class ColumnSet;
+struct ColumnBlockPosition;
+struct RefUpdateContext;
+struct RefUpdateInsertTabContext;
+struct RefUpdateDeleteTabContext;
+struct RefUpdateMoveTabContext;
+struct NoteEntry;
+
 }
 
 class SfxItemSet;
@@ -375,6 +378,11 @@ public:
 
     ScPostIt*   GetNote(const SCCOL nCol, const SCROW nRow);
 
+    size_t GetNoteCount( SCCOL nCol ) const;
+    SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const;
+
+    void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
+
     bool TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const;
     void        InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize );
     void DeleteRow(
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 0027ed8..a3bdef5 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1214,6 +1214,82 @@ bool ScColumn::IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
     return nEndRow < nNextRow;
 }
 
+size_t ScColumn::GetNoteCount() const
+{
+    size_t nCount = 0;
+    sc::CellNoteStoreType::const_iterator it = maCellNotes.begin(), itEnd = maCellNotes.end();
+    for (; it != itEnd; ++it)
+    {
+        if (it->type != sc::element_type_cellnote)
+            continue;
+
+        nCount += it->size;
+    }
+
+    return nCount;
+}
+
+SCROW ScColumn::GetNotePosition( size_t nIndex ) const
+{
+    // Return the row position of the nth note in the column.
+
+    sc::CellNoteStoreType::const_iterator it = maCellNotes.begin(), itEnd = maCellNotes.end();
+
+    size_t nCount = 0; // Number of notes encountered so far.
+    for (; it != itEnd; ++it)
+    {
+        if (!it->type != sc::element_type_cellnote)
+            // Skip the empty blocks.
+            continue;
+
+        if (nIndex < nCount + it->size)
+        {
+            // Index falls within this block.
+            size_t nOffset = nIndex - nCount;
+            return it->position + nOffset;
+        }
+
+        nCount += it->size;
+    }
+
+    return -1;
+}
+
+namespace {
+
+class NoteEntryCollector
+{
+    std::vector<sc::NoteEntry>& mrNotes;
+    SCTAB mnTab;
+    SCCOL mnCol;
+public:
+    NoteEntryCollector( std::vector<sc::NoteEntry>& rNotes, SCTAB nTab, SCCOL nCol ) :
+        mrNotes(rNotes), mnTab(nTab), mnCol(nCol) {}
+
+    void operator() (const sc::CellNoteStoreType::value_type& node) const
+    {
+        if (node.type != sc::element_type_cellnote)
+            return;
+
+        size_t nTopRow = node.position;
+        sc::cellnote_block::const_iterator it = sc::cellnote_block::begin(*node.data);
+        sc::cellnote_block::const_iterator itEnd = sc::cellnote_block::end(*node.data);
+        size_t nOffset = 0;
+        for (; it != itEnd; ++it, ++nOffset)
+        {
+            ScAddress aPos(mnCol, nTopRow + nOffset, mnTab);
+            mrNotes.push_back(sc::NoteEntry(aPos, *it));
+        }
+    }
+};
+
+}
+
+void ScColumn::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const
+{
+    std::for_each(maCellNotes.begin(), maCellNotes.end(), NoteEntryCollector(rNotes, nTab, nCol));
+}
+
 SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const
 {
     // Given a range of rows, find a top or bottom empty segment.
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index a6180bc..30c9256 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6073,10 +6073,7 @@ ScPostIt* ScDocument::GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab)
         return NULL;
 
 }
-sc::CellNoteStoreType& ScDocument::GetColNotes(SCCOL nCol, SCTAB nTab)
-{
-        return maTabs[nTab]->aCol[nCol].maCellNotes;
-}
+
 void ScDocument::SetNote(const ScAddress& rPos, ScPostIt* pNote)
 {
     return SetNote(rPos.Col(), rPos.Row(), rPos.Tab(), pNote);
@@ -6138,24 +6135,75 @@ ScPostIt* ScDocument::CreateNote(const ScAddress& rPos)
     return pPostIt;
 }
 
-sal_uLong ScDocument::CountNotes()
+size_t ScDocument::CountNotes() const
 {
-    sal_uLong nCount = 0;
+    size_t nCount = 0;
     SCTAB nTabCount = GetTableCount();
     for (SCTAB nTab=0; nTab<nTabCount; nTab++)
     {
         for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
+            nCount += GetNoteCount(nTab, nCol);
+    }
+    return nCount;
+}
+
+size_t ScDocument::GetNoteCount( SCTAB nTab, SCCOL nCol ) const
+{
+    const ScTable* pTab = FetchTable(nTab);
+    if (!pTab)
+        return 0;
+
+    return pTab->GetNoteCount(nCol);
+}
+
+ScAddress ScDocument::GetNotePosition( size_t nIndex ) const
+{
+    for (size_t nTab = 0; nTab < maTabs.size(); ++nTab)
+    {
+        for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
         {
-            sc::CellNoteStoreType& maCellNotes = GetColNotes(nCol, nTab);
-            sc::CellNoteStoreType::const_iterator it = maCellNotes.begin(), itEnd = maCellNotes.end();
-            for (; it != itEnd; ++it)
+            size_t nColNoteCount = GetNoteCount(nTab, nCol);
+            if (!nColNoteCount)
+                continue;
+
+            if (nIndex >= nColNoteCount)
             {
-               if (it->type == sc::element_type_cellnote)
-                    nCount +=it->size;
+                nIndex -= nColNoteCount;
+                continue;
             }
+
+            SCROW nRow = GetNotePosition(nTab, nCol, nIndex);
+            if (nRow >= 0)
+                return ScAddress(nCol, nRow, nTab);
+
+            OSL_FAIL("note not found");
+            return ScAddress();
         }
     }
-    return nCount;
+
+    OSL_FAIL("note not found");
+    return ScAddress();
+}
+
+SCROW ScDocument::GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const
+{
+    const ScTable* pTab = FetchTable(nTab);
+    if (!pTab)
+        return -1;
+
+    return pTab->GetNotePosition(nCol, nIndex);
+}
+
+void ScDocument::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const
+{
+    for (size_t nTab = 0; nTab < maTabs.size(); ++nTab)
+    {
+        const ScTable* pTab = maTabs[nTab];
+        if (!pTab)
+            continue;
+
+        pTab->GetAllNoteEntries(rNotes);
+    }
 }
 
 void ScDocument::SetAutoNameCache(  ScAutoNameCache* pCache )
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 67f7303..dfd143d 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -936,4 +936,12 @@ ScPostIt* ScNoteUtil::CreateNoteFromString(
     }
     return pNote;
 }
+
+namespace sc {
+
+NoteEntry::NoteEntry( const ScAddress& rPos, const ScPostIt* pNote ) :
+    maPos(rPos), mpNote(pNote) {}
+
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 312aa22..5295af6 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1502,6 +1502,28 @@ ScPostIt* ScTable::GetNote(const SCCOL nCol, const SCROW nRow)
     return pDocument->GetNote(nCol, nRow, nTab);
 }
 
+size_t ScTable::GetNoteCount( SCCOL nCol ) const
+{
+    if (!ValidCol(nCol))
+        return 0;
+
+    return aCol[nCol].GetNoteCount();
+}
+
+SCROW ScTable::GetNotePosition( SCCOL nCol, size_t nIndex ) const
+{
+    if (!ValidCol(nCol))
+        return -1;
+
+    return aCol[nCol].GetNotePosition(nIndex);
+}
+
+void ScTable::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const
+{
+    for (SCCOL nCol = 0; nCol < MAXCOLCOUNT; ++nCol)
+        aCol[nCol].GetAllNoteEntries(rNotes);
+}
+
 CellType ScTable::GetCellType( SCCOL nCol, SCROW nRow ) const
 {
     if (ValidColRow( nCol, nRow ))
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index 32db2e8..574dcbb 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -417,35 +417,11 @@ void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
     mxCellTable.reset( new XclExpCellTable( GetRoot() ) );
 
     //export cell notes
-        for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
-        {
-            if ( rDoc.HasColNotes(nCol, mnScTab) )
-            {
-                sc::CellNoteStoreType& maCellNotes = rDoc.GetColNotes(nCol, mnScTab);
-
-                sc::CellNoteStoreType::const_iterator itBlk = maCellNotes.begin(), itBlkEnd = maCellNotes.end();
-                sc::cellnote_block::const_iterator itData, itDataEnd;
-
-                for(;itBlk != itBlkEnd; ++itBlk)
-                {
-                    if (itBlk->data)
-                    {
-                        SCROW nRow = itBlk->position;
-                        itData = sc::cellnote_block::begin(*itBlk->data);
-                        itDataEnd = sc::cellnote_block::end(*itBlk->data);
-                        for (; itData != itDataEnd; ++itData, ++nRow)
-                        {
-                            ScPostIt* pScNote = *itData;
-                            if (pScNote)
-                            {
-                                ScAddress aScPos( nCol, nRow, mnScTab );
-                                mxNoteList->AppendNewRecord( new XclExpNote( GetRoot(), aScPos, pScNote, OUString() ) );
-                            }
-                        }
-                    }
-                }
-            }
-        }
+    std::vector<sc::NoteEntry> aNotes;
+    rDoc.GetAllNoteEntries(aNotes);
+    std::vector<sc::NoteEntry>::const_iterator it = aNotes.begin(), itEnd = aNotes.end();
+    for (; it != itEnd; ++it)
+        mxNoteList->AppendNewRecord(new XclExpNote(GetRoot(), it->maPos, it->mpNote, OUString()));
 
     if( GetOutput() != EXC_OUTPUT_BINARY )
     {
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 844ed81..fc70ef6 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -848,7 +848,6 @@ static OUString lcl_NoteString( const ScPostIt& rNote )
     return aText;
 }
 
-
 void ScContentTree::GetNoteStrings()
 {
     if ( nRootType && nRootType != SC_CONTENT_NOTE )        // ausgeblendet ?
@@ -859,36 +858,11 @@ void ScContentTree::GetNoteStrings()
         return;
 
     // loop over cell notes
-    SCTAB nTabCount = pDoc->GetTableCount();
-    for (SCTAB nTab=0; nTab<nTabCount; nTab++)
-    {
-        for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
-        {
-            if ( pDoc->HasColNotes(nCol, nTab) )
-            {
-                sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, nTab);
-
-                sc::CellNoteStoreType::const_iterator itBlk = maCellNotes.begin(), itBlkEnd = maCellNotes.end();
-                sc::cellnote_block::const_iterator itData, itDataEnd;
-
-                for(;itBlk != itBlkEnd; ++itBlk)
-                {
-                    if (itBlk->data)
-                    {
-                        itData = sc::cellnote_block::begin(*itBlk->data);
-                        itDataEnd = sc::cellnote_block::end(*itBlk->data);
-                        for (; itData != itDataEnd; ++itData)
-                        {
-                            ScPostIt* pNote = *itData;
-                            if (pNote)
-                                InsertContent(SC_CONTENT_NOTE, lcl_NoteString( *pNote ));
-                        }
-                    }
-
-                }
-            }
-        }
-    }
+    std::vector<sc::NoteEntry> aEntries;
+    pDoc->GetAllNoteEntries(aEntries);
+    std::vector<sc::NoteEntry>::const_iterator it = aEntries.begin(), itEnd = aEntries.end();
+    for (; it != itEnd; ++it)
+        InsertContent(SC_CONTENT_NOTE, lcl_NoteString(*it->mpNote));
 }
 
 ScAddress ScContentTree::GetNotePos( sal_uLong nIndex )
@@ -897,48 +871,9 @@ ScAddress ScContentTree::GetNotePos( sal_uLong nIndex )
     if (!pDoc)
         return ScAddress();
 
-    sal_uLong nFound = 0;
-    SCTAB nTabCount = pDoc->GetTableCount();
-
-    for (SCTAB nTab=0; nTab<nTabCount; nTab++)
-    {
-        for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
-        {
-            if ( pDoc->HasColNotes(nCol, nTab) )
-            {
-                sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, nTab);
-
-                sc::CellNoteStoreType::const_iterator itBlk = maCellNotes.begin(), itBlkEnd = maCellNotes.end();
-                sc::cellnote_block::const_iterator itData, itDataEnd;
-
-                for(;itBlk != itBlkEnd; ++itBlk)
-                {
-                    if (itBlk->data)
-                    {
-                        SCROW nRow = itBlk->position;
-                        itData = sc::cellnote_block::begin(*itBlk->data);
-                        itDataEnd = sc::cellnote_block::end(*itBlk->data);
-                        for (; itData != itDataEnd; ++itData, ++nRow)
-                        {
-                            ScPostIt* pNote = *itData;
-                            if (pNote)
-                            {
-                                if (nFound == nIndex)
-                                    return ScAddress(nCol, nRow, nTab);
-                                ++nFound;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    OSL_FAIL("note not found");
-    return ScAddress();
+    return pDoc->GetNotePosition(nIndex);
 }
 
-
 sal_Bool ScContentTree::NoteStringsChanged()
 {
     ScDocument* pDoc = GetSourceDocument();
@@ -952,35 +887,20 @@ sal_Bool ScContentTree::NoteStringsChanged()
     SvTreeListEntry* pEntry = FirstChild( pParent );
 
     bool bEqual = true;
-    SCTAB nTabCount = pDoc->GetTableCount();
-    for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
+    std::vector<sc::NoteEntry> aEntries;
+    pDoc->GetAllNoteEntries(aEntries);
+    std::vector<sc::NoteEntry>::const_iterator it = aEntries.begin(), itEnd = aEntries.end();
+    for (; it != itEnd; ++it)
     {
-        for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
+        const ScPostIt* pNote = it->mpNote;
+        if (!pEntry)
+            bEqual = false;
+        else
         {
-            if ( pDoc->HasColNotes(nCol, nTab) )
-            {
-                sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, nTab);
-                sc::CellNoteStoreType::const_iterator it = maCellNotes.begin(), itEnd = maCellNotes.end();
-                for (; it != itEnd; ++it)
-                {
-                    if (it->type == sc::element_type_cellnote)
-                    {
-                        SCROW nRow = it->position;
-                        ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
-                        if (pNote)
-                        {
-                            if ( !pEntry )
-                                bEqual = false;
-                            else
-                            {
-                                if ( lcl_NoteString( *pNote ) != GetEntryText(pEntry) )
-                                    bEqual = false;
-                                pEntry = NextSibling( pEntry );
-                            }
-                        }
-                    }
-                }
-            }
+            if (lcl_NoteString(*pNote) != GetEntryText(pEntry))
+                bEqual = false;
+
+            pEntry = NextSibling(pEntry);
         }
     }
 
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 4f1430f..8123f45 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -3429,41 +3429,12 @@ void ScAnnotationsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
 
 bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex, ScAddress& rPos ) const
 {
-    if (pDocShell)
-    {
-        sal_Int32 nFound = 0;
-        ScDocument* pDoc = pDocShell->GetDocument();
-        SCTAB nTabCount = pDoc->GetTableCount();
-        for (SCTAB aTab=0; aTab<nTabCount; aTab++)
-        {
-            for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
-            {
-                sc::CellNoteStoreType& maNotes = pDoc->GetColNotes(nCol, aTab);
-                std::pair<sc::CellNoteStoreType::const_iterator,size_t> aPos = maNotes.position(0);
-                sc::CellNoteStoreType::const_iterator it = aPos.first;
-                size_t nOffset = aPos.second;
-                size_t nDataSize = 0;
-                size_t nRow = 0;
-                sal_Int32 nNotesSize = maNotes.size();
-                if (nFound + nNotesSize >= nIndex)
-                {
-                    for (; it != maNotes.end(); ++it, nOffset = 0, nRow += nDataSize)
-                    {
-                        nDataSize = it->size - nOffset;
-                        if (nFound == nIndex)
-                        {
-                            rPos = ScAddress(nCol, nRow, nTab);
-                            return true;
-                        }
-                        ++nFound;
-                    }
-                }
-                else
-                    nFound += nNotesSize;
-            }
-        }
-    }
-    return false;
+    if (!pDocShell)
+        return false;
+
+    ScDocument* pDoc = pDocShell->GetDocument();
+    rPos = pDoc->GetNotePosition(nIndex);
+    return rPos.IsValid();
 }
 
 ScAnnotationObj* ScAnnotationsObj::GetObjectByIndex_Impl( sal_Int32 nIndex ) const


More information about the Libreoffice-commits mailing list