summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2021-10-18 14:51:05 +0200
committerLászló Németh <nemeth@numbertext.org>2021-11-03 15:01:31 +0100
commit4bfe8304a5600e236043e4ad7c6dc75fd05c937b (patch)
treedfb4b141927a264ceecd656fbc18454de3b536ff
parentac3266cccc3b65d1bfc1319d55fb0d1b35e96f65 (diff)
tdf#144914 PPTX export: fix interactions and hyperlinks on shapes
Follow-up to commit 83d92437e05a9ec872d9303953fa408dd4dcbcde "tdf#144616 PPTX import: fix hyperlinks on shapes" Change-Id: I56538da8d97e052af03c78e8d7eaa16c5c2fde1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123748 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--oox/source/export/shapes.cxx56
-rw-r--r--sd/qa/unit/export-tests-ooxml1.cxx45
2 files changed, 101 insertions, 0 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 1dd77a34b2ab..776f8df83472 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -837,6 +837,62 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId);
}
}
+
+ OUString sBookmark;
+ if (GETA(Bookmark))
+ mAny >>= sBookmark;
+
+ if (GETA(OnClick))
+ {
+ OUString sPPAction;
+ presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
+ mAny >>= eClickAction;
+ if (eClickAction != presentation::ClickAction_NONE)
+ {
+ switch (eClickAction)
+ {
+ case presentation::ClickAction_STOPPRESENTATION:
+ sPPAction = "ppaction://hlinkshowjump?jump=endshow";
+ break;
+ case presentation::ClickAction_NEXTPAGE:
+ sPPAction = "ppaction://hlinkshowjump?jump=nextslide";
+ break;
+ case presentation::ClickAction_LASTPAGE:
+ sPPAction = "ppaction://hlinkshowjump?jump=lastslide";
+ break;
+ case presentation::ClickAction_PREVPAGE:
+ sPPAction = "ppaction://hlinkshowjump?jump=previousslide";
+ break;
+ case presentation::ClickAction_FIRSTPAGE:
+ sPPAction = "ppaction://hlinkshowjump?jump=firstslide";
+ break;
+ case presentation::ClickAction_BOOKMARK:
+ sBookmark = "#" + sBookmark;
+ break;
+ default:
+ break;
+ }
+ }
+ if (!sPPAction.isEmpty())
+ pFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), "", XML_action,
+ sPPAction);
+ }
+ if (!sBookmark.isEmpty())
+ {
+ bool bExtURL = URLTransformer().isExternalURL(sBookmark);
+ sBookmark = bExtURL ? sBookmark : lcl_GetTarget(GetFB()->getModel(), sBookmark);
+
+ OUString sRelId
+ = mpFB->addRelation(mpFS->getOutputStream(),
+ bExtURL ? oox::getRelationship(Relationship::HYPERLINK)
+ : oox::getRelationship(Relationship::SLIDE),
+ sBookmark, bExtURL);
+ if (bExtURL)
+ mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId);
+ else
+ mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId,
+ XML_action, "ppaction://hlinksldjump");
+ }
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
WriteNonVisualProperties( xShape );
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index 07c0011bec40..a1512615ed8f 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -61,6 +61,7 @@ using namespace css;
class SdOOXMLExportTest1 : public SdModelTestBaseXML
{
public:
+ void testTdf144914();
void testTdf124232();
void testTdf143624();
void testTdf142648();
@@ -125,6 +126,7 @@ public:
CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
+ CPPUNIT_TEST(testTdf144914);
CPPUNIT_TEST(testTdf124232);
CPPUNIT_TEST(testTdf143624);
CPPUNIT_TEST(testTdf142648);
@@ -216,6 +218,49 @@ void checkFontAttributes( const SdrTextObj* pObj, ItemValue nVal, sal_uInt32 nId
}
+void SdOOXMLExportTest1::testTdf144914()
+{
+ sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf144616.pptx"), PPTX);
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+ xDocShRef->DoClose();
+
+ xmlDocUniquePtr pXmlDoc1 = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDoc1, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:nvSpPr/p:cNvPr/a:hlinkClick", "action",
+ "ppaction://hlinkshowjump?jump=firstslide");
+
+ xmlDocUniquePtr pXmlDoc2 = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDoc2, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:nvSpPr/p:cNvPr/a:hlinkClick", "action",
+ "ppaction://hlinkshowjump?jump=lastslide");
+
+ xmlDocUniquePtr pXmlDoc3 = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDoc3, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:nvSpPr/p:cNvPr/a:hlinkClick", "action",
+ "ppaction://hlinkshowjump?jump=nextslide");
+
+ xmlDocUniquePtr pXmlDoc4 = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDoc4, "/p:sld/p:cSld/p:spTree/p:sp[4]/p:nvSpPr/p:cNvPr/a:hlinkClick", "action",
+ "ppaction://hlinkshowjump?jump=previousslide");
+
+ xmlDocUniquePtr pXmlDoc5 = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDoc5, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:nvSpPr/p:cNvPr/a:hlinkClick", "action",
+ "ppaction://hlinksldjump");
+ xmlDocUniquePtr pRelsDoc5 = parseExport(tempFile, "ppt/slides/_rels/slide1.xml.rels");
+ assertXPath(pRelsDoc5, "/rels:Relationships/rels:Relationship[@Id='rId1']", "Target",
+ "slide2.xml");
+
+ xmlDocUniquePtr pXmlDoc6 = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDoc6, "/p:sld/p:cSld/p:spTree/p:sp[6]/p:nvSpPr/p:cNvPr/a:hlinkClick", "action",
+ "ppaction://hlinkshowjump?jump=endshow");
+
+ xmlDocUniquePtr pXmlDoc7 = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDoc7, "/p:sld/p:cSld/p:spTree/p:sp[7]/p:nvSpPr/p:cNvPr/a:hlinkClick", "id",
+ "rId2");
+ xmlDocUniquePtr pRelsDoc7 = parseExport(tempFile, "ppt/slides/_rels/slide1.xml.rels");
+ assertXPath(pRelsDoc7, "/rels:Relationships/rels:Relationship[@Id='rId2']", "Target",
+ "http://www.example.com/");
+}
+
void SdOOXMLExportTest1::testTdf124232()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf141704.pptx"), PPTX);