21 #include <rtl/math.hxx>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/drawing/Direction3D.hpp>
31 #include <com/sun/star/drawing/CameraGeometry.hpp>
42 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
44 maDiffuseColor(0x00000000),
45 maDirection(0.0, 0.0, 1.0),
52 switch(aIter.getToken())
63 if (!std::isnan(aVal.getX()) && !std::isnan(aVal.getY()) && !std::isnan(aVal.getZ()))
69 SAL_WARN(
"xmloff",
"NaNs found in light direction: " << aIter.toString());
96 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
97 uno::Reference< drawing::XShapes >
const & rShapes,
98 bool bTemporaryShapes)
109 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
113 AddShape(
"com.sun.star.drawing.Shape3DSceneObject" );
145 uno::Reference< beans::XPropertySet > xPropSet(
mxShape, uno::UNO_QUERY);
160 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
185 return xContext.get();
189 : mrImport( rImporter ),
190 mbSetTransform( false ),
191 mxPrjMode(
drawing::ProjectionMode_PERSPECTIVE),
195 mxShadeMode(
drawing::ShadeMode_SMOOTH),
196 maAmbientColor(0x00666666),
197 mbLightingMode(false),
198 maVRP(0.0, 0.0, 1.0),
199 maVPN(0.0, 0.0, 1.0),
200 maVUP(0.0, 1.0, 0.0),
213 maList.push_back(xContext);
215 return xContext.get();
221 auto nAttributeToken = aIter.
getToken();
230 if(aTransform.NeedsAction())
273 mxPrjMode = drawing::ProjectionMode_PARALLEL;
275 mxPrjMode = drawing::ProjectionMode_PERSPECTIVE;
352 for(
size_t a = 0;
a <
maList.size();
a++)
358 drawing::Direction3D aLightDir;
369 xPropSet->setPropertyValue(
"D3DSceneLightColor1", aAny);
370 xPropSet->setPropertyValue(
"D3DSceneLightDirection1", aAny2);
371 xPropSet->setPropertyValue(
"D3DSceneLightOn1", aAny3);
376 xPropSet->setPropertyValue(
"D3DSceneLightColor2", aAny);
377 xPropSet->setPropertyValue(
"D3DSceneLightDirection2", aAny2);
378 xPropSet->setPropertyValue(
"D3DSceneLightOn2", aAny3);
383 xPropSet->setPropertyValue(
"D3DSceneLightColor3", aAny);
384 xPropSet->setPropertyValue(
"D3DSceneLightDirection3", aAny2);
385 xPropSet->setPropertyValue(
"D3DSceneLightOn3", aAny3);
390 xPropSet->setPropertyValue(
"D3DSceneLightColor4", aAny);
391 xPropSet->setPropertyValue(
"D3DSceneLightDirection4", aAny2);
392 xPropSet->setPropertyValue(
"D3DSceneLightOn4", aAny3);
397 xPropSet->setPropertyValue(
"D3DSceneLightColor5", aAny);
398 xPropSet->setPropertyValue(
"D3DSceneLightDirection5", aAny2);
399 xPropSet->setPropertyValue(
"D3DSceneLightOn5", aAny3);
404 xPropSet->setPropertyValue(
"D3DSceneLightColor6", aAny);
405 xPropSet->setPropertyValue(
"D3DSceneLightDirection6", aAny2);
406 xPropSet->setPropertyValue(
"D3DSceneLightOn6", aAny3);
411 xPropSet->setPropertyValue(
"D3DSceneLightColor7", aAny);
412 xPropSet->setPropertyValue(
"D3DSceneLightDirection7", aAny2);
413 xPropSet->setPropertyValue(
"D3DSceneLightOn7", aAny3);
418 xPropSet->setPropertyValue(
"D3DSceneLightColor8", aAny);
419 xPropSet->setPropertyValue(
"D3DSceneLightDirection8", aAny2);
420 xPropSet->setPropertyValue(
"D3DSceneLightOn8", aAny3);
428 drawing::CameraGeometry aCamGeo;
429 aCamGeo.vrp.PositionX =
maVRP.getX();
430 aCamGeo.vrp.PositionY =
maVRP.getY();
431 aCamGeo.vrp.PositionZ =
maVRP.getZ();
432 aCamGeo.vpn.DirectionX =
maVPN.getX();
433 aCamGeo.vpn.DirectionY =
maVPN.getY();
434 aCamGeo.vpn.DirectionZ =
maVPN.getZ();
435 aCamGeo.vup.DirectionX =
maVUP.getX();
436 aCamGeo.vup.DirectionY =
maVUP.getY();
437 aCamGeo.vup.DirectionZ =
maVUP.getZ();
438 xPropSet->setPropertyValue(
"D3DCameraGeometry",
uno::Any(aCamGeo));
bool convertMeasureToCore(sal_Int32 &rValue, std::u16string_view rString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32) const
convert string to measure with meCoreMeasureUnit, using optional min and max values ...
constexpr sal_uInt16 XML_NAMESPACE_DR3D
static SvXMLShapeContext * Create3DSceneChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
sal_Int32 GetDiffuseColor() const
void setSceneAttributes(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
this sets the scene attributes at this propertyset
SvXMLImport & GetImport()
static bool convertB3DVector(::basegfx::B3DVector &rVector, std::u16string_view rValue)
convert string to basegfx::B3DVector
void processSceneAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter)
this should be called for each scene attribute
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
SdXML3DSceneShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
SdXML3DLightContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
void AddShape(css::uno::Reference< css::drawing::XShape > &xShape)
css::uno::Reference< css::drawing::XShapes > mxChildren
#define XMLOFF_WARN_UNKNOWN(area, rIter)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
sal_Int32 getToken() const
::basegfx::B3DVector maVUP
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual ~SdXML3DLightContext() override
css::drawing::ShadeMode mxShadeMode
::basegfx::B3DVector maVPN
SdXML3DSceneAttributesHelper(SvXMLImport &rImporter)
css::uno::Reference< css::drawing::XShape > mxShape
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
const ::basegfx::B3DVector & GetDirection() const
SvXMLImportContext * create3DLightContext(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
creates a 3d light context and adds it to the internal list for later processing
static bool convertBool(bool &rBool, std::u16string_view rString)
OUString toString() const
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
This class deliberately does not support XWeak, to improve performance when loading large documents...
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Handling of tokens in XML:
void SetStyle(bool bSupportsStyle=true)
if bSupportsStyle is false, auto styles will be set but not a style
::basegfx::B3DVector maDirection
#define XML_ELEMENT(prefix, name)
const SvXMLUnitConverter & GetMM100UnitConverter() const
virtual ~SdXML3DSceneShapeContext() override
std::string_view toView() const
#define SAL_WARN(area, stream)
constexpr sal_Int32 TOKEN_MASK
css::drawing::ProjectionMode mxPrjMode
::basegfx::B3DVector maVRP
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
::std::vector< rtl::Reference< SdXML3DLightContext > > maList
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
css::drawing::HomogenMatrix mxHomMat