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/internal/pdfinput') 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 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/pdfinput/pdf-input.cpp | 37 ++++----------------------- src/extension/internal/pdfinput/pdf-input.h | 9 +++---- 2 files changed, 8 insertions(+), 38 deletions(-) (limited to 'src/extension/internal/pdfinput') 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/pdfinput/pdf-input.cpp | 9 +++------ src/extension/internal/pdfinput/svg-builder.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'src/extension/internal/pdfinput') 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) { -- 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/internal/pdfinput') 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