From 70430fb14cf25f40abf9521710457ec042a6099d Mon Sep 17 00:00:00 2001 From: Noel Power Date: Mon, 4 Feb 2013 15:37:42 +0000 Subject: eliminate duplicated implementations (load, loadDoc etc. ) in unit tests additionally rtl::OUString(Buffer) => OUString(Buffer) changes Change-Id: Ibf93e8a3ed435fda42836c214b7faac6b3dda71e --- sc/qa/unit/filters-test.cxx | 162 ++++----------- sc/qa/unit/helper/qahelper.hxx | 173 +++++++++++++++- sc/qa/unit/subsequent_export-test.cxx | 197 ++---------------- sc/qa/unit/subsequent_filters-test.cxx | 362 ++++++++++++--------------------- sc/qa/unit/ucalc.cxx | 289 +++++++++++++------------- 5 files changed, 500 insertions(+), 683 deletions(-) (limited to 'sc/qa') diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 980bff211d7e..0f7d8903a652 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -52,57 +52,24 @@ #include "document.hxx" #include "cellform.hxx" -#define ODS_FORMAT_TYPE 50331943 -#define XLS_FORMAT_TYPE 318767171 -#define XLSX_FORMAT_TYPE 268959811 -#define LOTUS123_FORMAT_TYPE 268435649 - -#define ODS 0 -#define XLS 1 -#define XLSX 2 -#define LOTUS123 3 - using namespace ::com::sun::star; using namespace ::com::sun::star::uno; -namespace { - -struct FileFormat { - const char* pName; const char* pFilterName; const char* pTypeName; unsigned int nFormatType; -}; - -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 }, - { "123" , "Lotus", "calc_Lotus", LOTUS123_FORMAT_TYPE } -}; - -} - /* Implementation of Filters test */ class ScFiltersTest : public test::FiltersTest - , public test::BootstrapFixture + , public ScBootstrapFixture { public: ScFiltersTest(); - virtual bool load( const rtl::OUString &rFilter, const rtl::OUString &rURL, - const rtl::OUString &rUserData, unsigned int nFilterFlags, - unsigned int nClipboardID, unsigned int nFilterVersion); - - ScDocShellRef load(const rtl::OUString &rFilter, const rtl::OUString &rURL, - const rtl::OUString &rUserData, const rtl::OUString& rTypeName, - unsigned int nFilterFlags, unsigned int nClipboardID, unsigned int nFilterVersion); - - void createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath); - void createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rFilePath); - virtual void setUp(); virtual void tearDown(); + virtual bool load( const OUString &rFilter, const OUString &rURL, + const OUString &rUserData, unsigned int nFilterFlags, + unsigned int nClipboardID, unsigned int nFilterVersion); /** * Ensure CVEs remain unbroken */ @@ -140,42 +107,15 @@ public: CPPUNIT_TEST_SUITE_END(); private: - ScDocShellRef loadDoc(const rtl::OUString& rName, sal_Int32 nFormat); uno::Reference m_xCalcComponent; - ::rtl::OUString m_aBaseString; }; -ScDocShellRef ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL, - const rtl::OUString &rUserData, const rtl::OUString& rTypeName, - unsigned int nFilterFlags, unsigned int nClipboardID, unsigned int nFilterVersion) -{ - SfxFilter* pFilter = new SfxFilter( - rFilter, - rtl::OUString(), nFilterFlags, nClipboardID, rTypeName, 0, rtl::OUString(), - rUserData, rtl::OUString("private:factory/scalc*") ); - pFilter->SetVersion(nFilterVersion); - - ScDocShellRef xDocShRef = new ScDocShell; - xDocShRef->GetDocument()->EnableUserInteraction(false); - SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ); - pSrcMed->UseInteractionHandler(false); - pSrcMed->SetFilter(pFilter); - if (!xDocShRef->DoLoad(pSrcMed)) - { - xDocShRef->DoClose(); - // load failed. - xDocShRef.Clear(); - } - - return xDocShRef; -} - -bool ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL, - const rtl::OUString &rUserData, unsigned int nFilterFlags, +bool ScFiltersTest::load(const OUString &rFilter, const OUString &rURL, + const OUString &rUserData, unsigned int nFilterFlags, unsigned int nClipboardID, unsigned int nFilterVersion) { - ScDocShellRef xDocShRef = load(rFilter, rURL, rUserData, - rtl::OUString(), nFilterFlags, nClipboardID, nFilterVersion); + ScDocShellRef xDocShRef = ScBootstrapFixture::load(rURL, rFilter, rUserData, + OUString(), nFilterFlags, nClipboardID, nFilterVersion ); bool bLoaded = xDocShRef.Is(); //reference counting of ScDocShellRef is very confused. if (bLoaded) @@ -183,37 +123,20 @@ bool ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL return bLoaded; } -void ScFiltersTest::createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath) -{ - rtl::OUString aSep(RTL_CONSTASCII_USTRINGPARAM("/")); - rtl::OUStringBuffer aBuffer( getSrcRootURL() ); - aBuffer.append(m_aBaseString).append(aSep).append(aFileExtension); - aBuffer.append(aSep).append(aFileBase).append(aFileExtension); - rFilePath = aBuffer.makeStringAndClear(); -} - -void ScFiltersTest::createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rCSVPath) -{ - rtl::OUStringBuffer aBuffer(getSrcRootPath()); - aBuffer.append(m_aBaseString).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/contentCSV/"))); - aBuffer.append(aFileBase).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("csv"))); - rCSVPath = aBuffer.makeStringAndClear(); -} - void ScFiltersTest::testCVEs() { #ifndef DISABLE_CVE_TESTS - testDir(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Quattro Pro 6.0")), - getURLFromSrc("/sc/qa/unit/data/qpro/"), rtl::OUString()); + testDir(OUString(RTL_CONSTASCII_USTRINGPARAM("Quattro Pro 6.0")), + getURLFromSrc("/sc/qa/unit/data/qpro/"), OUString()); //warning, the current "sylk filter" in sc (docsh.cxx) automatically //chains on failure on trying as csv, rtf, etc. so "success" may //not indicate that it imported as .slk. - testDir(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYLK")), - getURLFromSrc("/sc/qa/unit/data/slk/"), rtl::OUString()); + testDir(OUString(RTL_CONSTASCII_USTRINGPARAM("SYLK")), + getURLFromSrc("/sc/qa/unit/data/slk/"), OUString()); - testDir(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Excel 97")), - getURLFromSrc("/sc/qa/unit/data/xls/"), rtl::OUString()); + testDir(OUString(RTL_CONSTASCII_USTRINGPARAM("MS Excel 97")), + getURLFromSrc("/sc/qa/unit/data/xls/"), OUString()); #endif } @@ -221,23 +144,23 @@ void ScFiltersTest::testCVEs() void ScFiltersTest::testDir(osl::Directory& rDir, sal_uInt32 nType) { - 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); + OUString aFilterName(aFileFormats[nType].pFilterName, strlen(aFileFormats[nType].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFilterType(aFileFormats[nType].pTypeName, strlen(aFileFormats[nType].pTypeName), RTL_TEXTENCODING_UTF8); osl::DirectoryItem aItem; osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type); 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)); + OUString sURL = aFileStatus.getFileURL(); + std::cout << "File: " << OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; + //OStringBuffer aMessage("Failed loading: "); + //aMessage.append(OUStringToOString(sURL, RTL_TEXTENCODING_UTF8)); unsigned int nFormatType = aFileFormats[nType].nFormatType; unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; - ScDocShellRef xDocSh = load(aFilterName, sURL, rtl::OUString(), - aFilterType, nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); + ScDocShellRef xDocSh = load(sURL, aFilterName, OUString(), + aFilterType, nFormatType, nClipboardId ); // 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()); @@ -248,7 +171,7 @@ void ScFiltersTest::testDir(osl::Directory& rDir, sal_uInt32 nType) void ScFiltersTest::testBugFiles() { - rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugODS/"); + OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugODS/"); osl::Directory aDir(aDirName); CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open()); @@ -257,7 +180,7 @@ void ScFiltersTest::testBugFiles() void ScFiltersTest::testBugFilesXLS() { - rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLS/"); + OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLS/"); osl::Directory aDir(aDirName); CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open()); @@ -266,7 +189,7 @@ void ScFiltersTest::testBugFilesXLS() void ScFiltersTest::testBugFilesXLSX() { - rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLSX/"); + OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLSX/"); osl::Directory aDir(aDirName); CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open()); @@ -281,16 +204,16 @@ void testRangeNameImpl(ScDocument* pDoc) { //check one range data per sheet and one global more detailed //add some more checks here - ScRangeData* pRangeData = pDoc->GetRangeName()->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GLOBAL1"))); + ScRangeData* pRangeData = pDoc->GetRangeName()->findByUpperName(OUString(RTL_CONSTASCII_USTRINGPARAM("GLOBAL1"))); CPPUNIT_ASSERT_MESSAGE("range name Global1 not found", pRangeData); double aValue; pDoc->GetValue(1,0,0,aValue); CPPUNIT_ASSERT_MESSAGE("range name Global1 should reference Sheet1.A1", aValue == 1); - pRangeData = pDoc->GetRangeName(0)->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL1"))); + pRangeData = pDoc->GetRangeName(0)->findByUpperName(OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL1"))); CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 not found", pRangeData); pDoc->GetValue(1,2,0,aValue); CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 should reference Sheet1.A3", aValue == 3); - pRangeData = pDoc->GetRangeName(1)->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL2"))); + pRangeData = pDoc->GetRangeName(1)->findByUpperName(OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL2"))); CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 not found", pRangeData); //check for correct results for the remaining formulas pDoc->GetValue(1,1,0, aValue); @@ -303,21 +226,6 @@ void testRangeNameImpl(ScDocument* pDoc) } -ScDocShellRef ScFiltersTest::loadDoc(const rtl::OUString& rName, sal_Int32 nFormat) -{ - rtl::OUString aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; - createFileURL( rName, aFileExtension, aFileName ); - rtl::OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8); - unsigned int nFormatType = aFileFormats[nFormat].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(xDocSh.Is()); - return xDocSh; -} - void ScFiltersTest::testRangeNameODS() { ScDocShellRef xDocSh = loadDoc("named-ranges-global.", ODS); @@ -329,8 +237,8 @@ void ScFiltersTest::testRangeNameODS() ScDocument* pDoc = xDocSh->GetDocument(); testRangeNameImpl(pDoc); - rtl::OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("rangeExp_Sheet2.")); - rtl::OUString aCSVPath; + OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("rangeExp_Sheet2.")); + OUString aCSVPath; createCSVPath( aSheet2CSV, aCSVPath ); testFile( aCSVPath, pDoc, 1); xDocSh->DoClose(); @@ -349,9 +257,9 @@ void testContentImpl(ScDocument* pDoc, sal_Int32 nFormat ) //same code for ods, OUString aString = pDoc->GetString(1, 0, 0); //check string import - CPPUNIT_ASSERT_MESSAGE("string imported not correctly", aString == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("String1"))); + CPPUNIT_ASSERT_MESSAGE("string imported not correctly", aString == OUString(RTL_CONSTASCII_USTRINGPARAM("String1"))); aString = pDoc->GetString(1, 1, 0); - CPPUNIT_ASSERT_MESSAGE("string not imported correctly", aString == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("String2"))); + CPPUNIT_ASSERT_MESSAGE("string not imported correctly", aString == OUString(RTL_CONSTASCII_USTRINGPARAM("String2"))); //check basic formula import pDoc->GetValue(2,0,0,fValue); @@ -375,7 +283,7 @@ void testContentImpl(ScDocument* pDoc, sal_Int32 nFormat ) //same code for ods, ScAddress aAddress(7, 2, 0); ScPostIt* pNote = pDoc->GetNotes(aAddress.Tab())->findByAddress(aAddress); CPPUNIT_ASSERT_MESSAGE("note not imported", pNote); - CPPUNIT_ASSERT_EQUAL_MESSAGE("note text not imported correctly", pNote->GetText(), rtl::OUString("Test")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("note text not imported correctly", pNote->GetText(), OUString("Test")); } //add additional checks here @@ -425,7 +333,7 @@ void ScFiltersTest::testContentLotus123() } ScFiltersTest::ScFiltersTest() - : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data")) + : ScBootstrapFixture( "/sc/qa/unit/data" ) { } @@ -436,7 +344,7 @@ void ScFiltersTest::setUp() // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure, // which is a private symbol to us, gets called m_xCalcComponent = - getMultiServiceFactory()->createInstance(rtl::OUString( + getMultiServiceFactory()->createInstance(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.SpreadsheetDocument"))); CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is()); } diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index 32f7f7a59229..86a9080e70b0 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -36,17 +36,67 @@ #include #include +#include + #include +#include +#include +#include + +#define ODS_FORMAT_TYPE 50331943 +#define XLS_FORMAT_TYPE 318767171 +#define XLSX_FORMAT_TYPE 268959811 +#define LOTUS123_FORMAT_TYPE 268435649 +#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 +#define LOTUS123 5 + +struct FileFormat { + const char* pName; const char* pFilterName; const char* pTypeName; unsigned int nFormatType; +}; + +// data format for row height tests +struct TestParam +{ + struct RowData + { + SCROW nStartRow; + SCROW nEndRow; + SCTAB nTab; + int nExpectedHeight; + }; + const char* sTestDoc; + int nImportType; + int nExportType; + int nRowData; + RowData* pData; +}; + +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 }, + { "html" , "calc_HTML_WebQuery", "generic_HTML", HTML_FORMAT_TYPE }, + { "123" , "Lotus", "calc_Lotus", LOTUS123_FORMAT_TYPE }, +}; + // Why is this here and not in osl, and using the already existing file // handling APIs? Do we really want to add arbitrary new file handling // wrappers here and there (and then having to handle the Android (and // eventually perhaps iOS) special cases here, too)? Please move this to osl, // it sure looks gemerally useful. Or am I missing something? -void loadFile(const rtl::OUString& aFileName, std::string& aContent) +void loadFile(const OUString& aFileName, std::string& aContent) { - rtl::OString aOFileName = rtl::OUStringToOString(aFileName, RTL_TEXTENCODING_UTF8); + OString aOFileName = OUStringToOString(aFileName, RTL_TEXTENCODING_UTF8); #ifdef ANDROID const char *contents; @@ -62,7 +112,7 @@ void loadFile(const rtl::OUString& aFileName, std::string& aContent) std::ifstream aFile(aOFileName.getStr()); - rtl::OStringBuffer aErrorMsg("Could not open csv file: "); + OStringBuffer aErrorMsg("Could not open csv file: "); aErrorMsg.append(aOFileName); CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), aFile); std::ostringstream aOStream; @@ -71,7 +121,116 @@ void loadFile(const rtl::OUString& aFileName, std::string& aContent) aContent = aOStream.str(); } -void testFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab, StringType aStringFormat = StringValue) +class ScBootstrapFixture : public test::BootstrapFixture +{ +protected: + OUString m_aBaseString; + ScDocShellRef load( + const OUString& rURL, const OUString& rFilter, const OUString &rUserData, + const OUString& rTypeName, unsigned int nFilterFlags, unsigned int nClipboardID, sal_uIntPtr nFilterVersion = SOFFICE_FILEFORMAT_CURRENT, const OUString* pPassword = NULL ) + { + SfxFilter* pFilter = new SfxFilter( + rFilter, + OUString(), nFilterFlags, nClipboardID, rTypeName, 0, OUString(), + rUserData, OUString("private:factory/scalc*")); + pFilter->SetVersion(nFilterVersion); + + ScDocShellRef xDocShRef = new ScDocShell; + xDocShRef->GetDocument()->EnableUserInteraction(false); + SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ); + pSrcMed->SetFilter(pFilter); + pSrcMed->UseInteractionHandler(false); + if (pPassword) + { + SfxItemSet* pSet = pSrcMed->GetItemSet(); + pSet->Put(SfxStringItem(SID_PASSWORD, *pPassword)); + } + printf("about to load %s\n", rtl::OUStringToOString( rURL, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (!xDocShRef->DoLoad(pSrcMed)) + { + xDocShRef->DoClose(); + // load failed. + xDocShRef.Clear(); + } + + return xDocShRef; + } + + ScDocShellRef loadDoc(const OUString& rFileName, sal_Int32 nFormat) + { + OUString aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFileName; + createFileURL( rFileName, aFileExtension, aFileName ); + OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8); + unsigned int nFormatType = aFileFormats[nFormat].nFormatType; + unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; + + return load(aFileName, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, nFormatType); + } + + +public: + ScBootstrapFixture( const OUString& rsBaseString ) : m_aBaseString( rsBaseString ) {} + void createFileURL(const OUString& aFileBase, const OUString& aFileExtension, OUString& rFilePath) + { + OUString aSep(RTL_CONSTASCII_USTRINGPARAM("/")); + OUStringBuffer aBuffer( getSrcRootURL() ); + aBuffer.append(m_aBaseString).append(aSep).append(aFileExtension); + aBuffer.append(aSep).append(aFileBase).append(aFileExtension); + rFilePath = aBuffer.makeStringAndClear(); + } + + void createCSVPath(const OUString& aFileBase, OUString& rCSVPath) + { + OUStringBuffer aBuffer( getSrcRootPath()); + aBuffer.append(m_aBaseString).append(OUString("/contentCSV/")); + aBuffer.append(aFileBase).append(OUString("csv")); + rCSVPath = aBuffer.makeStringAndClear(); + } + + ScDocShellRef saveAndReload(ScDocShell* pShell, const OUString &rFilter, + const OUString &rUserData, const OUString& rTypeName, sal_uLong nFormatType) + { + + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + SfxMedium aStoreMedium( aTempFile.GetURL(), STREAM_STD_WRITE ); + sal_uInt32 nExportFormat = 0; + if (nFormatType == ODS_FORMAT_TYPE) + nExportFormat = SFX_FILTER_EXPORT | SFX_FILTER_USESOPTIONS; + SfxFilter* pExportFilter = new SfxFilter( + rFilter, + OUString(), nFormatType, nExportFormat, rTypeName, 0, OUString(), + rUserData, OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) ); + pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT); + aStoreMedium.SetFilter(pExportFilter); + pShell->DoSaveAs( aStoreMedium ); + pShell->DoClose(); + + //std::cout << "File: " << aTempFile.GetURL() << std::endl; + + sal_uInt32 nFormat = 0; + if (nFormatType == ODS_FORMAT_TYPE) + nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS; + + return load(aTempFile.GetURL(), rFilter, rUserData, rTypeName, nFormatType, nFormat ); + } + ScDocShellRef saveAndReload( ScDocShell* pShell, sal_Int32 nFormat ) + { + OUString aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8); + ScDocShellRef xDocSh = saveAndReload(pShell, aFilterName, OUString(), aFilterType, aFileFormats[nFormat].nFormatType); + + CPPUNIT_ASSERT(xDocSh.Is()); + return xDocSh; + } + + +}; + +void testFile(OUString& aFileName, ScDocument* pDoc, SCTAB nTab, StringType aStringFormat = StringValue) { csv_handler aHandler(pDoc, nTab, aStringFormat); orcus::csv_parser_config aConfig; @@ -91,14 +250,14 @@ void testFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab, StringType catch (const orcus::csv_parse_error& e) { std::cout << "reading csv content file failed: " << e.what() << std::endl; - rtl::OStringBuffer aErrorMsg("csv parser error: "); + OStringBuffer aErrorMsg("csv parser error: "); aErrorMsg.append(e.what()); CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), false); } } //need own handler because conditional formatting strings must be generated -void testCondFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab) +void testCondFile(OUString& aFileName, ScDocument* pDoc, SCTAB nTab) { conditional_format_handler aHandler(pDoc, nTab); orcus::csv_parser_config aConfig; @@ -115,7 +274,7 @@ void testCondFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab) catch (const orcus::csv_parse_error& e) { std::cout << "reading csv content file failed: " << e.what() << std::endl; - rtl::OStringBuffer aErrorMsg("csv parser error: "); + OStringBuffer aErrorMsg("csv parser error: "); aErrorMsg.append(e.what()); CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), false); } diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 3fd6427eb045..cb451325f323 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -14,14 +14,11 @@ #include #include -#include #include #include #include #include -#include -#include #define CALC_DEBUG_OUTPUT 0 #define TEST_BUG_FILES 0 @@ -35,35 +32,10 @@ #include "document.hxx" #include "cellform.hxx" -#define ODS_FORMAT_TYPE 50331943 -#define XLS_FORMAT_TYPE 318767171 -#define XLSX_FORMAT_TYPE 268959811 -#define LOTUS123_FORMAT_TYPE 268435649 - -#define ODS 0 -#define XLS 1 -#define XLSX 2 -#define LOTUS123 3 - using namespace ::com::sun::star; using namespace ::com::sun::star::uno; -namespace { - -struct FileFormat { - const char* pName; const char* pFilterName; const char* pTypeName; unsigned int nFormatType; -}; - -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 }, - { "123" , "Lotus", "calc_Lotus", LOTUS123_FORMAT_TYPE } -}; - -} - -class ScExportTest : public test::BootstrapFixture +class ScExportTest : public ScBootstrapFixture { public: ScExportTest(); @@ -71,8 +43,7 @@ public: virtual void setUp(); virtual void tearDown(); - ScDocShellRef saveAndReload( ScDocShell*, const rtl::OUString&, const rtl::OUString&, const rtl::OUString&, sal_uLong ); - ScDocShellRef saveAndReloadPassword( ScDocShell*, const rtl::OUString&, const rtl::OUString&, const rtl::OUString&, sal_uLong ); + ScDocShellRef saveAndReloadPassword( ScDocShell*, const OUString&, const OUString&, const OUString&, sal_uLong ); void test(); void testPasswordExport(); @@ -89,39 +60,12 @@ public: CPPUNIT_TEST_SUITE_END(); private: - rtl::OUString m_aBaseString; uno::Reference m_xCalcComponent; - ScDocShellRef load( - const OUString& rURL, const OUString& rFilter, const OUString &rUserData, - const OUString& rTypeName, sal_Int32 nFormat, sal_uLong nFormatType, - const OUString* pPassword = NULL ); - - ScDocShellRef saveAndReload( ScDocShell* pShell, sal_Int32 nFormat ); - ScDocShellRef loadDocument( const rtl::OUString& rFileNameBase, sal_Int32 nFormat ); - void createFileURL( const rtl::OUString& aFileBase, const rtl::OUString& rFileExtension, rtl::OUString& rFilePath); - void createCSVPath(const rtl::OUString& rFileBase, rtl::OUString& rCSVPath); }; -void ScExportTest::createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath) -{ - rtl::OUString aSep("/"); - rtl::OUStringBuffer aBuffer( getSrcRootURL() ); - aBuffer.append(m_aBaseString).append(aSep).append(aFileExtension); - aBuffer.append(aSep).append(aFileBase).append(aFileExtension); - rFilePath = aBuffer.makeStringAndClear(); -} - -void ScExportTest::createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rCSVPath) -{ - rtl::OUStringBuffer aBuffer(getSrcRootPath()); - aBuffer.append(m_aBaseString).append(rtl::OUString("/contentCSV/")); - aBuffer.append(aFileBase).append(rtl::OUString("csv")); - rCSVPath = aBuffer.makeStringAndClear(); -} - -ScDocShellRef ScExportTest::saveAndReloadPassword(ScDocShell* pShell, const rtl::OUString &rFilter, - const rtl::OUString &rUserData, const rtl::OUString& rTypeName, sal_uLong nFormatType) +ScDocShellRef ScExportTest::saveAndReloadPassword(ScDocShell* pShell, const OUString &rFilter, + const OUString &rUserData, const OUString& rTypeName, sal_uLong nFormatType) { utl::TempFile aTempFile; aTempFile.EnableKillingFile(); @@ -131,12 +75,12 @@ ScDocShellRef ScExportTest::saveAndReloadPassword(ScDocShell* pShell, const rtl: nExportFormat = SFX_FILTER_EXPORT | SFX_FILTER_USESOPTIONS; SfxFilter* pExportFilter = new SfxFilter( rFilter, - rtl::OUString(), nFormatType, nExportFormat, rTypeName, 0, rtl::OUString(), - rUserData, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) ); + OUString(), nFormatType, nExportFormat, rTypeName, 0, OUString(), + rUserData, OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) ); pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT); aStoreMedium.SetFilter(pExportFilter); SfxItemSet* pExportSet = aStoreMedium.GetItemSet(); - uno::Sequence< beans::NamedValue > aEncryptionData = comphelper::OStorageHelper::CreatePackageEncryptionData( rtl::OUString("test") ); + uno::Sequence< beans::NamedValue > aEncryptionData = comphelper::OStorageHelper::CreatePackageEncryptionData( OUString("test") ); uno::Any xEncryptionData; xEncryptionData <<= aEncryptionData; pExportSet->Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, xEncryptionData)); @@ -154,89 +98,7 @@ ScDocShellRef ScExportTest::saveAndReloadPassword(ScDocShell* pShell, const rtl: nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS; OUString aPass("test"); - return load(aTempFile.GetURL(), rFilter, rUserData, rTypeName, nFormat, nFormatType, &aPass); -} - -ScDocShellRef ScExportTest::saveAndReload(ScDocShell* pShell, const rtl::OUString &rFilter, - const rtl::OUString &rUserData, const rtl::OUString& rTypeName, sal_uLong nFormatType) -{ - - utl::TempFile aTempFile; - aTempFile.EnableKillingFile(); - SfxMedium aStoreMedium( aTempFile.GetURL(), STREAM_STD_WRITE ); - sal_uInt32 nExportFormat = 0; - if (nFormatType == ODS_FORMAT_TYPE) - nExportFormat = SFX_FILTER_EXPORT | SFX_FILTER_USESOPTIONS; - SfxFilter* pExportFilter = new SfxFilter( - rFilter, - rtl::OUString(), nFormatType, nExportFormat, rTypeName, 0, rtl::OUString(), - rUserData, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) ); - pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT); - aStoreMedium.SetFilter(pExportFilter); - pShell->DoSaveAs( aStoreMedium ); - pShell->DoClose(); - - //std::cout << "File: " << aTempFile.GetURL() << std::endl; - - sal_uInt32 nFormat = 0; - if (nFormatType == ODS_FORMAT_TYPE) - nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS; - - return load(aTempFile.GetURL(), rFilter, rUserData, rTypeName, nFormat, nFormatType); -} - -ScDocShellRef ScExportTest::load( - const OUString& rURL, const OUString& rFilter, const OUString &rUserData, - const OUString& rTypeName, sal_Int32 nFormat, sal_uLong nFormatType, const OUString* pPassword ) -{ - SfxFilter* pFilter = new SfxFilter( - rFilter, - rtl::OUString(), nFormatType, nFormat, rTypeName, 0, rtl::OUString(), - rUserData, OUString("private:factory/scalc*")); - pFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT); - - ScDocShellRef xDocShRef = new ScDocShell; - xDocShRef->GetDocument()->EnableUserInteraction(false); - SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ); - pSrcMed->SetFilter(pFilter); - pSrcMed->UseInteractionHandler(false); - if (pPassword) - { - SfxItemSet* pSet = pSrcMed->GetItemSet(); - pSet->Put(SfxStringItem(SID_PASSWORD, *pPassword)); - } - if (!xDocShRef->DoLoad(pSrcMed)) - { - xDocShRef->DoClose(); - // load failed. - xDocShRef.Clear(); - } - - return xDocShRef; -} - -ScDocShellRef ScExportTest::saveAndReload( ScDocShell* pShell, sal_Int32 nFormat ) -{ - rtl::OUString aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8); - ScDocShellRef xDocSh = saveAndReload(pShell, aFilterName, rtl::OUString(), aFilterType, aFileFormats[nFormat].nFormatType); - - CPPUNIT_ASSERT(xDocSh.Is()); - return xDocSh; -} - -ScDocShellRef ScExportTest::loadDocument(const rtl::OUString& rFileName, sal_Int32 nFormat) -{ - rtl::OUString aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; - createFileURL( rFileName, aFileExtension, aFileName ); - rtl::OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8); - unsigned int nFormatType = aFileFormats[nFormat].nFormatType; - unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; - - return load(aFileName, aFilterName, OUString(), aFilterType, nClipboardId, nFormatType); + return load(aTempFile.GetURL(), rFilter, rUserData, rTypeName, nFormatType, nFormat, SOFFICE_FILEFORMAT_CURRENT, &aPass); } void ScExportTest::test() @@ -274,10 +136,10 @@ void ScExportTest::testPasswordExport() CPPUNIT_ASSERT(pDoc); sal_Int32 nFormat = ODS; - rtl::OUString aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8); - ScDocShellRef xDocSh = saveAndReloadPassword(pShell, aFilterName, rtl::OUString(), aFilterType, aFileFormats[nFormat].nFormatType); + OUString aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8); + ScDocShellRef xDocSh = saveAndReloadPassword(pShell, aFilterName, OUString(), aFilterType, aFileFormats[nFormat].nFormatType); CPPUNIT_ASSERT(xDocSh.Is()); ScDocument* pLoadedDoc = xDocSh->GetDocument(); @@ -287,37 +149,20 @@ void ScExportTest::testPasswordExport() void ScExportTest::testConditionalFormatExportXLSX() { - ScDocShellRef xShell = loadDocument("new_cond_format_test.", XLSX); + ScDocShellRef xShell = loadDoc("new_cond_format_test.", XLSX); CPPUNIT_ASSERT(xShell.Is()); ScDocShellRef xDocSh = saveAndReload(&(*xShell), XLSX); CPPUNIT_ASSERT(xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUString aCSVFile("new_cond_format_test."); - rtl::OUString aCSVPath; + OUString aCSVFile("new_cond_format_test."); + OUString aCSVPath; createCSVPath( aCSVFile, aCSVPath ); testCondFile(aCSVPath, pDoc, 0); } void ScExportTest::testMiscRowHeightExport() { - - struct TestParam - { - struct RowData - { - SCROW nStartRow; - SCROW nEndRow; - SCTAB nTab; - int nExpectedHeight; - }; - const char* sTestDoc; - int nImportType; - int nExportType; - int nRowData; - RowData* pData; - }; - TestParam::RowData DfltRowData[] = { { 0, 4, 0, 529 }, @@ -347,13 +192,13 @@ void ScExportTest::testMiscRowHeightExport() printf("aTestValues[%d] %s\n", index, OUStringToOString( sFileName, RTL_TEXTENCODING_UTF8 ).getStr() ); int nImportType = aTestValues[ index ].nImportType; int nExportType = aTestValues[ index ].nExportType; - ScDocShellRef xShell = loadDocument( sFileName, nImportType ); + ScDocShellRef xShell = loadDoc( sFileName, nImportType ); CPPUNIT_ASSERT(xShell.Is()); - ScDocShellRef xDocSh = saveAndReload(&(*xShell), nExportType ); - CPPUNIT_ASSERT(xDocSh.Is()); + xShell = saveAndReload(&(*xShell), nExportType ); + CPPUNIT_ASSERT(xShell.Is()); - ScDocument* pDoc = xDocSh->GetDocument(); + ScDocument* pDoc = xShell->GetDocument(); for (int i=0; icreateInstance(rtl::OUString( + getMultiServiceFactory()->createInstance(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.SpreadsheetDocument"))); CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is()); } diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 1e823b168f68..c57fbcf56959 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -73,57 +73,22 @@ #include "helper/qahelper.hxx" -#define ODS_FORMAT_TYPE 50331943 -#define XLS_FORMAT_TYPE 318767171 -#define XLSX_FORMAT_TYPE 268959811 -#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; -namespace { - -struct FileFormat { - const char* pName; const char* pFilterName; const char* pTypeName; unsigned int nFormatType; -}; - -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 }, - { "html" , "calc_HTML_WebQuery", "generic_HTML", HTML_FORMAT_TYPE } -}; - -} - /* Implementation of Filters test */ class ScFiltersTest : public test::FiltersTest - , public test::BootstrapFixture + , public ScBootstrapFixture { public: ScFiltersTest(); - virtual bool load( const rtl::OUString &rFilter, const rtl::OUString &rURL, - const rtl::OUString &rUserData, unsigned int nFilterFlags, + virtual bool load( const OUString &rFilter, const OUString &rURL, + const OUString &rUserData, unsigned int nFilterFlags, unsigned int nClipboardID, unsigned int nFilterVersion); - ScDocShellRef load(const rtl::OUString &rFilter, const rtl::OUString &rURL, - const rtl::OUString &rUserData, const rtl::OUString& rTypeName, - unsigned int nFilterFlags, unsigned int nClipboardID, unsigned int nFilterVersion); - - void createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath); - void createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rFilePath); - virtual void setUp(); virtual void tearDown(); @@ -241,60 +206,17 @@ public: CPPUNIT_TEST_SUITE_END(); private: - void testPassword_Impl(const rtl::OUString& rFileNameBase); - ScDocShellRef loadDoc(const rtl::OUString& rBaseName, size_t nExt); + void testPassword_Impl(const OUString& rFileNameBase); uno::Reference m_xCalcComponent; - ::rtl::OUString m_aBaseString; }; -ScDocShellRef ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL, - const rtl::OUString &rUserData, const rtl::OUString& rTypeName, - unsigned int nFilterFlags, unsigned int nClipboardID, unsigned int nFilterVersion) -{ - SfxFilter* pFilter = new SfxFilter( - rFilter, - rtl::OUString(), nFilterFlags, nClipboardID, rTypeName, 0, rtl::OUString(), - rUserData, rtl::OUString("private:factory/scalc*") ); - pFilter->SetVersion(nFilterVersion); - - ScDocShellRef xDocShRef = new ScDocShell; - xDocShRef->GetDocument()->EnableUserInteraction(false); - SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ); - pSrcMed->UseInteractionHandler(false); - pSrcMed->SetFilter(pFilter); - if (!xDocShRef->DoLoad(pSrcMed)) - { - xDocShRef->DoClose(); - // load failed. - xDocShRef.Clear(); - } - - return xDocShRef; -} - -ScDocShellRef ScFiltersTest::loadDoc(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; - ScDocShellRef xDocSh = load(aFilterName, aFileName, OUString(), aFilterType, nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); - CPPUNIT_ASSERT(xDocSh.Is()); - return xDocSh; -} - -bool ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL, - const rtl::OUString &rUserData, unsigned int nFilterFlags, +bool ScFiltersTest::load(const OUString &rFilter, const OUString &rURL, + const OUString &rUserData, unsigned int nFilterFlags, unsigned int nClipboardID, unsigned int nFilterVersion) { - ScDocShellRef xDocShRef = load(rFilter, rURL, rUserData, - rtl::OUString(), nFilterFlags, nClipboardID, nFilterVersion); + ScDocShellRef xDocShRef = ScBootstrapFixture::load( rURL, rFilter, rUserData, + OUString(), nFilterFlags, nClipboardID, nFilterVersion); bool bLoaded = xDocShRef.Is(); //reference counting of ScDocShellRef is very confused. if (bLoaded) @@ -302,22 +224,6 @@ bool ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL return bLoaded; } -void ScFiltersTest::createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath) -{ - rtl::OUString aSep(RTL_CONSTASCII_USTRINGPARAM("/")); - rtl::OUStringBuffer aBuffer( getSrcRootURL() ); - aBuffer.append(m_aBaseString).append(aSep).append(aFileExtension); - aBuffer.append(aSep).append(aFileBase).append(aFileExtension); - rFilePath = aBuffer.makeStringAndClear(); -} - -void ScFiltersTest::createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rCSVPath) -{ - rtl::OUStringBuffer aBuffer(getSrcRootPath()); - aBuffer.append(m_aBaseString).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/contentCSV/"))); - aBuffer.append(aFileBase).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("csv"))); - rCSVPath = aBuffer.makeStringAndClear(); -} namespace { @@ -325,16 +231,16 @@ void testRangeNameImpl(ScDocument* pDoc) { //check one range data per sheet and one global more detailed //add some more checks here - ScRangeData* pRangeData = pDoc->GetRangeName()->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GLOBAL1"))); + ScRangeData* pRangeData = pDoc->GetRangeName()->findByUpperName(OUString(RTL_CONSTASCII_USTRINGPARAM("GLOBAL1"))); CPPUNIT_ASSERT_MESSAGE("range name Global1 not found", pRangeData); double aValue; pDoc->GetValue(1,0,0,aValue); CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Global1 should reference Sheet1.A1", 1.0, aValue); - pRangeData = pDoc->GetRangeName(0)->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL1"))); + pRangeData = pDoc->GetRangeName(0)->findByUpperName(OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL1"))); CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 not found", pRangeData); pDoc->GetValue(1,2,0,aValue); CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Sheet1.Local1 should reference Sheet1.A3", 3.0, aValue); - pRangeData = pDoc->GetRangeName(1)->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL2"))); + pRangeData = pDoc->GetRangeName(1)->findByUpperName(OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL2"))); CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 not found", pRangeData); pDoc->GetValue(1,1,1,aValue); CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Sheet2.Local2 should reference Sheet2.A2", 7.0, aValue); @@ -362,8 +268,8 @@ void ScFiltersTest::testRangeNameXLS() ScDocument* pDoc = xDocSh->GetDocument(); testRangeNameImpl(pDoc); - rtl::OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("rangeExp_Sheet2.")); - rtl::OUString aCSVPath; + OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("rangeExp_Sheet2.")); + OUString aCSVPath; createCSVPath( aSheet2CSV, aCSVPath ); // fdo#44587 testFile( aCSVPath, pDoc, 1); @@ -389,11 +295,11 @@ void ScFiltersTest::testHardRecalcODS() CPPUNIT_ASSERT_MESSAGE("Failed to load hard-recalc.*", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUString aCSVFileName; + OUString aCSVFileName; //test hard recalc: document has an incorrect cached formula result //hard recalc should have updated to the correct result - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("hard-recalc.")), aCSVFileName); + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("hard-recalc.")), aCSVFileName); testFile(aCSVFileName, pDoc, 0); xDocSh->DoClose(); @@ -406,19 +312,19 @@ void ScFiltersTest::testFunctionsODS() CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUString aCSVFileName; + OUString aCSVFileName; //test logical functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("logical-functions.")), aCSVFileName); + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("logical-functions.")), aCSVFileName); testFile(aCSVFileName, pDoc, 0); //test spreadsheet functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("spreadsheet-functions.")), aCSVFileName); + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("spreadsheet-functions.")), aCSVFileName); testFile(aCSVFileName, pDoc, 1); //test mathematical functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mathematical-functions.")), aCSVFileName); + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("mathematical-functions.")), aCSVFileName); testFile(aCSVFileName, pDoc, 2, PureString); //test informations functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("information-functions.")), aCSVFileName); + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("information-functions.")), aCSVFileName); testFile(aCSVFileName, pDoc, 3); xDocSh->DoClose(); @@ -431,19 +337,19 @@ void ScFiltersTest::testCachedFormulaResultsODS() CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUString aCSVFileName; + OUString aCSVFileName; //test cached formula results of logical functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("logical-functions.")), aCSVFileName); + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("logical-functions.")), aCSVFileName); testFile(aCSVFileName, pDoc, 0); //test cached formula results of spreadsheet functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("spreadsheet-functions.")), aCSVFileName); + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("spreadsheet-functions.")), aCSVFileName); testFile(aCSVFileName, pDoc, 1); //test cached formula results of mathematical functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mathematical-functions.")), aCSVFileName); + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("mathematical-functions.")), aCSVFileName); testFile(aCSVFileName, pDoc, 2, PureString); //test cached formula results of informations functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("information-functions.")), aCSVFileName); + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("information-functions.")), aCSVFileName); testFile(aCSVFileName, pDoc, 3); xDocSh->DoClose(); @@ -454,7 +360,7 @@ void ScFiltersTest::testCachedFormulaResultsODS() CPPUNIT_ASSERT_MESSAGE("Failed to load cachedValue.*", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUString aCSVFileName; + OUString aCSVFileName; createCSVPath("cachedValue.", aCSVFileName); testFile(aCSVFileName, pDoc, 0); @@ -502,7 +408,7 @@ void ScFiltersTest::testCachedMatrixFormulaResultsODS() ScDocument* pDoc = xDocSh->GetDocument(); //test matrix - rtl::OUString aCSVFileName; + OUString aCSVFileName; createCSVPath("matrix.", aCSVFileName); testFile(aCSVFileName, pDoc, 0); //test matrices with special cases @@ -554,14 +460,14 @@ void testDBRanges_Impl(ScDocument* pDoc, sal_Int32 nFormat) { double aValue; pDoc->GetValue(0,10,1, aValue); - rtl::OUString aString; + OUString aString; CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: A11: formula result is incorrect", 4.0, aValue); pDoc->GetValue(1, 10, 1, aValue); CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: B11: formula result is incorrect", 2.0, aValue); } double aValue; pDoc->GetValue(3,10,1, aValue); - rtl::OUString aString; + OUString aString; CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: D11: formula result is incorrect", 4.0, aValue); pDoc->GetValue(4, 10, 1, aValue); CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: E11: formula result is incorrect", 2.0, aValue); @@ -608,8 +514,8 @@ namespace { void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 nFormat) { //test Sheet1 with csv file - rtl::OUString aCSVFileName; - pFiltersTest->createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("numberFormat.")), aCSVFileName); + OUString aCSVFileName; + pFiltersTest->createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("numberFormat.")), aCSVFileName); testFile(aCSVFileName, pDoc, 0, PureString); //need to test the color of B3 //it's not a font color! @@ -657,7 +563,7 @@ void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 n CPPUNIT_ASSERT_EQUAL( static_cast(4153), pDoc->GetColWidth(6,1) ); //2.8839in //test case for i53253 where a cell has text with different styles and space between the text. OUString aTestStr = pDoc->GetString(3,0,1); - rtl::OUString aKnownGoodStr("text14 space"); + OUString aKnownGoodStr("text14 space"); CPPUNIT_ASSERT_EQUAL( aKnownGoodStr, aTestStr ); //test case for cell text with line breaks. aTestStr = pDoc->GetString(3,5,1); @@ -681,8 +587,8 @@ void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 n //test Sheet3 only for ods if ( nFormat == ODS || nFormat == XLSX ) { - rtl::OUString aCondString = getConditionalFormatString(pDoc, 3,0,2); - pFiltersTest->createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("conditionalFormatting.")), aCSVFileName); + OUString aCondString = getConditionalFormatString(pDoc, 3,0,2); + pFiltersTest->createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("conditionalFormatting.")), aCSVFileName); testCondFile(aCSVFileName, pDoc, 2); // test parent cell style import ( fdo#55198 ) if ( nFormat == XLSX ) @@ -690,8 +596,8 @@ void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 n pPattern = pDoc->GetPattern(1,1,3); ScStyleSheet* pStyleSheet = (ScStyleSheet*)pPattern->GetStyleSheet(); // check parent style name - rtl::OUString sExpected("Excel Built-in Date"); - rtl::OUString sResult = pStyleSheet->GetName(); + OUString sExpected("Excel Built-in Date"); + OUString sResult = pStyleSheet->GetName(); CPPUNIT_ASSERT_EQUAL_MESSAGE("parent style for Sheet4.B2 is 'Excel Built-in Date'", sExpected, sResult); // check align of style SfxItemSet& rItemSet = pStyleSheet->GetItemSet(); @@ -699,7 +605,7 @@ void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 n CPPUNIT_ASSERT_EQUAL_MESSAGE("'Excel Built-in Date' style should be aligned centre horizontally", SVX_HOR_JUSTIFY_CENTER, eHorJustify); // check date format ( should be just month e.g. 29 ) sResult =pDoc->GetString( 1,1,3 ); - sExpected = rtl::OUString("29"); + sExpected = OUString("29"); CPPUNIT_ASSERT_EQUAL_MESSAGE("'Excel Built-in Date' style should just display month", sExpected, sResult ); // check actual align applied to cell, should be the same as @@ -764,8 +670,8 @@ void ScFiltersTest::testMatrixODS() ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUString aCSVFileName; - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("matrix.")), aCSVFileName); + OUString aCSVFileName; + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("matrix.")), aCSVFileName); testFile(aCSVFileName, pDoc, 0); xDocSh->DoClose(); @@ -779,8 +685,8 @@ void ScFiltersTest::testMatrixXLS() CPPUNIT_ASSERT_MESSAGE("Failed to load matrix.*", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUString aCSVFileName; - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("matrix.")), aCSVFileName); + OUString aCSVFileName; + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("matrix.")), aCSVFileName); testFile(aCSVFileName, pDoc, 0); xDocSh->DoClose(); @@ -975,8 +881,8 @@ void ScFiltersTest::testBugFixesODS() { // fdo - rtl::OUString aCSVFileName; - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bugFix_Sheet2.")), aCSVFileName); + OUString aCSVFileName; + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("bugFix_Sheet2.")), aCSVFileName); testFile(aCSVFileName, pDoc, 1); } @@ -1025,10 +931,10 @@ void checkMergedCells( ScDocument* pDoc, const ScAddress& rStartAddress, SCROW nActualEndRow = rStartAddress.Row(); pDoc->ExtendMerge( rStartAddress.Col(), rStartAddress.Row(), nActualEndCol, nActualEndRow, rStartAddress.Tab(), false ); - rtl::OString sTab = rtl::OString::valueOf( static_cast(rStartAddress.Tab() + 1) ); - rtl::OString msg = "Merged cells are not correctly imported on sheet" + sTab; - rtl::OString msgCol = msg + "; end col"; - rtl::OString msgRow = msg + "; end row"; + OString sTab = OString::valueOf( static_cast(rStartAddress.Tab() + 1) ); + OString msg = "Merged cells are not correctly imported on sheet" + sTab; + OString msgCol = msg + "; end col"; + OString msgRow = msg + "; end row"; CPPUNIT_ASSERT_EQUAL_MESSAGE( msgCol.pData->buffer, rExpectedEndAddress.Col(), nActualEndCol ); CPPUNIT_ASSERT_EQUAL_MESSAGE( msgRow.pData->buffer, rExpectedEndAddress.Row(), nActualEndRow ); } @@ -1041,8 +947,8 @@ void ScFiltersTest::testMergedCellsODS() ScDocument* pDoc = xDocSh->GetDocument(); //check sheet1 content - rtl::OUString aCSVFileName1; - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("merged1.")), aCSVFileName1); + OUString aCSVFileName1; + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("merged1.")), aCSVFileName1); testFile(aCSVFileName1, pDoc, 0); //check sheet1 merged cells @@ -1051,8 +957,8 @@ void ScFiltersTest::testMergedCellsODS() checkMergedCells( pDoc, ScAddress( 3, 15, 0 ), ScAddress( 7, 23, 0 ) ); //check sheet2 content - rtl::OUString aCSVFileName2; - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("merged2.")), aCSVFileName2); + OUString aCSVFileName2; + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("merged2.")), aCSVFileName2); testFile(aCSVFileName2, pDoc, 1); //check sheet2 merged cells @@ -1067,13 +973,13 @@ void ScFiltersTest::testRepeatedColumnsODS() ScDocument* pDoc = xDocSh->GetDocument(); //text - rtl::OUString aCSVFileName1; - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("repeatedColumns1.")), aCSVFileName1); + OUString aCSVFileName1; + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("repeatedColumns1.")), aCSVFileName1); testFile(aCSVFileName1, pDoc, 0); //numbers - rtl::OUString aCSVFileName2; - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("repeatedColumns2.")), aCSVFileName2); + OUString aCSVFileName2; + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("repeatedColumns2.")), aCSVFileName2); testFile(aCSVFileName2, pDoc, 1); xDocSh->DoClose(); @@ -1125,7 +1031,7 @@ void checkValiditationEntries( const ValDataTestParams& rVDTParams ) sal_Int32 nCol( static_cast(rVDTParams.aPosition.Col()) ); sal_Int32 nRow( static_cast(rVDTParams.aPosition.Row()) ); sal_Int32 nTab( static_cast(rVDTParams.aPosition.Tab()) ); - rtl::OStringBuffer sMsg("Data Validation Entry with base-cell-address: ("); + OStringBuffer sMsg("Data Validation Entry with base-cell-address: ("); sMsg.append(nCol).append(",").append(nRow).append(",").append(nTab).append(") was not imported correctly."); //check if expected and actual data validation entries are equal CPPUNIT_ASSERT_MESSAGE( sMsg.getStr(), pValDataTest && aValData.EqualEntries(*pValDataTest) ); @@ -1153,7 +1059,7 @@ void checkCellValidity( const ScAddress& rValBaseAddr, const ScRange& rRange, co sal_Int32 nCol = static_cast(i); sal_Int32 nRow = static_cast(j); sal_Int32 nTab32 = static_cast(nTab); - rtl::OStringBuffer sMsg("\nData validation entry base-cell-address: ("); + OStringBuffer sMsg("\nData validation entry base-cell-address: ("); sMsg.append( static_cast(nBCol) ).append(","); sMsg.append( static_cast(nBRow) ).append(","); sMsg.append( nTab32 ).append(")\n"); @@ -1205,12 +1111,12 @@ void ScFiltersTest::testDataValidityODS() checkCellValidity( aValBaseAddr2, aRange2, pDoc ); //check each sheet's content - rtl::OUString aCSVFileName1; - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("dataValidity1.")), aCSVFileName1); + OUString aCSVFileName1; + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("dataValidity1.")), aCSVFileName1); testFile(aCSVFileName1, pDoc, 0); - rtl::OUString aCSVFileName2; - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("dataValidity2.")), aCSVFileName2); + OUString aCSVFileName2; + createCSVPath(OUString(RTL_CONSTASCII_USTRINGPARAM("dataValidity2.")), aCSVFileName2); testFile(aCSVFileName2, pDoc, 1); xDocSh->DoClose(); @@ -1218,25 +1124,25 @@ void ScFiltersTest::testDataValidityODS() void ScFiltersTest::testBrokenQuotesCSV() { - const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("fdo48621_broken_quotes.")); - rtl::OUString aFileExtension(aFileFormats[CSV].pName, strlen(aFileFormats[CSV].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[CSV].pFilterName, strlen(aFileFormats[CSV].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; + const OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("fdo48621_broken_quotes.")); + OUString aFileExtension(aFileFormats[CSV].pName, strlen(aFileFormats[CSV].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[CSV].pFilterName, strlen(aFileFormats[CSV].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFileName; createFileURL(aFileNameBase, aFileExtension, aFileName); - rtl::OUString aFilterType(aFileFormats[CSV].pTypeName, strlen(aFileFormats[CSV].pTypeName), RTL_TEXTENCODING_UTF8); + OUString aFilterType(aFileFormats[CSV].pTypeName, strlen(aFileFormats[CSV].pTypeName), RTL_TEXTENCODING_UTF8); std::cout << aFileFormats[CSV].pName << " Test" << std::endl; 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, + ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); CPPUNIT_ASSERT_MESSAGE("Failed to load fdo48621_broken_quotes.csv", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test - rtl::OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("fdo48621_broken_quotes_exported.")); - rtl::OUString aCSVPath; + OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("fdo48621_broken_quotes_exported.")); + OUString aCSVPath; createCSVPath( aSheet2CSV, aCSVPath ); // fdo#48621 testFile( aCSVPath, pDoc, 0, PureString); @@ -1246,17 +1152,17 @@ void ScFiltersTest::testBrokenQuotesCSV() void ScFiltersTest::testSharedFormulaXLSX() { - const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("shared-formula.")); - rtl::OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; + const OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("shared-formula.")); + OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFileName; createFileURL(aFileNameBase, aFileExtension, aFileName); - rtl::OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8); + OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8); std::cout << aFileFormats[XLSX].pName << " Test" << std::endl; unsigned int nFormatType = aFileFormats[XLSX].nFormatType; unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; - ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType, + ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); xDocSh->DoHardRecalc(true); @@ -1265,7 +1171,7 @@ void ScFiltersTest::testSharedFormulaXLSX() ScDocument* pDoc = xDocSh->GetDocument(); CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test - rtl::OUString aCSVPath; + OUString aCSVPath; createCSVPath( aFileNameBase, aCSVPath ); testFile( aCSVPath, pDoc, 0 ); @@ -1281,49 +1187,49 @@ void ScFiltersTest::testSharedFormulaXLSX() void ScFiltersTest::testCellValueXLSX() { - const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("cell-value.")); - rtl::OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; + const OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("cell-value.")); + OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFileName; createFileURL(aFileNameBase, aFileExtension, aFileName); - rtl::OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8); + OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8); std::cout << aFileFormats[XLSX].pName << " Test" << std::endl; unsigned int nFormatType = aFileFormats[XLSX].nFormatType; unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; - ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType, + ScDocShellRef xDocSh = ScBootstrapFixture::load( aFileName, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); CPPUNIT_ASSERT_MESSAGE("Failed to load cell-value.xlsx", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test - rtl::OUString aCSVPath; + OUString aCSVPath; createCSVPath( aFileNameBase, aCSVPath ); testFile( aCSVPath, pDoc, 0 ); xDocSh->DoClose(); } -void ScFiltersTest::testPassword_Impl(const rtl::OUString& aFileNameBase) +void ScFiltersTest::testPassword_Impl(const OUString& aFileNameBase) { - rtl::OUString aFileExtension(aFileFormats[0].pName, strlen(aFileFormats[0].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[0].pFilterName, strlen(aFileFormats[0].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; + OUString aFileExtension(aFileFormats[0].pName, strlen(aFileFormats[0].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[0].pFilterName, strlen(aFileFormats[0].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFileName; createFileURL(aFileNameBase, aFileExtension, aFileName); - rtl::OUString aFilterType(aFileFormats[0].pTypeName, strlen(aFileFormats[0].pTypeName), RTL_TEXTENCODING_UTF8); + OUString aFilterType(aFileFormats[0].pTypeName, strlen(aFileFormats[0].pTypeName), RTL_TEXTENCODING_UTF8); sal_uInt32 nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS; SfxFilter* aFilter = new SfxFilter( aFilterName, - rtl::OUString(), aFileFormats[0].nFormatType, nFormat, aFilterType, 0, rtl::OUString(), - rtl::OUString(), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) ); + OUString(), aFileFormats[0].nFormatType, nFormat, aFilterType, 0, OUString(), + OUString(), OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) ); aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT); ScDocShellRef xDocSh = new ScDocShell; SfxMedium* pMedium = new SfxMedium(aFileName, STREAM_STD_READWRITE); SfxItemSet* pSet = pMedium->GetItemSet(); - pSet->Put(SfxStringItem(SID_PASSWORD, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test")))); + pSet->Put(SfxStringItem(SID_PASSWORD, OUString(RTL_CONSTASCII_USTRINGPARAM("test")))); pMedium->SetFilter(aFilter); if (!xDocSh->DoLoad(pMedium)) { @@ -1342,14 +1248,14 @@ void ScFiltersTest::testPassword_Impl(const rtl::OUString& aFileNameBase) void ScFiltersTest::testPasswordNew() { //tests opening a file with new password algorithm - const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("password.")); + const OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("password.")); testPassword_Impl(aFileNameBase); } void ScFiltersTest::testPasswordOld() { //tests opening a file with old password algorithm - const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("passwordOld.")); + const OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("passwordOld.")); testPassword_Impl(aFileNameBase); } @@ -1796,45 +1702,45 @@ void ScFiltersTest::testRichTextContentODS() namespace { -void testColorScaleFormat_Impl(const rtl::OUString& rFilePath, const ScConditionalFormat* pFormat) +void testColorScaleFormat_Impl(const OUString& rFilePath, const ScConditionalFormat* pFormat) { - rtl::OUStringBuffer aBuf; + OUStringBuffer aBuf; CPPUNIT_ASSERT(pFormat); pFormat->dumpInfo(aBuf); - rtl::OUString aString = aBuf.makeStringAndClear(); + OUString aString = aBuf.makeStringAndClear(); std::string aStdString; loadFile(rFilePath, aStdString); - rtl::OUString aRefString = rtl::OUString::createFromAscii(aStdString.c_str()); + OUString aRefString = OUString::createFromAscii(aStdString.c_str()); CPPUNIT_ASSERT_EQUAL(aRefString, aString); } -void testColorScale_Impl(ScDocument* pDoc, const rtl::OUString& aBaseString) +void testColorScale_Impl(ScDocument* pDoc, const OUString& aBaseString) { // first color scale { const ScConditionalFormat* pFormat = pDoc->GetCondFormat(1,1,0); - rtl::OUString aFilePath = aBaseString + rtl::OUString("colorScale_1.txt"); + OUString aFilePath = aBaseString + OUString("colorScale_1.txt"); testColorScaleFormat_Impl(aFilePath, pFormat); } // second cond format { const ScConditionalFormat* pFormat = pDoc->GetCondFormat(4,1,0); - rtl::OUString aFilePath = aBaseString + rtl::OUString("colorScale_2.txt"); + OUString aFilePath = aBaseString + OUString("colorScale_2.txt"); testColorScaleFormat_Impl(aFilePath, pFormat); } // third cond format { const ScConditionalFormat* pFormat = pDoc->GetCondFormat(7,1,0); - rtl::OUString aFilePath = aBaseString + rtl::OUString("colorScale_3.txt"); + OUString aFilePath = aBaseString + OUString("colorScale_3.txt"); testColorScaleFormat_Impl(aFilePath, pFormat); } // forth cond format { const ScConditionalFormat* pFormat = pDoc->GetCondFormat(10,1,0); - rtl::OUString aFilePath = aBaseString + rtl::OUString("colorScale_4.txt"); + OUString aFilePath = aBaseString + OUString("colorScale_4.txt"); testColorScaleFormat_Impl(aFilePath, pFormat); } } @@ -1843,25 +1749,25 @@ void testColorScale_Impl(ScDocument* pDoc, const rtl::OUString& aBaseString) void ScFiltersTest::testColorScaleODS() { - const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("colorScale.")); - rtl::OUString aFileExtension(aFileFormats[ODS].pName, strlen(aFileFormats[ODS].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[ODS].pFilterName, strlen(aFileFormats[ODS].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; + const OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("colorScale.")); + OUString aFileExtension(aFileFormats[ODS].pName, strlen(aFileFormats[ODS].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[ODS].pFilterName, strlen(aFileFormats[ODS].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFileName; createFileURL(aFileNameBase, aFileExtension, aFileName); - rtl::OUString aFilterType(aFileFormats[ODS].pTypeName, strlen(aFileFormats[ODS].pTypeName), RTL_TEXTENCODING_UTF8); + OUString aFilterType(aFileFormats[ODS].pTypeName, strlen(aFileFormats[ODS].pTypeName), RTL_TEXTENCODING_UTF8); std::cout << aFileFormats[ODS].pName << " Test" << std::endl; 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, + ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); CPPUNIT_ASSERT_MESSAGE("Failed to load colorScale.ods", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUStringBuffer aBuffer(getSrcRootPath()); - aBuffer.append(m_aBaseString).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/reference/"))); + OUStringBuffer aBuffer(getSrcRootPath()); + aBuffer.append(m_aBaseString).append(OUString(RTL_CONSTASCII_USTRINGPARAM("/reference/"))); testColorScale_Impl(pDoc, aBuffer.makeStringAndClear()); xDocSh->DoClose(); @@ -1869,25 +1775,25 @@ void ScFiltersTest::testColorScaleODS() void ScFiltersTest::testColorScaleXLSX() { - const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("colorScale.")); - rtl::OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; + const OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("colorScale.")); + OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFileName; createFileURL(aFileNameBase, aFileExtension, aFileName); - rtl::OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8); + OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8); std::cout << aFileFormats[XLSX].pName << " Test" << std::endl; unsigned int nFormatType = aFileFormats[XLSX].nFormatType; unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; - ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType, + ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); CPPUNIT_ASSERT_MESSAGE("Failed to load colorScale.xlsx", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUStringBuffer aBuffer(getSrcRootPath()); - aBuffer.append(m_aBaseString).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/reference/"))); + OUStringBuffer aBuffer(getSrcRootPath()); + aBuffer.append(m_aBaseString).append(OUString(RTL_CONSTASCII_USTRINGPARAM("/reference/"))); testColorScale_Impl(pDoc, aBuffer.makeStringAndClear()); xDocSh->DoClose(); @@ -1899,25 +1805,25 @@ void ScFiltersTest::testDataBarODS() void ScFiltersTest::testNewCondFormat() { - const rtl::OUString aFileNameBase("new_cond_format_test."); - rtl::OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; + const OUString aFileNameBase("new_cond_format_test."); + OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFileName; createFileURL(aFileNameBase, aFileExtension, aFileName); - rtl::OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8); + OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8); std::cout << aFileFormats[XLSX].pName << " Test" << std::endl; unsigned int nFormatType = aFileFormats[XLSX].nFormatType; unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; - ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType, + ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); CPPUNIT_ASSERT_MESSAGE("Failed to load new_cond_format_test.xlsx", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUString aCSVFile("new_cond_format_test."); - rtl::OUString aCSVPath; + OUString aCSVFile("new_cond_format_test."); + OUString aCSVPath; createCSVPath( aCSVFile, aCSVPath ); testCondFile(aCSVPath, pDoc, 0); @@ -1926,17 +1832,17 @@ void ScFiltersTest::testNewCondFormat() void ScFiltersTest::testFormulaDependency() { - const rtl::OUString aFileNameBase("dependencyTree."); - rtl::OUString aFileExtension(aFileFormats[ODS].pName, strlen(aFileFormats[ODS].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[ODS].pFilterName, strlen(aFileFormats[ODS].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; + const OUString aFileNameBase("dependencyTree."); + OUString aFileExtension(aFileFormats[ODS].pName, strlen(aFileFormats[ODS].pName), RTL_TEXTENCODING_UTF8 ); + OUString aFilterName(aFileFormats[ODS].pFilterName, strlen(aFileFormats[ODS].pFilterName), RTL_TEXTENCODING_UTF8) ; + OUString aFileName; createFileURL(aFileNameBase, aFileExtension, aFileName); - rtl::OUString aFilterType(aFileFormats[ODS].pTypeName, strlen(aFileFormats[ODS].pTypeName), RTL_TEXTENCODING_UTF8); + OUString aFilterType(aFileFormats[ODS].pTypeName, strlen(aFileFormats[ODS].pTypeName), RTL_TEXTENCODING_UTF8); std::cout << aFileFormats[ODS].pName << " Test" << std::endl; 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, + ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); ScDocument* pDoc = xDocSh->GetDocument(); @@ -1955,7 +1861,7 @@ void ScFiltersTest::testFormulaDependency() } ScFiltersTest::ScFiltersTest() - : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data")) + : ScBootstrapFixture( "/sc/qa/unit/data" ) { } @@ -1966,7 +1872,7 @@ void ScFiltersTest::setUp() // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure, // which is a private symbol to us, gets called m_xCalcComponent = - getMultiServiceFactory()->createInstance(rtl::OUString( + getMultiServiceFactory()->createInstance(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.SpreadsheetDocument"))); CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is()); } diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index f29bac11f696..691ad87078c1 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -97,8 +97,7 @@ const int indeterminate = 2; using namespace ::com::sun::star; -using ::rtl::OUString; -using ::rtl::OUStringBuffer; + using ::std::cout; using ::std::cerr; using ::std::endl; @@ -347,7 +346,7 @@ void printRange(ScDocument* pDoc, const ScRange& rRange, const char* pCaption) { for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) { - rtl::OUString aVal = pDoc->GetString(nCol, nRow, rRange.aStart.Tab()); + OUString aVal = pDoc->GetString(nCol, nRow, rRange.aStart.Tab()); printer.set(nRow-nRow1, nCol-nCol1, aVal); } } @@ -465,7 +464,7 @@ void Test::testRangeList() void Test::testInput() { - rtl::OUString aTabName("foo"); + OUString aTabName("foo"); CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, aTabName)); @@ -500,7 +499,7 @@ void testFuncSUM(ScDocument* pDoc) double result; pDoc->SetValue (0, 0, 0, val); pDoc->SetValue (0, 1, 0, val); - pDoc->SetString (0, 2, 0, rtl::OUString("=SUM(A1:A2)")); + pDoc->SetString (0, 2, 0, OUString("=SUM(A1:A2)")); pDoc->CalcAll(); pDoc->GetValue (0, 2, 0, result); CPPUNIT_ASSERT_MESSAGE ("calculation failed", result == 2.0); @@ -622,7 +621,7 @@ void testFuncCOUNTIF(ScDocument* pDoc) SCROW nRows = SAL_N_ELEMENTS(aData); for (SCROW i = 0; i < nRows; ++i) - pDoc->SetString(0, i, 0, rtl::OUString::createFromAscii(aData[i])); + pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i])); printRange(pDoc, ScRange(0, 0, 0, 0, 8, 0), "data range for COUNTIF"); @@ -647,7 +646,7 @@ void testFuncCOUNTIF(ScDocument* pDoc) for (SCROW i = 0; i < nRows; ++i) { SCROW nRow = 20 + i; - pDoc->SetString(0, nRow, 0, rtl::OUString::createFromAscii(aChecks[i].pFormula)); + pDoc->SetString(0, nRow, 0, OUString::createFromAscii(aChecks[i].pFormula)); } pDoc->CalcAll(); @@ -670,8 +669,8 @@ void testFuncCOUNTIF(ScDocument* pDoc) // Clear A1:A2. clearRange(pDoc, ScRange(0, 0, 0, 0, 1, 0)); - pDoc->SetString(0, 0, 0, rtl::OUString("=\"\"")); - pDoc->SetString(0, 1, 0, rtl::OUString("=COUNTIF(A1;1)")); + pDoc->SetString(0, 0, 0, OUString("=\"\"")); + pDoc->SetString(0, 1, 0, OUString("=COUNTIF(A1;1)")); pDoc->CalcAll(); double result = pDoc->GetValue(0, 1, 0); @@ -703,7 +702,7 @@ void testFuncIFERROR(ScDocument* pDoc) SCROW nRows = SAL_N_ELEMENTS(aData); for (SCROW i = 0; i < nRows; ++i) - pDoc->SetString(0, i, 0, rtl::OUString::createFromAscii(aData[i])); + pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i])); printRange(pDoc, ScRange(0, 0, 0, 0, nRows-1, 0), "data range for IFERROR/IFNA"); @@ -730,7 +729,7 @@ void testFuncIFERROR(ScDocument* pDoc) for (SCROW i = 0; i < nRows-2; ++i) { SCROW nRow = 20 + i; - pDoc->SetString(0, nRow, 0, rtl::OUString::createFromAscii(aChecks[i].pFormula)); + pDoc->SetString(0, nRow, 0, OUString::createFromAscii(aChecks[i].pFormula)); } // Create a matrix range in last two rows of the range above, actual data @@ -833,8 +832,8 @@ void testFuncVLOOKUP(ScDocument* pDoc) // Insert raw data into A1:B14. for (SCROW i = 0; aData[i][0]; ++i) { - pDoc->SetString(0, i, 0, rtl::OUString::createFromAscii(aData[i][0])); - pDoc->SetString(1, i, 0, rtl::OUString::createFromAscii(aData[i][1])); + pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i][0])); + pDoc->SetString(1, i, 0, OUString::createFromAscii(aData[i][1])); } printRange(pDoc, ScRange(0, 0, 0, 1, 13, 0), "raw data for VLOOKUP"); @@ -866,8 +865,8 @@ void testFuncVLOOKUP(ScDocument* pDoc) // Insert formula data into D1:E18. for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { - pDoc->SetString(3, i, 0, rtl::OUString::createFromAscii(aChecks[i].pLookup)); - pDoc->SetString(4, i, 0, rtl::OUString::createFromAscii(aChecks[i].pFormula)); + pDoc->SetString(3, i, 0, OUString::createFromAscii(aChecks[i].pLookup)); + pDoc->SetString(4, i, 0, OUString::createFromAscii(aChecks[i].pFormula)); } pDoc->CalcAll(); printRange(pDoc, ScRange(3, 0, 0, 4, 17, 0), "formula data for VLOOKUP"); @@ -905,13 +904,13 @@ void runTestMATCH(ScDocument* pDoc, const char* aData[_DataSize], StrStrCheck aC { size_t nDataSize = _DataSize; for (size_t i = 0; i < nDataSize; ++i) - pDoc->SetString(0, i, 0, rtl::OUString::createFromAscii(aData[i])); + pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i])); for (size_t i = 0; i < _FormulaSize; ++i) { - pDoc->SetString(1, i, 0, rtl::OUString::createFromAscii(aChecks[i].pVal)); + pDoc->SetString(1, i, 0, OUString::createFromAscii(aChecks[i].pVal)); - rtl::OUStringBuffer aBuf; + OUStringBuffer aBuf; aBuf.appendAscii("=MATCH(B"); aBuf.append(static_cast(i+1)); aBuf.appendAscii(";A1:A"); @@ -919,7 +918,7 @@ void runTestMATCH(ScDocument* pDoc, const char* aData[_DataSize], StrStrCheck aC aBuf.appendAscii(";"); aBuf.append(static_cast(_Type)); aBuf.appendAscii(")"); - rtl::OUString aFormula = aBuf.makeStringAndClear(); + OUString aFormula = aBuf.makeStringAndClear(); pDoc->SetString(2, i, 0, aFormula); } @@ -1032,7 +1031,7 @@ void testFuncCELL(ScDocument* pDoc) { const char* pContent = "Some random text"; - pDoc->SetString(2, 9, 0, rtl::OUString::createFromAscii(pContent)); // Set this value to C10. + pDoc->SetString(2, 9, 0, OUString::createFromAscii(pContent)); // Set this value to C10. double val = 1.2; pDoc->SetValue(2, 0, 0, val); // Set numeric value to C1; @@ -1051,12 +1050,12 @@ void testFuncCELL(ScDocument* pDoc) }; for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) - pDoc->SetString(0, i, 0, rtl::OUString::createFromAscii(aChecks[i].pVal)); + pDoc->SetString(0, i, 0, OUString::createFromAscii(aChecks[i].pVal)); pDoc->CalcAll(); for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { - rtl::OUString aVal = pDoc->GetString(0, i, 0); + OUString aVal = pDoc->GetString(0, i, 0); CPPUNIT_ASSERT_MESSAGE("Unexpected result for CELL", aVal.equalsAscii(aChecks[i].pRes)); } } @@ -1092,8 +1091,8 @@ void testFuncDATEDIF( ScDocument* pDoc ) for (size_t i = 0; i < SAL_N_ELEMENTS(aData); ++i) { - rtl::OUString aVal = pDoc->GetString( 4, i, 0); - //std::cout << "row "<< i << ": " << rtl::OUStringToOString( aVal, RTL_TEXTENCODING_UTF8).getStr() << ", expected " << aData[i][3] << std::endl; + OUString aVal = pDoc->GetString( 4, i, 0); + //std::cout << "row "<< i << ": " << OUStringToOString( aVal, RTL_TEXTENCODING_UTF8).getStr() << ", expected " << aData[i][3] << std::endl; CPPUNIT_ASSERT_MESSAGE("Unexpected result for DATEDIF", aVal.equalsAscii( aData[i][3])); } } @@ -1101,17 +1100,17 @@ void testFuncDATEDIF( ScDocument* pDoc ) void testFuncINDIRECT(ScDocument* pDoc) { clearRange(pDoc, ScRange(0, 0, 0, 0, 10, 0)); // Clear A1:A11 - rtl::OUString aTabName; + OUString aTabName; bool bGood = pDoc->GetName(0, aTabName); CPPUNIT_ASSERT_MESSAGE("failed to get sheet name.", bGood); - rtl::OUString aTest = "Test", aRefErr = "#REF!"; + OUString aTest = "Test", aRefErr = "#REF!"; pDoc->SetString(0, 10, 0, aTest); CPPUNIT_ASSERT_MESSAGE("Unexpected cell value.", pDoc->GetString(0,10,0) == aTest); - rtl::OUString aPrefix = "=INDIRECT(\""; + OUString aPrefix = "=INDIRECT(\""; - rtl::OUString aFormula = aPrefix + aTabName + ".A11\")"; // Calc A1 + OUString aFormula = aPrefix + aTabName + ".A11\")"; // Calc A1 pDoc->SetString(0, 0, 0, aFormula); aFormula = aPrefix + aTabName + "!A11\")"; // Excel A1 pDoc->SetString(0, 1, 0, aFormula); @@ -1123,13 +1122,13 @@ void testFuncINDIRECT(ScDocument* pDoc) pDoc->CalcAll(); { // Default is to use the current formula syntax, which is Calc A1. - const rtl::OUString* aChecks[] = { + const OUString* aChecks[] = { &aTest, &aRefErr, &aRefErr, &aTest }; for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { - rtl::OUString aVal = pDoc->GetString(0, i, 0); + OUString aVal = pDoc->GetString(0, i, 0); CPPUNIT_ASSERT_MESSAGE("Wrong value!", aVal == *aChecks[i]); } } @@ -1140,13 +1139,13 @@ void testFuncINDIRECT(ScDocument* pDoc) pDoc->CalcAll(); { // Explicit Calc A1 syntax - const rtl::OUString* aChecks[] = { + const OUString* aChecks[] = { &aTest, &aRefErr, &aRefErr, &aTest }; for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { - rtl::OUString aVal = pDoc->GetString(0, i, 0); + OUString aVal = pDoc->GetString(0, i, 0); CPPUNIT_ASSERT_MESSAGE("Wrong value!", aVal == *aChecks[i]); } } @@ -1156,13 +1155,13 @@ void testFuncINDIRECT(ScDocument* pDoc) pDoc->CalcAll(); { // Excel A1 syntax - const rtl::OUString* aChecks[] = { + const OUString* aChecks[] = { &aRefErr, &aTest, &aRefErr, &aTest }; for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { - rtl::OUString aVal = pDoc->GetString(0, i, 0); + OUString aVal = pDoc->GetString(0, i, 0); CPPUNIT_ASSERT_MESSAGE("Wrong value!", aVal == *aChecks[i]); } } @@ -1172,13 +1171,13 @@ void testFuncINDIRECT(ScDocument* pDoc) pDoc->CalcAll(); { // Excel R1C1 syntax - const rtl::OUString* aChecks[] = { + const OUString* aChecks[] = { &aRefErr, &aRefErr, &aTest, &aTest }; for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { - rtl::OUString aVal = pDoc->GetString(0, i, 0); + OUString aVal = pDoc->GetString(0, i, 0); CPPUNIT_ASSERT_MESSAGE("Wrong value!", aVal == *aChecks[i]); } } @@ -1186,7 +1185,7 @@ void testFuncINDIRECT(ScDocument* pDoc) void Test::testCellFunctions() { - rtl::OUString aTabName("foo"); + OUString aTabName("foo"); CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, aTabName)); @@ -1235,8 +1234,8 @@ void Test::testCopyToDocument() void Test::testSheetsFunc() { - rtl::OUString aTabName1("test1"); - rtl::OUString aTabName2("test2"); + OUString aTabName1("test1"); + OUString aTabName2("test2"); CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (SC_TAB_APPEND, aTabName1)); @@ -1268,7 +1267,7 @@ void Test::testSheetsFunc() void Test::testVolatileFunc() { - rtl::OUString aTabName("foo"); + OUString aTabName("foo"); CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, aTabName)); @@ -1430,7 +1429,7 @@ void Test::testFormulaDepTracking2() void Test::testFuncParam() { - rtl::OUString aTabName("foo"); + OUString aTabName("foo"); CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, aTabName)); @@ -1454,7 +1453,7 @@ void Test::testFuncParam() m_pDoc->SetString(0, 2, 0, OUString("=\" 4 \"+3")); // number in blanks m_pDoc->SetString(0, 3, 0, OUString("=\" x \"+3")); // non-numeric => #VALUE! error - rtl::OUString aVal; + OUString aVal; ScCalcConfig aConfig; // With "Empty string as zero" option. @@ -1507,8 +1506,8 @@ void Test::testNamedRange() { ScRangeData* pNew = new ScRangeData( m_pDoc, - rtl::OUString::createFromAscii(aNames[i].pName), - rtl::OUString::createFromAscii(aNames[i].pExpr), + OUString::createFromAscii(aNames[i].pName), + OUString::createFromAscii(aNames[i].pExpr), aA1, 0, formula::FormulaGrammar::GRAM_ENGLISH); pNew->SetIndex(aNames[i].nIndex); bool bSuccess = pNewRanges->insert(pNew); @@ -1520,13 +1519,13 @@ void Test::testNamedRange() { const ScRangeData* p = pNewRanges->findByIndex(aNames[i].nIndex); CPPUNIT_ASSERT_MESSAGE("lookup of range name by index failed.", p); - rtl::OUString aName = p->GetName(); + OUString aName = p->GetName(); CPPUNIT_ASSERT_MESSAGE("wrong range name is retrieved.", aName.equalsAscii(aNames[i].pName)); } // Test usage in formula expression. m_pDoc->SetRangeName(pNewRanges); - m_pDoc->SetString (1, 0, 0, rtl::OUString("=A1/Divisor")); + m_pDoc->SetString (1, 0, 0, OUString("=A1/Divisor")); m_pDoc->CalcAll(); double result; @@ -1541,7 +1540,7 @@ void Test::testNamedRange() { const ScRangeData* p = pCopiedRanges->findByIndex(aNames[i].nIndex); CPPUNIT_ASSERT_MESSAGE("lookup of range name by index failed with the copied instance.", p); - rtl::OUString aName = p->GetName(); + OUString aName = p->GetName(); CPPUNIT_ASSERT_MESSAGE("wrong range name is retrieved with the copied instance.", aName.equalsAscii(aNames[i].pName)); } @@ -1571,7 +1570,7 @@ void Test::testCSV() { "1.000.00", European, false, 0.0 } }; for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(aTests); i++) { - rtl::OUString aStr(aTests[i].pStr, strlen (aTests[i].pStr), RTL_TEXTENCODING_UTF8); + OUString aStr(aTests[i].pStr, strlen (aTests[i].pStr), RTL_TEXTENCODING_UTF8); double nValue = 0.0; bool bResult = ScStringUtil::parseSimpleNumber (aStr, aTests[i].eSep == English ? '.' : ',', @@ -1713,7 +1712,7 @@ void Test::testMatrix() pMat->PutBoolean(true, 1, 1); pMat->PutDouble(-12.5, 4, 5); - rtl::OUString aStr("Test"); + OUString aStr("Test"); pMat->PutString(aStr, 8, 2); pMat->PutEmptyPath(8, 11); checkMatrixElements(*pMat); @@ -1862,7 +1861,7 @@ ScDPObject* createDPFromSourceDesc( // Set the dimension information. for (size_t i = 0; i < nFieldCount; ++i) { - OUString aDimName = rtl::OUString::createFromAscii(aFields[i].pName); + OUString aDimName = OUString::createFromAscii(aFields[i].pName); ScDPSaveDimension* pDim = aSaveData.GetNewDimensionByName(aDimName); pDim->SetOrientation(static_cast(aFields[i].eOrient)); pDim->SetUsedHierarchy(0); @@ -2321,7 +2320,7 @@ void Test::testPivotTableFilters() ScAddress aFormulaAddr = aOutRange.aEnd; aFormulaAddr.IncRow(2); m_pDoc->SetString(aFormulaAddr.Col(), aFormulaAddr.Row(), aFormulaAddr.Tab(), - rtl::OUString("=B6")); + OUString("=B6")); double fTest = m_pDoc->GetValue(aFormulaAddr); CPPUNIT_ASSERT_MESSAGE("Incorrect formula value that references a cell in the pivot table output.", fTest == 80.0); @@ -2438,11 +2437,11 @@ void Test::testPivotTableNamedSource() // Insert the raw data. ScRange aSrcRange = insertDPSourceData(m_pDoc, aFields, nFieldCount, aData, nDataCount); - rtl::OUString aRangeStr; + OUString aRangeStr; aSrcRange.Format(aRangeStr, SCR_ABS_3D, m_pDoc); // Name this range. - rtl::OUString aRangeName("MyData"); + OUString aRangeName("MyData"); ScRangeName* pNames = m_pDoc->GetRangeName(); CPPUNIT_ASSERT_MESSAGE("Failed to get global range name container.", pNames); ScRangeData* pName = new ScRangeData( @@ -2486,7 +2485,7 @@ void Test::testPivotTableNamedSource() // Move the table with pivot table to the left of the source data sheet. m_pDoc->MoveTab(1, 0); - rtl::OUString aTabName; + OUString aTabName; m_pDoc->GetName(0, aTabName); CPPUNIT_ASSERT_MESSAGE( "Wrong sheet name.", aTabName == "Table" ); CPPUNIT_ASSERT_MESSAGE("Pivot table output is on the wrong sheet!", @@ -2535,7 +2534,7 @@ void Test::testPivotTableCache() aCache.InitFromDoc(m_pDoc, aDataRange); long nDimCount = aCache.GetColumnCount(); CPPUNIT_ASSERT_MESSAGE("wrong dimension count.", nDimCount == 3); - rtl::OUString aDimName = aCache.GetDimensionName(0); + OUString aDimName = aCache.GetDimensionName(0); CPPUNIT_ASSERT_MESSAGE("wrong dimension name", aDimName.equalsAscii("F1")); aDimName = aCache.GetDimensionName(1); CPPUNIT_ASSERT_MESSAGE("wrong dimension name", aDimName.equalsAscii("F2")); @@ -2637,7 +2636,7 @@ void Test::testPivotTableCache() for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { pItem = aCache.GetItemDataById(nDim, aCache.GetItemDataId(nDim, i, false)); - aTest.SetString(rtl::OUString::createFromAscii(aChecks[i])); + aTest.SetString(OUString::createFromAscii(aChecks[i])); CPPUNIT_ASSERT_MESSAGE("wrong data value", pItem && *pItem == aTest); } @@ -2653,7 +2652,7 @@ void Test::testPivotTableCache() for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { pItem = aCache.GetItemDataById(nDim, aCache.GetItemDataId(nDim, i, false)); - aTest.SetString(rtl::OUString::createFromAscii(aChecks[i])); + aTest.SetString(OUString::createFromAscii(aChecks[i])); CPPUNIT_ASSERT_MESSAGE("wrong data value", pItem && *pItem == aTest); } } @@ -2856,21 +2855,21 @@ void Test::testPivotTableNormalGrouping() ScDPDimensionSaveData* pDimData = pSaveData->GetDimensionData(); CPPUNIT_ASSERT_MESSAGE("Failed to create dimension data.", pDimData); - rtl::OUString aGroupPrefix("Group"); - rtl::OUString aBaseDimName("Name"); - rtl::OUString aGroupDimName = + OUString aGroupPrefix("Group"); + OUString aBaseDimName("Name"); + OUString aGroupDimName = pDimData->CreateGroupDimName(aBaseDimName, *pDPObj, false, NULL); { // Group A, B and C together. ScDPSaveGroupDimension aGroupDim(aBaseDimName, aGroupDimName); - rtl::OUString aGroupName = aGroupDim.CreateGroupName(aGroupPrefix); + OUString aGroupName = aGroupDim.CreateGroupName(aGroupPrefix); CPPUNIT_ASSERT_MESSAGE("Unexpected group name", aGroupName.equalsAscii("Group1")); ScDPSaveGroupItem aGroup(aGroupName); - aGroup.AddElement(rtl::OUString("A")); - aGroup.AddElement(rtl::OUString("B")); - aGroup.AddElement(rtl::OUString("C")); + aGroup.AddElement(OUString("A")); + aGroup.AddElement(OUString("B")); + aGroup.AddElement(OUString("C")); aGroupDim.AddGroupItem(aGroup); pDimData->AddGroupDimension(aGroupDim); @@ -2906,13 +2905,13 @@ void Test::testPivotTableNormalGrouping() // Group D, E, F together. ScDPSaveGroupDimension* pGroupDim = pDimData->GetGroupDimAccForBase(aBaseDimName); CPPUNIT_ASSERT_MESSAGE("There should be an existing group dimension.", pGroupDim); - rtl::OUString aGroupName = pGroupDim->CreateGroupName(aGroupPrefix); + OUString aGroupName = pGroupDim->CreateGroupName(aGroupPrefix); CPPUNIT_ASSERT_MESSAGE("Unexpected group name", aGroupName.equalsAscii("Group2")); ScDPSaveGroupItem aGroup(aGroupName); - aGroup.AddElement(rtl::OUString("D")); - aGroup.AddElement(rtl::OUString("E")); - aGroup.AddElement(rtl::OUString("F")); + aGroup.AddElement(OUString("D")); + aGroup.AddElement(OUString("E")); + aGroup.AddElement(OUString("F")); pGroupDim->AddGroupItem(aGroup); } @@ -3009,7 +3008,7 @@ void Test::testPivotTableNumberGrouping() aInfo.mfStart = 30; aInfo.mfEnd = 60; aInfo.mfStep = 10; - ScDPSaveNumGroupDimension aGroup(rtl::OUString("Order"), aInfo); + ScDPSaveNumGroupDimension aGroup(OUString("Order"), aInfo); pDimData->AddNumGroupDimension(aGroup); } @@ -3084,7 +3083,7 @@ void Test::testPivotTableDateGrouping() ScDPDimensionSaveData* pDimData = pSaveData->GetDimensionData(); CPPUNIT_ASSERT_MESSAGE("No dimension data !?", pDimData); - rtl::OUString aBaseDimName("Date"); + OUString aBaseDimName("Date"); ScDPNumGroupInfo aInfo; aInfo.mbEnable = true; @@ -3100,7 +3099,7 @@ void Test::testPivotTableDateGrouping() { // Add quarter dimension. This will be an additional dimension. - rtl::OUString aGroupDimName = + OUString aGroupDimName = pDimData->CreateDateGroupDimName( sheet::DataPilotFieldGroupBy::QUARTERS, *pDPObj, true, NULL); ScDPSaveGroupDimension aGroupDim(aBaseDimName, aGroupDimName); @@ -3115,7 +3114,7 @@ void Test::testPivotTableDateGrouping() { // Add year dimension. This is a new dimension also. - rtl::OUString aGroupDimName = + OUString aGroupDimName = pDimData->CreateDateGroupDimName( sheet::DataPilotFieldGroupBy::YEARS, *pDPObj, true, NULL); ScDPSaveGroupDimension aGroupDim(aBaseDimName, aGroupDimName); @@ -3151,9 +3150,9 @@ void Test::testPivotTableDateGrouping() { // Let's hide year 2012. pSaveData = pDPObj->GetSaveData(); - ScDPSaveDimension* pDim = pSaveData->GetDimensionByName(rtl::OUString("Years")); + ScDPSaveDimension* pDim = pSaveData->GetDimensionByName(OUString("Years")); CPPUNIT_ASSERT_MESSAGE("Years dimension should exist.", pDim); - ScDPSaveMember* pMem = pDim->GetMemberByName(rtl::OUString("2012")); + ScDPSaveMember* pMem = pDim->GetMemberByName(OUString("2012")); CPPUNIT_ASSERT_MESSAGE("Member should exist.", pMem); pMem->SetIsVisible(false); } @@ -3860,7 +3859,7 @@ void Test::testSheetMove() CPPUNIT_ASSERT_EQUAL_MESSAGE("document now should have two sheets.", m_pDoc->GetTableCount(), static_cast(2)); bHidden = m_pDoc->RowHidden(0, 1, &nRow1, &nRow2); CPPUNIT_ASSERT_MESSAGE("copied sheet should also have all rows visible as the original.", !bHidden && nRow1 == 0 && nRow2 == MAXROW); - rtl::OUString aName; + OUString aName; m_pDoc->GetName(0, aName); CPPUNIT_ASSERT_MESSAGE( "sheets should have changed places", aName == "TestTab1" ); @@ -4122,15 +4121,15 @@ void testExtRefFuncT(ScDocument* pDoc, ScDocument* pExtDoc) clearRange(pDoc, ScRange(0, 0, 0, 1, 9, 0)); clearRange(pExtDoc, ScRange(0, 0, 0, 1, 9, 0)); - pExtDoc->SetString(0, 0, 0, rtl::OUString("'1.2")); - pExtDoc->SetString(0, 1, 0, rtl::OUString("Foo")); + pExtDoc->SetString(0, 0, 0, OUString("'1.2")); + pExtDoc->SetString(0, 1, 0, OUString("Foo")); pExtDoc->SetValue(0, 2, 0, 12.3); - pDoc->SetString(0, 0, 0, rtl::OUString("=T('file:///extdata.fake'#Data.A1)")); - pDoc->SetString(0, 1, 0, rtl::OUString("=T('file:///extdata.fake'#Data.A2)")); - pDoc->SetString(0, 2, 0, rtl::OUString("=T('file:///extdata.fake'#Data.A3)")); + pDoc->SetString(0, 0, 0, OUString("=T('file:///extdata.fake'#Data.A1)")); + pDoc->SetString(0, 1, 0, OUString("=T('file:///extdata.fake'#Data.A2)")); + pDoc->SetString(0, 2, 0, OUString("=T('file:///extdata.fake'#Data.A3)")); pDoc->CalcAll(); - rtl::OUString aRes = pDoc->GetString(0, 0, 0); + OUString aRes = pDoc->GetString(0, 0, 0); CPPUNIT_ASSERT_MESSAGE( "Unexpected result with T.", aRes == "1.2" ); aRes = pDoc->GetString(0, 1, 0); CPPUNIT_ASSERT_MESSAGE( "Unexpected result with T.", aRes == "Foo" ); @@ -4156,7 +4155,7 @@ void Test::testExternalRefFunctions() // Populate the external source document. ScDocument* pExtDoc = xExtDocSh->GetDocument(); - pExtDoc->InsertTab(0, rtl::OUString("Data")); + pExtDoc->InsertTab(0, OUString("Data")); double val = 1; pExtDoc->SetValue(0, 0, 0, val); // leave cell B1 empty. @@ -4170,7 +4169,7 @@ void Test::testExternalRefFunctions() pExtDoc->SetValue(0, 3, 0, val); pExtDoc->SetValue(1, 3, 0, val); - m_pDoc->InsertTab(0, rtl::OUString("Test")); + m_pDoc->InsertTab(0, OUString("Test")); struct { const char* pFormula; double fResult; @@ -4185,7 +4184,7 @@ void Test::testExternalRefFunctions() for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { - m_pDoc->SetString(0, 0, 0, rtl::OUString::createFromAscii(aChecks[i].pFormula)); + m_pDoc->SetString(0, 0, 0, OUString::createFromAscii(aChecks[i].pFormula)); m_pDoc->CalcAll(); m_pDoc->GetValue(0, 0, 0, val); CPPUNIT_ASSERT_MESSAGE("unexpected result involving external ranges.", val == aChecks[i].fResult); @@ -4785,8 +4784,8 @@ void Test::testGraphicsInGroup() void Test::testGraphicsOnSheetMove() { - m_pDoc->InsertTab(0, rtl::OUString("Tab1")); - m_pDoc->InsertTab(1, rtl::OUString("Tab2")); + m_pDoc->InsertTab(0, OUString("Tab1")); + m_pDoc->InsertTab(1, OUString("Tab2")); CPPUNIT_ASSERT_MESSAGE("There should be only 2 sheets to begin with", m_pDoc->GetTableCount() == 2); m_pDoc->InitDrawLayer(); @@ -4813,7 +4812,7 @@ void Test::testGraphicsOnSheetMove() // Insert a new sheet at left-end, and make sure the object has moved to // the 2nd page. - m_pDoc->InsertTab(0, rtl::OUString("NewTab")); + m_pDoc->InsertTab(0, OUString("NewTab")); CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 3 sheets.", m_pDoc->GetTableCount(), static_cast(3)); pPage = pDrawLayer->GetPage(0); CPPUNIT_ASSERT_MESSAGE("1st sheet should have no object.", pPage && pPage->GetObjCount() == 0); @@ -4859,10 +4858,10 @@ void Test::testGraphicsOnSheetMove() void Test::testPostIts() { - rtl::OUString aHello("Hello world"); - rtl::OUString aJimBob("Jim Bob"); - rtl::OUString aTabName("PostIts"); - rtl::OUString aTabName2("Table2"); + OUString aHello("Hello world"); + OUString aJimBob("Jim Bob"); + OUString aTabName("PostIts"); + OUString aTabName2("Table2"); m_pDoc->InsertTab(0, aTabName); ScAddress rAddr(2, 2, 0); // cell C3 @@ -5021,7 +5020,7 @@ void Test::testAutofilter() for (SCROW i = 0; i < nRows; ++i) for (SCCOL j = 0; j < nCols; ++j) if (aData[i][j]) - m_pDoc->SetString(j, i, 0, rtl::OUString::createFromAscii(aData[i][j])); + m_pDoc->SetString(j, i, 0, OUString::createFromAscii(aData[i][j])); ScDBData* pDBData = new ScDBData(aDBName, 0, 0, 0, nCols-1, nRows-1); m_pDoc->SetAnonymousDBData(0,pDBData); @@ -5107,7 +5106,7 @@ void Test::testCopyPaste() ScAddress aAdr (0, 0, 0); //create some range names, local and global - ScRangeData* pLocal1 = new ScRangeData(m_pDoc, rtl::OUString("local1"), aAdr); + ScRangeData* pLocal1 = new ScRangeData(m_pDoc, OUString("local1"), aAdr); ScRangeData* pLocal2 = new ScRangeData(m_pDoc, OUString("local2"), aAdr); ScRangeData* pGlobal = new ScRangeData(m_pDoc, OUString("global"), aAdr); ScRangeName* pGlobalRangeName = new ScRangeName(); @@ -5119,7 +5118,7 @@ void Test::testCopyPaste() m_pDoc->SetRangeName(0, pLocalRangeName1); //add formula - rtl::OUString aFormulaString("=local1+global+SUM($C$1:$D$4)"); + OUString aFormulaString("=local1+global+SUM($C$1:$D$4)"); m_pDoc->SetString(1, 0, 0, aFormulaString); double aValue = 0; @@ -5147,7 +5146,7 @@ void Test::testCopyPaste() m_pDoc->CopyFromClip(aRange, aMarkData2, nFlags, NULL, pClipDoc); //check values after copying - rtl::OUString aString; + OUString aString; m_pDoc->GetValue(1,1,1, aValue); m_pDoc->GetFormula(1,1,1, aString); ASSERT_DOUBLES_EQUAL_MESSAGE("copied formula should return 2", aValue, 2); @@ -5191,7 +5190,7 @@ void Test::testMergedCells() { //test merge and unmerge //TODO: an undo/redo test for this would be a good idea - m_pDoc->InsertTab(0, rtl::OUString("Sheet1")); + m_pDoc->InsertTab(0, OUString("Sheet1")); m_pDoc->DoMerge(0, 1, 1, 3, 3, false); SCCOL nEndCol = 1; SCROW nEndRow = 1; @@ -5218,19 +5217,19 @@ void Test::testRenameTable() m_pDoc->InsertTab(1, "Sheet2"); //test case 1 , rename table2 to sheet 1, it should return error - rtl::OUString nameToSet = "Sheet1"; + OUString nameToSet = "Sheet1"; ScDocFunc& rDocFunc = m_xDocShRef->GetDocFunc(); CPPUNIT_ASSERT_MESSAGE("name same as another table is being set", !rDocFunc.RenameTable(1,nameToSet,false,true) ); //test case 2 , simple rename to check name nameToSet = "test1"; m_xDocShRef->GetDocFunc().RenameTable(0,nameToSet,false,true); - rtl::OUString nameJustSet; + OUString nameJustSet; m_pDoc->GetName(0,nameJustSet); CPPUNIT_ASSERT_MESSAGE("table not renamed", nameToSet == nameJustSet); //test case 3 , rename again - rtl::OUString anOldName; + OUString anOldName; m_pDoc->GetName(0,anOldName); nameToSet = "test2"; @@ -5290,10 +5289,10 @@ void Test::testUpdateReference() { //test that formulas are correctly updated during sheet delete //TODO: add tests for relative references, updating of named ranges, ... - rtl::OUString aSheet1("Sheet1"); - rtl::OUString aSheet2("Sheet2"); - rtl::OUString aSheet3("Sheet3"); - rtl::OUString aSheet4("Sheet4"); + OUString aSheet1("Sheet1"); + OUString aSheet2("Sheet2"); + OUString aSheet3("Sheet3"); + OUString aSheet4("Sheet4"); m_pDoc->InsertTab(0, aSheet1); m_pDoc->InsertTab(1, aSheet2); m_pDoc->InsertTab(2, aSheet3); @@ -5302,8 +5301,8 @@ void Test::testUpdateReference() m_pDoc->SetValue(0,0,2, 1); m_pDoc->SetValue(1,0,2, 2); m_pDoc->SetValue(1,1,3, 4); - m_pDoc->SetString(2,0,2, rtl::OUString("=A1+B1")); - m_pDoc->SetString(2,1,2, rtl::OUString("=Sheet4.B2+A1")); + m_pDoc->SetString(2,0,2, OUString("=A1+B1")); + m_pDoc->SetString(2,1,2, OUString("=Sheet4.B2+A1")); double aValue; m_pDoc->GetValue(2,0,2, aValue); @@ -5344,14 +5343,14 @@ void Test::testUpdateReference() m_pDoc->GetValue(2, 1, 0, aValue); ASSERT_DOUBLES_EQUAL_MESSAGE("after deleting sheets formula does not return correct result", aValue, 5); - std::vector aSheets; + std::vector aSheets; aSheets.push_back(aSheet1); aSheets.push_back(aSheet2); m_pDoc->InsertTabs(0, aSheets, false, true); m_pDoc->GetValue(2, 0, 2, aValue); - rtl::OUString aFormula; + OUString aFormula; m_pDoc->GetFormula(2,0,2, aFormula); - std::cout << "formel: " << rtl::OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8).getStr() << std::endl; + std::cout << "formel: " << OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8).getStr() << std::endl; std::cout << std::endl << aValue << std::endl; ASSERT_DOUBLES_EQUAL_MESSAGE("after inserting sheets formula does not return correct result", aValue, 3); m_pDoc->GetValue(2, 1, 2, aValue); @@ -5408,10 +5407,10 @@ void Test::testJumpToPrecedentsDependents() { // Precedent is another cell that the cell references, while dependent is // another cell that references it. - m_pDoc->InsertTab(0, rtl::OUString("Test")); + m_pDoc->InsertTab(0, OUString("Test")); - m_pDoc->SetString(2, 0, 0, rtl::OUString("=A1+A2+B3")); // C1 - m_pDoc->SetString(2, 1, 0, rtl::OUString("=A1")); // C2 + m_pDoc->SetString(2, 0, 0, OUString("=A1+A2+B3")); // C1 + m_pDoc->SetString(2, 1, 0, OUString("=A1")); // C2 m_pDoc->CalcAll(); std::vector aRefTokens; @@ -5500,10 +5499,10 @@ void Test::testAutoFill() // test auto fill user data lists m_pDoc->SetString( 0, 100, 0, "January" ); m_pDoc->Fill( 0, 100, 0, 100, NULL, aMarkData, 2, FILL_TO_BOTTOM, FILL_AUTO ); - rtl::OUString aTestValue = m_pDoc->GetString( 0, 101, 0 ); - CPPUNIT_ASSERT_EQUAL( aTestValue, rtl::OUString("February") ); + OUString aTestValue = m_pDoc->GetString( 0, 101, 0 ); + CPPUNIT_ASSERT_EQUAL( aTestValue, OUString("February") ); aTestValue = m_pDoc->GetString( 0, 102, 0 ); - CPPUNIT_ASSERT_EQUAL( aTestValue, rtl::OUString("March") ); + CPPUNIT_ASSERT_EQUAL( aTestValue, OUString("March") ); // test that two same user data list entries will not result in incremental fill m_pDoc->SetString( 0, 101, 0, "January" ); @@ -5511,7 +5510,7 @@ void Test::testAutoFill() for ( SCROW i = 102; i <= 103; ++i ) { aTestValue = m_pDoc->GetString( 0, i, 0 ); - CPPUNIT_ASSERT_EQUAL( aTestValue, rtl::OUString("January") ); + CPPUNIT_ASSERT_EQUAL( aTestValue, OUString("January") ); } m_pDoc->DeleteTab(0); } @@ -5537,22 +5536,22 @@ void Test::testCopyPasteFormulas() CPPUNIT_ASSERT(bMoveDone); ASSERT_DOUBLES_EQUAL(m_pDoc->GetValue(10,10,0), 1.0); ASSERT_DOUBLES_EQUAL(m_pDoc->GetValue(10,11,0), 1.0); - rtl::OUString aFormula; + OUString aFormula; m_pDoc->GetFormula(10,10,0, aFormula); - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=COLUMN($A$1)")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("=COLUMN($A$1)")); m_pDoc->GetFormula(10,11,0, aFormula); - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=$A$1+L12")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("=$A$1+L12")); m_pDoc->GetFormula(10,12,0, aFormula); - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=$Sheet2.K11")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("=$Sheet2.K11")); m_pDoc->GetFormula(10,13,0, aFormula); - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=$Sheet2.$A$1")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("=$Sheet2.$A$1")); m_pDoc->GetFormula(10,14,0, aFormula); - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=$Sheet2.K$1")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("=$Sheet2.K$1")); } void Test::testCopyPasteFormulasExternalDoc() { - rtl::OUString aDocName("file:///source.fake"); + OUString aDocName("file:///source.fake"); SfxMedium* pMedium = new SfxMedium(aDocName, STREAM_STD_READWRITE); m_xDocShRef->DoInitNew(pMedium); m_pDoc = m_xDocShRef->GetDocument(); @@ -5593,22 +5592,22 @@ void Test::testCopyPasteFormulasExternalDoc() aMarkData2.SetMarkArea(aRange); pExtDoc->CopyFromClip(aRange, aMarkData2, nFlags, NULL, pClipDoc); - rtl::OUString aFormula; + OUString aFormula; pExtDoc->GetFormula(1,1,1, aFormula); //adjust absolute refs pointing to the copy area - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=COLUMN($B$2)")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("=COLUMN($B$2)")); pExtDoc->GetFormula(1,2,1, aFormula); //adjust absolute refs and keep relative refs - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=$B$2+C3")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("=$B$2+C3")); pExtDoc->GetFormula(1,3,1, aFormula); // make absolute sheet refs external refs - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("='file:///source.fake'#$Sheet2.B2")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("='file:///source.fake'#$Sheet2.B2")); pExtDoc->GetFormula(1,4,1, aFormula); - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("='file:///source.fake'#$Sheet2.$A$1")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("='file:///source.fake'#$Sheet2.$A$1")); pExtDoc->GetFormula(1,5,1, aFormula); - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("='file:///source.fake'#$Sheet2.B$1")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("='file:///source.fake'#$Sheet2.B$1")); pExtDoc->GetFormula(1,6,1, aFormula); - CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=$ExtSheet2.$B$2")); + CPPUNIT_ASSERT_EQUAL(aFormula, OUString("=$ExtSheet2.$B$2")); } void Test::testFindAreaPosRowDown() @@ -5623,7 +5622,7 @@ void Test::testFindAreaPosRowDown() { "1", "1" }, }; ScDocument* pDoc = m_xDocShRef->GetDocument(); - rtl::OUString aTabName1("test1"); + OUString aTabName1("test1"); pDoc->InsertTab(0, aTabName1); clearRange( pDoc, ScRange(0, 0, 0, 1, SAL_N_ELEMENTS(aData), 0)); ScAddress aPos(0,0,0); @@ -5684,7 +5683,7 @@ void Test::testFindAreaPosColRight() { "", "", "1", "1", "1", "", "1" }, }; ScDocument* pDoc = m_xDocShRef->GetDocument(); - rtl::OUString aTabName1("test1"); + OUString aTabName1("test1"); pDoc->InsertTab(0, aTabName1); clearRange( pDoc, ScRange(0, 0, 0, 7, SAL_N_ELEMENTS(aData), 0)); ScAddress aPos(0,0,0); @@ -5743,8 +5742,8 @@ void Test::testFindAreaPosColRight() void Test::testSortWithFormulaRefs() { ScDocument* pDoc = m_xDocShRef->GetDocument(); - rtl::OUString aTabName1("List1"); - rtl::OUString aTabName2("List2"); + OUString aTabName1("List1"); + OUString aTabName2("List2"); pDoc->InsertTab(0, aTabName1); pDoc->InsertTab(1, aTabName2); @@ -5775,12 +5774,12 @@ void Test::testSortWithFormulaRefs() // insert data to sort SCROW nStart = 1, nEnd = 4; for ( SCROW i = nStart; i <= nEnd; ++i ) - pDoc->SetString( 0, i, 0, rtl::OUString::createFromAscii(aTextData[i-1]) ); + pDoc->SetString( 0, i, 0, OUString::createFromAscii(aTextData[i-1]) ); // insert forumulas nStart = 0; nEnd = SAL_N_ELEMENTS(aFormulaData); for ( SCROW i = nStart; i < nEnd; ++i ) - pDoc->SetString( 0, i, 1, rtl::OUString::createFromAscii(aFormulaData[i]) ); + pDoc->SetString( 0, i, 1, OUString::createFromAscii(aFormulaData[i]) ); ScSortParam aSortData; aSortData.nCol1 = 0; @@ -5796,7 +5795,7 @@ void Test::testSortWithFormulaRefs() for ( SCROW i = nStart; i < nEnd; ++i ) { OUString sResult = pDoc->GetString( 0, i + 1, 0); - CPPUNIT_ASSERT_EQUAL( rtl::OUString::createFromAscii( aResults[ i ] ), sResult ); + CPPUNIT_ASSERT_EQUAL( OUString::createFromAscii( aResults[ i ] ), sResult ); } pDoc->DeleteTab(0); pDoc->DeleteTab(1); @@ -5805,7 +5804,7 @@ void Test::testSortWithFormulaRefs() void Test::testSort() { ScDocument* pDoc = m_xDocShRef->GetDocument(); - rtl::OUString aTabName1("test1"); + OUString aTabName1("test1"); pDoc->InsertTab(0, aTabName1); const char* aData[][2] = { @@ -5819,8 +5818,8 @@ void Test::testSort() ScRange aDataRange = insertRangeData( pDoc, aPos, aData, SAL_N_ELEMENTS(aData)); CPPUNIT_ASSERT_MESSAGE("failed to insert range data at correct position", aDataRange.aStart == aPos); - rtl::OUString aHello("Hello"); - rtl::OUString aJimBob("Jim Bob"); + OUString aHello("Hello"); + OUString aJimBob("Jim Bob"); ScAddress rAddr(1, 1, 0); ScPostIt* pNote = m_pDoc->GetNotes(rAddr.Tab())->GetOrCreateNote(rAddr); pNote->SetText(rAddr, aHello); @@ -5872,11 +5871,11 @@ void Test::testShiftCells() void Test::testDeleteRow() { ScDocument* pDoc = m_xDocShRef->GetDocument(); - rtl::OUString aSheet1("Sheet1"); + OUString aSheet1("Sheet1"); pDoc->InsertTab(0, aSheet1); - rtl::OUString aHello("Hello"); - rtl::OUString aJimBob("Jim Bob"); + OUString aHello("Hello"); + OUString aJimBob("Jim Bob"); ScAddress rAddr(1, 1, 0); ScPostIt* pNote = m_pDoc->GetNotes(rAddr.Tab())->GetOrCreateNote(rAddr); pNote->SetText(rAddr, aHello); @@ -5891,11 +5890,11 @@ void Test::testDeleteRow() void Test::testDeleteCol() { ScDocument* pDoc = m_xDocShRef->GetDocument(); - rtl::OUString aSheet1("Sheet1"); + OUString aSheet1("Sheet1"); pDoc->InsertTab(0, aSheet1); - rtl::OUString aHello("Hello"); - rtl::OUString aJimBob("Jim Bob"); + OUString aHello("Hello"); + OUString aJimBob("Jim Bob"); ScAddress rAddr(1, 1, 0); ScPostIt* pNote = m_pDoc->GetNotes(rAddr.Tab())->GetOrCreateNote(rAddr); pNote->SetText(rAddr, aHello); -- cgit