diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-11-05 21:29:03 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-11-05 21:29:03 +0000 |
| commit | 647b3ccad1fd3b178e92341fdc92fd276a234dff (patch) | |
| tree | 8888f18c3f1455b6a182c90063a8edfbc0a96d54 | |
| parent | Change modifier to enter rotate mode from SHIFT to CONTROL (diff) | |
| download | inkscape-647b3ccad1fd3b178e92341fdc92fd276a234dff.tar.gz inkscape-647b3ccad1fd3b178e92341fdc92fd276a234dff.zip | |
Add exporters
(bzr r15142.1.32)
| -rwxr-xr-x | share/extensions/hpgl_output.py | 14 | ||||
| -rwxr-xr-x | share/extensions/synfig_output.py | 9 | ||||
| -rw-r--r-- | src/extension/internal/cairo-png-out.cpp | 4 | ||||
| -rw-r--r-- | src/extension/internal/cairo-ps-out.cpp | 7 | ||||
| -rw-r--r-- | src/extension/internal/cairo-renderer-pdf-out.cpp | 4 | ||||
| -rw-r--r-- | src/extension/internal/emf-inout.cpp | 5 | ||||
| -rw-r--r-- | src/extension/internal/javafx-out.cpp | 9 | ||||
| -rw-r--r-- | src/extension/internal/latex-pstricks-out.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/odf.cpp | 9 | ||||
| -rw-r--r-- | src/extension/internal/pov-out.cpp | 13 | ||||
| -rw-r--r-- | src/extension/internal/wmf-inout.cpp | 7 | ||||
| -rw-r--r-- | src/print.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/export.cpp | 3 |
13 files changed, 70 insertions, 18 deletions
diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index 58f82da71..367a9addd 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # standard library import sys +from inkex import NSS # local libraries import hpgl_encoder import inkex @@ -48,6 +49,13 @@ class HpglOutput(inkex.Effect): def effect(self): self.options.debug = False # get hpgl data + svg = self.document.getroot() + xpathStr = '//sodipodi:namedview' + nv = svg.xpath(xpathStr, namespaces=NSS) + document_rotate = "0" + if nv != []: + document_rotate = nv[0].get("{http://www.inkscape.org/namespaces/inkscape}document-rotation") + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document-rotation","0") myHpglEncoder = hpgl_encoder.hpglEncoder(self) try: self.hpgl, debugObject = myHpglEncoder.getHpgl() @@ -56,9 +64,13 @@ class HpglOutput(inkex.Effect): # issue error if no paths found inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths.")) self.hpgl = '' + if nv != [] and document_rotate: + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) return else: type, value, traceback = sys.exc_info() + if nv != [] and document_rotate: + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) raise ValueError, ("", type, value), traceback # convert raw HPGL to HPGL hpglInit = 'IN' @@ -67,6 +79,8 @@ class HpglOutput(inkex.Effect): if self.options.speed > 0: hpglInit += ';VS%d' % self.options.speed self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; ' + if nv != [] and document_rotate: + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) def output(self): # print to file diff --git a/share/extensions/synfig_output.py b/share/extensions/synfig_output.py index bcd1eeaf3..461078951 100755 --- a/share/extensions/synfig_output.py +++ b/share/extensions/synfig_output.py @@ -1046,6 +1046,11 @@ def extract_width(style, width_attrib, mtx): ###### Main Class ######################################### class SynfigExport(SynfigPrep): def __init__(self): + svg = self.document.getroot() + xpathStr = '//http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}:namedview' + res = svg.xpath(xpathStr, namespaces=inkex.NSS) + self.document_rotate = res[0].get("inkscape:document_rotation") + res[0].set("inkscape:document_rotation","0") SynfigPrep.__init__(self) def effect(self): @@ -1073,6 +1078,10 @@ class SynfigExport(SynfigPrep): root_canvas.append(layer) d.get_root_tree().write(sys.stdout) + svg = self.document.getroot() + xpathStr = '//http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}:namedview' + res = svg.xpath(xpathStr, namespaces=inkex.NSS) + res[0].set("inkscape:document_rotation",self.document_rotate) def convert_node(self, node, d): """Convert an SVG node to a list of Synfig layers""" diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp index 956fcce9a..5859a82da 100644 --- a/src/extension/internal/cairo-png-out.cpp +++ b/src/extension/internal/cairo-png-out.cpp @@ -53,11 +53,10 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) { CairoRenderer *renderer; CairoRenderContext *ctx; - + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; doc->ensureUpToDate(); /* Start */ - SPItem *base = doc->getRoot(); Inkscape::Drawing drawing; unsigned dkey = SPItem::display_key_new(1); @@ -77,6 +76,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) renderer->destroyContext(ctx); base->invoke_hide(dkey); + doc->getRoot()->c2p *= doc->getRoot()->rotation; /* end */ delete renderer; diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index e8f47e79e..809125266 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -68,6 +68,7 @@ static bool ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext, bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px, bool eps = false) { + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; doc->ensureUpToDate(); SPItem *base = NULL; @@ -84,9 +85,10 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l pageBoundingBox = !exportDrawing; } - if (!base) + if (!base) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; return false; - + } Inkscape::Drawing drawing; unsigned dkey = SPItem::display_key_new(1); base->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); @@ -115,6 +117,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l renderer->destroyContext(ctx); delete renderer; + doc->getRoot()->c2p *= doc->getRoot()->rotation; return ret; } diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index 5576676b2..5558fe1ad 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -61,6 +61,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int bool texttopath, bool omittext, bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px) { + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; doc->ensureUpToDate(); /* Start */ @@ -80,6 +81,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int } if (!base) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; return false; } @@ -112,7 +114,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int renderer->destroyContext(ctx); delete renderer; - + doc->getRoot()->c2p *= doc->getRoot()->rotation; return ret; } diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 12751c5ec..198c18ff2 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -94,7 +94,7 @@ Emf::print_document_to_file(SPDocument *doc, const gchar *filename) const gchar *oldconst; gchar *oldoutput; unsigned int ret; - + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; doc->ensureUpToDate(); mod = Inkscape::Extension::get_print(PRINT_EMF); @@ -114,6 +114,7 @@ Emf::print_document_to_file(SPDocument *doc, const gchar *filename) /* Print document */ ret = mod->begin(doc); if (ret) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; g_free(oldoutput); throw Inkscape::Extension::Output::save_failed(); } @@ -127,7 +128,7 @@ Emf::print_document_to_file(SPDocument *doc, const gchar *filename) mod->set_param_string("destination", oldoutput); g_free(oldoutput); - + doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index d7ad7e6f7..c95434939 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -843,7 +843,8 @@ void JavaFXOutput::reset() bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) { reset(); - + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; + doc->ensureUpToDate(); name = Glib::path_get_basename(filename_utf8); int pos = name.find('.'); @@ -856,12 +857,14 @@ bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) //# Lets do the curves first, to get the stats if (!doTree(doc)) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; return false; } String curveBuf = outbuf; outbuf.clear(); if (!doHeader()) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; return false; } @@ -875,6 +878,7 @@ bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) doBody(doc, doc->getRoot()); if (!doTail()) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; return false; } @@ -884,6 +888,7 @@ bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) FILE *f = Inkscape::IO::fopen_utf8name(filename_utf8, "w"); if (!f) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; err("Could open JavaFX file '%s' for writing", filename_utf8); return false; } @@ -894,7 +899,7 @@ bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) } fclose(f); - + doc->getRoot()->c2p *= doc->getRoot()->rotation; return true; } diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp index 3ce2c5531..aa6ea6963 100644 --- a/src/extension/internal/latex-pstricks-out.cpp +++ b/src/extension/internal/latex-pstricks-out.cpp @@ -49,6 +49,7 @@ bool LatexOutput::check(Inkscape::Extension::Extension * /*module*/) void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, gchar const *filename) { SPPrintContext context; + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; doc->ensureUpToDate(); Inkscape::Extension::Print *mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX); @@ -76,6 +77,7 @@ void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, mod->set_param_string("destination", oldoutput); g_free(oldoutput); + doc->getRoot()->c2p *= doc->getRoot()->rotation; } #include "clear-n_.h" diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index f885ef5e5..66d370357 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -72,6 +72,7 @@ #include "sp-path.h" #include "sp-text.h" #include "sp-flowtext.h" +#include "sp-root.h" #include "svg/svg.h" #include "text-editing.h" #include "util/units.h" @@ -2095,7 +2096,8 @@ void OdfOutput::reset() void OdfOutput::save(Inkscape::Extension::Output */*mod*/, SPDocument *doc, gchar const *filename) { reset(); - + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; + doc->ensureUpToDate(); documentUri = Inkscape::URI(filename); ZipFile zf; @@ -2104,25 +2106,30 @@ void OdfOutput::save(Inkscape::Extension::Output */*mod*/, SPDocument *doc, gcha if (!writeManifest(zf)) { g_warning("Failed to write manifest"); + doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } if (!writeContent(zf, doc->rroot)) { g_warning("Failed to write content"); + doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } if (!writeMeta(zf)) { g_warning("Failed to write metafile"); + doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } if (!zf.writeFile(filename)) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } + doc->getRoot()->c2p *= doc->getRoot()->rotation; } diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 8df883069..03a2ecd62 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -616,11 +616,13 @@ void PovOutput::reset() void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) { reset(); - + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; + doc->ensureUpToDate(); //###### SAVE IN POV FORMAT TO BUFFER //# Lets do the curves first, to get the stats if (!doTree(doc)) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; err("Could not output curves for %s", filename_utf8); return; } @@ -630,6 +632,7 @@ void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) if (!doHeader()) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; err("Could not write header for %s", filename_utf8); return; } @@ -638,6 +641,7 @@ void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) if (!doTail()) { + doc->getRoot()->c2p *= doc->getRoot()->rotation; err("Could not write footer for %s", filename_utf8); return; } @@ -648,9 +652,11 @@ void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) //###### WRITE TO FILE Inkscape::IO::dump_fopen_call(filename_utf8, "L"); FILE *f = Inkscape::IO::fopen_utf8name(filename_utf8, "w"); - if (!f) + if (!f){ + doc->getRoot()->c2p *= doc->getRoot()->rotation; return; - + } + for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); ++iter) { int ch = *iter; @@ -658,6 +664,7 @@ void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) } fclose(f); + doc->getRoot()->c2p *= doc->getRoot()->rotation; } diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index c7226a58a..a79af5ec1 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -95,7 +95,7 @@ Wmf::print_document_to_file(SPDocument *doc, const gchar *filename) SPPrintContext context; const gchar *oldconst; gchar *oldoutput; - + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; doc->ensureUpToDate(); mod = Inkscape::Extension::get_print(PRINT_WMF); @@ -115,6 +115,7 @@ Wmf::print_document_to_file(SPDocument *doc, const gchar *filename) /* Print document */ if (mod->begin(doc)) { g_free(oldoutput); + doc->getRoot()->c2p *= doc->getRoot()->rotation; throw Inkscape::Extension::Output::save_failed(); } mod->base->invoke_print(&context); @@ -127,7 +128,7 @@ Wmf::print_document_to_file(SPDocument *doc, const gchar *filename) mod->set_param_string("destination", oldoutput); g_free(oldoutput); - + doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } @@ -135,6 +136,8 @@ Wmf::print_document_to_file(SPDocument *doc, const gchar *filename) void Wmf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename) { + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; + doc->ensureUpToDate(); Inkscape::Extension::Extension * ext; ext = Inkscape::Extension::db.get(PRINT_WMF); diff --git a/src/print.cpp b/src/print.cpp index 7cd05ac93..479401995 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -79,6 +79,7 @@ unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p, void sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) { + doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; doc->ensureUpToDate(); // Build arena @@ -88,6 +89,7 @@ sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) Inkscape::UI::Dialog::Print printop(doc,base); Gtk::PrintOperationResult res = printop.run(Gtk::PRINT_OPERATION_ACTION_PRINT_DIALOG, parentWindow); (void)res; // TODO handle this + doc->getRoot()->c2p *= doc->getRoot()->rotation; } void sp_print_document_to_file(SPDocument *doc, gchar const *filename) diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 95c97390d..c38e798ec 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -977,9 +977,6 @@ void Export::onExport () SPDocument *doc = desktop->getDocument(); Geom::Affine rot = doc->getRoot()->c2p; doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; - //double rotate_angle = doc->getRoot()->get_rotation(); - //Inkscape::XML::Node *nv_repr = sp_item_group_get_child_by_name(doc->getRoot(), NULL, "sodipodi:namedview")->getRepr(); - //sp_repr_set_svg_double(nv_repr, "inkscape:document-rotation", 0.); doc->ensureUpToDate(); bool exportSuccessful = false; |
