[Libreoffice-commits] .: 5 commits - sc/CppunitTest_sc_filters_test.mk sc/qa sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Fri Nov 18 13:34:01 PST 2011
sc/CppunitTest_sc_filters_test.mk | 8 ++++
sc/qa/unit/filters-test.cxx | 71 ++++++++++++++++++++++++++++++++++++++
sc/source/core/data/dociter.cxx | 17 +++++----
3 files changed, 90 insertions(+), 6 deletions(-)
New commits:
commit a66be6346987e02e389331fcc4204b020ceaded8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 18 22:32:46 2011 +0100
refactor the new bugFile tests
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 03d35c4..195d5ef 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -180,6 +180,8 @@ public:
void testPassword();
#if TEST_BUG_FILES
+ //goes recursively through all files in this dir and tries to open them
+ void testDir(osl::Directory& rDir, sal_Int32 nType);
//test Bug Files and search for files that crash LibO
void testBugFiles();
void testBugFilesXLS();
@@ -278,76 +280,54 @@ void ScFiltersTest::testCVEs()
#if TEST_BUG_FILES
-void ScFiltersTest::testBugFiles()
+void ScFiltersTest::testDir(osl::Directory& rDir, sal_uInt32 nType)
{
- rtl::OUString aFilterName(aFileFormats[0].pFilterName, strlen(aFileFormats[0].pFilterName), RTL_TEXTENCODING_UTF8) ;
- rtl::OUString aFilterType(aFileFormats[0].pTypeName, strlen(aFileFormats[0].pTypeName), RTL_TEXTENCODING_UTF8);
- rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugODS/");
- osl::Directory aDir(aDirName);
+ rtl::OUString aFilterName(aFileFormats[nType].pFilterName, strlen(aFileFormats[nType].pFilterName), RTL_TEXTENCODING_UTF8) ;
+ rtl::OUString aFilterType(aFileFormats[nType].pTypeName, strlen(aFileFormats[nType].pTypeName), RTL_TEXTENCODING_UTF8);
- CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open());
osl::DirectoryItem aItem;
osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
- while (aDir.getNextItem(aItem) == osl::FileBase::E_None)
+ while (rDir.getNextItem(aItem) == osl::FileBase::E_None)
{
aItem.getFileStatus(aFileStatus);
rtl::OUString sURL = aFileStatus.getFileURL();
std::cout << "File: " << rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
rtl::OStringBuffer aMessage("Failed loading: ");
aMessage.append(rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8));
- ScDocShellRef xDocSh = load( aFilterName,sURL, rtl::OUString(),aFilterType, aFileFormats[0].nFormatType);
+ ScDocShellRef xDocSh = load( aFilterName,sURL, rtl::OUString(),aFilterType, aFileFormats[nType].nFormatType);
+ // use this only if you're sure that all files can be loaded
+ // pay attention to lock files
//CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xDocSh.Is());
if (xDocSh.Is())
xDocSh->DoClose();
}
}
+void ScFiltersTest::testBugFiles()
+{
+ rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugODS/");
+ osl::Directory aDir(aDirName);
+
+ CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open());
+ testDir(aDir, 0);
+}
+
void ScFiltersTest::testBugFilesXLS()
{
- rtl::OUString aFilterName(aFileFormats[1].pFilterName, strlen(aFileFormats[1].pFilterName), RTL_TEXTENCODING_UTF8) ;
- rtl::OUString aFilterType(aFileFormats[1].pTypeName, strlen(aFileFormats[1].pTypeName), RTL_TEXTENCODING_UTF8);
rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLS/");
osl::Directory aDir(aDirName);
CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open());
- osl::DirectoryItem aItem;
- osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
- while (aDir.getNextItem(aItem) == osl::FileBase::E_None)
- {
- aItem.getFileStatus(aFileStatus);
- rtl::OUString sURL = aFileStatus.getFileURL();
- std::cout << "File: " << rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- rtl::OStringBuffer aMessage("Failed loading: ");
- aMessage.append(rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8));
- ScDocShellRef xDocSh = load( aFilterName,sURL, rtl::OUString(),aFilterType, aFileFormats[1].nFormatType);
- //CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xDocSh.Is());
- if (xDocSh.Is())
- xDocSh->DoClose();
- }
+ testDir(aDir, 1);
}
void ScFiltersTest::testBugFilesXLSX()
{
- rtl::OUString aFilterName(aFileFormats[2].pFilterName, strlen(aFileFormats[2].pFilterName), RTL_TEXTENCODING_UTF8) ;
- rtl::OUString aFilterType(aFileFormats[2].pTypeName, strlen(aFileFormats[2].pTypeName), RTL_TEXTENCODING_UTF8);
rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLSX/");
osl::Directory aDir(aDirName);
CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open());
- osl::DirectoryItem aItem;
- osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
- while (aDir.getNextItem(aItem) == osl::FileBase::E_None)
- {
- aItem.getFileStatus(aFileStatus);
- rtl::OUString sURL = aFileStatus.getFileURL();
- std::cout << "File: " << rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- rtl::OStringBuffer aMessage("Failed loading: ");
- aMessage.append(rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8));
- ScDocShellRef xDocSh = load( aFilterName,sURL, rtl::OUString(),aFilterType, aFileFormats[2].nFormatType);
- //CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xDocSh.Is());
- if (xDocSh.Is())
- xDocSh->DoClose();
- }
+ testDir(aDir, 2);
}
#endif
commit fe5f715cad0fb4ff204ff7dffebcc252759b3208
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 18 00:49:12 2011 +0100
and another missing component for xls
diff --git a/sc/CppunitTest_sc_filters_test.mk b/sc/CppunitTest_sc_filters_test.mk
index fa18613..3051ef8 100644
--- a/sc/CppunitTest_sc_filters_test.mk
+++ b/sc/CppunitTest_sc_filters_test.mk
@@ -91,6 +91,7 @@ $(eval $(call gb_CppunitTest_add_type_rdbs,sc_filters_test,\
$(eval $(call gb_CppunitTest_add_components,sc_filters_test,\
basic/util/sb \
chart2/source/controller/chartcontroller \
+ chart2/source/tools/charttools \
chart2/source/model/chartmodel \
comphelper/util/comphelp \
dbaccess/util/dba \
commit 21c437d17b20d72823cdd617785462e342326e28
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 18 00:40:46 2011 +0100
allow testing of bugfiles in sc's filters-test
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index bcda710..03d35c4 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -43,6 +43,7 @@
#include <editeng/justifyitem.hxx>
#define CALC_DEBUG_OUTPUT 0
+#define TEST_BUG_FILES 0
#include "helper/csv_handler.hxx"
#include "helper/debughelper.hxx"
@@ -95,6 +96,8 @@ void testFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab, StringType
aConfig.delimiters.push_back(',');
aConfig.delimiters.push_back(';');
aConfig.text_qualifier = '"';
+
+
std::string aContent;
loadFile(aFileName, aContent);
orcus::csv_parser<csv_handler> parser ( &aContent[0], aContent.size() , aHandler, aConfig);
@@ -176,6 +179,13 @@ public:
//misc tests unrelated to the import filters
void testPassword();
+#if TEST_BUG_FILES
+ //test Bug Files and search for files that crash LibO
+ void testBugFiles();
+ void testBugFilesXLS();
+ void testBugFilesXLSX();
+#endif
+
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testCVEs);
CPPUNIT_TEST(testRangeName);
@@ -189,6 +199,11 @@ public:
CPPUNIT_TEST(testBugFixesXLSX);
CPPUNIT_TEST(testPassword);
+#if TEST_BUG_FILES
+ CPPUNIT_TEST(testBugFiles);
+ CPPUNIT_TEST(testBugFilesXLS);
+ CPPUNIT_TEST(testBugFilesXLSX);
+#endif
CPPUNIT_TEST_SUITE_END();
private:
@@ -261,6 +276,82 @@ void ScFiltersTest::testCVEs()
getURLFromSrc("/sc/qa/unit/data/slk/"), rtl::OUString());
}
+#if TEST_BUG_FILES
+
+void ScFiltersTest::testBugFiles()
+{
+ rtl::OUString aFilterName(aFileFormats[0].pFilterName, strlen(aFileFormats[0].pFilterName), RTL_TEXTENCODING_UTF8) ;
+ rtl::OUString aFilterType(aFileFormats[0].pTypeName, strlen(aFileFormats[0].pTypeName), RTL_TEXTENCODING_UTF8);
+ rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugODS/");
+ osl::Directory aDir(aDirName);
+
+ CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open());
+ osl::DirectoryItem aItem;
+ osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
+ while (aDir.getNextItem(aItem) == osl::FileBase::E_None)
+ {
+ aItem.getFileStatus(aFileStatus);
+ rtl::OUString sURL = aFileStatus.getFileURL();
+ std::cout << "File: " << rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ rtl::OStringBuffer aMessage("Failed loading: ");
+ aMessage.append(rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8));
+ ScDocShellRef xDocSh = load( aFilterName,sURL, rtl::OUString(),aFilterType, aFileFormats[0].nFormatType);
+ //CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xDocSh.Is());
+ if (xDocSh.Is())
+ xDocSh->DoClose();
+ }
+}
+
+void ScFiltersTest::testBugFilesXLS()
+{
+ rtl::OUString aFilterName(aFileFormats[1].pFilterName, strlen(aFileFormats[1].pFilterName), RTL_TEXTENCODING_UTF8) ;
+ rtl::OUString aFilterType(aFileFormats[1].pTypeName, strlen(aFileFormats[1].pTypeName), RTL_TEXTENCODING_UTF8);
+ rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLS/");
+ osl::Directory aDir(aDirName);
+
+ CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open());
+ osl::DirectoryItem aItem;
+ osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
+ while (aDir.getNextItem(aItem) == osl::FileBase::E_None)
+ {
+ aItem.getFileStatus(aFileStatus);
+ rtl::OUString sURL = aFileStatus.getFileURL();
+ std::cout << "File: " << rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ rtl::OStringBuffer aMessage("Failed loading: ");
+ aMessage.append(rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8));
+ ScDocShellRef xDocSh = load( aFilterName,sURL, rtl::OUString(),aFilterType, aFileFormats[1].nFormatType);
+ //CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xDocSh.Is());
+ if (xDocSh.Is())
+ xDocSh->DoClose();
+ }
+}
+
+void ScFiltersTest::testBugFilesXLSX()
+{
+ rtl::OUString aFilterName(aFileFormats[2].pFilterName, strlen(aFileFormats[2].pFilterName), RTL_TEXTENCODING_UTF8) ;
+ rtl::OUString aFilterType(aFileFormats[2].pTypeName, strlen(aFileFormats[2].pTypeName), RTL_TEXTENCODING_UTF8);
+ rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLSX/");
+ osl::Directory aDir(aDirName);
+
+ CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open());
+ osl::DirectoryItem aItem;
+ osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
+ while (aDir.getNextItem(aItem) == osl::FileBase::E_None)
+ {
+ aItem.getFileStatus(aFileStatus);
+ rtl::OUString sURL = aFileStatus.getFileURL();
+ std::cout << "File: " << rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ rtl::OStringBuffer aMessage("Failed loading: ");
+ aMessage.append(rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8));
+ ScDocShellRef xDocSh = load( aFilterName,sURL, rtl::OUString(),aFilterType, aFileFormats[2].nFormatType);
+ //CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xDocSh.Is());
+ if (xDocSh.Is())
+ xDocSh->DoClose();
+ }
+}
+
+#endif
+
namespace {
void testRangeNameImpl(ScDocument* pDoc)
commit 5455ffb97e93a88d6cf9d471d20566897595b7b8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Nov 17 20:41:28 2011 +0100
add component files so that we can import all ods, xls, xlsx in tests
diff --git a/sc/CppunitTest_sc_filters_test.mk b/sc/CppunitTest_sc_filters_test.mk
index 47fb2c5..fa18613 100644
--- a/sc/CppunitTest_sc_filters_test.mk
+++ b/sc/CppunitTest_sc_filters_test.mk
@@ -90,8 +90,11 @@ $(eval $(call gb_CppunitTest_add_type_rdbs,sc_filters_test,\
$(eval $(call gb_CppunitTest_add_components,sc_filters_test,\
basic/util/sb \
+ chart2/source/controller/chartcontroller \
+ chart2/source/model/chartmodel \
comphelper/util/comphelp \
dbaccess/util/dba \
+ eventattacher/source/evtatt \
fileaccess/source/fileacc \
filter/source/config/cache/filterconfig1 \
forms/util/frm \
@@ -104,8 +107,11 @@ $(eval $(call gb_CppunitTest_add_components,sc_filters_test,\
sax/source/fastparser/fastsax \
sc/util/sc \
sc/util/scfilt \
+ scaddins/source/analysis/analysis \
+ scaddins/source/datefunc/date \
sfx2/util/sfx \
sot/util/sot \
+ svl/util/svl \
toolkit/util/tk \
unotools/util/utl \
unoxml/source/rdf/unordf \
@@ -127,6 +133,7 @@ $(eval $(call gb_CppunitTest_add_components,sc_filters_test,\
endif
$(eval $(call gb_CppunitTest_add_old_components,sc_filters_test,\
+ embobj \
configmgr \
ucb1 \
ucpfile1 \
commit 84de459738d5c16b3df8719ff219aaccc3532b8c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Nov 17 08:24:30 2011 +0100
fix crash in dociter.cxx during import
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 9cee166..cb1bee7 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -75,9 +75,10 @@ ScDocumentIterator::ScDocumentIterator( ScDocument* pDocument,
nStartTab( nStartTable ),
nEndTab( nEndTable )
{
+ SCTAB nDocMaxTab = pDoc->GetTableCount() - 1;
PutInOrder( nStartTab, nEndTab );
- if (!ValidTab(nStartTab)) nStartTab = pDoc->GetTableCount()-1;
- if (!ValidTab(nEndTab)) nEndTab = pDoc->GetTableCount()-1;
+ if (!ValidTab(nStartTab) || nStartTab > nDocMaxTab ) nStartTab = nDocMaxTab;
+ if (!ValidTab(nEndTab) || nStartTab > nDocMaxTab ) nEndTab = nDocMaxTab;
pDefPattern = pDoc->GetDefPattern();
@@ -262,6 +263,8 @@ ScValueIterator::ScValueIterator( ScDocument* pDocument, const ScRange& rRange,
bCalcAsShown( pDocument->GetDocOptions().IsCalcAsShown() ),
bTextAsZero( bTextZero )
{
+ SCTAB nDocMaxTab = pDocument->GetTableCount() - 1;
+
PutInOrder( nStartCol, nEndCol);
PutInOrder( nStartRow, nEndRow);
PutInOrder( nStartTab, nEndTab );
@@ -270,8 +273,8 @@ ScValueIterator::ScValueIterator( ScDocument* pDocument, const ScRange& rRange,
if (!ValidCol(nEndCol)) nEndCol = MAXCOL;
if (!ValidRow(nStartRow)) nStartRow = MAXROW;
if (!ValidRow(nEndRow)) nEndRow = MAXROW;
- if (!ValidTab(nStartTab)) nStartTab = MAXTAB;
- if (!ValidTab(nEndTab)) nEndTab = MAXTAB;
+ if (!ValidTab(nStartTab) || nStartTab > nDocMaxTab) nStartTab = nDocMaxTab;
+ if (!ValidTab(nEndTab) || nEndTab > nDocMaxTab) nEndTab = nDocMaxTab;
nCol = nStartCol;
nRow = nStartRow;
@@ -944,6 +947,8 @@ ScCellIterator::ScCellIterator( ScDocument* pDocument,
bSubTotal(bSTotal)
{
+ SCTAB nDocMaxTab = pDocument->GetTableCount() - 1;
+
PutInOrder( nStartCol, nEndCol);
PutInOrder( nStartRow, nEndRow);
PutInOrder( nStartTab, nEndTab );
@@ -952,8 +957,8 @@ ScCellIterator::ScCellIterator( ScDocument* pDocument,
if (!ValidCol(nEndCol)) nEndCol = MAXCOL;
if (!ValidRow(nStartRow)) nStartRow = MAXROW;
if (!ValidRow(nEndRow)) nEndRow = MAXROW;
- if (!ValidTab(nStartTab)) nStartTab = pDoc->GetTableCount()-1;
- if (!ValidTab(nEndTab)) nEndTab = pDoc->GetTableCount()-1;
+ if (!ValidTab(nStartTab) || nStartTab > nDocMaxTab) nStartTab = nDocMaxTab;
+ if (!ValidTab(nEndTab) || nEndTab > nDocMaxTab) nEndTab = nDocMaxTab;
while (nEndTab>0 && !pDoc->maTabs[nEndTab])
--nEndTab; // nur benutzte Tabellen
More information about the Libreoffice-commits
mailing list