~ubuntu-branches/debian/squeeze/inkscape/squeeze

« back to all changes in this revision

Viewing changes to src/sp-style-elem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#include "document.h"
5
5
#include "sp-style-elem.h"
6
6
#include "attributes.h"
 
7
#include "style.h"
7
8
using Inkscape::XML::TEXT_NODE;
8
9
 
9
10
static void sp_style_elem_init(SPStyleElem *style_elem);
122
123
sp_style_elem_write(SPObject *const object, Inkscape::XML::Node *repr, guint const flags)
123
124
{
124
125
    if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
125
 
        repr = sp_repr_new("svg:style");
 
126
        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
 
127
        repr = xml_doc->createElement("svg:style");
126
128
    }
127
129
 
128
130
    g_return_val_if_fail(object, repr);
130
132
    if (flags & SP_OBJECT_WRITE_BUILD) {
131
133
        g_warning("nyi: Forming <style> content for SP_OBJECT_WRITE_BUILD.");
132
134
        /* fixme: Consider having the CRStyleSheet be a member of SPStyleElem, and then
133
 
           pretty-print to a string s, then repr->addChild(sp_repr_new_text(s), NULL). */
 
135
           pretty-print to a string s, then repr->addChild(xml_doc->createTextNode(s), NULL). */
134
136
    }
135
137
    if (style_elem.is_css) {
136
138
        repr->setAttribute("type", "text/css");
357
359
    }
358
360
    cr_parser_destroy(parser);
359
361
    //object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 
362
 
 
363
    // Style references via class= do not, and actually cannot, use autoupdating URIReferences.
 
364
    // Therefore, if an object refers to a stylesheet which has not yet loaded when the object is being loaded
 
365
    // (e.g. if the stylesheet is below or inside the object in XML), its class= has no effect (bug 1491639).
 
366
    // Below is a partial hack that fixes this for a single case: when the <style> is a child of the object
 
367
    // that uses a style from it. It just forces the parent of <style> to reread its style as soon as the stylesheet
 
368
    // is fully loaded. Naturally, this won't work if the user of the stylesheet is its grandparent or precedent.
 
369
    SPObject *parent = SP_OBJECT_PARENT (object);
 
370
    if ( parent ) {
 
371
        sp_style_read_from_object(parent->style, parent);
 
372
    }
360
373
}
361
374
 
362
375
/**