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

Laurent Godard lgodard.libre at laposte.net
Mon Oct 7 06:31:40 PDT 2013


 sc/inc/document.hxx               |    1 +
 sc/qa/unit/ucalc.cxx              |    3 ++-
 sc/source/core/data/column2.cxx   |    2 +-
 sc/source/core/data/document.cxx  |   11 ++++++++++-
 sc/source/ui/docshell/docfunc.cxx |    2 --
 sc/source/ui/docshell/docsh.cxx   |    4 ++--
 sc/source/ui/drawfunc/futext3.cxx |    4 ++--
 7 files changed, 18 insertions(+), 9 deletions(-)

New commits:
commit b9ea300d99ba57f101ab6c88123a5cc712e5c406
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Mon Oct 7 15:30:43 2013 +0200

    Notes new storage & methods
    
    Change-Id: If6265dbcb6cfe16c5398b331579d414a835344ca

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index e1c13c5..0c139d4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -900,6 +900,7 @@ public:
     bool                         HasNote(const ScAddress& rPos);
     bool                         HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
     SC_DLLPUBLIC bool            HasColNotes(SCCOL nCol, SCTAB nTab);
+    SC_DLLPUBLIC bool            HasTabNotes(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 0f97c50..cf66f14 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1870,7 +1870,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)
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9ebdd62..e77dd16 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6115,6 +6115,15 @@ bool ScDocument::HasColNotes(SCCOL nCol, SCTAB nTab)
     return maTabs[nTab]->aCol[nCol].HasCellNotes();
 }
 
+bool ScDocument::HasTabNotes(SCTAB nTab)
+{
+    bool hasNotes = false;
+    for (SCCOL nCol=0; nCol<MAXCOLCOUNT && !hasNotes; ++nCol)
+        hasNotes = HasColNotes(nCol, nTab);
+
+    return hasNotes;
+}
+
 ScPostIt* ScDocument::ReleaseNote(const ScAddress& rPos)
 {
         return ReleaseNote(rPos.Col(), rPos.Row(), rPos.Tab());
@@ -6156,7 +6165,7 @@ sal_uLong ScDocument::CountNotes()
             for (; it != itEnd; ++it)
             {
                if (it->type == sc::element_type_cellnote)
-                    nCount +=1;
+                    nCount +=it->size;
             }
         }
     }
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 7fb763e..0bbfe96 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1188,8 +1188,6 @@ 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->GetOrCreateNote( rPos ) : pDoc->GetNote(rPos) )
         pNote->SetText( rPos, aNewText );
 
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 0e954f6..feb2504 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()) TODO:
-          //      bFound = true;
+            if (aDocument.HasTabNotes(nTab)) //TODO:
+                bFound = true;
         }
 
         if (bFound)
diff --git a/sc/source/ui/drawfunc/futext3.cxx b/sc/source/ui/drawfunc/futext3.cxx
index 2bcc733..d83c34f 100644
--- a/sc/source/ui/drawfunc/futext3.cxx
+++ b/sc/source/ui/drawfunc/futext3.cxx
@@ -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)
-//   TODO        rDoc.GetNotes( aNotePos.Tab() )->erase( aNotePos );
+                rDoc.ReleaseNote(aNotePos);
                 // create undo action for removed note
                 pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
             }
             else
             {
-//  TODO              rDoc.GetNotes( aNotePos.Tab() )->erase( aNotePos );
+                rDoc.ReleaseNote(aNotePos);
             }
             // ScDocument::DeleteNote has deleted the note that pNote points to
             pNote = 0;
commit abbe2c0f501e052a5167f038092cbb9fc6aac30f
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Mon Oct 7 15:27:50 2013 +0200

    - unit test still failing
    
    Change-Id: Ibfef8a1264c70414f164df7cc15886955b06f79c

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 250e5aa..500894c 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3083,7 +3083,7 @@ void Test::testMoveBlock()
     ScPostIt* pNoteA1 = m_pDoc->GetOrCreateNote(aAddrA1);
     pNoteA1->SetText(aAddrA1, aHelloA1);
     ScAddress aAddrB1 (1, 0, 0);
-    OUString aHelloB1("Hello world in B1");
+    String aHelloB1("Hello world in B1");
     ScPostIt* pNoteB1 = m_pDoc->GetOrCreateNote(aAddrB1);
     pNoteB1->SetText(aAddrB1, aHelloB1);
     ScAddress aAddrC1 (2, 0, 0);
@@ -3093,6 +3093,7 @@ void Test::testMoveBlock()
     ScAddress aAddrD1 (3, 0, 0);
 
     std::cout << "B1 note before moveblock: " << m_pDoc->GetNote(aAddrB1)->GetText() << std::endl;
+    std::cout << "B1 note before moveblock pNoteB1: " << pNoteB1->GetText() << std::endl;
     std::cout << "B1 note before moveblock should be: " << aHelloB1 << std::endl;
 
     // previous tests on cell note content are ok. this one fails !!! :(


More information about the Libreoffice-commits mailing list