File bsc1178944.diff of Package libreoffice

From 0f064c28b4d733b3e1b7bee4515015a40cf3b1cc Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.com>
Date: Tue, 1 Dec 2020 15:16:13 +0100
Subject: [PATCH] bsc1178944.diff

This is a combination of 3 commits.
This is the 1st commit message:

tdf#129961 svx: add UNO API for table shadow as direct format

Adding it via a style was working already.

(cherry picked from commit 55d4c6cfe5bd9b737698c6cd1f28ee8234abb5d0)

Conflicts:
	svx/source/unodraw/unoprov.cxx

This is the commit message #2:

tdf#129961 svx: add rendering for table shadow as direct format

There was already shadow support in
ViewContactOfTableObj::createViewIndependentPrimitive2DSequence(), but
the UNO API and UI could only set the shadow properties on a shape
style, so shadow-as-direct-format is new.

One difference between the PowerPoint shadow and our shadow is that we
draw shadow for table text as well, while PowerPoint only does it for
the borders / cell fill style.

This means we're either backwards-compatible or compatible with
PowerPoint. Solve this problem by leaving the style case unchanged, but
render direct formatting like PowerPoint.

(cherry picked from commit a75bf43a8d6c5dec6dcc86908c142ceec541aa8c)

Conflicts:
	svx/source/sdr/primitive2d/sdrdecompositiontools.cxx

This is the commit message #3:

tdf#129961 oox: add PPTX import for table shadow as direct format

PPTX export and ODP filter is still missing.

(cherry picked from commit b273e82aaa916b0f6198097dc32740faced73741)

Conflicts:
	oox/qa/unit/drawingml.cxx

Change-Id: I451b334ada80d9d228b7d7f36b5f26473b575ef6
---
 oox/source/drawingml/table/tablecontext.cxx   |  5 +++
 .../sdr/primitive2d/sdrdecompositiontools.hxx |  3 +-
 .../sdr/primitive2d/sdrdecompositiontools.cxx |  5 +--
 svx/source/table/viewcontactoftableobj.cxx    | 34 ++++++++++++++++++-
 svx/source/unodraw/unoprov.cxx                |  1 +
 5 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/oox/source/drawingml/table/tablecontext.cxx b/oox/source/drawingml/table/tablecontext.cxx
index bbfc94845369..fc2a59c1fa10 100644
--- a/oox/source/drawingml/table/tablecontext.cxx
+++ b/oox/source/drawingml/table/tablecontext.cxx
@@ -24,6 +24,7 @@
 #include <drawingml/table/tableproperties.hxx>
 #include <drawingml/table/tablestylecontext.hxx>
 #include <drawingml/table/tablerowcontext.hxx>
+#include "../effectpropertiescontext.hxx"
 #include <oox/token/namespaces.hxx>
 #include <oox/token/tokens.hxx>
 
@@ -66,6 +67,10 @@ TableContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& r
             rTableStyle = std::make_shared<TableStyle>();
             return new TableStyleContext( *this, rAttribs, *rTableStyle );
         }
+    case A_TOKEN( effectLst ):  // CT_EffectList
+        {
+            return new EffectPropertiesContext(*this, mpShapePtr->getEffectProperties());
+        }
     case A_TOKEN( tableStyleId ):       // ST_Guid
         return new oox::drawingml::GuidContext( *this, mrTableProperties.getStyleId() );
 
diff --git a/svx/inc/sdr/primitive2d/sdrdecompositiontools.hxx b/svx/inc/sdr/primitive2d/sdrdecompositiontools.hxx
index e619206303ca..9e8b9fdfe14c 100644
--- a/svx/inc/sdr/primitive2d/sdrdecompositiontools.hxx
+++ b/svx/inc/sdr/primitive2d/sdrdecompositiontools.hxx
@@ -72,7 +72,8 @@ namespace drawinglayer
         Primitive2DContainer SVXCORE_DLLPUBLIC createEmbeddedShadowPrimitive(
             const Primitive2DContainer& rContent,
             const attribute::SdrShadowAttribute& rShadow,
-            const basegfx::B2DHomMatrix& rObjectMatrix = basegfx::B2DHomMatrix());
+            const basegfx::B2DHomMatrix& rObjectMatrix = basegfx::B2DHomMatrix(),
+            const Primitive2DContainer* pContentForShadow = nullptr);
 
         Primitive2DContainer SVXCORE_DLLPUBLIC createEmbeddedGlowPrimitive(
             const Primitive2DContainer& rContent,
diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
index 59b38300d375..2ee2bb625e2d 100644
--- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -485,7 +485,8 @@ namespace drawinglayer::primitive2d
         Primitive2DContainer createEmbeddedShadowPrimitive(
             const Primitive2DContainer& rContent,
             const attribute::SdrShadowAttribute& rShadow,
-            const basegfx::B2DHomMatrix& rObjectMatrix)
+            const basegfx::B2DHomMatrix& rObjectMatrix,
+            const Primitive2DContainer* pContentForShadow)
         {
             if(!rContent.empty())
             {
@@ -524,7 +525,7 @@ namespace drawinglayer::primitive2d
                     new ShadowPrimitive2D(
                         aShadowOffset,
                         rShadow.getColor(),
-                        rContent));
+                        (pContentForShadow ? *pContentForShadow : rContent)));
 
                 if(0.0 != rShadow.getTransparence())
                 {
diff --git a/svx/source/table/viewcontactoftableobj.cxx b/svx/source/table/viewcontactoftableobj.cxx
index fe6d03f1d900..bd950a02f7fb 100644
--- a/svx/source/table/viewcontactoftableobj.cxx
+++ b/svx/source/table/viewcontactoftableobj.cxx
@@ -36,6 +36,7 @@
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <svx/framelink.hxx>
 #include <svx/framelinkarray.hxx>
+#include <svx/sdooitm.hxx>
 #include <vcl/canvastools.hxx>
 
 #include <cell.hxx>
@@ -205,6 +206,7 @@ namespace sdr::contact
                 // directly to aRetval, Border info to aBorderSequence and added
                 // later to get the correct overlapping
                 drawinglayer::primitive2d::Primitive2DContainer aRetval;
+                drawinglayer::primitive2d::Primitive2DContainer aRetvalForShadow;
                 const sal_Int32 nRowCount(xTable->getRowCount());
                 const sal_Int32 nColCount(xTable->getColumnCount());
                 const sal_Int32 nAllCount(nRowCount * nColCount);
@@ -317,6 +319,16 @@ namespace sdr::contact
                                                 aCellMatrix, aAttribute));
                                         aRetval.append(xCellReference);
                                     }
+
+                                    // Create cell primitive without text.
+                                    aAttribute
+                                        = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
+                                            rCellItemSet, nullptr);
+                                    const drawinglayer::primitive2d::Primitive2DReference
+                                        xCellReference(
+                                            new drawinglayer::primitive2d::SdrCellPrimitive2D(
+                                                aCellMatrix, aAttribute));
+                                    aRetvalForShadow.append(xCellReference);
                                 }
                             }
                         }
@@ -364,6 +376,10 @@ namespace sdr::contact
                             new drawinglayer::primitive2d::TransformPrimitive2D(
                                 aTransform,
                                 aCellBorderPrimitives));
+
+                        // Borders are always the same for shadow as well.
+                        aRetvalForShadow.append(new drawinglayer::primitive2d::TransformPrimitive2D(
+                            aTransform, aCellBorderPrimitives));
                     }
                 }
 
@@ -376,7 +392,23 @@ namespace sdr::contact
 
                     if(!aNewShadowAttribute.isDefault())
                     {
-                        aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive(aRetval, aNewShadowAttribute);
+                        bool bDirectShadow
+                            = rObjectItemSet.Get(SDRATTR_SHADOW, /*bSrchInParent=*/false)
+                                  .GetValue();
+                        if (bDirectShadow)
+                        {
+                            // Shadow as direct formatting: no shadow for text, to be compatible
+                            // with PowerPoint.
+                            basegfx::B2DHomMatrix aMatrix;
+                            aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive(
+                                aRetval, aNewShadowAttribute, aMatrix, &aRetvalForShadow);
+                        }
+                        else
+                        {
+                            // Shadow as style: shadow for text, to be backwards-compatible.
+                            aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive(
+                                aRetval, aNewShadowAttribute);
+                        }
                     }
                 }
 
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index 037c5898b1f3..5ca622ce8d39 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -740,6 +740,7 @@ static SfxItemPropertyMapEntry const * ImplGetSvxTableShapePropertyMap()
 {
     static SfxItemPropertyMapEntry const  aTableShapePropertyMap_Impl[] =
     {
+        SHADOW_PROPERTIES
         { OUString(UNO_NAME_MISC_OBJ_ZORDER),       OWN_ATTR_ZORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},
         { OUString(UNO_NAME_MISC_OBJ_LAYERID),      SDRATTR_LAYERID, cppu::UnoType<sal_Int16>::get(), 0,    0},
         { OUString(UNO_NAME_MISC_OBJ_LAYERNAME),    SDRATTR_LAYERNAME, cppu::UnoType<OUString>::get(), 0, 0},
-- 
2.26.2
openSUSE Build Service is sponsored by