summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2019-06-20 16:52:20 +0200
committerXisco Faulí <xiscofauli@libreoffice.org>2019-06-26 08:26:57 +0200
commit861ee491b0bf3ca1c18336924017911a1823cc31 (patch)
treefec03faf36209c64ab253c7bdeec126c8572f73b /sc
parentca19c39695558092e943d2db7aec3d39bdfe17e1 (diff)
tdf#126024 XLSX export: fix hyperlink on formula cell
Hyperlink on formula cell lost after export. Change-Id: I682c8bb559b5adde84b350f79c35a2e769f106ec Reviewed-on: https://gerrit.libreoffice.org/74457 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 1bdbdc6ebcdba2784dcfa56b50632c4706ba14b5) Reviewed-on: https://gerrit.libreoffice.org/74713 Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/xlsx/hyperlink_formula.xlsxbin0 -> 9472 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx18
-rw-r--r--sc/source/filter/excel/xetable.cxx11
3 files changed, 29 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/hyperlink_formula.xlsx b/sc/qa/unit/data/xlsx/hyperlink_formula.xlsx
new file mode 100644
index 000000000000..77ae2bdc7f7b
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/hyperlink_formula.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 416fb9f32139..9d628f97faa9 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -224,6 +224,7 @@ public:
void testTdf123645XLSX();
void testTdf125173XLSX();
void testTdf79972XLSX();
+ void testTdf126024XLSX();
void testXltxExport();
@@ -353,6 +354,7 @@ public:
CPPUNIT_TEST(testTdf123645XLSX);
CPPUNIT_TEST(testTdf125173XLSX);
CPPUNIT_TEST(testTdf79972XLSX);
+ CPPUNIT_TEST(testTdf126024XLSX);
CPPUNIT_TEST(testXltxExport);
@@ -4419,6 +4421,22 @@ void ScExportTest::testTdf79972XLSX()
assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "TargetMode", "External");
}
+void ScExportTest::testTdf126024XLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("hyperlink_formula.", FORMAT_XLSX);
+ CPPUNIT_ASSERT(xDocSh.is());
+ std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX);
+
+ xmlDocPtr pDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
+ CPPUNIT_ASSERT(pDoc);
+ assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink", "ref", "A2");
+
+ xmlDocPtr pXmlRels = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/_rels/sheet1.xml.rels");
+ CPPUNIT_ASSERT(pXmlRels);
+ assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "Target", "https://bugs.documentfoundation.org/");
+ assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "TargetMode", "External");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index c8a34cd89faf..d7a3adf8f7e6 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2581,6 +2581,17 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) :
case CELLTYPE_FORMULA:
{
+ if (pPattern)
+ {
+ OUString aUrl = pPattern->GetItemSet().Get(ATTR_HYPERLINK).GetValue();
+ if (!aUrl.isEmpty())
+ {
+ std::shared_ptr<XclExpHyperlink> aLink;
+ aLink.reset(new XclExpHyperlink(GetRoot(), SvxURLField(aUrl, aUrl), aScPos));
+ mxHyperlinkList->AppendRecord(aLink);
+ }
+ }
+
xCell.reset(new XclExpFormulaCell(
GetRoot(), aXclPos, pPattern, nMergeBaseXFId,
*rScCell.mpFormula, maArrayBfr, maShrfmlaBfr, maTableopBfr));