summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-05 15:22:15 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-05-05 15:27:15 -0400
commitfe451fb94a33c914c0a7c1265c013d9704af850a (patch)
tree63b8fcf0fb4b755c20a1a30428011ced50a6bba3
parent718fbf4f808def97ad55b1afaeb5af68b9144b96 (diff)
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
-rw-r--r--sc/inc/document.hxx9
-rw-r--r--sc/source/core/data/document.cxx20
-rw-r--r--sc/source/ui/app/transobj.cxx2
3 files changed, 21 insertions, 10 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index f86bddac985e..3d8bcda3b2ca 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 4f90b2fdd503..181f29496057 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 8b64728804ba..1ccb4f23a2aa 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