]> git.lyx.org Git - lyx.git/commitdiff
Fix crash but problem still remains.
authorAngus Leeming <leeming@lyx.org>
Mon, 8 Apr 2002 20:00:02 +0000 (20:00 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 8 Apr 2002 20:00:02 +0000 (20:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3953 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/FormGraphics.C
src/frontends/xforms/xformsGImage.C
src/graphics/GraphicsParams.C

index dda36d298a6247700fb1eb73d3a7afe7ad6c5c07..38866c2af45afe07bd97621f87f08817541a05c1 100644 (file)
@@ -578,7 +578,7 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
 
                // the bb section
        } else if (!controller().bbChanged &&
-                  (ob == bbox_->choice_bb_units ||
+                  (ob == bbox_->check_clip  || ob == bbox_->choice_bb_units ||
                    ob == bbox_->input_bb_x0 || ob == bbox_->input_bb_y0 ||
                    ob == bbox_->input_bb_x1 || ob == bbox_->input_bb_y1)) {
                controller().bbChanged = true;
index fadefb4c6fa69fc88f6cfd1e2b6d116eb982a68a..ef0059e50bbbc9e2170ec5b330ee6dd1f34404d8 100644 (file)
@@ -261,10 +261,10 @@ void xformsGImage::clip(GParams const & params)
                // Bounds are unchanged.
                return;
 
-       int const xoffset_l = params.bb.xl;
-       int const xoffset_r = image_->w - params.bb.xr;
-       int const yoffset_t = image_->h - params.bb.yt;
-       int const yoffset_b = params.bb.yb;
+       int const xoffset_l = std::max(0, params.bb.xl);
+       int const xoffset_r = std::max(0, image_->w - params.bb.xr);
+       int const yoffset_t = std::max(0, image_->h - params.bb.yt);
+       int const yoffset_b = std::max(0, params.bb.yb);
 
        flimage_crop(image_, xoffset_l, yoffset_t, xoffset_r, yoffset_b);
 }
index b130623134be184e9627d0372f50fde920f5b03b..7a5a06c4e16dc24af59f2bdf5d21656d72fc2361 100644 (file)
@@ -36,20 +36,22 @@ GParams::GParams(InsetGraphicsParams const & iparams, string const & filepath)
                bb = iparams.bb;
 
                // Get the original Bounding Box from the file
-               string const bb_orig_str = readBB_from_PSFile(filename);
-               if (!bb_orig_str.empty()) {
-                       BoundingBox bb_orig;
-                       bb_orig.xl = strToInt(token(bb_orig_str, ' ', 0));
-                       bb_orig.yb = strToInt(token(bb_orig_str, ' ', 1));
-                       bb_orig.xr = strToInt(token(bb_orig_str, ' ', 2));
-                       bb_orig.yt = strToInt(token(bb_orig_str, ' ', 3));
-
-                       bb.xl -= bb_orig.xl;
-                       bb.xr -= bb_orig.xl;
-                       bb.yb -= bb_orig.yb;
-                       bb.yt -= bb_orig.yb;
+               string const tmp = readBB_from_PSFile(filename);
+               if (!tmp.empty()) {
+                       int const bb_orig_xl = strToInt(token(tmp, ' ', 0));
+                       int const bb_orig_yb = strToInt(token(tmp, ' ', 1));
+
+                       bb.xl -= bb_orig_xl;
+                       bb.xr -= bb_orig_xl;
+                       bb.yb -= bb_orig_yb;
+                       bb.yt -= bb_orig_yb;
                }
 
+               bb.xl = std::max(0, bb.xl);
+               bb.xr = std::max(0, bb.xr);
+               bb.yb = std::max(0, bb.yb);
+               bb.yt = std::max(0, bb.yt);
+
                // Paranoia check.
                int const width  = bb.xr - bb.xl;
                int const height = bb.yt - bb.yb;