diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2013-01-01 18:24:47 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2013-01-01 18:24:47 +0000 |
| commit | 0b3b386881da011ac7ee60dd20bd610fd9670677 (patch) | |
| tree | 59d08dfb788ebbe333fa21140fcd8203faadc356 /src/extension | |
| parent | merge from trunk (r11952) (diff) | |
| parent | clip path visual bbox refresh, second try (Bug 1005085) (diff) | |
| download | inkscape-0b3b386881da011ac7ee60dd20bd610fd9670677.tar.gz inkscape-0b3b386881da011ac7ee60dd20bd610fd9670677.zip | |
merge from trunk (r12005)
(bzr r11668.1.47)
Diffstat (limited to 'src/extension')
| -rw-r--r-- | src/extension/internal/image-resolution.cpp | 379 | ||||
| -rw-r--r-- | src/extension/internal/pdf-input-cairo.cpp | 8 | ||||
| -rw-r--r-- | src/extension/internal/pdfinput/pdf-input.cpp | 6 | ||||
| -rw-r--r-- | src/extension/internal/vsd-input.cpp | 45 | ||||
| -rw-r--r-- | src/extension/param/notebook.cpp | 18 | ||||
| -rw-r--r-- | src/extension/prefdialog.cpp | 5 |
6 files changed, 266 insertions, 195 deletions
diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index 53fcc0fbf..a17a2bb30 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -27,27 +27,30 @@ namespace Extension { namespace Internal { ImageResolution::ImageResolution(char const *fn) { - ok_ = false; - - readpng(fn); - if (!ok_) - readexif(fn); - if (!ok_) - readexiv(fn); - if (!ok_) - readjfif(fn); + ok_ = false; + + readpng(fn); + if (!ok_) { + readexiv(fn); + } + if (!ok_) { + readjfif(fn); + } + if (!ok_) { + readexif(fn); + } } bool ImageResolution::ok() const { - return ok_; + return ok_; } double ImageResolution::x() const { - return x_; + return x_; } double ImageResolution::y() const { - return y_; + return y_; } @@ -57,60 +60,62 @@ double ImageResolution::y() const { #include <png.h> static bool haspngheader(FILE *fp) { - unsigned char header[8]; - if (fread(header, 1, 8, fp)!=8) - return false; + unsigned char header[8]; + if ( fread(header, 1, 8, fp) != 8 ) { + return false; + } - fseek(fp, 0, SEEK_SET); - - if (png_sig_cmp(header, 0, 8)) - return false; + fseek(fp, 0, SEEK_SET); + + if (png_sig_cmp(header, 0, 8)) { + return false; + } - return true; + return true; } // Implementation using libpng void ImageResolution::readpng(char const *fn) { - FILE *fp = fopen(fn, "rb"); - if (!fp) - return; + FILE *fp = fopen(fn, "rb"); + if (!fp) + return; - if (!haspngheader(fp)) { - fclose(fp); - return; - } + if (!haspngheader(fp)) { + fclose(fp); + return; + } - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); - if (!png_ptr) - return; - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!png_ptr) { - png_destroy_read_struct(&png_ptr, 0, 0); - return; - } - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - fclose(fp); - return; - } + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); + if (!png_ptr) + return; + + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + png_destroy_read_struct(&png_ptr, 0, 0); + return; + } + + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_read_struct(&png_ptr, &info_ptr, 0); + fclose(fp); + return; + } - png_init_io(png_ptr, fp); - png_read_info(png_ptr, info_ptr); + png_init_io(png_ptr, fp); + png_read_info(png_ptr, info_ptr); - png_uint_32 res_x, res_y; - int unit_type; - png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type); + png_uint_32 res_x, res_y; + int unit_type; + png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type); - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - fclose(fp); + png_destroy_read_struct(&png_ptr, &info_ptr, 0); + fclose(fp); - if (unit_type == PNG_RESOLUTION_METER) { - ok_ = true; - x_ = res_x * 2.54/100; - y_ = res_y * 2.54/100; - } + if (unit_type == PNG_RESOLUTION_METER) { + ok_ = true; + x_ = res_x * 2.54 / 100; + y_ = res_y * 2.54 / 100; + } } #else @@ -126,63 +131,71 @@ void ImageResolution::readpng(char const *) { #include <libexif/exif-data.h> static double exifDouble(ExifEntry *entry, ExifByteOrder byte_order) { - switch (entry->format) { - case EXIF_FORMAT_BYTE: - return double(entry->data[0]); - case EXIF_FORMAT_SHORT: - return double(exif_get_short(entry->data, byte_order)); - case EXIF_FORMAT_LONG: - return double(exif_get_long(entry->data, byte_order)); - case EXIF_FORMAT_RATIONAL: { - ExifRational r = exif_get_rational(entry->data, byte_order); - return double(r.numerator)/double(r.denominator); - } - case EXIF_FORMAT_SBYTE: - return double(*(signed char *)entry->data); - case EXIF_FORMAT_SSHORT: - return double(exif_get_sshort(entry->data, byte_order)); - case EXIF_FORMAT_SLONG: - return double(exif_get_slong(entry->data, byte_order)); - case EXIF_FORMAT_SRATIONAL: { - ExifSRational r = exif_get_srational(entry->data, byte_order); - return double(r.numerator)/double(r.denominator); - } - case EXIF_FORMAT_FLOAT: - return double(((float *)entry->data)[0]); - case EXIF_FORMAT_DOUBLE: - return ((double *)entry->data)[0]; - default: - return nan(0); - } + switch (entry->format) { + case EXIF_FORMAT_BYTE: { + return double(entry->data[0]); + } + case EXIF_FORMAT_SHORT: { + return double(exif_get_short(entry->data, byte_order)); + } + case EXIF_FORMAT_LONG: { + return double(exif_get_long(entry->data, byte_order)); + } + case EXIF_FORMAT_RATIONAL: { + ExifRational r = exif_get_rational(entry->data, byte_order); + return double(r.numerator) / double(r.denominator); + } + case EXIF_FORMAT_SBYTE: { + return double(*(signed char *)entry->data); + } + case EXIF_FORMAT_SSHORT: { + return double(exif_get_sshort(entry->data, byte_order)); + } + case EXIF_FORMAT_SLONG: { + return double(exif_get_slong(entry->data, byte_order)); + } + case EXIF_FORMAT_SRATIONAL: { + ExifSRational r = exif_get_srational(entry->data, byte_order); + return double(r.numerator) / double(r.denominator); + } + case EXIF_FORMAT_FLOAT: { + return double(((float *)entry->data)[0]); + } + case EXIF_FORMAT_DOUBLE: { + return ((double *)entry->data)[0]; + } + default: { + return nan(0); + } + } } // Implementation using libexif void ImageResolution::readexif(char const *fn) { - ExifData *ed; - ed = exif_data_new_from_file(fn); - if (!ed) - return; - ExifByteOrder byte_order = exif_data_get_byte_order(ed); - - ExifEntry *xres = exif_content_get_entry(ed->ifd[EXIF_IFD_0], - EXIF_TAG_X_RESOLUTION); - ExifEntry *yres = exif_content_get_entry(ed->ifd[EXIF_IFD_0], - EXIF_TAG_Y_RESOLUTION); - ExifEntry *unit = exif_content_get_entry(ed->ifd[EXIF_IFD_0], - EXIF_TAG_RESOLUTION_UNIT); - if (xres && yres) { - x_ = exifDouble(xres, byte_order); - y_ = exifDouble(yres, byte_order); - if (unit) { - double u = exifDouble(unit, byte_order); - if (u==3) { - x_ *= 2.54; - y_ *= 2.54; - } + ExifData *ed; + ed = exif_data_new_from_file(fn); + if (!ed) + return; + + ExifByteOrder byte_order = exif_data_get_byte_order(ed); + + ExifEntry *xres = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_X_RESOLUTION); + ExifEntry *yres = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_Y_RESOLUTION); + ExifEntry *unit = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_RESOLUTION_UNIT); + + if ( xres && yres ) { + x_ = exifDouble(xres, byte_order); + y_ = exifDouble(yres, byte_order); + if (unit) { + double u = exifDouble(unit, byte_order); + if ( u == 3 ) { + x_ *= 2.54; + y_ *= 2.54; + } + } + ok_ = true; } - ok_ = true; - } - exif_data_free(ed); + exif_data_free(ed); } #else @@ -196,43 +209,43 @@ void ImageResolution::readexif(char const *) { #if IR_TRY_EXIV void ImageResolution::readexiv(char const *fn) { - Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fn); - if (!image.get()) - return; - - image->readMetadata(); - Exiv2::ExifData &exifData = image->exifData(); - if (exifData.empty()) - return; - - Exiv2::ExifData::const_iterator end = exifData.end(); - bool havex = false; - bool havey = false; - bool haveunit = false; - int unit; - for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) { - if (ok_) - break; - if (i->tag()==0x011a) { - // X Resolution - x_ = i->toFloat(); - havex = true; - } else if (i->tag()==0x011b) { - // Y Resolution - y_ = i->toFloat(); - havey = true; - } else if (i->tag()==0x0128) { - unit = i->toLong(); + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fn); + if (!image.get()) + return; + + image->readMetadata(); + Exiv2::ExifData &exifData = image->exifData(); + if (exifData.empty()) + return; + + Exiv2::ExifData::const_iterator end = exifData.end(); + bool havex = false; + bool havey = false; + bool haveunit = false; + int unit; + for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) { + if (ok_) + break; + if ( i->tag() == 0x011a ) { + // X Resolution + x_ = i->toFloat(); + havex = true; + } else if ( i->tag() == 0x011b ) { + // Y Resolution + y_ = i->toFloat(); + havey = true; + } else if ( i->tag() == 0x0128 ) { + unit = i->toLong(); + } + ok_ = havex && havey && haveunit; } - ok_ = havex && havey && haveunit; - } - if (haveunit) { - if (unit==3) { - x_ *= 2.54; - y_ *= 2.54; + if (haveunit) { + if ( unit == 3 ) { + x_ *= 2.54; + y_ *= 2.54; + } } - } - ok_ = havex && havey; + ok_ = havex && havey; } #else @@ -249,7 +262,7 @@ void ImageResolution::readexiv(char const *) { #include <setjmp.h> static void irjfif_error_exit(j_common_ptr cinfo) { - longjmp(*(jmp_buf*)cinfo->client_data, 1); + longjmp(*(jmp_buf*)cinfo->client_data, 1); } static void irjfif_emit_message(j_common_ptr, int) { @@ -265,44 +278,52 @@ static void irjfif_reset(j_common_ptr) { } void ImageResolution::readjfif(char const *fn) { - FILE *ifd = fopen(fn, "rb"); - if (!ifd) - return; - - struct jpeg_decompress_struct cinfo; - jmp_buf jbuf; - struct jpeg_error_mgr jerr; - bool constr = false; + FILE *ifd = fopen(fn, "rb"); + if (!ifd) { + return; + } - if (setjmp(jbuf)) { + struct jpeg_decompress_struct cinfo; + jmp_buf jbuf; + struct jpeg_error_mgr jerr; + bool constr = false; + + if (setjmp(jbuf)) { + fclose(ifd); + if (constr) { + jpeg_destroy_decompress(&cinfo); + } + return; + } + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + jerr.error_exit = &irjfif_error_exit; + jerr.emit_message = &irjfif_emit_message; + jerr.output_message = &irjfif_output_message; + jerr.format_message = &irjfif_format_message; + jerr.reset_error_mgr = &irjfif_reset; + cinfo.client_data = (void*)&jbuf; + + constr = true; + + jpeg_stdio_src(&cinfo, ifd); + jpeg_read_header(&cinfo, TRUE); + + if (cinfo.saw_JFIF_marker) { // JFIF APP0 marker was seen + if ( cinfo.density_unit == 1 ) { // dots/inch + x_ = cinfo.X_density; + y_ = cinfo.Y_density; + ok_ = true; + } else if ( cinfo.density_unit == 2 ) { // dots/cm + x_ = cinfo.X_density * 2.54; + y_ = cinfo.Y_density * 2.54; + ok_ = true; + } + } + constr = false; + jpeg_destroy_decompress(&cinfo); fclose(ifd); - if (constr) - jpeg_destroy_decompress(&cinfo); - return; - } - - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - jerr.error_exit = &irjfif_error_exit; - jerr.emit_message = &irjfif_emit_message; - jerr.output_message = &irjfif_output_message; - jerr.format_message = &irjfif_format_message; - jerr.reset_error_mgr = &irjfif_reset; - cinfo.client_data = (void*)&jbuf; - constr = true; - - jpeg_stdio_src(&cinfo, ifd); - jpeg_read_header(&cinfo, TRUE); - - if (cinfo.density_unit==1) { - x_ = cinfo.X_density; - y_ = cinfo.Y_density; - ok_ = true; - } - - constr = false; - jpeg_destroy_decompress(&cinfo); - fclose(ifd); } #else @@ -312,7 +333,7 @@ void ImageResolution::readjfif(char const *) { } #endif - + } } } diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index 03b7c0a90..0a9dd8399 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -229,7 +229,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc) this->get_vbox()->pack_start(*hbox1); this->set_title(_("PDF Import Settings")); this->set_modal(true); - sp_transientize((GtkWidget *)this->gobj()); //Make transient + sp_transientize(GTK_WIDGET(this->gobj())); //Make transient this->property_window_position().set_value(Gtk::WIN_POS_NONE); this->set_resizable(true); this->property_destroy_with_parent().set_value(false); @@ -416,7 +416,7 @@ static void copy_cairo_surface_to_pixbuf (cairo_surface_t *surface, cairo_height = gdk_pixbuf_get_height (pixbuf); for (y = 0; y < cairo_height; y++) { - src = (unsigned int *) (cairo_data + y * cairo_rowstride); + src = reinterpret_cast<unsigned int *>(cairo_data + y * cairo_rowstride); dst = pixbuf_data + y * pixbuf_rowstride; for (x = 0; x < cairo_width; x++) { @@ -622,8 +622,8 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) { static cairo_status_t _write_ustring_cb(void *closure, const unsigned char *data, unsigned int length) { - Glib::ustring* stream = (Glib::ustring*)closure; - stream->append((const char*)data, length); + Glib::ustring* stream = static_cast<Glib::ustring*>(closure); + stream->append(reinterpret_cast<const char*>(data), length); return CAIRO_STATUS_SUCCESS; } diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 688e3f612..90d53c6b0 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -245,7 +245,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) this->get_vbox()->pack_start(*hbox1); this->set_title(_("PDF Import Settings")); this->set_modal(true); - sp_transientize((GtkWidget *)this->gobj()); //Make transient + sp_transientize(GTK_WIDGET(this->gobj())); //Make transient this->property_window_position().set_value(Gtk::WIN_POS_NONE); this->set_resizable(true); this->property_destroy_with_parent().set_value(false); @@ -446,7 +446,7 @@ static void copy_cairo_surface_to_pixbuf (cairo_surface_t *surface, cairo_height = gdk_pixbuf_get_height (pixbuf); for (y = 0; y < cairo_height; y++) { - src = (unsigned int *) (cairo_data + y * cairo_rowstride); + src = reinterpret_cast<unsigned int *>(cairo_data + y * cairo_rowstride); dst = pixbuf_data + y * pixbuf_rowstride; for (x = 0; x < cairo_width; x++) { @@ -603,7 +603,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { PDFDoc *pdf_doc = new PDFDoc(filename_goo, NULL, NULL, NULL); // TODO: Could ask for password //delete filename_goo; #else - wchar_t *wfilename = (wchar_t*)g_utf8_to_utf16 (uri, -1, NULL, NULL, NULL); + wchar_t *wfilename = reinterpret_cast<wchar_t*>(g_utf8_to_utf16 (uri, -1, NULL, NULL, NULL)); if (wfilename == NULL) { return NULL; diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index 6d71ce72a..187318417 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -142,7 +142,7 @@ VsdImportDialog::VsdImportDialog(const std::vector<WPXString> &vec) this->get_vbox()->pack_start(*vbox2); this->set_title(_("Page Selector")); this->set_modal(true); - sp_transientize((GtkWidget *)this->gobj()); //Make transient + sp_transientize(GTK_WIDGET(this->gobj())); //Make transient this->property_window_position().set_value(Gtk::WIN_POS_NONE); this->set_resizable(true); this->property_destroy_with_parent().set_value(false); @@ -261,6 +261,7 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u void VsdInput::init(void) { + /* VSD */ Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("VSD Input") "</name>\n" @@ -272,6 +273,48 @@ void VsdInput::init(void) "<filetypetooltip>" N_("File format used by Microsoft Visio 6 and later") "</filetypetooltip>\n" "</input>\n" "</inkscape-extension>", new VsdInput()); + + /* VDX */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("VDX Input") "</name>\n" + "<id>org.inkscape.input.vdx</id>\n" + "<input>\n" + "<extension>.vdx</extension>\n" + "<mimetype>application/vnd.visio</mimetype>\n" + "<filetypename>" N_("Microsoft Visio XML Diagram (*.vdx)") "</filetypename>\n" + "<filetypetooltip>" N_("File format used by Microsoft Visio 2010 and later") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new VsdInput()); + + /* VSDM */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("VSDM Input") "</name>\n" + "<id>org.inkscape.input.vsdm</id>\n" + "<input>\n" + "<extension>.vsdm</extension>\n" + "<mimetype>application/vnd.visio</mimetype>\n" + "<filetypename>" N_("Microsoft Visio 2013 drawing (*.vsdm)") "</filetypename>\n" + "<filetypetooltip>" N_("File format used by Microsoft Visio 2013 and later") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new VsdInput()); + + /* VSDX */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("VSDX Input") "</name>\n" + "<id>org.inkscape.input.vsdx</id>\n" + "<input>\n" + "<extension>.vsdx</extension>\n" + "<mimetype>application/vnd.visio</mimetype>\n" + "<filetypename>" N_("Microsoft Visio 2013 drawing (*.vsdx)") "</filetypename>\n" + "<filetypetooltip>" N_("File format used by Microsoft Visio 2013 and later") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new VsdInput()); + + return; + } // init } } } /* namespace Inkscape, Extension, Implementation */ diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp index b4d4cbd16..85cb5d04c 100644 --- a/src/extension/param/notebook.cpp +++ b/src/extension/param/notebook.cpp @@ -206,14 +206,16 @@ Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Nod for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) { Parameter * param = reinterpret_cast<Parameter *>(list->data); Gtk::Widget * widg = param->get_widget(doc, node, changeSignal); - gchar const * tip = param->get_tooltip(); -// printf("Tip: '%s'\n", tip); - vbox->pack_start(*widg, false, false, 2); - if (tip) { - widg->set_tooltip_text(tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); + if (widg) { + gchar const * tip = param->get_tooltip(); + // printf("Tip: '%s'\n", tip); + vbox->pack_start(*widg, false, false, 2); + if (tip) { + widg->set_tooltip_text(tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } } } diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp index 2d2604c7f..649dc398a 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog.cpp @@ -88,7 +88,12 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co _param_preview = Parameter::make(doc->root(), _effect); } +#if WITH_GTKMM_3_0 + Gtk::Separator * sep = Gtk::manage(new Gtk::Separator()); +#else Gtk::HSeparator * sep = Gtk::manage(new Gtk::HSeparator()); +#endif + sep->show(); this->get_vbox()->pack_start(*sep, true, true, 4); |
