Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

static void sp_style_read_ifilter ( gchar const *  str,
SPStyle style,
SPDocument document 
) [static]

Set SPIFilter object from string.

Definition at line 3150 of file style.cpp.

References SPStyle::filter, SPIFilter::href, SPIFilter::inherit, SPIFilter::set, and sp_style_filter_ref_changed().

Referenced by sp_style_merge_property(), and sp_style_read().

{
    SPIFilter *f = &(style->filter);
    /* Try all possible values: inherit, none, uri */
    if (streq(str, "inherit")) {
        f->set = TRUE;
        f->inherit = TRUE;
        if (f->href && f->href->getObject())
            f->href->detach(); 
    } else if(streq(str, "none")) {
        f->set = TRUE;
        f->inherit = FALSE;
        if (f->href && f->href->getObject())
           f->href->detach(); 
    } else if (strneq(str, "url", 3)) {
        char *uri = extract_uri(str);
        if(uri == NULL || uri[0] == '\0') {
            g_warning("Specified filter url is empty");
            f->set = TRUE;
            f->inherit = FALSE;
            return;
        }
        f->set = TRUE;
        f->inherit = FALSE;
        if (f->href && f->href->getObject())
            f->href->detach();

        // it may be that this style has not yet created its SPFilterReference;
        // now that we have a document, we can create it here
        if (!f->href && document) {
            f->href = new SPFilterReference(document);
            f->href->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_style_filter_ref_changed), style));
        }

        try {
            f->href->attach(Inkscape::URI(uri));
        } catch (Inkscape::BadURIException &e) {
            g_warning("%s", e.what());
            f->href->detach();
        }
        g_free (uri);

    } else {
        /* We shouldn't reach this if SVG input is well-formed */
        f->set = FALSE;
        f->inherit = FALSE;
        if (f->href && f->href->getObject())
            f->href->detach(); 
    }
}


Generated by  Doxygen 1.6.0   Back to index