]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsParams.C
fix typo that put too many include paths for most people
[lyx.git] / src / graphics / GraphicsParams.C
index f289b305a18bbbdd39e1162ecd905ad1af412dab..b0cf8e1312aef3ac214617c7b558d2fbaeb91b1c 100644 (file)
 #include "GraphicsParams.h"
 #include "insets/insetgraphicsParams.h"
 #include "lyxrc.h"
+#include "support/filetools.h"
 #include "support/lstrings.h"
+#include "support/LAssert.h"
 
 namespace grfx {
 
-GParams::GParams(InsetGraphicsParams const & iparams)
-       : filename(iparams.filename),
-         width(0),
+GParams::GParams(InsetGraphicsParams const & iparams, string const & filepath)
+       : width(0),
          height(0),
          scale(0),
          angle(0)
 {
+       filename = iparams.filename;
+       if (!filepath.empty()) {
+               filename = MakeAbsPath(filename, filepath);
+       }
+
        if (iparams.clip)
                bb = iparams.bb;
-                 
+
        if (iparams.rotate)
                angle = int(iparams.rotateAngle);
 
@@ -73,8 +79,8 @@ GParams::GParams(InsetGraphicsParams const & iparams)
                // inPixels returns a value scaled by lyxrc.zoom.
                // We want, therefore, to undo this.
                double const scaling_factor = 100.0 / double(lyxrc.zoom);
-               width  = int(scaling_factor * width);
-               height = int(scaling_factor * height);
+               width  = uint(scaling_factor * width);
+               height = uint(scaling_factor * height);
        }
 }
 
@@ -119,7 +125,7 @@ BoundingBox::BoundingBox(string const & bb)
                return;
 
        LyXLength const length_yb(tmp1);
-       
+
        tmp2 = split(tmp2, tmp1, ' ');
        if (!isValidLength(tmp1) || !isValidLength(tmp2))
                return;
@@ -133,10 +139,10 @@ BoundingBox::BoundingBox(string const & bb)
        // want the bounding box in Postscript pixels.
        // Note further that there are 72 Postscript pixels per inch.
        double const scaling_factor = 7200.0 / (lyxrc.dpi * lyxrc.zoom);
-       xl = int(scaling_factor * length_xl.inPixels(1, 1));
-       yb = int(scaling_factor * length_yb.inPixels(1, 1));
-       xr = int(scaling_factor * length_xr.inPixels(1, 1));
-       yt = int(scaling_factor * length_yt.inPixels(1, 1));
+       xl = uint(scaling_factor * length_xl.inPixels(1, 1));
+       yb = uint(scaling_factor * length_yb.inPixels(1, 1));
+       xr = uint(scaling_factor * length_xr.inPixels(1, 1));
+       yt = uint(scaling_factor * length_yt.inPixels(1, 1));
 
        if (xr <= xl || yt <= yb) {
                xl = 0;
@@ -148,7 +154,7 @@ BoundingBox::BoundingBox(string const & bb)
 }
 
 
-bool BoundingBox::empty() const 
+bool BoundingBox::empty() const
 {
        return (!xl && !yb && !xr && !yt);
 }