Kaydet (Commit) 6a9cf9ba authored tarafından tundet's avatar tundet Kaydeden (comit) Katarina Behrens

tdf#91634 XLSX export: fix hyperlink inserted to image

Hyperlink inserted to image lost after export.

image_hyperlink.xlsx: Test file from Excel.

Change-Id: I8dc47528dafc8de5d1e01720697ef57f0ad9628d
Reviewed-on: https://gerrit.libreoffice.org/70248
Tested-by: Jenkins
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst 4ba6388c
......@@ -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
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment