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

Laurent Godard lgodard.libre at laposte.net
Fri Sep 27 03:16:54 PDT 2013


 sc/source/core/data/column.cxx  |   41 ++++++++++++++++++++++++++++++----------
 sc/source/core/data/column2.cxx |    2 -
 2 files changed, 32 insertions(+), 11 deletions(-)

New commits:
commit e1ae7c68dfb538f6d2cdfd7b860df1a3ab009d7c
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Fri Sep 27 12:10:19 2013 +0200

    refactor copyToClipboard notes
    
    - use advantages of mdds::multi_type_vector
    
    Change-Id: Ib3781d519572f798cb422baefd5152e38483faee

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 70df4d0..4bc37b4 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1264,6 +1264,10 @@ class CopyToClipHandler
     sc::ColumnBlockPosition maDestPos;
     sc::ColumnBlockPosition* mpDestPos;
     bool mbCopyNotes;
+    SCCOL nDestCol;
+    SCTAB nDestTab;
+    SCCOL nSrcCol;
+    SCTAB nSrcTab;
 
     void setDefaultAttrsToDest(size_t nRow, size_t nSize)
     {
@@ -1302,24 +1306,36 @@ class CopyToClipHandler
         }
     }
 
-    void duplicateNotes(SCROW nStartRow, size_t nDataSize ) // TODO : notes suboptimal
+    void duplicateNotes(SCROW nStartRow, size_t nDataSize )
     {
-        sc::CellNoteStoreType maSrcCellNotes = mrSrcCol.GetCellNoteStore();
         SCROW nRowMax = nStartRow + nDataSize;
 
+        std::vector<ScPostIt*> vDestNotes(nDataSize);
+
+        sc::CellNoteStoreType maSrcCellNotes = mrSrcCol.GetCellNoteStore();
+        sc::CellNoteStoreType::iterator posSrc = maSrcCellNotes.begin();
+
         for (SCROW nRow = nStartRow; nRow < nRowMax; ++nRow)
         {
-            ScPostIt* pSrcNote = maSrcCellNotes.get<ScPostIt*>(nRow);
-            if (pSrcNote)
+            sc::CellNoteStoreType::position_type curPosObj = maSrcCellNotes.position(posSrc, nRow);
+            posSrc = curPosObj.first;
+            size_t offset = curPosObj.second;
+            if (posSrc->type == sc::element_type_cellnote)
             {
-                ScAddress aDestPos = ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab());
-                ScPostIt* pClonedNote = pSrcNote->Clone( ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab() ),
-                                 mrDestCol.GetDoc(),
-                                 aDestPos, true );
-                mrDestCol.GetDoc().ReleaseNote(aDestPos);
-                mrDestCol.GetDoc().SetNote(aDestPos, pClonedNote);
+                ScAddress aDestAddress = ScAddress(nDestCol, nRow, nDestTab);
+                ScAddress aSrcAddress = ScAddress(nSrcCol, nRow, nSrcTab );
+
+                ScPostIt* pSrcNote = sc::cellnote_block::at(*posSrc->data, offset);
+                ScPostIt* pClonedNote = pSrcNote->Clone(aSrcAddress, mrDestCol.GetDoc(), aDestAddress, true );
+
+                vDestNotes[nRow-nStartRow] = pClonedNote;
             }
         }
+        // set the cloned notes vector in its dest position
+        sc::CellNoteStoreType maDestCellNotes = mrDestCol.GetCellNoteStore();
+        maDestCellNotes.set_empty(nStartRow, nRowMax);
+        maDestPos.miCellNotePos = mrDestCol.GetCellNoteStore().set(
+            maDestPos.miCellNotePos, nStartRow, vDestNotes.begin(), vDestNotes.end());
     }
 
 public:
@@ -1330,6 +1346,11 @@ public:
             maDestPos = *mpDestPos;
         else
             mrDestCol.InitBlockPosition(maDestPos);
+
+    nDestCol = mrDestCol.GetCol();
+    nDestTab = mrDestCol.GetTab();
+    nSrcCol = mrSrcCol.GetCol();
+    nSrcTab = mrSrcCol.GetTab();
     }
 
     ~CopyToClipHandler()
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 8f97e51..ee8e94f 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1891,7 +1891,7 @@ const ScPostIt* ScColumn::GetCellNote(SCROW nRow) const
 
 void ScColumn::SetCellNote(SCROW nRow, ScPostIt* pNote)
 {
-    pNote->UpdateCaptionPos(ScAddress(nCol, nRow, nTab));
+    //pNote->UpdateCaptionPos(ScAddress(nCol, nRow, nTab));
     maCellNotes.set(nRow, pNote);
 }
 void ScColumn::DeleteCellNote(SCROW nRow)


More information about the Libreoffice-commits mailing list