summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2021-10-06 09:31:37 +0200
committerLászló Németh <nemeth@numbertext.org>2021-10-20 12:30:21 +0200
commit378e8396223a80b96262d7b638a066eb83ba88d6 (patch)
tree64c842ba0d235f00689b0f7d59d4d5dcef5d567b /oox
parent649e29e53f9a79d8695b31b9a848fba14d6b583d (diff)
tdf#144917 PPTX import: fix hyperlinks on grouped shapes
Hyperlinks on the shapes of a group shape weren't imported. Now all of them are imported correctly. Change-Id: Ic42892650a3492958600232bd7038585f9aa6ae1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123127 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/ppt/pptshape.cxx143
1 files changed, 80 insertions, 63 deletions
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index bbc7d2585fd8..2a134ada4a0c 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -518,6 +518,8 @@ void PPTShape::addShape(
}
}
+ OUString sURL;
+ std::vector<std::pair<OUString, Reference<XShape>>> aURLShapes;
// if this is a group shape, we have to add also each child shape
Reference<XShapes> xShapes(xShape, UNO_QUERY);
if (xShapes.is())
@@ -531,6 +533,15 @@ void PPTShape::addShape(
{
rFilterBase.setDiagramFontHeights(nullptr);
}
+ for (size_t i = 0; i < this->getChildren().size(); i++)
+ {
+ this->getChildren()[i]->getShapeProperties().getProperty(PROP_URL) >>= sURL;
+ if (!sURL.isEmpty())
+ {
+ Reference<XShape> xChild = this->getChildren()[i]->getXShape();
+ aURLShapes.push_back({ sURL, xChild });
+ }
+ }
}
if (meFrameType == FRAMETYPE_DIAGRAM)
@@ -539,77 +550,83 @@ void PPTShape::addShape(
syncDiagramFontHeights();
}
- OUString sURL;
getShapeProperties().getProperty(PROP_URL) >>= sURL;
- if (!sURL.isEmpty())
+ if (!sURL.isEmpty() && !xShapes.is())
+ aURLShapes.push_back({ sURL, xShape });
+
+ if (!aURLShapes.empty())
{
- Reference<XEventsSupplier> xEventsSupplier(xShape, UNO_QUERY);
- if (!xEventsSupplier.is())
- return;
-
- Reference<XNameReplace> xEvents(xEventsSupplier->getEvents());
- if (!xEvents.is())
- return;
-
- OUString sAPIEventName;
- sal_Int32 nPropertyCount = 2;
- css::presentation::ClickAction meClickAction;
- uno::Sequence<beans::PropertyValue> aProperties;
-
- std::map<OUString, css::presentation::ClickAction> ActionMap = {
- { "#action?jump=nextslide", ClickAction_NEXTPAGE },
- { "#action?jump=previousslide", ClickAction_PREVPAGE },
- { "#action?jump=firstslide", ClickAction_FIRSTPAGE },
- { "#action?jump=lastslide", ClickAction_LASTPAGE },
- { "#action?jump=endshow", ClickAction_STOPPRESENTATION },
- };
-
- std::map<OUString, css::presentation::ClickAction>::const_iterator aIt
- = ActionMap.find(sURL);
- aIt != ActionMap.end() ? meClickAction = aIt->second
- : meClickAction = ClickAction_BOOKMARK;
-
- // ClickAction_BOOKMARK and ClickAction_DOCUMENT share the same event
- // so check here if it's a bookmark or a document
- if (meClickAction == ClickAction_BOOKMARK)
+ for (auto const& URLShape : aURLShapes)
{
- if (!sURL.startsWith("#"))
- meClickAction = ClickAction_DOCUMENT;
- else
- sURL = sURL.copy(1);
- nPropertyCount += 1;
- }
+ Reference<XEventsSupplier> xEventsSupplier(URLShape.second, UNO_QUERY);
+ if (!xEventsSupplier.is())
+ return;
+
+ Reference<XNameReplace> xEvents(xEventsSupplier->getEvents());
+ if (!xEvents.is())
+ return;
+
+ OUString sAPIEventName;
+ sal_Int32 nPropertyCount = 2;
+ css::presentation::ClickAction meClickAction;
+ uno::Sequence<beans::PropertyValue> aProperties;
+
+ std::map<OUString, css::presentation::ClickAction> ActionMap = {
+ { "#action?jump=nextslide", ClickAction_NEXTPAGE },
+ { "#action?jump=previousslide", ClickAction_PREVPAGE },
+ { "#action?jump=firstslide", ClickAction_FIRSTPAGE },
+ { "#action?jump=lastslide", ClickAction_LASTPAGE },
+ { "#action?jump=endshow", ClickAction_STOPPRESENTATION },
+ };
+
+ sURL = URLShape.first;
+ std::map<OUString, css::presentation::ClickAction>::const_iterator aIt
+ = ActionMap.find(sURL);
+ aIt != ActionMap.end() ? meClickAction = aIt->second
+ : meClickAction = ClickAction_BOOKMARK;
+
+ // ClickAction_BOOKMARK and ClickAction_DOCUMENT share the same event
+ // so check here if it's a bookmark or a document
+ if (meClickAction == ClickAction_BOOKMARK)
+ {
+ if (!sURL.startsWith("#"))
+ meClickAction = ClickAction_DOCUMENT;
+ else
+ sURL = sURL.copy(1);
+ nPropertyCount += 1;
+ }
- aProperties.realloc(nPropertyCount);
- beans::PropertyValue* pProperties = aProperties.getArray();
+ aProperties.realloc(nPropertyCount);
+ beans::PropertyValue* pProperties = aProperties.getArray();
- pProperties->Name = "EventType";
- pProperties->Handle = -1;
- pProperties->Value <<= OUString("Presentation");
- pProperties->State = beans::PropertyState_DIRECT_VALUE;
- pProperties++;
+ pProperties->Name = "EventType";
+ pProperties->Handle = -1;
+ pProperties->Value <<= OUString("Presentation");
+ pProperties->State = beans::PropertyState_DIRECT_VALUE;
+ pProperties++;
- pProperties->Name = "ClickAction";
- pProperties->Handle = -1;
- pProperties->Value <<= meClickAction;
- pProperties->State = beans::PropertyState_DIRECT_VALUE;
- pProperties++;
+ pProperties->Name = "ClickAction";
+ pProperties->Handle = -1;
+ pProperties->Value <<= meClickAction;
+ pProperties->State = beans::PropertyState_DIRECT_VALUE;
+ pProperties++;
- switch (meClickAction)
- {
- case ClickAction_BOOKMARK:
- case ClickAction_DOCUMENT:
- pProperties->Name = "Bookmark";
- pProperties->Handle = -1;
- pProperties->Value <<= sURL;
- pProperties->State = beans::PropertyState_DIRECT_VALUE;
- break;
- default:
- break;
- }
+ switch (meClickAction)
+ {
+ case ClickAction_BOOKMARK:
+ case ClickAction_DOCUMENT:
+ pProperties->Name = "Bookmark";
+ pProperties->Handle = -1;
+ pProperties->Value <<= sURL;
+ pProperties->State = beans::PropertyState_DIRECT_VALUE;
+ break;
+ default:
+ break;
+ }
- sAPIEventName = "OnClick";
- xEvents->replaceByName(sAPIEventName, uno::Any(aProperties));
+ sAPIEventName = "OnClick";
+ xEvents->replaceByName(sAPIEventName, uno::Any(aProperties));
+ }
}
}
}