summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2016-11-25 13:17:44 +0000
committertavmjong-free <tavmjong@free.fr>2016-11-25 13:17:44 +0000
commit07212a0ac053f34a7a695a82690196b5f38d80ab (patch)
treef67420b68970f4523263143e7b47345f8551e295 /src/display
parentRemove deprecated GtkWidget-separator-height, ignored as of 3.20. (diff)
downloadinkscape-07212a0ac053f34a7a695a82690196b5f38d80ab.tar.gz
inkscape-07212a0ac053f34a7a695a82690196b5f38d80ab.zip
Provide a way to update a legacy document to account for the 90 to 96 dpi change.
This method relies on setting the 'viewBox'. (bzr r15273)
Diffstat (limited to 'src/display')
-rw-r--r--src/display/canvas-grid.cpp34
-rw-r--r--src/display/canvas-grid.h10
2 files changed, 42 insertions, 2 deletions
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index fa45fe02c..81d194b35 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -139,7 +139,7 @@ grid_canvasitem_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned
};
CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type)
- : visible(true), gridtype(type)
+ : visible(true), gridtype(type), legacy(false), pixel(false)
{
repr = in_repr;
doc = in_doc;
@@ -528,6 +528,10 @@ CanvasXYGrid::readRepr()
if( q.unit->type == UNIT_TYPE_LINEAR ) {
// Legacy grid not in 'user units'
origin[Geom::X] = q.value("px");
+ legacy = true;
+ if (q.unit->abbr == "px" ) {
+ pixel = true;
+ }
} else {
// Grid in 'user units'
origin[Geom::X] = q.quantity * scale_x;
@@ -541,6 +545,10 @@ CanvasXYGrid::readRepr()
if( q.unit->type == UNIT_TYPE_LINEAR ) {
// Legacy grid not in 'user units'
origin[Geom::Y] = q.value("px");
+ legacy = true;
+ if (q.unit->abbr == "px" ) {
+ pixel = true;
+ }
} else {
// Grid in 'user units'
origin[Geom::Y] = q.quantity * scale_y;
@@ -559,6 +567,10 @@ CanvasXYGrid::readRepr()
if( q.unit->type == UNIT_TYPE_LINEAR ) {
// Legacy grid not in 'user units'
spacing[Geom::X] = q.value("px");
+ legacy = true;
+ if (q.unit->abbr == "px" ) {
+ pixel = true;
+ }
} else {
// Grid in 'user units'
spacing[Geom::X] = q.quantity * scale_x;
@@ -578,6 +590,10 @@ CanvasXYGrid::readRepr()
if( q.unit->type == UNIT_TYPE_LINEAR ) {
// Legacy grid not in 'user units'
spacing[Geom::Y] = q.value("px");
+ legacy = true;
+ if (q.unit->abbr == "px" ) {
+ pixel = true;
+ }
} else {
// Grid in 'user units'
spacing[Geom::Y] = q.quantity * scale_y;
@@ -798,7 +814,23 @@ CanvasXYGrid::updateWidgets()
*/
}
+// For correcting old SVG Inkscape files
+void
+CanvasXYGrid::Scale (Geom::Scale const &scale ) {
+ origin *= scale;
+ spacing *= scale;
+ // Write out in 'user-units'
+ Inkscape::SVGOStringStream os_x, os_y, ss_x, ss_y;
+ os_x << origin[Geom::X];
+ os_y << origin[Geom::Y];
+ ss_x << spacing[Geom::X];
+ ss_y << spacing[Geom::Y];
+ repr->setAttribute("originx", os_x.str().c_str());
+ repr->setAttribute("originy", os_y.str().c_str());
+ repr->setAttribute("spacingx", ss_x.str().c_str());
+ repr->setAttribute("spacingy", ss_y.str().c_str());
+}
void
CanvasXYGrid::Update (Geom::Affine const &affine, unsigned int /*flags*/)
diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h
index 557bd6dab..bf520467a 100644
--- a/src/display/canvas-grid.h
+++ b/src/display/canvas-grid.h
@@ -101,6 +101,9 @@ public:
static void on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data);
+ bool isLegacy() const { return legacy; }
+ bool isPixel() const { return pixel; }
+
bool isVisible() const { return (isEnabled() &&visible); };
bool isEnabled() const;
@@ -118,7 +121,11 @@ protected:
GridType gridtype;
-private:
+ // For dealing with old Inkscape SVG files (pre 0.92)
+ bool legacy;
+ bool pixel;
+
+ private:
CanvasGrid(const CanvasGrid&);
CanvasGrid& operator=(const CanvasGrid&);
};
@@ -129,6 +136,7 @@ public:
CanvasXYGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc);
virtual ~CanvasXYGrid();
+ virtual void Scale (Geom::Scale const &scale);
virtual void Update (Geom::Affine const &affine, unsigned int flags);
virtual void Render (SPCanvasBuf *buf);