From ce1fb126f2115c9038badd098c2900e0adbe1038 Mon Sep 17 00:00:00 2001 From: joncruz Date: Mon, 17 Dec 2007 06:33:24 +0000 Subject: [PATCH] non-poppler build fix Warning and CRLF cleanup --- src/extension/internal/pdfinput/pdf-input.cpp | 96 ++++++++++--------- src/widgets/layer-selector.cpp | 34 +++---- 2 files changed, 66 insertions(+), 64 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(_("Note: 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; diff --git a/src/widgets/layer-selector.cpp b/src/widgets/layer-selector.cpp index b6898b2fe..10b497cac 100644 --- a/src/widgets/layer-selector.cpp +++ b/src/widgets/layer-selector.cpp @@ -76,18 +76,18 @@ public: } private: - Gtk::Widget *_a; + Gtk::Widget *_a; Gtk::Widget *_b; bool _state; }; } -/** LayerSelector constructor. Creates lock and hide buttons, +/** LayerSelector constructor. Creates lock and hide buttons, * initalizes the layer dropdown selector with a label renderer, * and hooks up signal for setting the desktop layer when the * selector is changed. - */ + */ LayerSelector::LayerSelector(SPDesktop *desktop) : _desktop(NULL), _layer(NULL) { @@ -150,7 +150,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop) setDesktop(desktop); } -/** Destructor - disconnects signal handler +/** Destructor - disconnects signal handler */ LayerSelector::~LayerSelector() { setDesktop(NULL); @@ -159,7 +159,7 @@ LayerSelector::~LayerSelector() { namespace { -/** Helper function - detaches desktop from selector +/** Helper function - detaches desktop from selector */ bool detach(LayerSelector *selector) { selector->setDesktop(NULL); @@ -225,7 +225,7 @@ private: } -/** Selects the given layer in the dropdown selector. +/** Selects the given layer in the dropdown selector. */ void LayerSelector::_selectLayer(SPObject *layer) { using Inkscape::Util::List; @@ -361,9 +361,9 @@ struct Callbacks { sigc::slot update_list; }; -void attribute_changed(Inkscape::XML::Node *repr, gchar const *name, - gchar const *old_value, gchar const *new_value, - bool is_interactive, void *data) +void attribute_changed(Inkscape::XML::Node */*repr*/, gchar const *name, + gchar const */*old_value*/, gchar const */*new_value*/, + bool /*is_interactive*/, void *data) { if ( !std::strcmp(name, "inkscape:groupmode") ) { reinterpret_cast(data)->update_list(); @@ -372,22 +372,22 @@ void attribute_changed(Inkscape::XML::Node *repr, gchar const *name, } } -void node_added(Inkscape::XML::Node *parent, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data) { +void node_added(Inkscape::XML::Node */*parent*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, void *data) { gchar const *mode=child->attribute("inkscape:groupmode"); if ( mode && !std::strcmp(mode, "layer") ) { reinterpret_cast(data)->update_list(); } } -void node_removed(Inkscape::XML::Node *parent, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data) { +void node_removed(Inkscape::XML::Node */*parent*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, void *data) { gchar const *mode=child->attribute("inkscape:groupmode"); if ( mode && !std::strcmp(mode, "layer") ) { reinterpret_cast(data)->update_list(); } } -void node_reordered(Inkscape::XML::Node *parent, Inkscape::XML::Node *child, - Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref, +void node_reordered(Inkscape::XML::Node */*parent*/, Inkscape::XML::Node *child, + Inkscape::XML::Node */*old_ref*/, Inkscape::XML::Node */*new_ref*/, void *data) { gchar const *mode=child->attribute("inkscape:groupmode"); @@ -520,7 +520,7 @@ void LayerSelector::_destroyEntry(Gtk::ListStore::iterator const &row) { delete callbacks; } -/** Formats the label for a given layer row +/** Formats the label for a given layer row */ void LayerSelector::_prepareLabelRenderer( Gtk::TreeModel::const_iterator const &row @@ -564,7 +564,7 @@ void LayerSelector::_prepareLabelRenderer( label = _("(root)"); } - gchar *text = g_markup_printf_escaped(format, label); + gchar *text = g_markup_printf_escaped(format, label); _label_renderer.property_markup() = text; g_free(text); g_free(format); @@ -581,7 +581,7 @@ void LayerSelector::_prepareLabelRenderer( void LayerSelector::_lockLayer(bool lock) { if ( _layer && SP_IS_ITEM(_layer) ) { SP_ITEM(_layer)->setLocked(lock); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_NONE, + sp_document_done(sp_desktop_document(_desktop), SP_VERB_NONE, lock? _("Lock layer") : _("Unlock layer")); } } @@ -589,7 +589,7 @@ void LayerSelector::_lockLayer(bool lock) { void LayerSelector::_hideLayer(bool hide) { if ( _layer && SP_IS_ITEM(_layer) ) { SP_ITEM(_layer)->setHidden(hide); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_NONE, + sp_document_done(sp_desktop_document(_desktop), SP_VERB_NONE, hide? _("Hide layer") : _("Unhide layer")); } } -- 2.30.2