Inkscape
Vector Graphics Editor
|
#include <build-document.h>
Public Member Functions | |
Document (char const *filename, capypdf::DocumentProperties &opt) | |
void | add_page (PageContext &page) |
void | set_label (uint32_t page, std::string const &label) |
void | write () |
void | set_filter_resolution (unsigned res=0) |
unsigned | get_filter_resolution () const |
void | set_text_enabled (bool enabled) |
bool | get_text_enabled () const |
std::optional< CapyPDF_TransparencyGroupId > | add_group (ItemContext &context) |
std::optional< CapyPDF_TransparencyGroupId > | item_to_transparency_group (SPItem const *item, SPStyle const *context_style=nullptr, bool is_soft_mask=false) |
Render any type of item into a transparency group. | |
std::optional< CapyPDF_TransparencyGroupId > | mask_to_transparency_group (SPMask const *mask, Geom::Affine const &transform) |
Render a mask out to a transparency group context. | |
std::optional< CapyPDF_TransparencyGroupId > | style_to_transparency_mask (SPStyle const *style, SPStyle const *context_style) |
Render gradient transparencies into a transparency mask. | |
std::optional< CapyPDF_GraphicsStateId > | get_group_graphics_state (SPStyle const *style, std::optional< CapyPDF_TransparencyGroupId > sm) |
Set the style for any graphic from the SVG style. | |
std::optional< CapyPDF_GraphicsStateId > | get_shape_graphics_state (SPStyle const *style) |
Like get_graphics_style but for drawing shapes (paths) | |
std::optional< CapyPDF_FontId > | get_font (std::string const &filename) |
Load a font and cache the results. | |
std::optional< capypdf::Color > | get_paint (SPIPaint const &paint, SPStyle const *context_style, std::optional< double > opacity) |
Generate a solid color, gradient or pattern based on the SPIPaint. | |
capypdf::Color | get_color (Colors::Color const &color, std::optional< double > opacity) |
std::optional< CapyPDF_PatternId > | get_pattern (SPPaintServer const *paint, std::optional< double > opacity) |
Construct a PDF pattern object from the given paintserver. | |
CapyPDF_Device_Colorspace | get_default_colorspace () const |
CapyPDF_Device_Colorspace | get_colorspace (std::shared_ptr< Colors::Space::AnySpace > const &space) const |
std::optional< CapyPDF_IccColorSpaceId > | get_icc_profile (std::shared_ptr< Colors::Space::CMS > const &profile) |
Protected Member Functions | |
capypdf::Generator & | generator () |
StyleMemory & | paint_memory () |
std::vector< CapyPDF_AnnotationId > | get_anchors_for_page (SPPage const *page) |
Load an anchor link and add it to the page. | |
Private Member Functions | |
std::optional< CapyPDF_PatternId > | get_linear_pattern (SPLinearGradient const *linear, std::optional< double > opacity) |
Generate a linear gradient or linear gradient mask. | |
std::optional< CapyPDF_PatternId > | get_radial_pattern (SPRadialGradient const *radial, std::optional< double > opacity) |
Generate a radial gradient or radial gradient mask. | |
std::optional< CapyPDF_PatternId > | get_mesh_pattern (SPMeshGradient const *mesh, std::optional< double > opacity) |
Generate a mesh gradient or mesh gradient mask. | |
std::optional< CapyPDF_PatternId > | get_tiling_pattern (SPPattern const *pat, Geom::Affine const &transform) |
Render a pattern out to a transparency group context. | |
std::optional< CapyPDF_FunctionId > | get_gradient_function (SPGradientVector const &vector, std::optional< double > opacity, CapyPDF_Device_Colorspace *space) |
Generate a non-continous gradient from the gradient vector and add to the document. | |
std::optional< CapyPDF_FunctionId > | get_repeat_function (CapyPDF_FunctionId gradient, bool reflected, int from, int to) |
Generate a type3 gradient function which repeats the given gradient for the given ranges. | |
Private Attributes | |
capypdf::Generator | _gen |
StyleMemory | _paint_memory |
std::map< std::string, CapyPDF_IccColorSpaceId > | _icc_cache |
std::map< ItemCacheKey, CapyPDF_TransparencyGroupId > | _item_cache |
std::map< std::string, CapyPDF_TransparencyGroupId > | _mask_cache |
std::map< std::string, CapyPDF_PatternId > | _pattern_cache |
std::map< std::string, CapyPDF_FontId > | _font_cache |
std::set< SPAnchor const * > | _anchors |
unsigned | _filter_resolution = 0 |
bool | _text_enabled = true |
Friends | |
class | DrawContext |
class | PageContext |
class | GroupContext |
class | PatternContext |
class | TextContext |
Definition at line 81 of file build-document.h.
|
inline |
Definition at line 84 of file build-document.h.
References FILL, FILL_OPACITY, STROKE, STROKE_DASHARRAY, STROKE_DASHOFFSET, STROKE_LINECAP, STROKE_LINEJOIN, STROKE_MITERLIMIT, STROKE_OPACITY, and STROKE_WIDTH.
std::optional< CapyPDF_TransparencyGroupId > Inkscape::Extension::Internal::PdfBuilder::Document::add_group | ( | ItemContext & | context | ) |
Definition at line 58 of file build-document.cpp.
References Inkscape::Extension::Internal::PdfBuilder::DrawContext::_ctx, _gen, _item_cache, Inkscape::Extension::Internal::PdfBuilder::ItemContext::cache_key(), Inkscape::Extension::Internal::PdfBuilder::ItemContext::is_valid(), and Inkscape::Extension::Internal::PdfBuilder::ItemContext::paint().
void Inkscape::Extension::Internal::PdfBuilder::Document::add_page | ( | PageContext & | page | ) |
Definition at line 52 of file build-document.cpp.
|
inlineprotected |
Definition at line 152 of file build-document.h.
References _gen.
Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item_to_raster(), and Inkscape::Extension::Internal::PdfBuilder::TextContext::set_paint_style().
|
protected |
Load an anchor link and add it to the page.
Definition at line 229 of file build-document.cpp.
References _anchors, _gen, SPObject::document, Inkscape::PageManager::getPageFor(), SPDocument::getPageManager(), SPItem::i2doc_affine(), item, page, Inkscape::Extension::Internal::PdfBuilder::PageContext::page_transform(), result, and SPItem::visualBounds().
Referenced by Inkscape::Extension::Internal::PdfBuilder::PageContext::add_anchors_for_page().
capypdf::Color Inkscape::Extension::Internal::PdfBuilder::Document::get_color | ( | Colors::Color const & | color, |
std::optional< double > | opacity | ||
) |
Definition at line 343 of file build-styles.cpp.
References Inkscape::Colors::Color::converted(), get_icc_profile(), Inkscape::Colors::Color::getOpacity(), Inkscape::Colors::Color::getSpace(), Inkscape::Colors::Color::getValues(), Inkscape::Colors::Space::RGB, rgb, and Inkscape::Colors::Color::toString().
Referenced by get_gradient_function(), get_mesh_pattern(), and get_paint().
CapyPDF_Device_Colorspace Inkscape::Extension::Internal::PdfBuilder::Document::get_colorspace | ( | std::shared_ptr< Colors::Space::AnySpace > const & | space | ) | const |
Definition at line 392 of file build-styles.cpp.
References Inkscape::Colors::Space::CMYK, and Inkscape::Colors::Space::RGB.
Referenced by get_gradient_function(), and get_mesh_pattern().
CapyPDF_Device_Colorspace Inkscape::Extension::Internal::PdfBuilder::Document::get_default_colorspace | ( | ) | const |
Definition at line 386 of file build-styles.cpp.
Referenced by get_linear_pattern(), get_mesh_pattern(), and get_radial_pattern().
|
inline |
Definition at line 105 of file build-document.h.
References _filter_resolution.
Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item().
std::optional< CapyPDF_FontId > Inkscape::Extension::Internal::PdfBuilder::Document::get_font | ( | std::string const & | filename | ) |
Load a font and cache the results.
filename | - The filename to the font to use. |
Definition at line 289 of file build-styles.cpp.
References _font_cache, _gen, and Inkscape::Extension::Internal::err().
Referenced by Inkscape::Extension::Internal::PdfBuilder::TextContext::set_text_style().
|
private |
Generate a non-continous gradient from the gradient vector and add to the document.
Definition at line 359 of file build-patterns.cpp.
References _gen, bounds, get_color(), get_colorspace(), and SPGradientVector::stops.
Referenced by get_linear_pattern(), and get_radial_pattern().
std::optional< CapyPDF_GraphicsStateId > Inkscape::Extension::Internal::PdfBuilder::Document::get_group_graphics_state | ( | SPStyle const * | style, |
std::optional< CapyPDF_TransparencyGroupId > | soft_mask | ||
) |
Set the style for any graphic from the SVG style.
Definition at line 219 of file build-styles.cpp.
References _gen, Inkscape::Extension::Internal::PdfBuilder::get_blendmode(), SPStyle::mix_blend_mode, and SPStyle::opacity.
Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_group().
std::optional< CapyPDF_IccColorSpaceId > Inkscape::Extension::Internal::PdfBuilder::Document::get_icc_profile | ( | std::shared_ptr< Colors::Space::CMS > const & | profile | ) |
Definition at line 368 of file build-styles.cpp.
References _gen, _icc_cache, and key.
Referenced by get_color().
|
private |
Generate a linear gradient or linear gradient mask.
Definition at line 139 of file build-patterns.cpp.
References _gen, get_default_colorspace(), get_gradient_function(), Inkscape::Extension::Internal::PdfBuilder::get_id(), get_repeat_function(), linear(), Inkscape::Extension::Internal::PdfBuilder::repeat_is_reflection(), and SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX.
Referenced by get_pattern().
|
private |
Generate a mesh gradient or mesh gradient mask.
Definition at line 269 of file build-patterns.cpp.
References _gen, get_color(), get_colorspace(), get_default_colorspace(), Inkscape::Extension::Internal::PdfBuilder::get_id(), SPGradient::getAllItemsBox(), SPGradient::gradientTransform, SPMeshNodeArray::nodes, SPMeshNodeArray::patch_columns(), SPMeshNodeArray::patch_rows(), and SPMeshNodeArray::read().
Referenced by get_pattern().
std::optional< capypdf::Color > Inkscape::Extension::Internal::PdfBuilder::Document::get_paint | ( | SPIPaint const & | paint, |
SPStyle const * | context_style, | ||
std::optional< double > | opacity | ||
) |
Generate a solid color, gradient or pattern based on the SPIPaint.
Definition at line 306 of file build-styles.cpp.
References SPStyle::fill, get_color(), get_paint(), get_pattern(), SPIPaint::get_value(), SPIPaint::getColor(), SPIPaint::href, SPIPaint::isColor(), SPIPaint::isNone(), SPIPaint::isPaintserver(), SPIPaint::paintOrigin, SP_CSS_PAINT_ORIGIN_CONTEXT_FILL, SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE, and SPStyle::stroke.
Referenced by get_paint(), Inkscape::Extension::Internal::PdfBuilder::DrawContext::set_paint_style(), and Inkscape::Extension::Internal::PdfBuilder::TextContext::set_paint_style().
std::optional< CapyPDF_PatternId > Inkscape::Extension::Internal::PdfBuilder::Document::get_pattern | ( | SPPaintServer const * | paint, |
std::optional< double > | opacity | ||
) |
Construct a PDF pattern object from the given paintserver.
Gradients or patterns.
Definition at line 91 of file build-patterns.cpp.
References _pattern_cache, Inkscape::Extension::Internal::PdfBuilder::get_id(), get_linear_pattern(), get_mesh_pattern(), get_radial_pattern(), get_tiling_pattern(), SPPatternReference::getObject(), SPPaintServer::isValid(), linear(), and SPPattern::ref.
Referenced by get_paint().
|
private |
Generate a radial gradient or radial gradient mask.
Definition at line 203 of file build-patterns.cpp.
References _gen, SVGLength::computed, SPRadialGradient::cx, SPRadialGradient::cy, Geom::distance(), SPGradient::fetchSpread(), SPRadialGradient::fr, Geom::Line::from_origin_and_vector(), SPRadialGradient::fx, SPRadialGradient::fy, get_default_colorspace(), get_gradient_function(), Inkscape::Extension::Internal::PdfBuilder::get_id(), get_repeat_function(), SPGradient::getAllItemsBox(), SPGradient::getGradientVector(), SPGradient::getUnits(), SPGradient::gradientTransform, SPRadialGradient::r, Inkscape::Extension::Internal::PdfBuilder::repeat_is_reflection(), and SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX.
Referenced by get_pattern().
|
private |
Generate a type3 gradient function which repeats the given gradient for the given ranges.
Definition at line 410 of file build-patterns.cpp.
Referenced by get_linear_pattern(), and get_radial_pattern().
std::optional< CapyPDF_GraphicsStateId > Inkscape::Extension::Internal::PdfBuilder::Document::get_shape_graphics_state | ( | SPStyle const * | style | ) |
Like get_graphics_style but for drawing shapes (paths)
style | - The style from the SPObject |
Definition at line 255 of file build-styles.cpp.
References _gen, SPStyle::fill_opacity, SPStyle::stroke_opacity, and style_to_transparency_mask().
Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item().
|
inline |
Definition at line 108 of file build-document.h.
References _text_enabled.
Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item().
|
private |
Render a pattern out to a transparency group context.
Definition at line 332 of file build-patterns.cpp.
References _gen, _paint_memory, SPViewBox::c2p, SPObject::children, Inkscape::Extension::Internal::StyleMemory::get_ifset(), SPPattern::getBox(), item_to_transparency_group(), Inkscape::Extension::Internal::StyleMemory::remember(), and SPObject::style.
Referenced by get_pattern().
std::optional< CapyPDF_TransparencyGroupId > Inkscape::Extension::Internal::PdfBuilder::Document::item_to_transparency_group | ( | SPItem const * | item, |
SPStyle const * | context_style = nullptr , |
||
bool | is_soft_mask = false |
||
) |
Render any type of item into a transparency group.
Definition at line 85 of file build-document.cpp.
References _anchors, _gen, _item_cache, SPStyle::fill, SPStyle::fill_opacity, Inkscape::Extension::Internal::PdfBuilder::get_context_use_recursive(), Inkscape::Extension::Internal::PdfBuilder::get_id(), Geom::identity(), SPItem::isHidden(), item, Inkscape::Extension::Internal::PdfBuilder::paint_to_cache_key(), SPStyle::stroke, SPStyle::stroke_opacity, SPItem::transform, and SPItem::visualBounds().
Referenced by get_tiling_pattern(), mask_to_transparency_group(), Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item_clone(), Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item_group(), Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_raster(), and Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_shape().
std::optional< CapyPDF_TransparencyGroupId > Inkscape::Extension::Internal::PdfBuilder::Document::mask_to_transparency_group | ( | SPMask const * | mask, |
Geom::Affine const & | transform | ||
) |
Render a mask out to a transparency group context.
Definition at line 147 of file build-document.cpp.
References _gen, _mask_cache, SPObject::children, Inkscape::Extension::Internal::PdfBuilder::get_id(), item_to_transparency_group(), and SPMask::visualBounds().
Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item_group().
|
inlineprotected |
Definition at line 155 of file build-document.h.
References _paint_memory.
Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item(), and Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_text_layout().
|
inline |
Definition at line 104 of file build-document.h.
References _filter_resolution.
void Inkscape::Extension::Internal::PdfBuilder::Document::set_label | ( | uint32_t | page, |
std::string const & | label | ||
) |
Definition at line 47 of file build-document.cpp.
|
inline |
Definition at line 107 of file build-document.h.
References _text_enabled.
std::optional< CapyPDF_TransparencyGroupId > Inkscape::Extension::Internal::PdfBuilder::Document::style_to_transparency_mask | ( | SPStyle const * | style, |
SPStyle const * | context_style | ||
) |
Render gradient transparencies into a transparency mask.
Definition at line 183 of file build-document.cpp.
References _gen, _paint_memory, SPObject::DEPENDENT, SPStyle::fill, Inkscape::Extension::Internal::StyleMemory::get_ifset(), Inkscape::Extension::Internal::PdfBuilder::gradient_has_transparency(), Geom::identity(), item, SPStyle::stroke, SPObject::style, and Geom::GenericOptRect< C >::unionWith().
Referenced by get_shape_graphics_state(), and Inkscape::Extension::Internal::PdfBuilder::TextContext::set_paint_style().
|
inline |
Definition at line 102 of file build-document.h.
References _gen.
|
friend |
Definition at line 146 of file build-document.h.
|
friend |
Definition at line 148 of file build-document.h.
|
friend |
Definition at line 147 of file build-document.h.
|
friend |
Definition at line 149 of file build-document.h.
|
friend |
Definition at line 150 of file build-document.h.
|
private |
Definition at line 171 of file build-document.h.
Referenced by get_anchors_for_page(), and item_to_transparency_group().
|
private |
Definition at line 173 of file build-document.h.
Referenced by get_filter_resolution(), and set_filter_resolution().
|
private |
Definition at line 168 of file build-document.h.
Referenced by get_font().
|
private |
Definition at line 160 of file build-document.h.
Referenced by add_group(), add_page(), generator(), get_anchors_for_page(), get_font(), get_gradient_function(), get_group_graphics_state(), get_icc_profile(), get_linear_pattern(), get_mesh_pattern(), get_radial_pattern(), get_repeat_function(), get_shape_graphics_state(), get_tiling_pattern(), item_to_transparency_group(), mask_to_transparency_group(), Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item(), Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_raster(), set_label(), style_to_transparency_mask(), and write().
|
private |
Definition at line 164 of file build-document.h.
Referenced by get_icc_profile().
|
private |
Definition at line 165 of file build-document.h.
Referenced by add_group(), and item_to_transparency_group().
|
private |
Definition at line 166 of file build-document.h.
Referenced by mask_to_transparency_group().
|
private |
Definition at line 162 of file build-document.h.
Referenced by get_tiling_pattern(), paint_memory(), and style_to_transparency_mask().
|
private |
Definition at line 167 of file build-document.h.
Referenced by get_pattern().
|
private |
Definition at line 174 of file build-document.h.
Referenced by get_text_enabled(), and set_text_enabled().