diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-02 13:21:35 -0500 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-02-03 09:14:57 +0000 |
commit | 17593b3e00c4d73a1985dfc1fae976d211aee007 (patch) | |
tree | 6ecfba6585a587cf993407980cd101c004b8b6d6 | |
parent | b3a5e7bf97c3761ede9dce54f82da513c062af68 (diff) |
fdo#74325: Ensure that all note objects have an sdr object before exporting.
Otherwise, if a note hasn't been displayed at least once before saving
that note would not get saved. In the future, we should modify the export
code to not rely on SdrObject to check the presence of note.
Change-Id: Ib7ca3ac00a0c9cdd3a01facda7af479ef172afbe
(cherry picked from commit 018500a73f3b1082b6662b7c123dfe5158ae5752)
Reviewed-on: https://gerrit.libreoffice.org/7782
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | sc/inc/column.hxx | 1 | ||||
-rw-r--r-- | sc/inc/document.hxx | 6 | ||||
-rw-r--r-- | sc/inc/mtvcellfunc.hxx | 7 | ||||
-rw-r--r-- | sc/inc/table.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 23 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 11 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlwrap.cxx | 2 |
8 files changed, 57 insertions, 0 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 67d75726799c..414f40d90e5c 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -502,6 +502,7 @@ public: bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const; size_t GetNoteCount() const; + void CreateAllNoteCaptions(); SCROW GetNotePosition( size_t nIndex ) const; void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const; void GetNotesInRange( SCROW nStartRow, SCROW nEndRow, std::vector<sc::NoteEntry>& rNotes ) const; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 1f8ced4d5451..4a967092d2c9 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -912,6 +912,12 @@ public: size_t CountNotes() const; size_t GetNoteCount( SCTAB nTab, SCCOL nCol ) const; + /** + * Ensure that all note objects have an associated sdr object. The export + * code uses sdr objects to export note data. + */ + void CreateAllNoteCaptions(); + ScAddress GetNotePosition( size_t nIndex ) const; SCROW GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const; diff --git a/sc/inc/mtvcellfunc.hxx b/sc/inc/mtvcellfunc.hxx index c54d02ebd339..793f2dbc1872 100644 --- a/sc/inc/mtvcellfunc.hxx +++ b/sc/inc/mtvcellfunc.hxx @@ -159,6 +159,13 @@ FindFormulaEditText(const CellStoreType& rStore, SCROW nRow1, SCROW nRow2, _Func return FindElement2<CellStoreType, edittext_block, formula_block, _Func, _Func>(rStore, nRow1, nRow2, rFunc, rFunc); } +template<typename _Func> +void ProcessNote(CellNoteStoreType& rStore, _Func& rFunc) +{ + FuncElseNoOp<size_t> aElse; + ProcessElements1<CellNoteStoreType, cellnote_block, _Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse); +} + } #endif diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 2e1cfd50d040..f067658e1b0a 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -382,6 +382,7 @@ public: size_t GetNoteCount( SCCOL nCol ) const; SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const; + void CreateAllNoteCaptions(); void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const; void GetNotesInRange( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ) const; diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 20d3ee7edf1a..6aef111d9b6a 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1229,6 +1229,29 @@ size_t ScColumn::GetNoteCount() const return nCount; } +namespace { + +class NoteCaptionCreator +{ + ScAddress maPos; +public: + NoteCaptionCreator( SCTAB nTab, SCCOL nCol ) : maPos(nCol,0,nTab) {} + + void operator() ( size_t nRow, ScPostIt* p ) + { + maPos.SetRow(nRow); + p->GetOrCreateCaption(maPos); + } +}; + +} + +void ScColumn::CreateAllNoteCaptions() +{ + NoteCaptionCreator aFunc(nTab, nCol); + sc::ProcessNote(maCellNotes, aFunc); +} + SCROW ScColumn::GetNotePosition( size_t nIndex ) const { // Return the row position of the nth note in the column. diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 11b6507a381b..6bbe8358b4bc 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -6188,6 +6188,17 @@ size_t ScDocument::GetNoteCount( SCTAB nTab, SCCOL nCol ) const return pTab->GetNoteCount(nCol); } +void ScDocument::CreateAllNoteCaptions() +{ + TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end(); + for (; it != itEnd; ++it) + { + ScTable* p = *it; + if (p) + p->CreateAllNoteCaptions(); + } +} + ScAddress ScDocument::GetNotePosition( size_t nIndex ) const { for (size_t nTab = 0; nTab < maTabs.size(); ++nTab) diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index ce4871afafe3..e81a5e218811 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1510,6 +1510,12 @@ SCROW ScTable::GetNotePosition( SCCOL nCol, size_t nIndex ) const return aCol[nCol].GetNotePosition(nIndex); } +void ScTable::CreateAllNoteCaptions() +{ + for (SCCOL i = 0; i <= MAXCOL; ++i) + aCol[i].CreateAllNoteCaptions(); +} + void ScTable::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const { for (SCCOL nCol = 0; nCol < MAXCOLCOUNT; ++nCol) diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx index c2ad8ec0ed92..5fdf5812bcf1 100644 --- a/sc/source/filter/xml/xmlwrap.cxx +++ b/sc/source/filter/xml/xmlwrap.cxx @@ -762,6 +762,8 @@ sal_Bool ScXMLImportWrapper::ExportToComponent(const uno::Reference<uno::XCompon sal_Bool ScXMLImportWrapper::Export(sal_Bool bStylesOnly) { + rDoc.CreateAllNoteCaptions(); + uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext()); uno::Reference<xml::sax::XWriter> xWriter = xml::sax::Writer::create(xContext); |