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...)
 
| -#include "support/filetools.h" // for AddName, zippedFile
| +#include "support/filetools.h" // for AddName, zippedFile, readBB_from_PSFile

just drop the comment...
  
| -     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;
| +     // correct the lower left if the original bb
| +     // doesn't has a lower left(0,0)
| +     int dummy = params.bb.xl - xl_orig;
| +     int const xoffset_l = (dummy < 0) ? 0 : dummy;
| +
| +     dummy = image_->w - (params.bb.xr - xl_orig);
| +     int const xoffset_r = (dummy < 0) ? 0 : dummy;
| +
| +     dummy = image_->h - (params.bb.yt - yb_orig);
| +     int const yoffset_t = (dummy < 0) ? 0 : dummy;
| +
| +     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...
  
| +string const readBB_from_PSFile(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) ? unzipFile(file) : file;
| +     string const format = getExtFromContents(file_);
| +     if (format != "eps" && format != "ps")
| +             return string();
| +
| +     std::ifstream is(file_.c_str());
| +     while (is) {
| +             string s;
| +             is >> s;
| +             if (contains(s,"%%BoundingBox:")) {
| +                     string a, b, c, d;
| +                     is >> a >> b >> c >> d;
| +                     if (is && !contains(a,"atend")) { // bb at the end?
| +                             if (s != "%%BoundingBox:")
| +                                 return (s.substr(14)+" "+a+" "+b+"
|        "+c+" ");

spaces spaces spaces...
       
                                   return s.substr(14) + " " + " " + b
                                   + " " ... etc.

| +                             else
| +                                 return (a+" "+b+" "+c+" "+d+" ");

here too.

and what is really the point in parsing the bounding box and then
recreate it before returning it?


-- 
        Lgb

Reply via email to