[Libreoffice-commits] core.git: oox/source sc/qa
tundet (via logerrit)
logerrit at kemper.freedesktop.org
Sat Apr 6 07:27:50 UTC 2019
oox/source/export/shapes.cxx | 19 +++++++++++++++----
sc/qa/unit/data/xlsx/image_hyperlink.xlsx |binary
sc/qa/unit/subsequent_export-test.cxx | 18 ++++++++++++++++++
3 files changed, 33 insertions(+), 4 deletions(-)
New commits:
commit 6a9cf9ba2d37fee9b7c2f190b347e0d7c4a2676a
Author: tundet <tundeth at gmail.com>
AuthorDate: Thu Apr 4 12:25:33 2019 +0200
Commit: Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Sat Apr 6 09:27:29 2019 +0200
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: Katarina Behrens <Katarina.Behrens at cib.de>
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
Binary files /dev/null and b/sc/qa/unit/data/xlsx/image_hyperlink.xlsx 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();
More information about the Libreoffice-commits
mailing list