sc/inc/column.hxx                |    2 -
 sc/inc/document.hxx              |    1 
 sc/source/core/data/column2.cxx  |    2 -
 sc/source/core/data/document.cxx |    6 ++-
 sc/source/core/data/table1.cxx   |   62 +++++++++++++++++++++---------------
 sc/source/core/data/table2.cxx   |   24 ++++++++-----
 sc/source/ui/navipi/content.cxx  |   67 ++++++++++++++++++++++++++-------------
 7 files changed, 105 insertions(+), 59 deletions(-)

New commits:
commit 0827d9ee3838d10feceea720bf54a2d6299b8353
Author: Laurent Godard <lgodard.li...@laposte.net>
Date:   Mon Sep 16 12:24:17 2013 +0200

    optim cell notes loops
    
    Change-Id: I08a8a85a4353f7c1b3edada947110d49cfc7dddf

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 76f5127..75270d6 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -495,7 +495,7 @@ public:
     const ScPostIt* GetCellNote( SCROW nRow ) const;
     void DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, 
SCROW nRow2 );
     void DeleteCellNote( SCROW nRow );
-    bool HasCellNote() const;
+    bool HasCellNotes() const;
     void SetCellNote( SCROW nRow, ScPostIt* pNote);
     void SwapCellNotes( SCROW nRow1, SCROW nRow2 );
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 971b377..825d83c 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -904,6 +904,7 @@ public:
     void                         SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, 
ScPostIt* pNote);
     bool                         HasNote(const ScAddress& rPos);
     bool                         HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
+    bool                         HasColNotes(SCCOL nCol, SCTAB nTab);
     SC_DLLPUBLIC ScPostIt*       ReleaseNote(const ScAddress& rPos);
     SC_DLLPUBLIC ScPostIt*       ReleaseNote(SCCOL nCol, SCROW nRow, SCTAB 
nTab);
     SC_DLLPUBLIC ScPostIt*       GetOrCreateNote(const ScAddress& rPos);
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index c87a8a2..d7433a4 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1807,7 +1807,7 @@ void ScColumn::DeleteCellNotes( sc::ColumnBlockPosition& 
rBlockPos, SCROW nRow1,
         maCellNotes.set_empty(rBlockPos.miCellNotePos, nRow1, nRow2);
 }
 
-bool ScColumn::HasCellNote() const
+bool ScColumn::HasCellNotes() const
 {
     sc::CellNoteStoreType::const_iterator it = maCellNotes.begin(), itEnd = 
maCellNotes.end();
     for (; it != itEnd; ++it)
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 91b1ccc..824bb3b 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6121,12 +6121,16 @@ bool ScDocument::HasNote(const ScAddress& rPos)
 {
     return HasNote(rPos.Col(), rPos.Row(), rPos.Tab());
 }
-
 bool ScDocument::HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab)
 {
     ScPostIt* pNote = maTabs[nTab]->aCol[nCol].GetCellNote(nRow);
     return pNote != NULL;
 }
+bool ScDocument::HasColNotes(SCCOL nCol, SCTAB nTab)
+{
+    return maTabs[nTab]->aCol[nCol].HasCellNotes();
+}
+
 ScPostIt* ScDocument::ReleaseNote(const ScAddress& rPos)
 {
         return ReleaseNote(rPos.Col(), rPos.Row(), rPos.Tab());
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 8ca5d88..8823d6c 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -528,17 +528,20 @@ bool ScTable::GetCellArea( SCCOL& rEndCol, SCROW& rEndRow 
) const
                 if (nRow > nMaxY)
                     nMaxY = nRow;
             }
+            if ( pDocument->HasColNotes(i, nTab) )
+            {
             sc::CellNoteStoreType& maCellNotes = pDocument->GetColNotes(i, 
nTab);
-            for (SCROW r=nMaxY; r <=MAXROW; r++) // TODO : notes suboptimal
+            for (SCROW r=nMaxY; r <=MAXROW; r++) // TODO : notes suboptimal ?
                 {
                     ScPostIt* pNote = maCellNotes.get<ScPostIt*>(r);
                     if (pNote)
-                        {
-                            nMaxY = r;
-                            if (i>nMaxX)
-                                nMaxX = i;
-                        }
+                    {
+                        nMaxY = r;
+                        if (i>nMaxX)
+                            nMaxX = i;
+                    }
                 }
+           }
         }
 
     rEndCol = nMaxX;
@@ -581,15 +584,18 @@ bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& 
rEndRow, bool bNotes, bool bF
             }
             if (bNotes)
             {
-                sc::CellNoteStoreType& maCellNotes = pDocument->GetColNotes(i, 
nTab);
-                for (SCROW r=nMaxY; r <=MAXROW; r++) // TODO : notes suboptimal
+                if ( pDocument->HasColNotes(i, nTab) )
                 {
-                    ScPostIt* pNote = maCellNotes.get<ScPostIt*>(r);
-                    if (pNote)
+                    sc::CellNoteStoreType& maCellNotes = 
pDocument->GetColNotes(i, nTab);
+                    for (SCROW r=nMaxY; r <=MAXROW; r++) // TODO : notes 
suboptimal ?
                     {
-                        nMaxY = r;
-                        if (i>nMaxX)
-                            nMaxX = i;
+                        ScPostIt* pNote = maCellNotes.get<ScPostIt*>(r);
+                        if (pNote)
+                        {
+                            nMaxY = r;
+                            if (i>nMaxX)
+                                nMaxX = i;
+                        }
                     }
                 }
             }
@@ -714,12 +720,15 @@ bool ScTable::GetPrintAreaVer( SCCOL nStartCol, SCCOL 
nEndCol,
         }
         if (bNotes)
         {
-            sc::CellNoteStoreType& maCellNotes = pDocument->GetColNotes(i, 
nTab);
-            for (SCROW r=nMaxY; r <=MAXROW; r++) // TODO : notes suboptimal
+            if ( pDocument->HasColNotes(i, nTab) )
             {
-                ScPostIt* pNote = maCellNotes.get<ScPostIt*>(r);
-                if (pNote)
-                    nMaxY = r;
+                sc::CellNoteStoreType& maCellNotes = pDocument->GetColNotes(i, 
nTab);
+                for (SCROW r=nMaxY; r <=MAXROW; r++) // TODO : notes 
suboptimal ?
+                {
+                    ScPostIt* pNote = maCellNotes.get<ScPostIt*>(r);
+                    if (pNote)
+                        nMaxY = r;
+                }
             }
         }
     }
@@ -770,15 +779,18 @@ bool ScTable::GetDataStart( SCCOL& rStartCol, SCROW& 
rStartRow ) const
             if (nRow < nMinY)
                 nMinY = nRow;
         }
-        sc::CellNoteStoreType& maCellNotes = pDocument->GetColNotes(i, nTab);
-        for (SCROW r=0; r < nMinY; r++) // TODO : notes suboptimal
+        if ( pDocument->HasColNotes(i, nTab) )
         {
-            ScPostIt* pNote = maCellNotes.get<ScPostIt*>(r);
-            if (pNote)
+            sc::CellNoteStoreType& maCellNotes = pDocument->GetColNotes(i, 
nTab);
+            for (SCROW r=0; r < nMinY; r++) // TODO : notes suboptimal ?
             {
-                nMinY = r;
-                if (i<nMinX)
-                    nMinX = i;
+                ScPostIt* pNote = maCellNotes.get<ScPostIt*>(r);
+                if (pNote)
+                {
+                    nMinY = r;
+                    if (i<nMinX)
+                        nMinX = i;
+                }
             }
         }
     }
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 5bf1bbc..e5b128c 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1496,11 +1496,14 @@ void ScTable::InitializeNoteCaptions( bool bForced )
     {
         for (SCCOL nCol=0; nCol<MAXCOL; nCol++)
         {
-            sc::CellNoteStoreType& maCellNotes = pDocument->GetColNotes(nCol, 
nTab);
-            for (SCROW nRow=0; nRow < MAXROWCOUNT; nRow++) // TODO : notes 
suboptimal
+            if ( pDocument->HasColNotes(nCol, nTab) )
             {
-                if (ScPostIt* pNote = GetNote(nCol, nRow))
-                    pNote->GetOrCreateCaption( ScAddress( nCol, nRow, nTab ) );
+                sc::CellNoteStoreType& maCellNotes = 
pDocument->GetColNotes(nCol, nTab);
+                for (SCROW nRow=0; nRow < MAXROWCOUNT; nRow++) // TODO : notes 
suboptimal ?
+                {
+                    if (ScPostIt* pNote = GetNote(nCol, nRow))
+                        pNote->GetOrCreateCaption( ScAddress( nCol, nRow, nTab 
) );
+                }
             }
         }
     }
@@ -1834,12 +1837,15 @@ bool ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2,
         bEmpty = aCol[i].IsEmptyBlock( nRow1, nRow2 );
         if (!bIgnoreNotes && bEmpty)
         {
-            sc::CellNoteStoreType& maCellNotes = pDocument->GetColNotes(i, 
nTab);
-            for (SCROW nRow=nRow1; nRow <= nRow2 && bEmpty; nRow++) // TODO : 
notes suboptimal
+            if ( pDocument->HasColNotes(i, nTab) )
             {
-                ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
-                if (pNote)
-                    bEmpty = false;
+                sc::CellNoteStoreType& maCellNotes = pDocument->GetColNotes(i, 
nTab);
+                for (SCROW nRow=nRow1; nRow <= nRow2 && bEmpty; nRow++) // 
TODO : notes suboptimal ?
+                {
+                    ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
+                    if (pNote)
+                        bEmpty = false;
+                }
             }
         }
     }
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 0afe65d..b9591f4 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -867,12 +867,20 @@ void ScContentTree::GetNoteStrings()
     {
         for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
         {
-            sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, nTab);
-            for (SCROW nRow=0; nRow < MAXROWCOUNT; nRow++) // TODO : notes 
suboptimal
+            if ( pDoc->HasColNotes(nCol, nTab) )
             {
-                ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
-                if (pNote)
-                    InsertContent(SC_CONTENT_NOTE, lcl_NoteString( *pNote ));
+                sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, 
nTab);
+                for (SCROW nRow=0; nRow < MAXROWCOUNT; nRow++) // TODO : notes 
suboptimal ?
+                {
+                    sc::CellNoteStoreType::position_type aPos = 
maCellNotes.position(nRow);
+                    sc::CellNoteStoreType::iterator it = aPos.first;
+                    if (it->type == sc::element_type_cellnote)
+                    {
+                        ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
+                        if (pNote)
+                            InsertContent(SC_CONTENT_NOTE, lcl_NoteString( 
*pNote ));
+                    }
+                }
             }
         }
     }
@@ -891,18 +899,25 @@ ScAddress ScContentTree::GetNotePos( sal_uLong nIndex )
     {
         for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
         {
-            sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, nTab);
-
-                for (SCROW nRow=0; nRow < MAXROWCOUNT; nRow++) // TODO : notes 
suboptimal
+            if ( pDoc->HasColNotes(nCol, nTab) )
+            {
+                sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, 
nTab);
+                for (SCROW nRow=0; nRow < MAXROWCOUNT; nRow++) // TODO : notes 
suboptimal ?
                 {
-                    ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
-                    if (pNote)
+                    sc::CellNoteStoreType::position_type aPos = 
maCellNotes.position(nRow);
+                    sc::CellNoteStoreType::iterator it = aPos.first;
+                    if (it->type == sc::element_type_cellnote)
                     {
-                        if (nFound == nIndex)
-                            return ScAddress(nCol, nRow, nTab);
-                        ++nFound;
+                        ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
+                        if (pNote)
+                            {
+                                if (nFound == nIndex)
+                                    return ScAddress(nCol, nRow, nTab);
+                                ++nFound;
+                            }
                     }
                 }
+            }
         }
     }
 
@@ -929,22 +944,30 @@ sal_Bool ScContentTree::NoteStringsChanged()
     {
         for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
         {
-            sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, nTab);
-            for (SCROW nRow=0; nRow<MAXROWCOUNT; nRow++) // TODO : notes 
suboptimal
+            if ( pDoc->HasColNotes(nCol, nTab) )
             {
-                    ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
-                    if (pNote)
+                sc::CellNoteStoreType& maCellNotes = pDoc->GetColNotes(nCol, 
nTab);
+                for (SCROW nRow=0; nRow < MAXROWCOUNT; nRow++) // TODO : notes 
suboptimal ?
+                {
+                    sc::CellNoteStoreType::position_type aPos = 
maCellNotes.position(nRow);
+                    sc::CellNoteStoreType::iterator it = aPos.first;
+                    if (it->type == sc::element_type_cellnote)
                     {
-                        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 );
+                            }
                         }
                     }
+                }
             }
         }
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to