[Libreoffice-commits] .: 2 commits - sc/inc sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Sat Jul 7 19:52:56 PDT 2012
sc/inc/postit.hxx | 2
sc/source/core/data/postit.cxx | 7 ++
sc/source/filter/excel/xistream.cxx | 2
sc/source/filter/xml/XMLExportIterator.cxx | 78 +++++++++++++++++++++++------
sc/source/filter/xml/XMLExportIterator.hxx | 27 ++++++++++
sc/source/filter/xml/xmlexprt.cxx | 4 -
6 files changed, 101 insertions(+), 19 deletions(-)
New commits:
commit 382b8bafd041edb2f44052e931e701e0ee626597
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Jul 8 04:49:50 2012 +0200
we still need to pass the wrong number of read bytes
Somehow we rely in some cases on the invalid number of read bytes.
Change-Id: I07e31c231cd96878da098f72cf3279da939da9c7
diff --git a/sc/source/filter/excel/xistream.cxx b/sc/source/filter/excel/xistream.cxx
index 8cd9980..20f9c32 100644
--- a/sc/source/filter/excel/xistream.cxx
+++ b/sc/source/filter/excel/xistream.cxx
@@ -824,7 +824,7 @@ sal_Size XclImpStream::CopyToStream( SvStream& rOutStrm, sal_Size nBytes )
nRet += Read( pnBuffer, nReadSize );
// writing more bytes than read results in invalid memory access
SAL_WARN_IF(nRet != nReadSize, "sc", "read less bytes than requested");
- rOutStrm.Write( pnBuffer, nRet );
+ rOutStrm.Write( pnBuffer, nReadSize );
nBytesLeft -= nReadSize;
}
commit f23e5407c137504d5efa980f7ac202e1566b583e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Jul 8 04:44:14 2012 +0200
export all notes into odf, fdo#49924
Change-Id: Ic3b9176b1b8da7663d1dc3c88a4d56cd794e0805
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index e553c92..0db2a9f 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 279b3ff..97ab523 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 31981bb..cd8b445 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 e866f4a..9222ff1 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 5cd5594..9d8fbe3 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())
More information about the Libreoffice-commits
mailing list