diff --git a/qml/harbour-seaprint.qml b/qml/harbour-seaprint.qml
index f648720..c1957ae 100644
--- a/qml/harbour-seaprint.qml
+++ b/qml/harbour-seaprint.qml
@@ -79,6 +79,10 @@ ApplicationWindow
{
return {simple: "image", translatable: qsTr("images")};
}
+ else if(mimetype == Mimer.Plaintext)
+ {
+ return {simple: "plaintext", translatable: qsTr("plaintext")};
+ }
else
{
return {simple: "document", translatable: qsTr("documents")};
diff --git a/qml/pages/utils.js b/qml/pages/utils.js
index 8a08dac..ae5b94b 100644
--- a/qml/pages/utils.js
+++ b/qml/pages/utils.js
@@ -26,17 +26,21 @@ function supported_formats(printer, considerAdditionalFormats)
{
pdf = true;
mimetypes.push(Mimer.Mimer.PDF);
- plaintext = true;
- mimetypes.push(Mimer.Mimer.Plaintext);
}
+
if(has(formats, Mimer.Mimer.Postscript))
{
postscript = true;
mimetypes.push(Mimer.Mimer.Postscript);
}
- if((ConvertChecker.ConvertChecker.calligra) &&
- ( has(formats, Mimer.Mimer.PDF) || has(formats, Mimer.Mimer.Postscript) || raster ))
+ if(pdf || has(formats, Mimer.Mimer.Plaintext))
+ {
+ plaintext = true;
+ mimetypes.push(Mimer.Mimer.Plaintext);
+ }
+
+ if((ConvertChecker.ConvertChecker.calligra) && pdf)
{
office = true;
mimetypes = mimetypes.concat(Mimer.Mimer.OfficeFormats);
@@ -243,6 +247,8 @@ function ippName(name, value, printerStrings)
return qsTr("PDF");
case Mimer.Mimer.Postscript:
return qsTr("Postscript");
+ case Mimer.Mimer.Plaintext:
+ return qsTr("Plaintext");
case Mimer.Mimer.PWG:
return qsTr("PWG-raster");
case Mimer.Mimer.URF:
@@ -372,10 +378,12 @@ function endsWith(ending, string)
return string.lastIndexOf(ending) == (string.length - ending.length);
}
+var pdfTargets = [Mimer.Mimer.OctetStream, Mimer.Mimer.PDF, Mimer.Mimer.Postscript, Mimer.Mimer.PWG, Mimer.Mimer.URF];
+
+
function canConvertPdfTo(type)
{
- var targets = [Mimer.Mimer.OctetStream, Mimer.Mimer.PDF, Mimer.Mimer.Postscript, Mimer.Mimer.PWG, Mimer.Mimer.URF];
- return has(targets, type)
+ return has(pdfTargets, type)
}
function canTransferPostscriptAs(type)
@@ -384,10 +392,17 @@ function canTransferPostscriptAs(type)
return has(targets, type)
}
+function canConvertPlaintextTo(type)
+{
+ var targets = pdfTargets;
+ targets.push(Mimer.Mimer.Plaintext);
+ return has(targets, type)
+}
+
+
function canConvertOfficeDocumentTo(type)
{
- var targets = [Mimer.Mimer.OctetStream, Mimer.Mimer.PDF, Mimer.Mimer.Postscript, Mimer.Mimer.PWG, Mimer.Mimer.URF];
- return has(targets, type)
+ return has(pdfTargets, type)
}
function canConvertImageTo(type)
@@ -417,8 +432,7 @@ function fixupChoices(name, choices, mimeType)
}
else if(mimeType == Mimer.Mimer.Plaintext)
{
- // We convert plaintext to PDF internally
- return choices.filter(canConvertPdfTo)
+ return choices.filter(canConvertPlaintextTo)
}
else if(mimeType == Mimer.Mimer.Postscript)
{
diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp
index 2837d13..483fea8 100644
--- a/src/ippprinter.cpp
+++ b/src/ippprinter.cpp
@@ -18,6 +18,7 @@ IppPrinter::IppPrinter() : _worker(this)
connect(this, &IppPrinter::doGetJobs, &_worker, &PrinterWorker::getJobs);
connect(this, &IppPrinter::doCancelJob, &_worker, &PrinterWorker::cancelJob);
connect(this, &IppPrinter::doJustUpload, &_worker, &PrinterWorker::justUpload);
+ connect(this, &IppPrinter::doFixupPlaintext, &_worker, &PrinterWorker::fixupPlaintext);
connect(this, &IppPrinter::doFixupJpeg, &_worker, &PrinterWorker::fixupJpeg);
connect(this, &IppPrinter::doConvertPdf, &_worker, &PrinterWorker::convertPdf);
@@ -354,17 +355,22 @@ QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray
{
if(documentFormat == Mimer::OctetStream)
{
- if(mimeType == Mimer::PDF || mimeType == Mimer::Plaintext)
+ QStringList PdfPrioList = {Mimer::PDF, Mimer::Postscript, Mimer::PWG, Mimer::URF};
+ if(mimeType == Mimer::PDF)
{
- return firstMatch(supportedMimeTypes, {Mimer::PDF, Mimer::Postscript, Mimer::PWG, Mimer::URF });
+ return firstMatch(supportedMimeTypes, PdfPrioList);
}
else if(mimeType == Mimer::Postscript)
{
return firstMatch(supportedMimeTypes, {Mimer::Postscript});
}
+ else if(mimeType == Mimer::Plaintext)
+ {
+ return firstMatch(supportedMimeTypes, PdfPrioList << Mimer::Plaintext);
+ }
else if(Mimer::isOffice(mimeType))
{
- return firstMatch(supportedMimeTypes, {Mimer::PDF, Mimer::Postscript, Mimer::PWG, Mimer::URF });
+ return firstMatch(supportedMimeTypes, PdfPrioList);
}
else if(Mimer::isImage(mimeType))
{
@@ -697,7 +703,14 @@ void IppPrinter::print(QJsonObject jobAttrs, QString filename)
}
else if(mimeType == Mimer::Plaintext)
{
- emit doConvertPlaintext(filename, contents, Params);
+ if(targetFormat == Mimer::Plaintext)
+ {
+ emit doFixupPlaintext(filename, contents);
+ }
+ else
+ {
+ emit doConvertPlaintext(filename, contents, Params);
+ }
}
else if (Mimer::isImage(mimeType))
{
diff --git a/src/ippprinter.h b/src/ippprinter.h
index 1ad6a51..d0140e0 100644
--- a/src/ippprinter.h
+++ b/src/ippprinter.h
@@ -59,6 +59,7 @@ signals:
void doCancelJob(Bytestream msg);
void doJustUpload(QString filename, Bytestream header);
+ void doFixupPlaintext(QString filename, Bytestream header);
void doFixupJpeg(QString filename, Bytestream header);
void doConvertPdf(QString filename, Bytestream header, PrintParameters Params);
diff --git a/src/printerworker.cpp b/src/printerworker.cpp
index e46259d..9581e3e 100644
--- a/src/printerworker.cpp
+++ b/src/printerworker.cpp
@@ -101,6 +101,51 @@ catch(const ConvertFailedException& e)
}
}
+void PrinterWorker::fixupPlaintext(QString filename, Bytestream header)
+{
+try {
+ CurlRequester cr(_printer->httpUrl());
+ connect(&cr, &CurlRequester::done, _printer, &IppPrinter::printRequestFinished);
+
+ QFile inFile(filename);
+ if(!inFile.open(QIODevice::ReadOnly))
+ {
+ throw ConvertFailedException(tr("Failed to open file"));
+ }
+
+ QString allText = inFile.readAll();
+ if(allText.startsWith("\f"))
+ {
+ allText.remove(0, 1);
+ }
+
+ if(allText.endsWith("\f"))
+ {
+ allText.chop(1);
+ }
+ else if(allText.endsWith("\f\n"))
+ {
+ allText.chop(2);
+ }
+
+ QStringList lines;
+
+ foreach(QString rnline, allText.split("\r\n"))
+ {
+ lines.append(rnline.split("\n"));
+ }
+
+ QByteArray outData = lines.join("\r\n").toUtf8();
+
+ OK(cr.write((char*)header.raw(), header.size()));
+ OK(cr.write(outData.data(), outData.length()));
+}
+catch(const ConvertFailedException& e)
+{
+ emit failed(e.what() == QString("") ? tr("Upload error") : e.what());
+}
+}
+
void PrinterWorker::convertPdf(QString filename, Bytestream header, PrintParameters Params)
{
try {
diff --git a/src/printerworker.h b/src/printerworker.h
index 9923465..09e1779 100644
--- a/src/printerworker.h
+++ b/src/printerworker.h
@@ -41,6 +41,8 @@ public slots:
void fixupJpeg(QString filename, Bytestream header);
+ void fixupPlaintext(QString filename, Bytestream header);
+
void convertPdf(QString filename, Bytestream header, PrintParameters Params);
void convertImage(QString filename, Bytestream header, PrintParameters Params, QString targetFormat, QMargins margins);
diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts
index f1b4e1a..4b5d361 100644
--- a/translations/harbour-seaprint-de.ts
+++ b/translations/harbour-seaprint-de.ts
@@ -591,6 +591,10 @@ auf diesem Drucker
Dokumente
+
+
+
+
strings
@@ -5477,5 +5481,9 @@ auf diesem Drucker
Unbekannt
+
+
+
+
diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts
index 694961f..23de529 100644
--- a/translations/harbour-seaprint-es.ts
+++ b/translations/harbour-seaprint-es.ts
@@ -590,6 +590,10 @@
documentos
+
+
+
+
strings
@@ -5476,5 +5480,9 @@
+
+
+
+
diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts
index c9691b9..d1320f6 100644
--- a/translations/harbour-seaprint-fr.ts
+++ b/translations/harbour-seaprint-fr.ts
@@ -591,6 +591,10 @@ sur cette imprimante
documents
+
+
+
+
strings
@@ -5477,5 +5481,9 @@ sur cette imprimante
Inconnu
+
+
+
+
diff --git a/translations/harbour-seaprint-nl.ts b/translations/harbour-seaprint-nl.ts
index 0c593dd..099fda3 100644
--- a/translations/harbour-seaprint-nl.ts
+++ b/translations/harbour-seaprint-nl.ts
@@ -590,6 +590,10 @@
documenten
+
+
+
+
strings
@@ -5476,5 +5480,9 @@
Onbekend
+
+
+
+
diff --git a/translations/harbour-seaprint-pl.ts b/translations/harbour-seaprint-pl.ts
index e5b3a8f..6d6a98c 100644
--- a/translations/harbour-seaprint-pl.ts
+++ b/translations/harbour-seaprint-pl.ts
@@ -590,6 +590,10 @@
+
+
+
+
strings
@@ -5476,5 +5480,9 @@
Nieznana drukarka
+
+
+
+
diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts
index edfee96..a6401ce 100644
--- a/translations/harbour-seaprint-zh_CN.ts
+++ b/translations/harbour-seaprint-zh_CN.ts
@@ -590,6 +590,10 @@
文档
+
+
+
+
strings
@@ -5476,5 +5480,9 @@
未知
+
+
+
+