oox/CppunitTest_oox_testscene3d.mk                  |    6 
 oox/inc/drawingml/scene3dhelper.hxx                 |    8 
 oox/qa/unit/data/Scene3d_lightRig_default.pptx      |binary
 oox/qa/unit/data/Scene3d_lightRig_dir_rotation.pptx |binary
 oox/qa/unit/data/Scene3d_lightRig_legacyCamera.pptx |binary
 oox/qa/unit/data/Scene3d_lightRig_modernCamera.pptx |binary
 oox/qa/unit/data/Scene3d_lightRig_rot_rotation.pptx |binary
 oox/qa/unit/testscene3d.cxx                         |  188 +++++++
 oox/source/drawingml/scene3dhelper.cxx              |  504 +++++++++++++++++++-
 oox/source/drawingml/shape.cxx                      |   34 +
 10 files changed, 729 insertions(+), 11 deletions(-)

New commits:
commit 98b06ed3583fcc1f720ceb919cdd57ede7952a71
Author:     Regina Henschel <rb.hensc...@t-online.de>
AuthorDate: Wed Mar 6 21:52:39 2024 +0100
Commit:     Regina Henschel <rb.hensc...@t-online.de>
CommitDate: Wed Mar 13 21:43:58 2024 +0100

    tdf#70039 import lighting of extruded shapes
    
    The patch it a continuation of commit 6e5529d7, that handles import of
    the 3D-scene camera. This patch handles lighting of the 3D-scene. But
    lighting in MS Office has features which we cannot yet render, address
    in API or store in ODF. More than two lights, softing with Scale and
    and Offset, or Specular/Diffuse for all lights are not implemented for
    extruded shapes, for example. Thus the rendering results cannot be
    equal to MS Office.
    
    This patch contains a lot of workarounds and compromises to get a
    rendering which looks somewhat similar. Unit tests are not really
    meaningful in this situation. The included tests focus on the principle
    aspects modern/legacy lightRigs and lightRig rotation.
    
    The light rig values are taken from sections 2.1.1274 and 2.1.1321 in
    [MS-OI29500] - v20231113.
    https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oi29500
    
    That version does not specify the used coordinate system for the
    light directions. Find the discussion about that in
    https://learn.microsoft.com/en-us/answers/questions/1551836
    topic: LightDirection on shape with 3D effect is rendered different
    than specified.
    
    That version does not specify the values 'Specular' and 'Diffuse'
    for legacy* light rigs. Find the discussion about that in
    https://learn.microsoft.com/en-us/answers/questions/1608333
    topic: What is 'Specular' and 'Diffuse' in the lightRig table in
    section 2.1.1274 in [MS-OI29500]?
    
    Change-Id: I91750dc231d0ea09115424d896d3a1260ba766ca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164510
    Tested-by: Jenkins
    Reviewed-by: Regina Henschel <rb.hensc...@t-online.de>

diff --git a/oox/CppunitTest_oox_testscene3d.mk 
b/oox/CppunitTest_oox_testscene3d.mk
index 23b08eee6fed..f19943a3cfe3 100644
--- a/oox/CppunitTest_oox_testscene3d.mk
+++ b/oox/CppunitTest_oox_testscene3d.mk
@@ -26,11 +26,15 @@ $(eval $(call gb_CppunitTest_use_libraries,oox_testscene3d, 
\
     cppuhelper \
     oox \
     sal \
+    sfx \
     subsequenttest \
+    svx \
+    svxcore \
     test \
+    tl \
     unotest \
     utl \
-    tl \
+    vcl \
 ))
 
 $(eval $(call gb_CppunitTest_use_sdk_api,oox_testscene3d))
diff --git a/oox/inc/drawingml/scene3dhelper.hxx 
b/oox/inc/drawingml/scene3dhelper.hxx
index 8dd62186d895..af72a0e0cf2a 100644
--- a/oox/inc/drawingml/scene3dhelper.hxx
+++ b/oox/inc/drawingml/scene3dhelper.hxx
@@ -42,6 +42,14 @@ public:
                                 double& rRotZ, oox::drawingml::Color& 
rExtrusionColor,
                                 const bool bBlockExtrusion = false);
 
+    /** Creates lighting properties in rPropertyMap from MSO preset and shape 
rotation
+        @param [in] p3DProperties a pointer to Shape3DProperties
+        @param [in] rRotZ the shape rotation inclusive camera z-rotation as 
calculated by
+            setExtrusionProperties()
+        @param [in, out] rPropertyMap the map, that was already filled by 
setExtrusionProperties()*/
+    void setLightingProperties(const oox::drawingml::Shape3DPropertiesPtr 
p3DProperties,
+                               const double& rRotZ, oox::PropertyMap& 
rPropertyMap);
+
 private:
     /** Calculates angles suitable for API from OOXML scene3d angles.
         @param [in] nLat, nLon, nRev in unit 1/60000 deg with same orientation 
as the attributes lat,
diff --git a/oox/qa/unit/data/Scene3d_lightRig_default.pptx 
b/oox/qa/unit/data/Scene3d_lightRig_default.pptx
new file mode 100644
index 000000000000..a2d82f984e44
Binary files /dev/null and b/oox/qa/unit/data/Scene3d_lightRig_default.pptx 
differ
diff --git a/oox/qa/unit/data/Scene3d_lightRig_dir_rotation.pptx 
b/oox/qa/unit/data/Scene3d_lightRig_dir_rotation.pptx
new file mode 100644
index 000000000000..14b4486a15d1
Binary files /dev/null and 
b/oox/qa/unit/data/Scene3d_lightRig_dir_rotation.pptx differ
diff --git a/oox/qa/unit/data/Scene3d_lightRig_legacyCamera.pptx 
b/oox/qa/unit/data/Scene3d_lightRig_legacyCamera.pptx
new file mode 100644
index 000000000000..5f2d5c162ea7
Binary files /dev/null and 
b/oox/qa/unit/data/Scene3d_lightRig_legacyCamera.pptx differ
diff --git a/oox/qa/unit/data/Scene3d_lightRig_modernCamera.pptx 
b/oox/qa/unit/data/Scene3d_lightRig_modernCamera.pptx
new file mode 100644
index 000000000000..dfce2704f4f9
Binary files /dev/null and 
b/oox/qa/unit/data/Scene3d_lightRig_modernCamera.pptx differ
diff --git a/oox/qa/unit/data/Scene3d_lightRig_rot_rotation.pptx 
b/oox/qa/unit/data/Scene3d_lightRig_rot_rotation.pptx
new file mode 100644
index 000000000000..6583c2bd5b9a
Binary files /dev/null and 
b/oox/qa/unit/data/Scene3d_lightRig_rot_rotation.pptx differ
diff --git a/oox/qa/unit/testscene3d.cxx b/oox/qa/unit/testscene3d.cxx
index 6ca9e332d11f..6d22f714692e 100644
--- a/oox/qa/unit/testscene3d.cxx
+++ b/oox/qa/unit/testscene3d.cxx
@@ -10,14 +10,22 @@
 #include <test/unoapixml_test.hxx>
 
 #include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/Size.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
 #include <com/sun/star/drawing/Position3D.hpp>
 #include <com/sun/star/drawing/ProjectionMode.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+
 #include <comphelper/sequenceashashmap.hxx>
 #include <editeng/unoprnms.hxx>
+#include <sfx2/viewsh.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdview.hxx>
+#include <tools/color.hxx>
+#include <vcl/bitmapex.hxx>
 
 using namespace css;
 
@@ -33,6 +41,9 @@ public:
 protected:
     // get shape with nShapeIndex from page nPageIndex
     uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex, sal_uInt8 
nPageIndex);
+    // Converts the shape 0 on page 0 to a bitmap and returns this bitmap.
+    // It assumes, that shape 0 on page 0 is the only shape.
+    void getShapeAsBitmap(BitmapEx& rBMP);
 };
 
 uno::Reference<drawing::XShape> TestScene3d::getShape(sal_uInt8 nShapeIndex, 
sal_uInt8 nPageIndex)
@@ -49,6 +60,27 @@ uno::Reference<drawing::XShape> 
TestScene3d::getShape(sal_uInt8 nShapeIndex, sal
     return xShape;
 }
 
+void TestScene3d::getShapeAsBitmap(BitmapEx& rBMP)
+{
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    SdrView* pSdrView = pViewShell->GetDrawView();
+
+    // Mark object and convert it to bitmap
+    uno::Reference<drawing::XShape> xShape3D(getShape(0, 0));
+    SdrObject* pSdrShape(SdrObject::getSdrObjectFromXShape(xShape3D));
+    pSdrView->MarkObj(pSdrShape, pSdrView->GetSdrPageView());
+    dispatchCommand(mxComponent, ".uno:ConvertIntoBitmap", {});
+    pSdrView->UnmarkAll();
+
+    // Get graphic
+    uno::Reference<drawing::XShape> xShapeBmp(getShape(0, 0));
+    SdrGrafObj* pGrafObj = 
dynamic_cast<SdrGrafObj*>(SdrObject::getSdrObjectFromXShape(xShapeBmp));
+    CPPUNIT_ASSERT_MESSAGE("No image object created", pGrafObj);
+    const Graphic& rGraphic = pGrafObj->GetGraphic();
+    rBMP = rGraphic.GetBitmapEx();
+    CPPUNIT_ASSERT_MESSAGE("No bitmap", !rBMP.IsEmpty());
+}
+
 CPPUNIT_TEST_FIXTURE(TestScene3d, test_isometricRightUp)
 {
     // Given a document with a scene3d element on a shape. Without the fix, 
the shape was imported as
@@ -99,10 +131,11 @@ CPPUNIT_TEST_FIXTURE(TestScene3d, test_isometricRightUp)
     CPPUNIT_ASSERT_DOUBLES_EQUAL(1270.0, aParaPair.First.Value.get<double>(), 
1E-14);
     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, aParaPair.Second.Value.get<double>(), 
1E-14);
 
-    // This shape does not use an extrusion color.
-    bool bIsExtrusionColorEnabled(true);
+    // This shape does not use an extrusion color, but we enable it in all 
cases and set
+    // its color, because MSO and LO have different defaults.
+    bool bIsExtrusionColorEnabled(false);
     aExtrusionPropMap.getValue(u"Color"_ustr) >>= bIsExtrusionColorEnabled;
-    CPPUNIT_ASSERT_MESSAGE("error: Extrusion color enabled", 
!bIsExtrusionColorEnabled);
+    CPPUNIT_ASSERT_MESSAGE("error: Extrusion color not enabled", 
bIsExtrusionColorEnabled);
 }
 
 CPPUNIT_TEST_FIXTURE(TestScene3d, test_legacyObliqueBottomRight)
@@ -315,6 +348,155 @@ CPPUNIT_TEST_FIXTURE(TestScene3d, 
test_legacyPerspectiveTopRight)
     CPPUNIT_ASSERT_DOUBLES_EQUAL(6292, aBoundRect.X, 10);
     CPPUNIT_ASSERT_DOUBLES_EQUAL(3138, aBoundRect.Y, 10);
 }
+
+CPPUNIT_TEST_FIXTURE(TestScene3d, test_lightRig_modernCamera)
+{
+    // The modern camera 'orthographicFront' looks at the shape. The scene is 
lit by lightRig 'twoPt'.
+    // A modern camera moves around the shape. The lightRig has a fixed 
position in regard to the
+    // shape. This is the same shape as in test_lightRig_legacyCamera but with 
a modern camera.
+    // The test assumes rendering with ShadeMode_FLAT.
+    loadFromFile(u"Scene3d_lightRig_modernCamera.pptx");
+    BitmapEx aBMP;
+    getShapeAsBitmap(aBMP);
+
+    // Size in pixel depends on dpi. Thus calculate positions relative to size.
+    // Color in center
+    sal_Int32 nX = 0.5 * aBMP.GetSizePixel().Width();
+    sal_Int32 nY = 0.5 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedCenter(248, 226, 212);
+    CPPUNIT_ASSERT_MESSAGE("center color wrong",
+                           
aExpectedCenter.GetColorError(aBMP.GetPixelColor(nX, nY)) < 7);
+    // Color left
+    nX = 0.046122 * aBMP.GetSizePixel().Width();
+    nY = 0.5 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedLeft(0, 105, 48);
+    CPPUNIT_ASSERT_MESSAGE("left color wrong",
+                           aExpectedLeft.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+}
+
+CPPUNIT_TEST_FIXTURE(TestScene3d, test_lightRig_legacyCamera)
+{
+    // The legacy camera 'legacyObliqueFront' looks at the shape. The scene is 
lit by lightRig
+    // 'twoPt'. A legacy camera is fix, instead the shape is rotated. The 
lightRig has a fixed
+    // position in regard to the camera, but the shape receives various 
lighting when rotated.
+    // This is the same shape as in test_lightRig_modernCamera but with a 
legacy camera.
+    // The test assumes rendering with ShadeMode_FLAT.
+    loadFromFile(u"Scene3d_lightRig_legacyCamera.pptx");
+    BitmapEx aBMP;
+    getShapeAsBitmap(aBMP);
+
+    // Size in pixel depends on dpi. Thus calculate positions relative to size.
+    // Color in center
+    sal_Int32 nX = 0.5 * aBMP.GetSizePixel().Width();
+    sal_Int32 nY = 0.5 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedCenter(96, 88, 82);
+    CPPUNIT_ASSERT_MESSAGE("center color wrong",
+                           
aExpectedCenter.GetColorError(aBMP.GetPixelColor(nX, nY)) < 7);
+    // Color left
+    nX = 0.046122 * aBMP.GetSizePixel().Width();
+    nY = 0.5 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedLeft(0, 180, 82);
+    CPPUNIT_ASSERT_MESSAGE("left color wrong",
+                           aExpectedLeft.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+}
+
+CPPUNIT_TEST_FIXTURE(TestScene3d, test_lightRig_default)
+{
+    // The scene uses the modern camera 'isometricOffAxis1Top' and the 
lightRig 'harsh'. Here the
+    // unrotated lightRig is tested. Since rig 'harsh' has only two lights and 
the direction of the
+    // second light is against view direction, the colors are same in 
LibreOffice and MS Office.
+    // The test assumes rendering with ShadeMode_FLAT.
+    loadFromFile(u"Scene3d_lightRig_default.pptx");
+    BitmapEx aBMP;
+    getShapeAsBitmap(aBMP);
+
+    // Size in pixel depends on dpi. Thus calculate positions relative to size.
+    // Front color
+    sal_Int32 nX = 0.93811 * aBMP.GetSizePixel().Width();
+    sal_Int32 nY = 0.49904 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedFront(165, 187, 150);
+    CPPUNIT_ASSERT_MESSAGE("front color wrong",
+                           aExpectedFront.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+    // Left color
+    nX = 0.078176 * aBMP.GetSizePixel().Width();
+    nY = 0.49904 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedLeft(255, 189, 74);
+    CPPUNIT_ASSERT_MESSAGE("left color wrong",
+                           aExpectedLeft.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+    // Top color
+    nX = 0.48860 * aBMP.GetSizePixel().Width();
+    nY = 0.069098 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedTop(189, 100, 39);
+    CPPUNIT_ASSERT_MESSAGE("top color wrong",
+                           aExpectedTop.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+}
+
+CPPUNIT_TEST_FIXTURE(TestScene3d, test_lightRig_dir_rotation)
+{
+    // The scene uses the modern camera 'isometricOffAxis1Top' and the 
lightRig 'harsh'. The rig is
+    // rotated around the z-axis by attribute 'dir'. Since rig 'harsh' has 
only two lights and the
+    // direction of the second light is against the view direction, colors are 
same in LibreOffice
+    // and MSO. The test assumes rendering with ShadeMode_FLAT.
+    loadFromFile(u"Scene3d_lightRig_dir_rotation.pptx");
+    BitmapEx aBMP;
+    getShapeAsBitmap(aBMP);
+
+    // Size in pixel depends on dpi. Thus calculate positions relative to size.
+    // Front color
+    sal_Int32 nX = 0.93811 * aBMP.GetSizePixel().Width();
+    sal_Int32 nY = 0.49904 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedFront(165, 187, 150);
+    CPPUNIT_ASSERT_MESSAGE("front color wrong",
+                           aExpectedFront.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+    // Left color
+    nX = 0.078176 * aBMP.GetSizePixel().Width();
+    nY = 0.49904 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedLeft(206, 108, 42);
+    CPPUNIT_ASSERT_MESSAGE("left color wrong",
+                           aExpectedLeft.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+    // Top color
+    nX = 0.48860 * aBMP.GetSizePixel().Width();
+    nY = 0.069098 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedTop(255, 189, 74);
+    CPPUNIT_ASSERT_MESSAGE("top color wrong",
+                           aExpectedTop.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+}
+
+CPPUNIT_TEST_FIXTURE(TestScene3d, test_lightRig_rot_rotation)
+{
+    // The scene uses the modern camera 'isometricOffAxis1Top' and the 
lightRig 'harsh'. The rig is
+    // rotated around x- and y-axis by element 'rot'.
+    // The test assumes rendering with ShadeMode_FLAT.
+    loadFromFile(u"Scene3d_lightRig_rot_rotation.pptx");
+    BitmapEx aBMP;
+    getShapeAsBitmap(aBMP);
+
+    // Size in pixel depends on dpi. Thus calculate positions relative to size.
+    // Front color, same as in MS Office
+    sal_Int32 nX = 0.93811 * aBMP.GetSizePixel().Width();
+    sal_Int32 nY = 0.49904 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedFront(88, 100, 80);
+    CPPUNIT_ASSERT_MESSAGE("center color wrong",
+                           aExpectedFront.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+    // Left color, different from MS Office
+    // The rotation brings the second light in a position, that it contributes 
to the left face.
+    // Because the light is specular in MS Office, but current LibreOffice 
cannot make a second
+    // light specular, the colors in MS Office and LibreOffice differ 
noticeably. MS Office has
+    // here rgb(255, 214, 99). The expectected color is the color in 
LibreOffice as of March 2024.
+    // The test needs to be updated, when LibreOffice rendering is improved.
+    nX = 0.078176 * aBMP.GetSizePixel().Width();
+    nY = 0.49904 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedLeft(255, 191, 75);
+    CPPUNIT_ASSERT_MESSAGE("left color wrong",
+                           aExpectedLeft.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+    // Top color, same as in MS Office
+    nX = 0.48860 * aBMP.GetSizePixel().Width();
+    nY = 0.069098 * aBMP.GetSizePixel().Height();
+    ::Color aExpectedTop(106, 56, 22);
+    CPPUNIT_ASSERT_MESSAGE("top color wrong",
+                           aExpectedTop.GetColorError(aBMP.GetPixelColor(nX, 
nY)) < 7);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/scene3dhelper.cxx 
b/oox/source/drawingml/scene3dhelper.cxx
index d69abca24225..8f2d41b9bb12 100644
--- a/oox/source/drawingml/scene3dhelper.cxx
+++ b/oox/source/drawingml/scene3dhelper.cxx
@@ -12,16 +12,19 @@
 
 #include <basegfx/matrix/b3dhommatrix.hxx>
 #include <basegfx/numeric/ftools.hxx>
+#include <basegfx/vector/b3dvector.hxx>
 #include <oox/drawingml/drawingmltypes.hxx>
 #include <oox/helper/propertymap.hxx>
 #include <oox/token/properties.hxx>
 #include <oox/token/tokens.hxx>
 
+#include <com/sun/star/drawing/Direction3D.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameter.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
 #include <com/sun/star/drawing/Position3D.hpp>
 #include <com/sun/star/drawing/ProjectionMode.hpp>
+#include <com/sun/star/drawing/ShadeMode.hpp>
 
 namespace oox
 {
@@ -435,12 +438,509 @@ bool Scene3DHelper::setExtrusionProperties(const 
oox::drawingml::Shape3DProperti
     // Shape properties
     Scene3DHelper::addExtrusionDepthToMap(p3DProperties, rPropertyMap);
 
-    // Extrusion color enabled?
-    rPropertyMap.setProperty(oox::PROP_Color, rExtrusionColor.isUsed());
+    // The 'automatic' extrusion color is different in MS Office. Thus we 
enable it in any case.
+    // CreateAndInsert method will set a suitable 'automatic' color, if 
rExtrusionColor is not used.
+    rPropertyMap.setProperty(oox::PROP_Color, true);
+    // ToDo: Some materials might need ShadeMode_Smooth or ShadeMode_PHONG.
+    rPropertyMap.setProperty(oox::PROP_ShadeMode, 
css::drawing::ShadeMode_FLAT);
 
     return true;
 }
 
+namespace
+{
+/* This struct is used to hold light properties for a light in a preset light 
rig.*/
+struct MSOLight
+{
+    // Values are as specified in [MS-OI29500], see commit message.
+    // The color is specified as RGBA, but alpha value is always 1.0 and 
ignored anyway, so it is
+    // dropped here. The RGB values are in decimal, but might exceed the usual 
[0;1] range.
+    double fMSOColorR;
+    double fMSOColorG;
+    double fMSOColorB;
+    // MSO uses 4 decimals precision, some light directions are not normalized.
+    double fMSOLightDirectionX;
+    double fMSOLightDirectionY;
+    double fMSOLightDirectionZ;
+    double fScale;
+    double fOffset;
+    bool bSpecular;
+    bool bDiffuse;
+};
+
+/* This struct is used to hold properties of a light rig*/
+struct PrstLightRigValues
+{
+    // values are as specified in [MS-OI29500], see commit message.
+    std::u16string_view sLightRigName; // identifies the light rig, mandatory 
in OOXML
+    // The ambient color is specified as RGBA, but alpha value is always 1.0 
and R = B = G. Thus we
+    // store here only one value.
+    std::optional<double> fAmbient;
+    // Each rig has at least one light and maximal four lights
+    MSOLight aLight1;
+    std::optional<MSOLight> aLight2;
+    std::optional<MSOLight> aLight3;
+    std::optional<MSOLight> aLight4;
+    // Light rig rotation is not contained in the presets.
+};
+} // end anonymous namespace
+
+// The values are taken from [MS-OI29500]. For details see the spreadsheet 
attached to
+// tdf#70039 and the commit message.
+constexpr sal_uInt16 nLightRigPresetCount(27); // Fix value, specified in 
OOXML standard.
+constexpr PrstLightRigValues aPrstLightRigValuesArray[nLightRigPresetCount] = {
+    { u"balanced",
+      { 0.13 },
+      { 1.05, 1.05, 1.05, 0.5263, -0.4092, -0.7453, 1, 0, true, true },
+      { { 1, 1, 1, -0.9386, 0.3426, -0.041, 1, 0, true, true } },
+      { { 0.5, 0.5, 0.5, 0.0934, 0.763, 0.6396, 1, 0, true, true } },
+      {} },
+    { u"brightRoom",
+      { 1.5 },
+      { 1, 1, 1, 0, -1, 0, 1, 0, false, true },
+      { { 1, 1, 1, 0.8227, -0.1882, -0.5364, 1, 0, true, false } },
+      { { -0.5, -0.5, -0.5, 0, 0, -1, 1, 0, false, true } },
+      { { 0.5, 0.5, 0.5, 0, 1, 0, 1, 0, false, true } } },
+    { u"chilly",
+      { 0.11 },
+      { 0.31, 0.32, 0.32, 0.6574, -0.7316, -0.1806, 1, 0, true, true },
+      { { 0.45, 0.45, 0.45, -0.3539, -0.1505, -0.9231, 1, 0, false, true } },
+      { { 1.03, 1.02, 1.15, 0.672, -0.6185, -0.4073, 1, 0, false, true } },
+      { { 0.41, 0.45, 0.48, -0.5781, 0.7976, 0.1722, 1, 0, true, true } } },
+    { u"contrasting",
+      { 1 },
+      { 1, 1, 1, 0, -1, 0, 1, 0, true, false },
+      { { 1, 1, 1, 0, 1, 0, 1, 0, true, false } },
+      {},
+      {} },
+    { u"flat",
+      { 1 },
+      { 0.821, 0.821, 0.821, -0.9546, -0.1619, -0.2502, 1, 0, true, false },
+      { { 2.072, 2.54, 2.91, 0.0009, 0.8605, 0.5095, 1, 0, true, false } },
+      { { 3.843, 3.843, 3.843, 0.6574, -0.7316, -0.1806, 1, 0, true, false } },
+      {} },
+    { u"flood",
+      { 0.13 },
+      { 1.1, 1.1, 1.1, 0.5685, -0.7651, -0.3022, 1, 0, true, true },
+      { { 1.1, 1.1, 1.1, -0.2366, -0.9595, -0.1531, 1, 0, true, true } },
+      { { 0.55, 0.55, 0.55, -0.8982, 0.1386, -0.4171, 1, 0, true, true } },
+      {} },
+    { u"freezing",
+      {},
+      { 0.53, 0.567, 0.661, 0.6574, -0.7316, -0.1806, 1, 0, true, true },
+      { { 0.37, 0.461, 0.461, -0.2781, -0.4509, -0.8482, 1, 0, false, true } },
+      { { 0.649, 0.638, 0.904, 0.672, -0.6185, -0.4073, 1, 0, false, true } },
+      { { 0.971, 1.19, 1.363, -0.1825, 0.968, 0.1722, 1, 0, true, true } } },
+    { u"glow",
+      { 1 },
+      { 1, 1, 1, 0, -1, 0, 1, 0, true, true },
+      { { 0.7, 0.7, 0.7, 0, 1, 0, 1, 0, true, true } },
+      {},
+      {} },
+    { u"harsh",
+      { 0.28 },
+      { 0.88, 0.88, 0.88, 0.6689, -0.6755, -0.3104, 1, 0, true, true },
+      { { 0.88, 0.88, 0.88, -0.592, -0.7371, -0.326, 1, 0, true, true } },
+      {},
+      {} },
+    { u"legacyFlat1",
+      { 0.305 },
+      { 0.58, 0.58, 0.58, 0, 0, -0.2, 1, 0, true, true },
+      { { 0.58, 0.58, 0.58, 0, 0, -0.2, 0.5, 0, false, true } },
+      {},
+      {} },
+    { u"legacyFlat2",
+      { 0.305 },
+      { 0.58, 0.58, 0.58, -1, -1, -0.2, 1, 0, true, true },
+      { { 0.58, 0.58, 0.58, 0, 1, -0.2, 0.5, 0, false, true } },
+      {},
+      {} },
+    { u"legacyFlat3",
+      { 0.305 },
+      { 0.58, 0.58, 0.58, 0, -1, -0.2, 1, 0, true, true },
+      { { 0.58, 0.58, 0.58, 0, 1, -0.2, 0.5, 0, false, true } },
+      {},
+      {} },
+    { u"legacyFlat4",
+      { 0.305 },
+      { 0.58, 0.58, 0.58, 1, -1, -0.2, 1, 0, true, true },
+      { { 0.58, 0.58, 0.58, 0, 1, -0.2, 0.5, 0, false, true } },
+      {},
+      {} },
+    { u"legacyHarsh1",
+      { 0.061 },
+      { 0.793, 0.793, 0.793, 0, 0, -0.2, 1, 0, true, true },
+      { { 0.214, 0.214, 0.214, 0, 0, -0.2, 1, 0, false, true } },
+      {},
+      {} },
+    { u"legacyHarsh2",
+      { 0.061 },
+      { 0.793, 0.793, 0.793, -1, -1, -0.2, 1, 0, true, true },
+      { { 0.214, 0.214, 0.214, 0, 1, -0.2, 1, 0, false, true } },
+      {},
+      {} },
+    { u"legacyHarsh3",
+      { 0.061 },
+      { 0.793, 0.793, 0.793, 0, -1, -0.2, 1, 0, true, true },
+      { { 0.214, 0.214, 0.214, 0, 1, -0.2, 1, 0, false, true } },
+      {},
+      {} },
+    { u"legacyHarsh4",
+      { 0.061 },
+      { 0.793, 0.793, 0.793, 1, -1, -0.2, 1, 0, true, true },
+      { { 0.214, 0.214, 0.214, 0, 1, -0.2, 1, 0, false, true } },
+      {},
+      {} },
+    { u"legacyNormal1",
+      { 0.153 },
+      { 0.671, 0.671, 0.671, 0, 0, -0.2, 1, 0, true, true },
+      { { 0.366, 0.366, 0.366, 0, 0, -0.2, 0.5, 0, false, true } },
+      {},
+      {} },
+    { u"legacyNormal2",
+      { 0.153 },
+      { 0.671, 0.671, 0.671, -1, -1, -0.2, 1, 0, true, true },
+      { { 0.366, 0.366, 0.366, 0, 1, -0.2, 0.5, 0, false, true } },
+      {},
+      {} },
+    { u"legacyNormal3",
+      { 0.153 },
+      { 0.671, 0.671, 0.671, 0, -1, -0.2, 1, 0, true, true },
+      { { 0.366, 0.366, 0.366, 0, 1, -0.2, 0.5, 0, false, true } },
+      {},
+      {} },
+    { u"legacyNormal4",
+      { 0.153 },
+      { 0.671, 0.671, 0.671, 1, -1, -0.2, 1, 0, true, true },
+      { { 0.366, 0.366, 0.366, 0, 1, -0.2, 0.5, 0, false, true } },
+      {},
+      {} },
+    { u"morning",
+      {},
+      { 0.669, 0.648, 0.596, 0.6574, -0.7316, -0.1806, 0.5, 0.5, true, true },
+      { { 0.459, 0.454, 0.385, -0.2781, -0.4509, -0.8482, 1, 0, false, true } 
},
+      { { 0.9, 0.86, 0.83, 0.672, -0.6185, -0.4073, 1, 0, false, true } },
+      { { 0.911, 0.846, 0.728, -0.1825, 0.968, 0.1722, 1, 0, true, true } } },
+    { u"soft", { 0.3 }, { 0.8, 0.8, 0.8, -0.6897, 0.2484, -0.6802, 1, 0, true, 
true }, {}, {}, {} },
+    { u"sunrise",
+      {},
+      { 0.667, 0.63, 0.527, 0.6574, -0.7316, -0.1806, 1, 0, true, true },
+      { { 0.459, 0.459, 0.371, -0.2781, -0.4509, -0.8482, 1, 0, false, true } 
},
+      { { 0.826, 0.712, 0.638, 0.672, -0.6185, -0.4073, 1, 0, false, true } },
+      { { 1.511, 1.319, 0.994, -0.1825, 0.968, 0.1722, 1, 0, false, true } } },
+    { u"sunset",
+      {},
+      { 0.672, 0.169, 0.169, 0.6574, -0.7316, -0.1806, 1, 0, true, true },
+      { { 0.459, 0.448, 0.327, 0.0922, -0.3551, -0.9303, 1, 0, false, true } },
+      { { 0.775, 0.612, 0.502, 0.672, -0.6185, -0.4073, 1, 0, false, true } },
+      { { 0.761, 0.69, 0.397, -0.424, 0.8891, 0.1722, 1, 0, false, true } } },
+    { u"threePt",
+      {},
+      { 1.141, 1.141, 1.141, -0.6515, -0.2693, -0.7093, 1, 0, true, true },
+      { { 0.5, 0.5, 0.5, 0.8482, 0.2469, -0.4686, 1, 0, true, true } },
+      { { 1, 1, 1, 0.5634, -0.2812, 0.7769, 1, 0, true, true } },
+      {} },
+    { u"twoPt",
+      { 0.25 },
+      { 0.84, 0.84, 0.84, 0.5266, -0.4089, -0.7454, 0, 0, true, true },
+      { { 0.3, 0.3, 0.3, -0.8983, 0.2365, -0.3704, 1, 0, true, true } },
+      {},
+      {} }
+};
+
+namespace
+{
+/** Searches for the item in aPrstLightRigValuesArray with given sPresetName.
+    @param [in] sPresetName name as specified in OOXML standard
+    @return returns the index if item exists, otherwise -1.*/
+sal_Int16 lcl_getPrstLightRigIndex(std::u16string_view sPresetName)
+{
+    sal_Int16 nIt(0);
+    while (nIt < nLightRigPresetCount && 
aPrstLightRigValuesArray[nIt].sLightRigName != sPresetName)
+        ++nIt;
+    if (nIt >= nLightRigPresetCount)
+    {
+        nIt = -1; // Error is handled by caller
+    }
+    return nIt;
+}
+
+/** Extracts the light directions from the preset lightRig.
+    @param [in] rLightRig from which the lights are extracted
+    @param [out] rLightDirVec contains the preset lights but each as 
B3DVector*/
+void lcl_getLightDirectionsFromRig(const PrstLightRigValues& rLightRig,
+                                   std::vector<basegfx::B3DVector>& 
rLightDirVec)
+{
+    auto addLightDir = [&](const MSOLight& aMSOLight) {
+        basegfx::B3DVector aLightDir(aMSOLight.fMSOLightDirectionX, 
aMSOLight.fMSOLightDirectionY,
+                                     aMSOLight.fMSOLightDirectionZ);
+        rLightDirVec.push_back(std::move(aLightDir));
+    };
+    // aLight1 always exists, the others are optional
+    addLightDir(rLightRig.aLight1);
+    if (rLightRig.aLight2.has_value())
+        addLightDir(rLightRig.aLight2.value());
+    if (rLightRig.aLight3.has_value())
+        addLightDir(rLightRig.aLight3.value());
+    if (rLightRig.aLight4.has_value())
+        addLightDir(rLightRig.aLight4.value());
+}
+
+/** Converts the directions from MSO specification to coordinates in the shape 
coordinate system.
+    @details The extruded shape uses a left-hand Cartesian coordinate system 
with x-axis right, y-axis
+    down and z-axis towards observer. When L(Lx,Ly,Lz) is the specified ligth 
direction, then
+    V(-Ly, -Lx, Lz) is the direction in the shape coordinate system.
+    @param [in,out] rLightDirVec contains for each indiviual light its 
direction.*/
+void lcl_AdaptAndNormalizeLightDirections(std::vector<basegfx::B3DVector>& 
rLightDirVec)
+{
+    basegfx::B3DHomMatrix aTransform; // unit matrix
+    aTransform.set(0, 0, 0.0);
+    aTransform.set(0, 1, -1.0);
+    aTransform.set(1, 0, -1.0);
+    aTransform.set(1, 1, 0.0);
+    for (auto& rDirection : rLightDirVec)
+    {
+        rDirection *= aTransform;
+        rDirection.normalize();
+    }
+}
+
+/** Gets the rotation angles fX and fY from the extrusion property RotateAngle 
in the map.
+    Does nothing if property does not exist.
+    @param [in] rPropertyMap should contain valid value in RotateAngle property
+    @param [out] fX, fY rotation angle in unit rad with orientation as in 
API.*/
+void lcl_getXYAnglesFromMap(oox::PropertyMap& rPropertyMap, double& rfX, 
double& rfY)
+{
+    if (!rPropertyMap.hasProperty(oox::PROP_RotateAngle))
+        return;
+    css::drawing::EnhancedCustomShapeParameterPair aAnglePair;
+    css::uno::Any aAny = rPropertyMap.getProperty(oox::PROP_RotateAngle);
+    if (aAny >>= aAnglePair)
+    {
+        rfX = basegfx::deg2rad(aAnglePair.First.Value.get<double>());
+        rfY = basegfx::deg2rad(aAnglePair.Second.Value.get<double>());
+    }
+}
+
+/** Applies the rotations given in fX, fY, fZ to the light directions.
+    @details The rotations are applied in the order fZ, fY, fX. All angles 
have unit rad. The
+        orientation of the angles fX and fY is the same as in the extrusion 
property RotateAngle in
+        API. The orientation of angle fZ is the same as in shape property 
RotateAngle in API.
+    @param [in, out] rLightDirVec contains the to be transformed light 
directions
+    @param [in] fX angle for rotation around x-axis
+    @param [in] fY angle for rotation around y-axis
+    @param {in] fZ angle for rotation around z-axis*/
+void lcl_ApplyShapeRotationToLights(std::vector<basegfx::B3DVector>& 
rLightDirVec, const double& fX,
+                                    const double& fY, const double& fZ)
+{
+    basegfx::B3DHomMatrix aTransform; // unit matrix
+    // rotate has the order first x, than y, last z. We need order z, y, x.
+    aTransform.rotate(0.0, 0.0, -fZ);
+    aTransform.rotate(0.0, -fY, 0.0);
+    aTransform.rotate(fX, 0.0, 0.0);
+    for (auto it = rLightDirVec.begin(); it != rLightDirVec.end(); ++it)
+        (*it) *= aTransform;
+}
+
+/** Applies the light rig rotation to the directions of the individual lights
+    @details A light rig has a mandatory attribute 'dir' for rotating the rig 
in 45deg steps. It might
+        have an element 'rot', that describes a rotation by spherical 
coordinates 'lat', 'lon' and
+        'rev'. The element has precedence over the attribute.
+    @param [in] p3DProperties contains info about light rig.
+    @param {in, out] rLightDirVec contains for each indiviual light its 
direction in shape coordinate
+        system with x-axis right, y-axis down, z-axis toward observer.*/
+void lcl_IncorporateRigRotationIntoLightDirections(
+    const oox::drawingml::Shape3DPropertiesPtr p3DProperties,
+    std::vector<basegfx::B3DVector>& rLightDirVec)
+{
+    basegfx::B3DHomMatrix aTransform; // unit matrix
+    // if a 'rot' element exists, then all of 'lat', 'lon' and 'rev' needs to 
exist.
+    if ((*p3DProperties).maLightRigRotation.mnLatitude.has_value())
+    {
+        double fLat
+            = 
basegfx::deg2rad<60000>((*p3DProperties).maLightRigRotation.mnLatitude.value_or(0));
+        double fLon
+            = 
basegfx::deg2rad<60000>((*p3DProperties).maLightRigRotation.mnLongitude.value_or(0));
+        double fRev
+            = 
basegfx::deg2rad<60000>((*p3DProperties).maLightRigRotation.mnRevolution.value_or(0));
+        aTransform.rotate(0.0, 0.0, fRev);
+        aTransform.rotate(fLat, fLon, 0.0);
+    }
+    else
+    {
+        sal_Int32 nDir = 0;
+        switch ((*p3DProperties).mnLightRigDirection.value_or(XML_t))
+        {
+            case XML_t:
+                nDir = 0;
+                break;
+            case XML_tr:
+                nDir = 45;
+                break;
+            case XML_r:
+                nDir = 90;
+                break;
+            case XML_br:
+                nDir = 135;
+                break;
+            case XML_b:
+                nDir = 180;
+                break; // or -180
+            case XML_bl:
+                nDir = -135;
+                break;
+            case XML_l:
+                nDir = -90;
+                break;
+            case XML_tl:
+                nDir = -45;
+                break;
+            default:
+                nDir = 0;
+        }
+        // Rotation is always only around z-axis
+        aTransform.rotate(0.0, 0.0, basegfx::deg2rad(nDir));
+    }
+    for (auto& rDirection : rLightDirVec)
+        rDirection *= aTransform;
+}
+
+/** The lights in OOXML are basically incompatible with our lights. We try to 
tweak some rigs to
+    reduce obvious problems.
+    @param [in, out] rLightDirVec light directions with already incorporated 
rotations
+    @param [in, out] rLightRig the to be tweaked rig
+*/
+void lcl_tweakLightRig(std::vector<basegfx::B3DVector>& rLightDirVec, 
PrstLightRigValues& rLightRig)
+{
+    if (rLightRig.sLightRigName == u"brightRoom")
+    {
+        // The fourth light has more significant direction.
+        if (rLightDirVec.size() >= 4 && rLightRig.aLight2.has_value()
+            && rLightRig.aLight4.has_value())
+        {
+            std::swap(rLightDirVec[1], rLightDirVec[3]);
+            // swap fourth and second in light rig too, swap their other 
properties too.
+            MSOLight aTemp = rLightRig.aLight4.value();
+            rLightRig.aLight4 = rLightRig.aLight2.value();
+            rLightRig.aLight2 = aTemp;
+            // and make it brighter, 1.0 instead of 0.5
+            rLightRig.aLight2.value().fMSOColorR = 1.0;
+            rLightRig.aLight2.value().fMSOColorG = 1.0;
+            rLightRig.aLight2.value().fMSOColorB = 1.0;
+        }
+        // The object is far too bright.
+        rLightRig.fAmbient = 0.6; // instead 1.5
+    }
+    else if (rLightRig.sLightRigName == u"chilly" || rLightRig.sLightRigName 
== u"flood")
+    {
+        // They are too dark.
+        rLightRig.fAmbient = 0.35; // instead 0.11 resp. 0.13
+    }
+    else if (rLightRig.sLightRigName == u"freezing" || rLightRig.sLightRigName 
== u"morning"
+             || rLightRig.sLightRigName == u"sunrise")
+    {
+        // These rigs have no ambient color but four lights. The objects are 
too dark with only
+        // two lights.
+        rLightRig.fAmbient = 0.4;
+    }
+    else if (rLightRig.sLightRigName == u"sunset")
+    {
+        // The fourth light is more significant.
+        if (rLightDirVec.size() >= 4 && rLightRig.aLight4.has_value())
+        {
+            MSOLight aTemp = rLightRig.aLight2.value();
+            rLightRig.aLight2 = rLightRig.aLight4.value();
+            rLightRig.aLight4 = aTemp;
+            std::swap(rLightDirVec[1], rLightDirVec[3]);
+        }
+    }
+    else if (rLightRig.sLightRigName == u"soft")
+    {
+        // This is the only modern light rig with Scale=0.5 and Offset=0.5. It 
would be harsh=false
+        // and specular=true at the same time. We switch specular off as that 
is used to set harsh on.
+        rLightRig.aLight1.bSpecular = false;
+    }
+}
+
+} // end anonymous namespace
+
+void Scene3DHelper::setLightingProperties(const 
oox::drawingml::Shape3DPropertiesPtr p3DProperties,
+                                          const double& rfRotZ, 
oox::PropertyMap& rPropertyMap)
+{
+    if (!p3DProperties || (p3DProperties && 
!(*p3DProperties).mnLightRigType.has_value()))
+        return;
+
+    // get index of light rig in aPrstLightRigValuesArray
+    const sal_Int32 nLightRigPrstID((*p3DProperties).mnLightRigType.value()); 
// token
+    sal_Int16 nPrstLightRigIndex = lcl_getPrstLightRigIndex(
+        oox::drawingml::Generic3DProperties::getLightRigName(nLightRigPrstID));
+    if (nPrstLightRigIndex < 0 or nPrstLightRigIndex >= nLightRigPresetCount)
+        return; // error in document. OOXML specifies a fixed set of preset 
light rig types.
+
+    // The light rig is copied because it might be tweaked later.
+    PrstLightRigValues aLightRig = 
aPrstLightRigValuesArray[nPrstLightRigIndex];
+
+    std::vector<basegfx::B3DVector> aLightDirVec;
+    aLightDirVec.reserve(4);
+    lcl_getLightDirectionsFromRig(aLightRig, aLightDirVec);
+    lcl_AdaptAndNormalizeLightDirections(aLightDirVec);
+
+    lcl_IncorporateRigRotationIntoLightDirections(p3DProperties, aLightDirVec);
+
+    // Parts (1) to (6) are workarounds for the problem that our current model 
as well as API and
+    // ODF are not able to describe or use the capabilities of extruded custom 
shapes of MS Office.
+    // If the implementation is improved one day, the parts will need to be 
adapted.
+
+    // (1) Moving the camera around does not change shape or light directions 
for modern cameras in
+    // MS Office. For legacy cameras MS Office behaves same as LibreOffice: 
Not the camera is moved
+    // but the shape is rotated. For modern cameras we need to rotate the 
light rig the same way as
+    // the shape to get a similar illumination as in MS Office.
+    if (mnPrstCameraIndex < 20 || 37 < mnPrstCameraIndex)
+    {
+        double fX = 0.0; // unit rad, orientation as in API
+        double fY = 0.0; // unit rad, orientation as in API
+        lcl_getXYAnglesFromMap(rPropertyMap, fX, fY);
+        lcl_ApplyShapeRotationToLights(aLightDirVec, fX, fY, rfRotZ);
+    }
+
+    // (2) We try to tweak some light rigs a little bit, e.g. make sure the 
first light is specular
+    // or add some ambient light instead of not possible third or forth light.
+    lcl_tweakLightRig(aLightDirVec, aLightRig);
+
+    rPropertyMap.setProperty(oox::PROP_Brightness, 
aLightRig.fAmbient.value_or(0) * 100);
+
+    // (3) A 3D-scene of an extruded custom shape has currently no colored 
light, but only a
+    // level. We get the level from Red.
+    rPropertyMap.setProperty(oox::PROP_FirstLightLevel, 
aLightRig.aLight1.fMSOColorR * 100);
+
+    // (4) 'Specular' and 'Diffuse' in the MSO specification belong to modern 
3D geometry. That is not
+    // available in our legacy one. Here we treat 'Specular' as property 
'Harsh' and ignore 'Diffuse'.
+    rPropertyMap.setProperty(oox::PROP_FirstLightHarsh, 
aLightRig.aLight1.bSpecular);
+
+    // (5) In fact we have stored position in FirstLightDirection and 
SecondLightDirection,
+    // not direction, thus the minus sign.
+    css::drawing::Direction3D aLightPos;
+    aLightPos.DirectionX = -aLightDirVec[0].getX();
+    aLightPos.DirectionY = -aLightDirVec[0].getY();
+    aLightPos.DirectionZ = -aLightDirVec[0].getZ();
+    rPropertyMap.setProperty(oox::PROP_FirstLightDirection, aLightPos);
+
+    // (6) For extruded custom shapes only two lights are possible although 
our rendering engine has
+    // eight lights. We will loose lights.
+    if (aLightDirVec.size() > 1)
+    {
+        rPropertyMap.setProperty(oox::PROP_SecondLightLevel,
+                                 aLightRig.aLight2.value().fMSOColorR * 100);
+        rPropertyMap.setProperty(oox::PROP_SecondLightHarsh, 
aLightRig.aLight2.value().bSpecular);
+        aLightPos.DirectionX = -aLightDirVec[1].getX();
+        aLightPos.DirectionY = -aLightDirVec[1].getY();
+        aLightPos.DirectionZ = -aLightDirVec[1].getZ();
+        rPropertyMap.setProperty(oox::PROP_SecondLightDirection, aLightPos);
+    }
+    else
+        rPropertyMap.setProperty(oox::PROP_SecondLightLevel, 0.0); // prevent 
defaults.
+}
+
 } // end namespace oox
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 99a8e72d0de2..aaf26527db5b 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -988,20 +988,22 @@ Reference< XShape > const & Shape::createAndInsert(
         fShapeRotateInclCamera, aExtrusionColor, bBlockExtrusion);
     // Currently the other places use unit 1/60000deg and MSO shape rotate 
orientation.
     sal_Int32 nShapeRotateInclCamera = 
-basegfx::rad2deg<60000>(fShapeRotateInclCamera);
-
     bool bIs3DGraphic = aServiceName == 
"com.sun.star.drawing.GraphicObjectShape" && bHas3DEffect;
     bIsCustomShape |= bIs3DGraphic;
 
     // The extrusion color does not belong to the extrusion properties but is 
secondary color in
-    // the style of the shape, FillColor2 in API.
+    // the style of the shape, FillColor2 in API. The case that no extrusion 
color was set is handled
+    // further down when FillProperties and LineProperties are handled.
     if (aExtrusionColor.isUsed())
     {
         // FillColor2 is not yet transformed to ComplexColor.
         ::Color aColor = 
aExtrusionColor.getColor(rFilterBase.getGraphicHelper());
         maShapeProperties.setProperty(PROP_FillColor2, aColor);
     }
-    // ToDo: MS Office 'automatic' color uses line color if it exists, LO uses 
fill color. We might
-    // need to change color here in case of 'automatic'.
+
+    if (bHas3DEffect)
+        aScene3DHelper.setLightingProperties(mp3DPropertiesPtr, 
fShapeRotateInclCamera,
+                                             
getCustomShapeProperties()->getExtrusionPropertyMap());
 
     if (bIsCroppedGraphic || bIs3DGraphic)
     {
@@ -1468,6 +1470,28 @@ Reference< XShape > const & Shape::createAndInsert(
             if( aShapeProps.hasProperty( PROP_TextAutoGrowHeight ) )
                 xSet->setPropertyValue( rPropName, Any( false ) );
 
+        // For extruded shapes, MSO uses the line color if no extrusion color 
is specified. LO uses
+        // fill color in 'automatic' case. Thus we set extrusion color 
explicitely.
+        if (bHas3DEffect && !aExtrusionColor.isUsed())
+        {
+            const OUString& rFillColor2PropName = 
PropertyMap::getPropertyName(PROP_FillColor2);
+            if (xSetInfo.is() && 
xSetInfo->hasPropertyByName(rFillColor2PropName))
+            {
+                Color aComplexColor;
+                if (aLineProperties.maLineFill.moFillType.has_value()
+                    && aLineProperties.maLineFill.moFillType.value() != 
XML_noFill)
+                    aComplexColor = 
aLineProperties.maLineFill.getBestSolidColor();
+                else if (aFillProperties.moFillType.has_value()
+                    && aFillProperties.moFillType.value() != XML_noFill)
+                    aComplexColor = aFillProperties.getBestSolidColor();
+                if (aComplexColor.isUsed())
+                {
+                    const ::Color aSimpleColor = 
aComplexColor.getColor(rFilterBase.getGraphicHelper());
+                    xSet->setPropertyValue(rFillColor2PropName, 
Any(aSimpleColor));
+                }
+            }
+        }
+
         // do not set properties at a group shape (this causes
         // assertions from svx) ...
         if( aServiceName != "com.sun.star.drawing.GroupShape" )
@@ -1781,7 +1805,7 @@ Reference< XShape > const & Shape::createAndInsert(
                 putPropertyToGrabBag("EffectProperties", 
uno::Any(comphelper::containerToSequence(aEffects)));
             }
 
-            // add 3D effects if any
+            // add 3D effects if any to GrabBag. They are still used in export.
             Sequence< PropertyValue > aCamera3DEffects = 
get3DProperties().getCameraAttributes();
             Sequence< PropertyValue > aLightRig3DEffects = 
get3DProperties().getLightRigAttributes();
             Sequence< PropertyValue > aShape3DEffects = 
get3DProperties().getShape3DAttributes( rGraphicHelper, nFillPhClr );

Reply via email to