sw/qa/extras/ooxmlexport/ooxmllinks.cxx | 48 ++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 20 deletions(-)
New commits: commit 4253acd5300c526b062fc5b5f109e93e6e9d08df Author: Miklos Vajna <[email protected]> AuthorDate: Wed Jan 31 07:11:05 2024 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Wed Jan 31 08:15:27 2024 +0100 CppunitTest_sw_ooxmllinks: avoid DECLARE_LINKS_EXPORT_TEST at one place Reduce the amount of code that's inside the macro body, and then no need go via Writer-specific macros. Change-Id: I6a09754f04e3103195b0ca585c820ddc98efd4ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162787 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx index ccc08515644d..d58952cb6b5f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx @@ -32,24 +32,7 @@ if (!bUseTempDir) \ return; \ \ - uno::Reference<text::XTextRange> xParagraph = getParagraph(1); \ - /* can be changed only after import */ \ - uno::Reference<text::XTextRange> xText = getRun(xParagraph, 1); \ - \ - /* Get original link */ \ - OUString sOriginalFileName = getProperty<OUString>(xText, "HyperLinkURL"); \ - INetURLObject aOriginalURL(sOriginalFileName); \ - CPPUNIT_ASSERT(!aOriginalURL.HasError()); \ - OUString sFileName = aOriginalURL.GetLastName(); \ - CPPUNIT_ASSERT(!sFileName.isEmpty()); \ - \ - /* Get temp path */ \ - OUString sTempDir = utl::GetTempNameBaseDirectory(); \ - \ - /* Create & apply new URL */ \ - OUString sOriginalFileInTempDir = sTempDir + sFileName; \ - uno::Reference<beans::XPropertySet> xPropertySet(xText, css::uno::UNO_QUERY); \ - xPropertySet->setPropertyValue("HyperLinkURL", css::uno::Any(sOriginalFileInTempDir)); \ + UseTempDir(); \ } \ \ public: \ @@ -82,6 +65,28 @@ public: officecfg::Office::Common::Save::URL::FileSystem::set(!bAbsolute, xChanges); xChanges->commit(); } + + void UseTempDir() + { + uno::Reference<text::XTextRange> xParagraph = getParagraph(1); + /* can be changed only after import */ + uno::Reference<text::XTextRange> xText = getRun(xParagraph, 1); + + /* Get original link */ + OUString sOriginalFileName = getProperty<OUString>(xText, "HyperLinkURL"); + INetURLObject aOriginalURL(sOriginalFileName); + CPPUNIT_ASSERT(!aOriginalURL.HasError()); + OUString sFileName = aOriginalURL.GetLastName(); + CPPUNIT_ASSERT(!sFileName.isEmpty()); + + /* Get temp path */ + OUString sTempDir = utl::GetTempNameBaseDirectory(); + + /* Create & apply new URL */ + OUString sOriginalFileInTempDir = sTempDir + sFileName; + uno::Reference<beans::XPropertySet> xPropertySet(xText, css::uno::UNO_QUERY); + xPropertySet->setPropertyValue("HyperLinkURL", css::uno::Any(sOriginalFileInTempDir)); + } }; /* IMPORT */ @@ -142,9 +147,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf123627_import) /* EXPORT */ -DECLARE_LINKS_EXPORT_TEST(testRelativeToRelativeExport, "relative-link.docx", USE_RELATIVE, - USE_TEMP_DIR) +CPPUNIT_TEST_FIXTURE(Test, testRelativeToRelativeExport) { + SetAbsolute(USE_RELATIVE); + createSwDoc("relative-link.docx"); + UseTempDir(); + saveAndReload(mpFilter); xmlDocUniquePtr pXmlDoc = parseExport("word/_rels/document.xml.rels"); assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[@TargetMode='External']"_ostr,
