summaryrefslogtreecommitdiffstats
path: root/src/extension/internal
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-07-13 20:16:51 +0000
committerTed Gould <ted@gould.cx>2010-07-13 20:16:51 +0000
commitef2d72d29fce61231bdd7888ab8330503158e9d6 (patch)
tree4685bfddef010181fdd87fc182016b994f2b69d9 /src/extension/internal
parentPulling in a more recent trunk (diff)
parentTranslations. Romanian nsh file update. (diff)
downloadinkscape-ef2d72d29fce61231bdd7888ab8330503158e9d6.tar.gz
inkscape-ef2d72d29fce61231bdd7888ab8330503158e9d6.zip
Upgrading to trunk
(bzr r8254.1.57)
Diffstat (limited to 'src/extension/internal')
-rw-r--r--src/extension/internal/cairo-ps-out.cpp14
-rw-r--r--src/extension/internal/cairo-render-context.cpp10
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp7
-rw-r--r--src/extension/internal/filter/drop-shadow.h42
-rw-r--r--src/extension/internal/filter/snow.h7
-rw-r--r--src/extension/internal/grid.cpp4
-rw-r--r--src/extension/internal/latex-text-renderer.cpp22
7 files changed, 58 insertions, 48 deletions
diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index 61760e9d9..16adebac3 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -195,12 +195,7 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- gchar * tex_filename;
- //strip filename of ".ps", do not add ".tex" here.
- gsize n = g_str_has_suffix(filename, ".ps") ? strlen(filename)-3 : strlen(filename);
- tex_filename = g_strndup(filename, n);
- ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_areaDrawing, new_areaPage, false);
- g_free(tex_filename);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
@@ -283,12 +278,7 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- gchar * tex_filename;
- //strip filename of ".eps", do not add ".tex" here.
- gsize n = g_str_has_suffix(filename, ".eps") ? strlen(filename)-4 : strlen(filename);
- tex_filename = g_strndup(filename, n);
- ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_areaDrawing, new_areaPage, false);
- g_free(tex_filename);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index cf3c72432..28d1db9a4 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -1120,11 +1120,11 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
SPLinearGradient *lg=SP_LINEARGRADIENT(paintserver);
- sp_gradient_ensure_vector(SP_GRADIENT(lg)); // when exporting from commandline, vector is not built
+ SP_GRADIENT(lg)->ensureVector(); // when exporting from commandline, vector is not built
Geom::Point p1 (lg->x1.computed, lg->y1.computed);
Geom::Point p2 (lg->x2.computed, lg->y2.computed);
- if (pbox && SP_GRADIENT(lg)->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {
+ if (pbox && SP_GRADIENT(lg)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {
// convert to userspace
Geom::Matrix bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0);
p1 *= bbox2user;
@@ -1144,12 +1144,12 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
SPRadialGradient *rg=SP_RADIALGRADIENT(paintserver);
- sp_gradient_ensure_vector(SP_GRADIENT(rg)); // when exporting from commandline, vector is not built
+ SP_GRADIENT(rg)->ensureVector(); // when exporting from commandline, vector is not built
Geom::Point c (rg->cx.computed, rg->cy.computed);
Geom::Point f (rg->fx.computed, rg->fy.computed);
double r = rg->r.computed;
- if (pbox && SP_GRADIENT(rg)->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX)
+ if (pbox && SP_GRADIENT(rg)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX)
apply_bbox2user = true;
// create radial gradient pattern
@@ -1172,7 +1172,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
SPGradient *g = SP_GRADIENT(paintserver);
// set extend type
- SPGradientSpread spread = sp_gradient_get_spread(g);
+ SPGradientSpread spread = g->fetchSpread();
switch (spread) {
case SP_GRADIENT_SPREAD_REPEAT: {
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 808590e04..e8eff20b7 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -213,12 +213,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- gchar * tex_filename;
- //strip filename of ".pdf", do not add ".tex" here.
- gsize n = g_str_has_suffix(filename, ".pdf") ? strlen(filename)-4 : strlen(filename);
- tex_filename = g_strndup(filename, n);
- ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
- g_free(tex_filename);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h
index 34939222c..a48175fde 100644
--- a/src/extension/internal/filter/drop-shadow.h
+++ b/src/extension/internal/filter/drop-shadow.h
@@ -57,21 +57,26 @@ DropShadow::get_filter_text (Inkscape::Extension::Extension * ext)
{
if (_filter != NULL) g_free((void *)_filter);
- float blur = ext->get_param_float("blur");
- float opacity = ext->get_param_float("opacity") / 100;
- float x = ext->get_param_float("xoffset");
- float y = ext->get_param_float("yoffset");
+ std::ostringstream blur;
+ std::ostringstream opacity;
+ std::ostringstream x;
+ std::ostringstream y;
+
+ blur << ext->get_param_float("blur");
+ opacity << ext->get_param_float("opacity") / 100;
+ x << ext->get_param_float("xoffset");
+ y << ext->get_param_float("yoffset");
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Drop shadow\" width=\"1.5\" height=\"1.5\" x=\"-.25\" y=\"-.25\">\n"
- "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%f\" result=\"blur\"/>\n"
- "<feColorMatrix result=\"bluralpha\" type=\"matrix\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %f 0 \" />\n"
- "<feOffset in=\"bluralpha\" dx=\"%f\" dy=\"%f\" result=\"offsetBlur\"/>\n"
+ "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\"/>\n"
+ "<feColorMatrix result=\"bluralpha\" type=\"matrix\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s 0 \" />\n"
+ "<feOffset in=\"bluralpha\" dx=\"%s\" dy=\"%s\" result=\"offsetBlur\"/>\n"
"<feMerge>\n"
"<feMergeNode in=\"offsetBlur\"/>\n"
"<feMergeNode in=\"SourceGraphic\"/>\n"
"</feMerge>\n"
- "</filter>\n", blur, opacity, x, y);
+ "</filter>\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str());
return _filter;
};
@@ -112,21 +117,26 @@ DropGlow::get_filter_text (Inkscape::Extension::Extension * ext)
{
if (_filter != NULL) g_free((void *)_filter);
- float blur = ext->get_param_float("blur");
- float opacity = ext->get_param_float("opacity") / 100;
- float x = ext->get_param_float("xoffset");
- float y = ext->get_param_float("yoffset");
+ std::ostringstream blur;
+ std::ostringstream opacity;
+ std::ostringstream x;
+ std::ostringstream y;
+
+ blur << ext->get_param_float("blur");
+ opacity << ext->get_param_float("opacity") / 100;
+ x << ext->get_param_float("xoffset");
+ y << ext->get_param_float("yoffset");
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Drop shadow\" width=\"1.5\" height=\"1.5\" x=\"-.25\" y=\"-.25\">\n"
- "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%f\" result=\"blur\"/>\n"
- "<feColorMatrix result=\"bluralpha\" type=\"matrix\" values=\"-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 %f 0 \" />\n"
- "<feOffset in=\"bluralpha\" dx=\"%f\" dy=\"%f\" result=\"offsetBlur\"/>\n"
+ "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\"/>\n"
+ "<feColorMatrix result=\"bluralpha\" type=\"matrix\" values=\"-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 %s 0 \" />\n"
+ "<feOffset in=\"bluralpha\" dx=\"%s\" dy=\"%s\" result=\"offsetBlur\"/>\n"
"<feMerge>\n"
"<feMergeNode in=\"offsetBlur\"/>\n"
"<feMergeNode in=\"SourceGraphic\"/>\n"
"</feMerge>\n"
- "</filter>\n", blur, opacity, x, y);
+ "</filter>\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str());
return _filter;
};
diff --git a/src/extension/internal/filter/snow.h b/src/extension/internal/filter/snow.h
index cb5c55f57..2bb798cf1 100644
--- a/src/extension/internal/filter/snow.h
+++ b/src/extension/internal/filter/snow.h
@@ -51,12 +51,13 @@ Snow::get_filter_text (Inkscape::Extension::Extension * ext)
{
if (_filter != NULL) g_free((void *)_filter);
- float drift = ext->get_param_float("drift");
+ std::ostringstream drift;
+ drift << ext->get_param_float("drift");
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Snow\">\n"
"<feConvolveMatrix order=\"3 3\" kernelMatrix=\"1 1 1 0 0 0 -1 -1 -1\" preserveAlpha=\"false\" divisor=\"3\"/>\n"
- "<feMorphology operator=\"dilate\" radius=\"1 %f\"/>\n"
+ "<feMorphology operator=\"dilate\" radius=\"1 %s\"/>\n"
"<feGaussianBlur stdDeviation=\"1.6270889487870621\" result=\"result0\"/>\n"
"<feColorMatrix values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0\" result=\"result1\"/>\n"
"<feOffset dx=\"0\" dy=\"1\" result=\"result5\"/>\n"
@@ -67,7 +68,7 @@ Snow::get_filter_text (Inkscape::Extension::Extension * ext)
"<feColorMatrix values=\"0.4 0 0 0 0.6 0 0.4 0 0 0.6 0 0 0 0 1 0 0 0 1 0\" result=\"result4\"/>\n"
"<feComposite in2=\"result5\" in=\"result4\"/>\n"
"<feComposite in2=\"SourceGraphic\"/>\n"
- "</filter>\n", drift);
+ "</filter>\n", drift.str().c_str());
return _filter;
};
diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp
index 39bca52d8..1593ffe79 100644
--- a/src/extension/internal/grid.cpp
+++ b/src/extension/internal/grid.cpp
@@ -120,7 +120,9 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
Glib::ustring style("fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000");
style += ";stroke-width:";
gchar floatstring[64];
- sprintf(floatstring, "%f", line_width);
+ std::ostringstream stringstream;
+ stringstream << line_width;
+ sprintf(floatstring, "%s", stringstream.str().c_str());
style += floatstring;
style += "pt";
path->setAttribute("style", style.c_str());
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index c6c597b7a..00448b89e 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -51,7 +51,7 @@ namespace Internal {
/**
* This method is called by the PDF, EPS and PS output extensions.
- * @param filename This should be the filename without extension to which the tex code should be written. Output goes to <filename>.tex.
+ * @param filename This should be the filename without '_tex' extension to which the tex code should be written. Output goes to <filename>_tex, note the underscore instead of period.
*/
bool
latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
@@ -132,7 +132,7 @@ LaTeXTextRenderer::setTargetFile(gchar const *filename) {
_filename = g_path_get_basename(filename);
- gchar *filename_ext = g_strdup_printf("%s.tex", filename);
+ gchar *filename_ext = g_strdup_printf("%s_tex", filename);
Inkscape::IO::dump_fopen_call(filename_ext, "K");
FILE *osf = Inkscape::IO::fopen_utf8name(filename_ext, "w+");
if (!osf) {
@@ -176,14 +176,26 @@ LaTeXTextRenderer::setTargetFile(gchar const *filename) {
static char const preamble[] =
"%% To include the image in your LaTeX document, write\n"
-"%% \\input{<filename>.tex}\n"
+"%% \\input{<filename>.pdf_tex}\n"
"%% instead of\n"
"%% \\includegraphics{<filename>.pdf}\n"
"%% To scale the image, write\n"
-"%% \\def{\\svgwidth}{<desired width>}\n"
-"%% \\input{<filename>.tex}\n"
+"%% \\def\\svgwidth{<desired width>}\n"
+"%% \\input{<filename>.pdf_tex}\n"
"%% instead of\n"
"%% \\includegraphics[width=<desired width>]{<filename>.pdf}\n"
+"%%\n"
+"%% Images with a different path to the parent latex file can\n"
+"%% be accessed with the `import' package (which may need to be\n"
+"%% installed) using\n"
+"%% \\usepackage{import}\n"
+"%% in the preamble, and then including the image with\n"
+"%% \\import{<path to file>}{<filename>.pdf_tex}\n"
+"%% Alternatively, one can specify\n"
+"%% \\graphicspath{{<path to file>/}}\n"
+"%% \n"
+"%% For more information, please see info/svg-inkscape on CTAN:\n"
+"%% http://tug.ctan.org/tex-archive/info/svg-inkscape\n"
"\n"
"\\begingroup\n"
" \\makeatletter\n"