From 7d3ddc2c6cc39fdd671f08059528464675cd6ecc Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 5 Feb 2013 14:38:43 -0500 Subject: Pass DocumentService to the loader during macro tests. And disable user interaction during type detection, since that would cause the test to fail. With this change, 'make check' works once again. Change-Id: I2f45a2e962e45ee64f7984e794cff814fbfe6dab --- sc/qa/extras/macros-test.cxx | 4 ++-- sc/qa/extras/regression-test.cxx | 2 +- sc/qa/extras/sccellrangeobj.cxx | 4 ++-- sc/qa/extras/scdatabaserangeobj.cxx | 2 +- sc/qa/extras/scdatapilotfieldobj.cxx | 2 +- sc/qa/extras/scdatapilottableobj.cxx | 4 ++-- sc/qa/extras/scmodelobj.cxx | 2 +- sc/qa/extras/scnamedrangeobj.cxx | 2 +- sc/qa/extras/scnamedrangesobj.cxx | 2 +- sc/qa/extras/sctablesheetobj.cxx | 2 +- sc/source/ui/unoobj/exceldetect.cxx | 4 ++-- sw/qa/core/layout-test.cxx | 2 +- sw/qa/core/macros-test.cxx | 4 ++-- sw/qa/extras/inc/swmodeltestbase.hxx | 4 ++-- translations | 2 +- unotest/inc/unotest/macros_test.hxx | 2 +- unotest/source/cpp/macros_test.cxx | 15 ++++++++++++--- 17 files changed, 34 insertions(+), 25 deletions(-) diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 96da0e241267..244c61accb86 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -80,7 +80,7 @@ void ScMacrosTest::testStarBasic() rtl::OUString aFileName; createFileURL(aFileNameBase, aFileName); std::cout << "StarBasic test" << std::endl; - uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName); + uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); CPPUNIT_ASSERT_MESSAGE("Failed to load StarBasic.ods", xComponent.is()); @@ -122,7 +122,7 @@ void ScMacrosTest::testVba() { rtl::OUString aFileName; createFileURL(testInfo[i].sFileBaseName + "xls", aFileName); - uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName); + uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); rtl::OUString sMsg( "Failed to load " + aFileName ); CPPUNIT_ASSERT_MESSAGE( rtl::OUStringToOString( sMsg, RTL_TEXTENCODING_UTF8 ).getStr(), xComponent.is() ); diff --git a/sc/qa/extras/regression-test.cxx b/sc/qa/extras/regression-test.cxx index 5658618ba0d9..174debde8160 100644 --- a/sc/qa/extras/regression-test.cxx +++ b/sc/qa/extras/regression-test.cxx @@ -114,7 +114,7 @@ void ScChartRegressionTest::test() { rtl::OUString aFileName; createFileURL( "testChart.", "ods", aFileName); - uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName); + uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); CPPUNIT_ASSERT(xComponent.is()); diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx index 2d58459218c9..97366dec287f 100644 --- a/sc/qa/extras/sccellrangeobj.cxx +++ b/sc/qa/extras/sccellrangeobj.cxx @@ -92,7 +92,7 @@ uno::Reference< uno::XInterface > ScCellRangeObj::init() createFileURL(aFileBase, aFileURL); std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; if( !mxComponent.is()) - mxComponent = loadFromDesktop(aFileURL); + mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument"); uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW); uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); @@ -112,7 +112,7 @@ uno::Reference< uno::XInterface > ScCellRangeObj::getXCellRangeData() createFileURL(aFileBase, aFileURL); std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; if( !mxComponent.is()) - mxComponent = loadFromDesktop(aFileURL); + mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument"); uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW); uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW); diff --git a/sc/qa/extras/scdatabaserangeobj.cxx b/sc/qa/extras/scdatabaserangeobj.cxx index bd358853b8f7..c122e4fac742 100644 --- a/sc/qa/extras/scdatabaserangeobj.cxx +++ b/sc/qa/extras/scdatabaserangeobj.cxx @@ -75,7 +75,7 @@ uno::Reference< uno::XInterface > ScDatabaseRangeObj::init( const rtl::OUString& rtl::OUString aFileURL; createFileURL("ScDatabaseRangeObj.ods", aFileURL); if(!mxComponent.is()) - mxComponent = loadFromDesktop(aFileURL); + mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument"); CPPUNIT_ASSERT(mxComponent.is()); uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); diff --git a/sc/qa/extras/scdatapilotfieldobj.cxx b/sc/qa/extras/scdatapilotfieldobj.cxx index df4128815d6e..ccc7417638da 100644 --- a/sc/qa/extras/scdatapilotfieldobj.cxx +++ b/sc/qa/extras/scdatapilotfieldobj.cxx @@ -78,7 +78,7 @@ uno::Reference< uno::XInterface > ScDataPilotFieldObj::init() rtl::OUString aFileURL; createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("scdatapilotfieldobj.ods")), aFileURL); if(!mxComponent.is()) - mxComponent = loadFromDesktop(aFileURL); + mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument"); CPPUNIT_ASSERT(mxComponent.is()); uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); diff --git a/sc/qa/extras/scdatapilottableobj.cxx b/sc/qa/extras/scdatapilottableobj.cxx index 34128ba9c126..1e9f2a873bad 100644 --- a/sc/qa/extras/scdatapilottableobj.cxx +++ b/sc/qa/extras/scdatapilottableobj.cxx @@ -93,7 +93,7 @@ uno::Reference< uno::XInterface > ScDataPilotTableObj::init() rtl::OUString aFileURL; createFileURL("ScDataPilotTableObj.ods", aFileURL); if(!mxComponent.is()) - mxComponent = loadFromDesktop(aFileURL); + mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument"); CPPUNIT_ASSERT(mxComponent.is()); uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); @@ -130,7 +130,7 @@ uno::Reference< uno::XInterface > ScDataPilotTableObj::initDP2() rtl::OUString aFileURL; createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods")), aFileURL); if(!mxComponent.is()) - mxComponent = loadFromDesktop(aFileURL); + mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument"); CPPUNIT_ASSERT(mxComponent.is()); uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); diff --git a/sc/qa/extras/scmodelobj.cxx b/sc/qa/extras/scmodelobj.cxx index e41f7ddce932..167e3b290045 100644 --- a/sc/qa/extras/scmodelobj.cxx +++ b/sc/qa/extras/scmodelobj.cxx @@ -46,7 +46,7 @@ uno::Reference< uno::XInterface > ScModelObj::init() rtl::OUString aFileURL; createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScModelObj.ods")), aFileURL); if(!mxComponent.is()) - mxComponent = loadFromDesktop(aFileURL); + mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument"); CPPUNIT_ASSERT(mxComponent.is()); return mxComponent; diff --git a/sc/qa/extras/scnamedrangeobj.cxx b/sc/qa/extras/scnamedrangeobj.cxx index 81882e54ebc5..95e2b0f75e25 100644 --- a/sc/qa/extras/scnamedrangeobj.cxx +++ b/sc/qa/extras/scnamedrangeobj.cxx @@ -84,7 +84,7 @@ uno::Reference< sheet::XNamedRanges > ScNamedRangeObj::init_impl() rtl::OUString aFileURL; createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScNamedRangeObj.ods")), aFileURL); if(!mxComponent.is()) - mxComponent = loadFromDesktop(aFileURL); + mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument"); CPPUNIT_ASSERT(mxComponent.is()); uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW); diff --git a/sc/qa/extras/scnamedrangesobj.cxx b/sc/qa/extras/scnamedrangesobj.cxx index 1d1599e634de..d921932c0900 100644 --- a/sc/qa/extras/scnamedrangesobj.cxx +++ b/sc/qa/extras/scnamedrangesobj.cxx @@ -72,7 +72,7 @@ uno::Reference< uno::XInterface > ScNamedRangesObj::init(sal_Int32 nSheet) rtl::OUString aFileURL; createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScNamedRangeObj.ods")), aFileURL); if(!mxComponent.is()) - mxComponent = loadFromDesktop(aFileURL); + mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument"); CPPUNIT_ASSERT(mxComponent.is()); uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW); diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx index aff6a46638b6..e10df62997d6 100644 --- a/sc/qa/extras/sctablesheetobj.cxx +++ b/sc/qa/extras/sctablesheetobj.cxx @@ -76,7 +76,7 @@ uno::Reference< uno::XInterface > ScTableSheetObj::init() rtl::OUString aFileURL; createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScTableSheetObj.ods")), aFileURL); if(!mxComponent.is()) - mxComponent = loadFromDesktop(aFileURL); + mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument"); CPPUNIT_ASSERT(mxComponent.is()); uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); diff --git a/sc/source/ui/unoobj/exceldetect.cxx b/sc/source/ui/unoobj/exceldetect.cxx index 4119b1d6592b..db040e3e46f7 100644 --- a/sc/source/ui/unoobj/exceldetect.cxx +++ b/sc/source/ui/unoobj/exceldetect.cxx @@ -53,7 +53,7 @@ namespace { bool hasStream(const uno::Reference& xInStream, const OUString& rName) { SfxMedium aMedium; - aMedium.UseInteractionHandler(true); + aMedium.UseInteractionHandler(false); aMedium.setStreamToLoadFrom(xInStream, true); SvStream* pStream = aMedium.GetInStream(); if (!pStream) @@ -77,7 +77,7 @@ bool hasStream(const uno::Reference& xInStream, const OUString bool isExcel40(const uno::Reference& xInStream) { SfxMedium aMedium; - aMedium.UseInteractionHandler(true); + aMedium.UseInteractionHandler(false); aMedium.setStreamToLoadFrom(xInStream, true); SvStream* pStream = aMedium.GetInStream(); if (!pStream) diff --git a/sw/qa/core/layout-test.cxx b/sw/qa/core/layout-test.cxx index 188d5942b9a7..673e86653db5 100644 --- a/sw/qa/core/layout-test.cxx +++ b/sw/qa/core/layout-test.cxx @@ -89,7 +89,7 @@ void SwLayoutTest::test() rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("test.")); rtl::OUString aExtension(RTL_CONSTASCII_USTRINGPARAM("odt")); createFileURL(aFileBase, aExtension, aFilePath); - uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFilePath); + uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFilePath, "com.sun.star.text.TextDocument"); CPPUNIT_ASSERT(xComponent.is()); } diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index 1f127d09a8b6..036d2d236f87 100644 --- a/sw/qa/core/macros-test.cxx +++ b/sw/qa/core/macros-test.cxx @@ -117,7 +117,7 @@ void SwMacrosTest::testStarBasic() rtl::OUString aFileExtension(aFileFormats[0].pName, strlen(aFileFormats[0].pName), RTL_TEXTENCODING_UTF8 ); rtl::OUString aFileName; createFileURL(aFileNameBase, aFileExtension, aFileName); - uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName); + uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.text.TextDocument"); CPPUNIT_ASSERT_MESSAGE("Failed to load StarBasic.ods", xComponent.is()); @@ -151,7 +151,7 @@ void SwMacrosTest::testVba() { rtl::OUString aFileName; createFileURL(testInfo[i].sFileBaseName, aFileExtension, aFileName); - uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName); + uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.text.TextDocument"); rtl::OUStringBuffer sMsg( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Failed to load ")) ); sMsg.append ( aFileName ); CPPUNIT_ASSERT_MESSAGE( rtl::OUStringToOString( sMsg.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(), xComponent.is() ); diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index d045780df12a..8edb76f32bc9 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -243,7 +243,7 @@ protected: // Output name early, so in the case of a hang, the name of the hanging input file is visible. fprintf(stderr, "%s,", pName); m_nStartTime = osl_getGlobalTimer(); - mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName)); + mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.text.TextDocument"); calcLayout(); } @@ -258,7 +258,7 @@ protected: xStorable->storeToURL(aTempFile.GetURL(), aArgs); uno::Reference xComponent(xStorable, uno::UNO_QUERY); xComponent->dispose(); - mxComponent = loadFromDesktop(aTempFile.GetURL()); + mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument"); if (mpXmlBuffer) { xmlBufferFree(mpXmlBuffer); diff --git a/translations b/translations index 6ae868517d1d..69838a35694b 160000 --- a/translations +++ b/translations @@ -1 +1 @@ -Subproject commit 6ae868517d1dccf88fbcdb8cd815fe1c8eeba0f8 +Subproject commit 69838a35694be5b656df1ee0c5e5da0e0cc4373b diff --git a/unotest/inc/unotest/macros_test.hxx b/unotest/inc/unotest/macros_test.hxx index 1a82b83fc48f..c3eb7ff5629c 100644 --- a/unotest/inc/unotest/macros_test.hxx +++ b/unotest/inc/unotest/macros_test.hxx @@ -46,7 +46,7 @@ namespace unotest { class OOO_DLLPUBLIC_UNOTEST MacrosTest { public: - com::sun::star::uno::Reference< com::sun::star::lang::XComponent > loadFromDesktop(const rtl::OUString& rURL); + com::sun::star::uno::Reference< com::sun::star::lang::XComponent > loadFromDesktop(const OUString& rURL, const char* pDocService = NULL); protected: com::sun::star::uno::Reference< com::sun::star::frame::XDesktop2> mxDesktop; diff --git a/unotest/source/cpp/macros_test.cxx b/unotest/source/cpp/macros_test.cxx index 4d08d0488f65..be13798dd7d0 100644 --- a/unotest/source/cpp/macros_test.cxx +++ b/unotest/source/cpp/macros_test.cxx @@ -38,16 +38,25 @@ using namespace com::sun::star; namespace unotest { -uno::Reference< com::sun::star::lang::XComponent > MacrosTest::loadFromDesktop(const rtl::OUString& rURL) +uno::Reference< com::sun::star::lang::XComponent > MacrosTest::loadFromDesktop(const OUString& rURL, const char* pDocService) { uno::Reference< com::sun::star::frame::XComponentLoader> xLoader = uno::Reference< com::sun::star::frame::XComponentLoader >( mxDesktop, uno::UNO_QUERY ); com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > args(1); - args[0].Name = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode")); + args[0].Name = "MacroExecutionMode"; args[0].Handle = -1; args[0].Value <<= com::sun::star::document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN; args[0].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; + + if (pDocService) + { + args.realloc(2); + args[1].Name = "DocumentService"; + args[1].Handle = -1; + args[1].Value <<= OUString::createFromAscii(pDocService); + args[1].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; + } + uno::Reference< com::sun::star::lang::XComponent> xComponent= xLoader->loadComponentFromURL(rURL, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_default")), 0, args); rtl::OUString sMessage = rtl::OUString( "loading failed: " ) + rURL; CPPUNIT_ASSERT_MESSAGE(rtl::OUStringToOString( sMessage, RTL_TEXTENCODING_UTF8 ).getStr( ), xComponent.is()); -- cgit v1.2.3