From 513f26fe1c01359944a4e2a6497850a0bf7b0a8c Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 15 Apr 2012 17:40:44 -0400 Subject: pdf import. for radial gradient, approximate an ExponentialFunction using an extra stop (Bug 919176) Fixed bugs: - https://launchpad.net/bugs/919176 (bzr r11256) --- src/extension/internal/pdfinput/svg-builder.cpp | 37 ++++++++++++------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 885bed3c9..eefd66e12 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -862,30 +862,29 @@ bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *sh } else if ( type == 3 ) { // Stitching StitchingFunction *stitchingFunc = static_cast(func); double *bounds = stitchingFunc->getBounds(); + double *encode = stitchingFunc->getEncode(); int num_funcs = stitchingFunc->getNumFuncs(); + // Add stops from all the stitched functions + GfxRGB prev_color, color; + svgGetShadingColorRGB(shading, bounds[0], &prev_color); + _addStopToGradient(gradient, bounds[0], &prev_color, 1.0); for ( int i = 0 ; i < num_funcs ; i++ ) { - GfxRGB color; - svgGetShadingColorRGB(shading, bounds[i], &color); - bool is_continuation = false; - if ( i > 0 ) { // Compare to previous stop - GfxRGB prev_color; - svgGetShadingColorRGB(shading, bounds[i-1], &prev_color); - if ( abs(color.r - prev_color.r) < INT_EPSILON && - abs(color.g - prev_color.g) < INT_EPSILON && - abs(color.b - prev_color.b) < INT_EPSILON ) { - is_continuation = true; - } - } + svgGetShadingColorRGB(shading, bounds[i + 1], &color); // Add stops - if ( !is_continuation ) { - _addStopToGradient(gradient, bounds[i], &color, 1.0); - } - if ( is_continuation || ( i == num_funcs - 1 ) ) { - GfxRGB next_color; - svgGetShadingColorRGB(shading, bounds[i+1], &next_color); - _addStopToGradient(gradient, bounds[i+1], &next_color, 1.0); + if (stitchingFunc->getFunc(i)->getType() == 2) { // process exponential fxn + double expE = (static_cast(stitchingFunc->getFunc(i)))->getE(); + if (expE > 1.0) { + expE = (bounds[i + 1] - bounds[i])/expE; // approximate exponential as a single straight line at x=1 + if (encode[2*i] == 0) { // normal sequence + _addStopToGradient(gradient, bounds[i + 1] - expE, &prev_color, 1.0); + } else { // reflected sequence + _addStopToGradient(gradient, bounds[i] + expE, &color, 1.0); + } + } } + _addStopToGradient(gradient, bounds[i + 1], &color, 1.0); + prev_color = color; } } else { // Unsupported function type return false; -- cgit v1.2.3 From e48a286477d5b8d1d0f9188262e8252d5f77380b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 17 Apr 2012 12:21:44 +0100 Subject: Work around for some missing glibmm headers in gtkmm (should be fixed in gtkmm 3.4) (bzr r11261) --- src/extension/param/string.cpp | 1 + src/extension/prefdialog.h | 1 + 2 files changed, 2 insertions(+) (limited to 'src/extension') diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp index f15d56f0d..cf2b0f5d5 100644 --- a/src/extension/param/string.cpp +++ b/src/extension/param/string.cpp @@ -10,6 +10,7 @@ # include "config.h" #endif +#include #include #include #include diff --git a/src/extension/prefdialog.h b/src/extension/prefdialog.h index ff857272a..943273623 100644 --- a/src/extension/prefdialog.h +++ b/src/extension/prefdialog.h @@ -10,6 +10,7 @@ #ifndef INKSCAPE_EXTENSION_DIALOG_H__ #define INKSCAPE_EXTENSION_DIALOG_H__ +#include #include #include -- cgit v1.2.3 From 2120067e60eabe8918f78f007f7f585ef477abe9 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 18 Apr 2012 14:30:50 +0900 Subject: Fix for 169888 : Patch for HIG style frames for PDF import dialogs (bzr r11263) --- src/extension/internal/pdf-input-cairo.cpp | 38 +++++---------------------- src/extension/internal/pdf-input-cairo.h | 9 +++---- src/extension/internal/pdfinput/pdf-input.cpp | 37 ++++---------------------- src/extension/internal/pdfinput/pdf-input.h | 9 +++---- 4 files changed, 17 insertions(+), 76 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index 36ef66713..b1cf13db1 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -32,6 +32,8 @@ #include #include "ui/widget/spinbutton.h" +#include "ui/widget/frame.h" + #include namespace Inkscape { @@ -99,9 +101,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc) hbox3 = Gtk::manage(new class Gtk::HBox(false, 4)); vbox2 = Gtk::manage(new class Gtk::VBox(false, 4)); - alignment3 = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1)); - _labelPageSettings = Gtk::manage(new class Gtk::Label(_("Page settings"))); - _pageSettingsFrame = Gtk::manage(new class Gtk::Frame()); + _pageSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame(_("Page settings"))); _labelPrecision = Gtk::manage(new class Gtk::Label(_("Precision of approximating gradient meshes:"))); _labelPrecisionWarning = Gtk::manage(new class Gtk::Label(_("Note: setting the precision too high may result in a large SVG file and slow performance."))); @@ -125,9 +125,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc) hbox5 = Gtk::manage(new class Gtk::HBox(false, 4)); _embedImagesCheck = Gtk::manage(new class Gtk::CheckButton(_("Embed images"))); vbox3 = Gtk::manage(new class Gtk::VBox(false, 4)); - alignment4 = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1)); - _labelImportSettings = Gtk::manage(new class Gtk::Label(_("Import settings"))); - _importSettingsFrame = Gtk::manage(new class Gtk::Frame()); + _importSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame(_("Import settings"))); vbox1 = Gtk::manage(new class Gtk::VBox(false, 4)); _previewArea = Gtk::manage(new class Gtk::DrawingArea()); hbox1 = Gtk::manage(new class Gtk::HBox(false, 4)); @@ -167,18 +165,8 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc) hbox3->pack_start(*_cropTypeCombo, Gtk::PACK_SHRINK, 0); vbox2->pack_start(*hbox2); vbox2->pack_start(*hbox3); - alignment3->add(*vbox2); - _labelPageSettings->set_alignment(0.5,0.5); - _labelPageSettings->set_padding(4,0); - _labelPageSettings->set_justify(Gtk::JUSTIFY_LEFT); - _labelPageSettings->set_line_wrap(false); - _labelPageSettings->set_use_markup(true); - _labelPageSettings->set_selectable(false); + _pageSettingsFrame->add(*vbox2); _pageSettingsFrame->set_border_width(4); - _pageSettingsFrame->set_shadow_type(Gtk::SHADOW_ETCHED_IN); - _pageSettingsFrame->set_label_align(0,0.5); - _pageSettingsFrame->add(*alignment3); - _pageSettingsFrame->set_label_widget(*_labelPageSettings); _labelPrecision->set_alignment(0,0.5); _labelPrecision->set_padding(4,0); _labelPrecision->set_justify(Gtk::JUSTIFY_LEFT); @@ -228,18 +216,8 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc) vbox3->pack_start(*hbox5, Gtk::PACK_SHRINK, 4); vbox3->pack_start(*_localFontsCheck, Gtk::PACK_SHRINK, 0); vbox3->pack_start(*_embedImagesCheck, Gtk::PACK_SHRINK, 0); - alignment4->add(*vbox3); - _labelImportSettings->set_alignment(0.5,0.5); - _labelImportSettings->set_padding(4,0); - _labelImportSettings->set_justify(Gtk::JUSTIFY_LEFT); - _labelImportSettings->set_line_wrap(false); - _labelImportSettings->set_use_markup(true); - _labelImportSettings->set_selectable(false); + _importSettingsFrame->add(*vbox3); _importSettingsFrame->set_border_width(4); - _importSettingsFrame->set_shadow_type(Gtk::SHADOW_ETCHED_IN); - _importSettingsFrame->set_label_align(0,0.5); - _importSettingsFrame->add(*alignment4); - _importSettingsFrame->set_label_widget(*_labelImportSettings); vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0); vbox1->pack_start(*_importSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0); hbox1->pack_start(*vbox1); @@ -266,8 +244,6 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc) _cropTypeCombo->show(); hbox3->show(); vbox2->show(); - alignment3->show(); - _labelPageSettings->show(); _pageSettingsFrame->show(); _labelPrecision->show(); _labelPrecisionWarning->show(); @@ -280,8 +256,6 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc) _localFontsCheck->show(); _embedImagesCheck->show(); vbox3->show(); - alignment4->show(); - _labelImportSettings->show(); _importSettingsFrame->show(); vbox1->show(); _previewArea->show(); diff --git a/src/extension/internal/pdf-input-cairo.h b/src/extension/internal/pdf-input-cairo.h index 7581cb0a5..cc3ed975e 100644 --- a/src/extension/internal/pdf-input-cairo.h +++ b/src/extension/internal/pdf-input-cairo.h @@ -42,6 +42,7 @@ namespace Inkscape { namespace UI { namespace Widget { class SpinButton; + class Frame; } } @@ -77,9 +78,7 @@ private: class Gtk::ComboBoxText * _cropTypeCombo; class Gtk::HBox * hbox3; class Gtk::VBox * vbox2; - class Gtk::Alignment * alignment3; - class Gtk::Label * _labelPageSettings; - class Gtk::Frame * _pageSettingsFrame; + class Inkscape::UI::Widget::Frame * _pageSettingsFrame; class Gtk::Label * _labelPrecision; class Gtk::Label * _labelPrecisionWarning; class Gtk::HScale * _fallbackPrecisionSlider; @@ -92,9 +91,7 @@ private: class Gtk::CheckButton * _localFontsCheck; class Gtk::CheckButton * _embedImagesCheck; class Gtk::VBox * vbox3; - class Gtk::Alignment * alignment4; - class Gtk::Label * _labelImportSettings; - class Gtk::Frame * _importSettingsFrame; + class Inkscape::UI::Widget::Frame * _importSettingsFrame; class Gtk::VBox * vbox1; class Gtk::DrawingArea * _previewArea; class Gtk::HBox * hbox1; diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index eff488c9d..35972c00e 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -49,6 +49,7 @@ #include "dialogs/dialog-events.h" #include #include "ui/widget/spinbutton.h" +#include "ui/widget/frame.h" #include #include @@ -116,9 +117,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) hbox3 = Gtk::manage(new class Gtk::HBox(false, 4)); vbox2 = Gtk::manage(new class Gtk::VBox(false, 4)); - alignment3 = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1)); - _labelPageSettings = Gtk::manage(new class Gtk::Label(_("Page settings"))); - _pageSettingsFrame = Gtk::manage(new class Gtk::Frame()); + _pageSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame(_("Page settings"))); _labelPrecision = Gtk::manage(new class Gtk::Label(_("Precision of approximating gradient meshes:"))); _labelPrecisionWarning = Gtk::manage(new class Gtk::Label(_("Note: setting the precision too high may result in a large SVG file and slow performance."))); @@ -142,9 +141,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) hbox5 = Gtk::manage(new class Gtk::HBox(false, 4)); _embedImagesCheck = Gtk::manage(new class Gtk::CheckButton(_("Embed images"))); vbox3 = Gtk::manage(new class Gtk::VBox(false, 4)); - alignment4 = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1)); - _labelImportSettings = Gtk::manage(new class Gtk::Label(_("Import settings"))); - _importSettingsFrame = Gtk::manage(new class Gtk::Frame()); + _importSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame(_("Import settings"))); vbox1 = Gtk::manage(new class Gtk::VBox(false, 4)); _previewArea = Gtk::manage(new class Gtk::DrawingArea()); hbox1 = Gtk::manage(new class Gtk::HBox(false, 4)); @@ -184,18 +181,8 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) hbox3->pack_start(*_cropTypeCombo, Gtk::PACK_SHRINK, 0); vbox2->pack_start(*hbox2); vbox2->pack_start(*hbox3); - alignment3->add(*vbox2); - _labelPageSettings->set_alignment(0.5,0.5); - _labelPageSettings->set_padding(4,0); - _labelPageSettings->set_justify(Gtk::JUSTIFY_LEFT); - _labelPageSettings->set_line_wrap(false); - _labelPageSettings->set_use_markup(true); - _labelPageSettings->set_selectable(false); + _pageSettingsFrame->add(*vbox2); _pageSettingsFrame->set_border_width(4); - _pageSettingsFrame->set_shadow_type(Gtk::SHADOW_ETCHED_IN); - _pageSettingsFrame->set_label_align(0,0.5); - _pageSettingsFrame->add(*alignment3); - _pageSettingsFrame->set_label_widget(*_labelPageSettings); _labelPrecision->set_alignment(0,0.5); _labelPrecision->set_padding(4,0); _labelPrecision->set_justify(Gtk::JUSTIFY_LEFT); @@ -245,18 +232,8 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) vbox3->pack_start(*hbox5, Gtk::PACK_SHRINK, 4); vbox3->pack_start(*_localFontsCheck, Gtk::PACK_SHRINK, 0); vbox3->pack_start(*_embedImagesCheck, Gtk::PACK_SHRINK, 0); - alignment4->add(*vbox3); - _labelImportSettings->set_alignment(0.5,0.5); - _labelImportSettings->set_padding(4,0); - _labelImportSettings->set_justify(Gtk::JUSTIFY_LEFT); - _labelImportSettings->set_line_wrap(false); - _labelImportSettings->set_use_markup(true); - _labelImportSettings->set_selectable(false); + _importSettingsFrame->add(*vbox3); _importSettingsFrame->set_border_width(4); - _importSettingsFrame->set_shadow_type(Gtk::SHADOW_ETCHED_IN); - _importSettingsFrame->set_label_align(0,0.5); - _importSettingsFrame->add(*alignment4); - _importSettingsFrame->set_label_widget(*_labelImportSettings); vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0); vbox1->pack_start(*_importSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0); hbox1->pack_start(*vbox1); @@ -283,8 +260,6 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _cropTypeCombo->show(); hbox3->show(); vbox2->show(); - alignment3->show(); - _labelPageSettings->show(); _pageSettingsFrame->show(); _labelPrecision->show(); _labelPrecisionWarning->show(); @@ -297,8 +272,6 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _localFontsCheck->show(); _embedImagesCheck->show(); vbox3->show(); - alignment4->show(); - _labelImportSettings->show(); _importSettingsFrame->show(); vbox1->show(); _previewArea->show(); diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h index 7282de322..8334fd2f3 100644 --- a/src/extension/internal/pdfinput/pdf-input.h +++ b/src/extension/internal/pdfinput/pdf-input.h @@ -49,6 +49,7 @@ namespace Inkscape { namespace UI { namespace Widget { class SpinButton; + class Frame; } } @@ -87,9 +88,7 @@ private: class Gtk::ComboBoxText * _cropTypeCombo; class Gtk::HBox * hbox3; class Gtk::VBox * vbox2; - class Gtk::Alignment * alignment3; - class Gtk::Label * _labelPageSettings; - class Gtk::Frame * _pageSettingsFrame; + class Inkscape::UI::Widget::Frame * _pageSettingsFrame; class Gtk::Label * _labelPrecision; class Gtk::Label * _labelPrecisionWarning; class Gtk::HScale * _fallbackPrecisionSlider; @@ -102,9 +101,7 @@ private: class Gtk::CheckButton * _localFontsCheck; class Gtk::CheckButton * _embedImagesCheck; class Gtk::VBox * vbox3; - class Gtk::Alignment * alignment4; - class Gtk::Label * _labelImportSettings; - class Gtk::Frame * _importSettingsFrame; + class Inkscape::UI::Widget::Frame * _importSettingsFrame; class Gtk::VBox * vbox1; class Gtk::DrawingArea * _previewArea; class Gtk::HBox * hbox1; -- cgit v1.2.3 From 36e3c5550b49949729f2f23ab1796afdc53d6487 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 18 Apr 2012 00:02:24 -0700 Subject: Warning cleanup (bzr r11265) --- src/extension/internal/gdkpixbuf-input.cpp | 6 +++--- src/extension/internal/latex-pstricks-out.cpp | 26 +++++++++++-------------- src/extension/internal/latex-pstricks.cpp | 25 ++++++++++-------------- src/extension/internal/pdf-input-cairo.cpp | 4 +--- src/extension/internal/pdfinput/pdf-input.cpp | 9 +++------ src/extension/internal/pdfinput/svg-builder.cpp | 12 ++++++------ src/extension/internal/svg.cpp | 8 +++----- src/extension/internal/svgz.cpp | 12 +++++------- 8 files changed, 42 insertions(+), 60 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index 4519befcf..80be2ecc2 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -54,7 +54,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) static std::set lossy = create_lossy_set(); if (pb) { /* We are readable */ - bool is_lossy; + // TODO revisit: bool is_lossy; Glib::ustring mime_type, ext; Glib::ustring u = uri; std::size_t dotpos = u.rfind('.'); @@ -64,10 +64,10 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) // HACK: replace with something better based on GIO if (!ext.empty() && lossy.find(ext) != lossy.end()) { - is_lossy = true; + // TODO revisit: is_lossy = true; mime_type = "image/jpeg"; } else { - is_lossy = false; + // TODO revisit: is_lossy = false; mime_type = "image/png"; } diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp index decc42d94..3ce2c5531 100644 --- a/src/extension/internal/latex-pstricks-out.cpp +++ b/src/extension/internal/latex-pstricks-out.cpp @@ -49,8 +49,6 @@ bool LatexOutput::check(Inkscape::Extension::Extension * /*module*/) void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, gchar const *filename) { SPPrintContext context; - unsigned int ret = 0; - doc->ensureUpToDate(); Inkscape::Extension::Print *mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX); @@ -58,28 +56,26 @@ void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, gchar * oldoutput = g_strdup(oldconst); mod->set_param_string("destination", filename); - /* Start */ + // Start context.module = mod; - /* fixme: This has to go into module constructor somehow */ + // fixme: This has to go into module constructor somehow mod->base = doc->getRoot(); Inkscape::Drawing drawing; - mod->dkey = SPItem::display_key_new (1); - mod->root = (mod->base)->invoke_show (drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->dkey = SPItem::display_key_new(1); + mod->root = (mod->base)->invoke_show(drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY); drawing.setRoot(mod->root); - /* Print document */ - ret = mod->begin (doc); - (mod->base)->invoke_print (&context); - ret = mod->finish (); - /* Release things */ - (mod->base)->invoke_hide (mod->dkey); + // Print document + mod->begin(doc); + (mod->base)->invoke_print(&context); + mod->finish(); + // Release things + (mod->base)->invoke_hide(mod->dkey); mod->base = NULL; mod->root = NULL; // should have been deleted by invoke_hide - /* end */ + // end mod->set_param_string("destination", oldoutput); g_free(oldoutput); - - return; } #include "clear-n_.h" diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index bdf95f941..c1eddf539 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -326,22 +326,17 @@ PrintLatex::textToPath(Inkscape::Extension::Print * ext) #include "clear-n_.h" -void -PrintLatex::init (void) +void PrintLatex::init(void) { - Inkscape::Extension::Extension * ext; - - /* SVG in */ - ext = Inkscape::Extension::build_from_mem( - "\n" - "" N_("LaTeX Print") "\n" - "" SP_MODULE_KEY_PRINT_LATEX "\n" - "\n" - "true\n" - "\n" - "", new PrintLatex()); - - return; + /* SVG in */ + Inkscape::Extension::build_from_mem( + "\n" + "" N_("LaTeX Print") "\n" + "" SP_MODULE_KEY_PRINT_LATEX "\n" + "\n" + "true\n" + "\n" + "", new PrintLatex()); } } /* namespace Internal */ diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index b1cf13db1..0a89c6661 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -631,9 +631,7 @@ static cairo_status_t void PdfInputCairo::init(void) { - Inkscape::Extension::Extension * ext; - - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "PDF Input\n" "org.inkscape.input.cairo-pdf\n" diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 35972c00e..8802ce2ba 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -735,12 +735,9 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { #include "../clear-n_.h" -void -PdfInput::init(void) { - Inkscape::Extension::Extension * ext; - +void PdfInput::init(void) { /* PDF in */ - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "" N_("PDF Input") "\n" "org.inkscape.input.pdf\n" @@ -753,7 +750,7 @@ PdfInput::init(void) { "", new PdfInput()); /* AI in */ - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "" N_("AI Input") "\n" "org.inkscape.input.ai\n" diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index eefd66e12..6606e1846 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -910,10 +910,10 @@ void SvgBuilder::updateStyle(GfxState *state) { that a space in sp may be removed or replaced by some other tokens specified in the code. (Bug LP #179589) */ -static int MatchingChars(std::string s1, std::string sp) +static size_t MatchingChars(std::string s1, std::string sp) { - unsigned int is = 0; - unsigned int ip = 0; + size_t is = 0; + size_t ip = 0; while(is < s1.length() && ip < sp.length()) { if (s1[is] == sp[ip]) { @@ -927,7 +927,7 @@ static int MatchingChars(std::string s1, std::string sp) break; } } - return(ip); + return ip; } /* @@ -944,12 +944,12 @@ std::string SvgBuilder::_BestMatchingFont(std::string PDFname) std::string fontname = _availableFontNames[i]; // At least the first word of the font name should match. - guint minMatch = fontname.find(" "); + size_t minMatch = fontname.find(" "); if (minMatch == std::string::npos) { minMatch = fontname.length(); } - int Match = MatchingChars(PDFname, fontname); + size_t Match = MatchingChars(PDFname, fontname); if (Match >= minMatch) { double relMatch = (float)Match / (fontname.length() + PDFname.length()); if (relMatch > bestMatch) { diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index d054e4427..7d0b8299c 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -83,10 +83,8 @@ void pruneExtendedAttributes( Inkscape::XML::Node *repr ) void Svg::init(void) { - Inkscape::Extension::Extension * ext; - /* SVG in */ - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "" N_("SVG Input") "\n" "" SP_MODULE_KEY_INPUT_SVG "\n" @@ -100,7 +98,7 @@ Svg::init(void) "", new Svg()); /* SVG out Inkscape */ - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "" N_("SVG Output Inkscape") "\n" "" SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE "\n" @@ -114,7 +112,7 @@ Svg::init(void) "", new Svg()); /* SVG out */ - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "" N_("SVG Output") "\n" "" SP_MODULE_KEY_OUTPUT_SVG "\n" diff --git a/src/extension/internal/svgz.cpp b/src/extension/internal/svgz.cpp index fceafd3ee..be9440980 100644 --- a/src/extension/internal/svgz.cpp +++ b/src/extension/internal/svgz.cpp @@ -40,10 +40,8 @@ namespace Internal { void Svgz::init(void) { - Inkscape::Extension::Extension * ext; - /* SVGZ in */ - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "" N_("SVGZ Input") "\n" "" SP_MODULE_KEY_INPUT_SVGZ "\n" @@ -57,8 +55,8 @@ Svgz::init(void) "\n" "", new Svgz()); - /* SVGZ out Inkscape */ - ext = Inkscape::Extension::build_from_mem( + /* SVGZ out Inkscape */ + Inkscape::Extension::build_from_mem( "\n" "" N_("SVGZ Output") "\n" "" SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE "\n" @@ -71,8 +69,8 @@ Svgz::init(void) "\n" "", new Svgz()); - /* SVGZ out */ - ext = Inkscape::Extension::build_from_mem( + /* SVGZ out */ + Inkscape::Extension::build_from_mem( "\n" "" N_("SVGZ Output") "\n" "" SP_MODULE_KEY_OUTPUT_SVGZ "\n" -- cgit v1.2.3 From 319be62b08d35174e72ac2b3bd7a53a99ee69102 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 20 Apr 2012 21:11:42 +0200 Subject: Memory leak fix. (Bug #986271) Code supplied by David Mathog. (bzr r11268) --- src/extension/internal/emf-win32-print.cpp | 21 ++++++++++++++++----- src/extension/internal/emf-win32-print.h | 8 +++++++- 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index d5e44e702..a0ef960ac 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -543,7 +543,7 @@ bool PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom /** * For all Subpaths in the - */ + */ for (Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) { using Geom::X; @@ -553,7 +553,7 @@ bool PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom p0[X] = (p0[X] * IN_PER_PX * dwDPI); p0[Y] = (p0[Y] * IN_PER_PX * dwDPI); - + LONG const x0 = (LONG) round(p0[X]); LONG const y0 = (LONG) round(rc.bottom-p0[Y]); @@ -715,7 +715,7 @@ unsigned int PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geo /** * For all Subpaths in the - */ + */ for (Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) { using Geom::X; @@ -725,7 +725,7 @@ unsigned int PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geo p0[X] = (p0[X] * IN_PER_PX * dwDPI); p0[Y] = (p0[Y] * IN_PER_PX * dwDPI); - + LONG const x0 = (LONG) round(p0[X]); LONG const y0 = (LONG) round(rc.bottom-p0[Y]); @@ -818,7 +818,7 @@ unsigned int PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char cons HFONT hfont = NULL; Geom::Affine tf = m_tr_stack.top(); - double rot = 1800.0*std::atan2(tf[1], tf[0])/M_PI; // 0.1 degree rotation + double rot = 1800.0*std::atan2(tf[1], tf[0])/M_PI; // 0.1 degree rotation #ifdef USE_PANGO_WIN32 /* @@ -920,6 +920,17 @@ void PrintEmfWin32::init (void) return; } +unsigned int PrintEmfWin32::image(Inkscape::Extension::Print * /* module */, /** not used */ + unsigned char *px, /** array of pixel values, Gdk::Pixbuf bitmap format */ + unsigned int /*w*/, /** width of bitmap */ + unsigned int /*h*/, /** height of bitmap */ + unsigned int /*rs*/, /** row stride (normally w*4) */ + Geom::Affine const & /*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */ + SPStyle const * /*style*/) /** provides indirect link to image object */ +{ + free(px); + return 0; +} } /* namespace Internal */ } /* namespace Extension */ diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h index 71ce5d6d0..e7bd08477 100644 --- a/src/extension/internal/emf-win32-print.h +++ b/src/extension/internal/emf-win32-print.h @@ -50,6 +50,13 @@ class PrintEmfWin32 : public Inkscape::Extension::Implementation::Implementation unsigned int print_pathv (Geom::PathVector const &pathv, const Geom::Affine &transform); bool print_simple_shape (Geom::PathVector const &pathv, const Geom::Affine &transform); + unsigned int image(Inkscape::Extension::Print * /* module */, /** not used */ + unsigned char *px, /** array of pixel values, Gdk::Pixbuf bitmap format */ + unsigned int w, /** width of bitmap */ + unsigned int h, /** height of bitmap */ + unsigned int rs, /** row stride (normally w*4) */ + Geom::Affine const &tf_ignore, /** WRONG affine transform, use the one from m_tr_stack */ + SPStyle const *style); /** provides indirect link to image object */ public: PrintEmfWin32 (void); @@ -80,7 +87,6 @@ public: bool textToPath (Inkscape::Extension::Print * ext); static void init (void); - protected: int create_brush(SPStyle const *style); -- cgit v1.2.3 From 59aec1670d3228328122666c340cc104a5c537b1 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 20 Apr 2012 21:24:58 +0200 Subject: cppcheck (bzr r11269) --- src/extension/internal/emf-win32-print.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index a0ef960ac..ef76c2c14 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -904,10 +904,8 @@ unsigned int PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char cons void PrintEmfWin32::init (void) { - Inkscape::Extension::Extension * ext; - /* EMF print */ - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "Enhanced Metafile Print\n" "org.inkscape.print.emf.win32\n" -- cgit v1.2.3 From b319c181b21302ca3eb75148f4cd4c13832bf9d1 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 20 Apr 2012 21:39:53 +0200 Subject: cppcheck / fix issue in Dutch translation (bzr r11270) --- src/extension/internal/emf-win32-inout.cpp | 8 +++----- src/extension/internal/wpg-input.cpp | 7 ++----- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index e321f67f1..bb7f22a70 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -2457,10 +2457,8 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) void EmfWin32::init (void) { - Inkscape::Extension::Extension * ext; - /* EMF in */ - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "" N_("EMF Input") "\n" "org.inkscape.input.emf.win32\n" @@ -2474,7 +2472,7 @@ EmfWin32::init (void) "", new EmfWin32()); /* WMF in */ - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "" N_("WMF Input") "\n" "org.inkscape.input.wmf.win32\n" @@ -2488,7 +2486,7 @@ EmfWin32::init (void) "", new EmfWin32()); /* EMF out */ - ext = Inkscape::Extension::build_from_mem( + Inkscape::Extension::build_from_mem( "\n" "" N_("EMF Output") "\n" "org.inkscape.output.emf.win32\n" diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index 8862c1d4a..cb1677547 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -115,11 +115,8 @@ SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u #include "clear-n_.h" -void -WpgInput::init(void) { - Inkscape::Extension::Extension * ext; - - ext = Inkscape::Extension::build_from_mem( +void WpgInput::init(void) { + Inkscape::Extension::build_from_mem( "\n" "" N_("WPG Input") "\n" "org.inkscape.input.wpg\n" -- cgit v1.2.3 From a8497a5cbf71936d60b16767e0ae22bd28ef0c8f Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 21 Apr 2012 13:16:47 +0200 Subject: dropping some ghost code / probably fixing a memleak as well (bzr r11273) --- src/extension/internal/svg.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index 7d0b8299c..9b1098afd 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -230,8 +230,6 @@ Svg::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena g_return_if_fail(doc != NULL); g_return_if_fail(filename != NULL); - gchar *save_path = g_path_get_dirname(filename); - bool const exportExtensions = ( !mod->get_id() || !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE) || !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE)); @@ -257,8 +255,6 @@ Svg::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena Inkscape::GC::release(rdoc); } - g_free(save_path); - return; } -- cgit v1.2.3 From 641c2388cab5d32517ea25df011d8568c8e6f227 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 22 Apr 2012 17:18:06 -0400 Subject: pdf import. modify criterion for applying scaling to gradientTransform (Bug 985182) Fixed bugs: - https://launchpad.net/bugs/985182 (bzr r11283) --- src/extension/internal/pdfinput/svg-builder.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 6606e1846..2f36e19a4 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -57,6 +57,7 @@ namespace Internal { #define TRACE(_args) IFTRACE(g_print _args) static double ttm[6] = {1, 0, 0, 1, 0, 0}; // temporary transform matrix +static bool ttm_is_set = false; // flag to forbid setting ttm /** * \struct SvgTransparencyGroup @@ -214,7 +215,11 @@ Inkscape::XML::Node *SvgBuilder::pushGroup() { setAsLayer(_docname); } } - + if (_container->parent()->attribute("inkscape:groupmode") != NULL) { + ttm[0] = ttm[3] = 1.0; // clear ttm if parent is a layer + ttm[1] = ttm[2] = ttm[4] = ttm[5] = 0.0; + ttm_is_set = false; + } return _container; } @@ -567,17 +572,14 @@ bool SvgBuilder::getTransform(double *transform) { void SvgBuilder::setTransform(double c0, double c1, double c2, double c3, double c4, double c5) { // do not remember the group which is a layer - if (_container->attribute("inkscape:groupmode") != NULL) { - ttm[0] = ttm[3] = 1.0; - ttm[1] = ttm[2] = ttm[4] = ttm[5] = 0.0; - } - else { + if ((_container->attribute("inkscape:groupmode") == NULL) && !ttm_is_set) { ttm[0] = c0; ttm[1] = c1; ttm[2] = c2; ttm[3] = c3; ttm[4] = c4; ttm[5] = c5; + ttm_is_set = true; } // Avoid transforming a group with an already set clip-path -- cgit v1.2.3