summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-07-09 14:11:58 +0000
committerJan-Marek Glogowski <glogow@fbihome.de>2019-07-09 20:15:56 +0200
commit3f1527fba7b9fe729e421322a9ea91a24aa495e0 (patch)
tree52caa58e16d58a93d0fc9fab60fc24a53f816a77 /sc/qa
parent5da29a31903e0c11802548327b41511519e61d7d (diff)
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@fbihome.de>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx23
1 files changed, 23 insertions, 0 deletions
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(".."));
}