Inkscape
Vector Graphics Editor
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
Inkscape::Extension::Internal::SvgBuilder Class Reference

Builds the inner SVG representation using libpoppler from the calls of PdfParser. More...

#include <svg-builder.h>

Public Member Functions

 SvgBuilder (SPDocument *document, gchar *docname, XRef *xref)
 
 SvgBuilder (SvgBuilder *parent, Inkscape::XML::Node *root)
 
virtual ~SvgBuilder ()
 
void setDocumentSize (double width, double height)
 
void setMargins (const Geom::Rect &page, const Geom::Rect &margins, const Geom::Rect &bleed)
 Calculate the page margin size based on the pdf settings.
 
void cropPage (const Geom::Rect &bbox)
 Crop to this bounding box, do this before setMargins() but after setDocumentSize.
 
void setMetadata (char const *name, const std::string &content)
 
void setAsLayer (const char *layer_name=nullptr, bool visible=true)
 Sets groupmode of the current container to 'layer' and sets its label if given.
 
void setGroupOpacity (double opacity)
 Sets the current container's opacity.
 
Inkscape::XML::NodegetPreferences ()
 
void pushPage (const std::string &label, GfxState *state)
 We're creating a multi-page document, push page number.
 
void setPageMode (bool as_pages)
 
bool shouldMergePath (bool is_fill, const std::string &path)
 Returns the CSSAttr of the previously added path if it's exactly the same path AND is missing the fill or stroke that is now being painted.
 
bool mergePath (GfxState *state, bool is_fill, const std::string &path, bool even_odd=false)
 Set the fill XOR stroke of the previously added path, if that path is missing the given attribute AND the path is exactly the same.
 
void addPath (GfxState *state, bool fill, bool stroke, bool even_odd=false)
 Emits the current path in poppler's GfxState data structure Can be used to do filling and stroking at once.
 
void addClippedFill (GfxShading *shading, const Geom::Affine shading_tr)
 
void addShadedFill (GfxShading *shading, const Geom::Affine shading_tr, GfxPath *path, const Geom::Affine tr, bool even_odd=false)
 Emits the current path in poppler's GfxState data structure The path is set to be filled with the given shading.
 
void addImage (GfxState *state, Stream *str, int width, int height, GfxImageColorMap *color_map, bool interpolate, int *mask_colors)
 
void addImageMask (GfxState *state, Stream *str, int width, int height, bool invert, bool interpolate)
 
void addMaskedImage (GfxState *state, Stream *str, int width, int height, GfxImageColorMap *color_map, bool interpolate, Stream *mask_str, int mask_width, int mask_height, bool invert_mask, bool mask_interpolate)
 
void addSoftMaskedImage (GfxState *state, Stream *str, int width, int height, GfxImageColorMap *color_map, bool interpolate, Stream *mask_str, int mask_width, int mask_height, GfxImageColorMap *mask_color_map, bool mask_interpolate)
 
void applyOptionalMask (Inkscape::XML::Node *mask, Inkscape::XML::Node *target)
 Take a constructed mask and decide how to apply it to the target.
 
void startGroup (GfxState *state, double *bbox, GfxColorSpace *blending_color_space, bool isolated, bool knockout, bool for_softmask)
 Starts building a new transparency group.
 
void finishGroup (GfxState *state, bool for_softmask)
 
void popGroup (GfxState *state)
 
void beginString (GfxState *state, int len)
 Begin and end string is the inner most text processing step which tells us we're about to have a certain number of chars.
 
void endString (GfxState *state)
 
void addChar (GfxState *state, double x, double y, double dx, double dy, double ax, double ay, double originX, double originY, CharCode code, int nBytes, Unicode const *u, int uLen)
 Adds the specified character to the text buffer Takes care of converting it to UTF-8 and generates a new style repr if style has changed since the last call.
 
void beginTextObject (GfxState *state)
 These text object functions are the outer most calls for begining and ending text.
 
void endTextObject (GfxState *state)
 
bool isPatternTypeSupported (GfxPattern *pattern)
 Checks whether the given pattern type can be represented in SVG Used by PdfParser to decide when to do fallback operations.
 
void setFontStrategies (FontStrategies fs)
 
void saveState (GfxState *state)
 
void restoreState (GfxState *state)
 
void updateStyle (GfxState *state)
 Sets _invalidated_style to true to indicate that styles have to be updated Used for text output when glyphs are buffered till a font change.
 
void updateFont (GfxState *state, std::shared_ptr< CairoFont > cairo_font, bool flip)
 Updates _css_font according to the font set in parameter state.
 
void updateTextPosition (double tx, double ty)
 Updates current text position.
 
void updateTextShift (GfxState *state, double shift)
 Shifts the current text position by the given amount (specified in text space)
 
void updateTextMatrix (GfxState *state, bool flip)
 Flushes the buffered characters.
 
void beforeStateChange (GfxState *old_state)
 Notifies the svg builder the state will change.
 
void setClip (GfxState *state, GfxClipType clip, bool is_bbox=false)
 Clips to the current path set in GfxState.
 
void addOptionalGroup (const std::string &oc, const std::string &label, bool visible=true)
 
Inkscape::XML::NodebeginLayer (const std::string &label, bool visible)
 
void beginMarkedContent (const char *name=nullptr, const char *group=nullptr)
 
void endLayer (Inkscape::XML::Node *save)
 
void endMarkedContent ()
 
void addColorProfile (unsigned char *profBuf, int length)
 

Static Public Member Functions

static FontStrategies autoFontStrategies (FontStrategy s, FontList fonts)
 Decide what to do for each font in the font list, with the given strategy.
 

Private Member Functions

void _init ()
 
gchar * _createPattern (GfxPattern *pattern, GfxState *state, bool is_stroke=false)
 Creates a pattern from poppler's data structure Handles linear and radial gradients.
 
gchar * _createGradient (GfxShading *shading, const Geom::Affine pat_matrix, bool for_shading=false)
 Creates a linear or radial gradient from poppler's data structure.
 
void _addStopToGradient (Inkscape::XML::Node *gradient, double offset, GfxColor *color, GfxColorSpace *space, double opacity)
 Adds a stop with the given properties to the gradient's representation.
 
bool _addGradientStops (Inkscape::XML::Node *gradient, GfxShading *shading, _POPPLER_CONST Function *func)
 
gchar * _createTilingPattern (GfxTilingPattern *tiling_pattern, GfxState *state, bool is_stroke=false)
 Creates a tiling pattern from poppler's data structure Creates a sub-page PdfParser and uses it to parse the pattern's content stream.
 
Inkscape::XML::Node_createImage (Stream *str, int width, int height, GfxImageColorMap *color_map, bool interpolate, int *mask_colors, bool alpha_only=false, bool invert_alpha=false)
 Creates an <image> element containing the given ImageStream as a PNG.
 
Inkscape::XML::Node_createMask (double width, double height)
 Creates a <mask> with the specified width and height and adds to <defs> If we're not the top-level SvgBuilder, creates a <defs> too and adds the mask to it.
 
Inkscape::XML::Node_createClip (const std::string &d, const Geom::Affine tr, bool even_odd)
 
SPCSSAttr_setStyle (GfxState *state, bool fill, bool stroke, bool even_odd=false)
 Sets style properties from poppler's GfxState data structure.
 
void _setStrokeStyle (SPCSSAttr *css, GfxState *state)
 Sets stroke style from poppler's GfxState data structure Uses the given SPCSSAttr for storing the style properties.
 
void _setFillStyle (SPCSSAttr *css, GfxState *state, bool even_odd)
 Sets fill style from poppler's GfxState data structure Uses the given SPCSSAttr for storing the style properties.
 
void _setTextStyle (Inkscape::XML::Node *node, GfxState *state, SPCSSAttr *font_style, Geom::Affine text_affine)
 Sets the style for the text, rendered or un-rendered, preserving the text_transform for any gradients or other patterns.
 
void _setBlendMode (Inkscape::XML::Node *node, GfxState *state)
 Sets blend style properties from poppler's GfxState data structure \update a SPCSSAttr with all mix-blend-mode set.
 
void _setTransform (Inkscape::XML::Node *node, GfxState *state, Geom::Affine extra=Geom::identity())
 
Inkscape::XML::Node_flushTextText (GfxState *state, double text_scale, const Geom::Affine &text_transform)
 Create text node for text.
 
Inkscape::XML::Node_flushTextPath (GfxState *state, double text_scale, const Geom::Affine &text_transform)
 Create path node(s) for text.
 
void _flushText (GfxState *state)
 Writes the buffered characters to the SVG document.
 
Inkscape::XML::Node_pushGroup ()
 
Inkscape::XML::Node_popGroup ()
 
Inkscape::XML::Node_pushContainer (const char *name)
 
Inkscape::XML::Node_pushContainer (Inkscape::XML::Node *node)
 
Inkscape::XML::Node_popContainer ()
 
Inkscape::XML::Node_getClip (const Inkscape::XML::Node *node)
 Return the active clip as a new xml node.
 
bool _shouldClip (const Inkscape::XML::Node *node) const
 
Inkscape::XML::Node_addToContainer (const char *name)
 Create an svg element and append it to the current container object.
 
Inkscape::XML::Node_renderText (std::shared_ptr< CairoFont > cairo_font, double font_size, const Geom::Affine &transform, cairo_glyph_t *cairo_glyphs, unsigned int count)
 Renders the text as a path object using cairo and returns the node object.
 
void _setClipPath (Inkscape::XML::Node *node)
 
void _addToContainer (Inkscape::XML::Node *node, bool release=true)
 Append the given xml element to the current container object, clipping and masking as needed.
 
Inkscape::XML::Node_getGradientNode (Inkscape::XML::Node *node, bool is_fill)
 Find the fill or stroke gradient we previously set on this node.
 
std::string convertGfxColor (const GfxColor *color, GfxColorSpace *space)
 
std::string _getColorProfile (cmsHPROFILE hp)
 Return the color profile name if it's already been added.
 

Static Private Member Functions

static bool _attrEqual (Inkscape::XML::Node *a, Inkscape::XML::Node *b, char const *attr)
 

Private Attributes

std::string _aria_label
 
bool _aria_space = false
 
std::vector< Inkscape::XML::Node * > _node_stack
 
std::vector< GfxState * > _mask_groups
 
int _clip_groups = 0
 
FontStrategies _font_strategies
 
double _css_font_size = 1.0
 
SPCSSAttr_css_font
 
std::string _font_specification
 
double _text_size
 
Geom::Affine _text_matrix
 
Geom::Point _text_position
 
std::vector< SvgGlyph_glyphs
 
std::shared_ptr< CairoFont_cairo_font
 
bool _in_text_object
 
bool _invalidated_style
 
bool _invalidated_strategy = false
 
bool _for_softmask = false
 
bool _is_top_level
 
SPDocument_doc
 
gchar * _docname
 
XRef * _xref
 
Inkscape::XML::Document_xml_doc
 
Inkscape::XML::Node_root
 
Inkscape::XML::Node_container
 
Inkscape::XML::Node_preferences
 
double _width
 
double _height
 
bool _as_pages = true
 
Inkscape::XML::Node_page = nullptr
 
int _page_num = 0
 
double _page_left = 0
 
double _page_top = 0
 
bool _page_offset = false
 
Geom::Affine _page_affine = Geom::identity()
 
std::map< std::string, std::pair< std::string, bool > > _ocgs
 
std::string _icc_profile
 
std::map< cmsHPROFILE, std::string > _icc_profiles
 
ClipHistoryEntry_clip_history
 
Inkscape::XML::Node_clip_text = nullptr
 
Inkscape::XML::Node_clip_text_group = nullptr
 
Inkscape::XML::Node_prev_clip = nullptr
 

Detailed Description

Builds the inner SVG representation using libpoppler from the calls of PdfParser.

Definition at line 101 of file svg-builder.h.

Constructor & Destructor Documentation

◆ SvgBuilder() [1/2]

Inkscape::Extension::Internal::SvgBuilder::SvgBuilder ( SPDocument document,
gchar *  docname,
XRef *  xref 
)

◆ SvgBuilder() [2/2]

Inkscape::Extension::Internal::SvgBuilder::SvgBuilder ( SvgBuilder parent,
Inkscape::XML::Node root 
)

Definition at line 87 of file svg-builder.cpp.

References _container, _doc, _docname, _init(), _is_top_level, _preferences, _root, _xml_doc, _xref, parent, and root.

◆ ~SvgBuilder()

Inkscape::Extension::Internal::SvgBuilder::~SvgBuilder ( )
virtual

Definition at line 98 of file svg-builder.cpp.

References _clip_history.

Member Function Documentation

◆ _addGradientStops()

bool Inkscape::Extension::Internal::SvgBuilder::_addGradientStops ( Inkscape::XML::Node gradient,
GfxShading *  shading,
_POPPLER_CONST Function *  func 
)
private

◆ _addStopToGradient()

void Inkscape::Extension::Internal::SvgBuilder::_addStopToGradient ( Inkscape::XML::Node gradient,
double  offset,
GfxColor *  color,
GfxColorSpace *  space,
double  opacity 
)
private

◆ _addToContainer() [1/2]

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_addToContainer ( const char *  name)
private

Create an svg element and append it to the current container object.

Definition at line 333 of file svg-builder.cpp.

References _addToContainer(), _xml_doc, Inkscape::XML::Document::createElement(), name, and node.

Referenced by _addToContainer(), _flushTextText(), _renderText(), addImage(), addImageMask(), addMaskedImage(), addPath(), addShadedFill(), addSoftMaskedImage(), and popGroup().

◆ _addToContainer() [2/2]

void Inkscape::Extension::Internal::SvgBuilder::_addToContainer ( Inkscape::XML::Node node,
bool  release = true 
)
private

Append the given xml element to the current container object, clipping and masking as needed.

if release is true (default), the XML node will be GC released too.

Definition at line 345 of file svg-builder.cpp.

References _container, Inkscape::XML::Node::appendChild(), node, Inkscape::XML::Node::parent(), and Inkscape::GC::release().

◆ _attrEqual()

bool Inkscape::Extension::Internal::SvgBuilder::_attrEqual ( Inkscape::XML::Node a,
Inkscape::XML::Node b,
char const *  attr 
)
staticprivate

Definition at line 2360 of file svg-builder.cpp.

References Inkscape::XML::Node::attribute().

Referenced by applyOptionalMask().

◆ _createClip()

◆ _createGradient()

gchar * Inkscape::Extension::Internal::SvgBuilder::_createGradient ( GfxShading *  shading,
const Geom::Affine  pat_matrix,
bool  for_shading = false 
)
private

Creates a linear or radial gradient from poppler's data structure.

Parameters
shadingpoppler's data structure for the shading
matrixgradient transformation, can be null
for_shadingtrue if we're creating this for a shading operator; false otherwise
Returns
id of the created object

Definition at line 1141 of file svg-builder.cpp.

References _addGradientStops(), _doc, _xml_doc, Inkscape::XML::Node::appendChild(), Inkscape::XML::Node::attribute(), Inkscape::XML::Document::createElement(), SPDocument::getDefs(), SPObject::getRepr(), Geom::identity(), Inkscape::GC::release(), Inkscape::XML::Node::setAttribute(), Inkscape::XML::Node::setAttributeOrRemoveIfEmpty(), Inkscape::XML::Node::setAttributeSvgDouble(), and sp_svg_transform_write().

Referenced by _createPattern(), and addShadedFill().

◆ _createImage()

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_createImage ( Stream *  str,
int  width,
int  height,
GfxImageColorMap *  color_map,
bool  interpolate,
int *  mask_colors,
bool  alpha_only = false,
bool  invert_alpha = false 
)
private

◆ _createMask()

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_createMask ( double  width,
double  height 
)
private

Creates a <mask> with the specified width and height and adds to <defs> If we're not the top-level SvgBuilder, creates a <defs> too and adds the mask to it.

Returns
the created XML node

Definition at line 2213 of file svg-builder.cpp.

References _doc, _is_top_level, _xml_doc, Inkscape::XML::Node::appendChild(), Inkscape::XML::Document::createElement(), SPDocument::getDefs(), SPObject::getRepr(), height, Inkscape::XML::Node::lastChild(), Inkscape::GC::release(), Inkscape::XML::Node::setAttribute(), Inkscape::XML::Node::setAttributeSvgDouble(), and width.

Referenced by addImageMask(), addMaskedImage(), addSoftMaskedImage(), and startGroup().

◆ _createPattern()

gchar * Inkscape::Extension::Internal::SvgBuilder::_createPattern ( GfxPattern *  pattern,
GfxState *  state,
bool  is_stroke = false 
)
private

Creates a pattern from poppler's data structure Handles linear and radial gradients.

Creates a new PdfParser and uses it to build a tiling pattern.

Returns
a url pointing to the created pattern

Definition at line 1050 of file svg-builder.cpp.

References _createGradient(), _createTilingPattern(), _height, Inkscape::Util::Quantity::convert(), ctmToAffine(), and stateToAffine().

Referenced by _setFillStyle(), and _setStrokeStyle().

◆ _createTilingPattern()

gchar * Inkscape::Extension::Internal::SvgBuilder::_createTilingPattern ( GfxTilingPattern *  tiling_pattern,
GfxState *  state,
bool  is_stroke = false 
)
private

◆ _flushText()

void Inkscape::Extension::Internal::SvgBuilder::_flushText ( GfxState *  state)
private

◆ _flushTextPath()

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_flushTextPath ( GfxState *  state,
double  text_scale,
const Geom::Affine text_transform 
)
private

◆ _flushTextText()

◆ _getClip()

◆ _getColorProfile()

◆ _getGradientNode()

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_getGradientNode ( Inkscape::XML::Node node,
bool  is_fill 
)
private

Find the fill or stroke gradient we previously set on this node.

Definition at line 2349 of file svg-builder.cpp.

References _doc, css, SPDocument::getObjectById(), node, sp_repr_css_attr(), and try_extract_uri_id().

Referenced by applyOptionalMask().

◆ _init()

void Inkscape::Extension::Internal::SvgBuilder::_init ( )
private

◆ _popContainer()

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_popContainer ( )
private

◆ _popGroup()

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_popGroup ( )
private

Definition at line 375 of file svg-builder.cpp.

References _container, _popContainer(), and _root.

Referenced by _flushTextPath(), beginLayer(), endLayer(), endMarkedContent(), and pushPage().

◆ _pushContainer() [1/2]

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_pushContainer ( const char *  name)
private

◆ _pushContainer() [2/2]

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_pushContainer ( Inkscape::XML::Node node)
private

Definition at line 306 of file svg-builder.cpp.

References _clip_history, _container, _node_stack, node, and ClipHistoryEntry::save().

◆ _pushGroup()

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_pushGroup ( )
private

◆ _renderText()

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::_renderText ( std::shared_ptr< CairoFont cairo_font,
double  font_size,
const Geom::Affine transform,
cairo_glyph_t *  cairo_glyphs,
unsigned int  count 
)
private

Renders the text as a path object using cairo and returns the node object.

If the path is empty (e.g. due to trying to render a color bitmap font), return path node with empty "d" attribute. The aria attribute will still contain the original text.

cairo_font - The font that cairo can use to convert text to path. font_size - The size of the text when drawing the path. transform - The matrix which will place the text on the page, this is critical to allow cairo to render all the required parts of the text. cairo_glyphs - A pointer to a list of glyphs to render. count - A count of the number of glyphs to render.

Definition at line 1803 of file svg-builder.cpp.

References _addToContainer(), _aria_label, _height, _width, extract_pathvector_from_cairo(), ink_cairo_transform(), Inkscape::XML::Node::setAttribute(), sp_svg_write_path(), and surface.

Referenced by _flushTextPath().

◆ _setBlendMode()

void Inkscape::Extension::Internal::SvgBuilder::_setBlendMode ( Inkscape::XML::Node node,
GfxState *  state 
)
private

Sets blend style properties from poppler's GfxState data structure \update a SPCSSAttr with all mix-blend-mode set.

Definition at line 598 of file svg-builder.cpp.

References css, enum_blend_mode, key, node, Inkscape::XML::Node::setAttributeOrRemoveIfEmpty(), sp_repr_css_attr(), sp_repr_css_attr_unref(), sp_repr_css_set_property(), and sp_repr_css_write_string().

Referenced by _flushText(), addImage(), addImageMask(), addMaskedImage(), addPath(), and addSoftMaskedImage().

◆ _setClipPath()

void Inkscape::Extension::Internal::SvgBuilder::_setClipPath ( Inkscape::XML::Node node)
private

◆ _setFillStyle()

void Inkscape::Extension::Internal::SvgBuilder::_setFillStyle ( SPCSSAttr css,
GfxState *  state,
bool  even_odd 
)
private

Sets fill style from poppler's GfxState data structure Uses the given SPCSSAttr for storing the style properties.

Definition at line 571 of file svg-builder.cpp.

References _createPattern(), convertGfxColor(), css, sp_repr_css_set_property(), and Inkscape::CSSOStringStream::str().

Referenced by _setStyle(), addImageMask(), and mergePath().

◆ _setStrokeStyle()

void Inkscape::Extension::Internal::SvgBuilder::_setStrokeStyle ( SPCSSAttr css,
GfxState *  state 
)
private

Sets stroke style from poppler's GfxState data structure Uses the given SPCSSAttr for storing the style properties.

Definition at line 480 of file svg-builder.cpp.

References _createPattern(), convertGfxColor(), css, dash_pattern, sp_repr_css_set_property(), and Inkscape::CSSOStringStream::str().

Referenced by _setStyle(), and mergePath().

◆ _setStyle()

SPCSSAttr * Inkscape::Extension::Internal::SvgBuilder::_setStyle ( GfxState *  state,
bool  fill,
bool  stroke,
bool  even_odd = false 
)
private

Sets style properties from poppler's GfxState data structure.

Returns
SPCSSAttr with all the relevant properties set

Definition at line 620 of file svg-builder.cpp.

References _setFillStyle(), _setStrokeStyle(), css, sp_repr_css_attr_new(), and sp_repr_css_set_property().

Referenced by _setTextStyle(), and addPath().

◆ _setTextStyle()

void Inkscape::Extension::Internal::SvgBuilder::_setTextStyle ( Inkscape::XML::Node node,
GfxState *  state,
SPCSSAttr font_style,
Geom::Affine  ta 
)
private

Sets the style for the text, rendered or un-rendered, preserving the text_transform for any gradients or other patterns.

These values were promised to us when the font was updated.

Definition at line 1771 of file svg-builder.cpp.

References _setStyle(), has_fill(), has_stroke(), node, sp_repr_css_attr_unref(), sp_repr_css_change(), and sp_repr_css_merge().

Referenced by _flushTextPath(), and _flushTextText().

◆ _setTransform()

void Inkscape::Extension::Internal::SvgBuilder::_setTransform ( Inkscape::XML::Node node,
GfxState *  state,
Geom::Affine  extra = Geom::identity() 
)
private

◆ _shouldClip()

◆ addChar()

void Inkscape::Extension::Internal::SvgBuilder::addChar ( GfxState *  state,
double  x,
double  y,
double  dx,
double  dy,
double  ax,
double  ay,
double  originX,
double  originY,
CharCode  code,
int  nBytes,
Unicode const *  u,
int  uLen 
)

Adds the specified character to the text buffer Takes care of converting it to UTF-8 and generates a new style repr if style has changed since the last call.

x, y: Position of glyph. dx, dy: Advance of glyph. originX, originY code: 8-bit char code, 16 bit CID, or Unicode of glyph. u: Unicode mapping of character. "Unicode" is an unsigned int.

Definition at line 1878 of file svg-builder.cpp.

References _aria_label, _aria_space, _cairo_font, _css_font, _css_font_size, _font_specification, _glyphs, _invalidated_style, _text_position, Inkscape::Extension::Internal::SvgGlyph::advance, Inkscape::Extension::Internal::SvgGlyph::cairo_font, Inkscape::Extension::Internal::SvgGlyph::cairo_index, Inkscape::Extension::Internal::SvgGlyph::char_space, Inkscape::Extension::Internal::SvgGlyph::code, Inkscape::Extension::Internal::SvgGlyph::css_font, Inkscape::Extension::Internal::SvgGlyph::delta, delta, Inkscape::Extension::Internal::SvgGlyph::font_specification, Inkscape::Extension::Internal::SvgGlyph::horiz_scaling, Inkscape::Extension::Internal::SvgGlyph::is_space, Inkscape::Extension::Internal::SvgGlyph::origin, Inkscape::Extension::Internal::SvgGlyph::position, Inkscape::Extension::Internal::SvgGlyph::rise, sp_repr_css_attr_new(), sp_repr_css_merge(), Inkscape::Extension::Internal::SvgGlyph::state, Inkscape::Extension::Internal::SvgGlyph::style_changed, Inkscape::Extension::Internal::SvgGlyph::text_position, Inkscape::Extension::Internal::SvgGlyph::text_size, Inkscape::Extension::Internal::SvgGlyph::word_space, and Geom::Y.

Referenced by PdfParser::doShowText().

◆ addClippedFill()

void Inkscape::Extension::Internal::SvgBuilder::addClippedFill ( GfxShading *  shading,
const Geom::Affine  shading_tr 
)

◆ addColorProfile()

void Inkscape::Extension::Internal::SvgBuilder::addColorProfile ( unsigned char *  profBuf,
int  length 
)

Definition at line 979 of file svg-builder.cpp.

References _getColorProfile(), and _icc_profile.

Referenced by PdfParser::doShowText().

◆ addImage()

void Inkscape::Extension::Internal::SvgBuilder::addImage ( GfxState *  state,
Stream *  str,
int  width,
int  height,
GfxImageColorMap *  color_map,
bool  interpolate,
int *  mask_colors 
)

◆ addImageMask()

◆ addMaskedImage()

void Inkscape::Extension::Internal::SvgBuilder::addMaskedImage ( GfxState *  state,
Stream *  str,
int  width,
int  height,
GfxImageColorMap *  color_map,
bool  interpolate,
Stream *  mask_str,
int  mask_width,
int  mask_height,
bool  invert_mask,
bool  mask_interpolate 
)

◆ addOptionalGroup()

void Inkscape::Extension::Internal::SvgBuilder::addOptionalGroup ( const std::string &  oc,
const std::string &  label,
bool  visible = true 
)

Definition at line 945 of file svg-builder.cpp.

References _ocgs, label, and visible.

Referenced by PdfParser::doShowText().

◆ addPath()

void Inkscape::Extension::Internal::SvgBuilder::addPath ( GfxState *  state,
bool  fill,
bool  stroke,
bool  even_odd = false 
)

Emits the current path in poppler's GfxState data structure Can be used to do filling and stroking at once.

Parameters
fillwhether the path should be filled
strokewhether the path should be stroked
even_oddwhether the even-odd rule should be used when filling the path

Definition at line 693 of file svg-builder.cpp.

References _addToContainer(), _setBlendMode(), _setClipPath(), _setStyle(), _setTransform(), css, mergePath(), Inkscape::XML::Node::setAttribute(), sp_repr_css_attr_unref(), sp_repr_css_change(), and Inkscape::Extension::Internal::svgInterpretPath().

Referenced by PdfParser::doFillAndStroke(), PdfParser::doFunctionShFill1(), PdfParser::doShadingPatternFillFallback(), PdfParser::fillPatch(), PdfParser::gouraudFillTriangle(), PdfParser::opCloseStroke(), PdfParser::opEOFill(), PdfParser::opFill(), PdfParser::opFillStroke(), and PdfParser::opStroke().

◆ addShadedFill()

void Inkscape::Extension::Internal::SvgBuilder::addShadedFill ( GfxShading *  shading,
const Geom::Affine  shading_tr,
GfxPath *  path,
const Geom::Affine  tr,
bool  even_odd = false 
)

◆ addSoftMaskedImage()

void Inkscape::Extension::Internal::SvgBuilder::addSoftMaskedImage ( GfxState *  state,
Stream *  str,
int  width,
int  height,
GfxImageColorMap *  color_map,
bool  interpolate,
Stream *  mask_str,
int  mask_width,
int  mask_height,
GfxImageColorMap *  mask_color_map,
bool  mask_interpolate 
)

◆ applyOptionalMask()

void Inkscape::Extension::Internal::SvgBuilder::applyOptionalMask ( Inkscape::XML::Node mask,
Inkscape::XML::Node target 
)

◆ autoFontStrategies()

FontStrategies Inkscape::Extension::Internal::SvgBuilder::autoFontStrategies ( FontStrategy  s,
FontList  fonts 
)
static

◆ beforeStateChange()

void Inkscape::Extension::Internal::SvgBuilder::beforeStateChange ( GfxState *  old_state)

◆ beginLayer()

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::beginLayer ( const std::string &  label,
bool  visible 
)

◆ beginMarkedContent()

void Inkscape::Extension::Internal::SvgBuilder::beginMarkedContent ( const char *  name = nullptr,
const char *  group = nullptr 
)

◆ beginString()

void Inkscape::Extension::Internal::SvgBuilder::beginString ( GfxState *  state,
int  len 
)

Begin and end string is the inner most text processing step which tells us we're about to have a certain number of chars.

Definition at line 1846 of file svg-builder.cpp.

References _aria_space, _flushText(), _glyphs, and _invalidated_strategy.

Referenced by PdfParser::doShowText().

◆ beginTextObject()

void Inkscape::Extension::Internal::SvgBuilder::beginTextObject ( GfxState *  state)

These text object functions are the outer most calls for begining and ending text.

No text functions should be called outside of these two calls

Definition at line 1980 of file svg-builder.cpp.

References _in_text_object, and _invalidated_style.

Referenced by PdfParser::opBeginText().

◆ convertGfxColor()

std::string Inkscape::Extension::Internal::SvgBuilder::convertGfxColor ( const GfxColor *  color,
GfxColorSpace *  space 
)
private

◆ cropPage()

void Inkscape::Extension::Internal::SvgBuilder::cropPage ( const Geom::Rect bbox)

Crop to this bounding box, do this before setMargins() but after setDocumentSize.

Definition at line 196 of file svg-builder.cpp.

References _container, _createClip(), _page_affine, _root, Geom::identity(), Inkscape::XML::Node::setAttribute(), and Inkscape::CSSOStringStream::str().

Referenced by PdfParser::PdfParser().

◆ endLayer()

void Inkscape::Extension::Internal::SvgBuilder::endLayer ( Inkscape::XML::Node save)

Definition at line 968 of file svg-builder.cpp.

References _node_stack, _popGroup(), and Inkscape::Extension::save().

Referenced by PdfParser::doShowText().

◆ endMarkedContent()

void Inkscape::Extension::Internal::SvgBuilder::endMarkedContent ( )

Definition at line 974 of file svg-builder.cpp.

References _popGroup().

Referenced by PdfParser::doShowText().

◆ endString()

void Inkscape::Extension::Internal::SvgBuilder::endString ( GfxState *  state)

Definition at line 1863 of file svg-builder.cpp.

Referenced by PdfParser::doShowText().

◆ endTextObject()

void Inkscape::Extension::Internal::SvgBuilder::endTextObject ( GfxState *  state)

◆ finishGroup()

void Inkscape::Extension::Internal::SvgBuilder::finishGroup ( GfxState *  state,
bool  for_softmask 
)

Definition at line 2433 of file svg-builder.cpp.

References _container, _popContainer(), applyOptionalMask(), and popGroup().

Referenced by PdfParser::doShowText().

◆ getPreferences()

Inkscape::XML::Node * Inkscape::Extension::Internal::SvgBuilder::getPreferences ( )
inline

Definition at line 114 of file svg-builder.h.

References _preferences.

◆ isPatternTypeSupported()

bool Inkscape::Extension::Internal::SvgBuilder::isPatternTypeSupported ( GfxPattern *  pattern)

Checks whether the given pattern type can be represented in SVG Used by PdfParser to decide when to do fallback operations.

Definition at line 1026 of file svg-builder.cpp.

Referenced by PdfParser::doFillAndStroke(), PdfParser::opCloseStroke(), PdfParser::opEOFill(), PdfParser::opFill(), and PdfParser::opStroke().

◆ mergePath()

bool Inkscape::Extension::Internal::SvgBuilder::mergePath ( GfxState *  state,
bool  is_fill,
const std::string &  path,
bool  even_odd = false 
)

Set the fill XOR stroke of the previously added path, if that path is missing the given attribute AND the path is exactly the same.

This effectively merges the two objects and is an 'interpretation' step.

Definition at line 666 of file svg-builder.cpp.

References _container, _setFillStyle(), _setStrokeStyle(), css, Inkscape::XML::Node::lastChild(), shouldMergePath(), sp_repr_css_attr_new(), sp_repr_css_attr_unref(), sp_repr_css_change(), and sp_repr_css_set_property().

Referenced by addPath().

◆ popGroup()

◆ pushPage()

◆ restoreState()

void Inkscape::Extension::Internal::SvgBuilder::restoreState ( GfxState *  state)

◆ saveState()

void Inkscape::Extension::Internal::SvgBuilder::saveState ( GfxState *  state)

Definition at line 280 of file svg-builder.cpp.

References _clip_history, and ClipHistoryEntry::save().

Referenced by PdfParser::doShowText().

◆ setAsLayer()

void Inkscape::Extension::Internal::SvgBuilder::setAsLayer ( const char *  layer_name = nullptr,
bool  visible = true 
)

Sets groupmode of the current container to 'layer' and sets its label if given.

Definition at line 260 of file svg-builder.cpp.

References _container, css, Inkscape::XML::Node::setAttribute(), sp_repr_css_attr_new(), sp_repr_css_change(), sp_repr_css_set_property(), validateString(), and visible.

Referenced by beginLayer(), beginMarkedContent(), and pushPage().

◆ setClip()

void Inkscape::Extension::Internal::SvgBuilder::setClip ( GfxState *  state,
GfxClipType  clip,
bool  is_bbox = false 
)

Clips to the current path set in GfxState.

Parameters
statepoppler's data structure
even_oddwhether the even-odd rule should be applied

Definition at line 781 of file svg-builder.cpp.

References _clip_groups, _clip_history, _pushContainer(), clip(), ClipHistoryEntry::hasClipPath(), and ClipHistoryEntry::setClip().

Referenced by PdfParser::doEndPath(), and PdfParser::doShowText().

◆ setDocumentSize()

void Inkscape::Extension::Internal::SvgBuilder::setDocumentSize ( double  width,
double  height 
)

◆ setFontStrategies()

void Inkscape::Extension::Internal::SvgBuilder::setFontStrategies ( FontStrategies  fs)
inline

Definition at line 161 of file svg-builder.h.

References _font_strategies.

◆ setGroupOpacity()

void Inkscape::Extension::Internal::SvgBuilder::setGroupOpacity ( double  opacity)

Sets the current container's opacity.

Definition at line 276 of file svg-builder.cpp.

References _container, and Inkscape::XML::Node::setAttributeSvgDouble().

Referenced by PdfParser::doShowText().

◆ setMargins()

void Inkscape::Extension::Internal::SvgBuilder::setMargins ( const Geom::Rect page,
const Geom::Rect margins,
const Geom::Rect bleed 
)

◆ setMetadata()

void Inkscape::Extension::Internal::SvgBuilder::setMetadata ( char const *  name,
const std::string &  content 
)

Definition at line 250 of file svg-builder.cpp.

References _doc, name, rdf_find_entity(), rdf_set_work_entity(), and validateString().

Referenced by PdfParser::PdfParser().

◆ setPageMode()

void Inkscape::Extension::Internal::SvgBuilder::setPageMode ( bool  as_pages)
inline

Definition at line 118 of file svg-builder.h.

References _as_pages.

◆ shouldMergePath()

bool Inkscape::Extension::Internal::SvgBuilder::shouldMergePath ( bool  is_fill,
const std::string &  path 
)

Returns the CSSAttr of the previously added path if it's exactly the same path AND is missing the fill or stroke that is now being painted.

Definition at line 641 of file svg-builder.cpp.

References _container, Inkscape::XML::Node::attribute(), Inkscape::XML::Node::lastChild(), sp_repr_css_attr(), and sp_repr_css_property().

Referenced by addShadedFill(), and mergePath().

◆ startGroup()

void Inkscape::Extension::Internal::SvgBuilder::startGroup ( GfxState *  state,
double *  bbox,
GfxColorSpace *  blending_color_space,
bool  isolated,
bool  knockout,
bool  for_softmask 
)

Starts building a new transparency group.

Definition at line 2416 of file svg-builder.cpp.

References _createMask(), _mask_groups, and _pushContainer().

Referenced by PdfParser::doShowText().

◆ updateFont()

void Inkscape::Extension::Internal::SvgBuilder::updateFont ( GfxState *  state,
std::shared_ptr< CairoFont cairo_font,
bool  flip 
)

◆ updateStyle()

◆ updateTextMatrix()

void Inkscape::Extension::Internal::SvgBuilder::updateTextMatrix ( GfxState *  state,
bool  flip 
)

Flushes the buffered characters.

Definition at line 1416 of file svg-builder.cpp.

References _flushText(), _text_matrix, and ctmToAffine().

Referenced by PdfParser::opSetHorizScaling(), PdfParser::opSetTextMatrix(), and updateFont().

◆ updateTextPosition()

void Inkscape::Extension::Internal::SvgBuilder::updateTextPosition ( double  tx,
double  ty 
)

◆ updateTextShift()

void Inkscape::Extension::Internal::SvgBuilder::updateTextShift ( GfxState *  state,
double  shift 
)

Shifts the current text position by the given amount (specified in text space)

Definition at line 1397 of file svg-builder.cpp.

References _text_position, and shift().

Referenced by PdfParser::opShowSpaceText().

Member Data Documentation

◆ _aria_label

std::string Inkscape::Extension::Internal::SvgBuilder::_aria_label
private

Definition at line 218 of file svg-builder.h.

Referenced by _flushText(), _flushTextPath(), _renderText(), and addChar().

◆ _aria_space

bool Inkscape::Extension::Internal::SvgBuilder::_aria_space = false
private

Definition at line 219 of file svg-builder.h.

Referenced by addChar(), and beginString().

◆ _as_pages

bool Inkscape::Extension::Internal::SvgBuilder::_as_pages = true
private

Definition at line 277 of file svg-builder.h.

Referenced by pushPage(), setDocumentSize(), setMargins(), and setPageMode().

◆ _cairo_font

std::shared_ptr<CairoFont> Inkscape::Extension::Internal::SvgBuilder::_cairo_font
private

Definition at line 259 of file svg-builder.h.

Referenced by addChar(), and updateFont().

◆ _clip_groups

int Inkscape::Extension::Internal::SvgBuilder::_clip_groups = 0
private

Definition at line 229 of file svg-builder.h.

Referenced by restoreState(), and setClip().

◆ _clip_history

ClipHistoryEntry* Inkscape::Extension::Internal::SvgBuilder::_clip_history
private

◆ _clip_text

Inkscape::XML::Node* Inkscape::Extension::Internal::SvgBuilder::_clip_text = nullptr
private

Definition at line 291 of file svg-builder.h.

Referenced by _getClip(), _setClipPath(), and endTextObject().

◆ _clip_text_group

Inkscape::XML::Node* Inkscape::Extension::Internal::SvgBuilder::_clip_text_group = nullptr
private

Definition at line 292 of file svg-builder.h.

Referenced by _flushText(), and endTextObject().

◆ _container

◆ _css_font

SPCSSAttr* Inkscape::Extension::Internal::SvgBuilder::_css_font
private

Definition at line 251 of file svg-builder.h.

Referenced by _init(), addChar(), and updateFont().

◆ _css_font_size

double Inkscape::Extension::Internal::SvgBuilder::_css_font_size = 1.0
private

Definition at line 250 of file svg-builder.h.

Referenced by addChar(), and updateFont().

◆ _doc

◆ _docname

gchar* Inkscape::Extension::Internal::SvgBuilder::_docname
private

Definition at line 268 of file svg-builder.h.

Referenced by _createImage(), SvgBuilder(), and SvgBuilder().

◆ _font_specification

std::string Inkscape::Extension::Internal::SvgBuilder::_font_specification
private

Definition at line 252 of file svg-builder.h.

Referenced by addChar(), and updateFont().

◆ _font_strategies

FontStrategies Inkscape::Extension::Internal::SvgBuilder::_font_strategies
private

Definition at line 249 of file svg-builder.h.

Referenced by setFontStrategies(), and updateFont().

◆ _for_softmask

bool Inkscape::Extension::Internal::SvgBuilder::_for_softmask = false
private

Definition at line 264 of file svg-builder.h.

◆ _glyphs

std::vector<SvgGlyph> Inkscape::Extension::Internal::SvgBuilder::_glyphs
private

Definition at line 256 of file svg-builder.h.

Referenced by _flushText(), _flushTextPath(), _flushTextText(), addChar(), and beginString().

◆ _height

double Inkscape::Extension::Internal::SvgBuilder::_height
private

Definition at line 275 of file svg-builder.h.

Referenced by _createPattern(), _init(), _renderText(), setDocumentSize(), and setMargins().

◆ _icc_profile

std::string Inkscape::Extension::Internal::SvgBuilder::_icc_profile
private

Definition at line 287 of file svg-builder.h.

Referenced by addColorProfile(), and convertGfxColor().

◆ _icc_profiles

std::map<cmsHPROFILE, std::string> Inkscape::Extension::Internal::SvgBuilder::_icc_profiles
private

Definition at line 288 of file svg-builder.h.

Referenced by _getColorProfile().

◆ _in_text_object

bool Inkscape::Extension::Internal::SvgBuilder::_in_text_object
private

Definition at line 261 of file svg-builder.h.

Referenced by _init(), beforeStateChange(), beginTextObject(), endTextObject(), and updateStyle().

◆ _invalidated_strategy

bool Inkscape::Extension::Internal::SvgBuilder::_invalidated_strategy = false
private

Definition at line 263 of file svg-builder.h.

Referenced by beginString(), and updateFont().

◆ _invalidated_style

bool Inkscape::Extension::Internal::SvgBuilder::_invalidated_style
private

Definition at line 262 of file svg-builder.h.

Referenced by _init(), addChar(), beginTextObject(), updateFont(), and updateStyle().

◆ _is_top_level

bool Inkscape::Extension::Internal::SvgBuilder::_is_top_level
private

Definition at line 266 of file svg-builder.h.

Referenced by _createMask(), SvgBuilder(), and SvgBuilder().

◆ _mask_groups

std::vector<GfxState *> Inkscape::Extension::Internal::SvgBuilder::_mask_groups
private

Definition at line 228 of file svg-builder.h.

Referenced by restoreState(), and startGroup().

◆ _node_stack

std::vector<Inkscape::XML::Node *> Inkscape::Extension::Internal::SvgBuilder::_node_stack
private

◆ _ocgs

std::map<std::string, std::pair<std::string, bool> > Inkscape::Extension::Internal::SvgBuilder::_ocgs
private

Definition at line 285 of file svg-builder.h.

Referenced by addOptionalGroup(), beginMarkedContent(), and pushPage().

◆ _page

Inkscape::XML::Node* Inkscape::Extension::Internal::SvgBuilder::_page = nullptr
private

Definition at line 278 of file svg-builder.h.

Referenced by pushPage(), setDocumentSize(), and setMargins().

◆ _page_affine

Geom::Affine Inkscape::Extension::Internal::SvgBuilder::_page_affine = Geom::identity()
private

◆ _page_left

double Inkscape::Extension::Internal::SvgBuilder::_page_left = 0
private

Definition at line 280 of file svg-builder.h.

Referenced by pushPage(), and setDocumentSize().

◆ _page_num

int Inkscape::Extension::Internal::SvgBuilder::_page_num = 0
private

Definition at line 279 of file svg-builder.h.

Referenced by pushPage(), and setDocumentSize().

◆ _page_offset

bool Inkscape::Extension::Internal::SvgBuilder::_page_offset = false
private

Definition at line 282 of file svg-builder.h.

Referenced by pushPage().

◆ _page_top

double Inkscape::Extension::Internal::SvgBuilder::_page_top = 0
private

Definition at line 281 of file svg-builder.h.

Referenced by pushPage().

◆ _preferences

Inkscape::XML::Node* Inkscape::Extension::Internal::SvgBuilder::_preferences
private

Definition at line 273 of file svg-builder.h.

Referenced by _createImage(), getPreferences(), SvgBuilder(), and SvgBuilder().

◆ _prev_clip

Inkscape::XML::Node* Inkscape::Extension::Internal::SvgBuilder::_prev_clip = nullptr
private

Definition at line 295 of file svg-builder.h.

Referenced by _createClip().

◆ _root

Inkscape::XML::Node* Inkscape::Extension::Internal::SvgBuilder::_root
private

◆ _text_matrix

Geom::Affine Inkscape::Extension::Internal::SvgBuilder::_text_matrix
private

Definition at line 254 of file svg-builder.h.

Referenced by _flushText(), and updateTextMatrix().

◆ _text_position

Geom::Point Inkscape::Extension::Internal::SvgBuilder::_text_position
private

Definition at line 255 of file svg-builder.h.

Referenced by addChar(), updateTextPosition(), and updateTextShift().

◆ _text_size

double Inkscape::Extension::Internal::SvgBuilder::_text_size
private

Definition at line 253 of file svg-builder.h.

◆ _width

double Inkscape::Extension::Internal::SvgBuilder::_width
private

Definition at line 274 of file svg-builder.h.

Referenced by _init(), _renderText(), pushPage(), setDocumentSize(), and setMargins().

◆ _xml_doc

◆ _xref

XRef* Inkscape::Extension::Internal::SvgBuilder::_xref
private

Definition at line 269 of file svg-builder.h.

Referenced by _createTilingPattern(), SvgBuilder(), and SvgBuilder().


The documentation for this class was generated from the following files: