From 007bf2b8c04090920b54e914ac75fc13720b450c Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sat, 14 Dec 2013 11:14:39 +0100 Subject: utl::TempFile should not be copied Change-Id: I35d0c96d52b490ef70a0238e715d874f0ecd1012 --- chart2/qa/extras/chart2export.cxx | 4 ++-- chart2/qa/extras/charttest.hxx | 19 +++++++++++-------- include/unotools/tempfile.hxx | 4 ++++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 6c0f54925837..8088894c6ba6 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -85,10 +85,10 @@ void Chart2ExportTest::test() xmlDocPtr Chart2ExportTest::parseExport(const OUString& rStreamName, const OUString& rFilterFormat) { - utl::TempFile aTempFile = reload(rFilterFormat); + boost::shared_ptr pTempFile = reload(rFilterFormat); // Read the XML stream we're interested in. - uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), aTempFile.GetURL()); + uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), pTempFile->GetURL()); uno::Reference xInputStream(xNameAccess->getByName(rStreamName), uno::UNO_QUERY); CPPUNIT_ASSERT(xInputStream.is()); boost::shared_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream, sal_True)); diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index b50f4fd6cd0f..def88c313aac 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -43,6 +43,9 @@ #include #include +#include +#include + using namespace com::sun::star; using namespace com::sun::star::uno; @@ -51,7 +54,7 @@ class ChartTest : public test::BootstrapFixture, public unotest::MacrosTest { public: void load( const OUString& rDir, const OUString& rFileName ); - utl::TempFile reload( const OUString& rFileName ); + boost::shared_ptr reload( const OUString& rFileName ); uno::Sequence < OUString > getImpressChartColumnDescriptions( const char* pDir, const char* pName ); OUString getFileExtension( const OUString& rFileName ); @@ -88,20 +91,20 @@ void ChartTest::load( const OUString& aDir, const OUString& aName ) CPPUNIT_ASSERT(mxComponent.is()); } -utl::TempFile ChartTest::reload(const OUString& rFilterName) +boost::shared_ptr ChartTest::reload(const OUString& rFilterName) { uno::Reference xStorable(mxComponent, uno::UNO_QUERY); uno::Sequence aArgs(1); aArgs[0].Name = "FilterName"; aArgs[0].Value <<= rFilterName; - utl::TempFile aTempFile; - aTempFile.EnableKillingFile(); - xStorable->storeToURL(aTempFile.GetURL(), aArgs); + boost::shared_ptr pTempFile = boost::make_shared(); + pTempFile->EnableKillingFile(); + xStorable->storeToURL(pTempFile->GetURL(), aArgs); mxComponent->dispose(); - mxComponent = loadFromDesktop(aTempFile.GetURL(), maServiceName); - std::cout << aTempFile.GetURL(); + mxComponent = loadFromDesktop(pTempFile->GetURL(), maServiceName); + std::cout << pTempFile->GetURL(); CPPUNIT_ASSERT(mxComponent.is()); - return aTempFile; + return pTempFile; } void ChartTest::setUp() diff --git a/include/unotools/tempfile.hxx b/include/unotools/tempfile.hxx index 85eda3dc75bd..26c0581c73ff 100644 --- a/include/unotools/tempfile.hxx +++ b/include/unotools/tempfile.hxx @@ -49,6 +49,10 @@ class UNOTOOLS_DLLPUBLIC TempFile TempFile_Impl* pImp; bool bKillingFileEnabled; + // prevent copy c'tor + TempFile( const TempFile& ); + TempFile& operator=(const TempFile&); + protected: public: -- cgit