[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - include/oox oox/qa oox/source

2022-01-09 Thread Sarper Akdemir (via logerrit)
 include/oox/export/drawingml.hxx|6 ++-
 oox/qa/unit/data/camera-rotation-revolution-nonwps.pptx |binary
 oox/qa/unit/drawingml.cxx   |   26 ++
 oox/qa/unit/export.cxx  |   29 
 oox/source/drawingml/shape.cxx  |9 ++--
 oox/source/export/drawingml.cxx |   28 +++
 oox/source/export/shapes.cxx|4 +-
 7 files changed, 73 insertions(+), 29 deletions(-)

New commits:
commit 00ad4d5c38bb3d71eb0d8929dcb4b9485aacf933
Author: Sarper Akdemir 
AuthorDate: Mon Jan 3 05:45:17 2022 +0300
Commit: Miklos Vajna 
CommitDate: Mon Jan 10 08:49:23 2022 +0100

tdf#146534 pptx import: make Z rotation work with rotation transform

Expands previous idea from a9c5c0d814a266096483572b84c72875ef8efd77
(tdf#133037 OOXML shape import: camera rotation along Z)
and uses it also for shapes that have a true bUseRotationTransform flag

Also fixes same Z rotation exporting twice from InteropGrabBag to
both spPr and textBody causing text overrotating on roundtrip.

Change-Id: If0f192af029ca86b932a63613f961be1f5003c5b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127880
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit 8bdd134bef3baca2ebd878163af4e55e5f898efe)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127956
Tested-by: Jenkins CollaboraOffice 

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 594371db81b4..b5759cfbc560 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -313,7 +313,11 @@ public:
 void WriteShapeStyle( const css::uno::Reference< css::beans::XPropertySet 
>& rXPropSet );
 void WriteShapeEffects( const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet );
 void WriteShapeEffect( const OUString& sName, const css::uno::Sequence< 
css::beans::PropertyValue >& aEffectProps );
-void WriteShape3DEffects( const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet );
+/** Populates scene3d tag
+@param rXPropSet Prop set
+@param bIsText True if the 3D effects are for a text body, false if it 
is for a shape
+ */
+void Write3DEffects(const css::uno::Reference& 
rXPropSet, bool bIsText);
 void WriteArtisticEffect( const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet );
 OString WriteWdpPicture( const OUString& rFileId, const 
css::uno::Sequence< sal_Int8 >& rPictureData );
 void WriteDiagram(const css::uno::Reference& 
rXShape, int nDiagramId);
diff --git a/oox/qa/unit/data/camera-rotation-revolution-nonwps.pptx 
b/oox/qa/unit/data/camera-rotation-revolution-nonwps.pptx
new file mode 100755
index ..db26dc032caa
Binary files /dev/null and 
b/oox/qa/unit/data/camera-rotation-revolution-nonwps.pptx differ
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index a72f84d76b32..3362acb3c8c6 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -292,6 +292,32 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, 
testCameraRotationRevolution)
 CPPUNIT_ASSERT_EQUAL(static_cast(27000), nRotateAngle1);
 }
 
+CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, 
testTdf146534_CameraRotationRevolutionNonWpsShapes)
+{
+OUString aURL
+= m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"camera-rotation-revolution-nonwps.pptx";
+load(aURL);
+
+uno::Reference 
xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+uno::Reference 
xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+uno::Reference xShape0(xDrawPage->getByIndex(0), 
uno::UNO_QUERY);
+uno::Reference xShape1(xDrawPage->getByIndex(1), 
uno::UNO_QUERY);
+uno::Reference xShapeProps0(xShape0, uno::UNO_QUERY);
+uno::Reference xShapeProps1(xShape1, uno::UNO_QUERY);
+sal_Int32 nRotateAngle0;
+sal_Int32 nRotateAngle1;
+xShapeProps0->getPropertyValue("RotateAngle") >>= nRotateAngle0;
+xShapeProps1->getPropertyValue("RotateAngle") >>= nRotateAngle1;
+
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 9000
+// - Actual  : 0
+// so the camera rotation would not have been factored into how the shape 
is displayed
+CPPUNIT_ASSERT_EQUAL(static_cast(9000), nRotateAngle0);
+CPPUNIT_ASSERT_EQUAL(static_cast(30500), nRotateAngle1);
+}
+
 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testTableShadow)
 {
 auto verify = [](const uno::Reference& xComponent) {
diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index 5db14c35d03b..897eec7284b6 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -105,6 +105,8 @@ void Test::registerNamespaces(xmlXPathContextPtr& 
pXmlXpathCtx)

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - include/oox oox/qa oox/source

2021-12-17 Thread Miklos Vajna (via logerrit)
 include/oox/vml/vmlshape.hxx   |6 ++
 oox/qa/unit/data/watermark.docx|binary
 oox/qa/unit/vml.cxx|   22 ++
 oox/source/vml/vmlshape.cxx|7 +++
 oox/source/vml/vmlshapecontext.cxx |   28 
 5 files changed, 63 insertions(+)

New commits:
commit f21f0f0ff656880149cfdfd34b8984c9541bca24
Author: Miklos Vajna 
AuthorDate: Thu Dec 16 10:16:02 2021 +0100
Commit: Mike Kaganski 
CommitDate: Fri Dec 17 11:57:24 2021 +0100

VML import: handle 

Map it to (the UNO API of) GraphicDrawMode::Watermark, similar to what
the binary import does in SvxMSDffManager::ImportGraphic() and how the
drawingML import does it in
oox::drawingml::GraphicProperties::pushToPropMap().

On export, the drawingML export is used, and that already maps
GraphicDrawMode::Watermark to .

(cherry picked from commit 90556b6df0f6378fb60d7dee18b2f5d275ece530)

Conflicts:
oox/qa/unit/vml.cxx

Change-Id: I33986a03bf3d3863da5c5b1f0a2e0da0fa595c9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126949
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Mike Kaganski 

diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx
index 0e50e5b6ee1f..ad001c3e6e41 100644
--- a/include/oox/vml/vmlshape.hxx
+++ b/include/oox/vml/vmlshape.hxx
@@ -113,6 +113,12 @@ struct ShapeTypeModel
 OptValue moCropTop; ///< Specifies how much to crop the image 
from the top down as a fraction of picture size.
 OUString maLayoutFlowAlt; ///< Specifies the alternate layout flow for 
text in textboxes.
 
+/// An adjustment for the intensity of all colors, i.e. contrast, on a 
0..0x1 scale.
+sal_Int32 mnGain = 0x1;
+
+/// The image brightness, on a 0..0x1 scale.
+sal_Int16 mnBlacklevel = 0;
+
 explicitShapeTypeModel();
 
 voidassignUsed( const ShapeTypeModel& rSource );
diff --git a/oox/qa/unit/data/watermark.docx b/oox/qa/unit/data/watermark.docx
new file mode 100644
index ..c9eacff9a643
Binary files /dev/null and b/oox/qa/unit/data/watermark.docx differ
diff --git a/oox/qa/unit/vml.cxx b/oox/qa/unit/vml.cxx
index d75372da39ae..680e55fb093a 100644
--- a/oox/qa/unit/vml.cxx
+++ b/oox/qa/unit/vml.cxx
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 
@@ -145,6 +146,27 @@ CPPUNIT_TEST_FIXTURE(OoxVmlTest, testGraphicStroke)
 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID, eLineStyle);
 }
 
+CPPUNIT_TEST_FIXTURE(OoxVmlTest, testWatermark)
+{
+// Given a document with a picture watermark, and the "washout" checkbox 
is ticked on the Word
+// UI:
+// When loading that document:
+load(u"watermark.docx");
+
+// Then make sure the watermark effect is not lost on import:
+uno::Reference 
xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+uno::Reference 
xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+uno::Reference xShape(xDrawPage->getByIndex(0), 
uno::UNO_QUERY);
+drawing::ColorMode eMode{};
+xShape->getPropertyValue("GraphicColorMode") >>= eMode;
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 3
+// - Actual  : 0
+// i.e. the color mode was STANDARD, not WATERMARK.
+CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_WATERMARK, eMode);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 4ce5ffb30a34..52390b5e8166 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -977,6 +978,12 @@ Reference< XShape > SimpleShape::createPictureObject(const 
Reference< XShapes >&
 
 aPropSet.setProperty(PROP_GraphicCrop, aGraphicCrop);
 }
+
+if (maTypeModel.mnGain == -70 && maTypeModel.mnBlacklevel == 70)
+{
+// Map MSO 'washout' to our watermark colormode.
+aPropSet.setProperty(PROP_GraphicColorMode, 
uno::makeAny(drawing::ColorMode_WATERMARK));
+}
 }
 return xShape;
 }
diff --git a/oox/source/vml/vmlshapecontext.cxx 
b/oox/source/vml/vmlshapecontext.cxx
index e8f1b0b1910e..b511a968396c 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -385,6 +385,34 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( 
sal_Int32 nElement, const A
 mrTypeModel.moCropLeft = rAttribs.getString(XML_cropleft);
 mrTypeModel.moCropRight = rAttribs.getString(XML_cropright);
 mrTypeModel.moCropTop = rAttribs.getString(XML_croptop);
+
+// Gain / contrast.
+OptValue oGain = rAttribs.getString(XML_gain);
+