summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-10-26 12:33:17 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-10-26 12:33:17 +0000
commit7caf32d2b22680c603e4e88c76739c758630412c (patch)
treedaaf4e77d712bd802076980d7a077dc6562f3df7 /src
parentRemoved BSpline from tell by su_v (diff)
parentFix memleak in reference counting introduced in r12532. (diff)
downloadinkscape-7caf32d2b22680c603e4e88c76739c758630412c.tar.gz
inkscape-7caf32d2b22680c603e4e88c76739c758630412c.zip
Update to trunk
(bzr r12588.1.24)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/line.h1
-rw-r--r--src/2geom/ray.h26
-rw-r--r--src/2geom/transforms.h1
-rw-r--r--src/color-profile.cpp38
-rw-r--r--src/conn-avoid-ref.cpp30
-rw-r--r--src/desktop.cpp2
-rw-r--r--src/document.cpp34
-rw-r--r--src/document.h3
-rw-r--r--src/extension/dbus/Makefile_insert3
-rw-r--r--src/extension/internal/cdr-input.cpp2
-rw-r--r--src/extension/internal/emf-inout.cpp25
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp2
-rw-r--r--src/extension/internal/image-resolution.cpp11
-rw-r--r--src/extension/internal/pdf-input-cairo.cpp2
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp2
-rw-r--r--src/extension/internal/vsd-input.cpp2
-rw-r--r--src/extension/internal/wmf-inout.cpp12
-rw-r--r--src/extension/internal/wmf-print.cpp5
-rw-r--r--src/extension/internal/wpg-input.cpp2
-rw-r--r--src/file.cpp2
-rw-r--r--src/flood-context.cpp2
-rw-r--r--src/gradient-drag.cpp2
-rw-r--r--src/interface.cpp2
-rw-r--r--src/io/uristream.cpp44
-rw-r--r--src/io/uristream.h44
-rw-r--r--src/io/xsltstream.cpp20
-rw-r--r--src/io/xsltstream.h24
-rw-r--r--src/libcola/cola.cpp12
-rw-r--r--src/libcola/gradient_projection.h23
-rw-r--r--src/libcola/straightener.cpp2
-rw-r--r--src/libcola/straightener.h4
-rw-r--r--src/libdepixelize/priv/point.h4
-rw-r--r--src/libgdl/gdl-dock-object.h2
-rw-r--r--src/libnrtype/TextWrapper.cpp84
-rw-r--r--src/libuemf/uemf.c2
-rw-r--r--src/libuemf/uemf.h1
-rw-r--r--src/libuemf/uemf_print.c2
-rw-r--r--src/libvpsc/constraint.cpp4
-rw-r--r--src/libvpsc/solve_VPSC.cpp12
-rw-r--r--src/livarot/PathOutline.cpp4
-rw-r--r--src/livarot/Shape.cpp4
-rw-r--r--src/seltrans.cpp2
-rw-r--r--src/sp-gradient.cpp29
-rw-r--r--src/sp-namedview.cpp5
-rw-r--r--src/sp-namedview.h1
-rw-r--r--src/sp-object.cpp9
-rw-r--r--src/sp-polygon.cpp2
-rw-r--r--src/sp-rect.cpp2
-rw-r--r--src/sp-root.cpp2
-rw-r--r--src/sp-root.h2
-rw-r--r--src/ui/dialog/document-properties.cpp22
-rw-r--r--src/ui/dialog/pixelartdialog.cpp2
-rw-r--r--src/xml/repr-io.cpp11
53 files changed, 387 insertions, 205 deletions
diff --git a/src/2geom/line.h b/src/2geom/line.h
index f2d31ecc6..ade67f818 100644
--- a/src/2geom/line.h
+++ b/src/2geom/line.h
@@ -41,6 +41,7 @@
#include <2geom/crossing.h>
#include <2geom/exception.h>
#include <2geom/ray.h>
+#include <2geom/angle.h>
namespace Geom
{
diff --git a/src/2geom/ray.h b/src/2geom/ray.h
index 75cc72005..2fda06ff5 100644
--- a/src/2geom/ray.h
+++ b/src/2geom/ray.h
@@ -36,6 +36,8 @@
#include <2geom/bezier-curve.h> // for LineSegment
#include <2geom/exception.h>
#include <2geom/math-utils.h>
+#include <2geom/transforms.h>
+#include <2geom/angle.h>
namespace Geom
{
@@ -146,17 +148,31 @@ double angle_between(Ray const& r1, Ray const& r2, bool cw = true) {
return angle;
}
+/**
+ * @brief Returns the angle bisector for the two given rays.
+ *
+ * @a r1 is rotated half the way to @a r2 in either clockwise or counter-clockwise direction.
+ *
+ * @pre Both passed rays must have the same origin.
+ *
+ * @remarks If the versors of both given rays point in the same direction, the direction of the
+ * angle bisector ray depends on the third parameter:
+ * - If @a cw is set to @c true, the returned ray will equal the passed rays @a r1 and @a r2.
+ * - If @a cw is set to @c false, the returned ray will go in the opposite direction.
+ *
+ * @throws RangeError if the given rays do not have the same origins
+ */
inline
-Ray make_angle_bisector_ray(Ray const& r1, Ray const& r2)
+Ray make_angle_bisector_ray(Ray const& r1, Ray const& r2, bool cw = true)
{
if ( !are_near(r1.origin(), r2.origin()) )
{
- THROW_RANGEERROR("passed rays have not the same origin");
+ THROW_RANGEERROR("passed rays do not have the same origin");
}
- Point M = middle_point(r1.pointAt(1), r2.pointAt(1) );
- if (angle_between(r1, r2) > M_PI) M = 2 * r1.origin() - M;
- return Ray(r1.origin(), M);
+ Ray bisector(r1.origin(), r1.origin() + r1.versor() * Rotate(angle_between(r1, r2) / 2.0));
+
+ return (cw ? bisector : bisector.reverse());
}
} // end namespace Geom
diff --git a/src/2geom/transforms.h b/src/2geom/transforms.h
index 869e955c7..7f5635747 100644
--- a/src/2geom/transforms.h
+++ b/src/2geom/transforms.h
@@ -39,6 +39,7 @@
#include <cmath>
#include <2geom/forward.h>
#include <2geom/affine.h>
+#include <2geom/angle.h>
namespace Geom {
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index f0a06f73b..b18112ece 100644
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
@@ -1165,13 +1165,24 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayTransform()
cmsUInt32Number dwFlags = cmsFLAGS_SOFTPROOFING;
if ( gamutWarn ) {
dwFlags |= cmsFLAGS_GAMUTCHECK;
+
+#if WITH_GTKMM_3_0
+ gushort gamutColor_r = gamutColor.get_red_u();
+ gushort gamutColor_g = gamutColor.get_green_u();
+ gushort gamutColor_b = gamutColor.get_blue_u();
+#else
+ gushort gamutColor_r = gamutColor.get_red();
+ gushort gamutColor_g = gamutColor.get_green();
+ gushort gamutColor_b = gamutColor.get_blue();
+#endif
+
#if HAVE_LIBLCMS1
- cmsSetAlarmCodes(gamutColor.get_red() >> 8, gamutColor.get_green() >> 8, gamutColor.get_blue() >> 8);
+ cmsSetAlarmCodes(gamutColor_r >> 8, gamutColor_g >> 8, gamutColor_b >> 8);
#elif HAVE_LIBLCMS2
cmsUInt16Number newAlarmCodes[cmsMAXCHANNELS] = {0};
- newAlarmCodes[0] = gamutColor.get_red();
- newAlarmCodes[1] = gamutColor.get_green();
- newAlarmCodes[2] = gamutColor.get_blue();
+ newAlarmCodes[0] = gamutColor_r;
+ newAlarmCodes[1] = gamutColor_g;
+ newAlarmCodes[2] = gamutColor_b;
newAlarmCodes[3] = ~0;
cmsSetAlarmCodes(newAlarmCodes);
#endif
@@ -1339,13 +1350,24 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayPer( Glib::ustring const& id )
cmsUInt32Number dwFlags = cmsFLAGS_SOFTPROOFING;
if ( gamutWarn ) {
dwFlags |= cmsFLAGS_GAMUTCHECK;
+
+#if WITH_GTKMM_3_0
+ gushort gamutColor_r = gamutColor.get_red_u();
+ gushort gamutColor_g = gamutColor.get_green_u();
+ gushort gamutColor_b = gamutColor.get_blue_u();
+#else
+ gushort gamutColor_r = gamutColor.get_red();
+ gushort gamutColor_g = gamutColor.get_green();
+ gushort gamutColor_b = gamutColor.get_blue();
+#endif
+
#if HAVE_LIBLCMS1
- cmsSetAlarmCodes(gamutColor.get_red() >> 8, gamutColor.get_green() >> 8, gamutColor.get_blue() >> 8);
+ cmsSetAlarmCodes(gamutColor_r >> 8, gamutColor_g >> 8, gamutColor_b >> 8);
#elif HAVE_LIBLCMS2
cmsUInt16Number newAlarmCodes[cmsMAXCHANNELS] = {0};
- newAlarmCodes[0] = gamutColor.get_red();
- newAlarmCodes[1] = gamutColor.get_green();
- newAlarmCodes[2] = gamutColor.get_blue();
+ newAlarmCodes[0] = gamutColor_r;
+ newAlarmCodes[1] = gamutColor_g;
+ newAlarmCodes[2] = gamutColor_b;
newAlarmCodes[3] = ~0;
cmsSetAlarmCodes(newAlarmCodes);
#endif
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index c0d05e3c4..cb72f65dc 100644
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
@@ -303,23 +303,29 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item)
Geom::Line parallel_hull_edge;
parallel_hull_edge.setOrigin(hull_edge.origin()+hull_edge.versor().ccw()*spacing);
parallel_hull_edge.setVersor(hull_edge.versor());
-
+
// determine the intersection point
-
- Geom::OptCrossing int_pt = Geom::intersection(parallel_hull_edge, prev_parallel_hull_edge);
- if (int_pt)
- {
- Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
- (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);
- poly.ps.push_back(avoid_pt);
+ try {
+ Geom::OptCrossing int_pt = Geom::intersection(parallel_hull_edge, prev_parallel_hull_edge);
+ if (int_pt)
+ {
+ Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
+ (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);
+ poly.ps.push_back(avoid_pt);
+ }
+ else
+ {
+ // something went wrong...
+ std::cout<<"conn-avoid-ref.cpp: avoid_item_poly: Geom:intersection failed."<<std::endl;
+ }
}
- else
- {
- // something went wrong...
- std::cout<<"conn-avoid-ref.cpp: avoid_item_poly: Geom:intersection failed."<<std::endl;
+ catch (Geom::InfiniteSolutions const &e) {
+ // the parallel_hull_edge and prev_parallel_hull_edge lie on top of each other, hence infinite crossings
+ g_message("conn-avoid-ref.cpp: trying to get crossings of identical lines");
}
prev_parallel_hull_edge = parallel_hull_edge;
}
+
return poly;
}
diff --git a/src/desktop.cpp b/src/desktop.cpp
index dbad37b92..f5c35514c 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -1930,7 +1930,7 @@ SPDesktop::show_dialogs()
mapVerbPreference.insert(std::make_pair ("SpellCheck", "/dialogs/spellcheck") );
mapVerbPreference.insert(std::make_pair ("Symbols", "/dialogs/symbols") );
- for (std::map<Glib::ustring, Glib::ustring>::const_iterator iter = mapVerbPreference.begin(); iter != mapVerbPreference.end(); iter++) {
+ for (std::map<Glib::ustring, Glib::ustring>::const_iterator iter = mapVerbPreference.begin(); iter != mapVerbPreference.end(); ++iter) {
Glib::ustring pref = iter->second;
int visible = prefs->getInt(pref + "/visible", 0);
if (visible) {
diff --git a/src/document.cpp b/src/document.cpp
index 4f57cf080..3433e42ec 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -84,6 +84,7 @@ static gint sp_document_rerouting_handler(gpointer data);
gboolean sp_document_resource_list_free(gpointer key, gpointer value, gpointer data);
static gint doc_count = 0;
+static gint doc_mem_count = 0;
static unsigned long next_serial = 0;
@@ -500,15 +501,18 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b
base = NULL;
name = g_strdup(uri);
}
+ if (make_new) {
+ base = NULL;
+ uri = NULL;
+ name = g_strdup_printf(_("New document %d"), ++doc_count);
+ }
g_free(s);
} else {
- rdoc = sp_repr_document_new("svg:svg");
- }
+ if (make_new) {
+ name = g_strdup_printf(_("Memory document %d"), ++doc_mem_count);
+ }
- if (make_new) {
- base = NULL;
- uri = NULL;
- name = g_strdup_printf(_("New document %d"), ++doc_count);
+ rdoc = sp_repr_document_new("svg:svg");
}
//# These should be set by now
@@ -534,7 +538,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un
// If xml file is not svg, return NULL without warning
// TODO fixme: destroy document
} else {
- Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_count );
+ Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_mem_count );
doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive);
}
}
@@ -554,6 +558,13 @@ SPDocument *SPDocument::doUnref()
return NULL;
}
+/// guaranteed not to return nullptr
+Inkscape::Util::Unit const* SPDocument::getDefaultUnit() const
+{
+ SPNamedView const* nv = sp_document_namedview(this, NULL);
+ return nv ? nv->getDefaultUnit() : unit_table.getUnit("pt");
+}
+
Inkscape::Util::Quantity SPDocument::getWidth() const
{
g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit("")));
@@ -668,7 +679,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins)
double margin_right = 0.0;
double margin_bottom = 0.0;
- SPNamedView *nv = sp_document_namedview(this, 0);
+ SPNamedView *nv = sp_document_namedview(this, NULL);
if (with_margins && nv) {
if (nv != NULL) {
@@ -1471,9 +1482,10 @@ void SPDocument::setModifiedSinceSave(bool modified) {
this->modified_since_save = modified;
if (SP_ACTIVE_DESKTOP) {
Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel();
- g_assert(parent != NULL);
- SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget"));
- dtw->updateTitle( this->getName() );
+ if (parent) { // during load, SP_ACTIVE_DESKTOP may be !nullptr, but parent might still be nullptr
+ SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget"));
+ dtw->updateTitle( this->getName() );
+ }
}
}
diff --git a/src/document.h b/src/document.h
index 948b5b867..0977fc7a8 100644
--- a/src/document.h
+++ b/src/document.h
@@ -47,6 +47,7 @@ namespace Inkscape {
class Node;
}
namespace Util {
+ class Unit;
class Quantity;
}
}
@@ -123,6 +124,7 @@ public:
/** Returns our SPRoot */
SPRoot *getRoot() { return root; }
+ SPRoot const *getRoot() const { return root; }
Inkscape::XML::Node *getReprRoot() { return rroot; }
@@ -227,6 +229,7 @@ public:
SPDocument *doRef();
SPDocument *doUnref();
+ Inkscape::Util::Unit const* getDefaultUnit() const;
Inkscape::Util::Quantity getWidth() const;
Inkscape::Util::Quantity getHeight() const;
Geom::Point getDimensions() const;
diff --git a/src/extension/dbus/Makefile_insert b/src/extension/dbus/Makefile_insert
index a5eb3fdf4..7d851715e 100644
--- a/src/extension/dbus/Makefile_insert
+++ b/src/extension/dbus/Makefile_insert
@@ -12,7 +12,8 @@ ink_common_sources += \
extension/dbus/application-interface.cpp \
extension/dbus/application-interface.h \
extension/dbus/document-interface.cpp \
- extension/dbus/document-interface.h
+ extension/dbus/document-interface.h \
+ extension/dbus/org.inkscape.service.in
###########################
# Build DBus wrapper files
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
index 517d6fb9c..04087e268 100644
--- a/src/extension/internal/cdr-input.cpp
+++ b/src/extension/internal/cdr-input.cpp
@@ -258,7 +258,7 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
return doc;
}
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index f1876c687..36d7ca145 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -789,8 +789,12 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType)
// Assume src color is "white"
if(d->dwRop3){
switch(d->dwRop3){
- case U_PATINVERT: // treat all of these as black
- case U_SRCINVERT:
+ case U_PATINVERT: // invert pattern
+ fill_rgb[0] = 1.0 - fill_rgb[0];
+ fill_rgb[1] = 1.0 - fill_rgb[1];
+ fill_rgb[2] = 1.0 - fill_rgb[2];
+ break;
+ case U_SRCINVERT: // treat all of these as black
case U_DSTINVERT:
case U_BLACKNESS:
case U_SRCERASE:
@@ -799,7 +803,6 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType)
break;
case U_SRCCOPY: // treat all of these as white
case U_NOTSRCERASE:
- case U_PATCOPY:
case U_WHITENESS:
fill_rgb[0]=fill_rgb[1]=fill_rgb[2]=1.0;
break;
@@ -808,6 +811,7 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType)
case U_MERGECOPY:
case U_MERGEPAINT:
case U_PATPAINT:
+ case U_PATCOPY:
default:
break;
}
@@ -2747,7 +2751,10 @@ std::cout << "BEFORE DRAW"
{
dbg_str << "<!-- U_EMR_BEGINPATH -->\n";
// The next line should never be needed, should have been handled before main switch
- *(d->path) = "";
+ // qualifier added because EMF's encountered where moveto preceded beginpath followed by lineto
+ if(d->mask & U_DRAW_VISIBLE){
+ *(d->path) = "";
+ }
d->mask |= emr_mask;
break;
}
@@ -2859,6 +2866,7 @@ std::cout << "BEFORE DRAW"
if (!pEmr->cbBmiSrc) {
// should be an application of a DIBPATTERNBRUSHPT, use a solid color instead
+ if(pEmr->dwRop == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */
int32_t dx = pEmr->Dest.x;
int32_t dy = pEmr->Dest.y;
int32_t dw = pEmr->cDest.x;
@@ -3497,12 +3505,13 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
// Set document unit
Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr();
Inkscape::SVGOStringStream os;
- os << doc->getWidth().unit->abbr;
+ Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit;
+ os << doc_unit->abbr;
repr->setAttribute("inkscape:document-units", os.str().c_str());
-
+
// Set viewBox
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
-
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit)));
+
// Scale and translate objects
double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit);
ShapeEditor::blockSetItem(true);
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index 13267ee2b..6d159d265 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -105,7 +105,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
// restore undo, as now this document may be shown to the user if a bitmap was opened
diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp
index b38b0ddc7..865e86698 100644
--- a/src/extension/internal/image-resolution.cpp
+++ b/src/extension/internal/image-resolution.cpp
@@ -342,9 +342,16 @@ void ImageResolution::readmagick(char const *fn) {
image.read(fn);
} catch (...) {}
Magick::Geometry geo = image.density();
+ std::string type = image.magick();
+
+ if (type == "PNG") { // PNG only supports pixelspercentimeter
+ x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "in", "cm");
+ y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "in", "cm");
+ } else {
+ x_ = (double)geo.width();
+ y_ = (double)geo.height();
+ }
- x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "pt", "px");
- y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "pt", "px");
ok_ = true;
}
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
index adac0d6c9..f47fbaf87 100644
--- a/src/extension/internal/pdf-input-cairo.cpp
+++ b/src/extension/internal/pdf-input-cairo.cpp
@@ -626,7 +626,7 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
delete output;
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 213550688..3155ac098 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -750,7 +750,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
// Restore undo
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
index 42a9e3d41..6fc79237b 100644
--- a/src/extension/internal/vsd-input.cpp
+++ b/src/extension/internal/vsd-input.cpp
@@ -258,7 +258,7 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
return doc;
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index d69d46f20..2e55dcb1e 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -1970,7 +1970,9 @@ std::cout << "BEFORE DRAW"
}
if (!d->dc[d->level].sizeView.x || !d->dc[d->level].sizeView.y) {
- d->dc[d->level].sizeView = d->dc[d->level].sizeWnd;
+ /* Previously it used sizeWnd, but that always resulted in scale = 1 if no viewport ever appeared, and in most files, it did not */
+ d->dc[d->level].sizeView.x = d->PixelsInX - 1;
+ d->dc[d->level].sizeView.y = d->PixelsInY - 1;
}
/* scales logical to WMF pixels, transfer a negative sign on Y, if any */
@@ -2284,6 +2286,7 @@ std::cout << "BEFORE DRAW"
dbg_str << "<!-- U_WMR_BITBLT -->\n";
nSize = U_WMRBITBLT_get(contents,&Dst,&cwh,&Src,&dwRop3,&Bm16,&px);
if(!px){
+ if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */
int32_t dx = Dst.x;
int32_t dy = Dst.y;
int32_t dw = cwh.x;
@@ -2321,6 +2324,7 @@ std::cout << "BEFORE DRAW"
dbg_str << "<!-- U_WMR_STRETCHBLT -->\n";
nSize = U_WMRSTRETCHBLT_get(contents,&Dst,&cDst,&Src,&cSrc,&dwRop3,&Bm16,&px);
if(!px){
+ if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */
int32_t dx = Dst.x;
int32_t dy = Dst.y;
int32_t dw = cDst.x;
@@ -2715,6 +2719,7 @@ std::cout << "BEFORE DRAW"
if (!dib) {
// should be an application of a DIBPATTERNBRUSHPT, use a solid color instead
+ if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */
int32_t dx = Dst.x;
int32_t dy = Dst.y;
int32_t dw = cwh.x;
@@ -3185,11 +3190,12 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
// Set document unit
Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr();
Inkscape::SVGOStringStream os;
- os << doc->getWidth().unit->abbr;
+ Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit;
+ os << doc_unit->abbr;
repr->setAttribute("inkscape:document-units", os.str().c_str());
// Set viewBox
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit)));
// Scale and translate objects
double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit);
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index cf0302b38..3bb17146c 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -1120,6 +1120,9 @@ unsigned int PrintWmf::image(
Geom::Point pLL(x1, y1);
Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates
+ Geom::Point pWH(dw, dh);
+ Geom::Point pWH2 = pWH * tf.withoutTranslation(); //adjust scale
+
char *px;
uint32_t cbPx;
uint32_t colortype;
@@ -1133,7 +1136,7 @@ unsigned int PrintWmf::image(
Bmi = bitmapinfo_set(Bmih, ct);
U_POINT16 Dest = point16_set(round(pLL2[Geom::X] * PX2WORLD), round(pLL2[Geom::Y] * PX2WORLD));
- U_POINT16 cDest = point16_set(round(dw * PX2WORLD), round(dh * PX2WORLD));
+ U_POINT16 cDest = point16_set(round(pWH2[Geom::X] * PX2WORLD), round(pWH2[Geom::Y] * PX2WORLD));
U_POINT16 Src = point16_set(0, 0);
U_POINT16 cSrc = point16_set(w, h);
rec = U_WMRSTRETCHDIB_set(
diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp
index ac86a6171..b5eb3ce8f 100644
--- a/src/extension/internal/wpg-input.cpp
+++ b/src/extension/internal/wpg-input.cpp
@@ -114,7 +114,7 @@ SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
delete input;
diff --git a/src/file.cpp b/src/file.cpp
index 8a7b177c0..f978ec66e 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -144,7 +144,7 @@ SPDesktop *sp_file_new(const std::string &templ)
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
DocumentUndo::setUndoSensitive(doc, false);
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
DocumentUndo::setUndoSensitive(doc, true);
}
diff --git a/src/flood-context.cpp b/src/flood-context.cpp
index 28aedba6e..dc89fb0a9 100644
--- a/src/flood-context.cpp
+++ b/src/flood-context.cpp
@@ -955,7 +955,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
unsigned int sort_y = (unsigned int)cp[Geom::Y];
unsigned int current_y = sort_y;
- for (std::deque<Geom::Point>::iterator i = fill_queue.begin(); i != fill_queue.end(); i++) {
+ for (std::deque<Geom::Point>::iterator i = fill_queue.begin(); i != fill_queue.end(); ++i) {
Geom::Point current = *i;
current_y = (unsigned int)current[Geom::Y];
if (current_y != sort_y) {
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index b3622107b..0b250fe52 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -879,7 +879,7 @@ static void gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, gui
if (!bsp.getSnapped()) {
// If we didn't truly snap to an object or to a grid, then we will still have to look for the
// closest projection onto one of the constraints. findBestSnap() will not do this for us
- for (std::list<Inkscape::SnappedPoint>::const_iterator i = isr.points.begin(); i != isr.points.end(); i++) {
+ for (std::list<Inkscape::SnappedPoint>::const_iterator i = isr.points.begin(); i != isr.points.end(); ++i) {
if (i == isr.points.begin() || (Geom::L2((*i).getPoint() - p) < Geom::L2(bsp.getPoint() - p))) {
bsp.setPoint((*i).getPoint());
bsp.setTarget(Inkscape::SNAPTARGET_CONSTRAINED_ANGLE);
diff --git a/src/interface.cpp b/src/interface.cpp
index e57092e2b..f411989ce 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -324,7 +324,7 @@ sp_ui_close_view(GtkWidget */*widget*/)
SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true );
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
dt->change_document(doc);
sp_namedview_window_from_document(dt);
diff --git a/src/io/uristream.cpp b/src/io/uristream.cpp
index 37c13ada0..5d2eb59ee 100644
--- a/src/io/uristream.cpp
+++ b/src/io/uristream.cpp
@@ -89,7 +89,7 @@ static FILE *fopen_utf8name( char const *utf8name, int mode )
*
*/
UriInputStream::UriInputStream(Inkscape::URI &source)
- throw (StreamException): uri(source)
+ : uri(source)
{
//get information from uri
char const *schemestr = uri.getScheme();
@@ -130,7 +130,7 @@ UriInputStream::UriInputStream(Inkscape::URI &source)
*
*/
UriInputStream::UriInputStream(FILE *source, Inkscape::URI &uri)
- throw (StreamException): uri(uri),
+ : uri(uri),
inf(source),
data(0),
dataPos(0),
@@ -147,7 +147,7 @@ UriInputStream::UriInputStream(FILE *source, Inkscape::URI &uri)
/**
*
*/
-UriInputStream::~UriInputStream() throw(StreamException)
+UriInputStream::~UriInputStream()
{
close();
}
@@ -157,7 +157,7 @@ UriInputStream::~UriInputStream() throw(StreamException)
* this input stream without blocking by the next caller of a method for
* this input stream.
*/
-int UriInputStream::available() throw(StreamException)
+int UriInputStream::available()
{
return 0;
}
@@ -167,7 +167,7 @@ int UriInputStream::available() throw(StreamException)
* Closes this input stream and releases any system resources
* associated with the stream.
*/
-void UriInputStream::close() throw(StreamException)
+void UriInputStream::close()
{
if (closed)
return;
@@ -194,7 +194,7 @@ void UriInputStream::close() throw(StreamException)
/**
* Reads the next byte of data from the input stream. -1 if EOF
*/
-int UriInputStream::get() throw(StreamException)
+int UriInputStream::get()
{
int retVal = -1;
if (!closed)
@@ -236,7 +236,7 @@ int UriInputStream::get() throw(StreamException)
*
*/
UriReader::UriReader(Inkscape::URI &uri)
- throw (StreamException)
+
{
inputStream = new UriInputStream(uri);
}
@@ -244,7 +244,7 @@ UriReader::UriReader(Inkscape::URI &uri)
/**
*
*/
-UriReader::~UriReader() throw (StreamException)
+UriReader::~UriReader()
{
delete inputStream;
}
@@ -252,7 +252,7 @@ UriReader::~UriReader() throw (StreamException)
/**
*
*/
-int UriReader::available() throw(StreamException)
+int UriReader::available()
{
return inputStream->available();
}
@@ -260,7 +260,7 @@ int UriReader::available() throw(StreamException)
/**
*
*/
-void UriReader::close() throw(StreamException)
+void UriReader::close()
{
inputStream->close();
}
@@ -268,7 +268,7 @@ void UriReader::close() throw(StreamException)
/**
*
*/
-gunichar UriReader::get() throw(StreamException)
+gunichar UriReader::get()
{
gunichar ch = (gunichar)inputStream->get();
return ch;
@@ -283,7 +283,7 @@ gunichar UriReader::get() throw(StreamException)
* Temporary kludge
*/
UriOutputStream::UriOutputStream(FILE* fp, Inkscape::URI &destination)
- throw (StreamException): closed(false),
+ : closed(false),
ownsFile(false),
outf(fp),
uri(destination),
@@ -299,7 +299,7 @@ UriOutputStream::UriOutputStream(FILE* fp, Inkscape::URI &destination)
*
*/
UriOutputStream::UriOutputStream(Inkscape::URI &destination)
- throw (StreamException): closed(false),
+ : closed(false),
ownsFile(true),
outf(NULL),
uri(destination),
@@ -340,7 +340,7 @@ UriOutputStream::UriOutputStream(Inkscape::URI &destination)
/**
*
*/
-UriOutputStream::~UriOutputStream() throw(StreamException)
+UriOutputStream::~UriOutputStream()
{
close();
}
@@ -349,7 +349,7 @@ UriOutputStream::~UriOutputStream() throw(StreamException)
* Closes this output stream and releases any system resources
* associated with this stream.
*/
-void UriOutputStream::close() throw(StreamException)
+void UriOutputStream::close()
{
if (closed)
return;
@@ -378,7 +378,7 @@ void UriOutputStream::close() throw(StreamException)
* Flushes this output stream and forces any buffered output
* bytes to be written out.
*/
-void UriOutputStream::flush() throw(StreamException)
+void UriOutputStream::flush()
{
if (closed)
return;
@@ -402,7 +402,7 @@ void UriOutputStream::flush() throw(StreamException)
/**
* Writes the specified byte to this output stream.
*/
-int UriOutputStream::put(gunichar ch) throw(StreamException)
+int UriOutputStream::put(gunichar ch)
{
if (closed)
return -1;
@@ -436,7 +436,7 @@ int UriOutputStream::put(gunichar ch) throw(StreamException)
*
*/
UriWriter::UriWriter(Inkscape::URI &uri)
- throw (StreamException)
+
{
outputStream = new UriOutputStream(uri);
}
@@ -444,7 +444,7 @@ UriWriter::UriWriter(Inkscape::URI &uri)
/**
*
*/
-UriWriter::~UriWriter() throw (StreamException)
+UriWriter::~UriWriter()
{
delete outputStream;
}
@@ -452,7 +452,7 @@ UriWriter::~UriWriter() throw (StreamException)
/**
*
*/
-void UriWriter::close() throw(StreamException)
+void UriWriter::close()
{
outputStream->close();
}
@@ -460,7 +460,7 @@ void UriWriter::close() throw(StreamException)
/**
*
*/
-void UriWriter::flush() throw(StreamException)
+void UriWriter::flush()
{
outputStream->flush();
}
@@ -468,7 +468,7 @@ void UriWriter::flush() throw(StreamException)
/**
*
*/
-void UriWriter::put(gunichar ch) throw(StreamException)
+void UriWriter::put(gunichar ch)
{
outputStream->put(ch);
}
diff --git a/src/io/uristream.h b/src/io/uristream.h
index 3080519de..92fc0f76f 100644
--- a/src/io/uristream.h
+++ b/src/io/uristream.h
@@ -37,17 +37,17 @@ class UriInputStream : public InputStream
{
public:
- UriInputStream(FILE *source, Inkscape::URI &uri) throw(StreamException);
+ UriInputStream(FILE *source, Inkscape::URI &uri);
- UriInputStream(Inkscape::URI &source) throw(StreamException);
+ UriInputStream(Inkscape::URI &source);
- virtual ~UriInputStream() throw(StreamException);
+ virtual ~UriInputStream();
- virtual int available() throw(StreamException);
+ virtual int available();
- virtual void close() throw(StreamException);
+ virtual void close();
- virtual int get() throw(StreamException);
+ virtual int get();
private:
Inkscape::URI &uri;
@@ -73,15 +73,15 @@ class UriReader : public BasicReader
public:
- UriReader(Inkscape::URI &source) throw(StreamException);
+ UriReader(Inkscape::URI &source);
- virtual ~UriReader() throw(StreamException);
+ virtual ~UriReader();
- virtual int available() throw(StreamException);
+ virtual int available();
- virtual void close() throw(StreamException);
+ virtual void close();
- virtual gunichar get() throw(StreamException);
+ virtual gunichar get();
private:
@@ -105,17 +105,17 @@ class UriOutputStream : public OutputStream
public:
- UriOutputStream(FILE *fp, Inkscape::URI &destination) throw(StreamException);
+ UriOutputStream(FILE *fp, Inkscape::URI &destination);
- UriOutputStream(Inkscape::URI &destination) throw(StreamException);
+ UriOutputStream(Inkscape::URI &destination);
- virtual ~UriOutputStream() throw(StreamException);
+ virtual ~UriOutputStream();
- virtual void close() throw(StreamException);
+ virtual void close();
- virtual void flush() throw(StreamException);
+ virtual void flush();
- virtual int put(gunichar ch) throw(StreamException);
+ virtual int put(gunichar ch);
private:
@@ -144,15 +144,15 @@ class UriWriter : public BasicWriter
public:
- UriWriter(Inkscape::URI &source) throw(StreamException);
+ UriWriter(Inkscape::URI &source);
- virtual ~UriWriter() throw(StreamException);
+ virtual ~UriWriter();
- virtual void close() throw(StreamException);
+ virtual void close();
- virtual void flush() throw(StreamException);
+ virtual void flush();
- virtual void put(gunichar ch) throw(StreamException);
+ virtual void put(gunichar ch);
private:
diff --git a/src/io/xsltstream.cpp b/src/io/xsltstream.cpp
index 7a6632233..531647769 100644
--- a/src/io/xsltstream.cpp
+++ b/src/io/xsltstream.cpp
@@ -30,7 +30,7 @@ namespace IO
*
*/
XsltStyleSheet::XsltStyleSheet(InputStream &xsltSource)
- throw (StreamException)
+
: stylesheet(NULL)
{
if (!read(xsltSource)) {
@@ -86,7 +86,6 @@ XsltStyleSheet::~XsltStyleSheet()
*
*/
XsltInputStream::XsltInputStream(InputStream &xmlSource, XsltStyleSheet &sheet)
- throw (StreamException)
: BasicInputStream(xmlSource), stylesheet(sheet)
{
//Load the data
@@ -110,7 +109,7 @@ XsltInputStream::XsltInputStream(InputStream &xmlSource, XsltStyleSheet &sheet)
/**
*
*/
-XsltInputStream::~XsltInputStream() throw (StreamException)
+XsltInputStream::~XsltInputStream()
{
xmlFree(outbuf);
}
@@ -120,7 +119,7 @@ XsltInputStream::~XsltInputStream() throw (StreamException)
* this input stream without blocking by the next caller of a method for
* this input stream.
*/
-int XsltInputStream::available() throw (StreamException)
+int XsltInputStream::available()
{
return outsize - outpos;
}
@@ -130,7 +129,7 @@ int XsltInputStream::available() throw (StreamException)
* Closes this input stream and releases any system resources
* associated with the stream.
*/
-void XsltInputStream::close() throw (StreamException)
+void XsltInputStream::close()
{
closed = true;
}
@@ -138,7 +137,7 @@ void XsltInputStream::close() throw (StreamException)
/**
* Reads the next byte of data from the input stream. -1 if EOF
*/
-int XsltInputStream::get() throw (StreamException)
+int XsltInputStream::get()
{
if (closed)
return -1;
@@ -161,7 +160,6 @@ int XsltInputStream::get() throw (StreamException)
*
*/
XsltOutputStream::XsltOutputStream(OutputStream &dest, XsltStyleSheet &sheet)
- throw (StreamException)
: BasicOutputStream(dest), stylesheet(sheet)
{
flushed = false;
@@ -170,7 +168,7 @@ XsltOutputStream::XsltOutputStream(OutputStream &dest, XsltStyleSheet &sheet)
/**
*
*/
-XsltOutputStream::~XsltOutputStream() throw (StreamException)
+XsltOutputStream::~XsltOutputStream()
{
//do not automatically close
}
@@ -179,7 +177,7 @@ XsltOutputStream::~XsltOutputStream() throw (StreamException)
* Closes this output stream and releases any system resources
* associated with this stream.
*/
-void XsltOutputStream::close() throw (StreamException)
+void XsltOutputStream::close()
{
flush();
destination.close();
@@ -189,7 +187,7 @@ void XsltOutputStream::close() throw (StreamException)
* Flushes this output stream and forces any buffered output
* bytes to be written out.
*/
-void XsltOutputStream::flush() throw (StreamException)
+void XsltOutputStream::flush()
{
if (flushed)
{
@@ -230,7 +228,7 @@ void XsltOutputStream::flush() throw (StreamException)
/**
* Writes the specified byte to this output stream.
*/
-int XsltOutputStream::put(gunichar ch) throw (StreamException)
+int XsltOutputStream::put(gunichar ch)
{
outbuf.push_back(ch);
return 1;
diff --git a/src/io/xsltstream.h b/src/io/xsltstream.h
index 31ee89e10..105e6207a 100644
--- a/src/io/xsltstream.h
+++ b/src/io/xsltstream.h
@@ -39,7 +39,7 @@ public:
/**
* Constructor with loading
*/
- XsltStyleSheet(InputStream &source) throw (StreamException);
+ XsltStyleSheet(InputStream &source);
/**
* Simple constructor, no loading
@@ -74,16 +74,15 @@ class XsltInputStream : public BasicInputStream
public:
- XsltInputStream(InputStream &xmlSource, XsltStyleSheet &stylesheet)
- throw (StreamException);
+ XsltInputStream(InputStream &xmlSource, XsltStyleSheet &stylesheet);
- virtual ~XsltInputStream() throw (StreamException);
+ virtual ~XsltInputStream();
- virtual int available() throw (StreamException);
+ virtual int available();
- virtual void close() throw (StreamException);
+ virtual void close();
- virtual int get() throw (StreamException);
+ virtual int get();
private:
@@ -111,16 +110,15 @@ class XsltOutputStream : public BasicOutputStream
public:
- XsltOutputStream(OutputStream &destination, XsltStyleSheet &stylesheet)
- throw (StreamException);
+ XsltOutputStream(OutputStream &destination, XsltStyleSheet &stylesheet);
- virtual ~XsltOutputStream() throw (StreamException);
+ virtual ~XsltOutputStream();
- virtual void close() throw (StreamException);
+ virtual void close();
- virtual void flush() throw (StreamException);
+ virtual void flush();
- virtual int put(gunichar ch) throw (StreamException);
+ virtual int put(gunichar ch);
private:
diff --git a/src/libcola/cola.cpp b/src/libcola/cola.cpp
index 87fbf9f79..168ef5533 100644
--- a/src/libcola/cola.cpp
+++ b/src/libcola/cola.cpp
@@ -23,7 +23,8 @@ ConstrainedMajorizationLayout
double* eweights,
double idealLength,
TestConvergence& done)
- : constrainedLayout(false),
+ : avoidOverlaps(false),
+ constrainedLayout(false),
n(rs.size()),
lapSize(n), lap2(new double*[lapSize]),
Q(lap2), Dij(new double*[lapSize]),
@@ -116,18 +117,17 @@ void ConstrainedMajorizationLayout::majlayout(
void ConstrainedMajorizationLayout::majlayout(
double** Dij, GradientProjection* gp, double* coords, double* b)
{
- double L_ij,dist_ij,degree;
/* compute the vector b */
/* multiply on-the-fly with distance-based laplacian */
for (unsigned i = 0; i < n; i++) {
- degree = 0;
if(i<lapSize) {
+ double degree = 0;
for (unsigned j = 0; j < lapSize; j++) {
if (j == i) continue;
- dist_ij = euclidean_distance(i, j);
+ double dist_ij = euclidean_distance(i, j);
if (dist_ij > 1e-30 && Dij[i][j] > 1e-30) { /* skip zero distances */
/* calculate L_ij := w_{ij}*d_{ij}/dist_{ij} */
- L_ij = 1.0 / (dist_ij * Dij[i][j]);
+ double L_ij = 1.0 / (dist_ij * Dij[i][j]);
degree -= L_ij;
b[i] += L_ij * coords[j];
}
@@ -271,7 +271,7 @@ void ConstrainedMajorizationLayout::straighten(std::vector<straightener::Edge*>&
double b[n],*coords=dim==HORIZONTAL?X:Y,dist_ub,dist_bv;
std::fill(b,b+n,0);
for(LinearConstraints::iterator i=linearConstraints.begin();
- i!= linearConstraints.end();i++) {
+ i!= linearConstraints.end();++i) {
LinearConstraint* c=*i;
if(straightenToProjection) {
Q[c->u][c->u]+=c->w*c->duu;
diff --git a/src/libcola/gradient_projection.h b/src/libcola/gradient_projection.h
index 8cf45586c..980fa6064 100644
--- a/src/libcola/gradient_projection.h
+++ b/src/libcola/gradient_projection.h
@@ -25,7 +25,12 @@ typedef std::vector<SimpleConstraint*> SimpleConstraints;
class AlignmentConstraint {
friend class GradientProjection;
public:
- AlignmentConstraint(double pos) : position(pos), variable(NULL) {}
+ AlignmentConstraint(double pos) :
+ offsets(),
+ guide(NULL),
+ position(pos),
+ variable(NULL)
+ {}
void updatePosition() {
position = variable->position();
}
@@ -74,7 +79,21 @@ typedef std::vector<std::pair<unsigned, double> > CList;
*/
class DummyVarPair {
public:
- DummyVarPair(double desiredDist) : dist(desiredDist), lap2(1.0/(desiredDist*desiredDist)) { }
+ DummyVarPair(double desiredDist) :
+ leftof(),
+ rightof(),
+ place_l(0),
+ place_r(0),
+ dist(desiredDist),
+ b(0),
+ left(NULL),
+ right(NULL),
+ lap2(1.0/(desiredDist*desiredDist)),
+ g(0),
+ old_place_l(0),
+ old_place_r(0)
+ {}
+
CList leftof; // variables to which left dummy var must be to the left of
CList rightof; // variables to which right dummy var must be to the right of
double place_l;
diff --git a/src/libcola/straightener.cpp b/src/libcola/straightener.cpp
index fab30d48d..9e1ab1809 100644
--- a/src/libcola/straightener.cpp
+++ b/src/libcola/straightener.cpp
@@ -82,7 +82,7 @@ namespace straightener {
double bx=route->xs[i];
double by=route->ys[i];
double t=0;
- list<unsigned>::iterator copyit=j++;
+ list<unsigned>::iterator copyit=++j;
//printf(" px=%f, py=%f, ax=%f, ay=%f, bx=%f, by=%f\n",px,py,ax,ay,bx,by);
if(pointOnLine(px,py,ax,ay,bx,by,t)) {
//printf(" got node %d\n",*copyit);
diff --git a/src/libcola/straightener.h b/src/libcola/straightener.h
index b1ce665f4..927780140 100644
--- a/src/libcola/straightener.h
+++ b/src/libcola/straightener.h
@@ -38,7 +38,7 @@ namespace straightener {
std::vector<unsigned> dummyNodes;
std::vector<unsigned> path;
Edge(unsigned id, unsigned start, unsigned end, Route* route)
- : id(id), startNode(start), endNode(end), route(route)
+ : id(id), openInd(0), startNode(start), endNode(end), route(route)
{
route->boundingBox(xmin,ymin,xmax,ymax);
}
@@ -98,7 +98,7 @@ namespace straightener {
double weight;
bool open;
Node(unsigned id, vpsc::Rectangle* r) :
- id(id),x(r->getCentreX()),y(r->getCentreY()), width(r->width()), height(r->height()),
+ id(id),x(r->getCentreX()),y(r->getCentreY()), scanpos(0), width(r->width()), height(r->height()),
xmin(x-width/2),xmax(x+width/2),
ymin(y-height/2),ymax(y+height/2),
edge(NULL),dummy(false),weight(-0.1),open(false) { }
diff --git a/src/libdepixelize/priv/point.h b/src/libdepixelize/priv/point.h
index dc28a2b84..53babd9dc 100644
--- a/src/libdepixelize/priv/point.h
+++ b/src/libdepixelize/priv/point.h
@@ -30,8 +30,8 @@ namespace Tracer {
template<class T>
struct Point
{
- Point() : visible(true) {}
- Point(T x, T y) : visible(true), x(x), y(y) {}
+ Point() : smooth(false), visible(true) {}
+ Point(T x, T y) : smooth(false), visible(true), x(x), y(y) {}
Point(T x, T y, bool smooth) : smooth(smooth), visible(true), x(x), y(y) {}
Point operator+(const Point &rhs) const
diff --git a/src/libgdl/gdl-dock-object.h b/src/libgdl/gdl-dock-object.h
index eed66e97a..f8b192f35 100644
--- a/src/libgdl/gdl-dock-object.h
+++ b/src/libgdl/gdl-dock-object.h
@@ -207,7 +207,7 @@ GType gdl_dock_object_set_type_for_nick (const gchar *nick,
G_STMT_START { \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_DEBUG, \
- "%s:%d (%s) %s [%p %d%s:%d]: "format, \
+ "%s:%d (%s) %s [%p %d%s:%d]: " format, \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
diff --git a/src/libnrtype/TextWrapper.cpp b/src/libnrtype/TextWrapper.cpp
index 63af17f2e..32877e275 100644
--- a/src/libnrtype/TextWrapper.cpp
+++ b/src/libnrtype/TextWrapper.cpp
@@ -107,8 +107,24 @@ void text_wrapper::AppendUTF8(char const *text, int len)
/* effic: (Not an issue for the sole caller at the time of writing.) This implementation
takes quadratic time if the text is composed of n appends. Use a proper data structure.
STL vector would suffice. */
- utf8_text = (char*)realloc(utf8_text, (utf8_length + nlen + 1) * sizeof(char));
- uni32_codepoint = (int*)realloc(uni32_codepoint, (utf8_length + nlen + 1) * sizeof(int));
+ char *newdata = static_cast<char*>(realloc(utf8_text, (utf8_length + nlen + 1) * sizeof(char)));
+ if (newdata != NULL)
+ {
+ utf8_text = newdata;
+ }
+ else
+ {
+ g_warning("Failed to reallocate utf8_text");
+ }
+ int* newdata2 = static_cast<int*>(realloc(uni32_codepoint, (utf8_length + nlen + 1) * sizeof(int)));
+ if (newdata2 != NULL)
+ {
+ uni32_codepoint = newdata2;
+ }
+ else
+ {
+ g_warning("Failed to reallocate uni32_codepoint");
+ }
// copy the source text in the newly lengthened array
memcpy(utf8_text + utf8_length, text, nlen * sizeof(char));
@@ -164,11 +180,27 @@ void text_wrapper::AppendUTF8(char const *text, int len)
// so setting the dx to 0 is mandatory
if ( uni32_length > last_addition ) {
if ( kern_x ) {
- kern_x = (double*)realloc(kern_x, (uni32_length + 1) * sizeof(double));
+ double *newdata = static_cast<double*>(realloc(kern_x, (uni32_length + 1) * sizeof(double)));
+ if (newdata != NULL)
+ {
+ kern_x = newdata;
+ }
+ else
+ {
+ g_warning("Failed to reallocate kern_x");
+ }
for (int i = last_addition; i <= uni32_length; i++) kern_x[i] = 0;
}
if ( kern_y ) {
- kern_y = (double*)realloc(kern_y, (uni32_length + 1) * sizeof(double));
+ double *newdata = static_cast<double*>(realloc(kern_y, (uni32_length + 1) * sizeof(double)));
+ if (newdata != NULL)
+ {
+ kern_y = newdata;
+ }
+ else
+ {
+ g_warning("Failed to reallocate kern_y");
+ }
for (int i = last_addition; i <= uni32_length; i++) kern_y[i] = 0;
}
}
@@ -214,7 +246,15 @@ void text_wrapper::DoLayout(void)
// realloc the structures
if ( glyph_length >= max_g ) {
max_g = 2 * glyph_length + 1;
- glyph_text = (one_glyph*)realloc(glyph_text, (max_g + 1) * sizeof(one_glyph));
+ one_glyph *newdata = static_cast<one_glyph*>(realloc(glyph_text, (max_g + 1) * sizeof(one_glyph)));
+ if (newdata != NULL)
+ {
+ glyph_text = newdata;
+ }
+ else
+ {
+ g_warning("Failed to reallocate glyph_text");
+ }
}
// fill the glyph info
glyph_text[glyph_length].font = pRun->item->analysis.font;
@@ -354,7 +394,15 @@ void text_wrapper::ChunkText(void)
} while ( n_en < g_en && glyph_text[n_en].font == curPF );
if ( nbBox >= maxBox ) {
maxBox = 2 * nbBox + 1;
- boxes = (one_box*)realloc(boxes, maxBox * sizeof(one_box));
+ one_box *newdata = static_cast<one_box*>(realloc(boxes, maxBox * sizeof(one_box)));
+ if (newdata != NULL)
+ {
+ boxes = newdata;
+ }
+ else
+ {
+ g_warning("Failed to reallocate boxes");
+ }
}
boxes[nbBox].g_st = n_st;
boxes[nbBox].g_en = n_en;
@@ -378,7 +426,15 @@ void text_wrapper::ChunkText(void)
if ( b_en < nbBox && boxes[b_en].g_en == g_en ) {
if ( nbPara >= maxPara ) {
maxPara = 2 * nbPara + 1;
- paras = (one_para*)realloc(paras, maxPara * sizeof(one_para));
+ one_para *newdata = static_cast<one_para*>(realloc(paras, maxPara * sizeof(one_para)));
+ if (newdata != NULL)
+ {
+ paras = newdata;
+ }
+ else
+ {
+ g_warning("Failed to reallocate paras");
+ }
}
paras[nbPara].b_st = b_st;
paras[nbPara].b_en = b_en;
@@ -571,7 +627,15 @@ unsigned text_wrapper::AddBoundary(text_boundary const &ib)
{
if ( nbBound >= maxBound ) {
maxBound = 2 * nbBound + 1;
- bounds = (text_boundary*)realloc(bounds, maxBound * sizeof(text_boundary));
+ text_boundary *newdata = static_cast<text_boundary*>(realloc(bounds, maxBound * sizeof(text_boundary)));
+ if (newdata != NULL)
+ {
+ bounds = newdata;
+ }
+ else
+ {
+ g_warning("Failed to reallocate bounds");
+ }
}
unsigned const ix = nbBound++;
bounds[ix] = ib;
@@ -893,7 +957,7 @@ void text_wrapper::AddDxDy(void)
} else if ( l_pos > n_pos ) {
for (int j = l_pos; j > n_pos; j--) sum -= kern_x[j];
}
- l_pos = n_pos;
+ // l_pos = n_pos;
glyph_text[glyph_length].x += sum;
}
}
@@ -918,7 +982,7 @@ void text_wrapper::AddDxDy(void)
} else if ( l_pos > n_pos ) {
for (int j = l_pos; j > n_pos; j--) sum -= kern_y[j];
}
- l_pos = n_pos;
+ // l_pos = n_pos;
glyph_text[glyph_length].y += sum;
}
}
diff --git a/src/libuemf/uemf.c b/src/libuemf/uemf.c
index b06990dbd..220c88545 100644
--- a/src/libuemf/uemf.c
+++ b/src/libuemf/uemf.c
@@ -1371,8 +1371,8 @@ int emf_htable_create(
}
ehtl->stack = malloc(initsize * sizeof(uint32_t));
if(!ehtl->stack){
- free(ehtl);
free(ehtl->table);
+ free(ehtl);
return(5);
}
memset(ehtl->table , 0, initsize * sizeof(uint32_t)); // zero all slots in the table
diff --git a/src/libuemf/uemf.h b/src/libuemf/uemf.h
index f1211d63d..1ff6ead60 100644
--- a/src/libuemf/uemf.h
+++ b/src/libuemf/uemf.h
@@ -856,6 +856,7 @@ extern "C" {
#define U_DSTINVERT 0x550009
#define U_BLACKNESS 0x000042
#define U_WHITENESS 0xff0062
+#define U_NOOP 0xaa0029 /* Many GDI programs end with a bitblt with this ROP == "D". Seems to work like flush() */
/** @} */
/** \defgroup U_EMRSETROP2_iMode_Qualifiers Binary Raster Operation Enumeration
diff --git a/src/libuemf/uemf_print.c b/src/libuemf/uemf_print.c
index b4e1753c6..b7cbf9a14 100644
--- a/src/libuemf/uemf_print.c
+++ b/src/libuemf/uemf_print.c
@@ -735,7 +735,7 @@ void core10_print(const char *name, const char *contents){
printf(" Points: ");
PU_POINT16 papts = (PU_POINT16)((char *)pEmr->aPolyCounts + sizeof(uint32_t)* pEmr->nPolys);
for(i=0; i<pEmr->cpts; i++){
- printf(" [%d]:",i); point16_print(papts[i]);
+ printf(" [%u]:",i); point16_print(papts[i]);
}
printf("\n");
diff --git a/src/libvpsc/constraint.cpp b/src/libvpsc/constraint.cpp
index 2bd173155..0ec06dfac 100644
--- a/src/libvpsc/constraint.cpp
+++ b/src/libvpsc/constraint.cpp
@@ -24,11 +24,11 @@ Constraint::Constraint(Variable *left, Variable *right, double gap, bool equalit
}
Constraint::~Constraint() {
Constraints::iterator i;
- for(i=left->out.begin(); i!=left->out.end(); i++) {
+ for(i=left->out.begin(); i!=left->out.end(); ++i) {
if(*i==this) break;
}
left->out.erase(i);
- for(i=right->in.begin(); i!=right->in.end(); i++) {
+ for(i=right->in.begin(); i!=right->in.end(); ++i) {
if(*i==this) break;
}
right->in.erase(i);
diff --git a/src/libvpsc/solve_VPSC.cpp b/src/libvpsc/solve_VPSC.cpp
index f9bed649c..83cb517b6 100644
--- a/src/libvpsc/solve_VPSC.cpp
+++ b/src/libvpsc/solve_VPSC.cpp
@@ -301,16 +301,16 @@ bool Solver::constraintGraphIsCyclic(const unsigned n, Variable* const vs[]) {
varmap[vs[i]]->out.insert(varmap[r]);
}
}
- while(graph.size()>0) {
+ while(!graph.empty()) {
node *u=NULL;
vector<node*>::iterator i=graph.begin();
for(;i!=graph.end();++i) {
u=*i;
- if(u->in.size()==0) {
+ if(u->in.empty()) {
break;
}
}
- if(i==graph.end() && graph.size()>0) {
+ if(i==graph.end() && !graph.empty()) {
//cycle found!
return true;
} else {
@@ -358,16 +358,16 @@ bool Solver::blockGraphIsCyclic() {
c=b->findMinOutConstraint();
}
}
- while(graph.size()>0) {
+ while(!graph.empty()) {
node *u=NULL;
vector<node*>::iterator i=graph.begin();
for(;i!=graph.end();++i) {
u=*i;
- if(u->in.size()==0) {
+ if(u->in.empty()) {
break;
}
}
- if(i==graph.end() && graph.size()>0) {
+ if(i==graph.end() && !graph.empty()) {
//cycle found!
return true;
} else {
diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp
index 3b5ce79f9..2cd359328 100644
--- a/src/livarot/PathOutline.cpp
+++ b/src/livarot/PathOutline.cpp
@@ -1047,7 +1047,7 @@ void Path::TangentOnArcAt(double at, const Geom::Point &iS, PathDescrArcTo const
dtgt[0] = -ca * rx * cb + sa * ry * sb;
dtgt[1] = -sa * rx * cb - ca * ry * sb;
len = L2(tgt);
- rad = len * dot(tgt, tgt) / (tgt[0] * dtgt[1] - tgt[1] * dtgt[0]);
+ rad = -len * dot(tgt, tgt) / (tgt[0] * dtgt[1] - tgt[1] * dtgt[0]);
tgt /= len;
}
else
@@ -1476,7 +1476,7 @@ Path::RecStdArcTo (outline_callback_data * data, double tol, double width,
}
const Geom::Point diff = req - chk;
const double err = (dot(diff,diff));
- if (err <= tol * tol)
+ if (err <= tol) // tolerance is given as a quadratic value, no need to use tol*tol here
{
int n_d = data->dest->CubicTo (enPos + width*enNor,
stGue*scal*stTgt,
diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp
index 628e0fe9f..ac6c72342 100644
--- a/src/livarot/Shape.cpp
+++ b/src/livarot/Shape.cpp
@@ -59,10 +59,10 @@ void Shape::Affiche(void)
{
printf("sh=%p nbPt=%i nbAr=%i\n", this, static_cast<int>(_pts.size()), static_cast<int>(_aretes.size())); // localizing ok
for (unsigned int i=0; i<_pts.size(); i++) {
- printf("pt %i : x=(%f %f) dI=%i dO=%i\n",i, _pts[i].x[0], _pts[i].x[1], _pts[i].dI, _pts[i].dO); // localizing ok
+ printf("pt %u : x=(%f %f) dI=%i dO=%i\n",i, _pts[i].x[0], _pts[i].x[1], _pts[i].dI, _pts[i].dO); // localizing ok
}
for (unsigned int i=0; i<_aretes.size(); i++) {
- printf("ar %i : dx=(%f %f) st=%i en=%i\n",i, _aretes[i].dx[0], _aretes[i].dx[1], _aretes[i].st, _aretes[i].en); // localizing ok
+ printf("ar %u : dx=(%f %f) st=%i en=%i\n",i, _aretes[i].dx[0], _aretes[i].dx[1], _aretes[i].st, _aretes[i].en); // localizing ok
}
}
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 7a8f5ec17..ed0fd3a08 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -1394,7 +1394,7 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state)
/* Pick one */
Inkscape::SnappedPoint best_snapped_point;
- for (std::list<Inkscape::SnappedPoint>::const_iterator i = s.begin(); i != s.end(); i++) {
+ for (std::list<Inkscape::SnappedPoint>::const_iterator i = s.begin(); i != s.end(); ++i) {
if (i->getSnapped()) {
if (best_snapped_point.isOtherSnapBetter(*i, true)) {
best_snapped_point = *i;
diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp
index adfff3609..04fb18cf3 100644
--- a/src/sp-gradient.cpp
+++ b/src/sp-gradient.cpp
@@ -418,23 +418,28 @@ void SPGradient::remove_child(Inkscape::XML::Node *child)
void SPGradient::modified(guint flags)
{
if (flags & SP_OBJECT_CHILD_MODIFIED_FLAG) {
- // CPPIFY
+ // CPPIFY
+ // This comparison has never worked (i. e. always evaluated to false),
+ // the right value would have been SP_TYPE_MESHGRADIENT
//if( this->get_type() != SP_GRADIENT_TYPE_MESH ) {
- if (!SP_IS_MESHGRADIENT(this)) {
- this->invalidateVector();
- } else {
- this->invalidateArray();
- }
+// if (!SP_IS_MESHGRADIENT(this)) {
+// this->invalidateVector();
+// } else {
+// this->invalidateArray();
+// }
+ this->invalidateVector();
}
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
- // CPPIFY
+ // CPPIFY
+ // see above
//if( this->get_type() != SP_GRADIENT_TYPE_MESH ) {
- if (!SP_IS_MESHGRADIENT(this)) {
- this->ensureVector();
- } else {
- this->ensureArray();
- }
+// if (!SP_IS_MESHGRADIENT(this)) {
+// this->ensureVector();
+// } else {
+// this->ensureArray();
+// }
+ this->ensureVector();
}
if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index ad497ff2f..a01ba891e 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -1073,6 +1073,11 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id)
return (SPNamedView *) nv;
}
+SPNamedView const *sp_document_namedview(SPDocument const *document, const gchar *id)
+{
+ return sp_document_namedview(const_cast<SPDocument *>(document), id); // use a const_cast here to avoid duplicating code
+}
+
void SPNamedView::setGuides(bool v)
{
g_assert(this->getRepr() != NULL);
diff --git a/src/sp-namedview.h b/src/sp-namedview.h
index 00302e9a1..05cbcc398 100644
--- a/src/sp-namedview.h
+++ b/src/sp-namedview.h
@@ -110,6 +110,7 @@ protected:
SPNamedView *sp_document_namedview(SPDocument *document, gchar const *name);
+SPNamedView const *sp_document_namedview(SPDocument const *document, gchar const *name);
void sp_namedview_window_from_document(SPDesktop *desktop);
void sp_namedview_document_from_window(SPDesktop *desktop);
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index 8c54caf48..e5f119ee0 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -228,7 +228,7 @@ SPObject *sp_object_unref(SPObject *object, SPObject *owner)
//g_object_unref(G_OBJECT(object));
object->refCount--;
- if (object->refCount < 0) {
+ if (object->refCount <= 0) {
delete object;
}
@@ -648,11 +648,6 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) {
try {
const std::string typeString = NodeTraits::get_type_string(*rchild);
- // special cases
- if (typeString.empty()) continue; // comments, usually
- if (typeString == "rdf:RDF") continue; // no SP node yet
- if (typeString == "inkscape:clipboard") continue; // SP node not necessary
-
SPObject* child = SPFactory::instance().createObject(typeString);
object->attach(child, object->lastChild());
@@ -663,7 +658,7 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) {
// corresponding classes in the SPObject tree.
// (rdf:RDF, inkscape:clipboard, ...)
// Thus, simply ignore this case for now.
- return;
+ continue;
}
}
}
diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp
index 983a738ce..a5ddd653a 100644
--- a/src/sp-polygon.cpp
+++ b/src/sp-polygon.cpp
@@ -98,7 +98,7 @@ static gboolean polygon_get_value(gchar const **p, gdouble *v)
(*p)++;
}
- if (*p == '\0') {
+ if (**p == '\0') {
return false;
}
diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp
index ff5e81f95..b327f0b83 100644
--- a/src/sp-rect.cpp
+++ b/src/sp-rect.cpp
@@ -113,7 +113,7 @@ void SPRect::set(unsigned key, gchar const *value) {
void SPRect::update(SPCtx* ctx, unsigned int flags) {
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
- SPItemCtx const *ictx = (SPItemCtx const *) ctx;
+ SPItemCtx const *ictx = reinterpret_cast<SPItemCtx const *>(ctx);
double const w = ictx->viewport.width();
double const h = ictx->viewport.height();
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index c87c8397d..5466649a2 100644
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
@@ -62,7 +62,7 @@ SPRoot::SPRoot() : SPGroup()
this->width.unset(SVGLength::PERCENT, 1.0, 1.0);
this->height.unset(SVGLength::PERCENT, 1.0, 1.0);
- this->viewBox_set = FALSE;
+ this->viewBox_set = false;
this->c2p.setIdentity();
diff --git a/src/sp-root.h b/src/sp-root.h
index 47a37029d..2931391ff 100644
--- a/src/sp-root.h
+++ b/src/sp-root.h
@@ -41,7 +41,7 @@ public:
SVGLength height;
/* viewBox; */
- bool viewBox_set : true;
+ bool viewBox_set;
Geom::Rect viewBox;
/* preserveAspectRatio */
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index a6019c55c..79fb953ac 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -173,7 +173,7 @@ DocumentProperties::DocumentProperties()
signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDocumentReplaced));
signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop));
signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop));
-
+
_rum_deflt._changed_connection.block();
_rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange));
}
@@ -1437,8 +1437,9 @@ void DocumentProperties::update()
_rcp_bord.setRgba32 (nv->bordercolor);
_rcb_shad.setActive (nv->showpageshadow);
- if (nv->doc_units)
+ if (nv->doc_units) {
_rum_deflt.setUnit (nv->doc_units->abbr);
+ }
double doc_w = sp_desktop_document(dt)->getRoot()->width.value;
Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit)->abbr;
@@ -1643,18 +1644,23 @@ void DocumentProperties::onRemoveGrid()
void DocumentProperties::onDocUnitChange()
{
SPDocument *doc = SP_ACTIVE_DOCUMENT;
+ // Don't execute when change is being undone
+ if (!DocumentUndo::getUndoSensitive(doc)) {
+ return;
+ }
+ // Don't execute when initializing widgets
+ if (_wr.isUpdating()) {
+ return;
+ }
+
+
Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr();
Inkscape::Util::Unit const *old_doc_unit = unit_table.getUnit("px");
if(repr->attribute("inkscape:document-units")) {
old_doc_unit = unit_table.getUnit(repr->attribute("inkscape:document-units"));
}
Inkscape::Util::Unit const *doc_unit = _rum_deflt.getUnit();
-
- // Don't execute when change is being undone
- if (!DocumentUndo::getUndoSensitive(doc)) {
- return;
- }
-
+
// Set document unit
Inkscape::SVGOStringStream os;
os << doc_unit->abbr;
diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp
index ff527434e..cc7bbb277 100644
--- a/src/ui/dialog/pixelartdialog.cpp
+++ b/src/ui/dialog/pixelartdialog.cpp
@@ -421,7 +421,7 @@ void PixelArtDialogImpl::processLibdepixelize(SPImage *img)
sp_repr_css_attr_unref(css);
}
- gchar *str = sp_svg_write_path(move(it->pathVector));
+ gchar *str = sp_svg_write_path(Dialog::move(it->pathVector));
repr->setAttribute("d", str);
g_free(str);
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index f7e75a83b..54eff00bc 100644
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
@@ -78,11 +78,14 @@ public:
XmlSource()
: filename(0),
encoding(0),
- fp(0),
+ fp(NULL),
firstFewLen(0),
+ LoadEntities(false),
+ cachedData(),
+ cachedPos(0),
dummy("x"),
- instr(0),
- gzin(0)
+ instr(NULL),
+ gzin(NULL)
{
for (int k=0;k<4;k++)
{
@@ -191,7 +194,7 @@ int XmlSource::setFile(char const *filename, bool load_entities=false)
buffer[len] = 0;
this->cachedData += buffer;
}
- free(buffer);
+ delete[] buffer;
// Check for SYSTEM or PUBLIC entities and remove them from the cache
GMatchInfo *info;