summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-11-12 13:25:44 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-11-12 20:51:21 +0100
commit03edebda393ea684803b7a0da72f33655bdc24d1 (patch)
tree361ad0de28b6423ca8a1b5003ba8631dad23bd2c /xmloff
parent63c5a1e2aa9e39633c3e644df0d8d9f8cedfc10e (diff)
tdf#127791 defer import of group shape events until the group is popped
otherwise the group shape import applies the events over the children it has when it reads the events which is 0. We already push and pop groups for sorting so reuse that to store and apply the events to groups Change-Id: I3f31796f9e8d3d11df6f3ba12a32be920a228155 Reviewed-on: https://gerrit.libreoffice.org/82516 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/draw/eventimp.cxx30
-rw-r--r--xmloff/source/draw/eventimp.hxx25
-rw-r--r--xmloff/source/draw/shapeimport.cxx23
3 files changed, 49 insertions, 29 deletions
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!" );