Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
style.cpp File Reference

SVG stylesheets implementation. More...

Go to the source code of this file.

Functions

void sp_style_filter_ref_changed (SPObject *old_ref, SPObject *ref, SPStyle *style)
 Gets called when the filter is (re)attached to the style.
 
void sp_style_fill_paint_server_ref_changed (SPObject *old_ref, SPObject *ref, SPStyle *style)
 Gets called when the paintserver is (re)attached to the style.
 
void sp_style_stroke_paint_server_ref_changed (SPObject *old_ref, SPObject *ref, SPStyle *style)
 Gets called when the paintserver is (re)attached to the style.
 
static void sp_style_object_release (SPObject *object, SPStyle *style)
 Release callback.
 
static CRSelEngsp_repr_sel_eng ()
 
static void sp_style_filter_ref_modified (SPObject *obj, unsigned flags, SPStyle *style)
 Emit style modified signal on style's object if the filter changed.
 
static void sp_style_paint_server_ref_modified (SPObject *obj, unsigned, SPStyle *style)
 Emit style modified signal on style's object if server is style's fill or stroke paint server.
 
void sp_style_set_ipaint_to_uri (SPStyle *style, SPIPaint *paint, const Inkscape::URI *uri, SPDocument *document)
 
void sp_style_set_ipaint_to_uri_string (SPStyle *style, SPIPaint *paint, const gchar *uri)
 
void sp_style_set_to_uri (SPStyle *style, bool isfill, Inkscape::URI const *uri)
 
gchar const * sp_style_get_css_unit_string (int unit)
 
double sp_style_css_size_px_to_units (double size, int unit, double font_size)
 
double sp_style_css_size_units_to_px (double size, int unit, double font_size)
 
void sp_style_set_property_url (SPObject *item, gchar const *property, SPObject *linked, bool recursive)
 
SPCSSAttrsp_css_attr_from_style (SPStyle const *const style, guint const flags)
 
SPCSSAttrsp_css_attr_from_object (SPObject *object, guint const flags)
 
SPCSSAttrsp_css_attr_unset_text (SPCSSAttr *css)
 Unset any text-related properties.
 
SPCSSAttrsp_css_attr_unset_blacklist (SPCSSAttr *css)
 Unset properties that should not be set for default tool style.
 
static bool is_url (char const *p)
 
SPCSSAttrsp_css_attr_unset_uris (SPCSSAttr *css)
 Unset any properties that contain URI values.
 
static void sp_css_attr_scale_property_single (SPCSSAttr *css, gchar const *property, double ex, bool only_with_units=false)
 Scale a single-value property.
 
static void sp_css_attr_scale_property_list (SPCSSAttr *css, gchar const *property, double ex)
 Scale a list-of-values property.
 
SPCSSAttrsp_css_attr_scale (SPCSSAttr *css, double ex)
 Scale any properties that may hold <length> by ex.
 
void css_quote (Glib::ustring &val)
 Quote and/or escape string for writing to CSS, changing strings in place.
 
void css_font_family_quote (Glib::ustring &val)
 Quote font names in font-family lists, changing string in place.
 
void css_unquote (Glib::ustring &val)
 Remove paired single and double quotes from a string, changing string in place.
 
void css_font_family_unquote (Glib::ustring &val)
 Remove paired single and double quotes from font names in font-family lists, changing string in place.
 

Variables

static constexpr int BMAX = 8192
 
auto & _prop_helper = SPStylePropHelper::instance()
 

Detailed Description

SVG stylesheets implementation.

Definition in file style.cpp.

Function Documentation

◆ css_font_family_quote()

void css_font_family_quote ( Glib::ustring &  val)

Quote font names in font-family lists, changing string in place.

We use unquoted names internally but some need to be quoted in CSS.

Definition at line 1687 of file style.cpp.

References css_quote().

Referenced by Inkscape::FontLister::fill_css(), and SPIString::get_value().

◆ css_font_family_unquote()

void css_font_family_unquote ( Glib::ustring &  val)

Remove paired single and double quotes from font names in font-family lists, changing string in place.

We use unquoted family names internally but CSS sometimes uses quoted names.

Definition at line 1724 of file style.cpp.

References css_unquote().

Referenced by Inkscape::UI::Toolbar::TextToolbar::fontfamily_value_changed(), and SPIString::read().

◆ css_quote()

void css_quote ( Glib::ustring &  val)

Quote and/or escape string for writing to CSS, changing strings in place.

See: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier

Definition at line 1648 of file style.cpp.

Referenced by css_font_family_quote(), Inkscape::FontLister::fill_css(), and SPIString::get_value().

◆ css_unquote()

void css_unquote ( Glib::ustring &  val)

Remove paired single and double quotes from a string, changing string in place.

Definition at line 1706 of file style.cpp.

Referenced by css_font_family_unquote(), and SPIString::read().

◆ is_url()

static bool is_url ( char const *  p)
static
Todo:
FIXME: I'm not sure if this applies to SVG as well, but CSS2 says any URIs in property values must start with 'url('.

Definition at line 1524 of file style.cpp.

Referenced by sp_css_attr_unset_uris().

◆ sp_css_attr_from_object()

SPCSSAttr * sp_css_attr_from_object ( SPObject object,
guint const  flags 
)

◆ sp_css_attr_from_style()

SPCSSAttr * sp_css_attr_from_style ( SPStyle const *const  style,
guint const  flags 
)

◆ sp_css_attr_scale()

◆ sp_css_attr_scale_property_list()

static void sp_css_attr_scale_property_list ( SPCSSAttr css,
gchar const *  property,
double  ex 
)
static

Scale a list-of-values property.

Definition at line 1594 of file style.cpp.

References css, sp_repr_css_property(), sp_repr_css_set_property(), Inkscape::CSSOStringStream::str(), and w.

Referenced by sp_css_attr_scale().

◆ sp_css_attr_scale_property_single()

static void sp_css_attr_scale_property_single ( SPCSSAttr css,
gchar const *  property,
double  ex,
bool  only_with_units = false 
)
static

Scale a single-value property.

Definition at line 1568 of file style.cpp.

References css, sp_repr_css_property(), sp_repr_css_set_property(), Inkscape::CSSOStringStream::str(), and w.

Referenced by sp_css_attr_scale().

◆ sp_css_attr_unset_blacklist()

SPCSSAttr * sp_css_attr_unset_blacklist ( SPCSSAttr css)

Unset properties that should not be set for default tool style.

This list needs to be reviewed.

Definition at line 1498 of file style.cpp.

References css, and sp_repr_css_set_property().

Referenced by Inkscape::UI::Dialog::StyleFromSelectionToTool(), and take_style_from_item().

◆ sp_css_attr_unset_text()

SPCSSAttr * sp_css_attr_unset_text ( SPCSSAttr css)

Unset any text-related properties.

Definition at line 1444 of file style.cpp.

References css, and sp_repr_css_set_property().

Referenced by sp_desktop_get_style(), sp_desktop_set_style(), Inkscape::UI::Dialog::StyleFromSelectionToTool(), and take_style_from_item().

◆ sp_css_attr_unset_uris()

SPCSSAttr * sp_css_attr_unset_uris ( SPCSSAttr css)

Unset any properties that contain URI values.

Used for storing style that will be reused across documents when carrying the referenced defs is impractical.

Definition at line 1543 of file style.cpp.

References css, is_url(), sp_repr_css_property(), and sp_repr_css_set_property().

Referenced by Inkscape::UI::Tools::TweakTool::set_style(), sp_desktop_set_style(), and Inkscape::UI::Dialog::StyleFromSelectionToTool().

◆ sp_repr_sel_eng()

static CRSelEng * sp_repr_sel_eng ( )
static
Todo:
Check whether we need to register any pseudo-class handlers. libcroco has its own default handlers for first-child and lang.

We probably want handlers for link and arguably visited (though inkscape can't visit links at the time of writing). hover etc. more useful in inkview than the editor inkscape.

http://www.w3.org/TR/SVG11/styling.html#StylingWithCSS says that the following should be honoured, at least by inkview: :hover, :active, :focus, :visited, :link.

Definition at line 1225 of file style.cpp.

References cr_sel_eng_new(), and Inkscape::XML::croco_node_iface.

Referenced by SPStyle::_mergeObjectStylesheet().

◆ sp_style_css_size_px_to_units()

◆ sp_style_css_size_units_to_px()

double sp_style_css_size_units_to_px ( double  size,
int  unit,
double  font_size 
)

◆ sp_style_fill_paint_server_ref_changed()

void sp_style_fill_paint_server_ref_changed ( SPObject old_ref,
SPObject ref,
SPStyle style 
)

Gets called when the paintserver is (re)attached to the style.

Definition at line 1193 of file style.cpp.

References SPStyle::fill_ps_modified_connection, ref, SPStyle::signal_fill_ps_changed, and sp_style_paint_server_ref_modified().

Referenced by SPStyle::clear(), SPIPaint::read(), and sp_style_set_ipaint_to_uri().

◆ sp_style_filter_ref_changed()

void sp_style_filter_ref_changed ( SPObject old_ref,
SPObject ref,
SPStyle style 
)

Gets called when the filter is (re)attached to the style.

Definition at line 1147 of file style.cpp.

References SPStyle::filter_modified_connection, ref, SPStyle::signal_filter_changed, and sp_style_filter_ref_modified().

Referenced by SPStyle::clear(), and SPIFilter::read().

◆ sp_style_filter_ref_modified()

static void sp_style_filter_ref_modified ( SPObject obj,
unsigned  flags,
SPStyle style 
)
static

Emit style modified signal on style's object if the filter changed.

Definition at line 1126 of file style.cpp.

References SPStyle::block_filter_bbox_updates, SPStyle::getFilter(), SPStyle::object, SPObject::requestDisplayUpdate(), and SPObject::requestModified().

Referenced by sp_style_filter_ref_changed().

◆ sp_style_get_css_unit_string()

◆ sp_style_object_release()

static void sp_style_object_release ( SPObject object,
SPStyle style 
)
static

Release callback.

Definition at line 1116 of file style.cpp.

References SPStyle::object.

Referenced by SPStyle::SPStyle().

◆ sp_style_paint_server_ref_modified()

static void sp_style_paint_server_ref_modified ( SPObject obj,
unsigned  ,
SPStyle style 
)
static

Emit style modified signal on style's object if server is style's fill or stroke paint server.

Todo:
fixme: I do not know, whether it is optimal - we are forcing reread of everything (Lauris)
Todo:
fixme: We have to use object_modified flag, because parent flag is only available downstreams.

Definition at line 1167 of file style.cpp.

References SPStyle::fill, SPStyle::getFillPaintServer(), SPStyle::getStrokePaintServer(), SPStyle::object, SPObject::requestModified(), and SPStyle::stroke.

Referenced by sp_style_fill_paint_server_ref_changed(), and sp_style_stroke_paint_server_ref_changed().

◆ sp_style_set_ipaint_to_uri()

◆ sp_style_set_ipaint_to_uri_string()

void sp_style_set_ipaint_to_uri_string ( SPStyle style,
SPIPaint paint,
const gchar *  uri 
)

Definition at line 1287 of file style.cpp.

References SPStyle::document, and sp_style_set_ipaint_to_uri().

Referenced by SPIPaint::read().

◆ sp_style_set_property_url()

◆ sp_style_set_to_uri()

void sp_style_set_to_uri ( SPStyle style,
bool  isfill,
Inkscape::URI const *  uri 
)

◆ sp_style_stroke_paint_server_ref_changed()

void sp_style_stroke_paint_server_ref_changed ( SPObject old_ref,
SPObject ref,
SPStyle style 
)

Gets called when the paintserver is (re)attached to the style.

Definition at line 1210 of file style.cpp.

References ref, SPStyle::signal_stroke_ps_changed, sp_style_paint_server_ref_modified(), and SPStyle::stroke_ps_modified_connection.

Referenced by SPStyle::clear(), SPIPaint::read(), and sp_style_set_ipaint_to_uri().

Variable Documentation

◆ _prop_helper

auto& _prop_helper = SPStylePropHelper::instance()

Definition at line 246 of file style.cpp.

Referenced by SPStyle::clear(), SPStyle::isSet(), SPStyle::readIfUnset(), and SPStyle::SPStyle().

◆ BMAX

constexpr int BMAX = 8192
staticconstexpr

Definition at line 55 of file style.cpp.