summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-05 15:22:15 -0400
committerAndras Timar <andras.timar@collabora.com>2014-05-09 14:48:21 +0200
commit662d4a6bd9d61b078c34372f8a95afbb92ea66d0 (patch)
tree2daebdbb102896f4e1868ac022d5822291a9e25b /sc
parentd6150032eacea4eb2ac6da27333c21187bf2c604 (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. (cherry picked from commit fe451fb94a33c914c0a7c1265c013d9704af850a) Conflicts: sc/inc/document.hxx Change-Id: I37f4902fa84de91c9f793dc352127d9345a725e3 Reviewed-on: https://gerrit.libreoffice.org/9254 Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc')
-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 365cffdae538..339bbb00c047 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -919,10 +919,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);
- 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);
+ 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 bc6673575b09..8c69412d1beb 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6109,21 +6109,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)
@@ -6132,6 +6132,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 b2187d5975f0..ec6bb4a211f1 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -643,7 +643,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