~ubuntu-branches/ubuntu/natty/inkscape/natty

« back to all changes in this revision

Viewing changes to src/extension/internal/svg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "extension/system.h"
22
22
#include "extension/output.h"
23
23
#include <vector>
 
24
#include "xml/attribute-record.h"
24
25
 
25
26
#ifdef WITH_GNOME_VFS
26
27
# include <libgnomevfs/gnome-vfs.h>
32
33
 
33
34
#include "clear-n_.h"
34
35
 
 
36
 
 
37
using Inkscape::Util::List;
 
38
using Inkscape::XML::AttributeRecord;
 
39
using Inkscape::XML::Node;
 
40
 
 
41
 
 
42
 
 
43
void pruneExtendedAttributes( Inkscape::XML::Node *repr )
 
44
{
 
45
    if (repr) {
 
46
        if ( repr->type() == Inkscape::XML::ELEMENT_NODE ) {
 
47
            std::vector<gchar const*> toBeRemoved;
 
48
            for ( List<AttributeRecord const> it = repr->attributeList(); it; ++it ) {
 
49
                const gchar* attrName = g_quark_to_string(it->key);
 
50
                if ((strncmp("inkscape:", attrName, 9) == 0) || (strncmp("sodipodi:", attrName, 9) == 0)) {
 
51
                    toBeRemoved.push_back(attrName);
 
52
                }
 
53
            }
 
54
            // Can't change the set we're interating over while we are iterating.
 
55
            for ( std::vector<gchar const*>::iterator it = toBeRemoved.begin(); it != toBeRemoved.end(); ++it ) {
 
56
                repr->setAttribute(*it, 0);
 
57
            }
 
58
        }
 
59
 
 
60
        for ( Node *child = repr->firstChild(); child; child = child->next() ) {
 
61
            pruneExtendedAttributes(child);
 
62
        }
 
63
    }
 
64
}
 
65
 
 
66
 
35
67
/**
36
68
    \return   None
37
69
    \brief    What would an SVG editor be without loading/saving SVG
179
211
    we're getting good data.  It also checks the module ID of the
180
212
    incoming module to figure out whether this save should include
181
213
    the Inkscape namespace stuff or not.  The result of that comparison
182
 
    is stored in the spns variable.
 
214
    is stored in the exportExtensions variable.
183
215
 
184
216
    If there is not to be Inkscape name spaces a new document is created
185
217
    without.  (I think, I'm not sure on this code)
198
230
 
199
231
    gchar *save_path = g_path_get_dirname(filename);
200
232
 
201
 
    bool const spns = ( !mod->get_id()
 
233
    bool const exportExtensions = ( !mod->get_id()
202
234
      || !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE)
203
235
      || !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE));
204
236
 
205
237
    Inkscape::XML::Document *rdoc = NULL;
206
238
    Inkscape::XML::Node *repr = NULL;
207
 
    if (spns) {
 
239
    if (exportExtensions) {
208
240
        repr = sp_document_repr_root (doc);
209
241
    } else {
210
242
        rdoc = sp_repr_document_new ("svg:svg");
211
243
        repr = rdoc->root();
212
244
        repr = sp_document_root (doc)->updateRepr(rdoc, repr, SP_OBJECT_WRITE_BUILD);
 
245
 
 
246
        pruneExtendedAttributes(repr);
213
247
    }
214
248
 
215
249
    if (!sp_repr_save_rebased_file(repr->document(), filename, SP_SVG_NS_URI,
217
251
        throw Inkscape::Extension::Output::save_failed();
218
252
    }
219
253
 
220
 
    if (!spns) {
 
254
    if (!exportExtensions) {
221
255
        Inkscape::GC::release(rdoc);
222
256
    }
223
257