diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-07-24 23:26:11 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-07-24 23:26:11 +0000 |
| commit | 7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5 (patch) | |
| tree | 48cae26bf789b11d79f72efc16a6676f960eaaa6 /src/extension | |
| parent | update to trunk (diff) | |
| parent | 3D box tool: the shift key must not prevent snapping of the vanishing point. ... (diff) | |
| download | inkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.tar.gz inkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.zip | |
update to trunk
(bzr r12588.1.45)
Diffstat (limited to 'src/extension')
31 files changed, 394 insertions, 319 deletions
diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 47292fd97..21e652563 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -36,7 +36,6 @@ set(extension_SRC internal/cairo-render-context.cpp internal/cairo-renderer.cpp internal/cairo-renderer-pdf-out.cpp - internal/cdr-input.cpp internal/emf-inout.cpp internal/emf-print.cpp internal/gdkpixbuf-input.cpp @@ -54,7 +53,6 @@ set(extension_SRC internal/svg.cpp internal/svgz.cpp internal/text_reassemble.c - internal/vsd-input.cpp internal/wmf-inout.cpp internal/wmf-print.cpp @@ -103,7 +101,6 @@ set(extension_SRC internal/cairo-render-context.h internal/cairo-renderer-pdf-out.h internal/cairo-renderer.h - internal/cdr-input.h internal/clear-n_.h internal/emf-inout.h internal/emf-print.h @@ -139,7 +136,6 @@ set(extension_SRC internal/svg.h internal/svgz.h internal/text_reassemble.h - internal/vsd-input.h internal/wmf-inout.h internal/wmf-print.h ) @@ -149,6 +145,20 @@ if(WIN32) ) endif() +if(WITH_LIBCDR) + list(APPEND extension_SRC + internal/cdr-input.cpp + internal/cdr-input.h + ) +endif() + +if(WITH_LIBVISIO) + list(APPEND extension_SRC + internal/vsd-input.cpp + internal/vsd-input.h + ) +endif() + if(WITH_LIBWPG) list(APPEND extension_SRC internal/wpg-input.cpp @@ -156,7 +166,7 @@ if(WITH_LIBWPG) ) endif() -if(ImageMagick_FOUND) +if(WITH_IMAGE_MAGICK) list(APPEND extension_SRC internal/bitmap/adaptiveThreshold.cpp internal/bitmap/adaptiveThreshold.h diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 4fde6885f..d64bdbc5c 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -186,10 +186,10 @@ selection_get_center_y (Inkscape::Selection *sel){ * know we never bothered to implement it seperatly. Although * they might see the selection box flicker if used in a loop. */ -const GSList * +std::vector<SPObject*> selection_swap(Inkscape::Selection *sel, gchar *name, GError **error) { - const GSList *oldsel = g_slist_copy((GSList *)sel->list()); + std::vector<SPObject*> oldsel = sel->list(); sel->set(get_object_by_name(sel->layers()->getDocument(), name, error)); return oldsel; @@ -199,9 +199,11 @@ selection_swap(Inkscape::Selection *sel, gchar *name, GError **error) * See selection_swap, above */ void -selection_restore(Inkscape::Selection *sel, const GSList * oldsel) +selection_restore(Inkscape::Selection *sel, std::vector<SPObject*> oldsel) { - sel->setList(oldsel); + // ... setList used to work here + sel->clear(); + sel->add(oldsel.begin(), oldsel.end()); } /* @@ -708,8 +710,8 @@ gboolean document_interface_move (DocumentInterface *doc_interface, gchar *name, gdouble x, gdouble y, GError **error) { - const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), name, error); - if (!oldsel) + std::vector<SPObject*> oldsel = selection_swap(doc_interface->target.getSelection(), name, error); + if (oldsel.empty()) return FALSE; sp_selection_move (doc_interface->target.getSelection(), x, 0 - y); selection_restore(doc_interface->target.getSelection(), oldsel); @@ -720,8 +722,8 @@ gboolean document_interface_move_to (DocumentInterface *doc_interface, gchar *name, gdouble x, gdouble y, GError **error) { - const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), name, error); - if (!oldsel) + std::vector<SPObject*> oldsel = selection_swap(doc_interface->target.getSelection(), name, error); + if (oldsel.empty()) return FALSE; Inkscape::Selection * sel = doc_interface->target.getSelection(); sp_selection_move (doc_interface->target.getSelection(), x - selection_get_center_x(sel), @@ -734,8 +736,8 @@ gboolean document_interface_object_to_path (DocumentInterface *doc_interface, char *shape, GError **error) { - const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), shape, error); - if (!oldsel) + std::vector<SPObject*> oldsel = selection_swap(doc_interface->target.getSelection(), shape, error); + if (oldsel.empty()) return FALSE; dbus_call_verb (doc_interface, SP_VERB_OBJECT_TO_CURVE, error); selection_restore(doc_interface->target.getSelection(), oldsel); @@ -849,8 +851,8 @@ gboolean document_interface_move_to_layer (DocumentInterface *doc_interface, gchar *shape, gchar *layerstr, GError **error) { - const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), shape, error); - if (!oldsel) + std::vector<SPObject*> oldsel = selection_swap(doc_interface->target.getSelection(), shape, error); + if (oldsel.empty()) return FALSE; document_interface_selection_move_to_layer(doc_interface, layerstr, error); @@ -1085,15 +1087,15 @@ void document_interface_update(DocumentInterface *doc_interface, GError ** error gboolean document_interface_selection_get(DocumentInterface *doc_interface, char ***out, GError ** /*error*/) { Inkscape::Selection * sel = doc_interface->target.getSelection(); - GSList const *oldsel = sel->list(); + std::vector<SPObject*> oldsel = sel->list(); - int size = g_slist_length((GSList *) oldsel); + int size = oldsel.size(); *out = g_new0 (char *, size + 1); int i = 0; - for (GSList const *iter = oldsel; iter != NULL; iter = iter->next) { - (*out)[i] = g_strdup(SP_OBJECT(iter->data)->getRepr()->attribute("id")); + for (std::vector<SPObject*>::iterator iter = oldsel.begin(), e = oldsel.end(); iter != e; ++iter) { + (*out)[i] = g_strdup((*iter)->getId()); i++; } (*out)[i] = NULL; @@ -1426,23 +1428,21 @@ gboolean dbus_send_ping (SPDesktop* desk, SPItem *item) gboolean document_interface_get_children (DocumentInterface *doc_interface, char *name, char ***out, GError **error) { - SPItem* parent=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error); + SPItem* parent=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error); + std::vector<SPObject*> children = parent->childList(false); - GSList const *children = parent->childList(false); - - int size = g_slist_length((GSList *) children); + int size = children.size(); *out = g_new0 (char *, size + 1); int i = 0; - for (GSList const *iter = children; iter != NULL; iter = iter->next) { - (*out)[i] = g_strdup(SP_OBJECT(iter->data)->getRepr()->attribute("id")); + for (std::vector<SPObject*>::iterator iter = children.begin(), e = children.end(); iter != e; ++iter) { + (*out)[i] = g_strdup((*iter)->getId()); i++; } (*out)[i] = NULL; return TRUE; - } diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index e7cd43d9d..29c2b5537 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -60,14 +60,12 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp sp_namedview_document_from_window(desktop); if (desktop != NULL) { - Inkscape::Util::GSListConstIterator<SPItem *> selected = - desktop->getSelection()->itemList(); - while ( selected != NULL ) { + std::vector<SPItem*> selected = desktop->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); x++){ Glib::ustring selected_id; - selected_id = (*selected)->getId(); + selected_id = (*x)->getId(); _selected.insert(_selected.end(), selected_id); //std::cout << "Selected: " << selected_id << std::endl; - ++selected; } } diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 52f63499a..b0ff3e91c 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -47,12 +47,10 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I SPDocument * current_document = view->doc(); - using Inkscape::Util::GSListConstIterator; - // FIXME very unsafe cast - GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node const* first_select = NULL; - if (selected != NULL) { - const SPItem * item = *selected; + if (!selected.empty()) { + const SPItem * item = selected[0]; first_select = item->getRepr(); } diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index fb323cd78..f6f933aaf 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -15,14 +15,7 @@ #include <vector> #include <sigc++/signal.h> #include <glibmm/value.h> - -namespace Geom { - class Affine; - class OptRect; - class Path; - typedef std::vector<Path> PathVector; - class Point; -} +#include <2geom/forward.h> namespace Gtk { class Widget; diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 52c360fcd..e07a3963c 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -689,14 +689,13 @@ void Script::effect(Inkscape::Extension::Effect *module, return; } - Inkscape::Util::GSListConstIterator<SPItem *> selected = + std::vector<SPItem*> selected = desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer - while ( selected != NULL ) { + for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); x++){ Glib::ustring selected_id; selected_id += "--id="; - selected_id += (*selected)->getId(); + selected_id += (*x)->getId(); params.insert(params.begin(), selected_id); - ++selected; } file_listener fileout; @@ -813,6 +812,12 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr } } + if(!oldroot_namedview) + { + g_warning("Error on copy_doc: No namedview on destination document."); + return; + } + // Unparent (delete) for (unsigned int i = 0; i < delete_list.size(); i++) { sp_repr_unparent(delete_list[i]); @@ -824,12 +829,10 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr child = child->next()) { if (!strcmp("sodipodi:namedview", child->name())) { newroot_namedview = child; - if (oldroot_namedview != NULL) { - for (Inkscape::XML::Node * newroot_namedview_child = child->firstChild(); - newroot_namedview_child != NULL; - newroot_namedview_child = newroot_namedview_child->next()) { - oldroot_namedview->appendChild(newroot_namedview_child->duplicate(oldroot->document())); - } + for (Inkscape::XML::Node * newroot_namedview_child = child->firstChild(); + newroot_namedview_child != NULL; + newroot_namedview_child = newroot_namedview_child->next()) { + oldroot_namedview->appendChild(newroot_namedview_child->duplicate(oldroot->document())); } } else { oldroot->appendChild(child->duplicate(oldroot->document())); diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index 7c91bf1ef..bc0dd8e33 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -66,8 +66,8 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems(NULL) { SPDesktop *desktop = (SPDesktop*)view; - const GSList *selectedItemList = desktop->selection->itemList(); - int selectCount = g_slist_length((GSList *)selectedItemList); + const std::vector<SPItem*> selectedItemList = desktop->selection->itemList(); + int selectCount = selectedItemList.size(); // Init the data-holders _nodes = new Inkscape::XML::Node*[selectCount]; @@ -79,9 +79,8 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems = new SPItem*[selectCount]; // Loop through selected items - for (; selectedItemList != NULL; selectedItemList = g_slist_next(selectedItemList)) - { - SPItem *item = SP_ITEM(selectedItemList->data); + for (std::vector<SPItem*>::const_iterator i = selectedItemList.begin(); i != selectedItemList.end(); i++) { + SPItem *item = *i; Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr()); if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) { @@ -237,13 +236,10 @@ ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::Vie { SPDocument * current_document = view->doc(); - using Inkscape::Util::GSListConstIterator; - - // FIXME very unsafe cast - GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; - if (selected != NULL) { - first_select = (*selected)->getRepr(); + if (!selected.empty()) { + first_select = (selected.front())->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 3ce537d9f..9f19f8b3b 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -63,13 +63,11 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); - using Inkscape::Util::GSListConstIterator; // TODO need to properly refcount the items, at least - std::list<SPItem *> items; - items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL); + std::vector<SPItem*> items(selection->itemList()); selection->clear(); - for(std::list<SPItem *>::iterator item = items.begin(); + for(std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); ++item) { SPItem * spitem = *item; diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 2d6619e1e..c3e416184 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1008,17 +1008,16 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver ps2user = Geom::identity(); pcs2dev = Geom::identity(); - double x = pattern_x(pat); - double y = pattern_y(pat); - double width = pattern_width(pat); - double height = pattern_height(pat); + double x = pat->x(); + double y = pat->y(); + double width = pat->width(); + double height = pat->height(); double bbox_width_scaler; double bbox_height_scaler; TRACE(("%f x %f pattern\n", width, height)); - if (pbox && pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { - //Geom::Affine bbox2user (pbox->x1 - pbox->x0, 0.0, 0.0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); + if (pbox && pat->patternUnits() == SPPattern::UNITS_OBJECTBOUNDINGBOX) { bbox_width_scaler = pbox->width(); bbox_height_scaler = pbox->height(); ps2user[4] = x * bbox_width_scaler + pbox->left(); @@ -1031,13 +1030,13 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver } // apply pattern transformation - Geom::Affine pattern_transform(pattern_patternTransform(pat)); + Geom::Affine pattern_transform(pat->getTransform()); ps2user *= pattern_transform; Geom::Point ori (ps2user[4], ps2user[5]); // create pattern contents coordinate system if (pat->viewBox_set) { - Geom::Rect view_box = *pattern_viewBox(pat); + Geom::Rect view_box = *pat->viewbox(); double x, y, w, h; x = 0; @@ -1050,7 +1049,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver pcs2dev[3] = h / view_box.height(); pcs2dev[4] = x - view_box.left() * pcs2dev[0]; pcs2dev[5] = y - view_box.top() * pcs2dev[3]; - } else if (pbox && pattern_patternContentUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { + } else if (pbox && pat->patternContentUnits() == SPPattern::UNITS_OBJECTBOUNDINGBOX) { pcs2dev[0] = pbox->width(); pcs2dev[3] = pbox->height(); } @@ -1393,6 +1392,7 @@ CairoRenderContext::_setStrokeStyle(SPStyle const *style, Geom::OptRect const &p dashes[i] = style->stroke_dasharray.values[i]; } cairo_set_dash(_cr, dashes, ndashes, style->stroke_dashoffset.value); + free(dashes); } else { cairo_set_dash(_cr, NULL, 0, 0.0); // disable dashing } diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 7fbdc4296..5a5553e97 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -294,14 +294,12 @@ static void sp_group_render(SPGroup *group, CairoRenderContext *ctx) CairoRenderer *renderer = ctx->getRenderer(); TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value))); - GSList *l = g_slist_reverse(group->childList(false)); - while (l) { - SPObject *o = reinterpret_cast<SPObject *>(l->data); - SPItem *item = dynamic_cast<SPItem *>(o); + std::vector<SPObject*> l(group->childList(false)); + for(std::vector<SPObject*>::const_iterator x = l.begin(); x!= l.end(); x++){ + SPItem *item = dynamic_cast<SPItem*>(*x); if (item) { renderer->renderItem(ctx, item); } - l = g_slist_remove (l, o); } } diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index ed3ae158a..5b8aae655 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -388,8 +388,8 @@ int PrintEmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) } else if (SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style))) { // must be paint-server SPPaintServer *paintserver = style->fill.value.href->getObject(); SPPattern *pat = SP_PATTERN(paintserver); - double dwidth = pattern_width(pat); - double dheight = pattern_height(pat); + double dwidth = pat->width(); + double dheight = pat->height(); width = dwidth; height = dheight; brush_classify(pat, 0, &pixbuf, &hatchType, &hatchColor, &bkColor); @@ -573,8 +573,8 @@ int PrintEmf::create_pen(SPStyle const *style, const Geom::Affine &transform) if (SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style))) { // must be paint-server SPPaintServer *paintserver = style->stroke.value.href->getObject(); SPPattern *pat = SP_PATTERN(paintserver); - double dwidth = pattern_width(pat); - double dheight = pattern_height(pat); + double dwidth = pat->width(); + double dheight = pat->height(); width = dwidth; height = dheight; brush_classify(pat, 0, &pixbuf, &hatchType, &hatchColor, &bkColor); @@ -860,7 +860,7 @@ Geom::Path PrintEmf::pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, /* Get the ends of the LAST line segment. Find minimum rotation to align rectangle with X,Y axes. (Very degenerate if it is rotated 45 degrees.) */ *angle = 10.0; /* must be > than the actual angle in radians. */ - for(Geom::Path::const_iterator cit = pR.begin(); cit != pR.end_open(); ++cit){ + for(Geom::Path::iterator cit = pR.begin(); cit != pR.end_open(); ++cit){ P1_trail = cit->initialPoint(); P1 = cit->finalPoint(); v1 = unit_vector(P1 - P1_trail); @@ -874,7 +874,7 @@ Geom::Path PrintEmf::pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, double convert = 36000.0/ (2.0 * M_PI); *angle = round(*angle * convert)/convert; - for(Geom::Path::const_iterator cit = pR.begin(); cit != pR.end_open();++cit) { + for(Geom::Path::iterator cit = pR.begin(); cit != pR.end_open();++cit) { P1_lead = cit->finalPoint(); v1 = unit_vector(P1 - P1_trail); v2 = unit_vector(P1_lead - P1 ); @@ -924,7 +924,7 @@ int PrintEmf::vector_rect_alignment(double angle, Geom::Point vtest){ */ Geom::Point PrintEmf::get_pathrect_corner(Geom::Path pathRect, double angle, int corner){ Geom::Point center(0,0); - for(Geom::Path::const_iterator cit = pathRect.begin(); cit != pathRect.end_open(); ++cit) { + for(Geom::Path::iterator cit = pathRect.begin(); cit != pathRect.end_open(); ++cit) { center += cit->initialPoint()/4.0; } @@ -952,7 +952,7 @@ Geom::Point PrintEmf::get_pathrect_corner(Geom::Path pathRect, double angle, int Geom::Point v1 = Geom::Point(1,0) * Geom::Rotate(-angle); // unit horizontal side (sign change because Y increases DOWN) Geom::Point v2 = Geom::Point(0,1) * Geom::Rotate(-angle); // unit vertical side (sign change because Y increases DOWN) Geom::Point P1; - for(Geom::Path::const_iterator cit = pathRect.begin(); cit != pathRect.end_open(); ++cit) { + for(Geom::Path::iterator cit = pathRect.begin(); cit != pathRect.end_open(); ++cit) { P1 = cit->initialPoint(); if ( ( LR == (dot(P1 - center,v1) > 0 ? 0 : 1) ) @@ -1494,11 +1494,11 @@ bool PrintEmf::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff int curves = 0; char *rec = NULL; - for (Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) { + for (Geom::PathVector::iterator pit = pv.begin(); pit != pv.end(); ++pit) { moves++; nodes++; - for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { + for (Geom::Path::iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { nodes++; if (is_straight_curve(*cit)) { @@ -1519,7 +1519,7 @@ bool PrintEmf::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff /** * For all Subpaths in the <path> */ - for (Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) { + for (Geom::PathVector::iterator pit = pv.begin(); pit != pv.end(); ++pit) { using Geom::X; using Geom::Y; @@ -1538,7 +1538,7 @@ bool PrintEmf::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff /** * For all segments in the subpath */ - for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { + for (Geom::Path::iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { if (is_straight_curve(*cit)) { //Geom::Point p0 = cit->initialPoint(); Geom::Point p1 = cit->finalPoint(); @@ -1557,7 +1557,7 @@ bool PrintEmf::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff lpPoints[i].y = y1; i = i + 1; } else if (Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*cit)) { - std::vector<Geom::Point> points = cubic->points(); + std::vector<Geom::Point> points = cubic->controlPoints(); //Geom::Point p0 = points[0]; Geom::Point p1 = points[1]; Geom::Point p2 = points[2]; @@ -1846,7 +1846,7 @@ unsigned int PrintEmf::draw_pathv_to_EMF(Geom::PathVector const &pathv, const Ge g_error("Fatal programming error in PrintEmf::print_pathv at U_EMRLINETO_set"); } } else if (Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*cit)) { - std::vector<Geom::Point> points = cubic->points(); + std::vector<Geom::Point> points = cubic->controlPoints(); //Geom::Point p0 = points[0]; Geom::Point p1 = points[1]; Geom::Point p2 = points[2]; diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index c3c26bf8b..b9c76615c 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -258,7 +258,7 @@ public: "<param name=\"type\" gui-text=\"" N_("Blindness type:") "\" type=\"enum\">\n" "<_item value=\"0.618 0.32 0.062 0 0 0.163 0.775 0.062 0 0 0.163 0.32 0.516 0 0 0 0 0 1 0 \">" N_("Rod monochromacy (atypical achromatopsia)") "</_item>\n" "<_item value=\"0.299 0.587 0.114 0 0 0.299 0.587 0.114 0 0 0.299 0.587 0.114 0 0 0 0 0 1 0 \">" N_("Cone monochromacy (typical achromatopsia)") "</_item>\n" - "<_item value=\"0.8 0.2 0 0 0 0.2583 0.74167 0 0 0 0 0.14167 0.85833 0 0 0 0 0 1 0 \">" N_("Geen weak (deuteranomaly)") "</_item>\n" + "<_item value=\"0.8 0.2 0 0 0 0.2583 0.74167 0 0 0 0 0.14167 0.85833 0 0 0 0 0 1 0 \">" N_("Green weak (deuteranomaly)") "</_item>\n" "<_item value=\"0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0 \">" N_("Green blind (deuteranopia)") "</_item>\n" "<_item value=\"0.8166 0.1833 0 0 0 0.333 0.666 0 0 0 0 0.125 0.875 0 0 0 0 0 1 0 \">" N_("Red weak (protanomaly)") "</_item>\n" "<_item value=\"0.566 0.43333 0 0 0 0.55833 0.4416 0 0 0 0 0.24167 0.75833 0 0 0 0 0 1 0 \">" N_("Red blind (protanopia)") "</_item>\n" diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index a2c565699..65162af22 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -125,15 +125,13 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie //printf("Calling filter effect\n"); Inkscape::Selection * selection = ((SPDesktop *)document)->selection; - using Inkscape::Util::GSListConstIterator; // TODO need to properly refcount the items, at least - std::list<SPItem *> items; - items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL); + std::vector<SPItem*> items(selection->itemList()); Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); - for(std::list<SPItem *>::iterator item = items.begin(); + for(std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); ++item) { SPItem * spitem = *item; Inkscape::XML::Node * node = spitem->getRepr(); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 61f2f70e2..8fd82b675 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -186,13 +186,10 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View { SPDocument * current_document = view->doc(); - using Inkscape::Util::GSListConstIterator; - - // FIXME very unsafe cast - GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; - if (selected != NULL) { - first_select = (*selected)->getRepr(); + if (!selected.empty()) { + first_select = selected[0]->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 19946022c..386bde1d6 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -35,8 +35,7 @@ #include <extension/system.h> #include <2geom/pathvector.h> #include <2geom/rect.h> -#include <2geom/bezier-curve.h> -#include <2geom/hvlinesegment.h> +#include <2geom/curves.h> #include "helper/geom.h" #include "helper/geom-curves.h" #include <io/sys.h> @@ -531,9 +530,7 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id) for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit) { //### LINE - if ( dynamic_cast<Geom::LineSegment const *> (&*cit) || - dynamic_cast<Geom::HLineSegment const *> (&*cit) || - dynamic_cast<Geom::VLineSegment const *> (&*cit) ) + if ( dynamic_cast<Geom::LineSegment const *> (&*cit) ) { Geom::Point p = cit->finalPoint(); out(" LineTo {\n"); @@ -545,7 +542,7 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id) //### BEZIER else if (Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&*cit)) { - std::vector<Geom::Point> points = cubic->points(); + std::vector<Geom::Point> points = cubic->controlPoints(); Geom::Point p1 = points[1]; Geom::Point p2 = points[2]; Geom::Point p3 = points[3]; diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index 6aaa1bca4..ae8f30a5c 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -17,8 +17,7 @@ #include <2geom/pathvector.h> #include <2geom/sbasis-to-bezier.h> -#include <2geom/bezier-curve.h> -#include <2geom/hvlinesegment.h> +#include <2geom/curves.h> #include <errno.h> #include <signal.h> #include "util/units.h" @@ -300,7 +299,7 @@ PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const &c) os << "\\lineto(" << c.finalPoint()[X] << "," << c.finalPoint()[Y] << ")\n"; } else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const*>(&c)) { - std::vector<Geom::Point> points = cubic_bezier->points(); + std::vector<Geom::Point> points = cubic_bezier->controlPoints(); os << "\\curveto(" << points[1][X] << "," << points[1][Y] << ")(" << points[2][X] << "," << points[2][Y] << ")(" << points[3][X] << "," << points[3][Y] << ")\n"; diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index ab0733848..5933dd526 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -228,14 +228,12 @@ LaTeXTextRenderer::writePostamble() void LaTeXTextRenderer::sp_group_render(SPGroup *group) { - GSList *l = g_slist_reverse(group->childList(false)); - while (l) { - SPObject *o = reinterpret_cast<SPObject *>(l->data); - SPItem *item = dynamic_cast<SPItem *>(o); + std::vector<SPObject*> l = (group->childList(false)); + for(std::vector<SPObject*>::const_iterator x = l.begin(); x != l.end(); x++){ + SPItem *item = dynamic_cast<SPItem*>(*x); if (item) { renderItem(item); } - l = g_slist_remove (l, o); } } @@ -411,7 +409,8 @@ Flowing in rectangle is possible, not in arb shape. return; // don't know how to handle non-rect frames yet. is quite uncommon for latex users i think } - Geom::Rect framebox = frame->getRect() * transform(); + // We will transform the coordinates + Geom::Rect framebox = frame->getRect(); // get position and alignment // Align on topleft corner. @@ -431,7 +430,10 @@ Flowing in rectangle is possible, not in arb shape. // no need to add LaTeX code for standard justified output :) break; } - Geom::Point pos(framebox.corner(3)); //topleft corner + + // The topleft Corner was calculated after rotating the text which results in a wrong Coordinate. + // Now, the topleft Corner is rotated after calculating it + Geom::Point pos(framebox.corner(0) * transform()); //topleft corner // determine color and transparency (for now, use rgb color model as it is most native to Inkscape) bool has_color = false; // if the item has no color set, don't force black color @@ -474,7 +476,9 @@ Flowing in rectangle is possible, not in arb shape. os << "\\rotatebox{" << degrees << "}{"; } os << "\\makebox(0,0)" << alignment << "{"; - os << "\\begin{minipage}{" << framebox.width() << "\\unitlength}"; + + // Scale the x width correctly + os << "\\begin{minipage}{" << framebox.width() * transform().expansionX() << "\\unitlength}"; os << justification; // Walk through all spans in the text object. diff --git a/src/extension/internal/metafile-print.cpp b/src/extension/internal/metafile-print.cpp index 73d63f27d..2fb36be85 100644 --- a/src/extension/internal/metafile-print.cpp +++ b/src/extension/internal/metafile-print.cpp @@ -389,7 +389,7 @@ Geom::PathVector PrintMetafile::center_ellipse_as_SVG_PathV(Geom::Point ctr, dou char text[256]; sprintf(text, " M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z", x1, y1, rx, ry, F * 360. / (2.*M_PI), x2, y2, rx, ry, F * 360. / (2.*M_PI), x1, y1); - std::vector<Geom::Path> outres = Geom::parse_svg_path(text); + Geom::PathVector outres = Geom::parse_svg_path(text); return outres; } @@ -419,7 +419,7 @@ Geom::PathVector PrintMetafile::center_elliptical_ring_as_SVG_PathV(Geom::Point sprintf(text, " M %f,%f A %f %f %f 0 1 %f %f A %f %f %f 0 1 %f %f z M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z", x11, y11, rx1, ry1, degrot, x12, y12, rx1, ry1, degrot, x11, y11, x21, y21, rx2, ry2, degrot, x22, y22, rx2, ry2, degrot, x21, y21); - std::vector<Geom::Path> outres = Geom::parse_svg_path(text); + Geom::PathVector outres = Geom::parse_svg_path(text); return outres; } @@ -440,7 +440,7 @@ Geom::PathVector PrintMetafile::center_elliptical_hole_as_SVG_PathV(Geom::Point char text[256]; sprintf(text, " M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z M 50000,50000 50000,-50000 -50000,-50000 -50000,50000 z", x1, y1, rx, ry, F * 360. / (2.*M_PI), x2, y2, rx, ry, F * 360. / (2.*M_PI), x1, y1); - std::vector<Geom::Path> outres = Geom::parse_svg_path(text); + Geom::PathVector outres = Geom::parse_svg_path(text); return outres; } @@ -452,7 +452,7 @@ width vector to side edge */ Geom::PathVector PrintMetafile::rect_cutter(Geom::Point ctr, Geom::Point pos, Geom::Point neg, Geom::Point width) { - std::vector<Geom::Path> outres; + Geom::PathVector outres; Geom::Path cutter; cutter.start(ctr + pos - width); cutter.appendNew<Geom::LineSegment>(ctr + pos + width); diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 52fabcf3c..6904eb2fd 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -55,8 +55,7 @@ #include <style.h> #include "display/curve.h" #include <2geom/pathvector.h> -#include <2geom/bezier-curve.h> -#include <2geom/hvlinesegment.h> +#include <2geom/curves.h> #include <2geom/transforms.h> #include <helper/geom.h> #include "helper/geom-curves.h" @@ -1299,7 +1298,7 @@ writePath(Writer &outs, Geom::PathVector const &pathv, outs.printf("L %.3f %.3f ", destx, desty); } else if(Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&*cit)) { - std::vector<Geom::Point> points = cubic->points(); + std::vector<Geom::Point> points = cubic->controlPoints(); for (unsigned i = 1; i <= 3; i++) { if (fabs(points[i][X])<1.0) points[i][X] = 0.0; // Why is this needed? Shouldn't we just round all numbers then? if (fabs(points[i][Y])<1.0) points[i][Y] = 0.0; diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 148d2dcba..363061734 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -36,8 +36,14 @@ #include <gtkmm/comboboxtext.h> #include <gtkmm/drawingarea.h> #include <gtkmm/frame.h> +#include <gtkmm/radiobutton.h> #include <gtkmm/scale.h> +#if WITH_GTKMM_3_0 +#include <glibmm/convert.h> +#include <glibmm/miscutils.h> +#endif + #include "extension/system.h" #include "extension/input.h" #include "svg-builder.h" @@ -81,7 +87,6 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _poppler_doc = NULL; #endif // HAVE_POPPLER_CAIRO _pdf_doc = doc; - cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))); okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))); _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:"))); @@ -125,8 +130,13 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _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."))); #ifdef HAVE_POPPLER_CAIRO - _importviaPopplerCheck = Gtk::manage(new class Gtk::CheckButton(_("import via Poppler"))); + Gtk::RadioButton::Group group; + _importViaPoppler = Gtk::manage(new class Gtk::RadioButton(group,_("Poppler/Cairo import"))); + _labelViaPoppler = Gtk::manage(new class Gtk::Label(_("Import via external library. Text consists of groups containing cloned glyphs where each glyph is a path. Images are stored internally. Meshes cause entire document to be rendered as a raster image."))); + _importViaInternal = Gtk::manage(new class Gtk::RadioButton(group,_("Internal import"))); + _labelViaInternal = Gtk::manage(new class Gtk::Label(_("Import via internal (Poppler derived) library. Text is stored as text but white space is missing. Meshes are converted to tiles, the number depends on the precision set below."))); #endif + #if WITH_GTKMM_3_0 _fallbackPrecisionSlider_adj = Gtk::Adjustment::create(2, 1, 256, 1, 10, 10); _fallbackPrecisionSlider = Gtk::manage(new class Gtk::Scale(_fallbackPrecisionSlider_adj)); @@ -139,13 +149,15 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) hbox6 = Gtk::manage(new class Gtk::HBox(false, 4)); // Text options - _labelText = Gtk::manage(new class Gtk::Label(_("Text handling:"))); - _textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText()); - _textHandlingCombo->append(_("Import text as text")); - _textHandlingCombo->set_active_text(_("Import text as text")); + // _labelText = Gtk::manage(new class Gtk::Label(_("Text handling:"))); + // _textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText()); + // _textHandlingCombo->append(_("Import text as text")); + // _textHandlingCombo->set_active_text(_("Import text as text")); + // hbox5 = Gtk::manage(new class Gtk::HBox(false, 4)); + + // Font option _localFontsCheck = Gtk::manage(new class Gtk::CheckButton(_("Replace PDF fonts by closest-named installed fonts"))); - 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)); _importSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame(_("Import settings"))); @@ -202,12 +214,19 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _labelPrecisionWarning->set_line_wrap(true); _labelPrecisionWarning->set_use_markup(true); _labelPrecisionWarning->set_selectable(false); + #ifdef HAVE_POPPLER_CAIRO - _importviaPopplerCheck->set_can_focus(); - _importviaPopplerCheck->set_relief(Gtk::RELIEF_NORMAL); - _importviaPopplerCheck->set_mode(true); - _importviaPopplerCheck->set_active(false); + _importViaPoppler->set_can_focus(); + _importViaPoppler->set_relief(Gtk::RELIEF_NORMAL); + _importViaPoppler->set_mode(true); + _importViaPoppler->set_active(false); + _importViaInternal->set_can_focus(); + _importViaInternal->set_relief(Gtk::RELIEF_NORMAL); + _importViaInternal->set_mode(true); + _labelViaPoppler->set_line_wrap(true); + _labelViaInternal->set_line_wrap(true); #endif + _fallbackPrecisionSlider->set_size_request(180,-1); _fallbackPrecisionSlider->set_can_focus(); _fallbackPrecisionSlider->set_inverted(false); @@ -223,14 +242,14 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _labelPrecisionComment->set_selectable(false); hbox6->pack_start(*_fallbackPrecisionSlider, Gtk::PACK_SHRINK, 4); hbox6->pack_start(*_labelPrecisionComment, Gtk::PACK_SHRINK, 0); - _labelText->set_alignment(0.5,0.5); - _labelText->set_padding(4,0); - _labelText->set_justify(Gtk::JUSTIFY_LEFT); - _labelText->set_line_wrap(false); - _labelText->set_use_markup(false); - _labelText->set_selectable(false); - hbox5->pack_start(*_labelText, Gtk::PACK_SHRINK, 0); - hbox5->pack_start(*_textHandlingCombo, Gtk::PACK_SHRINK, 0); + // _labelText->set_alignment(0.5,0.5); + // _labelText->set_padding(4,0); + // _labelText->set_justify(Gtk::JUSTIFY_LEFT); + // _labelText->set_line_wrap(false); + // _labelText->set_use_markup(false); + // _labelText->set_selectable(false); + // hbox5->pack_start(*_labelText, Gtk::PACK_SHRINK, 0); + // hbox5->pack_start(*_textHandlingCombo, Gtk::PACK_SHRINK, 0); _localFontsCheck->set_can_focus(); _localFontsCheck->set_relief(Gtk::RELIEF_NORMAL); _localFontsCheck->set_mode(true); @@ -240,14 +259,17 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _embedImagesCheck->set_mode(true); _embedImagesCheck->set_active(true); #ifdef HAVE_POPPLER_CAIRO - vbox3->pack_start(*_importviaPopplerCheck, Gtk::PACK_SHRINK, 0); + vbox3->pack_start(*_importViaPoppler, Gtk::PACK_SHRINK, 0); + vbox3->pack_start(*_labelViaPoppler, Gtk::PACK_SHRINK, 0); + vbox3->pack_start(*_importViaInternal, Gtk::PACK_SHRINK, 0); + vbox3->pack_start(*_labelViaInternal, Gtk::PACK_SHRINK, 0); #endif + vbox3->pack_start(*_localFontsCheck, Gtk::PACK_SHRINK, 0); + vbox3->pack_start(*_embedImagesCheck, Gtk::PACK_SHRINK, 0); vbox3->pack_start(*_labelPrecision, Gtk::PACK_SHRINK, 0); vbox3->pack_start(*hbox6, Gtk::PACK_SHRINK, 0); vbox3->pack_start(*_labelPrecisionWarning, Gtk::PACK_SHRINK, 0); - vbox3->pack_start(*hbox5, Gtk::PACK_SHRINK, 4); - vbox3->pack_start(*_localFontsCheck, Gtk::PACK_SHRINK, 0); - vbox3->pack_start(*_embedImagesCheck, Gtk::PACK_SHRINK, 0); + // vbox3->pack_start(*hbox5, Gtk::PACK_SHRINK, 4); _importSettingsFrame->add(*vbox3); _importSettingsFrame->set_border_width(4); vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0); @@ -273,36 +295,9 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) this->property_destroy_with_parent().set_value(false); this->add_action_widget(*cancelbutton, -6); this->add_action_widget(*okbutton, -5); - cancelbutton->show(); - okbutton->show(); - _labelSelect->show(); - _pageNumberSpin->show(); - _labelTotalPages->show(); - hbox2->show(); - _cropCheck->show(); - _cropTypeCombo->show(); - hbox3->show(); - vbox2->show(); - _pageSettingsFrame->show(); - _labelPrecision->show(); - _labelPrecisionWarning->show(); -#ifdef HAVE_POPPLER_CAIRO - _importviaPopplerCheck->show(); -#endif - _fallbackPrecisionSlider->show(); - _labelPrecisionComment->show(); - hbox6->show(); - _labelText->show(); - _textHandlingCombo->show(); - hbox5->show(); - _localFontsCheck->show(); - _embedImagesCheck->show(); - vbox3->show(); - _importSettingsFrame->show(); - vbox1->show(); - _previewArea->show(); - hbox1->show(); + this->show_all(); + // Connect signals #if WITH_GTKMM_3_0 _previewArea->signal_draw().connect(sigc::mem_fun(*this, &PdfImportDialog::_onDraw)); @@ -313,17 +308,28 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PdfImportDialog::_onPageNumberChanged)); _cropCheck->signal_toggled().connect(sigc::mem_fun(*this, &PdfImportDialog::_onToggleCropping)); _fallbackPrecisionSlider_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PdfImportDialog::_onPrecisionChanged)); +#ifdef HAVE_POPPLER_CAIRO + _importViaPoppler->signal_toggled().connect(sigc::mem_fun(*this, &PdfImportDialog::_onToggleImport)); +#endif _render_thumb = false; #ifdef HAVE_POPPLER_CAIRO _cairo_surface = NULL; _render_thumb = true; + // Create PopplerDocument - gchar *doc_uri = g_filename_to_uri(_pdf_doc->getFileName()->getCString(),NULL,NULL); - if (doc_uri) { - _poppler_doc = poppler_document_new_from_file(doc_uri, NULL, NULL); - g_free(doc_uri); + Glib::ustring filename = _pdf_doc->getFileName()->getCString(); + if (!Glib::path_is_absolute(filename)) { + filename = Glib::build_filename(Glib::get_current_dir(),filename); + } + Glib::ustring full_uri = Glib::filename_to_uri(filename); + + if (!full_uri.empty()) { + _poppler_doc = poppler_document_new_from_file(full_uri.c_str(), NULL, NULL); } + + // Set sensitivity of some widgets based on selected import type. + _onToggleImport(); #endif // Set default preview size @@ -373,11 +379,11 @@ int PdfImportDialog::getSelectedPage() { return _current_page; } -int PdfImportDialog::getImportMethod() { +bool PdfImportDialog::getImportMethod() { #ifdef HAVE_POPPLER_CAIRO - return (_importviaPopplerCheck->get_active()) ? 1 : 0; + return _importViaPoppler->get_active(); #else - return 0; + return false; #endif } @@ -413,7 +419,7 @@ void PdfImportDialog::getImportSettings(Inkscape::XML::Node *prefs) { prefs->setAttribute("embedImages", "0"); } #ifdef HAVE_POPPLER_CAIRO - if (_importviaPopplerCheck->get_active()) { + if (_importViaPoppler->get_active()) { prefs->setAttribute("importviapoppler", "1"); } else { prefs->setAttribute("importviapoppler", "0"); @@ -454,6 +460,23 @@ void PdfImportDialog::_onPageNumberChanged() { } #ifdef HAVE_POPPLER_CAIRO +void PdfImportDialog::_onToggleImport() { + if( _importViaPoppler->get_active() ) { + hbox3->set_sensitive(false); + _localFontsCheck->set_sensitive(false); + _embedImagesCheck->set_sensitive(false); + hbox6->set_sensitive(false); + } else { + hbox3->set_sensitive(); + _localFontsCheck->set_sensitive(); + _embedImagesCheck->set_sensitive(); + hbox6->set_sensitive(); + } +} +#endif + + +#ifdef HAVE_POPPLER_CAIRO /** * \brief Copies image data from a Cairo surface to a pixbuf * @@ -673,8 +696,13 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { globalParams = new GlobalParams(); #endif // ENABLE_OSX_APP_LOCATIONS } - // poppler does not use glib g_open. So on win32 we must use unicode call. code was copied from glib gstdio.c + + + // PDFDoc is from poppler. PDFDoc is used for preview and for native import. + #ifndef WIN32 + // poppler does not use glib g_open. So on win32 we must use unicode call. code was copied from + // glib gstdio.c GooString *filename_goo = new GooString(uri); PDFDoc *pdf_doc = new PDFDoc(filename_goo, NULL, NULL, NULL); // TODO: Could ask for password //delete filename_goo; @@ -730,26 +758,20 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { } } - // Get needed page - int page_num; - if (dlg) + // Get options + int page_num = 1; + bool is_importvia_poppler = false; + if (dlg) { page_num = dlg->getSelectedPage(); - else - page_num = 1; - Catalog *catalog = pdf_doc->getCatalog(); - Page *page = catalog->getPage(page_num); - - int is_importvia_poppler = 0; - if(dlg) - { #ifdef HAVE_POPPLER_CAIRO is_importvia_poppler = dlg->getImportMethod(); + // printf("PDF import via %s.\n", is_importvia_poppler ? "poppler" : "native"); #endif } SPDocument *doc = NULL; bool saved = false; - if(is_importvia_poppler == 0) + if(!is_importvia_poppler) { // native importer doc = SPDocument::createNewDoc(NULL, TRUE, TRUE); @@ -769,12 +791,14 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { if (dlg) dlg->getImportSettings(prefs); - printf("pdf import via %s.", (is_importvia_poppler != 0) ? "poppler" : "native"); - // Apply crop settings PDFRectangle *clipToBox = NULL; double crop_setting; sp_repr_get_double(prefs, "cropTo", &crop_setting); + + Catalog *catalog = pdf_doc->getCatalog(); + Page *page = catalog->getPage(page_num); + if ( crop_setting >= 0.0 ) { // Do page clipping int crop_choice = (int)crop_setting; switch (crop_choice) { @@ -798,11 +822,11 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { } } - // Create parser + // Create parser (extension/internal/pdfinput/pdf-parser.h) PdfParser *pdf_parser = new PdfParser(pdf_doc->getXRef(), builder, page_num-1, page->getRotate(), page->getResourceDict(), page->getCropBox(), clipToBox); - // Set up approximation precision for parser + // Set up approximation precision for parser. Used for convering Mesh Gradients into tiles. double color_delta; sp_repr_get_double(prefs, "approximationPrecision", &color_delta); if ( color_delta <= 0.0 ) { @@ -831,13 +855,20 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { { #ifdef HAVE_POPPLER_CAIRO // the poppler import - gchar* filename_uri = g_filename_to_uri(uri, NULL, NULL); + + Glib::ustring full_path = uri; + if (!Glib::path_is_absolute(uri)) { + full_path = Glib::build_filename(Glib::get_current_dir(),uri); + } + Glib::ustring full_uri = Glib::filename_to_uri(full_path); + GError *error = NULL; - /// @todo handle passwort + /// @todo handle password /// @todo check if win32 unicode needs special attention - PopplerDocument* document = poppler_document_new_from_file(filename_uri, NULL, &error); + PopplerDocument* document = poppler_document_new_from_file(full_uri.c_str(), NULL, &error); if(error != NULL) { + std::cerr << "PDFInput::open: error opening document: " << full_uri << std::endl; g_error_free (error); } @@ -850,6 +881,13 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { Glib::ustring output; cairo_surface_t* surface = cairo_svg_surface_create_for_stream(Inkscape::Extension::Internal::_write_ustring_cb, &output, width, height); + + // This magical function results in more fine-grain fallbacks. In particular, a mesh + // gradient won't necessarily result in the whole PDF being rasterized. Of course, SVG + // 1.2 never made it as a standard, but hey, we'll take what we can get. This trick was + // found by examining the 'pdftocairo' code. + cairo_svg_surface_restrict_to_version( surface, CAIRO_SVG_VERSION_1_2 ); + cairo_t* cr = cairo_create(surface); poppler_page_render_for_printing(page, cr); @@ -867,13 +905,10 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { } else { - doc = SPDocument::createNewDoc(NULL, TRUE, TRUE); // fallback create empthy document + doc = SPDocument::createNewDoc(NULL, TRUE, TRUE); // fallback create empty document } saved = DocumentUndo::getUndoSensitive(doc); DocumentUndo::setUndoSensitive(doc, false); // No need to undo in this temporary document - - // Cleanup - g_free(filename_uri); #endif } diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h index 866db5d82..6e36603c3 100644 --- a/src/extension/internal/pdfinput/pdf-input.h +++ b/src/extension/internal/pdfinput/pdf-input.h @@ -44,6 +44,7 @@ namespace Gtk { #else class HScale; #endif + class RadioButton; class VBox; class Label; } @@ -71,7 +72,7 @@ public: bool showDialog(); int getSelectedPage(); - int getImportMethod(); + bool getImportMethod(); void getImportSettings(Inkscape::XML::Node *prefs); private: @@ -86,7 +87,10 @@ private: void _onPageNumberChanged(); void _onToggleCropping(); void _onPrecisionChanged(); - +#ifdef HAVE_POPPLER_CAIRO + void _onToggleImport(); +#endif + class Gtk::Button * cancelbutton; class Gtk::Button * okbutton; class Gtk::Label * _labelSelect; @@ -101,7 +105,10 @@ private: class Gtk::Label * _labelPrecision; class Gtk::Label * _labelPrecisionWarning; #ifdef HAVE_POPPLER_CAIRO - class Gtk::CheckButton * _importviaPopplerCheck; // using poppler_cairo for importing + class Gtk::RadioButton * _importViaPoppler; // Use poppler_cairo importing + class Gtk::Label * _labelViaPoppler; + class Gtk::RadioButton * _importViaInternal; // Use native (poppler based) importing + class Gtk::Label * _labelViaInternal; #endif #if WITH_GTKMM_3_0 class Gtk::Scale * _fallbackPrecisionSlider; diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index cc0b38515..836c34c32 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -2780,12 +2780,14 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg) Dict *dict; int width, height; int bits; + GBool interpolate; StreamColorSpaceMode csMode; GBool mask; GBool invert; Object maskObj, smaskObj; GBool haveColorKeyMask, haveExplicitMask, haveSoftMask; GBool maskInvert; + GBool maskInterpolate; Object obj1, obj2; // get info from the stream @@ -2828,6 +2830,19 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg) } obj1.free(); + // image interpolation + dict->lookup("Interpolate", &obj1); + if (obj1.isNull()) { + obj1.free(); + dict->lookup("I", &obj1); + } + if (obj1.isBool()) + interpolate = obj1.getBool(); + else + interpolate = gFalse; + obj1.free(); + maskInterpolate = gFalse; + // image or mask? dict->lookup(const_cast<char*>("ImageMask"), &obj1); if (obj1.isNull()) { @@ -2884,7 +2899,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg) obj1.free(); // draw it - builder->addImageMask(state, str, width, height, invert); + builder->addImageMask(state, str, width, height, invert, interpolate); } else { // get color space and color map @@ -2986,6 +3001,16 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg) } int maskBits = obj1.getInt(); obj1.free(); + maskDict->lookup("Interpolate", &obj1); + if (obj1.isNull()) { + obj1.free(); + maskDict->lookup("I", &obj1); + } + if (obj1.isBool()) + maskInterpolate = obj1.getBool(); + else + maskInterpolate = gFalse; + obj1.free(); maskDict->lookup(const_cast<char*>("ColorSpace"), &obj1); if (obj1.isNull()) { obj1.free(); @@ -3071,6 +3096,16 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg) goto err2; } obj1.free(); + maskDict->lookup("Interpolate", &obj1); + if (obj1.isNull()) { + obj1.free(); + maskDict->lookup("I", &obj1); + } + if (obj1.isBool()) + maskInterpolate = obj1.getBool(); + else + maskInterpolate = gFalse; + obj1.free(); maskInvert = gFalse; maskDict->lookup(const_cast<char*>("Decode"), &obj1); if (obj1.isNull()) { @@ -3092,14 +3127,14 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg) // draw it if (haveSoftMask) { - builder->addSoftMaskedImage(state, str, width, height, colorMap, - maskStr, maskWidth, maskHeight, maskColorMap); + builder->addSoftMaskedImage(state, str, width, height, colorMap, interpolate, + maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate); delete maskColorMap; } else if (haveExplicitMask) { - builder->addMaskedImage(state, str, width, height, colorMap, - maskStr, maskWidth, maskHeight, maskInvert); + builder->addMaskedImage(state, str, width, height, colorMap, interpolate, + maskStr, maskWidth, maskHeight, maskInvert, maskInterpolate); } else { - builder->addImage(state, str, width, height, colorMap, + builder->addImage(state, str, width, height, colorMap, interpolate, haveColorKeyMask ? maskColors : static_cast<int *>(NULL)); } delete colorMap; diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index a3abb4045..58e2030d9 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -1485,7 +1485,9 @@ void png_flush_base64stream(png_structp png_ptr) * */ Inkscape::XML::Node *SvgBuilder::_createImage(Stream *str, int width, int height, - GfxImageColorMap *color_map, int *mask_colors, bool alpha_only, bool invert_alpha) { + GfxImageColorMap *color_map, bool interpolate, + int *mask_colors, bool alpha_only, + bool invert_alpha) { // Create PNG write struct png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); @@ -1655,6 +1657,13 @@ Inkscape::XML::Node *SvgBuilder::_createImage(Stream *str, int width, int height Inkscape::XML::Node *image_node = _xml_doc->createElement("svg:image"); sp_repr_set_svg_double(image_node, "width", 1); sp_repr_set_svg_double(image_node, "height", 1); + if( !interpolate ) { + SPCSSAttr *css = sp_repr_css_attr_new(); + // This should be changed after CSS4 Images widely supported. + sp_repr_css_set_property(css, "image-rendering", "optimizeSpeed"); + sp_repr_css_change(image_node, css, "style"); + sp_repr_css_attr_unref(css); + } // PS/PDF images are placed via a transformation matrix, no preserveAspectRatio used image_node->setAttribute("preserveAspectRatio", "none"); @@ -1715,9 +1724,9 @@ Inkscape::XML::Node *SvgBuilder::_createMask(double width, double height) { } void SvgBuilder::addImage(GfxState * /*state*/, Stream *str, int width, int height, - GfxImageColorMap *color_map, int *mask_colors) { + GfxImageColorMap *color_map, bool interpolate, int *mask_colors) { - Inkscape::XML::Node *image_node = _createImage(str, width, height, color_map, mask_colors); + Inkscape::XML::Node *image_node = _createImage(str, width, height, color_map, interpolate, mask_colors); if (image_node) { _container->appendChild(image_node); Inkscape::GC::release(image_node); @@ -1725,7 +1734,7 @@ void SvgBuilder::addImage(GfxState * /*state*/, Stream *str, int width, int heig } void SvgBuilder::addImageMask(GfxState *state, Stream *str, int width, int height, - bool invert) { + bool invert, bool interpolate) { // Create a rectangle Inkscape::XML::Node *rect = _xml_doc->createElement("svg:rect"); @@ -1742,7 +1751,8 @@ void SvgBuilder::addImageMask(GfxState *state, Stream *str, int width, int heigh // Scaling 1x1 surfaces might not work so skip setting a mask with this size if ( width > 1 || height > 1 ) { - Inkscape::XML::Node *mask_image_node = _createImage(str, width, height, NULL, NULL, true, invert); + Inkscape::XML::Node *mask_image_node = + _createImage(str, width, height, NULL, interpolate, NULL, true, invert); if (mask_image_node) { // Create the mask Inkscape::XML::Node *mask_node = _createMask(1.0, 1.0); @@ -1762,13 +1772,13 @@ void SvgBuilder::addImageMask(GfxState *state, Stream *str, int width, int heigh } void SvgBuilder::addMaskedImage(GfxState * /*state*/, Stream *str, int width, int height, - GfxImageColorMap *color_map, + GfxImageColorMap *color_map, bool interpolate, Stream *mask_str, int mask_width, int mask_height, - bool invert_mask) { + bool invert_mask, bool mask_interpolate) { Inkscape::XML::Node *mask_image_node = _createImage(mask_str, mask_width, mask_height, - NULL, NULL, true, invert_mask); - Inkscape::XML::Node *image_node = _createImage(str, width, height, color_map, NULL); + NULL, mask_interpolate, NULL, true, invert_mask); + Inkscape::XML::Node *image_node = _createImage(str, width, height, color_map, interpolate, NULL); if ( mask_image_node && image_node ) { // Create mask for the image Inkscape::XML::Node *mask_node = _createMask(1.0, 1.0); @@ -1795,13 +1805,13 @@ void SvgBuilder::addMaskedImage(GfxState * /*state*/, Stream *str, int width, in } void SvgBuilder::addSoftMaskedImage(GfxState * /*state*/, Stream *str, int width, int height, - GfxImageColorMap *color_map, + GfxImageColorMap *color_map, bool interpolate, Stream *mask_str, int mask_width, int mask_height, - GfxImageColorMap *mask_color_map) { + GfxImageColorMap *mask_color_map, bool mask_interpolate) { Inkscape::XML::Node *mask_image_node = _createImage(mask_str, mask_width, mask_height, - mask_color_map, NULL, true); - Inkscape::XML::Node *image_node = _createImage(str, width, height, color_map, NULL); + mask_color_map, mask_interpolate, NULL, true); + Inkscape::XML::Node *image_node = _createImage(str, width, height, color_map, interpolate, NULL); if ( mask_image_node && image_node ) { // Create mask for the image Inkscape::XML::Node *mask_node = _createMask(1.0, 1.0); diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index f1ce02cf0..ad15c9c06 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -112,17 +112,17 @@ public: // Image handling void addImage(GfxState *state, Stream *str, int width, int height, - GfxImageColorMap *color_map, int *mask_colors); + GfxImageColorMap *color_map, bool interpolate, int *mask_colors); void addImageMask(GfxState *state, Stream *str, int width, int height, - bool invert); + bool invert, bool interpolate); void addMaskedImage(GfxState *state, Stream *str, int width, int height, - GfxImageColorMap *color_map, + GfxImageColorMap *color_map, bool interpolate, Stream *mask_str, int mask_width, int mask_height, - bool invert_mask); + bool invert_mask, bool mask_interpolate); void addSoftMaskedImage(GfxState *state, Stream *str, int width, int height, - GfxImageColorMap *color_map, + GfxImageColorMap *color_map, bool interpolate, Stream *mask_str, int mask_width, int mask_height, - GfxImageColorMap *mask_color_map); + GfxImageColorMap *mask_color_map, bool mask_interpolate); // Transparency group and soft mask handling void pushTransparencyGroup(GfxState *state, double *bbox, @@ -180,8 +180,9 @@ private: bool is_stroke=false); // Image/mask creation Inkscape::XML::Node *_createImage(Stream *str, int width, int height, - GfxImageColorMap *color_map, int *mask_colors, - bool alpha_only=false, bool invert_alpha=false); + GfxImageColorMap *color_map, bool interpolate, + int *mask_colors, bool alpha_only=false, + bool invert_alpha=false); Inkscape::XML::Node *_createMask(double width, double height); // Style setting SPCSSAttr *_setStyle(GfxState *state, bool fill, bool stroke, bool even_odd=false); diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 3d149928f..bd2168b68 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -30,8 +30,7 @@ #include <extension/system.h> #include <2geom/pathvector.h> #include <2geom/rect.h> -#include <2geom/bezier-curve.h> -#include <2geom/hvlinesegment.h> +#include <2geom/curves.h> #include "helper/geom.h" #include "helper/geom-curves.h" #include <io/sys.h> @@ -388,7 +387,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id) } else if(Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&*cit)) { - std::vector<Geom::Point> points = cubic->points(); + std::vector<Geom::Point> points = cubic->controlPoints(); Geom::Point p0 = points[0]; Geom::Point p1 = points[1]; Geom::Point p2 = points[2]; diff --git a/src/extension/internal/text_reassemble.c b/src/extension/internal/text_reassemble.c index d3aafef12..fa983b83d 100644 --- a/src/extension/internal/text_reassemble.c +++ b/src/extension/internal/text_reassemble.c @@ -67,8 +67,8 @@ Optional compiler switches for development: File: text_reassemble.c -Version: 0.0.16 -Date: 25-FEB-2015 +Version: 0.0.17 +Date: 21-MAY-2015 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2015 David Mathog and California Institute of Technology (Caltech) @@ -2204,10 +2204,10 @@ void TR_layout_2_svg(TR_INFO *tri){ sprintf(obuf,"text-decoration:"); /* multiple text decoration styles may be set */ utmp = tsp->decoration & TXTDECOR_TMASK; - if(utmp & TXTDECOR_UNDER ){ strcat(obuf,"underline"); } - if(utmp & TXTDECOR_OVER ){ strcat(obuf,"overline"); } - if(utmp & TXTDECOR_BLINK ){ strcat(obuf,"blink"); } - if(utmp & TXTDECOR_STRIKE){ strcat(obuf,"line-through");} + if(utmp & TXTDECOR_UNDER ){ strcat(obuf," underline"); } + if(utmp & TXTDECOR_OVER ){ strcat(obuf," overline"); } + if(utmp & TXTDECOR_BLINK ){ strcat(obuf," blink"); } + if(utmp & TXTDECOR_STRIKE){ strcat(obuf," line-through");} if(*obuf){ /* only a single text decoration line type may be set */ switch(tsp->decoration & TXTDECOR_LMASK){ diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index 3ab7a4e89..d17180d91 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -95,7 +95,6 @@ Wmf::print_document_to_file(SPDocument *doc, const gchar *filename) SPPrintContext context; const gchar *oldconst; gchar *oldoutput; - unsigned int ret; doc->ensureUpToDate(); @@ -114,13 +113,12 @@ Wmf::print_document_to_file(SPDocument *doc, const gchar *filename) mod->root = mod->base->invoke_show(drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY); drawing.setRoot(mod->root); /* Print document */ - ret = mod->begin(doc); - if (ret) { + if (mod->begin(doc)) { g_free(oldoutput); throw Inkscape::Extension::Output::save_failed(); } mod->base->invoke_print(&context); - ret = mod->finish(); + mod->finish(); /* Release arena */ mod->base->invoke_hide(mod->dkey); mod->base = NULL; @@ -451,7 +449,8 @@ uint32_t Wmf::add_dib_image(PWMF_CALLBACK_DATA d, const char *dib, uint32_t iUsa char *rgba_px = NULL; // RGBA pixels const char *px = NULL; // DIB pixels const U_RGBQUAD *ct = NULL; // DIB color table - int32_t width, height, colortype, numCt, invert; // if needed these values will be set by wget_DIB_params + uint32_t numCt; + int32_t width, height, colortype, invert; // if needed these values will be set by wget_DIB_params if(iUsage == U_DIB_RGB_COLORS){ // next call returns pointers and values, but allocates no memory dibparams = wget_DIB_params(dib, &px, &ct, &numCt, &width, &height, &colortype, &invert); @@ -1320,7 +1319,8 @@ void Wmf::common_dib_to_image(PWMF_CALLBACK_DATA d, const char *dib, char *sub_px = NULL; // RGBA pixels, subarray const char *px = NULL; // DIB pixels const U_RGBQUAD *ct = NULL; // color table - int32_t width, height, colortype, numCt, invert; // if needed these values will be set in wget_DIB_params + uint32_t numCt; + int32_t width, height, colortype, invert; // if needed these values will be set in wget_DIB_params if(iUsage == U_DIB_RGB_COLORS){ // next call returns pointers and values, but allocates no memory dibparams = wget_DIB_params(dib, &px, &ct, &numCt, &width, &height, &colortype, &invert); diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index 9fe1a0259..431053085 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -29,14 +29,13 @@ #endif -#include "2geom/sbasis-to-bezier.h" -#include "2geom/svg-elliptical-arc.h" - -#include "2geom/path.h" -#include "2geom/pathvector.h" -#include "2geom/rect.h" -#include "2geom/bezier-curve.h" -#include "2geom/hvlinesegment.h" +#include <2geom/sbasis-to-bezier.h> +#include <2geom/elliptical-arc.h> + +#include <2geom/path.h> +#include <2geom/pathvector.h> +#include <2geom/rect.h> +#include <2geom/curves.h> #include "helper/geom.h" #include "helper/geom-curves.h" #include "sp-item.h" @@ -59,7 +58,7 @@ #include "display/cairo-utils.h" #include "splivarot.h" // pieces for union on shapes -#include "2geom/svg-path-parser.h" // to get from SVG text to Geom::Path +#include <2geom/svg-path-parser.h> // to get from SVG text to Geom::Path #include "display/canvas-bpath.h" // for SPWindRule #include "display/cairo-utils.h" // for Inkscape::Pixbuf::PF_CAIRO @@ -380,8 +379,8 @@ int PrintWmf::create_brush(SPStyle const *style, U_COLORREF *fcolor) } else if (SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style))) { // must be paint-server SPPaintServer *paintserver = style->fill.value.href->getObject(); SPPattern *pat = SP_PATTERN(paintserver); - double dwidth = pattern_width(pat); - double dheight = pattern_height(pat); + double dwidth = pat->width(); + double dheight = pat->height(); width = dwidth; height = dheight; brush_classify(pat, 0, &pixbuf, &hatchType, &hatchColor, &bkColor); @@ -984,7 +983,7 @@ bool PrintWmf::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff lpPoints[i].y = y1; i = i + 1; } else if (Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*cit)) { - std::vector<Geom::Point> points = cubic->points(); + std::vector<Geom::Point> points = cubic->controlPoints(); //Geom::Point p0 = points[0]; Geom::Point p1 = points[1]; Geom::Point p2 = points[2]; diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp index b774bac83..0b58c5011 100644 --- a/src/extension/param/color.cpp +++ b/src/extension/param/color.cpp @@ -24,41 +24,37 @@ #include "color.h" #include <color.h> -#include "widgets/sp-color-selector.h" -#include "widgets/sp-color-notebook.h" +#include "ui/widget/color-notebook.h" #include "preferences.h" - namespace Inkscape { namespace Extension { -void sp_color_param_changed(SPColorSelector *csel, GObject *cp); - - ParamColor::~ParamColor(void) { - + _color_changed.disconnect(); } guint32 ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) { - _value = in; + _color_changed.block(true); + _color.setValue(in); + _color_changed.block(false); gchar * prefname = this->pref_name(); std::string value; string(value); - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setString(extension_pref_root + prefname, value); g_free(prefname); - return _value; + return in; } -ParamColor::ParamColor(const gchar *name, const gchar *guitext, const gchar *desc, const Parameter::_scope_t scope, - bool gui_hidden, const gchar *gui_tip, Inkscape::Extension::Extension *ext, - Inkscape::XML::Node *xml) - : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0), _changeSignal(0) +ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _changeSignal(0) { const char * defaulthex = NULL; if (xml->firstChild() != NULL) @@ -72,51 +68,48 @@ ParamColor::ParamColor(const gchar *name, const gchar *guitext, const gchar *des if (!paramval.empty()) defaulthex = paramval.data(); - if (defaulthex) - _value = atoi(defaulthex); + if (defaulthex) { + _color.setValue(atoi(defaulthex)); + } + _color_changed = _color.signal_changed.connect(sigc::mem_fun(this, &ParamColor::_onColorChanged)); + } void ParamColor::string(std::string &string) const { char str[16]; - sprintf(str, "%i", _value); + snprintf(str, 16, "%i", _color.value()); string += str; } Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal ) { - if (_gui_hidden) return NULL; + using Inkscape::UI::Widget::ColorNotebook; - _changeSignal = new sigc::signal<void>(*changeSignal); - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - SPColorSelector* spColorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK); + if (_gui_hidden) return NULL; - ColorSelector* colorSelector = spColorSelector->base; - if (_value < 1) { - _value = 0xFF000000; + if (changeSignal) { + _changeSignal = new sigc::signal<void>(*changeSignal); } - SPColor *color = new SPColor( _value ); - float alpha = (_value & 0xff) / 255.0F; - colorSelector->setColorAlpha(*color, alpha); - hbox->pack_start (*Glib::wrap(&spColorSelector->vbox), true, true, 0); - g_signal_connect(G_OBJECT(spColorSelector), "changed", G_CALLBACK(sp_color_param_changed), (void*)this); + if (_color.value() < 1) { + _color_changed.block(true); + _color.setValue(0xFF000000); + _color_changed.block(false); + } - gtk_widget_show(GTK_WIDGET(spColorSelector)); + Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, 4)); + Gtk::Widget *selector = Gtk::manage(new ColorNotebook(_color)); + hbox->pack_start (*selector, true, true, 0); + selector->show(); hbox->show(); - - return dynamic_cast<Gtk::Widget *>(hbox); + return hbox; } -void sp_color_param_changed(SPColorSelector *csel, GObject *obj) +void ParamColor::_onColorChanged() { - const SPColor color = csel->base->getColor(); - float alpha = csel->base->getAlpha(); - - ParamColor* ptr = reinterpret_cast<ParamColor*>(obj); - ptr->set(color.toRGBA32( alpha ), NULL, NULL); - - ptr->_changeSignal->emit(); + if (_changeSignal) + _changeSignal->emit(); } }; /* namespace Extension */ diff --git a/src/extension/param/color.h b/src/extension/param/color.h index 9894965a9..ed2e57ceb 100644 --- a/src/extension/param/color.h +++ b/src/extension/param/color.h @@ -9,6 +9,7 @@ */ #include "parameter.h" +#include "ui/selected-color.h" class SPDocument; @@ -25,14 +26,17 @@ namespace Extension { class ParamColor : public Parameter { private: - guint32 _value; + void _onColorChanged(); + + Inkscape::UI::SelectedColor _color; + sigc::connection _color_changed; public: ParamColor(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); virtual ~ParamColor(void); /** Returns \c _value, with a \i const to protect it. */ - guint32 get( SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/ ) const { return _value; } + guint32 get( SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/ ) const { return _color.value(); } guint32 set (guint32 in, SPDocument * doc, Inkscape::XML::Node * node); @@ -44,6 +48,7 @@ public: virtual void string (std::string &string) const; sigc::signal<void> * _changeSignal; + }; // class ParamColor } // namespace Extension diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 202b8110f..8c99ee55d 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -15,6 +15,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #ifdef linux // does the dollar sign need escaping when passed as string parameter? # define ESCAPE_DOLLAR_COMMANDLINE #endif @@ -26,8 +30,7 @@ #include "document-private.h" #include "sp-object.h" #include <color.h> -#include "widgets/sp-color-selector.h" -#include "widgets/sp-color-notebook.h" +#include "ui/widget/color-notebook.h" #include "parameter.h" #include "bool.h" |
