xmloff/qa/unit/data/Scene3d_LightRig_threePt.pptx |binary xmloff/qa/unit/draw.cxx | 12 ++++++++++++ xmloff/source/draw/shapeexport.cxx | 5 +++++ 3 files changed, 17 insertions(+)
New commits: commit 21d39b5a8c36203d18c5d67c9d2f2bb8d89a53de Author: Regina Henschel <rb.hensc...@t-online.de> AuthorDate: Sun Mar 17 16:28:12 2024 +0100 Commit: Regina Henschel <rb.hensc...@t-online.de> CommitDate: Mon Mar 18 15:58:53 2024 +0100 Clamp extrusion light level to allowed range for ODF With import of shapes in 3D-mode from pptx files, the internal values for light level might be outside the range 0..100 and thus not allowed in ODF. These high levels are needed to get a similar rendering to MS Office. The export to ODF clamps them now to the allowed range. I do not intend to change the export to loext namespace, because the extrusion mode of custom shapes needs a totally new handling. But that will not be possible timely for version 24.8. Change-Id: I839903cbaf1b304c1e0c4374080963bc70352e61 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164948 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.hensc...@t-online.de> diff --git a/xmloff/qa/unit/data/Scene3d_LightRig_threePt.pptx b/xmloff/qa/unit/data/Scene3d_LightRig_threePt.pptx new file mode 100644 index 000000000000..33121f2590e4 Binary files /dev/null and b/xmloff/qa/unit/data/Scene3d_LightRig_threePt.pptx differ diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index eea4e1362425..985af4f1ad5e 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -810,6 +810,18 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf157018_ThemeImportDraw) CPPUNIT_ASSERT_EQUAL(Color(0x0A0A0A), pColorSet->getColor(model::ThemeColorType::Hyperlink)); CPPUNIT_ASSERT_EQUAL(Color(0x440000), pColorSet->getColor(model::ThemeColorType::Accent1)); } + +CPPUNIT_TEST_FIXTURE(XmloffDrawTest, test_scene3d_ooxml_light) +{ + // The document has a shape in 3D mode. The import of ooxml light rigs can produce light + // levels outside the 0..100 range allowed in ODF. Such high levels are needed for rendering + // similar to MS Office. + loadFromFile(u"Scene3d_LightRig_threePt.pptx"); + + // Without fix this would have failed with validation error. + save("impress8"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 2322e6be63d5..01a97c5be666 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -125,6 +125,7 @@ #include <XMLBase64Export.hxx> #include <XMLImageMapExport.hxx> #include <memory> +#include <algorithm> using namespace ::com::sun::star; using namespace ::xmloff::EnhancedCustomShapeToken; @@ -4523,6 +4524,8 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc double fExtrusionFirstLightLevel = 0; if ( rProp.Value >>= fExtrusionFirstLightLevel ) { + fExtrusionFirstLightLevel = + std::clamp(fExtrusionFirstLightLevel, 0.0, 100.0); ::sax::Converter::convertDouble( aStrBuffer, fExtrusionFirstLightLevel, @@ -4540,6 +4543,8 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc double fExtrusionSecondLightLevel = 0; if ( rProp.Value >>= fExtrusionSecondLightLevel ) { + fExtrusionSecondLightLevel = + std::clamp(fExtrusionSecondLightLevel, 0.0, 100.0); ::sax::Converter::convertDouble( aStrBuffer, fExtrusionSecondLightLevel,