summaryrefslogtreecommitdiffstats
path: root/src/extension/internal
diff options
context:
space:
mode:
authorJabiertxof <jtx@jtx>2017-03-16 19:08:44 +0000
committerJabiertxof <jtx@jtx>2017-03-16 19:08:44 +0000
commit8330d0ef2b97c73121ead78ea9fbcec6ee01f879 (patch)
tree1b1717d1706ee6ebfecc800f2cc80430eb0450e0 /src/extension/internal
parentupdate to trunk (diff)
parentFix rendering when canvas rotated. General code clean-up and documentation. (diff)
downloadinkscape-8330d0ef2b97c73121ead78ea9fbcec6ee01f879.tar.gz
inkscape-8330d0ef2b97c73121ead78ea9fbcec6ee01f879.zip
Update to trunk
(bzr r13645.1.170)
Diffstat (limited to 'src/extension/internal')
-rw-r--r--src/extension/internal/bitmap/imagemagick.cpp1
-rw-r--r--src/extension/internal/cdr-input.cpp45
-rw-r--r--src/extension/internal/filter/color.h2
-rw-r--r--src/extension/internal/filter/protrusions.h2
-rw-r--r--src/extension/internal/metafile-print.cpp34
-rw-r--r--src/extension/internal/metafile-print.h1
-rw-r--r--src/extension/internal/vsd-input.cpp40
-rw-r--r--src/extension/internal/wmf-inout.cpp10
-rw-r--r--src/extension/internal/wmf-print.cpp23
-rw-r--r--src/extension/internal/wpg-input.cpp7
10 files changed, 118 insertions, 47 deletions
diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp
index 472c2db91..cc5b3d1bc 100644
--- a/src/extension/internal/bitmap/imagemagick.cpp
+++ b/src/extension/internal/bitmap/imagemagick.cpp
@@ -213,6 +213,7 @@ ImageMagick::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::Vi
dc->_nodes[i]->setAttribute("xlink:href", dc->_caches[i], true);
dc->_nodes[i]->setAttribute("sodipodi:absref", NULL, true);
+ delete blob;
}
catch (Magick::Exception &error_) {
printf("Caught exception: %s \n", error_.what());
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
index 0435f1396..70bf84ef4 100644
--- a/src/extension/internal/cdr-input.cpp
+++ b/src/extension/internal/cdr-input.cpp
@@ -41,6 +41,7 @@
#endif
#include <gtkmm/alignment.h>
+#include <gtkmm/grid.h>
#include <gtkmm/spinbutton.h>
#include "extension/system.h"
@@ -83,6 +84,8 @@ private:
class Gtk::Widget * _previewArea;
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
+
+ class Gtk::HBox * _page_selector_box;
class Gtk::Label * _labelSelect;
class Gtk::Label * _labelTotalPages;
class Gtk::SpinButton * _pageNumberSpin;
@@ -114,36 +117,38 @@ CdrImportDialog::CdrImportDialog(const std::vector<RVNGString> &vec)
this->get_content_area()->pack_start(*vbox1);
// CONTROLS
+ _page_selector_box = Gtk::manage(new Gtk::HBox());
- // Buttons
- cancelbutton = Gtk::manage(new Gtk::Button(_("_Cancel"), true));
- okbutton = Gtk::manage(new Gtk::Button(_("_OK"), true));
-
- // Labels
+ // "Select page:" label
_labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
_labelTotalPages = Gtk::manage(new class Gtk::Label());
_labelSelect->set_line_wrap(false);
_labelSelect->set_use_markup(false);
_labelSelect->set_selectable(false);
+ _page_selector_box->pack_start(*_labelSelect, Gtk::PACK_SHRINK);
+
+ // Adjustment + spinner
+ auto pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(pageNumberSpin_adj, 1, 0));
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_wrap(false);
+ _page_selector_box->pack_start(*_pageNumberSpin, Gtk::PACK_SHRINK);
+
_labelTotalPages->set_line_wrap(false);
_labelTotalPages->set_use_markup(false);
_labelTotalPages->set_selectable(false);
gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
_labelTotalPages->set_label(label_text);
g_free(label_text);
+ _page_selector_box->pack_start(*_labelTotalPages, Gtk::PACK_SHRINK);
- // Adjustment + spinner
- auto _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
- _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0));
- _pageNumberSpin->set_can_focus();
- _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
- _pageNumberSpin->set_numeric(true);
- _pageNumberSpin->set_wrap(false);
+ vbox1->pack_end(*_page_selector_box, Gtk::PACK_SHRINK);
- this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
- this->get_action_area()->add(*_labelSelect);
- this->add_action_widget(*_pageNumberSpin, Gtk::RESPONSE_ACCEPT);
- this->get_action_area()->add(*_labelTotalPages);
+ // Buttons
+ cancelbutton = Gtk::manage(new Gtk::Button(_("_Cancel"), true));
+ okbutton = Gtk::manage(new Gtk::Button(_("_OK"), true));
this->add_action_widget(*cancelbutton, Gtk::RESPONSE_CANCEL);
this->add_action_widget(*okbutton, Gtk::RESPONSE_OK);
@@ -218,11 +223,13 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
// RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows
// therefore attempt to convert uri to the system codepage
// even if this is not possible the alternate short (8.3) file name will be used if available
- uri = g_win32_locale_filename_from_utf8(uri);
+ gchar * converted_uri = g_win32_locale_filename_from_utf8(uri);
+ RVNGFileStream input(converted_uri);
+ g_free(converted_uri);
+ #else
+ RVNGFileStream input(uri);
#endif
- RVNGFileStream input(uri);
-
if (!libcdr::CDRDocument::isSupported(&input)) {
return NULL;
}
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h
index a6b777d20..6324dafa9 100644
--- a/src/extension/internal/filter/color.h
+++ b/src/extension/internal/filter/color.h
@@ -1480,7 +1480,7 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Quadritone fantasy") "</name>\n"
+ "<name>" N_("Quadritone Fantasy") "</name>\n"
"<id>org.inkscape.effect.filter.Quadritone</id>\n"
"<param name=\"dist\" _gui-text=\"" N_("Hue distribution (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">280</param>\n"
"<param name=\"colors\" _gui-text=\"" N_("Colors") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">100</param>\n"
diff --git a/src/extension/internal/filter/protrusions.h b/src/extension/internal/filter/protrusions.h
index ad75d8896..d6fd315db 100644
--- a/src/extension/internal/filter/protrusions.h
+++ b/src/extension/internal/filter/protrusions.h
@@ -45,7 +45,7 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Snow crest") "</name>\n"
+ "<name>" N_("Snow Crest") "</name>\n"
"<id>org.inkscape.effect.filter.snow</id>\n"
"<param name=\"drift\" _gui-text=\"" N_("Drift Size") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"20.0\">3.5</param>\n"
"<effect>\n"
diff --git a/src/extension/internal/metafile-print.cpp b/src/extension/internal/metafile-print.cpp
index 061eb634d..11567ceb3 100644
--- a/src/extension/internal/metafile-print.cpp
+++ b/src/extension/internal/metafile-print.cpp
@@ -355,6 +355,27 @@ int PrintMetafile::hold_gradient(void *gr, int mode)
return 1;
}
+/* behaves like snprintf() but makes sure decimal separators are formatted as dots
+ otherwise invalid strings can be produced depending on the set locale
+*/
+int PrintMetafile::snprintf_dots(char * s, size_t n, const char * format, ...)
+{
+ int nChars;
+
+ char *oldlocale = g_strdup(setlocale(LC_NUMERIC, NULL));
+ setlocale(LC_NUMERIC, "C");
+
+ va_list argptr;
+ va_start(argptr, format);
+ nChars = vsnprintf(s, n, format, argptr);
+ va_end(argptr);
+
+ setlocale(LC_NUMERIC, oldlocale);
+ g_free(oldlocale);
+
+ return nChars;
+}
+
/* convert from center ellipse to SVGEllipticalArc ellipse
From:
@@ -390,7 +411,8 @@ Geom::PathVector PrintMetafile::center_ellipse_as_SVG_PathV(Geom::Point ctr, dou
y2 = ctr[Y] + sin(F) * rx * cos(M_PI) + cos(F) * ry * sin(M_PI);
char text[256];
- sprintf(text, " M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z", x1, y1, rx, ry, F * 360. / (2.*M_PI), x2, y2, rx, ry, F * 360. / (2.*M_PI), x1, y1);
+ snprintf_dots(text, 256, " M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z",
+ x1, y1, rx, ry, F * 360. / (2.*M_PI), x2, y2, rx, ry, F * 360. / (2.*M_PI), x1, y1);
Geom::PathVector outres = Geom::parse_svg_path(text);
return outres;
}
@@ -418,9 +440,9 @@ Geom::PathVector PrintMetafile::center_elliptical_ring_as_SVG_PathV(Geom::Point
y22 = ctr[Y] + sin(F) * rx2 * cos(M_PI) + cos(F) * ry2 * sin(M_PI);
char text[512];
- sprintf(text, " M %f,%f A %f %f %f 0 1 %f %f A %f %f %f 0 1 %f %f z M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z",
- x11, y11, rx1, ry1, degrot, x12, y12, rx1, ry1, degrot, x11, y11,
- x21, y21, rx2, ry2, degrot, x22, y22, rx2, ry2, degrot, x21, y21);
+ snprintf_dots(text, 512, " M %f,%f A %f %f %f 0 1 %f %f A %f %f %f 0 1 %f %f z M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z",
+ x11, y11, rx1, ry1, degrot, x12, y12, rx1, ry1, degrot, x11, y11,
+ x21, y21, rx2, ry2, degrot, x22, y22, rx2, ry2, degrot, x21, y21);
Geom::PathVector outres = Geom::parse_svg_path(text);
return outres;
@@ -440,8 +462,8 @@ Geom::PathVector PrintMetafile::center_elliptical_hole_as_SVG_PathV(Geom::Point
y2 = ctr[Y] + sin(F) * rx * cos(M_PI) + cos(F) * ry * sin(M_PI);
char text[256];
- sprintf(text, " M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z M 50000,50000 50000,-50000 -50000,-50000 -50000,50000 z",
- x1, y1, rx, ry, F * 360. / (2.*M_PI), x2, y2, rx, ry, F * 360. / (2.*M_PI), x1, y1);
+ snprintf_dots(text, 256, " M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z M 50000,50000 50000,-50000 -50000,-50000 -50000,50000 z",
+ x1, y1, rx, ry, F * 360. / (2.*M_PI), x2, y2, rx, ry, F * 360. / (2.*M_PI), x1, y1);
Geom::PathVector outres = Geom::parse_svg_path(text);
return outres;
}
diff --git a/src/extension/internal/metafile-print.h b/src/extension/internal/metafile-print.h
index d184b72b7..9903cbb98 100644
--- a/src/extension/internal/metafile-print.h
+++ b/src/extension/internal/metafile-print.h
@@ -101,6 +101,7 @@ protected:
static void swapRBinRGBA(char *px, int pixels);
int hold_gradient(void *gr, int mode);
+ static int snprintf_dots(char * s, size_t n, const char * format, ...);
static Geom::PathVector center_ellipse_as_SVG_PathV(Geom::Point ctr, double rx, double ry, double F);
static Geom::PathVector center_elliptical_ring_as_SVG_PathV(Geom::Point ctr, double rx1, double ry1, double rx2, double ry2, double F);
static Geom::PathVector center_elliptical_hole_as_SVG_PathV(Geom::Point ctr, double rx, double ry, double F);
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
index 78783aa2d..b7277b99e 100644
--- a/src/extension/internal/vsd-input.cpp
+++ b/src/extension/internal/vsd-input.cpp
@@ -84,6 +84,8 @@ private:
class Gtk::Widget * _previewArea;
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
+
+ class Gtk::HBox * _page_selector_box;
class Gtk::Label * _labelSelect;
class Gtk::Label * _labelTotalPages;
class Gtk::SpinButton * _pageNumberSpin;
@@ -116,10 +118,7 @@ VsdImportDialog::VsdImportDialog(const std::vector<RVNGString> &vec)
this->get_content_area()->pack_start(*vbox1);
// CONTROLS
-
- // Buttons
- cancelbutton = Gtk::manage(new Gtk::Button(_("_Cancel"), true));
- okbutton = Gtk::manage(new Gtk::Button(_("_OK"), true));
+ _page_selector_box = Gtk::manage(new Gtk::HBox());
// Labels
_labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
@@ -127,12 +126,7 @@ VsdImportDialog::VsdImportDialog(const std::vector<RVNGString> &vec)
_labelSelect->set_line_wrap(false);
_labelSelect->set_use_markup(false);
_labelSelect->set_selectable(false);
- _labelTotalPages->set_line_wrap(false);
- _labelTotalPages->set_use_markup(false);
- _labelTotalPages->set_selectable(false);
- gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
- _labelTotalPages->set_label(label_text);
- g_free(label_text);
+ _page_selector_box->pack_start(*_labelSelect, Gtk::PACK_SHRINK);
// Adjustment + spinner
auto _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
@@ -141,11 +135,21 @@ VsdImportDialog::VsdImportDialog(const std::vector<RVNGString> &vec)
_pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
_pageNumberSpin->set_numeric(true);
_pageNumberSpin->set_wrap(false);
+ _page_selector_box->pack_start(*_pageNumberSpin, Gtk::PACK_SHRINK);
- this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
- this->get_action_area()->add(*_labelSelect);
- this->add_action_widget(*_pageNumberSpin, Gtk::RESPONSE_ACCEPT);
- this->get_action_area()->add(*_labelTotalPages);
+ _labelTotalPages->set_line_wrap(false);
+ _labelTotalPages->set_use_markup(false);
+ _labelTotalPages->set_selectable(false);
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+ _page_selector_box->pack_start(*_labelTotalPages, Gtk::PACK_SHRINK);
+
+ vbox1->pack_end(*_page_selector_box, Gtk::PACK_SHRINK);
+
+ // Buttons
+ cancelbutton = Gtk::manage(new Gtk::Button(_("_Cancel"), true));
+ okbutton = Gtk::manage(new Gtk::Button(_("_OK"), true));
this->add_action_widget(*cancelbutton, Gtk::RESPONSE_CANCEL);
this->add_action_widget(*okbutton, Gtk::RESPONSE_OK);
@@ -220,11 +224,13 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
// RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows
// therefore attempt to convert uri to the system codepage
// even if this is not possible the alternate short (8.3) file name will be used if available
- uri = g_win32_locale_filename_from_utf8(uri);
+ gchar * converted_uri = g_win32_locale_filename_from_utf8(uri);
+ RVNGFileStream input(converted_uri);
+ g_free(converted_uri);
+ #else
+ RVNGFileStream input(uri);
#endif
- RVNGFileStream input(uri);
-
if (!libvisio::VisioDocument::isSupported(&input)) {
return NULL;
}
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index a79af5ec1..42ec2f2bb 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -1765,11 +1765,20 @@ std::cout << "BEFORE DRAW"
<< " test0 " << ( d->mask & U_DRAW_VISIBLE)
<< " test1 " << ( d->mask & U_DRAW_FORCE)
<< " test2 " << (wmr_mask & U_DRAW_ALTERS)
+ << " test2.5 " << ((d->mask & U_DRAW_NOFILL) != (wmr_mask & U_DRAW_NOFILL) )
<< " test3 " << (wmr_mask & U_DRAW_VISIBLE)
<< " test4 " << !(d->mask & U_DRAW_ONLYTO)
<< " test5 " << ((d->mask & U_DRAW_ONLYTO) && !(wmr_mask & U_DRAW_ONLYTO) )
<< std::endl;
*/
+ /* spurious moveto records should not affect the drawing. However, they set the NOFILL
+ bit and that messes up the logic about when to emit a path. So prune out any
+ stray moveto records. That is those which were never followed by a lineto.
+ */
+ if((d->mask & U_DRAW_NOFILL) && !(d->mask & U_DRAW_VISIBLE) &&
+ !(wmr_mask & U_DRAW_ONLYTO) && (wmr_mask & U_DRAW_VISIBLE)){
+ d->mask ^= U_DRAW_NOFILL;
+ }
if(
(wmr_mask != U_WMR_INVALID) && // next record is valid type
@@ -1777,6 +1786,7 @@ std::cout << "BEFORE DRAW"
(
(d->mask & U_DRAW_FORCE) || // This draw is forced by STROKE/FILL/STROKEANDFILL PATH
(wmr_mask & U_DRAW_ALTERS) || // Next record would alter the drawing environment in some way
+ ((d->mask & U_DRAW_NOFILL) != (wmr_mask & U_DRAW_NOFILL)) || // Fill<->!Fill requires a draw between
( (wmr_mask & U_DRAW_VISIBLE) && // Next record is visible...
(
( !(d->mask & U_DRAW_ONLYTO) ) || // Non *TO records cannot be followed by any Visible
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index 3d913bf1e..6dd9d895e 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -598,7 +598,28 @@ int PrintWmf::create_pen(SPStyle const *style, const Geom::Affine &transform)
if (!style->stroke_dasharray.values.empty()) {
if (!FixPPTDashLine) { // if this is set code elsewhere will break dots/dashes into many smaller lines.
- penstyle = U_PS_DASH;// userstyle not supported apparently, for now map all Inkscape dot/dash to just dash
+ int n_dash = style->stroke_dasharray.values.size();
+ /* options are dash, dot, dashdot and dashdotdot. Try to pick the closest one. */
+ int mark_short=INT_MAX;
+ int mark_long =0;
+ int i;
+ for (i=0;i<n_dash;i++) {
+ int mark = style->stroke_dasharray.values[i];
+ if (mark>mark_long) { mark_long = mark; }
+ if (mark<mark_short) { mark_short = mark; }
+ }
+ if(mark_long == mark_short){ // only one mark size
+ penstyle = U_PS_DOT;
+ }
+ else if (n_dash==2) {
+ penstyle = U_PS_DASH;
+ }
+ else if (n_dash==4) {
+ penstyle = U_PS_DASHDOT;
+ }
+ else {
+ penstyle = U_PS_DASHDOTDOT;
+ }
}
}
diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp
index 12457791b..299614c94 100644
--- a/src/extension/internal/wpg-input.cpp
+++ b/src/extension/internal/wpg-input.cpp
@@ -85,10 +85,13 @@ SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
// RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows
// therefore attempt to convert uri to the system codepage
// even if this is not possible the alternate short (8.3) file name will be used if available
- uri = g_win32_locale_filename_from_utf8(uri);
+ gchar * converted_uri = g_win32_locale_filename_from_utf8(uri);
+ RVNGInputStream* input = new RVNGFileStream(converted_uri);
+ g_free(converted_uri);
+ #else
+ RVNGInputStream* input = new RVNGFileStream(uri);
#endif
- RVNGInputStream* input = new RVNGFileStream(uri);
#if WITH_LIBWPG03
if (input->isStructured()) {
RVNGInputStream* olestream = input->getSubStreamByName("PerfectOffice_MAIN");