diff options
-rw-r--r-- | include/xmloff/shapeimport.hxx | 4 | ||||
-rw-r--r-- | xmloff/source/draw/eventimp.cxx | 30 | ||||
-rw-r--r-- | xmloff/source/draw/eventimp.hxx | 25 | ||||
-rw-r--r-- | xmloff/source/draw/shapeimport.cxx | 23 |
4 files changed, 53 insertions, 29 deletions
diff --git a/include/xmloff/shapeimport.hxx b/include/xmloff/shapeimport.hxx index 4412d26e07d6..a20154a70387 100644 --- a/include/xmloff/shapeimport.hxx +++ b/include/xmloff/shapeimport.hxx @@ -215,6 +215,7 @@ public: struct XMLShapeImportHelperImpl; struct XMLShapeImportPageContextImpl; +struct SdXMLEventContextData; class XMLOFF_DLLPUBLIC XMLShapeImportHelper : public salhelper::SimpleReferenceObject { @@ -307,6 +308,9 @@ public: const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList, css::uno::Reference< css::drawing::XShapes >& rShapes); + // tdf#127791 help function for group shape events + void addShapeEvents(SdXMLEventContextData& rData); + // helper functions for z-order sorting void pushGroupForSorting( css::uno::Reference< css::drawing::XShapes >& rShapes ); void popGroupAndSort(); diff --git a/xmloff/source/draw/eventimp.cxx b/xmloff/source/draw/eventimp.cxx index ccb93c379aba..f9e10c11cf7d 100644 --- a/xmloff/source/draw/eventimp.cxx +++ b/xmloff/source/draw/eventimp.cxx @@ -21,8 +21,6 @@ #include <com/sun/star/container/XNameReplace.hpp> #include <com/sun/star/presentation/AnimationSpeed.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/xml/sax/XAttributeList.hpp> -#include <com/sun/star/presentation/ClickAction.hpp> #include <tools/urlobj.hxx> #include <osl/diagnose.h> #include <sal/log.hxx> @@ -35,7 +33,6 @@ #include <xmloff/xmluconv.hxx> #include <xmloff/nmspmap.hxx> #include "eventimp.hxx" -#include <anim.hxx> using namespace ::std; using namespace ::cppu; @@ -70,31 +67,6 @@ SvXMLEnumMapEntry<ClickAction> const aXML_EventActions_EnumMap[] = { XML_TOKEN_INVALID, ClickAction(0) } }; -class SdXMLEventContextData -{ -private: - css::uno::Reference< css::drawing::XShape > mxShape; - -public: - SdXMLEventContextData(const Reference< XShape >& rxShape); - - void ApplyProperties(); - - bool mbValid; - bool mbScript; - ClickAction meClickAction; - XMLEffect meEffect; - XMLEffectDirection meDirection; - sal_Int16 mnStartScale; - AnimationSpeed meSpeed; - sal_Int32 mnVerb; - OUString msSoundURL; - bool mbPlayFull; - OUString msMacroName; - OUString msBookmark; - OUString msLanguage; -}; - SdXMLEventContextData::SdXMLEventContextData(const Reference< XShape >& rxShape) : mxShape(rxShape), mbValid(false), mbScript(false) , meClickAction(ClickAction_NONE), meEffect(EK_none) @@ -268,7 +240,7 @@ SvXMLImportContextRef SdXMLEventContext::CreateChildContext( sal_uInt16 nPrefix, void SdXMLEventContext::EndElement() { - maData.ApplyProperties(); + GetImport().GetShapeImport()->addShapeEvents(maData); } void SdXMLEventContextData::ApplyProperties() diff --git a/xmloff/source/draw/eventimp.hxx b/xmloff/source/draw/eventimp.hxx index 5f7937a529b3..7388407058d0 100644 --- a/xmloff/source/draw/eventimp.hxx +++ b/xmloff/source/draw/eventimp.hxx @@ -22,6 +22,9 @@ #include <xmloff/xmlictxt.hxx> #include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/presentation/ClickAction.hpp> +#include <com/sun/star/presentation/AnimationSpeed.hpp> +#include <anim.hxx> // office:events inside a shape @@ -43,6 +46,28 @@ public: const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override; }; +struct SdXMLEventContextData +{ + SdXMLEventContextData(const css::uno::Reference<css::drawing::XShape>& rxShape); + void ApplyProperties(); + + css::uno::Reference<css::drawing::XShape> mxShape; + + bool mbValid; + bool mbScript; + css::presentation::ClickAction meClickAction; + XMLEffect meEffect; + XMLEffectDirection meDirection; + sal_Int16 mnStartScale; + css::presentation::AnimationSpeed meSpeed; + sal_Int32 mnVerb; + OUString msSoundURL; + bool mbPlayFull; + OUString msMacroName; + OUString msBookmark; + OUString msLanguage; +}; + #endif // INCLUDED_XMLOFF_SOURCE_DRAW_EVENTIMP_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx index 6708e48e73dc..2f8faf02ae30 100644 --- a/xmloff/source/draw/shapeimport.cxx +++ b/xmloff/source/draw/shapeimport.cxx @@ -35,6 +35,7 @@ #include <xmloff/xmltoken.hxx> #include <xmloff/table/XMLTableImport.hxx> #include <xmloff/attrlist.hxx> +#include "eventimp.hxx" #include "ximpshap.hxx" #include "sdpropls.hxx" #include <xmloff/xmlprmap.hxx> @@ -708,6 +709,7 @@ class ShapeSortContext { public: uno::Reference< drawing::XShapes > mxShapes; + std::vector<SdXMLEventContextData> maEventData; vector<ZOrderHint> maZOrderList; vector<ZOrderHint> maUnsortedList; @@ -759,6 +761,14 @@ void ShapeSortContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos ) // sort shapes void ShapeSortContext::popGroupAndSort() { + if (!maEventData.empty()) + { + // tdf#127791 wait until a group is popped to set its event data + for (auto& event : maEventData) + event.ApplyProperties(); + maEventData.clear(); + } + // only do something if we have shapes to sort if( maZOrderList.empty() ) return; @@ -860,6 +870,19 @@ void XMLShapeImportHelper::pushGroupForSorting( uno::Reference< drawing::XShapes mpImpl->mpSortContext = std::make_shared<ShapeSortContext>( rShapes, mpImpl->mpSortContext ); } +void XMLShapeImportHelper::addShapeEvents(SdXMLEventContextData& rData) +{ + if (mpImpl->mpSortContext && mpImpl->mpSortContext->mxShapes == rData.mxShape) + { + // tdf#127791 wait until a group is popped to set its event data so + // that the events are applied to all its children, which are not available + // at the start of the group tag + mpImpl->mpSortContext->maEventData.push_back(rData); + } + else + rData.ApplyProperties(); +} + void XMLShapeImportHelper::popGroupAndSort() { SAL_WARN_IF( !mpImpl->mpSortContext, "xmloff", "No context to sort!" ); |