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-10 12:18:29 +0200
commitc86cf2aaa07538e8c37dc81729905a3bb9ecc1ff (patch)
treeccf989aacdbb0718784518e34a9c942d66b569f7 /oox
parent96dd1cd36c2f9446d3455a06b5f77a3954950c03 (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>
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 76e5e9089a35..e8e661e64d51 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>
@@ -314,6 +315,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 41c8d9493dcf..64c80568f7a8 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -128,6 +128,7 @@ Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight )
, mbFlipV( false )
, mbHidden( false )
, mbHiddenMasterShape( false )
+, mbLocked( false )
, mbLockedCanvas( false )
, mbWps( false )
, mbTextBox( false )
@@ -171,6 +172,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 )
@@ -335,6 +337,7 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
mbFlipH = rReferencedShape.mbFlipH;
mbFlipV = rReferencedShape.mbFlipV;
mbHidden = rReferencedShape.mbHidden;
+ mbLocked = rReferencedShape.mbLocked;
}
struct ActionLockGuard
@@ -856,6 +859,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 3035a390a36f..41cf6973b492 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -434,6 +434,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();
}