summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-26 11:50:30 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-07-30 23:49:56 -0400
commit51c940947f5536b5edda59531265dc4677ca9200 (patch)
tree046b657939d15de6f7d44f08f02bcf82e1743b49 /sc/qa
parentcc5ac726d5d5947449a081a98bd890fe059a75fc (diff)
Add export test for exporting inline arrays to xls format.
Change-Id: I8f6e32adcbd33362f20eca3ce329633bf9fbf039
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/data/xls/inline-array.xlsbin0 -> 13824 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx53
2 files changed, 53 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xls/inline-array.xls b/sc/qa/unit/data/xls/inline-array.xls
new file mode 100644
index 000000000000..64574f84310a
--- /dev/null
+++ b/sc/qa/unit/data/xls/inline-array.xls
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 600bc5a7b75d..ad7a5140d235 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -26,6 +26,7 @@
#include "scitems.hxx"
#include "document.hxx"
#include "cellform.hxx"
+#include "formulacell.hxx"
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -51,6 +52,8 @@ public:
void testMiscRowHeightExport();
void testNamedRangeBugfdo62729();
+ void testInlineArrayXLS();
+
CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test);
#if !defined(MACOSX) && !defined(DRAGONFLY)
@@ -62,6 +65,7 @@ public:
CPPUNIT_TEST(testColorScaleExportXLSX);
CPPUNIT_TEST(testMiscRowHeightExport);
CPPUNIT_TEST(testNamedRangeBugfdo62729);
+ CPPUNIT_TEST(testInlineArrayXLS);
CPPUNIT_TEST_SUITE_END();
private:
@@ -319,6 +323,55 @@ void ScExportTest::testNamedRangeBugfdo62729()
xDocSh->DoClose();
}
+namespace {
+
+void checkMatrixRange(ScDocument& rDoc, const ScRange& rRange)
+{
+ ScRange aMatRange;
+ ScAddress aMatOrigin;
+ for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
+ {
+ for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow)
+ {
+ ScAddress aPos(nCol, nRow, rRange.aStart.Tab());
+ bool bIsMatrix = rDoc.GetMatrixFormulaRange(aPos, aMatRange);
+ CPPUNIT_ASSERT_MESSAGE("Matrix expected, but not found.", bIsMatrix);
+ CPPUNIT_ASSERT_MESSAGE("Wrong matrix range.", rRange == aMatRange);
+ const ScFormulaCell* pCell = rDoc.GetFormulaCell(aPos);
+ CPPUNIT_ASSERT_MESSAGE("This must be a formula cell.", pCell);
+
+ bIsMatrix = pCell->GetMatrixOrigin(aMatOrigin);
+ CPPUNIT_ASSERT_MESSAGE("Not a part of matrix formula.", bIsMatrix);
+ CPPUNIT_ASSERT_MESSAGE("Wrong matrix origin.", aMatOrigin == aMatRange.aStart);
+ }
+ }
+}
+
+}
+
+void ScExportTest::testInlineArrayXLS()
+{
+ ScDocShellRef xShell = loadDoc("inline-array.", XLS);
+ CPPUNIT_ASSERT(xShell.Is());
+
+ ScDocShellRef xDocSh = saveAndReload(xShell, XLS);
+ CPPUNIT_ASSERT(xDocSh.Is());
+
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+
+ // B2:C3 contains a matrix.
+ checkMatrixRange(*pDoc, ScRange(1,1,0,2,2,0));
+
+ // B5:D6 contains a matrix.
+ checkMatrixRange(*pDoc, ScRange(1,4,0,3,5,0));
+
+ // B8:C10 as well.
+ checkMatrixRange(*pDoc, ScRange(1,7,0,2,9,0));
+
+ xDocSh->DoClose();
+}
+
ScExportTest::ScExportTest()
: ScBootstrapFixture("/sc/qa/unit/data")
{