Kaydet (Commit) f97a3a7f authored tarafından Kohei Yoshida's avatar Kohei Yoshida

New HTML file to test number format on import.

Change-Id: I74e831e5ede01dfe2954314be6b64b19a551dc6b
üst 582e06f7
<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>
...@@ -60,12 +60,14 @@ ...@@ -60,12 +60,14 @@
#define ODS_FORMAT_TYPE 50331943 #define ODS_FORMAT_TYPE 50331943
#define XLS_FORMAT_TYPE 318767171 #define XLS_FORMAT_TYPE 318767171
#define XLSX_FORMAT_TYPE 268959811 #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 ODS 0
#define XLS 1 #define XLS 1
#define XLSX 2 #define XLSX 2
#define CSV 3 #define CSV 3
#define HTML 4
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
...@@ -80,7 +82,8 @@ FileFormat aFileFormats[] = { ...@@ -80,7 +82,8 @@ FileFormat aFileFormats[] = {
{ "ods" , "calc8", "", ODS_FORMAT_TYPE }, { "ods" , "calc8", "", ODS_FORMAT_TYPE },
{ "xls" , "MS Excel 97", "calc_MS_EXCEL_97", XLS_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 }, { "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: ...@@ -145,6 +148,8 @@ public:
//test shape import //test shape import
void testControlImport(); void testControlImport();
void testNumberFormatHTML();
CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testRangeNameXLS); CPPUNIT_TEST(testRangeNameXLS);
CPPUNIT_TEST(testRangeNameXLSX); CPPUNIT_TEST(testRangeNameXLSX);
...@@ -178,6 +183,8 @@ public: ...@@ -178,6 +183,8 @@ public:
CPPUNIT_TEST(testDataBar); CPPUNIT_TEST(testDataBar);
CPPUNIT_TEST(testCondFormat); CPPUNIT_TEST(testCondFormat);
CPPUNIT_TEST(testNumberFormatHTML);
//disable testPassword on MacOSX due to problems with libsqlite3 //disable testPassword on MacOSX due to problems with libsqlite3
//also crashes on DragonFly due to problems with nss/nspr headers //also crashes on DragonFly due to problems with nss/nspr headers
#if !defined(MACOSX) && !defined(DRAGONFLY) && !defined(WNT) #if !defined(MACOSX) && !defined(DRAGONFLY) && !defined(WNT)
...@@ -1180,6 +1187,32 @@ void ScFiltersTest::testControlImport() ...@@ -1180,6 +1187,32 @@ void ScFiltersTest::testControlImport()
xDocSh->DoClose(); 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() void ScFiltersTest::testColorScale()
{ {
const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("colorScale.")); const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("colorScale."));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment