Lars Gullik Bjønnes wrote: > Herbert Voss <[EMAIL PROTECTED]> writes: > > | The attached patch fixes this, so that lyx-view > | and latex view are the same.. > > | +2002-04-07 Herbert Voss <[EMAIL PROTECTED]> > | + > | + * ControlGraphics.[C]: move readBB as readBB_from_PSFile into filetools > | + > > Was this necessary to do now? > (yes perhaps...)
exactly .. :-) > | + > | + dummy = params.bb.yb - yb_orig; > | + int const yoffset_b = (dummy < 0) ? 0 : dummy; > > int const xoffset_l = max(0, params.bb.xl - xl_orig); > int const xoffset_r = max(0, image_->w - params.bb.xr + xl_orig); > int const yoffset_t = max(0, image_->h - params.bb.yt + yb_orig); > int const yoffset_b = max(0, params.bb.yb - yb_orig); > > looks a lot better... yesss > | + return (s.substr(14)+" "+a+" "+b+" > | "+c+" "); > > spaces spaces spaces... ok ok. I'll do my best ... > here too. s.a. > > and what is really the point in parsing the bounding box and then > recreate it before returning it? ?? %%BoundingBox:0 0 10 10 %%BoundingBox: 0 0 10 10 %%BoundingBox: (atend) %%BoundingBox:(atend) this is all possible. but I think we can get it easier, when also using getline. But I'm not really sure that the bb command must be in an own line ??? the attached one works on my demo-graphic file. Herbert -- http://www.lyx.org/help/
Index: src/support/filetools.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v retrieving revision 1.114 diff -u -r1.114 filetools.C --- src/support/filetools.C 7 Apr 2002 15:31:16 -0000 1.114 +++ src/support/filetools.C 7 Apr 2002 18:02:46 -0000 @@ -1344,3 +1357,30 @@ } } } + + +string const readBB_from_PS(string const & file) +{ + // in a (e)ps-file it's an entry like %%BoundingBox:23 45 321 345 + // The first number can following without a space, so we have + // to be a little careful. + // On the other hand some plot programs write the bb at the + // end of the file. Than we have in the header: + // %%BoundingBox: (atend) + // In this case we must check the end. + string const file_ = zippedFile(file) ? + string(unzipFile(file)) : string(file); + string const format = getExtFromContents(file_); + if (format != "eps" && format != "ps") + return string(); + + std::ifstream is(file_.c_str()); + while (is) { + string s; + getline(is,s); + if (contains(s,"%%BoundingBox:") && !contains(s,"atend")) + return (frontStrip(s.substr(14))); + } + return string(); +} +