diff options
-rw-r--r-- | sc/inc/postit.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/postit.cxx | 7 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLExportIterator.cxx | 78 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLExportIterator.hxx | 27 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 4 |
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 31981bb12b48..cd8b4459359c 100644 --- a/sc/source/filter/xml/XMLExportIterator.cxx +++ b/sc/source/filter/xml/XMLExportIterator.cxx @@ -672,6 +672,7 @@ void ScMyNotEmptyCellsIterator::Clear() OSL_FAIL("not all Annotations saved"); aAnnotations.clear(); } + maNoteExportList.clear(); pCellItr = NULL; pShapes = NULL; pNoteShapes = NULL; @@ -764,6 +765,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) { @@ -773,11 +775,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); @@ -828,25 +846,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 5cd559427bb2..9d8fbe38f1ee 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -654,12 +654,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()) |