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

Laurent Godard lgodard.libre at laposte.net
Thu Sep 12 08:40:56 PDT 2013


 helpcontent2                                                 |    2 
 sc/inc/column.hxx                                            |   14 +
 sc/inc/document.hxx                                          |   20 ++
 sc/inc/mtvelements.hxx                                       |   13 +
 sc/inc/postit.hxx                                            |    1 
 sc/qa/unit/ucalc.cxx                                         |    1 
 sc/source/core/data/column.cxx                               |   14 +
 sc/source/core/data/column2.cxx                              |   79 +++++++++
 sc/source/core/data/column3.cxx                              |   54 ++++++
 sc/source/core/data/document.cxx                             |   89 +++++++++++
 sc/source/core/data/drwlayer.cxx                             |    2 
 sc/source/core/data/postit.cxx                               |   15 +
 sc/source/core/tool/detfunc.cxx                              |    2 
 sc/source/filter/excel/excdoc.cxx                            |    2 
 sc/source/filter/xml/XMLExportIterator.cxx                   |   21 ++
 sc/source/filter/xml/xmlexprt.cxx                            |   10 -
 sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx |    4 
 sc/source/ui/docshell/docfunc.cxx                            |   10 -
 sc/source/ui/docshell/docsh.cxx                              |    4 
 sc/source/ui/drawfunc/futext3.cxx                            |    6 
 sc/source/ui/navipi/content.cxx                              |   83 ++++++++--
 sc/source/ui/undo/undoblk3.cxx                               |    2 
 sc/source/ui/undo/undocell.cxx                               |   12 -
 sc/source/ui/unoobj/docuno.cxx                               |   32 +++
 sc/source/ui/unoobj/editsrc.cxx                              |    4 
 sc/source/ui/unoobj/notesuno.cxx                             |    2 
 sc/source/ui/view/cellsh.cxx                                 |   64 ++-----
 sc/source/ui/view/cellsh1.cxx                                |   35 ----
 sc/source/ui/view/drawview.cxx                               |    2 
 sc/source/ui/view/gridwin.cxx                                |    2 
 sc/source/ui/view/gridwin5.cxx                               |    2 
 sc/source/ui/view/output.cxx                                 |    6 
 sc/source/ui/view/printfun.cxx                               |   23 --
 sc/source/ui/view/viewfun6.cxx                               |    2 
 34 files changed, 482 insertions(+), 152 deletions(-)

New commits:
commit 57f5cf23f061a47c65f119cd3dce9a724ea45fd5
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Thu Aug 22 17:46:29 2013 +0200

    move cell notes to ScColumn and use mdds storage
    
    remove GetNotes calls
    first initial global patch

diff --git a/helpcontent2 b/helpcontent2
index d7cdc2f..4ae80c4 160000
--- a/helpcontent2
+++ b/helpcontent2
@@ -1 +1 @@
-Subproject commit d7cdc2fbf36d81ecfdfa92bdf07e8471aa380ce5
+Subproject commit 4ae80c49646df353bada547f4755593bf1a6b209
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 6d09ad1..8c5aaeb 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -108,6 +108,9 @@ class ScColumn
     // type value or SC_SCRIPTTYPE_UNKNOWN.
     sc::CellTextAttrStoreType maCellTextAttrs;
 
+    // Cell notes
+    sc::CellNoteStoreType maCellNotes;
+
     // Broadcasters for formula cells.
     sc::BroadcasterStoreType maBroadcasters;
 
@@ -159,6 +162,9 @@ public:
     sc::CellTextAttrStoreType& GetCellAttrStore() { return maCellTextAttrs; }
     const sc::CellTextAttrStoreType& GetCellAttrStore() const { return maCellTextAttrs; }
 
+    sc::CellNoteStoreType& GetCellNoteStore() { return maCellNotes; }
+    const sc::CellNoteStoreType& GetCellNoteStore() const { return maCellNotes; }
+
     ScRefCellValue GetCellValue( SCROW nRow ) const;
     ScRefCellValue GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset ) const;
 
@@ -484,6 +490,14 @@ public:
     void Broadcast( SCROW nRow );
     void BroadcastCells( const std::vector<SCROW>& rRows );
 
+    // cell notes
+    ScPostIt* GetCellNote( SCROW nRow );
+    const ScPostIt* GetCellNote( SCROW nRow ) const;
+    void DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 );
+    void DeleteCellNote( SCROW nRow );
+    bool HasCellNote() const;
+    void SetCellNote( SCROW nRow, ScPostIt* pNote);
+
     void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
 
     void JoinNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6993abb..971b377 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -48,6 +48,8 @@
 #include <boost/scoped_ptr.hpp>
 #include "markdata.hxx"
 
+#include "mtvelements.hxx"
+
 namespace editeng { class SvxBorderLine; }
 namespace formula { struct VectorRefArray; }
 
@@ -161,6 +163,7 @@ class ScEditDataArray;
 class EditTextObject;
 struct ScRefCellValue;
 class ScDocumentImport;
+class ScPostIt;
 
 namespace com { namespace sun { namespace star {
     namespace lang {
@@ -541,6 +544,7 @@ public:
     SC_DLLPUBLIC bool GetCodeName( SCTAB nTab, OUString& rName ) const;
     SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName );
     SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const;
+
     OUString   GetCopyTabName(SCTAB nTab) const;
 
     SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, ScDBData* pDBData);
@@ -890,7 +894,21 @@ public:
     bool            HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
 
     /** Returns a table notes container. */
-    SC_DLLPUBLIC ScNotes*       GetNotes(SCTAB nTab);
+//    SC_DLLPUBLIC ScNotes*       GetNotes(SCTAB nTab);
+
+    /** Notes **/
+    SC_DLLPUBLIC ScPostIt*       GetNote(const ScAddress& rPos);
+    SC_DLLPUBLIC ScPostIt*       GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
+    sc::CellNoteStoreType&       GetColNotes(SCCOL nCol, SCTAB nTab);
+    void                         SetNote(const ScAddress& rPos, ScPostIt* pNote);
+    void                         SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, ScPostIt* pNote);
+    bool                         HasNote(const ScAddress& rPos);
+    bool                         HasNote(SCCOL nCol, SCROW nRow, 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);
+    SC_DLLPUBLIC ScPostIt*       CreateNote(const ScAddress& rPos);
+    sal_uLong                    CountNotes();
 
     /** Creates the captions of all uninitialized cell notes in the specified sheet.
         @param bForced  True = always create all captions, false = skip when Undo is disabled. */
diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index 46a5d40..c61d0f3 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -15,6 +15,7 @@
 #include "svl/broadcast.hxx"
 #include "editeng/editobj.hxx"
 #include "calcmacros.hxx"
+#include "postit.hxx"
 
 #if DEBUG_COLUMN_STORAGE
 #ifdef NDEBUG
@@ -53,12 +54,15 @@ const mdds::mtv::element_t element_type_string = mdds::mtv::element_type_user_st
 const mdds::mtv::element_t element_type_edittext = mdds::mtv::element_type_user_start + 3;
 const mdds::mtv::element_t element_type_formula = mdds::mtv::element_type_user_start + 4;
 
+const mdds::mtv::element_t element_type_cellnote = mdds::mtv::element_type_user_start + 5;
+
 /// Mapped standard element types (for convenience).
 const mdds::mtv::element_t element_type_numeric = mdds::mtv::element_type_numeric;
 const mdds::mtv::element_t element_type_empty = mdds::mtv::element_type_empty;
 
 /// Custom element blocks.
 
+typedef mdds::mtv::noncopyable_managed_element_block<element_type_cellnote, ScPostIt> cellnote_block;
 typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block;
 typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block;
 typedef mdds::mtv::default_element_block<element_type_string, rtl::OUString> string_block;
@@ -70,10 +74,10 @@ typedef mdds::mtv::numeric_element_block numeric_block;
 
 /// This needs to be in the same namespace as CellTextAttr.
 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, CellTextAttr(), celltextattr_block)
-
 }
 
 /// These need to be in global namespace just like their respective types are.
+MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScPostIt, sc::element_type_cellnote, NULL, sc::cellnote_block)
 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcaster, NULL, sc::broadcaster_block)
 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, NULL, sc::formula_block)
 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, sc::element_type_edittext, NULL, sc::edittext_block)
@@ -84,8 +88,13 @@ MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(OUString, sc::element_type_string, OUString(),
 
 }
 
+
 namespace sc {
 
+/// Cell note container
+typedef mdds::mtv::custom_block_func1<sc::cellnote_block> CNoteFunc;
+typedef mdds::multi_type_vector<CNoteFunc> CellNoteStoreType;
+
 /// Broadcaster storage container
 typedef mdds::mtv::custom_block_func1<sc::broadcaster_block> BCBlkFunc;
 typedef mdds::multi_type_vector<BCBlkFunc> BroadcasterStoreType;
@@ -103,6 +112,7 @@ typedef mdds::multi_type_vector<CellFunc> CellStoreType;
  */
 struct ColumnBlockPosition
 {
+    CellNoteStoreType::iterator miCellNotePos;
     BroadcasterStoreType::iterator miBroadcasterPos;
     CellTextAttrStoreType::iterator miCellTextAttrPos;
     CellStoreType::iterator miCellPos;
@@ -112,6 +122,7 @@ struct ColumnBlockPosition
 
 struct ColumnBlockConstPosition
 {
+    CellNoteStoreType::const_iterator miCellNotePos;
     BroadcasterStoreType::const_iterator miBroadcasterPos;
     CellTextAttrStoreType::const_iterator miCellTextAttrPos;
     CellStoreType::const_iterator miCellPos;
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index c8468c4..26536a1 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -57,6 +57,7 @@ struct SC_DLLPUBLIC ScNoteData
 class SC_DLLPUBLIC ScPostIt
 {
 public:
+
     /** Creates an empty note and its caption object and places it according to
         the passed cell position. */
     explicit            ScPostIt( ScDocument& rDoc, const ScAddress& rPos, bool bShown );
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ad98b7d..11b7c0e 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2574,6 +2574,7 @@ void Test::testPostIts()
 
     ScAddress rAddr(2, 2, 0); // cell C3
     ScPostIt *pNote = m_pDoc->GetNotes(rAddr.Tab())->GetOrCreateNote(rAddr);
+
     pNote->SetText(rAddr, aHello);
     pNote->SetAuthor(aJimBob);
 
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index d8c3e60..381dc98 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -75,6 +75,7 @@ ScNeededSizeOptions::ScNeededSizeOptions() :
 
 ScColumn::ScColumn() :
     maCellTextAttrs(MAXROWCOUNT),
+    maCellNotes(MAXROWCOUNT),
     maBroadcasters(MAXROWCOUNT),
     maCells(MAXROWCOUNT),
     nCol( 0 ),
@@ -1152,6 +1153,7 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn& rCol)
 
     maCells.swap(nRow, nRow, rCol.maCells, nRow);
     maCellTextAttrs.swap(nRow, nRow, rCol.maCellTextAttrs, nRow);
+    maCellNotes.swap(nRow, nRow, rCol.maCellNotes, nRow);
 
     aPos1 = maCells.position(nRow);
     aPos2 = rCol.maCells.position(nRow);
@@ -1231,6 +1233,9 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
 {
     pAttrArray->InsertRow( nStartRow, nSize );
 
+    maCellNotes.insert_empty(nStartRow, nSize);
+    maCellNotes.resize(MAXROWCOUNT);
+
     maBroadcasters.insert_empty(nStartRow, nSize);
     maBroadcasters.resize(MAXROWCOUNT);
 
@@ -1561,9 +1566,16 @@ void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDes
     }
 
     if (bSet)
+    {
         rDestCol.maCellTextAttrs.set(nDestRow, maCellTextAttrs.get<sc::CellTextAttr>(nSrcRow));
+        ScPostIt* pPostIt = maCellNotes.get<ScPostIt*>(nSrcRow);
+        rDestCol.maCellNotes.set(nDestRow, pPostIt);
+    }
     else
+    {
         rDestCol.maCellTextAttrs.set_empty(nDestRow, nDestRow);
+        rDestCol.maCellNotes.set_empty(nDestRow, nDestRow);
+    }
 
     rDestCol.CellStorageModified();
 }
@@ -2141,6 +2153,7 @@ void resetColumnPosition(sc::CellStoreType& rCells, SCCOL nCol)
 void ScColumn::SwapCol(ScColumn& rCol)
 {
     maBroadcasters.swap(rCol.maBroadcasters);
+    maCellNotes.swap(rCol.maCellNotes);
     maCells.swap(rCol.maCells);
     maCellTextAttrs.swap(rCol.maCellTextAttrs);
 
@@ -2186,6 +2199,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol)
 
     // Move the broadcasters to the destination column.
     maBroadcasters.transfer(nStartRow, nEndRow, rCol.maBroadcasters, nStartRow);
+    maCellNotes.transfer(nStartRow, nEndRow, rCol.maCellNotes, nStartRow);
     maCells.transfer(nStartRow, nEndRow, rCol.maCells, nStartRow);
     maCellTextAttrs.transfer(nStartRow, nEndRow, rCol.maCellTextAttrs, nStartRow);
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index eda83ff..55e28fe 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1475,6 +1475,13 @@ void ScColumn::CellStorageModified()
         abort();
     }
 
+    if (maCellNotes.size() != MAXROWCOUNT)
+    {
+        cout << "ScColumn::CellStorageModified: Size of the cell note array is incorrect." << endl;
+        cout.flush();
+        abort();
+    }
+
     // Make sure that these two containers are synchronized wrt empty segments.
     sc::CellStoreType::const_iterator itCell = maCells.begin();
     sc::CellTextAttrStoreType::const_iterator itAttr = maCellTextAttrs.begin();
@@ -1508,6 +1515,42 @@ void ScColumn::CellStorageModified()
         while (itAttr != maCellTextAttrs.end() && itAttr->type != sc::element_type_empty)
             ++itAttr;
     }
+
+    // Make sure that these two containers are synchronized wrt empty segments.
+    sc::CellStoreType::const_iterator itCell = maCells.begin();
+    sc::CellNoteStoreType::const_iterator itNote = maCellNotes.begin();
+
+    // Move to the first empty blocks.
+    while (itCell != maCells.end() && itCell->type != sc::element_type_empty)
+        ++itCell;
+
+    while (itNote != maCellNotes.end() && itNote->type != sc::element_type_empty)
+        ++itNote;
+
+    while (itCell != maCells.end())
+    {
+        if (itCell->position != itNote->position || itCell->size != itNote->size)
+        {
+            cout << "ScColumn::CellStorageModified: Cell array and cell notes array are out of sync." << endl;
+            cout << "-- cell array" << endl;
+            maCells.dump_blocks(cout);
+            cout << "-- cell notes array" << endl;
+            maCellNotes.dump_blocks(cout);
+            cout.flush();
+            abort();
+        }
+
+        // Move to the next empty blocks.
+        ++itCell;
+        while (itCell != maCells.end() && itCell->type != sc::element_type_empty)
+            ++itCell;
+
+        ++itNote;
+        while (itNote != maCellNotes.end() && itNote->type != sc::element_type_empty)
+            ++itNote;
+    }
+
+
 #endif
 }
 
@@ -1693,6 +1736,42 @@ bool ScColumn::HasBroadcaster() const
     return false;
 }
 
+ScPostIt* ScColumn::GetCellNote(SCROW nRow)
+{
+    return maCellNotes.get<ScPostIt*>(nRow);
+}
+
+const ScPostIt* ScColumn::GetCellNote(SCROW nRow) const
+{
+    return maCellNotes.get<ScPostIt*>(nRow);
+}
+
+void ScColumn::SetCellNote(SCROW nRow, ScPostIt* pNote)
+{
+    maCellNotes.set(nRow, pNote);
+}
+void ScColumn::DeleteCellNote(SCROW nRow)
+{
+    maCellNotes.set_empty(nRow, nRow);
+}
+void ScColumn::DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 )
+{
+    rBlockPos.miCellNotePos =
+        maCellNotes.set_empty(rBlockPos.miCellNotePos, nRow1, nRow2);
+}
+
+bool ScColumn::HasCellNote() const
+{
+    sc::CellNoteStoreType::const_iterator it = maCellNotes.begin(), itEnd = maCellNotes.end();
+    for (; it != itEnd; ++it)
+    {
+        if (it->type == sc::element_type_cellnote)
+            // Having a cellnote block automatically means there is at least one cell note.
+            return true;
+    }
+    return false;
+}
+
 sal_uInt16 ScColumn::GetTextWidth(SCROW nRow) const
 {
     return maCellTextAttrs.get<sc::CellTextAttr>(nRow).mnTextWidth;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index ce2d81f..6cabed3 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -118,6 +118,7 @@ void ScColumn::Delete( SCROW nRow )
     }
     maCells.set_empty(nRow, nRow);
     maCellTextAttrs.set_empty(nRow, nRow);
+    maCellNotes.set_empty(nRow, nRow);
 
     Broadcast(nRow);
     CellStorageModified();
@@ -130,6 +131,8 @@ void ScColumn::FreeAll()
     maCells.resize(MAXROWCOUNT);
     maCellTextAttrs.clear();
     maCellTextAttrs.resize(MAXROWCOUNT);
+    maCellNotes.clear();
+    maCellNotes.resize(MAXROWCOUNT);
     CellStorageModified();
 }
 
@@ -215,6 +218,9 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
     maBroadcasters.erase(nStartRow, nEndRow);
     maBroadcasters.resize(MAXROWCOUNT);
 
+    maCellNotes.erase(nStartRow, nEndRow);
+    maCellNotes.resize(MAXROWCOUNT);
+
     // See if we have any cells that would get deleted or shifted by deletion.
     sc::CellStoreType::position_type aPos = maCells.position(nStartRow);
     sc::CellStoreType::iterator itCell = aPos.first;
@@ -284,6 +290,10 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
     maCellTextAttrs.erase(nStartRow, nEndRow);
     maCellTextAttrs.resize(MAXROWCOUNT);
 
+    // Shift the cell notes array too (before the broadcast).
+    maCellNotes.erase(nStartRow, nEndRow);
+    maCellNotes.resize(MAXROWCOUNT);
+
     CellStorageModified();
 
     if (!bShiftCells)
@@ -556,6 +566,11 @@ public:
 
         mrPos.miCellPos = rCells.set_empty(mrPos.miCellPos, rSpan.mnRow1, rSpan.mnRow2);
         mrPos.miCellTextAttrPos = mrColumn.GetCellAttrStore().set_empty(mrPos.miCellTextAttrPos, rSpan.mnRow1, rSpan.mnRow2);
+
+        //empty notes LG ???
+        sc::CellNoteStoreType& rCellNotes = mrColumn.GetCellNoteStore();
+        mrPos.miCellNotePos = rCellNotes.set_empty(mrPos.miCellNotePos, rSpan.mnRow1, rSpan.mnRow2);
+
     }
 };
 
@@ -587,6 +602,7 @@ void ScColumn::DeleteArea(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag)
         sc::ColumnBlockPosition aBlockPos;
         aBlockPos.miCellPos = itPos;
         aBlockPos.miCellTextAttrPos = maCellTextAttrs.begin();
+        aBlockPos.miCellNotePos = maCellNotes.begin();
 
         // Delete the cells for real.
         std::for_each(aSpans.begin(), aSpans.end(), EmptyCells(aBlockPos, *this));
@@ -613,6 +629,7 @@ void ScColumn::DeleteArea(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag)
 bool ScColumn::InitBlockPosition( sc::ColumnBlockPosition& rBlockPos )
 {
     rBlockPos.miBroadcasterPos = maBroadcasters.begin();
+    rBlockPos.miCellNotePos = maCellNotes.begin();
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.begin();
     rBlockPos.miCellPos = maCells.begin();
     return true;
@@ -621,6 +638,7 @@ bool ScColumn::InitBlockPosition( sc::ColumnBlockPosition& rBlockPos )
 bool ScColumn::InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const
 {
     rBlockPos.miBroadcasterPos = maBroadcasters.begin();
+    rBlockPos.miCellNotePos = maCellNotes.begin();
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.begin();
     rBlockPos.miCellPos = maCells.begin();
     return true;
@@ -1599,6 +1617,9 @@ void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, Edit
     rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, pEditText);
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
         rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    rBlockPos.miCellNotePos = maCellNotes.set(rBlockPos.miCellNotePos, nRow, pPostIt);
+
     CellStorageModified();
 
     BroadcastNewCell(nRow);
@@ -1679,6 +1700,9 @@ void ScColumn::SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::Form
         pCell->SetNeedNumberFormat(true);
     it = maCells.set(it, nRow, pCell);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    maCellNotes.set(nRow, pPostIt);
+
     CellStorageModified();
 
     ActivateNewFormulaCell(it, nRow, *pCell);
@@ -1695,6 +1719,9 @@ void ScColumn::SetFormula( SCROW nRow, const OUString& rFormula, formula::Formul
         pCell->SetNeedNumberFormat(true);
     it = maCells.set(it, nRow, pCell);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    maCellNotes.set(nRow, pPostIt);
+
     CellStorageModified();
 
     ActivateNewFormulaCell(it, nRow, *pCell);
@@ -1708,6 +1735,9 @@ ScFormulaCell* ScColumn::SetFormulaCell( SCROW nRow, ScFormulaCell* pCell )
         pCell->SetNeedNumberFormat(true);
     it = maCells.set(it, nRow, pCell);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    maCellNotes.set(nRow, pPostIt);
+
     CellStorageModified();
 
     ActivateNewFormulaCell(it, nRow, *pCell);
@@ -1723,6 +1753,10 @@ ScFormulaCell* ScColumn::SetFormulaCell( sc::ColumnBlockPosition& rBlockPos, SCR
     rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, pCell);
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
         rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    rBlockPos.miCellNotePos = maCellNotes.set(
+//        rBlockPos.miCellNotePos, nRow, pPostIt);
+
     CellStorageModified();
 
     ActivateNewFormulaCell(rBlockPos.miCellPos, nRow, *pCell);
@@ -1737,6 +1771,9 @@ bool ScColumn::SetGroupFormulaCell( SCROW nRow, ScFormulaCell* pCell )
         pCell->SetNeedNumberFormat(true);
     it = maCells.set(it, nRow, pCell);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    maCellNotes.set(nRow, pPostIt);
+
     CellStorageModified();
 
     ActivateNewFormulaCell(it, nRow, *pCell, false);
@@ -2131,6 +2168,9 @@ void ScColumn::SetError( SCROW nRow, const sal_uInt16 nError)
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
     it = maCells.set(it, nRow, pCell);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    maCellNotes.set(nRow, pPostIt);
+
     CellStorageModified();
 
     ActivateNewFormulaCell(it, nRow, *pCell);
@@ -2144,6 +2184,9 @@ void ScColumn::SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast )
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
     maCells.set(it, nRow, rStr);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    maCellNotes.set(nRow, pPostIt);
+
     CellStorageModified();
 
     if (bBroadcast)
@@ -2160,6 +2203,10 @@ void ScColumn::SetRawString(
     rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, rStr);
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
         rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    rBlockPos.miCellNotePos = maCellNotes.set(
+//        rBlockPos.miCellNotePos, nRow, pPostIt);
+
     CellStorageModified();
 
     if (bBroadcast)
@@ -2174,6 +2221,9 @@ void ScColumn::SetValue( SCROW nRow, double fVal )
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
     maCells.set(it, nRow, fVal);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    maCellNotes.set(nRow, pPostIt);
+
     CellStorageModified();
 
     BroadcastNewCell(nRow);
@@ -2189,6 +2239,10 @@ void ScColumn::SetValue(
     rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, fVal);
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
         rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
+//    ScPostIt* pPostIt;
+//    rBlockPos.miCellNotePos = maCellNotes.set(
+//        rBlockPos.miCellNotePos, nRow, pPostIt);
+
     CellStorageModified();
 
     if (bBroadcast)
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index dc7db44..91b1ccc 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -101,6 +101,8 @@
 #include <limits>
 #include <boost/scoped_ptr.hpp>
 
+#include "mtvelements.hxx"
+
 using ::editeng::SvxBorderLine;
 using namespace ::com::sun::star;
 
@@ -6078,6 +6080,7 @@ bool ScDocument::IsInVBAMode() const
     return false;
 }
 
+/*
 ScNotes* ScDocument::GetNotes(SCTAB nTab)
 {
     if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
@@ -6085,6 +6088,92 @@ ScNotes* ScDocument::GetNotes(SCTAB nTab)
 
     return NULL;
 }
+*/
+
+ScPostIt* ScDocument::GetNote(const ScAddress& rPos)
+{
+    return GetNote(rPos.Col(), rPos.Row(), rPos.Tab());
+}
+
+ScPostIt* ScDocument::GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab)
+{
+    if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
+        return maTabs[nTab]->aCol[nCol].GetCellNote(nRow);
+    else
+        return NULL;
+
+}
+sc::CellNoteStoreType& ScDocument::GetColNotes(SCCOL nCol, SCTAB nTab)
+{
+        return maTabs[nTab]->aCol[nCol].GetCellNoteStore();
+}
+void ScDocument::SetNote(const ScAddress& rPos, ScPostIt* pNote)
+{
+    return SetNote(rPos.Col(), rPos.Row(), rPos.Tab(), pNote);
+}
+
+void ScDocument::SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, ScPostIt* pNote)
+{
+        return maTabs[nTab]->aCol[nCol].SetCellNote(nRow, pNote);
+}
+
+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;
+}
+ScPostIt* ScDocument::ReleaseNote(const ScAddress& rPos)
+{
+        return ReleaseNote(rPos.Col(), rPos.Row(), rPos.Tab());
+}
+ScPostIt* ScDocument::ReleaseNote(SCCOL nCol, SCROW nRow, SCTAB nTab)
+{
+
+    ScPostIt* pPostIt = GetNote(nCol, nRow, nTab);
+    if (pPostIt != NULL)
+        maTabs[nTab]->aCol[nCol].DeleteCellNote(nRow);
+
+    return pPostIt;
+}
+
+ScPostIt* ScDocument::GetOrCreateNote(const ScAddress& rPos)
+{
+    if (HasNote(rPos))
+        return GetNote(rPos);
+    else
+        return CreateNote(rPos);
+}
+ScPostIt* ScDocument::CreateNote(const ScAddress& rPos)
+{
+    ScPostIt* pPostIt = new ScPostIt(*this, rPos, false);
+    SetNote(rPos, pPostIt);
+    return pPostIt;
+}
+
+sal_uLong ScDocument::CountNotes()
+{
+    sal_uLong nCount = 0;
+    SCTAB nTabCount = GetTableCount();
+    for (SCTAB nTab=0; nTab<nTabCount; 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)
+            {
+               if (it->type == sc::element_type_cellnote)
+                    nCount +=1;
+            }
+        }
+    }
+    return nCount;
+}
 
 void ScDocument::SetAutoNameCache(  ScAutoNameCache* pCache )
 {
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 363969c..bc83f0c 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -627,7 +627,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
                 where cell note is already deleted (thus document cannot find
                 the note object anymore). The caption will be deleted later
                 with drawing undo. */
-            if( ScPostIt* pNote = pDoc->GetNotes( rData.maStart.Tab() )->findByAddress( rData.maStart ) )
+            if( ScPostIt* pNote = pDoc->GetNote( rData.maStart ) )
                 pNote->UpdateCaptionPos( rData.maStart );
         return;
     }
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 6b9bb4d..f72da35 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -39,6 +39,7 @@
 #include <svx/sdsxyitm.hxx>
 #include <tools/gen.hxx>
 
+#include "table.hxx"
 #include "document.hxx"
 #include "docpool.hxx"
 #include "patattr.hxx"
@@ -799,7 +800,7 @@ void ScNoteUtil::UpdateCaptionPositions( ScDocument& rDoc, const ScRange& rRange
     for( ScAddress aPos( rRange.aStart ); aPos.Tab() <= rRange.aEnd.Tab(); aPos.IncTab() )
         for( aPos.SetCol( rRange.aStart.Col() ); aPos.Col() <= rRange.aEnd.Col(); aPos.IncCol() )
             for( aPos.SetRow( rRange.aStart.Row() ); aPos.Row() <= rRange.aEnd.Row(); aPos.IncRow() )
-                if( ScPostIt* pNote = rDoc.GetNotes(aPos.Tab())->findByAddress( aPos ) )
+                if( ScPostIt* pNote = rDoc.GetNote(aPos) )
                     pNote->UpdateCaptionPos( aPos );
 }
 
@@ -810,7 +811,7 @@ SdrCaptionObj* ScNoteUtil::CreateTempCaption(
     OUStringBuffer aBuffer( rUserText );
     // add plain text of invisible (!) cell note (no formatting etc.)
     SdrCaptionObj* pNoteCaption = 0;
-    const ScPostIt* pNote = rDoc.GetNotes(rPos.Tab())->findByAddress( rPos );
+    const ScPostIt* pNote = rDoc.GetNote( rPos );
     if( pNote && !pNote->IsCaptionShown() )
     {
         if( !aBuffer.isEmpty() )
@@ -874,7 +875,8 @@ ScPostIt* ScNoteUtil::CreateNoteFromCaption(
     pNote->AutoStamp();
 
     // if pNote still points to the note after TakeNote(), insertion was successful
-    if( rDoc.GetNotes(rPos.Tab())->insert( rPos, pNote ) )
+    rDoc.SetNote(rPos, pNote);
+    if( pNote )
     {
         // ScNoteCaptionCreator c'tor updates the caption object to be part of a note
         ScNoteCaptionCreator aCreator( rDoc, rPos, rCaption, bShown );
@@ -912,7 +914,9 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
         visible, the caption object will be created automatically. */
     ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, bAlwaysCreateCaption );
     pNote->AutoStamp();
-    if(rDoc.GetNotes(rPos.Tab())->insert( rPos, pNote ))
+
+    rDoc.SetNote(rPos, pNote);
+    if(pNote)
         return pNote;
     else
         return NULL;
@@ -936,7 +940,8 @@ ScPostIt* ScNoteUtil::CreateNoteFromString(
         pNote = new ScPostIt( rDoc, rPos, aNoteData, bAlwaysCreateCaption );
         pNote->AutoStamp();
         //insert takes ownership
-        if(!rDoc.GetNotes(rPos.Tab())->insert( rPos, pNote ))
+        rDoc.SetNote(rPos, pNote);
+        if(!pNote)
             pNote = NULL;
     }
     return pNote;
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 198dba5..2d2fe80 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -1432,7 +1432,7 @@ void ScDetectiveFunc::UpdateAllComments( ScDocument& rDoc )
             {
                 if ( ScDrawObjData* pData = ScDrawLayer::GetNoteCaptionData( pObject, nObjTab ) )
                 {
-                    ScPostIt* pNote = rDoc.GetNotes( pData->maStart.Tab() )->findByAddress( pData->maStart );
+                    ScPostIt* pNote = rDoc.GetNote( pData->maStart );
                     // caption should exist, we iterate over drawing objects...
                     OSL_ENSURE( pNote && (pNote->GetCaption() == pObject), "ScDetectiveFunc::UpdateAllComments - invalid cell note" );
                     if( pNote )
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index 89dcce8..356d44a 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -417,6 +417,7 @@ void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
     mxCellTable.reset( new XclExpCellTable( GetRoot() ) );
 
     //export cell notes
+/* TODO
     ScNotes::iterator itr = rDoc.GetNotes(mnScTab)->begin();
     ScNotes::iterator itrEnd = rDoc.GetNotes(mnScTab)->end();
     for (; itr != itrEnd; ++itr)
@@ -426,6 +427,7 @@ void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
         ScAddress aScPos( itr->first.first, itr->first.second, mnScTab );
         mxNoteList->AppendNewRecord( new XclExpNote( GetRoot(), aScPos, pScNote, OUString() ) );
     }
+*/
 
     if( GetOutput() != EXC_OUTPUT_BINARY )
     {
diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index 976f387..36fe8b8 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -761,6 +761,25 @@ void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable,
                 static_cast<SCCOL>(rExport.GetSharedData()->GetLastColumn(nCurrentTable)),
                 static_cast<SCROW>(rExport.GetSharedData()->GetLastRow(nCurrentTable))));
 
+/*
+        ScTable* pTable = rExport.GetDocument()-> GetTable(nTable);
+        for ( SCCOL c=0; c < MAXCOLCOUNT; c++)
+        {
+            if (pTable->GetColumn(c).HasCellNote())
+            {
+                sc::CellNoteStoreType& noteStore = pTable.GetColumn(c).GetCellNoteStore();
+                sc::CellNoteStoreType::iterator it = noteStore.begin(), itEnd = noteStore.end();
+                for (; it != itEnd; ++it)
+                {
+                    ScNoteExportData aExportData;
+                    aExportData.nCol = c;
+                    aExportData.nRow = static_cast <SCROW>(it);
+                    aExportData.pNote = it->first;
+                    maNoteExportList.insert( aExportData );
+                }
+            }
+        }
+
         ScNotes* pNotes = rExport.GetDocument()->GetNotes(nTable);
         if(pNotes)
         {
@@ -773,8 +792,10 @@ void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable,
                 maNoteExportList.insert( aExportData );
             }
         }
+*/
         maNoteExportListItr = maNoteExportList.begin();
 
+
         xTable.set(rxTable);
         xCellRange.set(xTable, uno::UNO_QUERY);
         uno::Reference<sheet::XSheetAnnotationsSupplier> xSheetAnnotationsSupplier (xTable, uno::UNO_QUERY);
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 45e2677..bd8b3e5 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -655,7 +655,7 @@ void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCo
 
     for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
     {
-        pDoc->GetNotes(nTable)->CreateAllNoteCaptions(nTable);
+  //      pDoc->GetNotes(nTable)->CreateAllNoteCaptions(nTable);
         nCurrentTable = sal::static_int_cast<sal_uInt16>(nTable);
         uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xIndex->getByIndex(nTable), uno::UNO_QUERY);
         if (!xDrawPageSupplier.is())
@@ -2433,7 +2433,7 @@ void ScXMLExport::_ExportAutoStyles()
                 {
                     //! separate method AddStyleFromNote needed?
 
-                    ScPostIt* pNote = pDoc->GetNotes( nTable )->findByAddress(aPos);
+                    ScPostIt* pNote = pDoc->GetNote(aPos);
                     OSL_ENSURE( pNote, "note not found" );
                     if (pNote)
                     {
@@ -2479,7 +2479,7 @@ void ScXMLExport::_ExportAutoStyles()
                 bool bCopySheet = pDoc->IsStreamValid( nTable );
                 if (bCopySheet)
                 {
-                    ScPostIt* pNote = pDoc->GetNotes(nTable)->findByAddress( aPos );
+                    ScPostIt* pNote = pDoc->GetNote( aPos );
                     OSL_ENSURE( pNote, "note not found" );
                     if (pNote)
                     {
@@ -2514,7 +2514,7 @@ void ScXMLExport::_ExportAutoStyles()
                 bool bCopySheet = pDoc->IsStreamValid( nTable );
                 if (bCopySheet)
                 {
-                    ScPostIt* pNote = pDoc->GetNotes(nTable)->findByAddress( aPos );
+                    ScPostIt* pNote = pDoc->GetNote( aPos );
                     OSL_ENSURE( pNote, "note not found" );
                     if (pNote)
                     {
@@ -2764,7 +2764,7 @@ void ScXMLExport::CollectInternalShape( uno::Reference< drawing::XShape > xShape
             // collect note caption objects from all layers (internal or hidden)
             if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, static_cast< SCTAB >( nCurrentTable ) ) )
             {
-                if(pDoc->GetNotes(nCurrentTable)->findByAddress(pCaptData->maStart))
+                if(pDoc->GetNote(pCaptData->maStart))
                 {
                     pSharedData->AddNoteObj( xShape, pCaptData->maStart );
 
diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
index a2fce10..1fa6253 100644
--- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -182,7 +182,7 @@ sal_Int32 ScNotesChildren::AddNotes(const ScPreviewLocationData& rData, const Re
                 }
                 else
                 {
-                    if( ScPostIt* pNote = pDoc->GetNotes( aNote.maNoteCell.Tab() )->findByAddress( aNote.maNoteCell ) )
+                    if( ScPostIt* pNote = pDoc->GetNote( aNote.maNoteCell ) )
                         aNote.maNoteText = pNote->GetText();
                     aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
                     if (aNote.mpTextHelper)
@@ -359,7 +359,7 @@ sal_Int32 ScNotesChildren::CheckChanges(const ScPreviewLocationData& rData,
                 }
                 else
                 {
-                    if( ScPostIt* pNote = pDoc->GetNotes( aNote.maNoteCell.Tab() )->findByAddress( aNote.maNoteCell ) )
+                    if( ScPostIt* pNote = pDoc->GetNote( aNote.maNoteCell ) )
                         aNote.maNoteText = pNote->GetText();
                 }
 
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 15355ee..6241a0e 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1155,7 +1155,7 @@ bool ScDocFunc::SetCellText(
 bool ScDocFunc::ShowNote( const ScAddress& rPos, bool bShow )
 {
     ScDocument& rDoc = *rDocShell.GetDocument();
-    ScPostIt* pNote = rDoc.GetNotes( rPos.Tab() )->findByAddress( rPos );
+    ScPostIt* pNote = rDoc.GetNote( rPos );
     if( !pNote || (bShow == pNote->IsCaptionShown()) ) return false;
 
     // move the caption to internal or hidden layer and create undo action
@@ -1188,7 +1188,9 @@ bool ScDocFunc::SetNoteText( const ScAddress& rPos, const String& rText, sal_Boo
 
     String aNewText = convertLineEnd(rText, GetSystemLineEnd()); //! ist das noetig ???
 
-    if( ScPostIt* pNote = (aNewText.Len() > 0) ? pDoc->GetNotes(rPos.Tab())->GetOrCreateNote( rPos ) : pDoc->GetNotes( rPos.Tab() )->findByAddress(rPos) )
+
+  //  if( ScPostIt* pNote = (aNewText.Len() > 0) ? pDoc->GetNotes(rPos.Tab())->GetOrCreateNote( rPos ) : pDoc->GetNotes( rPos.Tab() )->findByAddress(rPos) )
+    if( ScPostIt* pNote = (aNewText.Len() > 0) ? pDoc->GetOrCreateNote( rPos ) : pDoc->GetNote(rPos) )
         pNote->SetText( rPos, aNewText );
 
     //! Undo !!!
@@ -1217,7 +1219,7 @@ bool ScDocFunc::ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, c
         ::svl::IUndoManager* pUndoMgr = (pDrawLayer && rDoc.IsUndoEnabled()) ? rDocShell.GetUndoManager() : 0;
 
         ScNoteData aOldData;
-        ScPostIt* pOldNote = rDoc.GetNotes(rPos.Tab())->ReleaseNote( rPos );
+        ScPostIt* pOldNote = rDoc.ReleaseNote( rPos );
         if( pOldNote )
         {
             // ensure existing caption object before draw undo tracking starts
@@ -4693,7 +4695,7 @@ sal_Bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, sal_Bool bCont
             bool bHasNotes = false;
             for( ScAddress aPos( nStartCol, nStartRow, nTab ); !bHasNotes && (aPos.Col() <= nEndCol); aPos.IncCol() )
                 for( aPos.SetRow( nStartRow ); !bHasNotes && (aPos.Row() <= nEndRow); aPos.IncRow() )
-                    bHasNotes = ((aPos.Col() != nStartCol) || (aPos.Row() != nStartRow)) && (pDoc->GetNotes( aPos.Tab() )->findByAddress(aPos) != 0);
+                    bHasNotes = ((aPos.Col() != nStartCol) || (aPos.Row() != nStartRow)) && (pDoc->HasNote(aPos));
 
             if (!pUndoDoc)
             {
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 05b44a0..0e954f6 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -247,8 +247,8 @@ sal_uInt16 ScDocShell::GetHiddenInformationState( sal_uInt16 nStates )
         bool bFound = false;
         for (SCTAB nTab = 0; nTab < nTableCount && !bFound; ++nTab)
         {
-            if (!aDocument.GetNotes(nTab)->empty())
-                bFound = true;
+          //  if (!aDocument.GetNotes(nTab)->empty()) TODO:
+          //      bFound = true;
         }
 
         if (bFound)
diff --git a/sc/source/ui/drawfunc/futext3.cxx b/sc/source/ui/drawfunc/futext3.cxx
index 0a42f79..2bcc733 100644
--- a/sc/source/ui/drawfunc/futext3.cxx
+++ b/sc/source/ui/drawfunc/futext3.cxx
@@ -70,7 +70,7 @@ void FuText::StopEditMode(sal_Bool /*bTextDirection*/)
     if( const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, rViewData.GetTabNo() ) )
     {
         aNotePos = pCaptData->maStart;
-        pNote = rDoc.GetNotes( aNotePos.Tab() )->findByAddress( aNotePos );
+        pNote = rDoc.GetNote( aNotePos );
         OSL_ENSURE( pNote && (pNote->GetCaption() == pObject), "FuText::StopEditMode - missing or invalid cell note" );
     }
 
@@ -142,13 +142,13 @@ void FuText::StopEditMode(sal_Bool /*bTextDirection*/)
                 // rescue note data before deletion
                 ScNoteData aNoteData( pNote->GetNoteData() );
                 // delete note from document (removes caption, but does not delete it)
-                rDoc.GetNotes( aNotePos.Tab() )->erase( aNotePos );
+//   TODO        rDoc.GetNotes( aNotePos.Tab() )->erase( aNotePos );
                 // create undo action for removed note
                 pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
             }
             else
             {
-                rDoc.GetNotes( aNotePos.Tab() )->erase( aNotePos );
+//  TODO              rDoc.GetNotes( aNotePos.Tab() )->erase( aNotePos );
             }
             // ScDocument::DeleteNote has deleted the note that pNote points to
             pNote = 0;
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index c4dce57..17e92ad 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -58,6 +58,9 @@
 #include "clipparam.hxx"
 #include "markdata.hxx"
 
+#include "table.hxx"
+#include "column.hxx"
+
 using namespace com::sun::star;
 
 //  Reihenfolge der Kategorien im Navigator -------------------------------------
@@ -848,6 +851,7 @@ static String lcl_NoteString( const ScPostIt& rNote )
     return aText;
 }
 
+
 void ScContentTree::GetNoteStrings()
 {
     if ( nRootType && nRootType != SC_CONTENT_NOTE )        // ausgeblendet ?
@@ -857,14 +861,25 @@ void ScContentTree::GetNoteStrings()
     if (!pDoc)
         return;
 
+    // loop over cell notes
     SCTAB nTabCount = pDoc->GetTableCount();
     for (SCTAB nTab=0; nTab<nTabCount; nTab++)
     {
-        ScNotes::iterator itr = pDoc->GetNotes(nTab)->begin();
-        ScNotes::iterator itrEnd = pDoc->GetNotes(nTab)->end();
-        for (; itr != itrEnd; ++itr)
+        for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
         {
-            InsertContent(SC_CONTENT_NOTE, lcl_NoteString(*itr->second));
+            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)
+            {
+                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 ));
+            }
         }
     }
 }
@@ -877,27 +892,37 @@ ScAddress ScContentTree::GetNotePos( sal_uLong nIndex )
 
     sal_uLong nFound = 0;
     SCTAB nTabCount = pDoc->GetTableCount();
+
     for (SCTAB nTab=0; nTab<nTabCount; nTab++)
     {
-        ScNotes* pNotes = pDoc->GetNotes(nTab);
-        if (nFound + pNotes->size() >= nIndex)
+        for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
         {
-            for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
+            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)
             {
-                if (nFound == nIndex)
-                    return ScAddress( itr->first.first, itr->first.second, nTab );   // gefunden
-
-                ++nFound;
+                for (; it != maNotes.end(); ++it, nOffset = 0, nRow += nDataSize)
+                {
+                    nDataSize = it->size - nOffset;
+                    if (nFound == nIndex)
+                        return ScAddress(nCol, nRow, nTab);
+                    ++nFound;
+                }
             }
+            else
+                nFound += maNotes.size();
         }
-        else
-            nFound += pNotes->size();
     }
 
     OSL_FAIL("note not found");
     return ScAddress();
 }
 
+
 sal_Bool ScContentTree::NoteStringsChanged()
 {
     ScDocument* pDoc = GetSourceDocument();
@@ -914,6 +939,37 @@ sal_Bool ScContentTree::NoteStringsChanged()
     SCTAB nTabCount = pDoc->GetTableCount();
     for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
     {
+        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)
+            {
+                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
+                    {
+                        if ( lcl_NoteString( *pNote ) != GetEntryText(pEntry) )
+                            bEqual = false;
+
+                        pEntry = NextSibling( pEntry );
+                    }
+                }
+
+            }
+        }
+
+/*
         ScNotes* pNotes = pDoc->GetNotes(nTab);
         for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
         {
@@ -930,6 +986,7 @@ sal_Bool ScContentTree::NoteStringsChanged()
                 }
             }
         }
+*/
     }
 
     if ( pEntry )
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index e16d5f0..321d269 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -1013,7 +1013,7 @@ void ScUndoReplace::Undo()
     }
     else if (pSearchItem->GetCellType() == SVX_SEARCHIN_NOTE)
     {
-        ScPostIt* pNote = pDoc->GetNotes( aCursorPos.Tab() )->findByAddress( aCursorPos );
+        ScPostIt* pNote = pDoc->GetNote(aCursorPos);
         OSL_ENSURE( pNote, "ScUndoReplace::Undo - cell does not contain a note" );
         if (pNote)
             pNote->SetText( aCursorPos, aUndoStr );
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 499ca5e..a3a3e8e 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -849,9 +849,9 @@ void ScUndoReplaceNote::DoInsertNote( const ScNoteData& rNoteData )
     if( rNoteData.mpCaption )
     {
         ScDocument& rDoc = *pDocShell->GetDocument();
-        OSL_ENSURE( !rDoc.GetNotes( maPos.Tab() )->findByAddress(maPos), "ScUndoReplaceNote::DoInsertNote - unexpected cell note" );
+        OSL_ENSURE( !rDoc.GetNote(maPos), "ScUndoReplaceNote::DoInsertNote - unexpected cell note" );
         ScPostIt* pNote = new ScPostIt( rDoc, maPos, rNoteData, false );
-        rDoc.GetNotes(maPos.Tab())->insert( maPos, pNote );
+        rDoc.SetNote( maPos, pNote );
     }
 }
 
@@ -860,8 +860,8 @@ void ScUndoReplaceNote::DoRemoveNote( const ScNoteData& rNoteData )
     if( rNoteData.mpCaption )
     {
         ScDocument& rDoc = *pDocShell->GetDocument();
-        OSL_ENSURE( rDoc.GetNotes( maPos.Tab() )->findByAddress(maPos), "ScUndoReplaceNote::DoRemoveNote - missing cell note" );
-        if( ScPostIt* pNote = rDoc.GetNotes(maPos.Tab())->ReleaseNote( maPos ) )
+        OSL_ENSURE( rDoc.GetNote(maPos), "ScUndoReplaceNote::DoRemoveNote - missing cell note" );
+        if( ScPostIt* pNote = rDoc.ReleaseNote( maPos ) )
         {
             /*  Forget pointer to caption object to suppress removing the
                 caption object from the drawing layer while deleting pNote
@@ -886,7 +886,7 @@ ScUndoShowHideNote::~ScUndoShowHideNote()
 void ScUndoShowHideNote::Undo()
 {
     BeginUndo();
-    if( ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( maPos.Tab() )->findByAddress(maPos) )
+    if( ScPostIt* pNote = pDocShell->GetDocument()->GetNote(maPos) )
         pNote->ShowCaption( maPos, !mbShown );
     EndUndo();
 }
@@ -894,7 +894,7 @@ void ScUndoShowHideNote::Undo()
 void ScUndoShowHideNote::Redo()
 {
     BeginRedo();
-    if( ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( maPos.Tab() )->findByAddress(maPos) )
+    if( ScPostIt* pNote = pDocShell->GetDocument()->GetNote(maPos) )
         pNote->ShowCaption( maPos, mbShown );
     EndRedo();
 }
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index ed62205..1bfe362 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -3418,15 +3418,33 @@ bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex, ScAddress& rPos
     {
         sal_Int32 nFound = 0;
         ScDocument* pDoc = pDocShell->GetDocument();
-        const ScNotes* pNotes = pDoc->GetNotes(nTab);
-        for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
+        SCTAB nTabCount = pDoc->GetTableCount();
+        for (SCTAB aTab=0; aTab<nTabCount; aTab++)
         {
-            if (nFound == nIndex)
+            for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++)
             {
-                rPos = ScAddress( itr->first.first, itr->first.second, nTab );
-                return true;
+                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;
+                if (nFound + maNotes.size() >= 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 += maNotes.size();
             }
-            ++nFound;
         }
     }
     return false;
@@ -3495,7 +3513,7 @@ sal_Int32 SAL_CALL ScAnnotationsObj::getCount() throw(uno::RuntimeException)
     if (pDocShell)
     {
         ScDocument* pDoc = pDocShell->GetDocument();
-        nCount = pDoc->GetNotes(nTab)->size();
+        nCount = pDoc->CountNotes();
     }
     return nCount;
 }
diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx
index 6f64090..b48ae1b 100644
--- a/sc/source/ui/unoobj/editsrc.cxx
+++ b/sc/source/ui/unoobj/editsrc.cxx
@@ -137,7 +137,7 @@ SvxEditSource* ScAnnotationEditSource::Clone() const
 
 SdrObject* ScAnnotationEditSource::GetCaptionObj()
 {
-    ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( aCellPos.Tab() )->findByAddress(aCellPos);
+    ScPostIt* pNote = pDocShell->GetDocument()->GetNote(aCellPos);
     return pNote ? pNote->GetOrCreateCaption( aCellPos ) : 0;
 }
 
@@ -163,7 +163,7 @@ SvxTextForwarder* ScAnnotationEditSource::GetTextForwarder()
         return pForwarder;
 
     if ( pDocShell )
-        if ( ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( aCellPos.Tab() )->findByAddress(aCellPos) )
+        if ( ScPostIt* pNote = pDocShell->GetDocument()->GetNote(aCellPos) )
             if ( const EditTextObject* pEditObj = pNote->GetEditTextObject() )
                 pEditEngine->SetText( *pEditObj );      // incl. Umbrueche
 
diff --git a/sc/source/ui/unoobj/notesuno.cxx b/sc/source/ui/unoobj/notesuno.cxx
index be5bc1f..1822003 100644
--- a/sc/source/ui/unoobj/notesuno.cxx
+++ b/sc/source/ui/unoobj/notesuno.cxx
@@ -251,6 +251,6 @@ SvxUnoText& ScAnnotationObj::GetUnoText()
 
 const ScPostIt* ScAnnotationObj::ImplGetNote() const
 {
-    return pDocShell ? pDocShell->GetDocument()->GetNotes( aCellPos.Tab() )->findByAddress(aCellPos) : 0;
+    return pDocShell ? pDocShell->GetDocument()->GetNote(aCellPos) : 0;
 }
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index f3be1cb..8fb6a43 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -602,7 +602,7 @@ void ScCellShell::GetState(SfxItemSet &rSet)
                 {
                     //  always take cursor position, do not use top-left cell of selection
                     String aNoteText;
-                    if ( const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY) )
+                    if ( const ScPostIt* pNote = pDoc->GetNote(nPosX, nPosY, nTab) )
                         aNoteText = pNote->GetText();
                     rSet.Put( SfxStringItem( nWhich, aNoteText ) );
                 }
@@ -906,7 +906,7 @@ void ScCellShell::GetState(SfxItemSet &rSet)
 
             case FID_NOTE_VISIBLE:
                 {
-                    const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY);
+                    const ScPostIt* pNote = pDoc->GetNote(nPosX, nPosY, nTab);
                     if ( pNote && pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
                         rSet.Put( SfxBoolItem( nWhich, pNote->IsCaptionShown() ) );
                     else
@@ -922,7 +922,7 @@ void ScCellShell::GetState(SfxItemSet &rSet)
                     if (!rMark.IsMarked() && !rMark.IsMultiMarked())
                     {
                         // Check current cell
-                        const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY);
+                        const ScPostIt* pNote = pDoc->GetNote(nPosX, nPosY, nTab);
                         if ( pNote && pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
                             if ( pNote->IsCaptionShown() != bSearchForHidden)
                                 bEnable = true;
@@ -943,41 +943,18 @@ void ScCellShell::GetState(SfxItemSet &rSet)
                             const SCCOL nCol0 = pRange->aStart.Col();
                             const SCCOL nCol1 = pRange->aEnd.Col();
                             const SCTAB nRangeTab = pRange->aStart.Tab();
-                            const size_t nCellNumber = ( nRow1 - nRow0 ) * ( nCol1 - nCol0 );
-                            const ScNotes *pNotes = pDoc->GetNotes(nRangeTab);
-
-                            if ( nCellNumber < pNotes->size() )
-                            {
-                                // Check by each cell
-                                for ( SCROW nRow = nRow0; nRow <= nRow1 && !bEnable; ++nRow )
-                                {
-                                    for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol )
-                                    {
-                                        const ScPostIt* pNote = pNotes->findByAddress(nCol, nRow);
-                                        if ( pNote && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) )
-                                        {
-                                            if ( pNote->IsCaptionShown() != bSearchForHidden)
-                                            {
-                                                bEnable = true;
-                                                break;
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                            else
+                            // Check by each cell
+                            // nCellNumber < pDoc->CountNotes() with const size_t nCellNumber = ( nRow1 - nRow0 ) * ( nCol1 - nCol0 );
+                            for ( SCROW nRow = nRow0; nRow <= nRow1 && !bEnable; ++nRow )
                             {
-                                // Check by each document note
-                                for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
+                                for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol )
                                 {
-                                    SCCOL nCol = itr->first.first;
-                                    SCROW nRow = itr->first.second;
-
-                                    if ( nCol <= nCol1 && nRow <= nRow1 && nCol >= nCol0 && nRow >= nRow0 )
+                                    const ScPostIt* pNote = pDoc->GetNote(nCol, nRow, nRangeTab);
+                                    if ( pNote && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) )
                                     {
-                                        if ( itr->second->IsCaptionShown() != bSearchForHidden)
+                                        if ( pNote->IsCaptionShown() != bSearchForHidden)
                                         {
-                                            bEnable = true; //note found
+                                            bEnable = true;
                                             break;
                                         }
                                     }
@@ -1003,17 +980,16 @@ void ScCellShell::GetState(SfxItemSet &rSet)
                             size_t nCount = aRanges.size();
                             for (size_t nPos = 0; nPos < nCount && !bEnable; ++nPos)
                             {
-                                ScNotes* pNotes = pDoc->GetNotes( aRanges[nPos]->aStart.Tab() );
-                                for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
+                                SCTAB aTab = aRanges[nPos]->aStart.Tab();
+                                for (SCCOL aCol=aRanges[nPos]->aStart.Col(); aCol <= aRanges[nPos]->aEnd.Col() && !bEnable; aCol++)
                                 {
-                                    SCCOL nCol = itr->first.first;
-                                    SCROW nRow = itr->first.second;
-
-                                    if ( nCol <= aRanges[nPos]->aEnd.Col() && nRow <= aRanges[nPos]->aEnd.Row()
-                                            && nCol >= aRanges[nPos]->aStart.Col() && nRow >= aRanges[nPos]->aStart.Row() )
+                                    for (SCROW aRow=aRanges[nPos]->aStart.Row(); aRow <= aRanges[nPos]->aEnd.Row(); aRow++)
                                     {
-                                        bEnable = true; //note found
-                                        break;
+                                        if (pDoc->HasNote(aCol, aRow, aTab))
+                                        {
+                                            bEnable = true;
+                                            break;
+                                        }
                                     }
                                 }
                             }
@@ -1022,7 +998,7 @@ void ScCellShell::GetState(SfxItemSet &rSet)
                     else
                     {
                         bEnable = pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) &&
-                                  pDoc->GetNotes(nTab)->findByAddress( nPosX, nPosY );
+                                  pDoc->GetNote(nPosX, nPosY, nTab);
                     }
                     if ( !bEnable )
                         rSet.DisableItem( nWhich );
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index b7d6d30..1e89de7 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2113,7 +2113,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
             {
                 ScDocument* pDoc = GetViewData()->GetDocument();
                 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
-                if( ScPostIt* pNote = pDoc->GetNotes( aPos.Tab() )->findByAddress(aPos) )
+                if( ScPostIt* pNote = pDoc->GetNote(aPos) )
                 {
                     bool bShow;
                     const SfxPoolItem* pItem;
@@ -2148,7 +2148,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 {
                     // Check current cell
                     ScAddress aPos( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
-                    if( pDoc->GetNotes( aPos.Tab() )->findByAddress(aPos) )
+                    if( pDoc->GetNote(aPos) )
                     {
                         pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote );
                         bDone = true;
@@ -2173,35 +2173,12 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                         const SCCOL nCol0 = pRange->aStart.Col();
                         const SCCOL nCol1 = pRange->aEnd.Col();
                         const SCTAB nRangeTab = pRange->aStart.Tab();
-                        const size_t nCellNumber = ( nRow1 - nRow0 ) * ( nCol1 - nCol0 );
-                        ScNotes *pNotes = pDoc->GetNotes(nRangeTab);
-
-                        if ( nCellNumber < pNotes->size() )
+                        // Check by each cell
+                        for ( SCROW nRow = nRow0; nRow <= nRow1; ++nRow )
                         {
-                            // Check by each cell
-                            for ( SCROW nRow = nRow0; nRow <= nRow1; ++nRow )
+                            for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol )
                             {
-                                for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol )
-                                {
-                                    ScPostIt* pNote = pNotes->findByAddress(nCol, nRow);
-                                    if ( pNote && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) )
-                                    {
-                                        ScAddress aPos( nCol, nRow, nRangeTab );
-                                        pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote );
-                                        bDone = true;
-                                    }
-                                }
-                            }
-                        }
-                        else
-                        {
-                            // Check by each document note
-                            for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
-                            {
-                                SCCOL nCol = itr->first.first;
-                                SCROW nRow = itr->first.second;
-
-                                if ( nCol <= nCol1 && nRow <= nRow1 && nCol >= nCol0 && nRow >= nRow0 )
+                                if ( pDoc->HasNote(nCol, nRow, nRangeTab) && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) )
                                 {
                                     ScAddress aPos( nCol, nRow, nRangeTab );
                                     pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote );
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 8bd69d3..7cfebef 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -749,7 +749,7 @@ void ScDrawView::DeleteMarked()
         bool bUndo = pDrawLayer && pDocShell && pUndoMgr && pDoc->IsUndoEnabled();
 
         // remove the cell note from document, we are its owner now
-        ScPostIt* pNote = pDoc->GetNotes(pCaptData->maStart.Tab())->ReleaseNote( pCaptData->maStart );
+        ScPostIt* pNote = pDoc->ReleaseNote( pCaptData->maStart );
         OSL_ENSURE( pNote, "ScDrawView::DeleteMarked - cell note missing in document" );
         if( pNote )
         {
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 3042dd3..d51c683 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -383,7 +383,7 @@ static void lcl_UnLockComment( ScDrawView* pView, SdrPageView* pPV, SdrModel* pD
 
     ScDocument& rDoc = *pViewData->GetDocument();
     ScAddress aCellPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
-    ScPostIt* pNote = rDoc.GetNotes( aCellPos.Tab() )->findByAddress( aCellPos );
+    ScPostIt* pNote = rDoc.GetNote( aCellPos );
     SdrObject* pObj = pNote ? pNote->GetCaption() : 0;
     if( pObj && pObj->GetLogicRect().IsInside( rPos ) && ScDrawLayer::IsNoteCaption( pObj ) )
     {
diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx
index ee357f6..9fd44ce 100644
--- a/sc/source/ui/view/gridwin5.cxx
+++ b/sc/source/ui/view/gridwin5.cxx
@@ -163,7 +163,7 @@ bool ScGridWindow::ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, bool bKeyboard )
     }
 
     //  Notiz nur, wenn sie nicht schon auf dem Drawing-Layer angezeigt wird:
-    const ScPostIt* pNote = pDoc->GetNotes( aCellPos.Tab() )->findByAddress( aCellPos );
+    const ScPostIt* pNote = pDoc->GetNote( aCellPos );
     if ( (aTrackText.Len() > 0) || (pNote && !pNote->IsCaptionShown()) )
     {
         bool bNew = true;
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 1208699..75d4cdb 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -2356,7 +2356,7 @@ void ScOutputData::DrawNoteMarks()
                     // use origin's pCell for NotePtr test below
                 }
 
-                if ( mpDoc->GetNotes(nTab)->findByAddress(nX, pRowInfo[nArrY].nRowNo) && ( bIsMerged ||
+                if ( mpDoc->GetNote(nX, pRowInfo[nArrY].nRowNo, nTab) && ( bIsMerged ||
                         ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) )
                 {
                     if (bFirst)
@@ -2432,7 +2432,7 @@ void ScOutputData::AddPDFNotes()
                     // use origin's pCell for NotePtr test below
                 }
 
-                if ( mpDoc->GetNotes(nTab)->findByAddress(nMergeX, nMergeY) && ( bIsMerged ||
+                if ( mpDoc->GetNote(nMergeX, nMergeY, nTab) && ( bIsMerged ||
                         ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) )
                 {
                     long nNoteWidth = (long)( SC_CLIPMARK_SIZE * mnPPTX );
@@ -2452,7 +2452,7 @@ void ScOutputData::AddPDFNotes()
                     if ( bLayoutRTL ? ( nMarkX >= 0 ) : ( nMarkX < nScrX+nScrW ) )
                     {
                         Rectangle aNoteRect( nMarkX, nPosY, nMarkX+nNoteWidth*nLayoutSign, nPosY+nNoteHeight );
-                        const ScPostIt* pNote = mpDoc->GetNotes(nTab)->findByAddress(nMergeX, nMergeY);
+                        const ScPostIt* pNote = mpDoc->GetNote(nMergeX, nMergeY, nTab);
 
                         // Note title is the cell address (as on printed note pages)
                         ScAddress aAddress( nMergeX, nMergeY, nTab );
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 0a7cb32..953fc70 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -1863,7 +1863,7 @@ long ScPrintFunc::DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocation
         {
             ScAddress &rPos = aNotePosList[ nNoteStart + nCount ];
 
-            if( const ScPostIt* pNote = pDoc->GetNotes(rPos.Tab())->findByAddress( rPos ) )
+            if( const ScPostIt* pNote = pDoc->GetNote( rPos ) )
             {
                 if(const EditTextObject *pEditText = pNote->GetEditTextObject())
                     pEditEngine->SetText(*pEditText);
@@ -2465,8 +2465,6 @@ long ScPrintFunc::CountNotePages()
     if ( !aTableParam.bNotes || !bPrintCurrentTable )
         return 0;
 
-    long nCount=0;
-
     sal_Bool bError = false;
     if (!aAreaParam.bPrintArea)
         bError = !AdjustPrintArea(sal_True);            // completely search in Doc
@@ -2495,20 +2493,13 @@ long ScPrintFunc::CountNotePages()
 
         if (bDoThis)
         {
-            ScNotes::const_iterator itr = pDoc->GetNotes(nPrintTab)->begin();
-            ScNotes::const_iterator itrEnd = pDoc->GetNotes(nPrintTab)->end();
-            for (; itr != itrEnd; ++itr)
+            for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
             {
-                SCCOL nCol = itr->first.first;
-                SCROW nRow = itr->first.second;
-                if (nCol > nEndCol || nRow > nEndRow)
-                    continue;
-
-                if (nCol < nStartCol || nRow < nStartRow)
-                    continue;
-
-                aNotePosList.push_back( ScAddress( nCol, nRow, nPrintTab ) );
-                ++nCount;
+                for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
+                {
+                    if ( pDoc->HasNote(nCol, nRow, nPrintTab) )
+                        aNotePosList.push_back( ScAddress( nCol, nRow, nPrintTab ) );
+                }
             }
         }
     }
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index e324d4a..9f6b9de 100644
--- a/sc/source/ui/view/viewfun6.cxx
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -292,7 +292,7 @@ void ScViewFunc::EditNote()
     // generated undo action is processed in FuText::StopEditMode
 
     // get existing note or create a new note (including caption drawing object)
-    if( ScPostIt* pNote = pDoc->GetNotes(aPos.Tab())->GetOrCreateNote( aPos ) )
+    if( ScPostIt* pNote = pDoc->GetOrCreateNote( aPos ) )
     {
         // hide temporary note caption
         HideNoteMarker();


More information about the Libreoffice-commits mailing list