12#include <rtl/string.hxx>
71const size_t constMaxActionType = 513;
76 return "#" + aRGBString;
127 for (sal_uInt32 i = 0;
i < rPolygon.count(); ++
i)
152 sDotDash += OUString::number(lround(fDotDash)) +
" ";
154 rWriter.
attribute(
"dotDashArray", sDotDash);
185 rWriter.
attribute(
"linejoin",
"Unknown");
190 case css::drawing::LineCap::LineCap_BUTT:
193 case css::drawing::LineCap::LineCap_ROUND:
196 case css::drawing::LineCap::LineCap_SQUARE:
218 switch (rLineAttribute.
getJoin())
233 rWriter.
attribute(
"linejoin",
"Unknown");
236 switch (rLineAttribute.
getCap())
238 case css::drawing::LineCap::LineCap_BUTT:
241 case css::drawing::LineCap::LineCap_ROUND:
244 case css::drawing::LineCap::LineCap_SQUARE:
257 sDotDash += OUString::number(fDotDash) +
" ";
259 rWriter.
attribute(
"dotDashArray", sDotDash);
276 auto const& rGradient = rFillAttribute.
getGradient();
277 if (!rGradient.isDefault())
280 switch (rGradient.getStyle())
283 case css::awt::GradientStyle_LINEAR:
286 case css::awt::GradientStyle_AXIAL:
289 case css::awt::GradientStyle_RADIAL:
292 case css::awt::GradientStyle_ELLIPTICAL:
293 rWriter.
attribute(
"style",
"Elliptical");
295 case css::awt::GradientStyle_SQUARE:
298 case css::awt::GradientStyle_RECT:
302 rWriter.
attribute(
"border", rGradient.getBorder());
303 rWriter.
attribute(
"offsetX", rGradient.getOffsetX());
304 rWriter.
attribute(
"offsetY", rGradient.getOffsetY());
305 rWriter.
attribute(
"angle", rGradient.getAngle());
306 rWriter.
attribute(
"steps", rGradient.getSteps());
308 auto const& rColorStops(rGradient.getColorStops());
309 for (
size_t a(0);
a < rColorStops.size();
a++)
313 convertColorToString(rColorStops[a].getStopColor()));
314 else if (rColorStops.size() == a + 1)
315 rWriter.
attribute(
"endColor", convertColorToString(rColorStops[a].getStopColor()));
319 rWriter.
attribute(
"stopOffset", rColorStops[a].getStopOffset());
320 rWriter.
attribute(
"stopColor", convertColorToString(rColorStops[a].getStopColor()));
327 auto const& rHatch = rFillAttribute.
getHatch();
328 if (!rHatch.isDefault())
331 switch (rHatch.getStyle())
343 rWriter.
attribute(
"distance", rHatch.getDistance());
344 rWriter.
attribute(
"angle", rHatch.getAngle());
345 rWriter.
attribute(
"color", convertColorToString(rHatch.getColor()));
346 rWriter.
attribute(
"minimalDescreteDistance", rHatch.getMinimalDiscreteDistance());
347 rWriter.
attribute(
"isFillBackground", sal_Int32(rHatch.isFillBackground()));
352 if (!rGraphic.isDefault())
366 case css::drawing::ShadeMode_FLAT:
369 case css::drawing::ShadeMode_SMOOTH:
370 rWriter.
attribute(
"shadeMode",
"Smooth");
372 case css::drawing::ShadeMode_PHONG:
375 case css::drawing::ShadeMode_DRAFT:
379 rWriter.
attribute(
"shadeMode",
"Undefined");
384void writeProjectionMode(
::tools::XmlWriter& rWriter,
const css::drawing::ProjectionMode& rMode)
388 case css::drawing::ProjectionMode_PARALLEL:
389 rWriter.
attribute(
"projectionMode",
"Parallel");
391 case css::drawing::ProjectionMode_PERSPECTIVE:
392 rWriter.
attribute(
"projectionMode",
"Perspective");
395 rWriter.
attribute(
"projectionMode",
"Undefined");
400void writeNormalsKind(
::tools::XmlWriter& rWriter,
const css::drawing::NormalsKind& rKind)
404 case css::drawing::NormalsKind_SPECIFIC:
405 rWriter.
attribute(
"normalsKind",
"Specific");
407 case css::drawing::NormalsKind_FLAT:
408 rWriter.
attribute(
"normalsKind",
"Flat");
410 case css::drawing::NormalsKind_SPHERE:
411 rWriter.
attribute(
"normalsKind",
"Sphere");
414 rWriter.
attribute(
"normalsKind",
"Undefined");
420 const css::drawing::TextureProjectionMode& rMode)
424 case css::drawing::TextureProjectionMode_OBJECTSPECIFIC:
427 case css::drawing::TextureProjectionMode_PARALLEL:
430 case css::drawing::TextureProjectionMode_SPHERE:
434 rWriter.
attribute(pElement,
"Undefined");
439void writeTextureKind(
::tools::XmlWriter& rWriter,
const css::drawing::TextureKind2& rKind)
443 case css::drawing::TextureKind2_LUMINANCE:
444 rWriter.
attribute(
"textureKind",
"Luminance");
446 case css::drawing::TextureKind2_INTENSITY:
447 rWriter.
attribute(
"textureKind",
"Intensity");
449 case css::drawing::TextureKind2_COLOR:
450 rWriter.
attribute(
"textureKind",
"Color");
453 rWriter.
attribute(
"textureKind",
"Undefined");
458void writeTextureMode(
::tools::XmlWriter& rWriter,
const css::drawing::TextureMode& rMode)
462 case css::drawing::TextureMode_REPLACE:
463 rWriter.
attribute(
"textureMode",
"Replace");
465 case css::drawing::TextureMode_MODULATE:
466 rWriter.
attribute(
"textureMode",
"Modulate");
468 case css::drawing::TextureMode_BLEND:
469 rWriter.
attribute(
"textureMode",
"Blend");
472 rWriter.
attribute(
"textureMode",
"Undefined");
491 switch (rSpreadMethod)
494 rWriter.
attribute(
"spreadmethod",
"pad");
497 rWriter.
attribute(
"spreadmethod",
"reflect");
500 rWriter.
attribute(
"spreadmethod",
"repeat");
503 rWriter.
attribute(
"spreadmethod",
"unknown");
510 : maFilter(constMaxActionType, false)
518 const OUString& rStreamName)
520 std::unique_ptr<SvStream> pStream;
522 if (rStreamName.isEmpty())
525 pStream.reset(
new SvFileStream(rStreamName, StreamMode::STD_READWRITE | StreamMode::TRUNC));
541class Primitive3DXmlDump
547 for (
size_t i = 0;
i < rSequence.size();
i++)
550 const auto* pBasePrimitive
552 sal_uInt32
nId = pBasePrimitive->getPrimitive3DID();
558 const auto* pExtrudePrimitive3D
564 writeMatrix3D(rWriter, pExtrudePrimitive3D->getTransform());
567 rWriter.
attribute(
"textureSizeX", pExtrudePrimitive3D->getTextureSize().getX());
568 rWriter.
attribute(
"textureSizeY", pExtrudePrimitive3D->getTextureSize().getY());
569 auto const& rLFSAttribute = pExtrudePrimitive3D->getSdrLFSAttribute();
570 writeSdrLineAttribute(rWriter, rLFSAttribute.getLine());
571 writeSdrFillAttribute(rWriter, rLFSAttribute.getFill());
575 auto const& r3DObjectAttributes
576 = pExtrudePrimitive3D->getSdr3DObjectAttribute();
578 writeNormalsKind(rWriter, r3DObjectAttributes.getNormalsKind());
579 writeTextureProjectionMode(rWriter,
"textureProjectionX",
580 r3DObjectAttributes.getTextureProjectionX());
581 writeTextureProjectionMode(rWriter,
"textureProjectionY",
582 r3DObjectAttributes.getTextureProjectionY());
583 writeTextureKind(rWriter, r3DObjectAttributes.getTextureKind());
584 writeTextureMode(rWriter, r3DObjectAttributes.getTextureMode());
585 writeMaterialAttribute(rWriter, r3DObjectAttributes.getMaterial());
588 sal_Int32(r3DObjectAttributes.getNormalsInvert()));
590 sal_Int32(r3DObjectAttributes.getDoubleSided()));
591 rWriter.
attribute(
"shadow3D", sal_Int32(r3DObjectAttributes.getShadow3D()));
593 sal_Int32(r3DObjectAttributes.getTextureFilter()));
595 sal_Int32(r3DObjectAttributes.getReducedLineGeometry()));
599 rWriter.
attribute(
"depth", pExtrudePrimitive3D->getDepth());
600 rWriter.
attribute(
"diagonal", pExtrudePrimitive3D->getDiagonal());
601 rWriter.
attribute(
"backScale", pExtrudePrimitive3D->getBackScale());
603 sal_Int32(pExtrudePrimitive3D->getSmoothNormals()));
605 sal_Int32(pExtrudePrimitive3D->getSmoothLids()));
607 sal_Int32(pExtrudePrimitive3D->getCharacterMode()));
609 sal_Int32(pExtrudePrimitive3D->getCloseFront()));
610 rWriter.
attribute(
"closeBack", sal_Int32(pExtrudePrimitive3D->getCloseBack()));
611 writePolyPolygon(rWriter, pExtrudePrimitive3D->getPolyPolygon());
619 rWriter.
attribute(
"id", sCurrentElementTag);
624 aContainer = pBasePrimitive->get3DDecomposition(aViewInformation3D);
625 decomposeAndWrite(aContainer, rWriter);
636 const OUString& rStreamName)
638 std::unique_ptr<SvStream> pStream;
640 if (rStreamName.isEmpty())
643 pStream.reset(
new SvFileStream(rStreamName, StreamMode::STD_READWRITE | StreamMode::TRUNC));
656 std::size_t nSize = pStream->remainingSize();
657 std::unique_ptr<sal_uInt8[]> pBuffer(
new sal_uInt8[nSize + 1]);
658 pStream->ReadBytes(pBuffer.get(), nSize);
660 SAL_INFO(
"drawinglayer",
"Parsed XML: " << pBuffer.get());
662 return xmlDocUniquePtr(xmlParseDoc(
reinterpret_cast<xmlChar*
>(pBuffer.get())));
669 for (
size_t i = 0;
i < rPrimitive2DSequence.size();
i++)
685 writeMatrix(rWriter, rBitmapPrimitive2D.
getTransform());
697 OUString aBitmapData =
"";
701 aBitmapData = aBitmapData +
",";
738 convertColorToString(rPolyPolygonColorPrimitive2D.
getBColor()));
742 writePolyPolygon(rWriter, aB2DPolyPolygon);
754 convertColorToString(rPointArrayPrimitive2D.
getRGBColor()));
756 const std::vector<basegfx::B2DPoint> aPositions
758 for (std::vector<basegfx::B2DPoint>::const_iterator iter = aPositions.begin();
759 iter != aPositions.end(); ++iter)
762 rWriter.
attribute(
"x", OUString::number(iter->getX()));
763 rWriter.
attribute(
"y", OUString::number(iter->getY()));
788 static_cast<sal_Int32
>(
790 writePolyPolygon(rWriter,
800 static_cast<sal_Int32
>(
802 writePolyPolygon(rWriter,
807 writeLineAttribute(rWriter, rPolygonStrokeArrowPrimitive2D.
getLineAttribute());
835 writeLineAttribute(rWriter, rPolyPolygonStrokePrimitive2D.
getLineAttribute());
850 convertColorToString(rPolygonHairlinePrimitive2D.
getBColor()));
871 convertColorToString(rTextDecoratedPortionPrimitive2D.
getFontColor()));
891 convertColorToString(rTextLinePrimitive2D.
getLineColor()));
903 double fRotate, fShearX;
912 OUString aText = rTextSimplePortionPrimitive2D.
getText();
914 rWriter.
attribute(
"text", aText.replaceAll(
"␁",
"	"));
915 rWriter.
attribute(
"fontcolor", convertColorToString(
921 const std::vector<double> aDx = rTextSimplePortionPrimitive2D.
getDXArray();
924 for (
size_t iDx = 0; iDx < aDx.size(); ++iDx)
926 OString
sName =
"dx" + OString::number(iDx);
949 writePolyPolygon(rWriter, rMaskPrimitive2D.
getMask());
997 if (rSvgRadialGradientPrimitive2D.
isFocalSet())
1008 OString::number(rSvgRadialGradientPrimitive2D.
getRadius()));
1009 writeSpreadMethod(rWriter, rSvgRadialGradientPrimitive2D.getSpreadMethod());
1012 rSvgRadialGradientPrimitive2D.getGradientEntries().front().getOpacity());
1015 writeMatrix(rWriter, rSvgRadialGradientPrimitive2D.getGradientTransform());
1018 writePolyPolygon(rWriter, rSvgRadialGradientPrimitive2D.getPolyPolygon());
1035 writeSpreadMethod(rWriter, rSvgLinearGradientPrimitive2D.getSpreadMethod());
1038 rSvgLinearGradientPrimitive2D.getGradientEntries().front().getOpacity());
1041 writeMatrix(rWriter, rSvgLinearGradientPrimitive2D.getGradientTransform());
1044 writePolyPolygon(rWriter, rSvgLinearGradientPrimitive2D.getPolyPolygon());
1151 rWriter.
attribute(
"modifier", aColorModifier->getModifierName());
1172 const auto& rScenePrimitive2D
1177 auto const& rSceneAttribute = rScenePrimitive2D.getSdrSceneAttribute();
1179 rWriter.
attribute(
"shadowSlant", rSceneAttribute.getShadowSlant());
1181 sal_Int32(rSceneAttribute.getTwoSidedLighting()));
1182 writeShadeMode(rWriter, rSceneAttribute.getShadeMode());
1183 writeProjectionMode(rWriter, rSceneAttribute.getProjectionMode());
1185 auto const& rLightingAttribute = rScenePrimitive2D.getSdrLightingAttribute();
1187 convertColorToString(rLightingAttribute.getAmbientLightColor()));
1189 for (
auto const& rLight : rLightingAttribute.getLightVector())
1192 rWriter.
attribute(
"color", convertColorToString(rLight.getColor()));
1193 rWriter.
attribute(
"directionVectorX", rLight.getDirection().getX());
1194 rWriter.
attribute(
"directionVectorY", rLight.getDirection().getY());
1195 rWriter.
attribute(
"specular", sal_Int32(rLight.getSpecular()));
1200 Primitive3DXmlDump aPrimitive3DXmlDump;
1201 aPrimitive3DXmlDump.decomposeAndWrite(rScenePrimitive2D.getChildren3D(), rWriter);
1209 const char*
aName =
"unhandled";
1219 rWriter.
attribute(
"id", sCurrentElementTag);
1222 auto pBufferedDecomposition
1224 if (pBufferedDecomposition)
1227 "transparenceForShadow",
1228 OString::number(pBufferedDecomposition->getTransparenceForShadow()));
::Color GetPixelColor(sal_Int32 nX, sal_Int32 nY) const
BitmapChecksum GetChecksum() const
const Size & GetSizePixel() const
OUString AsRGBHexString() const
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
B2DRange getB2DRange() const
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
void dump(const drawinglayer::primitive2d::Primitive2DContainer &rPrimitive2DSequence, const OUString &rStreamName)
Dumps the input primitive sequence to xml into a file.
std::vector< bool > maFilter
xmlDocUniquePtr dumpAndParse(const drawinglayer::primitive2d::Primitive2DContainer &aPrimitive2DSequence, const OUString &rStreamName=OUString())
Dumps the input primitive sequence to xml into a file or memory stream and parses the xml for testing...
void decomposeAndWrite(const drawinglayer::primitive2d::Primitive2DContainer &rPrimitive2DSequence, tools::XmlWriter &rWriter)
const OUString & getFamilyName() const
data read access
double getMiterMinimumAngle() const
basegfx::B2DLineJoin getLineJoin() const
css::drawing::LineCap getLineCap() const
const basegfx::BColor & getColor() const
const basegfx::B2DPolyPolygon & getB2DPolyPolygon() const
sal_uInt16 getSpecularIntensity() const
const basegfx::BColor & getSpecular() const
const basegfx::BColor & getEmission() const
const basegfx::BColor & getColor() const
const basegfx::BColor & getColor() const
const FillHatchAttribute & getHatch() const
double getTransparence() const
const FillGradientAttribute & getGradient() const
const SdrFillGraphicAttribute & getFillGraphic() const
css::drawing::LineCap getCap() const
double getTransparence() const
const ::std::vector< double > & getDotDashArray() const
double getFullDotDashLen() const
const basegfx::BColor & getColor() const
basegfx::B2DLineJoin getJoin() const
const ::std::vector< double > & getDotDashArray() const
double getFullDotDashLen() const
virtual void get2DDecomposition(Primitive2DDecompositionVisitor &rVisitor, const geometry::ViewInformation2D &rViewInformation) const
The default implementation will return an empty sequence.
virtual sal_uInt32 getPrimitive2DID() const =0
provide unique ID for fast identifying of known primitive implementations in renderers.
const basegfx::B2DHomMatrix & getTransform() const
const BitmapEx & getBitmap() const
data read access
BufferedDecompositionPrimitive2D class.
virtual void get2DDecomposition(Primitive2DDecompositionVisitor &rVisitor, const geometry::ViewInformation2D &rViewInformation) const override
The getDecomposition default implementation will on demand use create2DDecomposition() if maBuffered2...
const Primitive2DContainer & getChildren() const
data read access
const basegfx::B2DPolyPolygon & getMask() const
data read access
ModifiedColorPrimitive2D class.
const basegfx::BColorModifierSharedPtr & getColorModifier() const
data read access
ObjectInfoPrimitive2D class.
PointArrayPrimitive2D class.
const basegfx::BColor & getRGBColor() const
const std::vector< basegfx::B2DPoint > & getPositions() const
data read access
PolyPolygonColorPrimitive2D class.
const basegfx::BColor & getBColor() const
const basegfx::B2DPolyPolygon & getB2DPolyPolygon() const
data read access
PolyPolygonStrokePrimitive2D class.
const attribute::LineAttribute & getLineAttribute() const
const attribute::StrokeAttribute & getStrokeAttribute() const
const basegfx::B2DPolyPolygon & getB2DPolyPolygon() const
data read access
PolygonHairlinePrimitive2D class.
const basegfx::BColor & getBColor() const
const basegfx::B2DPolygon & getB2DPolygon() const
data read access
PolygonStrokeArrowPrimitive2D class.
const attribute::LineStartEndAttribute & getStart() const
data read access
const attribute::LineStartEndAttribute & getEnd() const
PolygonStrokePrimitive2D class.
const attribute::StrokeAttribute & getStrokeAttribute() const
const basegfx::B2DPolygon & getB2DPolygon() const
data read access
const attribute::LineAttribute & getLineAttribute() const
const basegfx::BColor & getShadowColor() const
double getShadowBlur() const
const basegfx::B2DHomMatrix & getShadowTransform() const
data read access
double getRadius() const
data read access
StructureTagPrimitive2D class.
const vcl::PDFWriter::StructElement & getStructureElement() const
data read access
the basic linear gradient primitive
const basegfx::B2DPoint & getEnd() const
data read access
the basic radial gradient primitive
const basegfx::B2DPoint & getFocal() const
double getRadius() const
data read access
TextDecoratedPortionPrimitive2D class.
const basegfx::BColor & getLineColor() const
const basegfx::B2DHomMatrix & getObjectTransformation() const
data read access
TextSimplePortionPrimitive2D class.
const basegfx::BColor & getFontColor() const
const OUString & getText() const
const ::std::vector< double > & getDXArray() const
const attribute::FontAttribute & getFontAttribute() const
const basegfx::B2DHomMatrix & getTextTransform() const
data read access
UnifiedTransparencePrimitive2D class.
double getTransparence() const
data read access
SdrExtrudePrimitive3D class.
#define PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D
#define PRIMITIVE2D_ID_SCENEPRIMITIVE2D
#define PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D
#define PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D
#define PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D
#define PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D
#define PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D
#define PRIMITIVE2D_ID_SOFTEDGEPRIMITIVE2D
#define PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D
#define PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D
#define PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D
#define PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D
#define PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D
#define PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D
#define PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D
#define PRIMITIVE2D_ID_GROUPPRIMITIVE2D
#define PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D
#define PRIMITIVE2D_ID_SHADOWPRIMITIVE2D
#define PRIMITIVE2D_ID_MASKPRIMITIVE2D
#define PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D
#define PRIMITIVE2D_ID_METAFILEPRIMITIVE2D
#define PRIMITIVE2D_ID_BITMAPPRIMITIVE2D
#define PRIMITIVE2D_ID_SVGLINEARGRADIENTPRIMITIVE2D
#define PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D
#define PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D
#define PRIMITIVE2D_ID_RANGE_SVX
#define PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D
#define PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D
#define PRIMITIVE3D_ID_SDREXTRUDEPRIMITIVE3D
#define SAL_INFO(area, stream)
OUString exportToSvgD(const B2DPolyPolygon &rPolyPoly, bool bUseRelativeCoordinates, bool bDetectQuadraticBeziers, bool bHandleRelativeNextPointCompatible, bool bOOXMLMotionPath=false)
OUString exportToSvgPoints(const B2DPolygon &rPoly)
std::shared_ptr< BColorModifier > BColorModifierSharedPtr
constexpr double rad2deg(double v)
OUString idToString(sal_uInt32 nId)
css::uno::Reference< css::graphic::XPrimitive3D > Primitive3DReference
OUString idToString(sal_uInt32 nId)
#define STREAM_SEEK_TO_BEGIN
#define PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D
#define PRIMITIVE2D_ID_SDRBLOCKTEXTPRIMITIVE2D
std::unique_ptr< xmlDoc, xmlDocDeleter > xmlDocUniquePtr