[Libreoffice-commits] core.git: sc/qa
Jan-Marek Glogowski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jul 9 18:17:06 UTC 2019
sc/qa/unit/subsequent_export-test.cxx | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
New commits:
commit 3f1527fba7b9fe729e421322a9ea91a24aa495e0
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Tue Jul 9 14:11:58 2019 +0000
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Tue Jul 9 20:15:56 2019 +0200
tdf#126255 handle _WIN32 with different drive letters
Copying the source comment: if the exported document is not on the
same drive then the linked document, there is no way to get a
relative URL for the link, because ../X:/ is undefined.
Change-Id: Ic83be54d878f968daa027918ce0f588774044a94
Reviewed-on: https://gerrit.libreoffice.org/75306
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 473be4c8593b..ed7ad9df3269 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -3073,6 +3073,17 @@ void ScExportTest::testCustomXml()
CPPUNIT_ASSERT(pStream);
}
+#ifdef _WIN32
+static sal_Unicode lcl_getWindowsDrive(const OUString& aURL)
+{
+ static const sal_Int32 nMinLen = strlen("file:///X:/");
+ if (aURL.getLength() <= nMinLen)
+ return 0;
+ const OUString aUrlStart = aURL.copy(0, nMinLen);
+ return (aUrlStart.startsWith("file:///") && aUrlStart.endsWith(":/")) ? aUrlStart[8] : 0;
+}
+#endif
+
void ScExportTest::testRelativePathsODS()
{
ScDocShellRef xDocSh = loadDoc("fdo79305.", FORMAT_ODS);
@@ -3082,6 +3093,18 @@ void ScExportTest::testRelativePathsODS()
CPPUNIT_ASSERT(pDoc);
OUString aURL = getXPath(pDoc,
"/office:document-content/office:body/office:spreadsheet/table:table/table:table-row[2]/table:table-cell[2]/text:p/text:a", "href");
+#ifdef _WIN32
+ // if the exported document is not on the same drive then the linked document,
+ // there is no way to get a relative URL for the link, because ../X:/ is undefined.
+ if (!aURL.startsWith(".."))
+ {
+ sal_Unicode aDocDrive = lcl_getWindowsDrive(xDocSh->getDocumentBaseURL());
+ sal_Unicode aLinkDrive = lcl_getWindowsDrive(aURL);
+ CPPUNIT_ASSERT_MESSAGE("document on the same drive but no relative link!",
+ aDocDrive != 0 && aLinkDrive != 0 && aDocDrive != aLinkDrive);
+ return;
+ }
+#endif
// make sure that the URL is relative
CPPUNIT_ASSERT(aURL.startsWith(".."));
}
More information about the Libreoffice-commits
mailing list