void nr_arena_group_set_style (NRArenaGroup *group, SPStyle *style) { g_return_if_fail(group != NULL); g_return_if_fail(NR_IS_ARENA_GROUP(group)); if (style) sp_style_ref(style); if (group->style) sp_style_unref(group->style); group->style = style; //if group has a filter if (style->filter.set && style->getFilter()) { if (!group->filter) { int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); group->filter = new Inkscape::Filters::Filter(primitives); } sp_filter_build_renderer(SP_FILTER(style->getFilter()), group->filter); } else { //no filter set for this group delete group->filter; group->filter = NULL; } if (style && style->enable_background.set && style->enable_background.value == SP_CSS_BACKGROUND_NEW) { group->background_new = true; } }
/** * Process information related to the new style. * * Note: _style is not used by DrawingGlyphs which uses its parent style. */ void DrawingItem::setStyle(SPStyle *style, SPStyle *context_style) { // std::cout << "DrawingItem::setStyle: " << name() << " " << style // << " " << context_style << std::endl; if( style != _style ) { if (style) sp_style_ref(style); if (_style) sp_style_unref(_style); _style = style; } if (style && style->filter.set && style->getFilter()) { if (!_filter) { int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); _filter = new Inkscape::Filters::Filter(primitives); } sp_filter_build_renderer(SP_FILTER(style->getFilter()), _filter); } else { // no filter set for this group delete _filter; _filter = NULL; } if (style && style->enable_background.set) { if (style->enable_background.value == SP_CSS_BACKGROUND_NEW && !_background_new) { _background_new = true; _markForUpdate(STATE_BACKGROUND, true); } else if (style->enable_background.value == SP_CSS_BACKGROUND_ACCUMULATE && _background_new) { _background_new = false; _markForUpdate(STATE_BACKGROUND, true); } } if (context_style != NULL) { _context_style = context_style; } else if (_parent != NULL) { _context_style = _parent->_context_style; } _markForUpdate(STATE_ALL, false); }
// this function does nothing more than store all its parameters for future reference void Layout::appendText(Glib::ustring const &text, SPStyle *style, void *source_cookie, OptionalTextTagAttrs const *optional_attributes, unsigned optional_attributes_offset, Glib::ustring::const_iterator text_begin, Glib::ustring::const_iterator text_end) { if (style == NULL) return; InputStreamTextSource *new_source = new InputStreamTextSource; new_source->source_cookie = source_cookie; new_source->text = &text; new_source->text_begin = text_begin; new_source->text_end = text_end; new_source->style = style; sp_style_ref(style); new_source->text_length = 0; for ( ; text_begin != text_end && text_begin != text.end() ; text_begin++) new_source->text_length++; // save this because calculating the length of a UTF-8 string is expensive if (optional_attributes) { // we need to fill in x and y even if the text is empty so that empty paragraphs can be positioned correctly _copyInputVector(optional_attributes->x, optional_attributes_offset, &new_source->x, std::max(1, new_source->text_length)); _copyInputVector(optional_attributes->y, optional_attributes_offset, &new_source->y, std::max(1, new_source->text_length)); _copyInputVector(optional_attributes->dx, optional_attributes_offset, &new_source->dx, new_source->text_length); _copyInputVector(optional_attributes->dy, optional_attributes_offset, &new_source->dy, new_source->text_length); _copyInputVector(optional_attributes->rotate, optional_attributes_offset, &new_source->rotate, new_source->text_length); if (!optional_attributes->rotate.empty() && optional_attributes_offset >= optional_attributes->rotate.size()) { SVGLength last_rotate; last_rotate = 0.f; for (std::vector<SVGLength>::const_iterator it = optional_attributes->rotate.begin() ; it != optional_attributes->rotate.end() ; ++it) if (it->_set) last_rotate = *it; new_source->rotate.resize(1, last_rotate); } } _input_stream.push_back(new_source); }