sc/qa/unit/ucalc.hxx | 2 sc/source/core/data/column2.cxx | 1 sc/source/core/data/postit.cxx | 1 sc/source/filter/xml/XMLExportIterator.cxx | 107 ++--------------------------- sc/source/filter/xml/XMLExportIterator.hxx | 39 ---------- sc/source/filter/xml/xmlexprt.cxx | 37 +++++++--- 6 files changed, 41 insertions(+), 146 deletions(-)
New commits: commit e56b351f680ee97c34f95f08e16c8ecb87cbb5ba Author: Laurent Godard <[email protected]> Date: Wed Sep 25 13:52:50 2013 +0200 first working export of notes - dirty, need to be cleaned Change-Id: I3819a2717d7d24ca53254f2bc46db3ce7f9eed7f diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index eab3076..8f97e51 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1891,6 +1891,7 @@ const ScPostIt* ScColumn::GetCellNote(SCROW nRow) const void ScColumn::SetCellNote(SCROW nRow, ScPostIt* pNote) { + pNote->UpdateCaptionPos(ScAddress(nCol, nRow, nTab)); maCellNotes.set(nRow, pNote); } void ScColumn::DeleteCellNote(SCROW nRow) diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 9896034..4d3f175 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -906,6 +906,7 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData( pNote->AutoStamp(); rDoc.SetNote(rPos, pNote); + if(pNote) return pNote; else diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx index 6ff000c..afc05fd 100644 --- a/sc/source/filter/xml/XMLExportIterator.cxx +++ b/sc/source/filter/xml/XMLExportIterator.cxx @@ -160,14 +160,12 @@ bool ScMyNoteShapesContainer::GetFirstAddress( table::CellAddress& rCellAddress void ScMyNoteShapesContainer::SetCellData( ScMyCell& rMyCell ) { - rMyCell.xNoteShape.clear(); ScAddress aAddress; ScUnoConversion::FillScAddress( aAddress, rMyCell.aCellAddress ); ScMyNoteShapeList::iterator aItr = aNoteShapeList.begin(); while( (aItr != aNoteShapeList.end()) && (aItr->aPos == aAddress) ) { - rMyCell.xNoteShape = aItr->xShape; aItr = aNoteShapeList.erase(aItr); } } @@ -618,15 +616,6 @@ ScMyCell::~ScMyCell() //============================================================================== -bool ScMyExportAnnotation::operator<(const ScMyExportAnnotation& rAnno) const -{ - if( aCellAddress.Row != rAnno.aCellAddress.Row ) - return (aCellAddress.Row < rAnno.aCellAddress.Row); - else - return (aCellAddress.Column < rAnno.aCellAddress.Column); -} - - ScMyNotEmptyCellsIterator::ScMyNotEmptyCellsIterator(ScXMLExport& rTempXMLExport) : pShapes(NULL), pNoteShapes(NULL), @@ -648,12 +637,6 @@ ScMyNotEmptyCellsIterator::~ScMyNotEmptyCellsIterator() void ScMyNotEmptyCellsIterator::Clear() { - if (!aAnnotations.empty()) - { - OSL_FAIL("not all Annotations saved"); - aAnnotations.clear(); - } - maNoteExportList.clear(); mpCellItr.reset(); pShapes = NULL; pNoteShapes = NULL; @@ -720,39 +703,27 @@ void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, table::CellAddre void ScMyNotEmptyCellsIterator::HasAnnotation(ScMyCell& aCell) { aCell.bHasAnnotation = false; - if (!aAnnotations.empty()) + ScAddress aAddress; + ScUnoConversion::FillScAddress( aAddress, aCell.aCellAddress ); + + ScPostIt* pNote = rExport.GetDocument()->GetNote(aAddress); + + if(pNote) { - ScMyExportAnnotationList::iterator aItr(aAnnotations.begin()); - if ((aCell.aCellAddress.Column == aItr->aCellAddress.Column) && - (aCell.aCellAddress.Row == aItr->aCellAddress.Row)) - { - aCell.xAnnotation.set(aItr->xAnnotation); - uno::Reference<text::XSimpleText> xSimpleText(aCell.xAnnotation, uno::UNO_QUERY); - if (aCell.xAnnotation.is() && xSimpleText.is()) - { - if (!xSimpleText->getString().isEmpty()) - aCell.bHasAnnotation = true; - } - aAnnotations.erase(aItr); - } + aCell.bHasAnnotation = true; + aCell.pNote = pNote; } - - // test - bypass the API - // if (xCellRange.is()) - // aCell.xCell.set(xCellRange->getCellByPosition(aCell.aCellAddress.Column, aCell.aCellAddress.Row)); } void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable, uno::Reference<sheet::XSpreadsheet>& rxTable) { - OSL_ENSURE(aAnnotations.empty(), "not all Annotations saved"); aLastAddress.Row = 0; aLastAddress.Column = 0; aLastAddress.Sheet = nTable; if (nCurrentTable != nTable) { - maNoteExportList.clear(); nCurrentTable = nTable; mpCellItr.reset( @@ -761,75 +732,15 @@ void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable, static_cast<SCCOL>(rExport.GetSharedData()->GetLastColumn(nCurrentTable)), static_cast<SCROW>(rExport.GetSharedData()->GetLastRow(nCurrentTable)))); -/* TODO : notes - - ScTable* pTable = rExport.GetDocument()-> GetTable(nTable); - for ( SCCOL c=0; c < MAXCOLCOUNT; c++) - { - if (pTable->GetColumn(c).HasCellNote()) - { - sc::CellNoteStoreType& noteStore = pTable.GetColumn(c).GetCellNoteStore(); - sc::CellNoteStoreType::iterator it = noteStore.begin(), itEnd = noteStore.end(); - for (; it != itEnd; ++it) - { - ScNoteExportData aExportData; - aExportData.nCol = c; - aExportData.nRow = static_cast <SCROW>(it); - aExportData.pNote = it->first; - maNoteExportList.insert( aExportData ); - } - } - } - - 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); - if (xSheetAnnotationsSupplier.is()) - { - uno::Reference<container::XEnumerationAccess> xAnnotationAccess ( xSheetAnnotationsSupplier->getAnnotations(), uno::UNO_QUERY); - if (xAnnotationAccess.is()) - { - uno::Reference<container::XEnumeration> xAnnotations(xAnnotationAccess->createEnumeration()); - if (xAnnotations.is()) - { - while (xAnnotations->hasMoreElements()) - { - ScMyExportAnnotation aAnnotation; - aAnnotation.xAnnotation.set(xAnnotations->nextElement(), uno::UNO_QUERY); - if (aAnnotation.xAnnotation.is()) - { - aAnnotation.aCellAddress = aAnnotation.xAnnotation->getPosition(); - aAnnotations.push_back(aAnnotation); - } - } - if (!aAnnotations.empty()) - aAnnotations.sort(); - } - } - } } } void ScMyNotEmptyCellsIterator::SkipTable(SCTAB nSkip) { // Skip entries for a sheet that is copied instead of saving normally. - // Cells (including aAnnotations) are handled separately in SetCurrentTable. + // Cells are handled separately in SetCurrentTable. if( pShapes ) pShapes->SkipTable(nSkip); diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx index 9fa520d..857f98c 100644 --- a/sc/source/filter/xml/XMLExportIterator.hxx +++ b/sc/source/filter/xml/XMLExportIterator.hxx @@ -294,8 +294,6 @@ public: // contains data to export for the current cell position struct ScMyCell { - com::sun::star::uno::Reference<com::sun::star::sheet::XSheetAnnotation> xAnnotation; - com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xNoteShape; com::sun::star::table::CellAddress aCellAddress; com::sun::star::table::CellRangeAddress aMergeRange; com::sun::star::table::CellRangeAddress aMatrixRange; @@ -305,6 +303,8 @@ struct ScMyCell ScMyDetectiveObjVec aDetectiveObjVec; ScMyDetectiveOpVec aDetectiveOpVec; + ScPostIt* pNote; + sal_Int32 nValidationIndex; sal_Int32 nStyleIndex; sal_Int32 nNumberFormat; @@ -332,44 +332,11 @@ struct ScMyCell //============================================================================== -struct ScMyExportAnnotation -{ - com::sun::star::uno::Reference<com::sun::star::sheet::XSheetAnnotation> xAnnotation; - com::sun::star::table::CellAddress aCellAddress; - 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 : boost::noncopyable { com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet> xTable; com::sun::star::uno::Reference<com::sun::star::table::XCellRange> xCellRange; com::sun::star::table::CellAddress aLastAddress; - ScMyExportAnnotationList aAnnotations; ScMyShapesContainer* pShapes; ScMyNoteShapesContainer* pNoteShapes; @@ -378,8 +345,6 @@ class ScMyNotEmptyCellsIterator : boost::noncopyable ScMyAreaLinksContainer* pAreaLinks; ScMyDetectiveObjContainer* pDetectiveObj; ScMyDetectiveOpContainer* pDetectiveOp; - ScMyNoteExportDataList maNoteExportList; - ScMyNoteExportDataList::iterator maNoteExportListItr; ScXMLExport& rExport; boost::scoped_ptr<ScHorizontalCellIterator> mpCellItr; diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index bd8b3e5..bab349e 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -655,7 +655,6 @@ void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCo 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()) @@ -3643,9 +3642,22 @@ void ScXMLExport::WriteAreaLink( const ScMyCell& rMyCell ) void ScXMLExport::exportAnnotationMeta( const uno::Reference < drawing::XShape >& xShape) { - if (pCurrentCell && pCurrentCell->xNoteShape.is() && pCurrentCell->xNoteShape.get() == xShape.get() && pCurrentCell->xAnnotation.is()) + ScAddress aCellPos; + ScUnoConversion::FillScAddress( aCellPos, pCurrentCell->aCellAddress ); + + ScPostIt* pNote = pCurrentCell->pNote; + + if (pNote) { - OUString sAuthor(pCurrentCell->xAnnotation->getAuthor()); + // TODO : notes + //is it still usefull, as this call back is only called from ScXMLExport::WriteAnnotation + // and should be in sync with pCurrentCell + SdrCaptionObj* pNoteCaption = pNote->GetOrCreateCaption(aCellPos); + Reference<drawing::XShape> xCurrentShape( pNoteCaption->getUnoShape(), uno::UNO_QUERY ); + if (xCurrentShape.get()!=xShape.get()) + return; + + OUString sAuthor(pNote->GetAuthor()); if (!sAuthor.isEmpty()) { SvXMLElementExport aCreatorElem( *this, XML_NAMESPACE_DC, @@ -3654,7 +3666,7 @@ void ScXMLExport::exportAnnotationMeta( const uno::Reference < drawing::XShape > Characters(sAuthor); } - String aDate(pCurrentCell->xAnnotation->getDate()); + String aDate(pNote->GetDate()); if (pDoc) { SvNumberFormatter* pNumForm = pDoc->GetFormatTable(); @@ -3689,20 +3701,25 @@ void ScXMLExport::exportAnnotationMeta( const uno::Reference < drawing::XShape > void ScXMLExport::WriteAnnotation(ScMyCell& rMyCell) { - if( rMyCell.bHasAnnotation && rMyCell.xAnnotation.is()) - { - if (rMyCell.xAnnotation->getIsVisible()) + ScAddress aCellPos; + ScUnoConversion::FillScAddress( aCellPos, rMyCell.aCellAddress ); + + ScPostIt* pNote = pDoc->GetNote(aCellPos); + if (pNote) + { + if (pNote->IsCaptionShown()) AddAttribute(XML_NAMESPACE_OFFICE, XML_DISPLAY, XML_TRUE); pCurrentCell = &rMyCell; - if(rMyCell.xNoteShape.is()) - GetShapeExport()->exportShape(rMyCell.xNoteShape, SEF_DEFAULT|SEF_EXPORT_ANNOTATION, NULL); + SdrCaptionObj* pNoteCaption = pNote->GetOrCreateCaption(aCellPos); + Reference<drawing::XShape> xShape( pNoteCaption->getUnoShape(), uno::UNO_QUERY ); + + GetShapeExport()->exportShape(xShape, SEF_DEFAULT|SEF_EXPORT_ANNOTATION, NULL); pCurrentCell = NULL; - rMyCell.xNoteShape.clear(); } } commit 2f6dd6a7df2190b61b696d50ae60f3411b48616a Author: Laurent Godard <[email protected]> Date: Wed Sep 25 13:52:34 2013 +0200 note unit test Change-Id: I714576a3abec016ceacfe0e49b747e2bec603fca diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 0a141a3..ed2ae1f 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -348,8 +348,8 @@ public: CPPUNIT_TEST(testToggleRefFlag); CPPUNIT_TEST(testAutofilter); CPPUNIT_TEST(testCopyPaste); - CPPUNIT_TEST(testCopyPasteTranspose); CPPUNIT_TEST(testMoveBlock); + CPPUNIT_TEST(testCopyPasteTranspose); CPPUNIT_TEST(testCopyPasteRelativeFormula); CPPUNIT_TEST(testMergedCells); CPPUNIT_TEST(testUpdateReference); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
