vcl/qa/cppunit/pdfexport/pdfexport.cxx | 73 +++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 29 deletions(-)
New commits: commit d8c5fdcb3f1e2fdaacc6a7e403a2077d93207c82 Author: Dr. David Alan Gilbert <d...@treblig.org> AuthorDate: Sat Feb 19 15:13:01 2022 +0000 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Mar 9 14:05:03 2022 +0100 pdfwriter: Add check without relativeFsys Set relativeFsys on a per-test basis and add a test with relativeFsys off. Change-Id: I43b1d82200aca37b2cf8ac71d77a4aa61df543ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130197 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 60ac42adf707..35ca1c9bc051 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -3037,28 +3037,43 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testURIs) { OUString in; OString out; - } URIs[] = { { - "http://example.com/", - "http://example.com/", - }, - { - "file://localfile.odt/", - "file://localfile.odt/", - }, - { - "git://git.example.org/project/example", - "git://git.example.org/project/example", - }, - { - // The odt/pdf gets substituted due to 'ConvertOOoTargetToPDFTarget' - "filebypath.odt", - "filebypath.pdf", - }, - { - // This also gets made relative due to 'ExportLinksRelativeFsys' - utl::TempFile::GetTempNameBaseDirectory() + "fileintempdir.odt", - "fileintempdir.pdf", - } }; + bool relativeFsys; + } URIs[] + = { { + "http://example.com/", + "http://example.com/", + true, + }, + { + "file://localfile.odt/", + "file://localfile.odt/", + true, + }, + { + "git://git.example.org/project/example", + "git://git.example.org/project/example", + true, + }, + { + // The odt/pdf gets substituted due to 'ConvertOOoTargetToPDFTarget' + "filebypath.odt", + "filebypath.pdf", + true, + }, + { + // The odt/pdf gets substituted due to 'ConvertOOoTargetToPDFTarget' + // but this time with ExportLinksRelativeFsys off the path is added + "filebypath.odt", + OUStringToOString(utl::TempFile::GetTempNameBaseDirectory(), RTL_TEXTENCODING_UTF8) + + "filebypath.pdf", + false, + }, + { + // This also gets made relative due to 'ExportLinksRelativeFsys' + utl::TempFile::GetTempNameBaseDirectory() + "fileintempdir.odt", + "fileintempdir.pdf", + true, + } }; // Create an empty document. // Note: The test harness gets very upset if we try and create multiple @@ -3073,15 +3088,15 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testURIs) uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); xModel->attachResource(maTempFile.GetURL(), xModel->getArgs()); - // Test the filename rewriting - uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({ - { "ExportLinksRelativeFsys", uno::makeAny(true) }, - { "ConvertOOoTargetToPDFTarget", uno::makeAny(true) }, - })); - aMediaDescriptor["FilterData"] <<= aFilterData; - for (unsigned int i = 0; i < (sizeof(URIs) / sizeof(URIs[0])); i++) { + // Test the filename rewriting + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({ + { "ExportLinksRelativeFsys", uno::makeAny(URIs[i].relativeFsys) }, + { "ConvertOOoTargetToPDFTarget", uno::makeAny(true) }, + })); + aMediaDescriptor["FilterData"] <<= aFilterData; + // Add a link (based on testNestedHyperlink in rtfexport3) xCursor->gotoStart(/*bExpand=*/false); xCursor->gotoEnd(/*bExpand=*/true);