summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/pdfinput/pdf-input.cpp
diff options
context:
space:
mode:
authorAdib Taraben <theadib@gmail.com>2007-12-16 20:07:44 +0000
committertheadib <theadib@users.sourceforge.net>2007-12-16 20:07:44 +0000
commiteedf76a6bd4aa9c3577db32601c37810d9a278a9 (patch)
tree9f1208b3e09d01d8bcae06ccc11397c5202c8959 /src/extension/internal/pdfinput/pdf-input.cpp
parentfix default grid unit scaling, fix crash for unknown unit. (diff)
downloadinkscape-eedf76a6bd4aa9c3577db32601c37810d9a278a9.tar.gz
inkscape-eedf76a6bd4aa9c3577db32601c37810d9a278a9.zip
[BUG #169122] PDF import doesn't work when file name has accents, partially fixed
(bzr r4241)
Diffstat (limited to 'src/extension/internal/pdfinput/pdf-input.cpp')
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp49
1 files changed, 41 insertions, 8 deletions
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 2d6a8ea4b..9b671a7c3 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -43,7 +43,7 @@
namespace Inkscape {
namespace Extension {
namespace Internal {
-
+
/**
* \brief The PDF import dialog
* FIXME: Probably this should be placed into src/ui/dialog
@@ -59,7 +59,7 @@ static Glib::ustring crop_setting_choices[] = {
PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar *uri)
{
-
+ _poppler_doc = NULL;
_pdf_doc = doc;
cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
@@ -285,7 +285,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar *uri)
_render_thumb = true;
// Create PopplerDocument
gchar *doc_uri = g_filename_to_uri(uri, NULL, NULL);
- if (doc_uri) {
+ if (doc_uri) {
_poppler_doc = poppler_document_new_from_file(doc_uri, NULL, NULL);
g_free(doc_uri);
}
@@ -444,7 +444,8 @@ static void copy_cairo_surface_to_pixbuf (cairo_surface_t *surface,
src++;
}
}
-}
+}
+
#endif
/**
@@ -575,15 +576,47 @@ PdfInput::open(::Inkscape::Extension::Input * mod, const gchar * uri) {
// Initialize the globalParams variable for poppler
if (!globalParams) {
globalParams = new GlobalParams();
- }
- GooString *filename_goo = new GooString(uri);
- PDFDoc *pdf_doc = new PDFDoc(filename_goo, NULL, NULL, NULL); // TODO: Could ask for password
+ }
+ // poppler does not use glib g_open. So on win32 we must use unicode call. code was copied from glib gstdio.c
+#ifndef WIN32
+ GooString *filename_goo = new GooString(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);
+
+ if (wfilename == NULL) {
+ return NULL;
+ }
+
+ PDFDoc *pdf_doc = new PDFDoc(wfilename, wcslen(wfilename), NULL, NULL, NULL); // TODO: Could ask for password
+ g_free (wfilename);
+#endif
+
if (!pdf_doc->isOk()) {
int error = pdf_doc->getErrorCode();
delete pdf_doc;
if (error == errEncrypted) {
g_message("Document is encrypted.");
- } else {
+ } else if (error == errOpenFile) {
+ g_message("couldn't open the PDF file.");
+ } else if (error == errBadCatalog) {
+ g_message("couldn't read the page catalog.");
+ } else if (error == errDamaged) {
+ g_message("PDF file was damaged and couldn't be repaired.");
+ } else if (error == errHighlightFile) {
+ g_message("nonexistent or invalid highlight file.");
+ } else if (error == errBadPrinter) {
+ g_message("invalid printer.");
+ } else if (error == errPrinting) {
+ g_message("Error during printing.");
+ } else if (error == errPermission) {
+ g_message("PDF file does not allow that operation.");
+ } else if (error == errBadPageNum) {
+ g_message("invalid page number.");
+ } else if (error == errFileIO) {
+ g_message("file IO error.");
+ } else {
g_message("Failed to load document from data (error %d)", error);
}