summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oox/source/export/shapes.cxx19
-rw-r--r--sc/qa/unit/data/xlsx/image_hyperlink.xlsxbin0 -> 17868 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx18
3 files changed, 33 insertions, 4 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index d615d2ec32da..0b28f58003a7 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1133,13 +1133,15 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
pFS->startElementNS( mnXmlNamespace, XML_nvPicPr, FSEND );
- OUString sName, sDescr;
- bool bHaveName, bHaveDesc;
+ OUString sName, sDescr, sURL;
+ bool bHaveName, bHaveDesc, bHaveURL;
if ( ( bHaveName= GetProperty( xShapeProps, "Name" ) ) )
mAny >>= sName;
if ( ( bHaveDesc = GetProperty( xShapeProps, "Description" ) ) )
mAny >>= sDescr;
+ if ( ( bHaveURL = GetProperty( xShapeProps, "URL" ) ) )
+ mAny >>= sURL;
pFS->startElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
@@ -1149,19 +1151,28 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
XML_descr, bHaveDesc ? sDescr.toUtf8().getStr() : nullptr,
FSEND );
- // OOXTODO: //cNvPr children: XML_extLst, XML_hlinkClick, XML_hlinkHover
+ // OOXTODO: //cNvPr children: XML_extLst, XML_hlinkHover
if (bHasMediaURL)
pFS->singleElementNS(XML_a, XML_hlinkClick,
FSNS(XML_r, XML_id), "",
XML_action, "ppaction://media",
FSEND);
+ if( !sURL.isEmpty() )
+ {
+ OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
+ oox::getRelationship(Relationship::HYPERLINK),
+ mpURLTransformer->getTransformedString(sURL),
+ mpURLTransformer->isExternalURL(sURL));
+ mpFS->singleElementNS( XML_a, XML_hlinkClick,
+ FSNS( XML_r,XML_id ), USS( sRelId ),
+ FSEND );
+ }
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS( mnXmlNamespace, XML_cNvPicPr,
// OOXTODO: XML_preferRelativeSize
FSEND );
-
if (bHasMediaURL)
WriteMediaNonVisualProperties(xShape);
else
diff --git a/sc/qa/unit/data/xlsx/image_hyperlink.xlsx b/sc/qa/unit/data/xlsx/image_hyperlink.xlsx
new file mode 100644
index 000000000000..dd7afe725adb
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/image_hyperlink.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 9ce85f021ccb..159152871adf 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -212,6 +212,7 @@ public:
void testPivotCacheAfterExportXLSX();
void testTdf114969XLSX();
void testTdf115192XLSX();
+ void testTdf91634XLSX();
void testXltxExport();
@@ -331,6 +332,7 @@ public:
CPPUNIT_TEST(testPivotCacheAfterExportXLSX);
CPPUNIT_TEST(testTdf114969XLSX);
CPPUNIT_TEST(testTdf115192XLSX);
+ CPPUNIT_TEST(testTdf91634XLSX);
CPPUNIT_TEST(testXltxExport);
@@ -4186,6 +4188,22 @@ void ScExportTest::testTdf115192XLSX()
assertXPath(pDoc, "/r:Relationships/r:Relationship[@Id='rId3']", "TargetMode", "External");
}
+void ScExportTest::testTdf91634XLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("image_hyperlink.", 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/drawings/drawing1.xml");
+ CPPUNIT_ASSERT(pDoc);
+ assertXPath(pDoc, "/xdr:wsDr/xdr:twoCellAnchor/xdr:pic/xdr:nvPicPr/xdr:cNvPr/a:hlinkClick", 1);
+
+ xmlDocPtr pXmlRels = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/_rels/drawing1.xml.rels");
+ CPPUNIT_ASSERT(pXmlRels);
+ assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId1']", "Target", "https://www.google.com/");
+ assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId1']", "TargetMode", "External");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();