summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/qa/unit/data/xls/external-ref.xlsbin0 -> 5632 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx22
-rw-r--r--sc/source/filter/excel/xehelper.cxx10
3 files changed, 32 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xls/external-ref.xls b/sc/qa/unit/data/xls/external-ref.xls
new file mode 100644
index 000000000000..21f3338bd878
--- /dev/null
+++ b/sc/qa/unit/data/xls/external-ref.xls
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 988ed3447e45..ef3e8dce8403 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -125,6 +125,8 @@ public:
void testPivotTableXLSX();
void testPivotTableTwoDataFieldsXLSX();
+ void testSupBookVirtualPath();
+
CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test);
#if !defined(MACOSX) && !defined(DRAGONFLY)
@@ -164,6 +166,9 @@ public:
CPPUNIT_TEST(testPivotTableXLSX);
CPPUNIT_TEST(testPivotTableTwoDataFieldsXLSX);
CPPUNIT_TEST(testFunctionsExcel2010ODS);
+#if !defined(WNT)
+ CPPUNIT_TEST(testSupBookVirtualPath);
+#endif
CPPUNIT_TEST_SUITE_END();
@@ -2272,6 +2277,23 @@ void ScExportTest::tearDown()
test::BootstrapFixture::tearDown();
}
+void ScExportTest::testSupBookVirtualPath()
+{
+ ScDocShellRef xShell = loadDoc("external-ref.", XLS);
+ CPPUNIT_ASSERT(xShell.Is());
+
+ ScDocShellRef xDocSh = saveAndReload(xShell, XLS);
+ xShell->DoClose();
+ CPPUNIT_ASSERT(xDocSh.Is());
+
+ ScDocument& rDoc = xDocSh->GetDocument();
+
+ if (!checkFormula(rDoc, ScAddress(0,0,0), "'file:///home/timar/Documents/external.xls'#$Sheet1.A1"))
+ CPPUNIT_FAIL("Wrong SupBook VirtualPath URL");
+
+ xDocSh->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index 79da723f7a40..f58d19291866 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -908,6 +908,11 @@ OUString lclEncodeDosUrl(
aBuf.append(EXC_URL_DOSDRIVE).append(cDrive);
aOldUrl = aOldUrl.copy(3);
}
+ else
+ {
+ // URL probably points to a document on a Unix-like file system
+ aBuf.append(EXC_URL_DRIVEROOT);
+ }
// directories
sal_Int32 nPos = -1;
@@ -949,6 +954,11 @@ OUString lclEncodeDosUrl(
if (pTableName)
aBuf.append(*pTableName);
+ // VirtualPath must be shorter than 255 chars ([MS-XLS].pdf 2.5.277)
+ // It's better to truncate, than generate invalid file that Excel cannot open.
+ if (aBuf.getLength() > 255)
+ aBuf.setLength(255);
+
return aBuf.makeStringAndClear();
}