drawinglayer/Library_drawinglayer.mk | 1 drawinglayer/source/attribute/sdrlightingattribute3d.cxx | 5 drawinglayer/source/primitive3d/Tools.cxx | 67 ++ drawinglayer/source/tools/primitive2dxmldump.cxx | 431 ++++++++++++++ include/drawinglayer/attribute/sdrlightingattribute3d.hxx | 1 include/drawinglayer/primitive3d/Tools.hxx | 21 svx/qa/unit/data/FontWork.odg |binary svx/qa/unit/svdraw.cxx | 40 + 8 files changed, 566 insertions(+)
New commits: commit a2fa768b73d96352ffafd166564d2c1cb2e140c3 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat Nov 6 21:45:37 2021 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Nov 8 13:52:31 2021 +0100 extend XML dumpig for primitives to support fontwork objects This adds support for 3D drawinglayer primitive XML dumping and adds dumping support for many more primitives and attributes that were missing before. This is needed to be able to check the fontwork objects, which can be rendered in 3D. Change-Id: I0e78be4d4030a0cae3d2b952a1a38de8940ee310 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124804 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/Library_drawinglayer.mk b/drawinglayer/Library_drawinglayer.mk index 158ea62be0ac..11edeae98c92 100644 --- a/drawinglayer/Library_drawinglayer.mk +++ b/drawinglayer/Library_drawinglayer.mk @@ -153,6 +153,7 @@ $(eval $(call gb_Library_add_exception_objects,drawinglayer,\ drawinglayer/source/primitive3d/shadowprimitive3d \ drawinglayer/source/primitive3d/textureprimitive3d \ drawinglayer/source/primitive3d/transformprimitive3d \ + drawinglayer/source/primitive3d/Tools \ drawinglayer/source/processor2d/baseprocessor2d \ drawinglayer/source/processor2d/processor2dtools \ drawinglayer/source/processor2d/contourextractor2d \ diff --git a/drawinglayer/source/attribute/sdrlightingattribute3d.cxx b/drawinglayer/source/attribute/sdrlightingattribute3d.cxx index b07fa88c7ce3..90fcc193c271 100644 --- a/drawinglayer/source/attribute/sdrlightingattribute3d.cxx +++ b/drawinglayer/source/attribute/sdrlightingattribute3d.cxx @@ -105,6 +105,11 @@ namespace drawinglayer::attribute return mpSdrLightingAttribute->getLightVector(); } + const basegfx::BColor& SdrLightingAttribute::getAmbientLightColor() const + { + return mpSdrLightingAttribute->maAmbientLight; + } + // color model solver basegfx::BColor SdrLightingAttribute::solveColorModel( const basegfx::B3DVector& rNormalInEyeCoordinates, diff --git a/drawinglayer/source/primitive3d/Tools.cxx b/drawinglayer/source/primitive3d/Tools.cxx new file mode 100644 index 000000000000..c27896b043cc --- /dev/null +++ b/drawinglayer/source/primitive3d/Tools.cxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#include <drawinglayer/primitive3d/Tools.hxx> +#include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx> + +using namespace css; + +namespace drawinglayer::primitive3d +{ +OUString idToString(sal_uInt32 nId) +{ + switch (nId) + { + case PRIMITIVE3D_ID_GROUPPRIMITIVE3D: + return "GROUPPRIMITIVE3D"; + case PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D: + return "HATCHTEXTUREPRIMITIVE3D"; + case PRIMITIVE3D_ID_MODIFIEDCOLORPRIMITIVE3D: + return "MODIFIEDCOLORPRIMITIVE3D"; + case PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D: + return "POLYGONHAIRLINEPRIMITIVE3D"; + case PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D: + return "POLYGONSTROKEPRIMITIVE3D"; + case PRIMITIVE3D_ID_POLYGONTUBEPRIMITIVE3D: + return "POLYGONTUBEPRIMITIVE3D"; + case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D: + return "POLYPOLYGONMATERIALPRIMITIVE3D"; + case PRIMITIVE3D_ID_SDRCUBEPRIMITIVE3D: + return "SDRCUBEPRIMITIVE3D"; + case PRIMITIVE3D_ID_SDREXTRUDEPRIMITIVE3D: + return "SDREXTRUDEPRIMITIVE3D"; + case PRIMITIVE3D_ID_SDRLATHEPRIMITIVE3D: + return "SDRLATHEPRIMITIVE3D"; + case PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D: + return "SDRPOLYPOLYGONPRIMITIVE3D"; + case PRIMITIVE3D_ID_SDRSPHEREPRIMITIVE3D: + return "SDRSPHEREPRIMITIVE3D"; + case PRIMITIVE3D_ID_SHADOWPRIMITIVE3D: + return "SHADOWPRIMITIVE3D"; + case PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D: + return "UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D"; + case PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D: + return "GRADIENTTEXTUREPRIMITIVE3D"; + case PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D: + return "BITMAPTEXTUREPRIMITIVE3D"; + case PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D: + return "TRANSPARENCETEXTUREPRIMITIVE3D"; + case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D: + return "TRANSFORMPRIMITIVE3D"; + case PRIMITIVE3D_ID_HIDDENGEOMETRYPRIMITIVE3D: + return "HIDDENGEOMETRYPRIMITIVE3D"; + default: + return OUString::number((nId >> 16) & 0xFF) + "|" + OUString::number(nId & 0xFF); + } +} + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index 17bb707b666e..b679465a69c2 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -33,6 +33,7 @@ #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx> #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> +#include <drawinglayer/primitive2d/sceneprimitive2d.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <drawinglayer/attribute/lineattribute.hxx> #include <drawinglayer/attribute/fontattribute.hxx> @@ -42,6 +43,18 @@ #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> #include <toolkit/helper/vclunohelper.hxx> +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> +#include <drawinglayer/primitive3d/Tools.hxx> +#include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx> +#include <drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx> +#include <drawinglayer/attribute/sdrlightattribute3d.hxx> +#include <drawinglayer/attribute/sdrfillattribute.hxx> +#include <drawinglayer/attribute/fillgraphicattribute.hxx> +#include <drawinglayer/attribute/fillhatchattribute.hxx> +#include <drawinglayer/attribute/fillgradientattribute.hxx> +#include <drawinglayer/attribute/sdrfillgraphicattribute.hxx> +#include <drawinglayer/attribute/materialattribute3d.hxx> + using namespace drawinglayer::primitive2d; namespace drawinglayer @@ -69,6 +82,26 @@ void writeMatrix(::tools::XmlWriter& rWriter, const basegfx::B2DHomMatrix& rMatr rWriter.attribute("xy33", rMatrix.get(2, 2)); } +void writeMatrix3D(::tools::XmlWriter& rWriter, const basegfx::B3DHomMatrix& rMatrix) +{ + rWriter.attribute("xy11", rMatrix.get(0, 0)); + rWriter.attribute("xy12", rMatrix.get(0, 1)); + rWriter.attribute("xy13", rMatrix.get(0, 2)); + rWriter.attribute("xy14", rMatrix.get(0, 3)); + rWriter.attribute("xy21", rMatrix.get(1, 0)); + rWriter.attribute("xy22", rMatrix.get(1, 1)); + rWriter.attribute("xy23", rMatrix.get(1, 2)); + rWriter.attribute("xy24", rMatrix.get(1, 3)); + rWriter.attribute("xy31", rMatrix.get(2, 0)); + rWriter.attribute("xy32", rMatrix.get(2, 1)); + rWriter.attribute("xy33", rMatrix.get(2, 2)); + rWriter.attribute("xy34", rMatrix.get(2, 3)); + rWriter.attribute("xy41", rMatrix.get(3, 0)); + rWriter.attribute("xy42", rMatrix.get(3, 1)); + rWriter.attribute("xy43", rMatrix.get(3, 2)); + rWriter.attribute("xy44", rMatrix.get(3, 3)); +} + void writePolyPolygon(::tools::XmlWriter& rWriter, const basegfx::B2DPolyPolygon& rB2DPolyPolygon) { rWriter.startElement("polypolygon"); @@ -141,6 +174,271 @@ void writeLineAttribute(::tools::XmlWriter& rWriter, rWriter.endElement(); } +void writeSdrLineAttribute(::tools::XmlWriter& rWriter, + const drawinglayer::attribute::SdrLineAttribute& rLineAttribute) +{ + if (rLineAttribute.isDefault()) + return; + + rWriter.startElement("line"); + rWriter.attribute("color", convertColorToString(rLineAttribute.getColor())); + rWriter.attribute("width", rLineAttribute.getWidth()); + rWriter.attribute("transparence", rLineAttribute.getTransparence()); + + switch (rLineAttribute.getJoin()) + { + case basegfx::B2DLineJoin::NONE: + rWriter.attribute("linejoin", "NONE"); + break; + case basegfx::B2DLineJoin::Bevel: + rWriter.attribute("linejoin", "Bevel"); + break; + case basegfx::B2DLineJoin::Miter: + rWriter.attribute("linejoin", "Miter"); + break; + case basegfx::B2DLineJoin::Round: + rWriter.attribute("linejoin", "Round"); + break; + default: + rWriter.attribute("linejoin", "Unknown"); + break; + } + switch (rLineAttribute.getCap()) + { + case css::drawing::LineCap::LineCap_BUTT: + rWriter.attribute("linecap", "BUTT"); + break; + case css::drawing::LineCap::LineCap_ROUND: + rWriter.attribute("linecap", "ROUND"); + break; + case css::drawing::LineCap::LineCap_SQUARE: + rWriter.attribute("linecap", "SQUARE"); + break; + default: + rWriter.attribute("linecap", "Unknown"); + break; + } + + if (!rLineAttribute.getDotDashArray().empty()) + { + OUString sDotDash; + for (double fDotDash : rLineAttribute.getDotDashArray()) + { + sDotDash += OUString::number(fDotDash) + " "; + } + rWriter.attribute("dotDashArray", sDotDash); + rWriter.attribute("fullDotDashLength", rLineAttribute.getFullDotDashLen()); + } + + rWriter.endElement(); +} + +void writeSdrFillAttribute(::tools::XmlWriter& rWriter, + const drawinglayer::attribute::SdrFillAttribute& rFillAttribute) +{ + if (rFillAttribute.isDefault()) + return; + + rWriter.startElement("fill"); + rWriter.attribute("color", convertColorToString(rFillAttribute.getColor())); + rWriter.attribute("transparence", rFillAttribute.getTransparence()); + + auto const& rGradient = rFillAttribute.getGradient(); + if (!rGradient.isDefault()) + { + rWriter.startElement("gradient"); + switch (rGradient.getStyle()) + { + case drawinglayer::attribute::GradientStyle::Linear: + rWriter.attribute("style", "Linear"); + break; + case drawinglayer::attribute::GradientStyle::Axial: + rWriter.attribute("style", "Axial"); + break; + case drawinglayer::attribute::GradientStyle::Radial: + rWriter.attribute("style", "Radial"); + break; + case drawinglayer::attribute::GradientStyle::Elliptical: + rWriter.attribute("style", "Elliptical"); + break; + case drawinglayer::attribute::GradientStyle::Square: + rWriter.attribute("style", "Square"); + break; + case drawinglayer::attribute::GradientStyle::Rect: + rWriter.attribute("style", "Rect"); + break; + }; + rWriter.attribute("border", rGradient.getBorder()); + rWriter.attribute("offsetX", rGradient.getOffsetX()); + rWriter.attribute("offsetY", rGradient.getOffsetY()); + rWriter.attribute("angle", rGradient.getAngle()); + rWriter.attribute("steps", rGradient.getSteps()); + rWriter.attribute("startColor", convertColorToString(rGradient.getStartColor())); + rWriter.attribute("endColor", convertColorToString(rGradient.getEndColor())); + rWriter.endElement(); + } + + auto const& rHatch = rFillAttribute.getHatch(); + if (!rHatch.isDefault()) + { + rWriter.startElement("hatch"); + switch (rHatch.getStyle()) + { + case drawinglayer::attribute::HatchStyle::Single: + rWriter.attribute("style", "Single"); + break; + case drawinglayer::attribute::HatchStyle::Double: + rWriter.attribute("style", "Double"); + break; + case drawinglayer::attribute::HatchStyle::Triple: + rWriter.attribute("style", "Triple"); + break; + }; + rWriter.attribute("distance", rHatch.getDistance()); + rWriter.attribute("angle", rHatch.getAngle()); + rWriter.attribute("color", convertColorToString(rHatch.getColor())); + rWriter.attribute("minimalDescreteDistance", rHatch.getMinimalDiscreteDistance()); + rWriter.attribute("isFillBackground", sal_Int32(rHatch.isFillBackground())); + rWriter.endElement(); + } + + auto const& rGraphic = rFillAttribute.getFillGraphic(); + if (!rGraphic.isDefault()) + { + rWriter.startElement("graphic"); + // TODO + rWriter.endElement(); + } + + rWriter.endElement(); +} + +void writeShadeMode(::tools::XmlWriter& rWriter, const css::drawing::ShadeMode& rMode) +{ + switch (rMode) + { + case css::drawing::ShadeMode_FLAT: + rWriter.attribute("shadeMode", "Flat"); + break; + case css::drawing::ShadeMode_SMOOTH: + rWriter.attribute("shadeMode", "Smooth"); + break; + case css::drawing::ShadeMode_PHONG: + rWriter.attribute("shadeMode", "Phong"); + break; + case css::drawing::ShadeMode_DRAFT: + rWriter.attribute("shadeMode", "Draft"); + break; + default: + rWriter.attribute("shadeMode", "Undefined"); + break; + } +} + +void writeProjectionMode(::tools::XmlWriter& rWriter, const css::drawing::ProjectionMode& rMode) +{ + switch (rMode) + { + case css::drawing::ProjectionMode_PARALLEL: + rWriter.attribute("projectionMode", "Parallel"); + break; + case css::drawing::ProjectionMode_PERSPECTIVE: + rWriter.attribute("projectionMode", "Perspective"); + break; + default: + rWriter.attribute("projectionMode", "Undefined"); + break; + } +} + +void writeNormalsKind(::tools::XmlWriter& rWriter, const css::drawing::NormalsKind& rKind) +{ + switch (rKind) + { + case css::drawing::NormalsKind_SPECIFIC: + rWriter.attribute("normalsKind", "Specific"); + break; + case css::drawing::NormalsKind_FLAT: + rWriter.attribute("normalsKind", "Flat"); + break; + case css::drawing::NormalsKind_SPHERE: + rWriter.attribute("normalsKind", "Sphere"); + break; + default: + rWriter.attribute("normalsKind", "Undefined"); + break; + } +} + +void writeTextureProjectionMode(::tools::XmlWriter& rWriter, const char* pElement, + const css::drawing::TextureProjectionMode& rMode) +{ + switch (rMode) + { + case css::drawing::TextureProjectionMode_OBJECTSPECIFIC: + rWriter.attribute(pElement, "Specific"); + break; + case css::drawing::TextureProjectionMode_PARALLEL: + rWriter.attribute(pElement, "Parallel"); + break; + case css::drawing::TextureProjectionMode_SPHERE: + rWriter.attribute(pElement, "Sphere"); + break; + default: + rWriter.attribute(pElement, "Undefined"); + break; + } +} + +void writeTextureKind(::tools::XmlWriter& rWriter, const css::drawing::TextureKind2& rKind) +{ + switch (rKind) + { + case css::drawing::TextureKind2_LUMINANCE: + rWriter.attribute("textureKind", "Luminance"); + break; + case css::drawing::TextureKind2_INTENSITY: + rWriter.attribute("textureKind", "Intensity"); + break; + case css::drawing::TextureKind2_COLOR: + rWriter.attribute("textureKind", "Color"); + break; + default: + rWriter.attribute("textureKind", "Undefined"); + break; + } +} + +void writeTextureMode(::tools::XmlWriter& rWriter, const css::drawing::TextureMode& rMode) +{ + switch (rMode) + { + case css::drawing::TextureMode_REPLACE: + rWriter.attribute("textureMode", "Replace"); + break; + case css::drawing::TextureMode_MODULATE: + rWriter.attribute("textureMode", "Modulate"); + break; + case css::drawing::TextureMode_BLEND: + rWriter.attribute("textureMode", "Blend"); + break; + default: + rWriter.attribute("textureMode", "Undefined"); + break; + } +} + +void writeMaterialAttribute(::tools::XmlWriter& rWriter, + const drawinglayer::attribute::MaterialAttribute3D& rMaterial) +{ + rWriter.startElement("material"); + rWriter.attribute("color", convertColorToString(rMaterial.getColor())); + rWriter.attribute("specular", convertColorToString(rMaterial.getSpecular())); + rWriter.attribute("emission", convertColorToString(rMaterial.getEmission())); + rWriter.attribute("specularIntensity", rMaterial.getSpecularIntensity()); + rWriter.endElement(); +} + } // end anonymous namespace Primitive2dXmlDump::Primitive2dXmlDump() @@ -173,6 +471,102 @@ void Primitive2dXmlDump::dump( pStream->Seek(STREAM_SEEK_TO_BEGIN); } +namespace +{ +class Primitive3DXmlDump +{ +public: + void decomposeAndWrite(const drawinglayer::primitive3d::Primitive3DContainer& rSequence, + ::tools::XmlWriter& rWriter) + { + for (size_t i = 0; i < rSequence.size(); i++) + { + drawinglayer::primitive3d::Primitive3DReference xReference = rSequence[i]; + const auto* pBasePrimitive + = static_cast<const drawinglayer::primitive3d::BasePrimitive3D*>(xReference.get()); + sal_uInt32 nId = pBasePrimitive->getPrimitive3DID(); + OUString sCurrentElementTag = drawinglayer::primitive3d::idToString(nId); + switch (nId) + { + case PRIMITIVE3D_ID_SDREXTRUDEPRIMITIVE3D: + { + const auto* pExtrudePrimitive3D + = static_cast<const drawinglayer::primitive3d::SdrExtrudePrimitive3D*>( + xReference.get()); + rWriter.startElement("extrude3D"); + + rWriter.startElement("matrix3D"); + writeMatrix3D(rWriter, pExtrudePrimitive3D->getTransform()); + rWriter.endElement(); + + rWriter.attribute("textureSizeX", pExtrudePrimitive3D->getTextureSize().getX()); + rWriter.attribute("textureSizeY", pExtrudePrimitive3D->getTextureSize().getY()); + auto const& rLFSAttribute = pExtrudePrimitive3D->getSdrLFSAttribute(); + writeSdrLineAttribute(rWriter, rLFSAttribute.getLine()); + writeSdrFillAttribute(rWriter, rLFSAttribute.getFill()); + + rWriter.startElement("object3Dattributes"); + { + auto const& r3DObjectAttributes + = pExtrudePrimitive3D->getSdr3DObjectAttribute(); + + writeNormalsKind(rWriter, r3DObjectAttributes.getNormalsKind()); + writeTextureProjectionMode(rWriter, "textureProjectionX", + r3DObjectAttributes.getTextureProjectionX()); + writeTextureProjectionMode(rWriter, "textureProjectionY", + r3DObjectAttributes.getTextureProjectionY()); + writeTextureKind(rWriter, r3DObjectAttributes.getTextureKind()); + writeTextureMode(rWriter, r3DObjectAttributes.getTextureMode()); + writeMaterialAttribute(rWriter, r3DObjectAttributes.getMaterial()); + + rWriter.attribute("normalsInvert", + sal_Int32(r3DObjectAttributes.getNormalsInvert())); + rWriter.attribute("doubleSided", + sal_Int32(r3DObjectAttributes.getDoubleSided())); + rWriter.attribute("shadow3D", sal_Int32(r3DObjectAttributes.getShadow3D())); + rWriter.attribute("textureFilter", + sal_Int32(r3DObjectAttributes.getTextureFilter())); + rWriter.attribute("reducedGeometry", + sal_Int32(r3DObjectAttributes.getReducedLineGeometry())); + } + rWriter.endElement(); + + rWriter.attribute("depth", pExtrudePrimitive3D->getDepth()); + rWriter.attribute("diagonal", pExtrudePrimitive3D->getDiagonal()); + rWriter.attribute("backScale", pExtrudePrimitive3D->getBackScale()); + rWriter.attribute("smoothNormals", + sal_Int32(pExtrudePrimitive3D->getSmoothNormals())); + rWriter.attribute("smoothLids", + sal_Int32(pExtrudePrimitive3D->getSmoothLids())); + rWriter.attribute("characterMode", + sal_Int32(pExtrudePrimitive3D->getCharacterMode())); + rWriter.attribute("closeFront", + sal_Int32(pExtrudePrimitive3D->getCloseFront())); + rWriter.attribute("closeBack", sal_Int32(pExtrudePrimitive3D->getCloseBack())); + writePolyPolygon(rWriter, pExtrudePrimitive3D->getPolyPolygon()); + rWriter.endElement(); + } + break; + + default: + { + rWriter.startElement("unhandled"); + rWriter.attribute("id", + OUStringToOString(sCurrentElementTag, RTL_TEXTENCODING_UTF8)); + rWriter.attribute("idNumber", nId); + + drawinglayer::geometry::ViewInformation3D aViewInformation3D; + drawinglayer::primitive3d::Primitive3DContainer aContainer; + aContainer = pBasePrimitive->get3DDecomposition(aViewInformation3D); + decomposeAndWrite(aContainer, rWriter); + rWriter.endElement(); + } + break; + } + } + } +}; +} xmlDocUniquePtr Primitive2dXmlDump::dumpAndParse( const drawinglayer::primitive2d::Primitive2DContainer& rPrimitive2DSequence, const OUString& rStreamName) @@ -620,6 +1014,43 @@ void Primitive2dXmlDump::decomposeAndWrite( break; } + case PRIMITIVE2D_ID_SCENEPRIMITIVE2D: + { + const auto& rScenePrimitive2D + = dynamic_cast<const drawinglayer::primitive2d::ScenePrimitive2D&>( + *pBasePrimitive); + rWriter.startElement("scene"); + + auto const& rSceneAttribute = rScenePrimitive2D.getSdrSceneAttribute(); + + rWriter.attribute("shadowSlant", rSceneAttribute.getShadowSlant()); + rWriter.attribute("isTwoSidedLighting", + sal_Int32(rSceneAttribute.getTwoSidedLighting())); + writeShadeMode(rWriter, rSceneAttribute.getShadeMode()); + writeProjectionMode(rWriter, rSceneAttribute.getProjectionMode()); + + auto const& rLightingAttribute = rScenePrimitive2D.getSdrLightingAttribute(); + rWriter.attribute("ambientLightColor", + convertColorToString(rLightingAttribute.getAmbientLightColor())); + rWriter.startElement("lights"); + for (auto const& rLight : rLightingAttribute.getLightVector()) + { + rWriter.startElement("light"); + rWriter.attribute("color", convertColorToString(rLight.getColor())); + rWriter.attribute("directionVectorX", rLight.getDirection().getX()); + rWriter.attribute("directionVectorY", rLight.getDirection().getY()); + rWriter.attribute("specular", sal_Int32(rLight.getSpecular())); + rWriter.endElement(); + } + rWriter.endElement(); + + Primitive3DXmlDump aPrimitive3DXmlDump; + aPrimitive3DXmlDump.decomposeAndWrite(rScenePrimitive2D.getChildren3D(), rWriter); + + rWriter.endElement(); + break; + } + default: { OString aName("unhandled"); diff --git a/include/drawinglayer/attribute/sdrlightingattribute3d.hxx b/include/drawinglayer/attribute/sdrlightingattribute3d.hxx index d7557ebbd45a..ae2155a542ab 100644 --- a/include/drawinglayer/attribute/sdrlightingattribute3d.hxx +++ b/include/drawinglayer/attribute/sdrlightingattribute3d.hxx @@ -68,6 +68,7 @@ namespace drawinglayer::attribute bool operator==(const SdrLightingAttribute& rCandidate) const; // data read access + const basegfx::BColor& getAmbientLightColor() const; const ::std::vector< Sdr3DLightAttribute >& getLightVector() const; // color model solver diff --git a/include/drawinglayer/primitive3d/Tools.hxx b/include/drawinglayer/primitive3d/Tools.hxx new file mode 100644 index 000000000000..4f0d4967efb1 --- /dev/null +++ b/include/drawinglayer/primitive3d/Tools.hxx @@ -0,0 +1,21 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <rtl/ustring.hxx> + +namespace drawinglayer::primitive3d +{ +OUString DRAWINGLAYER_DLLPUBLIC idToString(sal_uInt32 nId); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/qa/unit/data/FontWork.odg b/svx/qa/unit/data/FontWork.odg new file mode 100644 index 000000000000..e14d2f70bde7 Binary files /dev/null and b/svx/qa/unit/data/FontWork.odg differ diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx index 8cf0f889eea7..5050136991bf 100644 --- a/svx/qa/unit/svdraw.cxx +++ b/svx/qa/unit/svdraw.cxx @@ -351,6 +351,46 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testAutoHeightMultiColShape) static_cast<sal_Int32>(o3tl::convert(2477601, o3tl::Length::emu, o3tl::Length::mm100)), xShape->getSize().Height, 1); } + +CPPUNIT_TEST_FIXTURE(SvdrawTest, testFontWorks) +{ + OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/FontWork.odg"); + mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.drawing.DrawingDocument"); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDrawPagesSupplier.is()); + uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages()); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDrawPage.is()); + uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShape.is()); + + auto pDrawPage = dynamic_cast<SvxDrawPage*>(xDrawPage.get()); + CPPUNIT_ASSERT(pDrawPage); + SdrPage* pSdrPage = pDrawPage->GetSdrPage(); + + ScopedVclPtrInstance<VirtualDevice> aVirtualDevice; + sdr::contact::ObjectContactOfObjListPainter aObjectContact(*aVirtualDevice, + { pSdrPage->GetObj(0) }, nullptr); + const auto& rDrawPageVOContact + = pSdrPage->GetViewContact().GetViewObjectContact(aObjectContact); + sdr::contact::DisplayInfo aDisplayInfo; + drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence; + rDrawPageVOContact.getPrimitive2DSequenceHierarchy(aDisplayInfo, xPrimitiveSequence); + + drawinglayer::Primitive2dXmlDump aDumper; + xmlDocUniquePtr pXmlDoc = aDumper.dumpAndParse(xPrimitiveSequence); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/primitive2D", 1); + + assertXPath(pXmlDoc, "//scene", "projectionMode", "Perspective"); + assertXPath(pXmlDoc, "//scene/extrude3D[1]/fill", "color", "#ff0000"); + assertXPath(pXmlDoc, "//scene/extrude3D[1]/object3Dattributes/material", "color", "#ff0000"); + assertXPath(pXmlDoc, "//scene/extrude3D[1]/object3Dattributes/material", "specularIntensity", + "20"); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */