sc/qa/unit/data/ods/notes-on-3-sheets.ods |binary sc/qa/unit/subsequent_export-test.cxx | 45 ++++++++++++++++++++++++++++++ sc/source/filter/excel/excdoc.cxx | 5 +++ 3 files changed, 50 insertions(+)
New commits: commit 771b9d2718f28beedbc1a913e8965cdd1fc75a88 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Sat Feb 8 11:37:46 2014 -0500 fdo#74521: Only pick cell notes for that sheet, and skip the rest. Change-Id: I06a069e835eb7f2f90d34f4fcdfd935aff0234de diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index a8bfbf7..9cf433d 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -421,7 +421,12 @@ void ExcTable::FillAsTable( SCTAB nCodeNameIdx ) rDoc.GetAllNoteEntries(aNotes); std::vector<sc::NoteEntry>::const_iterator it = aNotes.begin(), itEnd = aNotes.end(); for (; it != itEnd; ++it) + { + if (it->maPos.Tab() != mnScTab) + continue; + mxNoteList->AppendNewRecord(new XclExpNote(GetRoot(), it->maPos, it->mpNote, OUString())); + } if( GetOutput() != EXC_OUTPUT_BINARY ) { commit 7d71fd489c39f348c43477cafdc1bc150bf1ff68 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Sat Feb 8 10:46:47 2014 -0500 fdo#74521: Write unit test for this first. Change-Id: I1815464e25703f1b0181211ac74341edb41793be diff --git a/sc/qa/unit/data/ods/notes-on-3-sheets.ods b/sc/qa/unit/data/ods/notes-on-3-sheets.ods new file mode 100644 index 0000000..e7b6399 Binary files /dev/null and b/sc/qa/unit/data/ods/notes-on-3-sheets.ods differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 47278e0..2db6307 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -70,6 +70,7 @@ public: void testCellValuesExportODS(); void testCellNoteExportODS(); + void testCellNoteExportXLS(); void testFormatExportODS(); void testInlineArrayXLS(); @@ -91,6 +92,7 @@ public: CPPUNIT_TEST(testRichTextExportODS); CPPUNIT_TEST(testCellValuesExportODS); CPPUNIT_TEST(testCellNoteExportODS); + CPPUNIT_TEST(testCellNoteExportXLS); CPPUNIT_TEST(testFormatExportODS); CPPUNIT_TEST(testInlineArrayXLS); CPPUNIT_TEST(testEmbeddedChartXLS); @@ -775,6 +777,49 @@ void ScExportTest::testCellNoteExportODS() xNewDocSh->DoClose(); } +void ScExportTest::testCellNoteExportXLS() +{ + // Start with an empty document.s + ScDocShellRef xOrigDocSh = loadDoc("notes-on-3-sheets.", ODS); + ScDocument* pDoc = xOrigDocSh->GetDocument(); + CPPUNIT_ASSERT_MESSAGE("This document should have 3 sheets.", pDoc->GetTableCount() == 3); + + // Check note's presence. + CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,0,0))); + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,1,0))); + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,2,0))); + + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,0,1))); + CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,1,1))); + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,2,1))); + + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,0,2))); + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,1,2))); + CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,2,2))); + + // save and reload as XLS. + ScDocShellRef xNewDocSh = saveAndReload(xOrigDocSh, XLS); + xOrigDocSh->DoClose(); + CPPUNIT_ASSERT(xNewDocSh.Is()); + pDoc = xNewDocSh->GetDocument(); + CPPUNIT_ASSERT_MESSAGE("This document should have 3 sheets.", pDoc->GetTableCount() == 3); + + // Check note's presence again. + CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,0,0))); + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,1,0))); + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,2,0))); + + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,0,1))); + CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,1,1))); + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,2,1))); + + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,0,2))); + CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,1,2))); + CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,2,2))); + + xNewDocSh->DoClose(); +} + namespace { void checkMatrixRange(ScDocument& rDoc, const ScRange& rRange) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits