diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-08-13 13:02:41 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-08-13 14:22:32 -0400 |
commit | f97a3a7f51a7de9c2170953ee3969ef48d914e25 (patch) | |
tree | 41b2554cf1e68c90f4796fe61caa889017ce5862 | |
parent | 582e06f71c63d70189e1ecd4fe365c541648cf83 (diff) |
New HTML file to test number format on import.
Change-Id: I74e831e5ede01dfe2954314be6b64b19a551dc6b
-rw-r--r-- | sc/qa/unit/data/html/numberformat.html | 8 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 37 |
2 files changed, 43 insertions, 2 deletions
diff --git a/sc/qa/unit/data/html/numberformat.html b/sc/qa/unit/data/html/numberformat.html new file mode 100644 index 000000000000..f5fdc026f7da --- /dev/null +++ b/sc/qa/unit/data/html/numberformat.html @@ -0,0 +1,8 @@ +<html lang="en"> +<body> +<table> + <tr><td>Product</td><td>Price</td><td>Note</td></tr> + <tr><td>Google Nexus 7 (8GB)</td><td>199.98</td><td>This should be imported as a number, not text.</td></tr> +</table> +</body> +</html> diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 5667348d78d3..4f7a23beccc4 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -60,12 +60,14 @@ #define ODS_FORMAT_TYPE 50331943 #define XLS_FORMAT_TYPE 318767171 #define XLSX_FORMAT_TYPE 268959811 -#define CSV_FORMAT_TYPE 195 +#define CSV_FORMAT_TYPE (SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_ALIEN | SFX_FILTER_USESOPTIONS) +#define HTML_FORMAT_TYPE (SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_ALIEN | SFX_FILTER_USESOPTIONS) #define ODS 0 #define XLS 1 #define XLSX 2 #define CSV 3 +#define HTML 4 using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -80,7 +82,8 @@ FileFormat aFileFormats[] = { { "ods" , "calc8", "", ODS_FORMAT_TYPE }, { "xls" , "MS Excel 97", "calc_MS_EXCEL_97", XLS_FORMAT_TYPE }, { "xlsx", "Calc MS Excel 2007 XML" , "MS Excel 2007 XML", XLSX_FORMAT_TYPE }, - { "csv" , "Text - txt - csv (StarCalc)", "generic_Text", CSV_FORMAT_TYPE } + { "csv" , "Text - txt - csv (StarCalc)", "generic_Text", CSV_FORMAT_TYPE }, + { "html" , "calc_HTML_WebQuery", "generic_HTML", HTML_FORMAT_TYPE } }; } @@ -145,6 +148,8 @@ public: //test shape import void testControlImport(); + void testNumberFormatHTML(); + CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testRangeNameXLS); CPPUNIT_TEST(testRangeNameXLSX); @@ -178,6 +183,8 @@ public: CPPUNIT_TEST(testDataBar); CPPUNIT_TEST(testCondFormat); + CPPUNIT_TEST(testNumberFormatHTML); + //disable testPassword on MacOSX due to problems with libsqlite3 //also crashes on DragonFly due to problems with nss/nspr headers #if !defined(MACOSX) && !defined(DRAGONFLY) && !defined(WNT) @@ -1180,6 +1187,32 @@ void ScFiltersTest::testControlImport() xDocSh->DoClose(); } +void ScFiltersTest::testNumberFormatHTML() +{ + OUString aFileNameBase("numberformat."); + OUString aFileExt = OUString::createFromAscii(aFileFormats[HTML].pName); + OUString aFilterName = OUString::createFromAscii(aFileFormats[HTML].pFilterName); + OUString aFilterType = OUString::createFromAscii(aFileFormats[HTML].pTypeName); + + rtl::OUString aFileName; + createFileURL(aFileNameBase, aFileExt, aFileName); + ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[HTML].nFormatType); + CPPUNIT_ASSERT_MESSAGE("Failed to load numberformat.html", xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + + // Check the header just in case. + CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(0, 0, 0) == "Product"); + CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(1, 0, 0) == "Price"); + CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(2, 0, 0) == "Note"); + + // B2 should be imported as a value cell. + bool bHasValue = pDoc->HasValueData(1, 1, 0); + CPPUNIT_ASSERT_MESSAGE("Fail to import number as a value cell.", bHasValue); + + xDocSh->DoClose(); +} + void ScFiltersTest::testColorScale() { const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("colorScale.")); |