r20329 by craig - Barcode Generator update from Terry: Store and show barcode entry errors to the user
scribus-commit
scribus-commit at lists.scribus.net
Sun Aug 16 09:56:18 UTC 2015
Author: craig
Date: Sun Aug 16 09:56:18 2015
New Revision: 20329
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20329
Log:
Barcode Generator update from Terry: Store and show barcode entry errors to the user
Modified:
trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h
trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.ui
Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20329&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp (original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp Sun Aug 16 09:56:18 2015
@@ -292,6 +292,8 @@
tmpFile = QDir::toNativeSeparators(ScPaths::getTempFileDir() + "bcode.png");
psFile = QDir::toNativeSeparators(ScPaths::getTempFileDir() + "bcode.ps");
+ fileStdErr = QDir::toNativeSeparators(ScPaths::getTempFileDir() + "bcode.err");
+ fileStdOut = QDir::toNativeSeparators(ScPaths::getTempFileDir() + "bcode.out");
paintBarcodeTimer=new QTimer(this);
paintBarcodeTimer->setSingleShot(true);
@@ -305,6 +307,8 @@
{
QFile::remove(psFile);
QFile::remove(tmpFile);
+ QFile::remove(fileStdErr);
+ QFile::remove(fileStdOut);
if (paintBarcodeTimer)
{
@@ -703,6 +707,23 @@
foreach (req, resreqs[enc].split(" "))
psCommand.append(resbodys[req]);
psCommand.append(resbodys[enc]);
+ psCommand.append(
+ "errordict begin\n"
+ "/handleerror {\n"
+ "$error begin\n"
+ "errorname dup length string cvs 0 6 getinterval (bwipp.) eq {\n"
+ "(%stderr) (w) file\n"
+ "dup (\nBWIPP ERROR: ) writestring\n"
+ "dup errorname dup length string cvs writestring\n"
+ "dup ( ) writestring\n"
+ "dup errorinfo dup length string cvs writestring\n"
+ "dup (\n) writestring\n"
+ "dup flushfile end quit\n"
+ "} if\n"
+ "end //handleerror exec\n"
+ "} bind def\n"
+ "end\n"
+ );
QString comm("20 10 moveto <%1> <%2> /%3 /uk.co.terryburton.bwipp findresource exec\n");
QString bcdata(ui.codeEdit->text().toLatin1().toHex());
QString bcopts(opts.toLatin1().toHex());
@@ -732,7 +753,7 @@
gargs.append( psFile );
qApp->changeOverrideCursor(Qt::WaitCursor);
QFile::remove(realFile);
- int gs = callGS(gargs);
+ int gs = callGS(gargs,NULL,fileStdErr,fileStdOut);
bool retval = gs==0 && QFile::exists(realFile); // GS returns 0 for BWIPP-handled errors
qApp->changeOverrideCursor(Qt::ArrowCursor);
// qApp->restoreOverrideCursor();
@@ -746,8 +767,21 @@
}
else
{
-// TODO capture gs output and display handled errors
- ui.sampleLabel->setText("<qt>" + tr("Barcode incomplete") + "</qt>");
+ QString errorMsg="<qt>" + tr("Barcode incomplete") + "</qt>";
+ if (QFile::exists(fileStdErr)) // Display BWIPP handled error message
+ {
+ QFile f(fileStdErr);
+ f.open(QIODevice::ReadOnly);
+ QTextStream ts(&f);
+ QString err = ts.readAll();
+ f.close();
+ QRegExp rx("[\\r\\n]+BWIPP ERROR: [^\\s]+ (.*)[\\r\\n$]+");
+ rx.setMinimal(true);
+ if (rx.indexIn(err) != -1)
+ errorMsg=rx.cap(1).trimmed();
+
+ }
+ ui.sampleLabel->setText(errorMsg);
}
return retval;
}
Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20329&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h (original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h Sun Aug 16 09:56:18 2015
@@ -118,6 +118,10 @@
QString tmpFile;
//! \brief A temporary PS file to store commants for Ghostscript.
QString psFile;
+ //! \brief A temporary file to store stderr from Ghostscript.
+ QString fileStdErr;
+ //! \brief A temporary file to store stdout from Ghostscript.
+ QString fileStdOut;
QColor guiColor;
/*! \brief Create bitmap for current BC.
Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20329&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.ui
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.ui (original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.ui Sun Aug 16 09:56:18 2015
@@ -406,7 +406,7 @@
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
- <bool>false</bool>
+ <bool>true</bool>
</property>
</widget>
</item>
More information about the scribus-commit
mailing list