]> git.lyx.org Git - features.git/commitdiff
Herbert's upgrade to the recognized graphics formats.
authorAngus Leeming <leeming@lyx.org>
Mon, 4 Mar 2002 10:37:25 +0000 (10:37 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 4 Mar 2002 10:37:25 +0000 (10:37 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3652 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/configure
lib/configure.m4
src/support/ChangeLog
src/support/filetools.C

index 3b7b5582ebf66b81f0dd578aa82efa81693d63b4..66a86758d625b02e391e48d6c3a877255298827a 100644 (file)
@@ -1,3 +1,7 @@
+2002-03-03  Herbert Voss  <voss@perce.de>
+
+       * configure.m4: added more converter stuff for different formats
+
 2002-03-03  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * layouts/hollywood.layout: set DefaultStyle
 2002-03-03  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * layouts/hollywood.layout: set DefaultStyle
index 95476d60f2cd72a01ea970af43da5e65f10c9420..6c95c01a68624106feb7167cd50520654bf65778 100755 (executable)
@@ -1088,7 +1088,7 @@ if test -z "$TOEPS" ; then
 fi
 
 case $TOEPS in
 fi
 
 case $TOEPS in
-       convert) bmp_to_eps="convert BMP:\$\$i EPS:\$\$o" fits_to_eps="convert FITS:\$\$i EPS:\$\$o" gif_to_eps="convert GIF:\$\$i EPS:\$\$o" jpg_to_eps="convert JPG:\$\$i EPS:\$\$o" pbm_to_eps="convert PBM:\$\$i EPS:\$\$o" pgm_to_eps="convert PGM:\$\$i EPS:\$\$o" png_to_eps="convert PNG:\$\$i EPS:\$\$o" ppm_to_eps="convert PPM:\$\$i EPS:\$\$o" sgi_to_eps="convert SGI:\$\$i EPS:\$\$o" xwd_to_eps="convert XWD:\$\$i EPS:\$\$o" ;;
+       convert) bmp_to_eps="convert BMP:\$\$i EPS:\$\$o" fits_to_eps="convert FITS:\$\$i EPS:\$\$o" gif_to_eps="convert GIF:\$\$i EPS:\$\$o" jpg_to_eps="convert JPG:\$\$i EPS:\$\$o" pbm_to_eps="convert PBM:\$\$i EPS:\$\$o" pgm_to_eps="convert PGM:\$\$i EPS:\$\$o" png_to_eps="convert PNG:\$\$i EPS:\$\$o" ppm_to_eps="convert PPM:\$\$i EPS:\$\$o" sgi_to_eps="convert SGI:\$\$i EPS:\$\$o" xbm_to_eps="convert XBM:\$\$i EPS:\$\$o" xwd_to_eps="convert XWD:\$\$i EPS:\$\$o" ;;
        pnmtops) gif_to_eps="giftopnm \$\$i | pnmtops > \$\$o" png_to_eps="pngtopnm \$\$i | pnmtops >\$\$o" jpg_to_eps="jpegtopnm \$\$i | pnmtops >\$\$o";;
 esac
 
        pnmtops) gif_to_eps="giftopnm \$\$i | pnmtops > \$\$o" png_to_eps="pngtopnm \$\$i | pnmtops >\$\$o" jpg_to_eps="jpegtopnm \$\$i | pnmtops >\$\$o";;
 esac
 
@@ -1171,6 +1171,7 @@ if test "$TOXPM" = "convert"; then
        jpg_to_xpm="convert JPG:\$\$i XPM:\$\$o"
        png_to_xpm="convert PNG:\$\$i XPM:\$\$o"
        ps_to_xpm="convert PS:\$\$i XPM:\$\$o" 
        jpg_to_xpm="convert JPG:\$\$i XPM:\$\$o"
        png_to_xpm="convert PNG:\$\$i XPM:\$\$o"
        ps_to_xpm="convert PS:\$\$i XPM:\$\$o" 
+       xbm_to_xpm="convert XBM:\$\$i XPM:\$\$o" 
 fi
 
 echo $ac_n "checking For an EPS -> PDF converter""... $ac_c"
 fi
 
 echo $ac_n "checking For an EPS -> PDF converter""... $ac_c"
@@ -1322,6 +1323,7 @@ cat >$outfile <<EOF
 \\Format sgi      sgi  SGI             ""
 \\Format tgif     tgif TGIF            ""
 \\Format tiff     tif  TIFF            ""
 \\Format sgi      sgi  SGI             ""
 \\Format tgif     tgif TGIF            ""
 \\Format tiff     tif  TIFF            ""
+\\Format xbm      xbm   XBM             ""
 \\Format xpm      xpm   XPM             ""
 \\Format xwd      xwd  XWD             ""
 \\Format word    doc   Word            W
 \\Format xpm      xpm   XPM             ""
 \\Format xwd      xwd  XWD             ""
 \\Format word    doc   Word            W
@@ -1358,6 +1360,7 @@ cat >$outfile <<EOF
 \\converter sgi  eps "$sgi_to_eps" ""
 \\converter tgif eps "tgif -print -eps \$\$i" ""
 \\converter tiff eps "tiff2ps \$\$i > \$\$o" ""
 \\converter sgi  eps "$sgi_to_eps" ""
 \\converter tgif eps "tgif -print -eps \$\$i" ""
 \\converter tiff eps "tiff2ps \$\$i > \$\$o" ""
+\\converter xbm  eps "$xbm_to_eps" ""
 \\converter xwd  eps "$xwd_to_eps" ""
 
 \\converter tgif gif "tgif -print -gif \$\$i" ""
 \\converter xwd  eps "$xwd_to_eps" ""
 
 \\converter tgif gif "tgif -print -gif \$\$i" ""
@@ -1373,6 +1376,8 @@ cat >$outfile <<EOF
 \\converter epsi xpm "$eps_to_xpm" ""
 \\converter jpg  xpm "$jpg_to_xpm" ""
 \\converter png  xpm "$png_to_xpm" ""
 \\converter epsi xpm "$eps_to_xpm" ""
 \\converter jpg  xpm "$jpg_to_xpm" ""
 \\converter png  xpm "$png_to_xpm" ""
+\\converter ps  xpm "$ps_to_xpm" ""
+\\converter xbm  xpm "$xbm_to_xpm" ""
  
 \\converter eps  pdf "$eps_to_pdf" ""
 \\converter epsi pdf "$eps_to_pdf" ""
  
 \\converter eps  pdf "$eps_to_pdf" ""
 \\converter epsi pdf "$eps_to_pdf" ""
index 15ff8aea8c9780023ea60769dc31ec03188e861a..045365c25bf7f257bc521c912b6aff0be1c523fb 100644 (file)
@@ -355,7 +355,7 @@ esac
 #### Search for image conversion ####
 SEARCH_PROG([for an Image -> EPS converter], TOEPS, convert pnmtops)
 case $TOEPS in
 #### Search for image conversion ####
 SEARCH_PROG([for an Image -> EPS converter], TOEPS, convert pnmtops)
 case $TOEPS in
-       convert) bmp_to_eps="convert BMP:\$\$i EPS:\$\$o" fits_to_eps="convert FITS:\$\$i EPS:\$\$o" gif_to_eps="convert GIF:\$\$i EPS:\$\$o" jpg_to_eps="convert JPG:\$\$i EPS:\$\$o" pbm_to_eps="convert PBM:\$\$i EPS:\$\$o" pgm_to_eps="convert PGM:\$\$i EPS:\$\$o" png_to_eps="convert PNG:\$\$i EPS:\$\$o" ppm_to_eps="convert PPM:\$\$i EPS:\$\$o" sgi_to_eps="convert SGI:\$\$i EPS:\$\$o" xwd_to_eps="convert XWD:\$\$i EPS:\$\$o" ;;
+       convert) bmp_to_eps="convert BMP:\$\$i EPS:\$\$o" fits_to_eps="convert FITS:\$\$i EPS:\$\$o" gif_to_eps="convert GIF:\$\$i EPS:\$\$o" jpg_to_eps="convert JPG:\$\$i EPS:\$\$o" pbm_to_eps="convert PBM:\$\$i EPS:\$\$o" pgm_to_eps="convert PGM:\$\$i EPS:\$\$o" png_to_eps="convert PNG:\$\$i EPS:\$\$o" ppm_to_eps="convert PPM:\$\$i EPS:\$\$o" sgi_to_eps="convert SGI:\$\$i EPS:\$\$o" xbm_to_eps="convert XBM:\$\$i EPS:\$\$o" xwd_to_eps="convert XWD:\$\$i EPS:\$\$o" ;;
        pnmtops) gif_to_eps="giftopnm \$\$i | pnmtops > \$\$o" png_to_eps="pngtopnm \$\$i | pnmtops >\$\$o" jpg_to_eps="jpegtopnm \$\$i | pnmtops >\$\$o";;
 esac
 
        pnmtops) gif_to_eps="giftopnm \$\$i | pnmtops > \$\$o" png_to_eps="pngtopnm \$\$i | pnmtops >\$\$o" jpg_to_eps="jpegtopnm \$\$i | pnmtops >\$\$o";;
 esac
 
@@ -372,6 +372,7 @@ if test "$TOXPM" = "convert"; then
        jpg_to_xpm="convert JPG:\$\$i XPM:\$\$o"
        png_to_xpm="convert PNG:\$\$i XPM:\$\$o"
        ps_to_xpm="convert PS:\$\$i XPM:\$\$o" 
        jpg_to_xpm="convert JPG:\$\$i XPM:\$\$o"
        png_to_xpm="convert PNG:\$\$i XPM:\$\$o"
        ps_to_xpm="convert PS:\$\$i XPM:\$\$o" 
+       xbm_to_xpm="convert XBM:\$\$i XPM:\$\$o" 
 fi
 
 SEARCH_PROG([For an EPS -> PDF converter], EPSTOPDF, epstopdf)
 fi
 
 SEARCH_PROG([For an EPS -> PDF converter], EPSTOPDF, epstopdf)
@@ -478,6 +479,7 @@ cat >$outfile <<EOF
 \\Format sgi      sgi  SGI             ""
 \\Format tgif     tgif TGIF            ""
 \\Format tiff     tif  TIFF            ""
 \\Format sgi      sgi  SGI             ""
 \\Format tgif     tgif TGIF            ""
 \\Format tiff     tif  TIFF            ""
+\\Format xbm      xbm   XBM             ""
 \\Format xpm      xpm   XPM             ""
 \\Format xwd      xwd  XWD             ""
 \\Format word    doc   Word            W
 \\Format xpm      xpm   XPM             ""
 \\Format xwd      xwd  XWD             ""
 \\Format word    doc   Word            W
@@ -514,6 +516,7 @@ cat >$outfile <<EOF
 \\converter sgi  eps "$sgi_to_eps" ""
 \\converter tgif eps "tgif -print -eps \$\$i" ""
 \\converter tiff eps "tiff2ps \$\$i > \$\$o" ""
 \\converter sgi  eps "$sgi_to_eps" ""
 \\converter tgif eps "tgif -print -eps \$\$i" ""
 \\converter tiff eps "tiff2ps \$\$i > \$\$o" ""
+\\converter xbm  eps "$xbm_to_eps" ""
 \\converter xwd  eps "$xwd_to_eps" ""
 
 \\converter tgif gif "tgif -print -gif \$\$i" ""
 \\converter xwd  eps "$xwd_to_eps" ""
 
 \\converter tgif gif "tgif -print -gif \$\$i" ""
@@ -529,6 +532,8 @@ cat >$outfile <<EOF
 \\converter epsi xpm "$eps_to_xpm" ""
 \\converter jpg  xpm "$jpg_to_xpm" ""
 \\converter png  xpm "$png_to_xpm" ""
 \\converter epsi xpm "$eps_to_xpm" ""
 \\converter jpg  xpm "$jpg_to_xpm" ""
 \\converter png  xpm "$png_to_xpm" ""
+\\converter ps  xpm "$ps_to_xpm" ""
+\\converter xbm  xpm "$xbm_to_xpm" ""
  
 \\converter eps  pdf "$eps_to_pdf" ""
 \\converter epsi pdf "$eps_to_pdf" ""
  
 \\converter eps  pdf "$eps_to_pdf" ""
 \\converter epsi pdf "$eps_to_pdf" ""
index 3bb81cc55662afa9c8e8c32cc807561eb590ae3b..01139595e609fe6183697e000a879def1fa2a4e9 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-02  Herbert Voss  <voss@perce.de>
+
+       * filetools.C: fix bug for xbm format and added some more debug
+       infos
+
 2002-03-02  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * forkedcontr.h: make constructor public
 2002-03-02  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * forkedcontr.h: make constructor public
index 4018d633008031c2afb76d15043c85b76181af75..a593833e93ef9ceb942302fba71148f09f984e7f 100644 (file)
@@ -981,15 +981,15 @@ string const GetExtension(string const & name)
 // SGI \001\332...     (decimal 474)
 // TGIF        %TGIF...
 // TIFF        II... or MM...
 // SGI \001\332...     (decimal 474)
 // TGIF        %TGIF...
 // TIFF        II... or MM...
-// XBM ... static char ...
+// XBM ..._bits[]...
 // XPM /* XPM */
 // XPM /* XPM */
-// XWD \000\000\000\151        (0x00006900)
+// XWD \000\000\000\151        (0x00006900) decimal 105
 //
 // GZIP        \037\213\010\010...     http://www.ietf.org/rfc/rfc1952.txt
 // ZIP PK...                   http://www.halyava.ru/document/ind_arch.htm
 // Z   \037\177                UNIX compress
 
 //
 // GZIP        \037\213\010\010...     http://www.ietf.org/rfc/rfc1952.txt
 // ZIP PK...                   http://www.halyava.ru/document/ind_arch.htm
 // Z   \037\177                UNIX compress
 
-/// return the "extension" which belongs to the contents
+/// return the "extension" which belongs to the contents.
 /// for no knowing contents return the extension. Without
 /// an extension and unknown contents we return "user"
 string const getExtFromContents(string const & filename) {
 /// for no knowing contents return the extension. Without
 /// an extension and unknown contents we return "user"
 string const getExtFromContents(string const & filename) {
@@ -1013,10 +1013,11 @@ string const getExtFromContents(string const & filename) {
 
        // Maximum strings to read
        int const max_count = 50;
 
        // Maximum strings to read
        int const max_count = 50;
+       int count = 0;
 
 
-       string str;
+       string str, format;
        bool firstLine = true;
        bool firstLine = true;
-       for (int count = 0; count < max_count; ++count) {
+       while ((count++ < max_count) && format.empty()) {
                if (ifs.eof()) {
                        lyxerr[Debug::GRAPHICS]
                                << "filetools(getExtFromContents)\n"
                if (ifs.eof()) {
                        lyxerr[Debug::GRAPHICS]
                                << "filetools(getExtFromContents)\n"
@@ -1026,110 +1027,120 @@ string const getExtFromContents(string const & filename) {
                }
 
                ifs >> str;
                }
 
                ifs >> str;
+               lyxerr[Debug::GRAPHICS]
+                   << "Scanstring: " << str << endl;
+               string const stamp = str.substr(0,2);
                if (firstLine && str.size() >= 2) {
                        // at first we check for a zipped file, because this
                        // information is saved in the first bytes of the file!
                        // also some graphic formats which save the information
                        // in the first line, too.
                        if (prefixIs(str, gzipStamp))
                if (firstLine && str.size() >= 2) {
                        // at first we check for a zipped file, because this
                        // information is saved in the first bytes of the file!
                        // also some graphic formats which save the information
                        // in the first line, too.
                        if (prefixIs(str, gzipStamp))
-                               return "gzip";
+                               format =  "gzip";
 
 
-                       string const stamp = str.substr(0,2);
+                       else if (stamp == zipStamp)
+                               format =  "zip";
 
 
-                       if (stamp == zipStamp)
-                               return "zip";
-
-                       if (stamp == compressStamp)
-                               return "compress";
+                       else if (stamp == compressStamp)
+                               format =  "compress";
 
                        // the graphics part
 
                        // the graphics part
-                       if (stamp == "BM")
-                               return "bmp";
-
-                       if (stamp == "\001\332")
-                               return "sgi";
-
-                       if ((stamp == "II") || (stamp == "MM"))
-                               return "tiff";
+                       else if (stamp == "BM")
+                               format =  "bmp";
 
 
+                       else if (stamp == "\001\332")
+                               format =  "sgi";
                        // PBM family
                        // PBM family
-                       // Dont need to use str.at(0), str.at(1) because
+                       // Don't need to use str.at(0), str.at(1) because
                        // we already know that str.size() >= 2
                        // we already know that str.size() >= 2
-                       if (str[0] == 'P') {
+                       else if (str[0] == 'P') {
                                switch (str[1]) {
                                case '1':
                                case '4':
                                switch (str[1]) {
                                case '1':
                                case '4':
-                                       return "pbm";
-
+                                       format =  "pbm";
+                                   break;
                                case '2':
                                case '5':
                                case '2':
                                case '5':
-                                       return "pgm";
-
+                                       format =  "pgm";
+                                   break;
                                case '3':
                                case '6':
                                case '3':
                                case '6':
-                                       return "ppm";
+                                       format =  "ppm";
                                }
                                }
-                       }
-
-                       if (prefixIs(str, "GIF"))
-                               return "gif";
-
-                       // prefixIs doesn't seem happy with this
-                       if (str.size() >= 4 &&
-                           str.substr(0,4) == "\000\000\000i")
-                               return "xwd";
+                               break;
+                       } 
+                       if (stamp == "\001\332")
+                           format =  "sgi";
+                       else if ((stamp == "II") || (stamp == "MM"))
+                           format =  "tiff";
+                       else if (str == "%TGIF")
+                           format =  "tgif";
+                       else if (prefixIs(str,"GIF"))
+                           format =  "gif";
+                       else if (str.size() > 3)        // get long
+                           if (((str[0] << 24) + (str[1] << 16) +
+                               (str[2] << 8) + str[3]) == 105)
+                               format =  "xwd";
+                       firstLine = false;
                }
                }
-
-               firstLine = false;
-
-               if (contains(str,"EPSF"))
+               if (!format.empty())
+                   break;
+               else if (contains(str,"EPSF"))
                        // dummy, if we have wrong file description like
                        // description like "%!PS-Adobe-2.0EPSF"
                        // dummy, if we have wrong file description like
                        // description like "%!PS-Adobe-2.0EPSF"
-                       return "eps";
-
-               if (contains(str,"TGIF"))
-                       return "tgif";
+                       format =  "eps";
 
 
-               if (contains(str,"Grace"))
-                       return "agr";
+               else if (contains(str,"Grace"))
+                       format =  "agr";
 
 
-               if (contains(str,"JFIF"))
-                       return "jpg";
+               else if (contains(str,"JFIF"))
+                       format =  "jpg";
 
 
-               if (contains(str,"%PDF"))
-                       return "pdf";
+               else if (contains(str,"%PDF"))
+                       format =  "pdf";
 
 
-               if (contains(str,"PNG"))
-                       return "png";
+               else if (contains(str,"PNG"))
+                       format =  "png";
 
 
-               if (contains(str,"%!PS-Adobe")) {
+               else if (contains(str,"%!PS-Adobe")) {
                        // eps or ps
                        ifs >> str;
                        if (contains(str,"EPSF"))
                        // eps or ps
                        ifs >> str;
                        if (contains(str,"EPSF"))
-                               return "eps";
-                       return "ps";
+                               format = "eps";
+                       else
+                           format = "ps";
                }
 
                }
 
-               if (contains(str,"static char"))
-                       return "xbm";
+               else if (contains(str,"_bits[]"))
+                       format = "xbm";
 
 
-               if (contains(str,"XPM"))
-                       return "xpm";
+               else if (contains(str,"XPM"))
+                       format = "xpm";
 
 
-               if (contains(str,"BITPIX"))
-                       return "fits";
+               else if (contains(str,"BITPIX"))
+                       format = "fits";
        }
        }
-
+       
+       if (!format.empty()) {
+           lyxerr[Debug::GRAPHICS]
+               << "Recognised Fileformat: " << format << endl;
+           return format;
+       } 
+       
+       string const ext(GetExtension(filename));
        lyxerr[Debug::GRAPHICS]
                << "filetools(getExtFromContents)\n"
        lyxerr[Debug::GRAPHICS]
                << "filetools(getExtFromContents)\n"
-               << "\tCouldn't find a known Type!"
-               << "\twill use ext or a \"user\" defined format" << endl;
-
-       string const ext(GetExtension(filename));
-       if (!ext.empty())
+               << "\tCouldn't find a known Type!\n";
+       if (!ext.empty()) {
+           lyxerr[Debug::GRAPHICS]
+               << "\twill take the file extension -> " 
+               << ext << endl;
                return ext;
                return ext;
-
-       return "user";
+       } else {
+           lyxerr[Debug::GRAPHICS]
+               << "\twill use ext or a \"user\" defined format" << endl;
+           return "user";
+       }
 }
 
 
 }