summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-07-08 04:44:14 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-07-08 05:02:50 +0200
commit4d965688abb30589b9092a290bfa8aca827f24c6 (patch)
tree3c792da3967c499e5fb820a1947748a316ec9c67
parenta411058ad8c4106c26b41ab9defed356bf62b04b (diff)
export all notes into odf, fdo#49924
Change-Id: Ic3b9176b1b8da7663d1dc3c88a4d56cd794e0805
-rw-r--r--sc/inc/postit.hxx2
-rw-r--r--sc/source/core/data/postit.cxx7
-rw-r--r--sc/source/filter/xml/XMLExportIterator.cxx78
-rw-r--r--sc/source/filter/xml/XMLExportIterator.hxx27
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx4
5 files changed, 100 insertions, 18 deletions
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index e553c92dee60..0db2a9fc1f69 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -311,7 +311,7 @@ public:
void erase(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bForgetCaption = false);
-
+ void CreateAllNoteCaptions(SCTAB nTab);
};
// ============================================================================
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 279b3ffa821b..97ab523406a8 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -1102,5 +1102,12 @@ void ScNotes::erase(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bFo
}
}
+void ScNotes::CreateAllNoteCaptions(SCTAB nTab)
+{
+ for(iterator itr = begin(), itrEnd = end(); itr != itrEnd; ++itr)
+ {
+ itr->second->GetOrCreateCaption(ScAddress(itr->first.first, itr->first.second, nTab));
+ }
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index 298cda550eae..df705d92df9f 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -676,6 +676,7 @@ void ScMyNotEmptyCellsIterator::Clear()
OSL_FAIL("not all Annotations saved");
aAnnotations.clear();
}
+ maNoteExportList.clear();
pCellItr = NULL;
pShapes = NULL;
pNoteShapes = NULL;
@@ -768,6 +769,7 @@ void ScMyNotEmptyCellsIterator::HasAnnotation(ScMyCell& aCell)
// aCell.xCell.set(xCellRange->getCellByPosition(aCell.aCellAddress.Column, aCell.aCellAddress.Row));
}
+
void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable,
uno::Reference<sheet::XSpreadsheet>& rxTable)
{
@@ -777,11 +779,27 @@ void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable,
aLastAddress.Sheet = nTable;
if (nCurrentTable != nTable)
{
+ maNoteExportList.clear();
nCurrentTable = nTable;
if (pCellItr)
delete pCellItr;
pCellItr = new ScHorizontalCellIterator(rExport.GetDocument(), nCurrentTable, 0, 0,
static_cast<SCCOL>(rExport.GetSharedData()->GetLastColumn(nCurrentTable)), static_cast<SCROW>(rExport.GetSharedData()->GetLastRow(nCurrentTable)));
+
+ ScNotes* pNotes = rExport.GetDocument()->GetNotes(nTable);
+ if(pNotes)
+ {
+ for(ScNotes::iterator itr = pNotes->begin(), itrEnd = pNotes->end(); itr != itrEnd; ++itr)
+ {
+ ScNoteExportData aExportData;
+ aExportData.nCol = itr->first.first;
+ aExportData.nRow = itr->first.second;
+ aExportData.pNote = itr->second;
+ maNoteExportList.insert( aExportData );
+ }
+ }
+ maNoteExportListItr = maNoteExportList.begin();
+
xTable.set(rxTable);
xCellRange.set(xTable, uno::UNO_QUERY);
uno::Reference<sheet::XSheetAnnotationsSupplier> xSheetAnnotationsSupplier (xTable, uno::UNO_QUERY);
@@ -832,25 +850,57 @@ void ScMyNotEmptyCellsIterator::SkipTable(SCTAB nSkip)
pDetectiveOp->SkipTable(nSkip);
}
+namespace {
+
+bool IsNoteBeforeNextCell(const SCCOL nCol, const SCROW nRow, const table::CellAddress& rAddress)
+{
+ if(nRow < rAddress.Row)
+ return true;
+ else if(nRow > rAddress.Row)
+ return false;
+ else
+ {
+ if(nCol < rAddress.Column)
+ return true;
+ else
+ return false;
+ }
+}
+
+}
+
bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles)
{
table::CellAddress aAddress( nCurrentTable, MAXCOL + 1, MAXROW + 1 );
UpdateAddress( aAddress );
- if( pShapes )
- pShapes->UpdateAddress( aAddress );
- if( pNoteShapes )
- pNoteShapes->UpdateAddress( aAddress );
- if( pEmptyDatabaseRanges )
- pEmptyDatabaseRanges->UpdateAddress( aAddress );
- if( pMergedRanges )
- pMergedRanges->UpdateAddress( aAddress );
- if( pAreaLinks )
- pAreaLinks->UpdateAddress( aAddress );
- if( pDetectiveObj )
- pDetectiveObj->UpdateAddress( aAddress );
- if( pDetectiveOp )
- pDetectiveOp->UpdateAddress( aAddress );
+ if( (maNoteExportListItr != maNoteExportList.end()) && IsNoteBeforeNextCell(maNoteExportListItr->nCol, maNoteExportListItr->nRow, aAddress) )
+ {
+ //we have a note before the new cell
+ aAddress.Column = maNoteExportListItr->nCol;
+ aAddress.Row = maNoteExportListItr->nRow;
+ ++maNoteExportListItr;
+ }
+ else
+ {
+ if(maNoteExportListItr != maNoteExportList.end() && maNoteExportListItr->nCol == aAddress.Column && maNoteExportListItr->nRow == aAddress.Row)
+ ++maNoteExportListItr;
+
+ if( pShapes )
+ pShapes->UpdateAddress( aAddress );
+ if( pNoteShapes )
+ pNoteShapes->UpdateAddress( aAddress );
+ if( pEmptyDatabaseRanges )
+ pEmptyDatabaseRanges->UpdateAddress( aAddress );
+ if( pMergedRanges )
+ pMergedRanges->UpdateAddress( aAddress );
+ if( pAreaLinks )
+ pAreaLinks->UpdateAddress( aAddress );
+ if( pDetectiveObj )
+ pDetectiveObj->UpdateAddress( aAddress );
+ if( pDetectiveOp )
+ pDetectiveOp->UpdateAddress( aAddress );
+ }
bool bFoundCell((aAddress.Column <= MAXCOL) && (aAddress.Row <= MAXROW));
if( bFoundCell )
diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx
index e866f4a0c1c9..9222ff13ce77 100644
--- a/sc/source/filter/xml/XMLExportIterator.hxx
+++ b/sc/source/filter/xml/XMLExportIterator.hxx
@@ -31,6 +31,7 @@
#include <vector>
#include <list>
+#include <set>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
@@ -41,6 +42,7 @@
#include "global.hxx"
#include "detfunc.hxx"
#include "detdata.hxx"
+#include "postit.hxx"
class ScHorizontalCellIterator;
struct ScMyCell;
@@ -355,7 +357,30 @@ struct ScMyExportAnnotation
bool operator<(const ScMyExportAnnotation& rAnno) const;
};
+struct ScNoteExportData
+{
+ SCROW nRow;
+ SCCOL nCol;
+ ScPostIt* pNote;
+
+ bool operator<(const ScNoteExportData& r) const
+ {
+ if(nRow < r.nRow)
+ return true;
+ else if(nRow > r.nRow)
+ return false;
+ else
+ {
+ if(nCol < r.nCol)
+ return true;
+ else
+ return false;
+ }
+ }
+};
+
typedef ::std::list< ScMyExportAnnotation > ScMyExportAnnotationList;
+typedef ::std::set< ScNoteExportData > ScMyNoteExportDataList;
class ScMyNotEmptyCellsIterator
{
@@ -371,6 +396,8 @@ class ScMyNotEmptyCellsIterator
ScMyAreaLinksContainer* pAreaLinks;
ScMyDetectiveObjContainer* pDetectiveObj;
ScMyDetectiveOpContainer* pDetectiveOp;
+ ScMyNoteExportDataList maNoteExportList;
+ ScMyNoteExportDataList::iterator maNoteExportListItr;
ScXMLExport& rExport;
ScHorizontalCellIterator* pCellItr;
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 6b91c2e34884..55f0e6420f41 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -659,12 +659,10 @@ void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCo
CreateSharedData(nTableCount);
pCellStyles->AddNewTable(nTableCount - 1);
- pDoc->InitializeAllNoteCaptions(true);
- if (!HasDrawPages(xSpreadDoc))
- return;
for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
{
+ pDoc->GetNotes(nTable)->CreateAllNoteCaptions(nTable);
nCurrentTable = sal::static_int_cast<sal_uInt16>(nTable);
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xIndex->getByIndex(nTable), uno::UNO_QUERY);
if (!xDrawPageSupplier.is())