libreoffice/bsc1172189.diff
Tomáš Chvátal bd52313473 Accepting request 813391 from LibreOffice:6.4
- Fix bsc#1172189 - LO-L3: Impress crashes midway opening a PPTX document
  * bsc1172189.diff

- Fix bsc#1157627 - LO-L3: Some XML-created shapes simply lost upon PPTX import (= earth loses countries)
  * bsc1157627.diff

OBS-URL: https://build.opensuse.org/request/show/813391
OBS-URL: https://build.opensuse.org/package/show/LibreOffice:Factory/libreoffice?expand=0&rev=885
2020-06-11 07:20:30 +00:00

77 lines
3.6 KiB
Diff

From 3c5f6a7f81c5882de6bcd0afcc528e8643d95f35 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.com>
Date: Wed, 10 Jun 2020 11:07:43 +0200
Subject: [PATCH] PPTX import: handle adjust values from both the shape and its
placeholder
The direct problem is a crash in CustomShapeProperties::pushToPropSet(),
the code just hoped that the input file doesn't have more adjust values
than the # of adjust values we allocate based on the preset type. Fix
the crash, but there is a deeper problem here...
The shape can inherit custom shape properties from a placeholder, then
later it can have its own custom shape properties. When it comes to
adjust values specifically, we used to just append own adjust values to
the end of the list. This way we got the double of expected adjust
values. And later rendering took the N expected adjust values from
the start of the 2N element list, so we used the adjust values of the
placeholder, not of the actual shape.
Fix this by clearing the custom shape geometry once we know we have our
own preset geometry.
(cherry picked from commit 408ec7a4470741edbedbb034de07a2d776348593)
Change-Id: I09f669bf59c33b552b906733d323eba7af5548e7
---
oox/qa/unit/data/preset-adjust-value.pptx | Bin 0 -> 33233 bytes
oox/qa/unit/drawingml.cxx | 30 +++++++++++++++++-
.../drawingml/customshapeproperties.cxx | 6 +++-
.../drawingml/shapepropertiescontext.cxx | 5 +++
4 files changed, 39 insertions(+), 2 deletions(-)
create mode 100644 oox/qa/unit/data/preset-adjust-value.pptx
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
index 2f4848088cc4..4a6e3d9eae6d 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -206,7 +206,11 @@ void CustomShapeProperties::pushToPropSet(
aAdjustmentVal.Value <<= adjustmentGuide.maFormula.toInt32();
aAdjustmentVal.State = PropertyState_DIRECT_VALUE;
aAdjustmentVal.Name = adjustmentGuide.maName;
- aAdjustmentSeq[ nIndex++ ] = aAdjustmentVal;
+ if (nIndex < aAdjustmentSeq.getLength())
+ {
+ aAdjustmentSeq[nIndex] = aAdjustmentVal;
+ ++nIndex;
+ }
}
}
rGeoProp.Value <<= aAdjustmentSeq;
diff --git a/oox/source/drawingml/shapepropertiescontext.cxx b/oox/source/drawingml/shapepropertiescontext.cxx
index ffedcfa5bf13..eedc338a25e4 100644
--- a/oox/source/drawingml/shapepropertiescontext.cxx
+++ b/oox/source/drawingml/shapepropertiescontext.cxx
@@ -34,6 +34,7 @@
#include <oox/helper/attributelist.hxx>
#include <oox/token/namespaces.hxx>
#include <oox/token/tokens.hxx>
+#include <drawingml/customshapeproperties.hxx>
using namespace oox::core;
using namespace ::com::sun::star;
@@ -77,6 +78,10 @@ ContextHandlerRef ShapePropertiesContext::onCreateContext( sal_Int32 aElementTok
{
mrShape.getServiceName() = "com.sun.star.drawing.CustomShape";
}
+
+ // We got a preset geometry, forget the geometry inherited from the placeholder shape.
+ mrShape.getCustomShapeProperties() = std::make_shared<CustomShapeProperties>();
+
return new PresetShapeGeometryContext( *this, rAttribs, *(mrShape.getCustomShapeProperties()) );
}
--
2.26.2