[Libreoffice-commits] core.git: Branch 'feature/sc-notes-storage' - sc/source

Laurent Godard lgodard.libre at laposte.net
Fri Sep 13 00:44:38 PDT 2013


 sc/source/ui/navipi/content.cxx |   57 +++++++++++++---------------------------
 1 file changed, 19 insertions(+), 38 deletions(-)

New commits:
commit 565cf66b93f264e4f6ef65184472c48abe7a9997
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Fri Sep 13 09:42:58 2013 +0200

    notes & navigator
    
    do not crash anymore
    these loops are suboptimal - need to refactor using iterator
    
    Change-Id: I26507a19b6acc0d319449a455c558bca3c444255

diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index c09baeb..73ec095 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -867,18 +867,12 @@ void ScContentTree::GetNoteStrings()
     {
         for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
         {
-            sc::CellNoteStoreType& maNotes = pDoc->GetColNotes(nCol, nTab);
-            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 nCurRow = 0;
-            for (; it != maNotes.end(); ++it, nOffset = 0, nCurRow += nDataSize)
+            sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, nTab);
+            for (SCROW nRow=0; nRow < MAXROWCOUNT; nRow++) // TODO : suboptimal
             {
-                nDataSize = it->size - nOffset;
-                sc::cellnote_block::const_iterator itData = sc::cellnote_block::begin(*it->data);
-                std::advance(itData, nOffset);
-                InsertContent(SC_CONTENT_NOTE, lcl_NoteString( **itData ));
+                ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
+                if (pNote)
+                    InsertContent(SC_CONTENT_NOTE, lcl_NoteString( *pNote ));
             }
         }
     }
@@ -898,23 +892,19 @@ ScAddress ScContentTree::GetNotePos( sal_uLong nIndex )
         for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
         {
             sc::CellNoteStoreType& maNotes = pDoc->GetColNotes(nCol, nTab);
-            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;
             if (nFound + maNotes.size() >= nIndex)
             {
-                for (; it != maNotes.end(); ++it, nOffset = 0, nRow += nDataSize)
+                for (SCROW nRow=0; nRow < MAXROWCOUNT; nRow++) // TODO : suboptimal
                 {
-                    nDataSize = it->size - nOffset;
                     if (nFound == nIndex)
                         return ScAddress(nCol, nRow, nTab);
                     ++nFound;
                 }
             }
             else
+            {
                 nFound += maNotes.size();
+            }
         }
     }
 
@@ -941,31 +931,22 @@ sal_Bool ScContentTree::NoteStringsChanged()
     {
         for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
         {
-            sc::CellNoteStoreType& maNotes = pDoc->GetColNotes(nCol, nTab);
-            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 nCurRow = 0;
-            for (; it != maNotes.end(); ++it, nOffset = 0, nCurRow += nDataSize)
+            sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, nTab);
+            for (SCROW nRow=0; nRow<MAXROWCOUNT; nRow++) // TODO : suboptimal
             {
-                nDataSize = it->size - nOffset;
-                sc::cellnote_block::const_iterator itData = sc::cellnote_block::begin(*it->data);
-                std::advance(itData, nOffset);
-                const ScPostIt* pNote = *itData;
-                if (pNote)
-                {
-                    if ( !pEntry )
-                        bEqual = false;
-                    else
+                    ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
+                    if (pNote)
                     {
-                        if ( lcl_NoteString( *pNote ) != GetEntryText(pEntry) )
+                        if ( !pEntry )
                             bEqual = false;
+                        else
+                        {
+                            if ( lcl_NoteString( *pNote ) != GetEntryText(pEntry) )
+                                bEqual = false;
 
-                        pEntry = NextSibling( pEntry );
+                            pEntry = NextSibling( pEntry );
+                        }
                     }
-                }
-
             }
         }
     }


More information about the Libreoffice-commits mailing list