summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/pdfinput/pdf-input.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/extension/internal/pdfinput/pdf-input.cpp')
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp96
1 files changed, 49 insertions, 47 deletions
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 9b671a7c3..537837efa 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -1,6 +1,6 @@
/** \file
* Native PDF import using libpoppler.
- *
+ *
* Authors:
* miklos erdelyi
*
@@ -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
@@ -57,9 +57,11 @@ static Glib::ustring crop_setting_choices[] = {
Glib::ustring(_("art box"))
};
-PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar *uri)
+PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
{
+#ifdef HAVE_POPPLER_CAIRO
_poppler_doc = NULL;
+#endif // HAVE_POPPLER_CAIRO
_pdf_doc = doc;
cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
@@ -100,7 +102,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar *uri)
_pageSettingsFrame = Gtk::manage(new class Gtk::Frame());
_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.")));
-
+
_fallbackPrecisionSlider_adj = Gtk::manage(new class Gtk::Adjustment(2, 1, 256, 1, 10, 10));
_fallbackPrecisionSlider = Gtk::manage(new class Gtk::HScale(*_fallbackPrecisionSlider_adj));
_fallbackPrecisionSlider->set_value(2.0);
@@ -112,7 +114,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar *uri)
_textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText());
_textHandlingCombo->append_text(_("Import text as text"));
_textHandlingCombo->set_active_text(_("Import text as text"));
-
+
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));
@@ -285,7 +287,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,14 +446,14 @@ static void copy_cairo_surface_to_pixbuf (cairo_surface_t *surface,
src++;
}
}
-}
-
+}
+
#endif
/**
* \brief Updates the preview area with the previously rendered thumbnail
*/
-bool PdfImportDialog::_onExposePreview(GdkEventExpose *event) {
+bool PdfImportDialog::_onExposePreview(GdkEventExpose */*event*/) {
// Check if we have a thumbnail at all
if (!_thumb_data) {
@@ -571,55 +573,55 @@ void PdfImportDialog::_setPreviewPage(int page) {
* Parses the selected page of the given PDF document using PdfParser.
*/
SPDocument *
-PdfInput::open(::Inkscape::Extension::Input * mod, const gchar * uri) {
+PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
// Initialize the globalParams variable for poppler
if (!globalParams) {
globalParams = new GlobalParams();
- }
- // poppler does not use glib g_open. So on win32 we must use unicode call. code was copied from glib gstdio.c
+ }
+ // 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
+ 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
-
+#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 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 {
+ } 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);
}
-
+
return NULL;
}
PdfImportDialog *dlg = new PdfImportDialog(pdf_doc, uri);
@@ -693,14 +695,14 @@ PdfInput::open(::Inkscape::Extension::Input * mod, const gchar * uri) {
for ( int i = 1 ; i <= pdfNumShadingTypes ; i++ ) {
pdf_parser->setApproximationPrecision(i, color_delta, 6);
}
-
+
// Parse the document structure
Object obj;
page->getContents(&obj);
if (!obj.isNull()) {
pdf_parser->parse(&obj);
}
-
+
// Cleanup
obj.free();
delete pdf_parser;