summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorGrzegorz Araminowicz <grzegorz.araminowicz@collabora.com>2019-05-08 21:49:34 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-05-31 16:46:22 +0200
commit3235ae697e1ae90e218f5c3bee280659d8a74a60 (patch)
treeb441a9a64d817c97a00979ab2c640600f53df7d7 /oox
parent1124e98e935cec42c51f25f1fc713285b1044d07 (diff)
SmartArt: support diagram background
Solved by adding additional shape filling whole diagram. MS PowerPoint does the same when converting SmartArt to shapes. Background shape is also copied when loading from drawingML fallback, appearently there is no background information. Corrected SmartArt import tests, so that they are aware of extra shape. Change-Id: I6154f8e1b34e5867ab582d6fc54459c7c93edbac Reviewed-on: https://gerrit.libreoffice.org/72012 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/73250
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/diagram/diagram.cxx11
-rw-r--r--oox/source/drawingml/shape.cxx9
-rw-r--r--oox/source/shape/ShapeContextHandler.cxx8
3 files changed, 28 insertions, 0 deletions
diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx
index d1de1c72f94d..8efefe139dbf 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -29,6 +29,7 @@
#include <drawingml/textrun.hxx>
#include <drawingml/diagram/diagram.hxx>
#include <drawingml/fillproperties.hxx>
+#include <drawingml/customshapeproperties.hxx>
#include <oox/ppt/pptshapegroupcontext.hxx>
#include <oox/ppt/pptshape.hxx>
#include <oox/token/namespaces.hxx>
@@ -317,6 +318,16 @@ void Diagram::addTo( const ShapePtr & pParentShape )
ShapeLayoutingVisitor aLayoutingVisitor;
mpLayout->getNode()->accept(aLayoutingVisitor);
}
+
+ ShapePtr pBackground(new Shape("com.sun.star.drawing.CustomShape"));
+ pBackground->setSubType(XML_rect);
+ pBackground->getCustomShapeProperties()->setShapePresetType(XML_rect);
+ pBackground->setSize(pParentShape->getSize());
+ pBackground->getFillProperties() = *mpData->getFillProperties();
+ pBackground->setLocked(true);
+ auto& aChildren = pParentShape->getChildren();
+ aChildren.insert(aChildren.begin(), pBackground);
+
pParentShape->setDiagramDoms( getDomsAsPropertyValues() );
}
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 4848f4086e02..23e9537f4b32 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -127,6 +127,7 @@ Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight )
, mbFlipV( false )
, mbHidden( false )
, mbHiddenMasterShape( false )
+, mbLocked( false )
, mbLockedCanvas( false )
, mbWps( false )
, mbTextBox( false )
@@ -170,6 +171,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
, mbFlipV( pSourceShape->mbFlipV )
, mbHidden( pSourceShape->mbHidden )
, mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
+, mbLocked( pSourceShape->mbLocked )
, mbLockedCanvas( pSourceShape->mbLockedCanvas )
, mbWps( pSourceShape->mbWps )
, mbTextBox( pSourceShape->mbTextBox )
@@ -333,6 +335,7 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
mbFlipH = rReferencedShape.mbFlipH;
mbFlipV = rReferencedShape.mbFlipV;
mbHidden = rReferencedShape.mbHidden;
+ mbLocked = rReferencedShape.mbLocked;
}
struct ActionLockGuard
@@ -858,6 +861,12 @@ Reference< XShape > const & Shape::createAndInsert(
xSet->setPropertyValue( sPrintable, Any( false ) );
}
+ if (mbLocked)
+ {
+ xSet->setPropertyValue("MoveProtect", Any(true));
+ xSet->setPropertyValue("SizeProtect", Any(true));
+ }
+
ActionLockGuard const alg(mxShape);
// sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 2747572f0479..e6feaa818c69 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -428,6 +428,14 @@ ShapeContextHandler::getShape()
pShapePtr->setDiagramDoms(mpShape->getDiagramDoms());
pShapePtr->keepDiagramDrawing(*mxFilterBase, aFragmentPath);
+ if (!mpShape->getChildren().empty())
+ {
+ // first child is diagram background - we want to keep it, as drawingML fallback doesn't contain it
+ auto& aChildren = pShapePtr->getChildren();
+ ShapePtr pBackground = mpShape->getChildren().front();
+ aChildren.insert(aChildren.begin(), pBackground);
+ }
+
pShapePtr->addShape( *mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShapePtr->getFillProperties() );
xResult = pShapePtr->getXShape();
}