summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/test/calc_unoapi_test.hxx4
-rw-r--r--sc/qa/extras/macros-test.cxx22
-rw-r--r--sc/qa/unit/scshapetest.cxx15
-rw-r--r--sc/qa/unit/uicalc/uicalc.cxx57
-rw-r--r--test/source/calc_unoapi_test.cxx25
5 files changed, 46 insertions, 77 deletions
diff --git a/include/test/calc_unoapi_test.hxx b/include/test/calc_unoapi_test.hxx
index 369e48b877f2..5bca2c150f93 100644
--- a/include/test/calc_unoapi_test.hxx
+++ b/include/test/calc_unoapi_test.hxx
@@ -11,6 +11,7 @@
#define INCLUDED_TEST_CALC_UNOAPI_TEST_HXX
#include <test/unoapi_test.hxx>
+#include <unotools/tempfile.hxx>
// basic uno api test class for calc
@@ -25,6 +26,9 @@ public:
css::uno::Any executeMacro(const OUString& rScriptURL,
const css::uno::Sequence<css::uno::Any>& rParams = {});
+ utl::TempFileNamed save(const OUString& rFilter);
+ void saveAndReload(const OUString& rFilter);
+
protected:
// reference to document component that we are testing
css::uno::Reference<css::lang::XComponent> mxComponent;
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 2df09b8626af..c14490473124 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -41,7 +41,6 @@ protected:
void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override;
public:
ScMacrosTest();
- void saveAndReload(const OUString& rFilter);
void testStarBasic();
void testMSP();
@@ -118,19 +117,6 @@ void ScMacrosTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx)
XmlTestTools::registerODFNamespaces(pXmlXPathCtx);
}
-void ScMacrosTest::saveAndReload(const OUString& rFilter)
-{
- utl::TempFileNamed aTempFile;
- aTempFile.EnableKillingFile();
- css::uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName", rFilter) };
- css::uno::Reference<css::frame::XStorable> xStorable(mxComponent, css::uno::UNO_QUERY_THROW);
- xStorable->storeAsURL(aTempFile.GetURL(), aArgs);
- css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW);
- xCloseable->close(true);
-
- mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.sheet.SpreadsheetDocument");
-}
-
// I suppose you could say this test doesn't really belong here, OTOH
// we need a full document to run the test ( it related originally to an
// imported Excel VBA macro ) It's convenient and fast to unit test
@@ -267,13 +253,7 @@ void ScMacrosTest::testMacroButtonFormControlXlsxExport()
mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
// When exporting to XLSM:
- uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
- utl::MediaDescriptor aMediaDescriptor;
- aMediaDescriptor["FilterName"] <<= OUString("Calc MS Excel 2007 VBA XML");
- auto pTempFile = std::make_shared<utl::TempFileNamed>();
- pTempFile->EnableKillingFile();
- xStorable->storeToURL(pTempFile->GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
- mxComponent->dispose();
+ auto pTempFile = std::make_shared<utl::TempFileNamed>(save("Calc MS Excel 2007 VBA XML"));
// Then make sure that the macro is associated with the control:
xmlDocUniquePtr pSheetDoc = XPathHelper::parseExport(pTempFile, m_xSFactory, "xl/worksheets/sheet1.xml");
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 670f956862a0..364209883709 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -42,7 +42,6 @@ class ScShapeTest : public CalcUnoApiTest
{
public:
ScShapeTest();
- void saveAndReload(const OUString& rFilter);
void testTdf143619_validation_circle_pos();
void testTdf140252_DragCreateFormControl();
void testTdf134355_DragCreateCustomShape();
@@ -103,20 +102,6 @@ ScShapeTest::ScShapeTest()
{
}
-void ScShapeTest::saveAndReload(const OUString& rFilter)
-{
- utl::TempFileNamed aTempFile;
- aTempFile.EnableKillingFile();
- css::uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName",
- rFilter) }; // e.g. "calc8"
- css::uno::Reference<css::frame::XStorable> xStorable(mxComponent, css::uno::UNO_QUERY_THROW);
- xStorable->storeAsURL(aTempFile.GetURL(), aArgs);
- css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW);
- xCloseable->close(true);
-
- mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.sheet.SpreadsheetDocument");
-}
-
static void lcl_AssertRectEqualWithTolerance(std::string_view sInfo,
const tools::Rectangle& rExpected,
const tools::Rectangle& rActual,
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 992d694a1b60..28c46538030f 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -11,13 +11,11 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <svx/svdpage.hxx>
#include <unotools/syslocaleoptions.hxx>
-#include <unotools/tempfile.hxx>
#include <vcl/keycodes.hxx>
#include <vcl/scheduler.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
-#include <comphelper/propertyvalue.hxx>
#include <comphelper/scopeguard.hxx>
#include <com/sun/star/awt/Key.hpp>
#include <com/sun/star/frame/Desktop.hpp>
@@ -26,7 +24,6 @@
#include <conditio.hxx>
#include <dbdata.hxx>
#include <document.hxx>
-#include <docuno.hxx>
#include <docsh.hxx>
#include <dpobject.hxx>
#include <drwlayer.hxx>
@@ -44,10 +41,6 @@ class ScUiCalcTest : public CalcUnoApiTest
public:
ScUiCalcTest();
ScModelObj* createDoc(const char* pName = nullptr);
- utl::TempFileNamed save(css::uno::Reference<css::lang::XComponent>& xComponent,
- const OUString& rFilter);
- ScModelObj* saveAndReload(css::uno::Reference<css::lang::XComponent>& xComponent,
- const OUString& rFilter);
void goToCell(const OUString& rCell);
void typeString(ScModelObj& rModelObj, const std::u16string_view& rStr);
void insertStringToCell(ScModelObj& rModelObj, const OUString& rCell,
@@ -157,32 +150,6 @@ ScModelObj* ScUiCalcTest::createDoc(const char* pName)
return pModelObj;
}
-utl::TempFileNamed ScUiCalcTest::save(css::uno::Reference<css::lang::XComponent>& xComponent,
- const OUString& rFilter)
-{
- utl::TempFileNamed aTempFile;
- aTempFile.EnableKillingFile();
- css::uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName", rFilter) };
- css::uno::Reference<css::frame::XStorable> xStorable(xComponent, css::uno::UNO_QUERY_THROW);
- xStorable->storeAsURL(aTempFile.GetURL(), aArgs);
- css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW);
- xCloseable->close(true);
-
- return aTempFile;
-}
-
-ScModelObj* ScUiCalcTest::saveAndReload(css::uno::Reference<css::lang::XComponent>& xComponent,
- const OUString& rFilter)
-{
- utl::TempFileNamed aTempFile = save(xComponent, rFilter);
-
- mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.sheet.SpreadsheetDocument");
-
- ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
- CPPUNIT_ASSERT(pModelObj);
- return pModelObj;
-}
-
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf100847)
{
ScModelObj* pModelObj = createDoc();
@@ -190,7 +157,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf100847)
CPPUNIT_ASSERT(pDoc);
// Save the document
- utl::TempFileNamed aTempFile = save(mxComponent, "calc8");
+ utl::TempFileNamed aTempFile = save("calc8");
// Open a new document
mxComponent = loadFromDesktop("private:factory/scalc");
@@ -223,7 +190,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testExternalReferences)
insertStringToCell(*pModelObj, "D3", u"FISHY");
// Save the document
- utl::TempFileNamed aTempFile = save(mxComponent, "calc8");
+ utl::TempFileNamed aTempFile = save("calc8");
// Open a new document
mxComponent = loadFromDesktop("private:factory/scalc");
@@ -329,7 +296,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf103994)
insertStringToCell(*pModelObj, "B1", u"2");
// Save the document
- utl::TempFileNamed aTempFile = save(mxComponent, "calc8");
+ utl::TempFileNamed aTempFile = save("calc8");
// Open a new document
mxComponent = loadFromDesktop("private:factory/scalc");
@@ -371,7 +338,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf113541)
insertStringToCell(*pModelObj, "A1", u"50");
// Save the document
- utl::TempFileNamed aTempFile = save(mxComponent, "calc8");
+ utl::TempFileNamed aTempFile = save("calc8");
// Open a new document
mxComponent = loadFromDesktop("private:factory/scalc");
@@ -797,7 +764,9 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf124820)
dispatchCommand(mxComponent, ".uno:Strikeout", {});
Scheduler::ProcessEventsToIdle();
- pModelObj = saveAndReload(mxComponent, "Calc Office Open XML");
+ saveAndReload("Calc Office Open XML");
+ pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
+ CPPUNIT_ASSERT(pModelObj);
pDoc = pModelObj->GetDocument();
CPPUNIT_ASSERT(pDoc);
@@ -967,7 +936,9 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf143896)
CPPUNIT_ASSERT_EQUAL(OUString("Test"), pDoc->GetString(ScAddress(0, 1999, 0)));
- pModelObj = saveAndReload(mxComponent, "Calc Office Open XML");
+ saveAndReload("Calc Office Open XML");
+ pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
+ CPPUNIT_ASSERT(pModelObj);
pDoc = pModelObj->GetDocument();
CPPUNIT_ASSERT(pDoc);
@@ -1029,7 +1000,9 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf144244)
CPPUNIT_ASSERT_EQUAL(OUString("x"), pDoc->GetString(ScAddress(0, 0, 0)));
// Without the fix in place, this test would have crashed
- pModelObj = saveAndReload(mxComponent, "calc8");
+ saveAndReload("calc8");
+ pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
+ CPPUNIT_ASSERT(pModelObj);
pDoc = pModelObj->GetDocument();
CPPUNIT_ASSERT(pDoc);
@@ -1060,7 +1033,9 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf100582)
dispatchCommand(mxComponent, ".uno:Paste", {});
- pModelObj = saveAndReload(mxComponent, "MS Excel 97");
+ saveAndReload("MS Excel 97");
+ pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
+ CPPUNIT_ASSERT(pModelObj);
pDoc = pModelObj->GetDocument();
CPPUNIT_ASSERT(pDoc);
diff --git a/test/source/calc_unoapi_test.cxx b/test/source/calc_unoapi_test.cxx
index 1aaed35f3fb5..fc8cae982bea 100644
--- a/test/source/calc_unoapi_test.cxx
+++ b/test/source/calc_unoapi_test.cxx
@@ -10,6 +10,10 @@
#include <test/calc_unoapi_test.hxx>
#include <sfx2/objsh.hxx>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <comphelper/propertyvalue.hxx>
+
using namespace css;
using namespace css::uno;
@@ -49,4 +53,25 @@ uno::Any CalcUnoApiTest::executeMacro(const OUString& rScriptURL, const uno::Seq
return aRet;
}
+
+utl::TempFileNamed CalcUnoApiTest::save(const OUString& rFilter)
+{
+ utl::TempFileNamed aTempFile;
+ aTempFile.EnableKillingFile();
+ uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName", rFilter) };
+ css::uno::Reference<frame::XStorable> xStorable(mxComponent, css::uno::UNO_QUERY_THROW);
+ xStorable->storeAsURL(aTempFile.GetURL(), aArgs);
+ css::uno::Reference<util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW);
+ xCloseable->close(true);
+
+ return aTempFile;
+}
+
+void CalcUnoApiTest::saveAndReload(const OUString& rFilter)
+{
+ utl::TempFileNamed aTempFile = save(rFilter);
+
+ mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.sheet.SpreadsheetDocument");
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */