[Libreoffice-commits] core.git: sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon May 5 12:26:55 PDT 2014


 sc/inc/document.hxx              |    9 +++++----
 sc/source/core/data/document.cxx |   20 +++++++++++++++-----
 sc/source/ui/app/transobj.cxx    |    2 +-
 3 files changed, 21 insertions(+), 10 deletions(-)

New commits:
commit fe451fb94a33c914c0a7c1265c013d9704af850a
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon May 5 15:22:15 2014 -0400

    fdo#78054: Initialize drawing layer when the document contains notes.
    
    Don't be fooled even when the document doesn't have a drawing layer
    initialized.  Sometimes a note creates caption on demand later, but if
    the drawing layer isn't there the caption will not get created, which
    ultimately causes this crash.
    
    Change-Id: I37f4902fa84de91c9f793dc352127d9345a725e3

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index f86bdda..3d8bcda 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -933,10 +933,11 @@ public:
     SC_DLLPUBLIC ScPostIt*       GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
     void                         SetNote(const ScAddress& rPos, ScPostIt* pNote);
     void                         SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, ScPostIt* pNote);
-    SC_DLLPUBLIC 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 bool HasNote(const ScAddress& rPos) const;
+    bool HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
+    SC_DLLPUBLIC bool HasColNotes(SCCOL nCol, SCTAB nTab) const;
+    SC_DLLPUBLIC bool HasTabNotes(SCTAB nTab) const;
+    bool HasNotes() const;
     SC_DLLPUBLIC ScPostIt*       ReleaseNote(const ScAddress& rPos);
     SC_DLLPUBLIC ScPostIt*       GetOrCreateNote(const ScAddress& rPos);
     SC_DLLPUBLIC ScPostIt*       CreateNote(const ScAddress& rPos);
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 4f90b2f..181f294 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6131,21 +6131,21 @@ 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)
+bool ScDocument::HasNote(const ScAddress& rPos) const
 {
     return HasNote(rPos.Col(), rPos.Row(), rPos.Tab());
 }
-bool ScDocument::HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab)
+bool ScDocument::HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const
 {
-    ScPostIt* pNote = maTabs[nTab]->aCol[nCol].GetCellNote(nRow);
+    const ScPostIt* pNote = maTabs[nTab]->aCol[nCol].GetCellNote(nRow);
     return pNote != NULL;
 }
-bool ScDocument::HasColNotes(SCCOL nCol, SCTAB nTab)
+bool ScDocument::HasColNotes(SCCOL nCol, SCTAB nTab) const
 {
     return maTabs[nTab]->aCol[nCol].HasCellNotes();
 }
 
-bool ScDocument::HasTabNotes(SCTAB nTab)
+bool ScDocument::HasTabNotes(SCTAB nTab) const
 {
     bool hasNotes = false;
     for (SCCOL nCol=0; nCol<MAXCOLCOUNT && !hasNotes; ++nCol)
@@ -6154,6 +6154,16 @@ bool ScDocument::HasTabNotes(SCTAB nTab)
     return hasNotes;
 }
 
+bool ScDocument::HasNotes() const
+{
+    for (SCTAB i = 0; i <= MAXTAB; ++i)
+    {
+        if (HasTabNotes(i))
+            return true;
+    }
+    return false;
+}
+
 ScPostIt* ScDocument::ReleaseNote(const ScAddress& rPos)
 {
     ScTable* pTab = FetchTable(rPos.Tab());
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 8b64728..1ccb4f2 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -637,7 +637,7 @@ void ScTransferObj::InitDocShell(bool bLimitToPageSize)
             }
         }
 
-        if ( pDoc->GetDrawLayer() )
+        if (pDoc->GetDrawLayer() || pDoc->HasNotes())
             pDocSh->MakeDrawLayer();
 
         //  cell range is copied to the original position, but on the first sheet


More information about the Libreoffice-commits mailing list