summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorgulsahkose <gulsah.kose@collabora.com>2021-12-01 10:46:41 +0300
committerMiklos Vajna <vmiklos@collabora.com>2021-12-03 09:30:01 +0100
commit0fa00d879995d498d1f04efe72f3413a3c15601b (patch)
tree334018c20ed701b77843f6009e421cc4c5c275c9 /oox
parent7d9bc58315f4d94c63a19d1d9b900e452c03a7ca (diff)
tdf#140912 Better handling of the picture placeholders.
To see icon and placeholder text at the center of picture placeholder shape, we set the TextContourFrame and GraphicCrop properties. Change-Id: I49e3d08c9020e593232c60c97af3f45fb620075e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126165 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit 7b3be7f6f3d800e2ad86f5a043e6e9b21ed4409f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126141
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/shape.cxx30
-rw-r--r--oox/source/token/properties.txt1
2 files changed, 31 insertions, 0 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 9aed4d3588d0..78a27f8a0c9c 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -88,6 +88,7 @@
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <com/sun/star/document/XActionLockable.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/text/GraphicCrop.hpp>
#include <svx/svdtrans.hxx>
#include <tools/stream.hxx>
#include <unotools/streamwrap.hxx>
@@ -1337,6 +1338,35 @@ Reference< XShape > const & Shape::createAndInsert(
propertySet->setPropertyValue("InteropGrabBag",uno::makeAny(aGrabBag));
}
+ // If the shape is a picture placeholder.
+ if (aServiceName == "com.sun.star.presentation.GraphicObjectShape" && !bClearText)
+ {
+ // Placeholder text should be in center of the shape.
+ aShapeProps.setProperty(PROP_TextContourFrame, false);
+
+ /* Placeholder icon should be at the center of the parent shape.
+ * We use negative graphic crop property because of that we don't
+ * have padding support.
+ */
+ uno::Reference<beans::XPropertySet> xGraphic(xSet->getPropertyValue("Graphic"), uno::UNO_QUERY);
+ if (xGraphic.is())
+ {
+ awt::Size aBitmapSize;
+ xGraphic->getPropertyValue("Size100thMM") >>= aBitmapSize;
+ sal_Int32 nXMargin = (aShapeRectHmm.Width - aBitmapSize.Width) / 2;
+ sal_Int32 nYMargin = (aShapeRectHmm.Height - aBitmapSize.Height) / 2;
+ if (nXMargin > 0 && nYMargin > 0)
+ {
+ text::GraphicCrop aGraphicCrop;
+ aGraphicCrop.Top = nYMargin * -1;
+ aGraphicCrop.Bottom = nYMargin * -1;
+ aGraphicCrop.Left = nXMargin * -1;
+ aGraphicCrop.Right = nXMargin * -1;
+ aShapeProps.setProperty(PROP_GraphicCrop, aGraphicCrop);
+ }
+ }
+ }
+
PropertySet( xSet ).setProperties( aShapeProps );
if (mbLockedCanvas)
{
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 5d261469ca42..87a6700bd35a 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -541,6 +541,7 @@ TextBreak
TextCameraZRotateAngle
TextColor
TextColumns
+TextContourFrame
TextFitToSize
TextFrames
TextHorizontalAdjust