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 #include #include +#include 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,