oox/source/export/shapes.cxx | 18 +++++++++++++++++- sc/qa/unit/data/xlsx/textbox-hyperlink.xlsx |binary sc/qa/unit/subsequent_export-test.cxx | 21 ++++++++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-)
New commits: commit a7d843b6112250d1a41c2a56d8e083ccf6538bca Author: yogesh.bharate001 <yogesh.bhar...@synerzip.com> Date: Mon Apr 27 19:28:54 2015 +0530 tdf#90890: hyperlink inside textbox is not exported after roundtrip. Problem Description: - Text box hyperlink is not exported after roundtrip. XML Difference: in drawing1.xml Original file: <xdr:cNvPr id="2" name="TextBox 1"> <a:hlinkClick xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId1" tooltip="text123"/> </xdr:cNvPr> After RT: <xdr:cNvPr id="0" name="CustomShape 1"/> <a:hlinkClick> is missing. Change-Id: I01082de5d7d2e1a9323e84f54c97d5444cab13cd Solution: Added support for hyperlink in text box. Reviewed-on: https://gerrit.libreoffice.org/15555 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: David Tardon <dtar...@redhat.com> Tested-by: David Tardon <dtar...@redhat.com> diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 7caf3e9..349f398 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -419,10 +419,26 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape ) if (GetDocumentType() != DOCUMENT_DOCX) { pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND ); - pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, + pFS->startElementNS( mnXmlNamespace, XML_cNvPr, XML_id, I32S( GetNewShapeID( xShape ) ), XML_name, IDS( CustomShape ), FSEND ); + + if( GETA( URL ) ) + { + OUString sURL; + mAny >>= sURL; + if( !sURL.isEmpty() ) { + OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(), + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", + sURL, true ); + + mpFS->singleElementNS( XML_a, XML_hlinkClick, + FSNS( XML_r,XML_id ), USS( sRelId ), + FSEND ); + } + } + pFS->endElementNS(mnXmlNamespace, XML_cNvPr); pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND ); WriteNonVisualProperties( xShape ); pFS->endElementNS( mnXmlNamespace, XML_nvSpPr ); diff --git a/sc/qa/unit/data/xlsx/textbox-hyperlink.xlsx b/sc/qa/unit/data/xlsx/textbox-hyperlink.xlsx new file mode 100644 index 0000000..bbebca9 Binary files /dev/null and b/sc/qa/unit/data/xlsx/textbox-hyperlink.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index f8b5344..ecf39bd 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -137,6 +137,7 @@ public: void testSupBookVirtualPath(); void testSheetLocalRangeNameXLS(); + void testSheetTextBoxHyperlink(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -184,6 +185,7 @@ public: CPPUNIT_TEST(testLinkedGraphicRT); CPPUNIT_TEST(testImageWithSpecialID); CPPUNIT_TEST(testSheetLocalRangeNameXLS); + CPPUNIT_TEST(testSheetTextBoxHyperlink); CPPUNIT_TEST_SUITE_END(); @@ -209,7 +211,8 @@ void ScExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) { BAD_CAST("office"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0") }, { BAD_CAST("table"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:table:1.0") }, { BAD_CAST("text"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:text:1.0") }, - { BAD_CAST("xlink"), BAD_CAST("http://www.w3c.org/1999/xlink") } + { BAD_CAST("xlink"), BAD_CAST("http://www.w3c.org/1999/xlink") }, + { BAD_CAST("xdr"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing") } }; for(size_t i = 0; i < SAL_N_ELEMENTS(aNamespaces); ++i) { @@ -2517,6 +2520,22 @@ void ScExportTest::testSheetLocalRangeNameXLS() xDocSh2->DoClose(); } +void ScExportTest::testSheetTextBoxHyperlink() +{ + ScDocShellRef xShell = loadDoc("textbox-hyperlink.", XLSX); + CPPUNIT_ASSERT(xShell.Is()); + + ScDocShellRef xDocSh = saveAndReload(&(*xShell), XLSX); + CPPUNIT_ASSERT(xDocSh.Is()); + + xmlDocPtr pDoc = XPathHelper::parseExport(&(*xDocSh), m_xSFactory, "xl/drawings/drawing1.xml", XLSX); + CPPUNIT_ASSERT(pDoc); + + assertXPath(pDoc, "/xdr:wsDr[1]/xdr:twoCellAnchor[1]/xdr:sp[1]/xdr:nvSpPr[1]/xdr:cNvPr[1]/a:hlinkClick[1]", 1); + + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits