[Libreoffice-commits] Changes to 'feature/cell-notes'

Michael Meeks michael at kemper.freedesktop.org
Mon Oct 31 11:02:00 PDT 2011


New branch 'feature/cell-notes' available with the following commits:
commit 9d8d0e99a78f903e9c7315808e5986f63aca27d9
Author: Kevin Hunter <hunteke at earlham.edu>
Date:   Mon Oct 31 13:23:06 2011 -0400

    Move ScPostIt storage from ScBaseCell->ScDocument
    
    ScPostIt is the behind-the-scenes name for Notes.  This move removes a
    usually empty pointer for each ScBaseCell to list of pointers within
    ScDocument.  The advantage is basically a reduction in size of 8 bytes
    per cell.  The current sizeof(ScBaseCell) is 16.  Here are the
    highlights:
    
    * Remove mpNote from ScBaseCell, and add a std::map (data structure) to
      ScDocument to store notes and associate with addresses.
    
    * Remove ScPostIt accessors and mutators from ScTable, ScColumn, and
      ScBaseCell
    
    * Replace ScPostIt accessors and mutators in ScDocument with ones to
      handle move of data structure from ScBaseCell to ScDocument
    
    * Rename ScPostIt.CloneWithoutNote to ScPostIt.Clone, while completely
      removing ScPostIt.CloneWithNote.  Any cloning of cell notes must now
      be handled outside external to the ScPostIt class, through
      ScDocument.*Note() functions.
    
    * Rename ScNoteCell to a more ScEmptyCell.  I expect this can be
      completely removed at some point the future, if we can handle
      broadcasters external to the cell logic.
    
    * Add ScDocument and ScTable to ScUsedAreaIterator data structure to
      accomodate for new placement of ScPostIt objects in ScDocument.
    
    * Convert CELLTYPE_NOTE to CELLTYPE_EMPTY (and all ensuing uses).
    
    * Wherever possible, respect 80-columns.
    
    * New ScDocument based API (individually block-comment documented before
      their definitions):
    
    SC_DLLPUBLIC ScPostIt* GetNote( ScAddress const & );
    SC_DLLPUBLIC ScPostIt* GetOrCreateNote( const ScAddress& rPos );
    bool                   SetNote( ScAddress const &, ScPostIt* );
    bool                   MoveNote( ScAddress const & from, ScAddress const & to );
    bool                   SwapNotes( ScAddress const &, ScAddress const & );
    ScPostIt*              ReleaseNote( ScAddress const & );
    void                   DeleteNote( ScAddress const & );
    
    Of note, TakeNote has been replaced with SetNote, which returns true on
    success, and false on failure.  TakeNote indicated failure by removing
    the passed note.  The SetNote approach leaves room for the caller to
    attempt to fix the issue, but also means the caller is now on the hook
    to cleanup the memory.  For now, the Calc-internal API is lazy and does
    not take advantage of this, but merely says "You failed?  Oh well,
    delete the note." ... which is exactly what TakeNote did.  This means, the
    lazy-programmer's idiom for SetNote use is:
    
       if ( ! pDoc->SetNote( aAddress, pNotePointer ) )
          DELETEZ( pNotePointer );



More information about the Libreoffice-commits mailing list