summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-01-07 15:02:25 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-01-07 15:03:39 -0500
commit0bb184196e2b6a10640155a02d0eac263a1f48e4 (patch)
treec51a688fe9dfc045f248fef8aa0ef8c0e46dae04 /sc/qa
parentf6bf087a039a7c275207eba4a35e0ad814cf2813 (diff)
Remove duplicated code blocks.
Change-Id: I332a39fe86fee385bcd2cce33fe2096043111472 TODO: Do this in the other tests as well.
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx88
1 files changed, 23 insertions, 65 deletions
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index df858dab2bd4..214069338fbf 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -113,6 +113,8 @@ public:
const rtl::OUString &rUserData, const rtl::OUString& rTypeName,
unsigned int nFilterFlags, unsigned int nClipboardID, unsigned int nFilterVersion);
+ ScDocShellRef loadFile(const OUString& rBaseName, size_t nExt);
+
void createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath);
void createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rFilePath);
@@ -263,6 +265,20 @@ ScDocShellRef ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUStr
return xDocShRef;
}
+ScDocShellRef ScFiltersTest::loadFile(const OUString& rBaseName, size_t nExt)
+{
+ OUString aFileExt = OUString::createFromAscii(aFileFormats[nExt].pName);
+ OUString aFilterName = OUString::createFromAscii(aFileFormats[nExt].pFilterName);
+ OUString aFilterType = OUString::createFromAscii(aFileFormats[nExt].pTypeName);
+
+ rtl::OUString aFileName;
+ createFileURL(rBaseName, aFileExt, aFileName);
+
+ unsigned int nFormatType = aFileFormats[nExt].nFormatType;
+ unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0;
+ return load(aFilterName, aFileName, OUString(), aFilterType, nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT);
+}
+
bool ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL,
const rtl::OUString &rUserData, unsigned int nFilterFlags,
unsigned int nClipboardID, unsigned int nFilterVersion)
@@ -1392,19 +1408,7 @@ void ScFiltersTest::testControlImport()
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);
-
- unsigned int nFormatType = aFileFormats[HTML].nFormatType;
- unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0;
- ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType,
- nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT);
-
+ ScDocShellRef xDocSh = loadFile("numberformat.", HTML);
CPPUNIT_ASSERT_MESSAGE("Failed to load numberformat.html", xDocSh.Is());
ScDocument* pDoc = xDocSh->GetDocument();
@@ -1424,20 +1428,8 @@ void ScFiltersTest::testNumberFormatHTML()
void ScFiltersTest::testNumberFormatCSV()
{
- OUString aFileNameBase("numberformat.");
- OUString aFileExt = OUString::createFromAscii(aFileFormats[CSV].pName);
- OUString aFilterName = OUString::createFromAscii(aFileFormats[CSV].pFilterName);
- OUString aFilterType = OUString::createFromAscii(aFileFormats[CSV].pTypeName);
-
- rtl::OUString aFileName;
- createFileURL(aFileNameBase, aFileExt, aFileName);
-
- unsigned int nFormatType = aFileFormats[CSV].nFormatType;
- unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0;
- ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType,
- nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT);
-
- CPPUNIT_ASSERT_MESSAGE("Failed to load numberformat.html", xDocSh.Is());
+ ScDocShellRef xDocSh = loadFile("numberformat.", CSV);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load numberformat.csv", xDocSh.Is());
ScDocument* pDoc = xDocSh->GetDocument();
@@ -1456,19 +1448,7 @@ void ScFiltersTest::testNumberFormatCSV()
void ScFiltersTest::testCellAnchoredShapesODS()
{
- OUString aFileNameBase("cell-anchored-shapes.");
- OUString aFileExt = OUString::createFromAscii(aFileFormats[ODS].pName);
- OUString aFilterName = OUString::createFromAscii(aFileFormats[ODS].pFilterName);
- OUString aFilterType = OUString::createFromAscii(aFileFormats[ODS].pTypeName);
-
- rtl::OUString aFileName;
- createFileURL(aFileNameBase, aFileExt, aFileName);
-
- unsigned int nFormatType = aFileFormats[ODS].nFormatType;
- unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0;
- ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType,
- nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT);
-
+ ScDocShellRef xDocSh = loadFile("cell-anchored-shapes.", ODS);
CPPUNIT_ASSERT_MESSAGE("Failed to load cell-anchored-shapes.ods", xDocSh.Is());
// There are two cell-anchored objects on the first sheet.
@@ -1516,19 +1496,7 @@ bool hasDimension(const std::vector<const ScDPSaveDimension*>& rDims, const OUSt
void ScFiltersTest::testPivotTableBasicODS()
{
- OUString aFileNameBase("pivot-table-basic.");
- OUString aFileExt = OUString::createFromAscii(aFileFormats[ODS].pName);
- OUString aFilterName = OUString::createFromAscii(aFileFormats[ODS].pFilterName);
- OUString aFilterType = OUString::createFromAscii(aFileFormats[ODS].pTypeName);
-
- rtl::OUString aFileName;
- createFileURL(aFileNameBase, aFileExt, aFileName);
-
- unsigned int nFormatType = aFileFormats[ODS].nFormatType;
- unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0;
- ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType,
- nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT);
-
+ ScDocShellRef xDocSh = loadFile("pivot-table-basic.", ODS);
CPPUNIT_ASSERT_MESSAGE("Failed to load pivot-table-basic.ods", xDocSh.Is());
ScDocument* pDoc = xDocSh->GetDocument();
@@ -1576,18 +1544,8 @@ void ScFiltersTest::testPivotTableBasicODS()
void ScFiltersTest::testRowHeightODS()
{
- OUString aFileNameBase("row-height-import.");
- OUString aFileExt = OUString::createFromAscii(aFileFormats[ODS].pName);
- OUString aFilterName = OUString::createFromAscii(aFileFormats[ODS].pFilterName);
- OUString aFilterType = OUString::createFromAscii(aFileFormats[ODS].pTypeName);
-
- rtl::OUString aFileName;
- createFileURL(aFileNameBase, aFileExt, aFileName);
-
- unsigned int nFormatType = aFileFormats[ODS].nFormatType;
- unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0;
- ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType,
- nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT);
+ ScDocShellRef xDocSh = loadFile("row-height-import.", ODS);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load row-height-import.ods", xDocSh.Is());
SCTAB nTab = 0;
SCROW nRow = 0;