Hello community,

here is the log from the commit of package klatexformula for openSUSE:Factory 
checked in at 2014-02-02 07:50:41
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/klatexformula (Old)
 and      /work/SRC/openSUSE:Factory/.klatexformula.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "klatexformula"

Changes:
--------
--- /work/SRC/openSUSE:Factory/klatexformula/klatexformula.changes      
2013-08-10 11:04:11.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.klatexformula.new/klatexformula.changes 
2014-02-02 07:50:43.000000000 +0100
@@ -1,0 +2,6 @@
+Fri Jan 31 19:32:24 UTC 2014 - badshah...@gmail.com
+
+- Update to version 3.2.8:
+  - Fixes a bug caused by recent versions of ghostscript  
+
+-------------------------------------------------------------------

Old:
----
  klatexformula-3.2.7.tar.gz

New:
----
  klatexformula-3.2.8.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ klatexformula.spec ++++++
--- /var/tmp/diff_new_pack.sznune/_old  2014-02-02 07:50:44.000000000 +0100
+++ /var/tmp/diff_new_pack.sznune/_new  2014-02-02 07:50:44.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package klatexformula
 #
-# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -49,7 +49,7 @@
 #  --------------
 
 Name:           klatexformula
-Version:        3.2.7
+Version:        3.2.8
 Release:        0
 Summary:        An easy-to-use graphical application for generating images 
from LaTeX equations
 License:        GPL-2.0+

++++++ klatexformula-3.2.7.tar.gz -> klatexformula-3.2.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/klatexformula-3.2.7/VERSION 
new/klatexformula-3.2.8/VERSION
--- old/klatexformula-3.2.7/VERSION     2013-06-23 12:52:36.000000000 +0200
+++ new/klatexformula-3.2.8/VERSION     2013-11-23 20:25:38.000000000 +0100
@@ -1 +1 @@
-3.2.7
+3.2.8
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/klatexformula-3.2.7/src/CMakeLists.txt 
new/klatexformula-3.2.8/src/CMakeLists.txt
--- old/klatexformula-3.2.7/src/CMakeLists.txt  2013-06-23 12:52:34.000000000 
+0200
+++ new/klatexformula-3.2.8/src/CMakeLists.txt  2013-11-23 20:25:37.000000000 
+0100
@@ -1,7 +1,7 @@
 # ######################################## #
 # CMake project file for klatexformula/src #
 # ######################################## #
-# $Id: CMakeLists.txt 742 2011-10-09 11:02:08Z phfaist $
+# $Id: CMakeLists.txt 864 2013-11-23 13:52:28Z phfaist $
 # ######################################## #
 
 if(KLF_MACOSX_BUNDLES)
@@ -503,9 +503,12 @@
 if(WIN32 AND KLF_INSTALL_QTLIBS)
   # Install Qt libs
   #  QT_BINARY_DIR and QT_PLUGINS_DIR are set by FindQt4 CMake module
-  install(DIRECTORY "${QT_BINARY_DIR}/" DESTINATION "${KLF_INSTALL_LIB_DIR}"
-           FILES_MATCHING REGEX "/Qt(Core|Gui|Sql|Xml)4?\\.dll$" REGEX 
"/libgcc.*\\.dll" REGEX "/mingw.*\\.dll"
-        )
+  #message(STATUS "QT_BINARY_DIR is ${QT_BINARY_DIR}")
+  install(DIRECTORY "${QT_BINARY_DIR}/" DESTINATION "${KLF_INSTALL_LIB_DIR}" 
FILES_MATCHING
+    PATTERN "libgcc*.dll"
+    PATTERN "mingw*.dll"
+    REGEX "/Qt(Core|Gui|Sql|Xml)4?\\.dll$"
+  )
   set(qtplugin_list ${KLF_INSTALL_QTPLUGINS_LIST})
   set(qtplugin_list "dummyitem" ${qtplugin_list})
   string(REGEX REPLACE ";" ";${QT_PLUGINS_DIR}/" qtplugin_list_temp 
"${qtplugin_list}")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/klatexformula-3.2.7/src/klfbackend/klfbackend.cpp 
new/klatexformula-3.2.8/src/klfbackend/klfbackend.cpp
--- old/klatexformula-3.2.7/src/klfbackend/klfbackend.cpp       2013-06-23 
12:52:33.000000000 +0200
+++ new/klatexformula-3.2.8/src/klfbackend/klfbackend.cpp       2013-11-23 
20:25:36.000000000 +0100
@@ -19,7 +19,7 @@
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
-/* $Id: klfbackend.cpp 748 2012-01-01 15:06:40Z phfaist $ */
+/* $Id: klfbackend.cpp 863 2013-11-23 13:14:34Z phfaist $ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -33,7 +33,6 @@
 #include <qbuffer.h>
 #include <qdir.h>
 
-
 #include "klfblockprocess.h"
 #include "klfbackend.h"
 
@@ -205,6 +204,22 @@
 
 
 
+// utilities for dealing with bounding boxes in EPS file
+// (backported from 3.3)
+
+// A Bounding Box
+struct klfbbox {
+  double x1, x2, y1, y2;
+};
+static bool read_eps_bbox(const QByteArray& epsdata, klfbbox *bbox, 
KLFBackend::klfOutput * resError);
+static void correct_eps_bbox(const QByteArray& epsdata, const klfbbox& 
bbox_corrected, const klfbbox& bbox_orig,
+                            double vectorscale, QByteArray * epsdatacorrected);
+
+
+
+
+
+
 KLFBackend::klfOutput KLFBackend::getLatexFormula(const klfInput& in, const 
klfSettings& settings)
 {
   // ALLOW ONLY ONE RUNNING getLatexFormula() AT A TIME 
@@ -254,7 +269,13 @@
   // - if epstopdfexec is not empty, run epstopdf and get PDF file.
 
   QString tempfname = settings.tempdir + "/klatexformulatmp" 
KLF_VERSION_STRING "-"
-    + QDateTime::currentDateTime().toString("hh-mm-ss");
+    + QDateTime::currentDateTime().toString("hh-mm-ss")
+#ifdef KLFBACKEND_QT4
+    + "-p"+ QString("%1").arg(QApplication::applicationPid(), 0, 26)
+#else
+    + "-p" + QString("%1").arg(rand()%100000, 0, 26)
+#endif
+    ;
 
   QString fnTex = tempfname + ".tex";
   QString fnDvi = tempfname + ".dvi";
@@ -391,71 +412,122 @@
       return res;
     }
 
-    // add some space on bounding-box to avoid some too tight bounding box bugs
-    // read eps file
-    QFile epsfile(fnRawEps);
-    r = epsfile.open(dev_READONLY);
-    if ( ! r ) {
-      res.status = KLFERR_EPSREADFAIL;
-      res.errorstr = QObject::tr("Can't read file '%1'!\n", 
"KLFBackend").arg(fnRawEps);
-      return res;
-    }
-    /** \todo Hi-Res bounding box adjustment. Shouldn't be too hard to do, but 
needs tests to see
-     * how this works... [ Currently: only integer-valued BoundingBox: is 
adjusted. ] */
-    QByteArray epscontent = epsfile.readAll();
-#ifdef KLFBACKEND_QT4
-    QByteArray epscontent_s = epscontent;
-    int i = epscontent_s.indexOf("%%BoundingBox: ");
-#else
-    QCString epscontent_s(epscontent.data(), epscontent.size());
-    int i = epscontent_s.find("%%BoundingBox: ");
-#endif
-    // process file data and transform it
-    if ( i == -1 ) {
-      res.status = KLFERR_NOEPSBBOX;
-      res.errorstr = QObject::tr("File '%1' does not contain line 
\"%%BoundingBox: ... \" !",
-                                "KLFBackend").arg(fnRawEps);
-      return res;
-    }
-    int ax, ay, bx, by;
-    char temp[250];
-    const int k = i;
-    i += strlen("%%BoundingBox:");
-    int n = sscanf(epscontent_s.data()+i, "%d %d %d %d", &ax, &ay, &bx, &by);
-    if ( n != 4 ) {
-      res.status = KLFERR_BADEPSBBOX;
-      res.errorstr = QObject::tr("file %1: Line %%BoundingBox: can't read 
values!\n", "KLFBackend")
-       .arg(fnRawEps);
-      return res;
-    }
-    // grow bbox by settings.Xborderoffset points
-    // Don't forget: '%' in printf has special meaning (!) -> double percent 
signs '%'->'%%'
-    sprintf(temp, "%%%%BoundingBox: %d %d %d %d",
-           (int)(ax-settings.lborderoffset+0.5),
-           (int)(ay-settings.bborderoffset+0.5),
-           (int)(bx+settings.rborderoffset+0.5),
-           (int)(by+settings.tborderoffset+0.5));
-    QString chunk = QString::fromLocal8Bit(epscontent_s.data()+k);
-    QRegExp rx("^%%BoundingBox: [0-9]+ [0-9]+ [0-9]+ [0-9]+");
-    rx.rx_indexin(chunk);
-    int l = rx.matchedLength();
-    epscontent_s.replace(k, l, temp);
-
-    // write content back to second file
-    QFile epsgoodfile(fnBBCorrEps);
-    r = epsgoodfile.open(dev_WRITEONLY);
-    if ( ! r ) {
-      res.status = KLFERR_EPSWRITEFAIL;
-      res.errorstr = QObject::tr("Can't write to file '%1'!\n", "KLFBackend")
-       .arg(fnBBCorrEps);
-      return res;
-    }
-    epsgoodfile.dev_write(epscontent_s);
+//     { // DEAL WITH BOUNDING BOX
 
-    if ( ! settings.outlineFonts ) {
-      res.epsdata.ba_assign(epscontent_s);
+//       // add some space on bounding-box to avoid some too tight bounding 
box bugs
+//       // read eps file
+//       QFile epsfile(fnRawEps);
+//       r = epsfile.open(dev_READONLY);
+//       if ( ! r ) {
+//         res.status = KLFERR_EPSREADFAIL;
+//         res.errorstr = QObject::tr("Can't read file '%1'!\n", 
"KLFBackend").arg(fnRawEps);
+//         return res;
+//       }
+//       /** \todo Hi-Res bounding box adjustment. Shouldn't be too hard to 
do, but needs tests to see
+//        * how this works... [ Currently: only integer-valued BoundingBox: is 
adjusted. ] */
+//       QByteArray epscontent = epsfile.readAll();
+// #ifdef KLFBACKEND_QT4
+//       QByteArray epscontent_s = epscontent;
+//       int i = epscontent_s.indexOf("%%BoundingBox: ");
+// #else
+//       QCString epscontent_s(epscontent.data(), epscontent.size());
+//       int i = epscontent_s.find("%%BoundingBox: ");
+// #endif
+//       // process file data and transform it
+//       if ( i == -1 ) {
+//         res.status = KLFERR_NOEPSBBOX;
+//         res.errorstr = QObject::tr("File '%1' does not contain line 
\"%%BoundingBox: ... \" !",
+//                                    "KLFBackend").arg(fnRawEps);
+//         return res;
+//       }
+//       int ax, ay, bx, by;
+//       char temp[250];
+//       const int k = i;
+//       i += strlen("%%BoundingBox:");
+//       int n = sscanf(epscontent_s.data()+i, "%d %d %d %d", &ax, &ay, &bx, 
&by);
+//       if ( n != 4 ) {
+//         res.status = KLFERR_BADEPSBBOX;
+//         res.errorstr = QObject::tr("file %1: Line %%BoundingBox: can't read 
values!\n", "KLFBackend")
+//           .arg(fnRawEps);
+//         return res;
+//       }
+//       // grow bbox by settings.Xborderoffset points
+//       // Don't forget: '%' in printf has special meaning (!) -> double 
percent signs '%'->'%%'
+//       sprintf(temp, "%%%%BoundingBox: %d %d %d %d",
+//               (int)(ax-settings.lborderoffset+0.5),
+//               (int)(ay-settings.bborderoffset+0.5),
+//               (int)(bx+settings.rborderoffset+0.5),
+//               (int)(by+settings.tborderoffset+0.5));
+//       QString chunk = QString::fromLocal8Bit(epscontent_s.data()+k);
+//       QRegExp rx("^%%BoundingBox: [0-9]+ [0-9]+ [0-9]+ [0-9]+");
+//       rx.rx_indexin(chunk);
+//       int l = rx.matchedLength();
+//       epscontent_s.replace(k, l, temp);
+      
+//       // write content back to second file
+//       QFile epsgoodfile(fnBBCorrEps);
+//       r = epsgoodfile.open(dev_WRITEONLY);
+//       if ( ! r ) {
+//         res.status = KLFERR_EPSWRITEFAIL;
+//         res.errorstr = QObject::tr("Can't write to file '%1'!\n", 
"KLFBackend")
+//           .arg(fnBBCorrEps);
+//         return res;
+//       }
+//       epsgoodfile.dev_write(epscontent_s);
+      
+//       if ( ! settings.outlineFonts ) {
+//         res.epsdata.ba_assign(epscontent_s);
+//       }
+//       // res.epsdata is now set.
+
+//     }
+
+    { // DEAL WITH BBOX: BACKPORT FROM 3.3
+
+      // read eps file
+      QFile epsfile(fnRawEps);
+      r = epsfile.open(dev_READONLY);
+      if ( ! r ) {
+        res.status = KLFERR_EPSREADFAIL;
+        res.errorstr = QObject::tr("Can't read file '%1'!\n", 
"KLFBackend").arg(fnRawEps);
+        return res;
+      }
+      QByteArray rawepsdata = epsfile.readAll();
+
+      klfbbox bbox, bbox_corrected;
+      bool ok = read_eps_bbox(rawepsdata, &bbox, &res);
+      if (!ok)
+       return res; // res was set by the function
+
+      bbox.x1 -= settings.lborderoffset;
+      bbox.y1 -= settings.bborderoffset;
+      bbox.x2 += settings.rborderoffset;
+      bbox.y2 += settings.tborderoffset;
+
+      int width_pt = bbox.x2 - bbox.x1;
+      int height_pt = bbox.y2 - bbox.y1;
+
+      // now correct the bbox to (0,0,width,height)
+
+      bbox_corrected.x1 = 0;
+      bbox_corrected.y1 = 0;
+      bbox_corrected.x2 = width_pt;
+      bbox_corrected.y2 = height_pt;
+
+      // and generate corrected raw EPS
+      correct_eps_bbox(rawepsdata, bbox_corrected, bbox, 1.0,
+                       &res.epsdata);
+
+      QFile epsgoodfile(fnBBCorrEps);
+      r = epsgoodfile.open(dev_WRITEONLY);
+      if ( ! r ) {
+        res.status = KLFERR_EPSWRITEFAIL;
+        res.errorstr = QObject::tr("Can't write to file '%1'!\n", "KLFBackend")
+          .arg(fnBBCorrEps);
+        return res;
+      }
+      epsgoodfile.dev_write(res.epsdata);
     }
-    // res.epsdata is now set.
 
     qDebug("%s: %s:  eps bbox set.", KLF_FUNC_NAME, KLF_SHORT_TIME) ;    
 
@@ -464,15 +536,48 @@
   if (settings.outlineFonts) {
     // run 'gs' to outline fonts
     KLFBlockProcess proc;
-    QStringList args;
-    args << settings.gsexec << "-dNOCACHE" << "-dNOPAUSE" << "-dSAFER" << 
"-dEPSCrop"
-        << "-sDEVICE=pswrite" << 
"-sOutputFile="+dir_native_separators(fnOutlFontsEps)
-        << "-q" << "-dBATCH" << dir_native_separators(fnBBCorrEps);
 
-    qDebug("%s: %s: about to gs (for outline fonts)...\n%s", KLF_FUNC_NAME, 
KLF_SHORT_TIME,
-          qPrintable(args.join(" ")));
-    bool r = proc.startProcess(args, execenv);
-    qDebug("%s: %s:  gs returned (for outline fonts).", KLF_FUNC_NAME, 
KLF_SHORT_TIME) ;    
+    // Very bad joke from ghostscript's guys: they deprecate pswrite device, 
which worked very well, and
+    // so I had to adapt the code so that it works with the new ps2write 
device. The bounding boxes were
+    // going like hell. Hopefully a backport of the new system in 3.3 seemed 
to fix the issue.
+
+    // So now we have to make sure we use ps2write on newer systems but make 
sure we still use pswrite on
+    // old systems which don't support ps2write. THANKS A TON GS GUYS :(
+
+    // In 3.2 we don't query gs version so we have no idea. So just let the 
user define an environment
+    // variable in case. KLFBACKEND_GS_PS_DEVICE="pswrite" or "epswrite" or 
"ps2write" (note: with epswrite
+    // you can't expand the bbox)
+
+    QStringList try_ps_devices;
+    const char *env_gs_device = getenv("KLFBACKEND_GS_PS_DEVICE");
+    if (env_gs_device != NULL) {
+      try_ps_devices << QString::fromLatin1(env_gs_device);
+    } else {
+      try_ps_devices << QLatin1String("pswrite") << QLatin1String("ps2write");
+    }
+
+    bool r = false;
+    int try_ps_dev_i = 0;
+    for (try_ps_dev_i = 0; try_ps_dev_i < try_ps_devices.size(); 
try_ps_dev_i++) {
+      QString psdev = try_ps_devices[try_ps_dev_i];
+      qDebug("trying with gs device %s ...", qPrintable(psdev));
+
+      QStringList args;
+      args << settings.gsexec << "-dNOCACHE" << "-dNOPAUSE" << "-dSAFER" << 
"-dEPSCrop"
+           << QString("-sDEVICE=%1").arg(psdev)
+           << "-sOutputFile="+dir_native_separators(fnOutlFontsEps)
+           << "-q" << "-dBATCH" << dir_native_separators(fnBBCorrEps);
+
+      qDebug("%s: %s: about to gs (for outline fonts)...\n%s", KLF_FUNC_NAME, 
KLF_SHORT_TIME,
+             qPrintable(args.join(" ")));
+      r = proc.startProcess(args, execenv);
+      qDebug("%s: %s:  gs returned (for outline fonts).", KLF_FUNC_NAME, 
KLF_SHORT_TIME) ;    
+
+      if (r && proc.processNormalExit() && proc.processExitStatus() == 0) {
+        // successful run
+        break;
+      }
+    }
   
     if ( ! r ) {
       res.status = KLFERR_NOGSPROG;
@@ -653,6 +758,253 @@
 }
 
 
+
+static bool s_starts_with(const char * x, int len_x, const char *test, int 
len_test)
+{
+  if (len_x < len_test)
+    return false;
+  return !strncmp(x, test, len_test);
+}
+
+#define D_RX "([0-9eE.-]+)"
+
+static bool parse_bbox_values(const QString& str, klfbbox *bbox)
+{
+  // parse bbox values
+  QRegExp rx_bbvalues("" D_RX "\\s+" D_RX "\\s+" D_RX "\\s+" D_RX "");
+  int i = rx_bbvalues.rx_indexin(str);
+  if (i < 0) {
+    return false;
+  }
+  bbox->x1 = rx_bbvalues.cap(1).toDouble();
+  bbox->y1 = rx_bbvalues.cap(2).toDouble();
+  bbox->x2 = rx_bbvalues.cap(3).toDouble();
+  bbox->y2 = rx_bbvalues.cap(4).toDouble();
+  return true;
+}
+
+static bool read_eps_bbox(const QByteArray& epsdata, klfbbox *bbox, 
KLFBackend::klfOutput * resError)
+{
+  static const char * hibboxtag = "%%HiResBoundingBox:";
+  static const char * bboxtag = "%%BoundingBox:";
+  static const int hibboxtaglen = strlen(hibboxtag);
+  static const int bboxtaglen = strlen(bboxtag);
+
+  // Read dvips' bounding box.
+  QBuffer buf;
+  buf_setdata(buf, epsdata);
+  bool r = buf.open(dev_READONLY);
+  if (!r) {
+    qWarning("What's going on!!?! can't open buffer for reading? Will 
Fail!!!") ;
+  }
+
+  QString nobboxerrstr =
+    QObject::tr("DVIPS did not provide parsable %%BoundingBox: in its 
output!", "KLFBackend");
+
+  char linebuffer[512];
+  int n;
+  bool gotepsbbox = false;
+  int still_look_for_hiresbbox_lines = 5;
+  while ((n = buf.readLine(linebuffer, sizeof(linebuffer)-1)) > 0) {
+    if (gotepsbbox && still_look_for_hiresbbox_lines-- < 0) {
+      // if we already got the %BoundingBox, and we've been looking at more 
than a certian number of lines
+      // after that, abort because usually %BoundingBox and %HiResBoundingBox 
are together...
+      klfDbg("stopped looking for hires-bbox.") ;
+      break;
+    }
+    if (s_starts_with(linebuffer, n-1, hibboxtag, hibboxtaglen)) {
+      // got hi-res bounding-box
+      bool ok = 
parse_bbox_values(QString::fromLatin1(linebuffer+hibboxtaglen), bbox);
+      if (!ok) {
+       resError->status = KLFERR_BADEPSBBOX;
+       resError->errorstr = nobboxerrstr;
+       return false;
+      }
+      klfDbg("got hires-bbox.") ;
+      // all ok, got hi-res bbox
+      return true;
+    }
+    if (s_starts_with(linebuffer, n-1, bboxtag, bboxtaglen)) {
+      // got bounding-box.
+      bool ok = parse_bbox_values(QString::fromLatin1(linebuffer+bboxtaglen), 
bbox);
+      if (!ok) {
+       continue;
+      }
+      // stand by, continue in case we have a hi-res bbox.
+      gotepsbbox = true;
+      klfDbg("got normal bbox.") ;
+      continue;
+    }
+  }
+
+  // didn't get a hi-res bbox. see if we still got a regular %BoundingBox: and 
return that.
+  if (gotepsbbox) {
+    // bbox pointer is already set
+    return true;
+  }
+
+  resError->status = KLFERR_BADEPSBBOX;
+  resError->errorstr = nobboxerrstr;
+  return false;
+}
+
+// static int find_ba_in_ba(const QByteArray& haystack, const QByteArray& 
needle)
+// {
+// #ifdef KLFBACKEND_QT4
+//   return haystack.indexOf(needle);
+// #else
+//   int k, j;
+//   for (k = 0; k < haystack.length()-needle.length(); ++k) {
+//     // locally compare haystack and needle
+//     for (j = 0; j < needle.length(); ++j) {
+//       if (haystack[k+j] != needle[j])
+//         break; // nope they're not the same
+//     }
+//     if (j == needle.length())
+//       // found the needle
+//       return k;
+//   }
+//   return -1;
+// #endif
+// }
+
+static void correct_eps_bbox(const QByteArray& rawepsdata, const klfbbox& 
bbox_corrected,
+                            const klfbbox& bbox_orig, double vectorscale,
+                            QByteArray * epsdatacorrected)
+{
+  static const char * bboxdecl = "%%BoundingBox:";
+  static int bboxdecl_len = strlen(bboxdecl);
+
+  double offx = bbox_corrected.x1 - bbox_orig.x1;
+  double offy = bbox_corrected.y1 - bbox_orig.y1;
+
+  // in raw EPS data, find '%%BoundingBox:' and length of the full BoundingBox 
instruction
+  int i, len;
+  char nl[] = "\0\0\0";
+#ifdef KLFBACKEND_QT4
+  i = rawepsdata.indexOf(bboxdecl);
+#else
+  QCString rawepsdata_s(rawepsdata.data(), rawepsdata.size());
+  i = rawepsdata_s.find(bboxdecl);
+#endif
+  if (i < 0) {
+    i = 0;
+    len = 0;
+  } else {
+    int j = i+bboxdecl_len;
+    while (j < (int)rawepsdata.size() && rawepsdata[j] != '\r' && 
rawepsdata[j] != '\n')
+      ++j;
+    len = j-i;
+    // also determine what the newline is (\n, \r, \r\n?)
+    if (rawepsdata[j] == '\r' && j < (int)rawepsdata.size()-1 && 
rawepsdata[j+1] == '\n') {
+      nl[0] = '\r', nl[1] = '\n';
+    } else {
+      nl[0] = rawepsdata[j];
+    }
+  }
+
+  double dwi = bbox_corrected.x2 * vectorscale;
+  double dhi = bbox_corrected.y2 * vectorscale;
+  int wi = (int)(dwi + 0.99999) ;
+  int hi = (int)(dhi + 0.99999) ;
+  char buffer[1024];
+  int buffer_len;
+  // recall that '%%' in printf is replaced by a single '%'...
+  snprintf(buffer, sizeof(buffer)-1,
+          "%%%%BoundingBox: 0 0 %d %d%s"
+          "%%%%HiResBoundingBox: 0 0 %.6g %.6g%s",
+          wi, hi, nl,
+          dwi, dhi, nl);
+  buffer_len = strlen(buffer);
+
+  /*
+  char backgroundfillps[1024] = "";
+  if (qAlpha(bgcolor) > 0) {
+    sprintf(backgroundfillps,
+           // draw the background color, if any
+           "newpath "
+           "-2 -2 moveto "
+           "%s -2 lineto "
+           "%s %s lineto "
+           "-2 %s lineto "
+           "closepath "
+           "gsave "
+           "%s %s %s setrgbcolor "
+           "fill "
+           "grestore %s",
+           klfFmtDoubleCC(dwi+1, 'g', 6),
+           klfFmtDoubleCC(dwi+1, 'g', 6), klfFmtDoubleCC(dhi+1, 'g', 6),
+           klfFmtDoubleCC(dhi+1, 'g', 6),
+           // and the color, in RGB components:
+           klfFmtDoubleCC(qRed(bgcolor)/255.0, 'f', 6),
+           klfFmtDoubleCC(qGreen(bgcolor)/255.0, 'f', 6),
+           klfFmtDoubleCC(qBlue(bgcolor)/255.0, 'f', 6),
+           nl
+         );
+  }
+  */
+
+  char buffer2[1024];
+  int buffer2_len;
+  snprintf(buffer2, sizeof(buffer2)-1,
+          "%s"
+          "%%%%Page 1 1%s"
+          "%%%%PageBoundingBox 0 0 %d %d%s"
+          "<< /PageSize [%d %d] >> setpagedevice%s"
+          //"%s"
+          "%f %f scale%s"
+          "%f %f translate%s"
+          ,
+          nl,
+          nl,
+          wi, hi, nl,
+          wi, hi, nl,
+          //backgroundfillps,
+          vectorscale, vectorscale, nl,
+          offx, offy, nl);
+  buffer2_len = strlen(buffer2);
+
+  //    char buffer2[128];
+  //    snprintf(buffer2, 127, "%sgrestore%s", nl, nl);
+
+  //klfDbg("buffer is `"<<buffer<<"', length="<<buffer_len) ;
+  //klfDbg("rawepsdata has length="<<rawepsdata.size()) ;
+
+  // and modify the raw EPS data, to replace "%%BoundingBox:" instruction by 
our stuff...
+#ifdef KLFBACKEND_QT4
+  QByteArray neweps;
+  neweps = rawepsdata;
+#else
+  QCString neweps(rawepsdata.data(), rawepsdata.size()); // makes deep copy
+#endif
+  neweps.replace(i, len, buffer);
+
+  const char * endsetupstr = "%%EndSetup";
+  int i2 = neweps.s_indexOf(endsetupstr);
+  if (i2 < 0)
+    i2 = i + buffer_len; // add our info after modified %%BoundingBox'es 
instructions if %%EndSetup not found
+  else
+    i2 +=  strlen(endsetupstr);
+
+  neweps.replace(i2, 0, buffer2);
+  
+  qDebug("neweps has now length=%d",neweps.size());
+  qDebug("New eps bbox is [0 0 %.6g %.6g] with translate [%.6g %.6g] and scale 
%.6g.",
+            dwi, dhi, offx, offy, vectorscale);
+
+  epsdatacorrected->ba_assign(neweps);
+}
+
+
+
+
+
+
+
+
+
+
+
 void KLFBackend::cleanup(QString tempfname)
 {
   const char *skipcleanup = getenv("KLFBACKEND_LEAVE_TEMP_FILES");
@@ -674,9 +1026,14 @@
   if (QFile::exists(tempfname+".pdf")) QFile::remove(tempfname+".pdf");
 }
 
+
+
+
 // static private mutex object
 QMutex KLFBackend::__mutex;
 
+
+
 KLF_EXPORT bool operator==(const KLFBackend::klfInput& a, const 
KLFBackend::klfInput& b)
 {
   return a.latex == b.latex &&
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/klatexformula-3.2.7/src/klfbackend/klfblockprocess.cpp 
new/klatexformula-3.2.8/src/klfbackend/klfblockprocess.cpp
--- old/klatexformula-3.2.7/src/klfbackend/klfblockprocess.cpp  2013-06-23 
12:52:33.000000000 +0200
+++ new/klatexformula-3.2.8/src/klfbackend/klfblockprocess.cpp  2013-11-23 
20:25:36.000000000 +0100
@@ -19,7 +19,7 @@
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
-/* $Id: klfblockprocess.cpp 856 2013-06-23 10:38:35Z phfaist $ */
+/* $Id: klfblockprocess.cpp 862 2013-11-23 11:10:54Z phfaist $ */
 
 #include <ctype.h>
 
@@ -70,7 +70,7 @@
 
 bool KLFBlockProcess::startProcess(QStringList cmd, QByteArray stdindata, 
QStringList env)
 {
-  klfDbg("Running: "<<cmd<<", stdindata/size="<<stdindata.size());
+  //  klfDbg("Running: "<<cmd<<", stdindata/size="<<stdindata.size());
 
   _runstatus = 0;
 
@@ -87,7 +87,7 @@
       fn = klfSearchPath(cmd[0]);
     QFile fpeek(fn);
     if (!fpeek.open(QIODevice::ReadOnly)) {
-      klfDbg("cmd[0]="<<cmd[0]<<", Can't peek into file "<<fn<<"!") ;
+      //klfDbg("cmd[0]="<<cmd[0]<<", Can't peek into file "<<fn<<"!") ;
     } else {
       QByteArray line;
       int n = 0, j;
@@ -114,8 +114,8 @@
 
   QString program = cmd[0];
 
-  klfDbg("Running cmd="<<cmd);
-  klfDbg("env="<<env<<", curenv="<<environment());
+  //klfDbg("Running cmd="<<cmd);
+  //klfDbg("env="<<env<<", curenv="<<environment());
 
 #ifdef KLFBACKEND_QT4
   if (env.size() > 0) {
@@ -124,17 +124,17 @@
 
   QStringList args = cmd;
   args.erase(args.begin());
-  klfDbg("Starting "<<program<<", "<<args) ;
+  //klfDbg("Starting "<<program<<", "<<args) ;
   start(program, args);
   if ( ! waitForStarted() ) {
-    klfDbg("Can't wait for started! Error="<<error()) ;
+    //klfDbg("Can't wait for started! Error="<<error()) ;
     return false;
   }
 
   write(stdindata.constData(), stdindata.size());
   closeWriteChannel();
 
-  klfDbg("wrote input data (size="<<stdindata.size()<<")") ;
+  //klfDbg("wrote input data (size="<<stdindata.size()<<")") ;
 
 #else
   setArguments(cmd);
@@ -168,7 +168,7 @@
 #endif
 
   if (_runstatus < 0) { // some error occurred somewhere
-    klfDbg("some error occurred, _runstatus="<<_runstatus) ;
+    klfDbg("some error occurred, _runstatus="+QString("%1").arg(_runstatus)) ;
     return false;
   }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/klatexformula-3.2.7/src/klfbackend/klfdebug.h 
new/klatexformula-3.2.8/src/klfbackend/klfdebug.h
--- old/klatexformula-3.2.7/src/klfbackend/klfdebug.h   2013-06-23 
12:52:33.000000000 +0200
+++ new/klatexformula-3.2.8/src/klfbackend/klfdebug.h   2013-11-23 
20:25:36.000000000 +0100
@@ -19,7 +19,7 @@
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
-/* $Id: klfdebug.h 748 2012-01-01 15:06:40Z phfaist $ */
+/* $Id: klfdebug.h 862 2013-11-23 11:10:54Z phfaist $ */
 
 #ifndef KLFDEBUG_H
 #define KLFDEBUG_H
@@ -235,7 +235,7 @@
 #else
 #define KLF_ASSERT_CONDITION(expr, msg, failaction)                    \
   if ( !(expr) ) {                                                     \
-    qWarning("In function %s:\n\t%s", (QString("")+msg).local8Bit().data()); \
+    qWarning("In function %s:\n\t%s", KLF_FUNC_NAME, 
(QString("")+msg).local8Bit().data()); \
     failaction;                                                                
\
   }
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/klatexformula-3.2.7/src/klfbackend/klfqt34common.h 
new/klatexformula-3.2.8/src/klfbackend/klfqt34common.h
--- old/klatexformula-3.2.7/src/klfbackend/klfqt34common.h      2013-06-23 
12:52:33.000000000 +0200
+++ new/klatexformula-3.2.8/src/klfbackend/klfqt34common.h      2013-11-23 
20:25:36.000000000 +0100
@@ -19,7 +19,7 @@
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
-/* $Id: klfqt34common.h 603 2011-02-26 23:14:55Z phfaist $ */
+/* $Id: klfqt34common.h 862 2013-11-23 11:10:54Z phfaist $ */
 
 #ifndef KLFQT34COMMON_H
 #define KLFQT34COMMON_H
@@ -30,6 +30,7 @@
 #ifdef KLFBACKEND_QT4
 #define dir_native_separators(x) QDir::toNativeSeparators(x)
 #define ba_assign(otherba) operator=(otherba)
+#define buf_setdata(buf, ba_ref) buf.setData(ba_ref)
 #define dev_WRITEONLY QIODevice::WriteOnly
 #define dev_READONLY QIODevice::ReadOnly
 #define dev_write write
@@ -54,6 +55,7 @@
 #define QLatin1String QString::fromLatin1
 #define dir_native_separators(x) QDir::convertSeparators(x)
 #define ba_assign(otherba) duplicate((otherba).data(), (otherba).size())
+#define buf_setdata(buf, ba_ref) buf.setBuffer(ba_ref)
 #define dev_WRITEONLY IO_WriteOnly
 #define dev_READONLY IO_ReadOnly
 #define dev_write writeBlock

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to