diff options
Diffstat (limited to 'oox/source')
-rw-r--r-- | oox/source/ppt/pptshape.cxx | 143 |
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)); + } } } } |