diff options
Diffstat (limited to 'sfx2/qa/cppunit/doc.cxx')
-rw-r--r-- | sfx2/qa/cppunit/doc.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sfx2/qa/cppunit/doc.cxx b/sfx2/qa/cppunit/doc.cxx index 01e8fd7f2000..058bf4788d67 100644 --- a/sfx2/qa/cppunit/doc.cxx +++ b/sfx2/qa/cppunit/doc.cxx @@ -17,6 +17,9 @@ #include <comphelper/propertyvalue.hxx> #include <sfx2/objsh.hxx> #include <sfx2/sfxbasemodel.hxx> +#include <unotools/tempfile.hxx> +#include <sfx2/docfile.hxx> +#include <osl/file.hxx> using namespace com::sun::star; @@ -74,6 +77,34 @@ CPPUNIT_TEST_FIXTURE(Test, testNoGrabBagShape) // which was not caught later, resulting in a crash. pObjectShell->GetSignPDFCertificate(); } + +CPPUNIT_TEST_FIXTURE(Test, testTempFilePath) +{ + // Create a test file in a directory that contains the URL-encoded "testÿ" string. + getComponent() = loadFromDesktop("private:factory/swriter"); + auto pBaseModel = dynamic_cast<SfxBaseModel*>(getComponent().get()); + CPPUNIT_ASSERT(pBaseModel); + OUString aTargetDir + = m_directories.getURLFromWorkdir(u"CppunitTest/sfx2_doc.test.user/test%25C3%25Bf"); + osl::Directory::create(aTargetDir); + OUString aTargetFile = aTargetDir + "/test.odt"; + css::uno::Sequence<css::beans::PropertyValue> aArgs{ comphelper::makePropertyValue( + "FilterName", OUString("writer8")) }; + pBaseModel->storeAsURL(aTargetFile, aArgs); + getComponent()->dispose(); + + // Load it and export to PDF. + getComponent() = loadFromDesktop(aTargetFile); + pBaseModel = dynamic_cast<SfxBaseModel*>(getComponent().get()); + OUString aPdfTarget = aTargetDir + "/test.pdf"; + css::uno::Sequence<css::beans::PropertyValue> aPdfArgs{ comphelper::makePropertyValue( + "FilterName", OUString("writer_pdf_Export")) }; + // Without the accompanying fix in place, this test would have failed on Windows with: + // An uncaught exception of type com.sun.star.io.IOException + // because we first tried to create a temp file next to test.odt in a directory named + // "test%25C3%25Bf" instead of a directory named "test%C3%Bf". + pBaseModel->storeToURL(aPdfTarget, aPdfArgs); +} } CPPUNIT_PLUGIN_IMPLEMENT(); |