summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e45563a)
raw | patch | inline | side by side (parent: e45563a)
author | miklosh <miklosh@users.sourceforge.net> | |
Sat, 28 Jul 2007 14:31:25 +0000 (14:31 +0000) | ||
committer | miklosh <miklosh@users.sourceforge.net> | |
Sat, 28 Jul 2007 14:31:25 +0000 (14:31 +0000) |
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 9adf1958f99b74bd1e4700c711f601331cd326cc..4a9377b9a2ffd6aae297ce43318eb5301a31cbe8 100644 (file)
sp_document_set_undo_sensitive(doc, false); // No need to undo in this temporary document
// Create builder and parser
- SvgBuilder *builder = new SvgBuilder(doc, pdf_doc->getXRef());
+ gchar *docname = g_path_get_basename(uri);
+ gchar *dot = g_strrstr(docname, ".");
+ if (dot) {
+ *dot = 0;
+ }
+ SvgBuilder *builder = new SvgBuilder(doc, docname, pdf_doc->getXRef());
PdfParser *pdf_parser = new PdfParser(pdf_doc->getXRef(), builder, page_num-1, page->getRotate(),
page->getResourceDict(), page->getCropBox());
obj.free();
delete pdf_parser;
delete builder;
+ g_free(docname);
delete pdf_doc;
// Restore undo
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index f640ded3574dad203e7c6c5bd4597de1fdf37ce7..b0c6c8feaa7065217c9f2a939f760d533f5e4410 100644 (file)
_current_state = NULL;
}
-SvgBuilder::SvgBuilder(SPDocument *document, XRef *xref) {
+SvgBuilder::SvgBuilder(SPDocument *document, gchar *docname, XRef *xref) {
_doc = document;
+ _docname = docname;
_xref = xref;
_xml_doc = sp_document_repr_doc(_doc);
_container = _root = _doc->rroot;
SvgBuilder::SvgBuilder(SvgBuilder *parent, Inkscape::XML::Node *root) {
_doc = parent->_doc;
+ _docname = parent->_docname;
_xref = parent->_xref;
_xml_doc = parent->_xml_doc;
_container = this->_root = root;
this->_height = height;
}
+/**
+ * \brief Sets groupmode of the current container to 'layer' and sets its label if given
+ */
+void SvgBuilder::setAsLayer(char *layer_name) {
+ _container->setAttribute("inkscape:groupmode", "layer");
+ if (layer_name) {
+ _container->setAttribute("inkscape:label", layer_name);
+ }
+}
+
void SvgBuilder::saveState() {
_group_depth.push_back(0);
pushGroup();
_container = node;
Inkscape::GC::release(node);
_group_depth.back()++;
+ // Set as a layer if this is a top-level group
+ if ( _container->parent() == _root ) {
+ static int layer_count = 1;
+ if ( layer_count > 1 ) {
+ gchar *layer_name = g_strdup_printf("%s%d", _docname, layer_count);
+ setAsLayer(layer_name);
+ g_free(layer_name);
+ } else {
+ setAsLayer(_docname);
+ }
+ }
return _container;
}
diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h
index 47a79a0f4c5636f9b7c38382035e7dcb47bd040e..a329e3020111d67f42ba6f92419aea3ef0b17736 100644 (file)
*/
class SvgBuilder {
public:
- SvgBuilder(SPDocument *document, XRef *xref);
+ SvgBuilder(SPDocument *document, gchar *docname, XRef *xref);
SvgBuilder(SvgBuilder *parent, Inkscape::XML::Node *root);
~SvgBuilder();
// Property setting
void setDocumentSize(double width, double height); // Document size in px
+ void setAsLayer(char *layer_name=NULL);
// Handling the node stack
Inkscape::XML::Node *pushGroup();
GfxState *_current_state;
SPDocument *_doc;
+ gchar *_docname; // Basename of the URI from which this document is created
XRef *_xref; // Cross-reference table from the PDF doc we're converting from
Inkscape::XML::Document *_xml_doc;
Inkscape::XML::Node *_root; // Root node from the point of view of this SvgBuilder