=== modified file 'src/display/canvas-grid.cpp'
--- src/display/canvas-grid.cpp	2015-05-06 11:55:31 +0000
+++ src/display/canvas-grid.cpp	2016-06-07 20:49:40 +0000
@@ -144,8 +144,9 @@
     };
 
 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)
 {
+    std::cout << "CanvasGrid::CanvasGrid()" << std::endl;
     repr = in_repr;
     doc = in_doc;
     if (repr) {
@@ -534,6 +535,7 @@
 void
 CanvasXYGrid::readRepr()
 {
+    std::cout << "CanvasXYGrid::readRepr()" << std::endl;
     SPRoot *root = doc->getRoot();
     double scale_x = 1.0;
     double scale_y = 1.0;
@@ -549,6 +551,7 @@
             scale_y = scale_x;
         }
     }
+    std::cout << "  scale: " << scale_x << std::endl;
 
     gchar const *value;
 
@@ -559,6 +562,11 @@
         if( q.unit->type == UNIT_TYPE_LINEAR ) {
             // Legacy grid not in 'user units'
             origin[Geom::X] = q.value("px");
+            std::cout << "  factor: " << q.unit->factor << std::endl;
+            legacy = true;
+            if (q.unit->abbr == "px" ) {
+                pixel = true;
+            }
         } else {
             // Grid in 'user units'
             origin[Geom::X] = q.quantity * scale_x;
@@ -572,6 +580,10 @@
         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;
@@ -590,10 +602,15 @@
             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;
             }
+            std::cout << " unit type: " << q.unit->type << " " << spacing[Geom::X] << std::endl;
         }
     }
 
@@ -609,6 +626,10 @@
             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;
@@ -834,7 +855,23 @@
 */
 }
 
+// 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*/)

=== modified file 'src/display/canvas-grid.h'
--- src/display/canvas-grid.h	2014-10-08 02:22:03 +0000
+++ src/display/canvas-grid.h	2016-06-08 09:28:55 +0000
@@ -101,6 +101,9 @@
 
     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 @@
 
     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 @@
     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);
 

=== modified file 'src/file.cpp'
--- src/file.cpp	2016-06-08 09:16:29 +0000
+++ src/file.cpp	2016-06-08 09:45:57 +0000
@@ -67,6 +67,10 @@
 #include "event-log.h"
 #include "ui/dialog/font-substitution.h"
 
+// For updating old Inkscape SVG files
+#include "display/canvas-grid.h"
+#include "sp-guide.h"
+
 #include <gtk/gtk.h>
 #include <gtkmm/main.h>
 
@@ -141,15 +145,6 @@
         DocumentUndo::setUndoSensitive(doc, true);
     }
     
-    // Set viewBox if it doesn't exist
-    if (!doc->getRoot()->viewBox_set
-    && (doc->getRoot()->width.unit != SVGLength::PERCENT)
-    && (doc->getRoot()->height.unit != SVGLength::PERCENT)) {
-        DocumentUndo::setUndoSensitive(doc, false);
-        doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit())));
-        DocumentUndo::setUndoSensitive(doc, true);
-    }
-    
     SPDesktop *olddesktop = SP_ACTIVE_DESKTOP;
     if (olddesktop)
         olddesktop->setWaitingCursor();
@@ -290,14 +285,6 @@
     }
 
     if (doc) {
-        // Set viewBox if it doesn't exist
-        if (!doc->getRoot()->viewBox_set
-        && (doc->getRoot()->width.unit != SVGLength::PERCENT)
-        && (doc->getRoot()->height.unit != SVGLength::PERCENT)) {
-            DocumentUndo::setUndoSensitive(doc, false);
-            doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit())));
-            DocumentUndo::setUndoSensitive(doc, true);
-        }
 
         SPDocument *existing = desktop ? desktop->getDocument() : NULL;
 
@@ -324,6 +311,177 @@
         root->original.inkscape = root->version.inkscape;
         root->original.svg      = root->version.svg;
 
+        // See if we need to offer the user a fix for the 90->96 px per inch change.
+        std::cout << "SPFileOpen:" << std::endl;
+        std::cout << "  Version: " << sp_version_to_string(root->version.inkscape) << std::endl;
+
+        if ( sp_version_inside_range( root->version.inkscape, 0, 1, 0, 92 ) ) {
+
+            std::cout << "  SVG file from old Inkscape version detected: "
+                      << sp_version_to_string(root->version.inkscape) << std::endl;
+
+
+            static const double ratio = 90.0/96.0;
+
+            bool need_fix_viewbox = false;
+            bool need_fix_units   = false;
+            bool need_fix_guides  = false;
+            bool need_fix_grid_mm = false;
+
+            // Check if potentially need viewbox or unit fix
+            switch (root->width.unit) {
+                case SP_CSS_UNIT_PC:
+                case SP_CSS_UNIT_MM:
+                case SP_CSS_UNIT_CM:
+                case SP_CSS_UNIT_IN:
+                    need_fix_viewbox = true;
+                    break;
+                case SP_CSS_UNIT_NONE:
+                case SP_CSS_UNIT_PX:
+                    need_fix_units = true;
+                default:
+                    break;
+                    // OK
+            }
+
+            switch (root->height.unit) {
+                case SP_CSS_UNIT_PC:
+                case SP_CSS_UNIT_MM:
+                case SP_CSS_UNIT_CM:
+                case SP_CSS_UNIT_IN:
+                    need_fix_viewbox = true;
+                    break;
+                case SP_CSS_UNIT_NONE:
+                case SP_CSS_UNIT_PX:
+                    need_fix_units = true;
+                default:
+                    break;
+                    // OK
+            }
+
+            std::cout << "Absolute SVG units in root? " << (need_fix_viewbox?"true":"false") << std::endl;
+            std::cout << "User units in root? "         << (need_fix_units  ?"true":"false") << std::endl;
+
+            if (!root->viewBox_set && need_fix_viewbox) {
+
+                std::cout << "Old Inkscape files used 1in == 90px. CSS requires 1in == 96px.\n"
+                          << "Setting 'viewBox' can correct for this.\n"
+                          << "Do you wish to set 'viewBox'? (yn)" << std::endl;
+                std::string input;
+                while (true) {
+                    getline( std::cin, input);
+                    if (input.length() == 1) {
+                        if (input[0] == 'y') {
+                            std::cout << "y entered" << std::endl;
+
+                            //DocumentUndo::setUndoSensitive(doc, false);
+                            doc->setViewBox(Geom::Rect::from_xywh(
+                                                0, 0,
+                                                doc->getWidth().value("px") * ratio,
+                                                doc->getHeight().value("px") * ratio));
+                            //DocumentUndo::setUndoSensitive(doc, true);
+                        }
+                        break;
+                    }
+                    std::cout << "Enter 'y' or 'n'" << std::endl;
+                }
+                need_fix_guides = true; // Always fix guides
+            }
+
+            if (need_fix_units) {
+                std::cout << "Old Inkscape files used 1in == 90px. CSS requires 1in == 96px.\n"
+                          << "Drawings meant to match a physical size (e.g. Letter or A4)\n"
+                          << "will be too small.\n"
+                          << "Scaling the drawing and setting 'viewBox' can correct for this.\n"
+                          << "Do you wish to scale the drawing and set 'viewBox'? (yn)" << std::endl;
+                std::string input;
+                while (true) {
+                    getline( std::cin, input);
+                    if (input.length() == 1) {
+                        if (input[0] == 'y') {
+                            std::cout << "y entered" << std::endl;
+
+                            //DocumentUndo::setUndoSensitive(doc, false);
+                            if (!root->viewBox_set) {
+                                doc->setViewBox(Geom::Rect::from_xywh(
+                                                    0, 0,
+                                                    doc->getWidth().value("px"),
+                                                    doc->getHeight().value("px")));
+                            }
+                            Inkscape::Util::Quantity width  =
+                                Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" );
+                            Inkscape::Util::Quantity height =
+                                Inkscape::Util::Quantity(doc->getHeight().value("px")/ratio,"px" );
+                            doc->setWidthAndHeight( width, height, false );
+                            std::cout << "  Width: " << width.string()
+                                      << "  Height: " << height.string() << std::endl;
+                            //DocumentUndo::setUndoSensitive(doc, true);
+
+                            need_fix_guides = true; // Only fix guides if drawing scaled
+                        } else {
+                            need_fix_grid_mm = true;
+                        }
+                        break;
+                    }
+                    std::cout << "Enter 'y' or 'n'" << std::endl;
+                }
+            }
+
+            // Fix guides and grids
+            for (SPObject *child = root->firstChild() ; child; child = child->getNext() ) {
+                SPNamedView *nv = dynamic_cast<SPNamedView *>(child);
+                if (nv) {
+                    if (need_fix_guides) {
+                        std::cout << "Fixing guides" << std::endl;
+                        for (SPObject *child2 = nv->firstChild() ; child2; child2 = child2->getNext() ) {
+                            SPGuide *gd = dynamic_cast<SPGuide *>(child2);
+                            if (gd) {
+                                gd->moveto( gd->getPoint() / ratio, true );
+                            }
+                        }
+                    }
+                    
+                    for(std::vector<Inkscape::CanvasGrid *>::const_iterator it=nv->grids.begin();it!=nv->grids.end();++it ) {
+                        Inkscape::CanvasXYGrid *xy = dynamic_cast<Inkscape::CanvasXYGrid *>(*it);
+                        if (xy) { 
+                            std::cout << "A grid: " << xy->getSVGName() << std::endl;
+                            std::cout << "  Origin: " << xy->origin
+                                      << "  Spacing: " << xy->spacing << std::endl;
+                            std::cout << (xy->isLegacy()?"  Legacy":"  Not Legacy") << std::endl;
+                            Geom::Scale scale = doc->getDocumentScale();
+                            std::cout << "  document scale: " << scale << std::endl;
+                            if (xy->isLegacy()) {
+                                if (xy->isPixel()) {
+                                    std::cout << "  Is pixel" << std::endl;
+                                    if (need_fix_grid_mm) {
+                                        std::cout << "   Need_fix_grid_mm" << std::endl;
+                                        xy->Scale( Geom::Scale(1,1) );
+                                    } else {
+                                        std::cout << "   Don't Need_fix_grid_mm" << std::endl;
+                                        scale *= Geom::Scale(ratio,ratio);
+                                        xy->Scale( scale.inverse() ); /* *** */
+                                    }
+                                } else {
+                                    std::cout << "  Is not pixel" << std::endl;
+                                    if (need_fix_grid_mm) {
+                                        std::cout << "   Need_fix_grid_mm" << std::endl;
+                                        xy->Scale( Geom::Scale(ratio,ratio) );
+                                    } else {
+                                        std::cout << "   Don't Need_fix_grid_mm" << std::endl;
+                                        xy->Scale( scale.inverse() ); /* *** */
+                                    }
+                                }
+                            } else {
+                                if (need_fix_guides) {
+                                    xy->Scale( Geom::Scale(1,1) );
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
         // resize the window to match the document properties
         sp_namedview_window_from_document(desktop);
         sp_namedview_update_layers_from_document(desktop);

