summaryrefslogtreecommitdiffstats
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:29:46 +0100
commit516bc5f5e592dfeac9f25dd9c38298a455da3886 (patch)
tree4902871a66f39099e5fe822bdcc52c60c55dc562
parenttdf#144244: fix crash when FILESAVE a calc file after delete some columns (diff)
downloadcore-516bc5f5e592dfeac9f25dd9c38298a455da3886.tar.gz
core-516bc5f5e592dfeac9f25dd9c38298a455da3886.zip
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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126214 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--oox/source/drawingml/shape.cxx30
-rw-r--r--oox/source/token/properties.txt1
-rw-r--r--sd/qa/unit/data/pptx/tdfpictureplaceholder.pptxbin0 -> 28072 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx21
4 files changed, 52 insertions, 0 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index c2e97c5b947b..072bc59a4462 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -87,6 +87,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>
@@ -1338,6 +1339,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 980c1bb8c0f2..6b2b3b029177 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -529,6 +529,7 @@ TextBreak
TextCameraZRotateAngle
TextColor
TextColumns
+TextContourFrame
TextFitToSize
TextFrames
TextHorizontalAdjust
diff --git a/sd/qa/unit/data/pptx/tdfpictureplaceholder.pptx b/sd/qa/unit/data/pptx/tdfpictureplaceholder.pptx
new file mode 100644
index 000000000000..d681c749cab0
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdfpictureplaceholder.pptx
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 11a69d3afc29..a784e5ff2e32 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -39,6 +39,7 @@
#include <com/sun/star/style/LineSpacingMode.hpp>
#include <com/sun/star/frame/XLoadable.hpp>
#include <com/sun/star/text/XTextColumns.hpp>
+#include <com/sun/star/text/GraphicCrop.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
@@ -216,6 +217,7 @@ public:
void testTdf59323_slideFooters();
void testTdf143222_embeddedWorksheet();
void testTdf143315();
+ void testTdf140912_PicturePlaceholder();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
@@ -344,6 +346,7 @@ public:
CPPUNIT_TEST(testTdf59323_slideFooters);
CPPUNIT_TEST(testTdf143222_embeddedWorksheet);
CPPUNIT_TEST(testTdf143315);
+ CPPUNIT_TEST(testTdf140912_PicturePlaceholder);
CPPUNIT_TEST_SUITE_END();
@@ -3350,6 +3353,24 @@ void SdOOXMLExportTest2::testTdf143315()
assertXPath(pXml, "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr/a:buChar", 0);
}
+void SdOOXMLExportTest2::testTdf140912_PicturePlaceholder()
+{
+ ::sd::DrawDocShellRef xDocShRef = loadURL(
+ m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdfpictureplaceholder.pptx"), PPTX);
+
+ uno::Reference<beans::XPropertySet> xShapeProps(getShapeFromPage(0, 0, xDocShRef));
+
+ bool bTextContourFrame = true;
+ xShapeProps->getPropertyValue("TextContourFrame") >>= bTextContourFrame;
+ CPPUNIT_ASSERT_EQUAL(false, bTextContourFrame);
+
+ text::GraphicCrop aGraphicCrop;
+ xShapeProps->getPropertyValue("GraphicCrop") >>= aGraphicCrop;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-9429), aGraphicCrop.Top);
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
CPPUNIT_PLUGIN_IMPLEMENT();