summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/pdfinput
diff options
context:
space:
mode:
authorDenis Declara <declara91@gmail.com>2012-04-26 11:14:34 +0000
committerDenis Declara <declara91@gmail.com>2012-04-26 11:14:34 +0000
commit95a8ad7bfec98f7cede15c4e8856ce547aaf4aa4 (patch)
tree506de5a8437cb39917a66d74b68d78692d10a993 /src/extension/internal/pdfinput
parentAdded first support for elliptical arrangements (diff)
parentpowerstroke: cautious fix. (diff)
downloadinkscape-95a8ad7bfec98f7cede15c4e8856ce547aaf4aa4.tar.gz
inkscape-95a8ad7bfec98f7cede15c4e8856ce547aaf4aa4.zip
Trunk merge
(bzr r11073.1.20)
Diffstat (limited to 'src/extension/internal/pdfinput')
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp46
-rw-r--r--src/extension/internal/pdfinput/pdf-input.h9
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp63
3 files changed, 43 insertions, 75 deletions
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index eff488c9d..8802ce2ba 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 <gtk/gtk.h>
#include "ui/widget/spinbutton.h"
+#include "ui/widget/frame.h"
#include <glibmm/i18n.h>
#include <gdkmm/general.h>
@@ -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(_("<b>Note</b>: 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();
@@ -762,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(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("PDF Input") "</name>\n"
"<id>org.inkscape.input.pdf</id>\n"
@@ -780,7 +750,7 @@ PdfInput::init(void) {
"</inkscape-extension>", new PdfInput());
/* AI in */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("AI Input") "</name>\n"
"<id>org.inkscape.input.ai</id>\n"
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;
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index 885bed3c9..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
@@ -862,30 +864,29 @@ bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *sh
} else if ( type == 3 ) { // Stitching
StitchingFunction *stitchingFunc = static_cast<StitchingFunction*>(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<ExponentialFunction*>(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;
@@ -911,10 +912,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]) {
@@ -928,7 +929,7 @@ static int MatchingChars(std::string s1, std::string sp)
break;
}
}
- return(ip);
+ return ip;
}
/*
@@ -945,12 +946,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) {