r23825 by jghali - Simplify handling of some PDF export parameters related to PDF/X output profile
scribus-commit
scribus-commit at lists.scribus.net
Fri May 22 01:17:58 UTC 2020
Author: jghali
Date: Fri May 22 01:17:58 2020
New Revision: 23825
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23825
Log:
Simplify handling of some PDF export parameters related to PDF/X output profile
Modified:
trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.cpp
trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.h
trunk/Scribus/scribus/colormgmt/sccolorprofile.cpp
trunk/Scribus/scribus/colormgmt/sccolorprofile.h
trunk/Scribus/scribus/colormgmt/sccolorprofiledata.h
trunk/Scribus/scribus/colormgmt/sclcms2colormgmtengineimpl.h
trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.cpp
trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.h
trunk/Scribus/scribus/pdflib.cpp
trunk/Scribus/scribus/pdflib.h
trunk/Scribus/scribus/pdflib_core.cpp
trunk/Scribus/scribus/pdflib_core.h
trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribus.h
trunk/Scribus/scribus/ui/pdfexportdialog.cpp
trunk/Scribus/scribus/ui/pdfexportdialog.h
trunk/Scribus/scribus/ui/tabpdfoptions.cpp
Modified: trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.cpp
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.cpp (original)
+++ trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.cpp Fri May 22 01:17:58 2020
@@ -68,3 +68,33 @@
}
return colorSpace;
}
+
+int ScColorMgmtEngineData::channelsOfColorspace(eColorSpaceType colorspace)
+{
+ if (colorspace == ColorSpace_Unknown)
+ return 0;
+ if (colorspace == ColorSpace_XYZ)
+ return 3;
+ if (colorspace == ColorSpace_Lab)
+ return 3;
+ if (colorspace == ColorSpace_Luv)
+ return 3;
+ if (colorspace == ColorSpace_YCbCr)
+ return 3;
+ if (colorspace == ColorSpace_Yxy)
+ return 3;
+ if (colorspace == ColorSpace_Rgb)
+ return 3;
+ if (colorspace == ColorSpace_Gray)
+ return 1;
+ if (colorspace == ColorSpace_Hsv)
+ return 3;
+ if (colorspace == ColorSpace_Hls)
+ return 3;
+ if (colorspace == ColorSpace_Cmyk)
+ return 4;
+ if (colorspace == ColorSpace_Cmy)
+ return 3;
+
+ return 0;
+}
Modified: trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.h
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.h (original)
+++ trunk/Scribus/scribus/colormgmt/sccolormgmtenginedata.h Fri May 22 01:17:58 2020
@@ -64,6 +64,8 @@
eRenderIntent proofingIntent, long transformFlags) = 0;
virtual ScColorSpace createColorSpace(ScColorProfile& profile, eColorFormat colorFormat);
+
+ static int channelsOfColorspace(eColorSpaceType colorspace);
};
#endif
Modified: trunk/Scribus/scribus/colormgmt/sccolorprofile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/colormgmt/sccolorprofile.cpp
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sccolorprofile.cpp (original)
+++ trunk/Scribus/scribus/colormgmt/sccolorprofile.cpp Fri May 22 01:17:58 2020
@@ -26,11 +26,32 @@
return ColorSpace_Unknown;
}
+eColorSpaceType ScColorProfile::connectionSpace() const
+{
+ if (m_data)
+ return m_data->connectionSpace();
+ return ColorSpace_Unknown;
+}
+
eProfileClass ScColorProfile::deviceClass() const
{
if (m_data)
return m_data->deviceClass();
return Class_Unknown;
+}
+
+int ScColorProfile::channelsOfColorSpace() const
+{
+ if (m_data)
+ return m_data->channelsOfColorSpace();
+ return 0;
+}
+
+int ScColorProfile::channelsOfConnectionSpace() const
+{
+ if (m_data)
+ return m_data->channelsOfConnectionSpace();
+ return 0;
}
QString ScColorProfile::dataHash() const
Modified: trunk/Scribus/scribus/colormgmt/sccolorprofile.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/colormgmt/sccolorprofile.h
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sccolorprofile.h (original)
+++ trunk/Scribus/scribus/colormgmt/sccolorprofile.h Fri May 22 01:17:58 2020
@@ -36,7 +36,11 @@
QString productDescription() const;
eColorSpaceType colorSpace() const;
+ eColorSpaceType connectionSpace() const;
eProfileClass deviceClass() const;
+
+ int channelsOfColorSpace() const;
+ int channelsOfConnectionSpace() const;
const ScColorProfileData* data() const { return m_data.data(); }
QString dataHash() const;
Modified: trunk/Scribus/scribus/colormgmt/sccolorprofiledata.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/colormgmt/sccolorprofiledata.h
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sccolorprofiledata.h (original)
+++ trunk/Scribus/scribus/colormgmt/sccolorprofiledata.h Fri May 22 01:17:58 2020
@@ -30,7 +30,12 @@
virtual bool isNull() const = 0;
virtual eColorSpaceType colorSpace() const = 0;
+ virtual eColorSpaceType connectionSpace() const = 0;
virtual eProfileClass deviceClass() const = 0;
+
+ virtual int channelsOfColorSpace() const = 0;
+ virtual int channelsOfConnectionSpace() const = 0;
+
virtual bool isSuitableForOutput() const = 0;
virtual QString productDescription() const = 0;
virtual bool save(QByteArray& profileData) const = 0;
Modified: trunk/Scribus/scribus/colormgmt/sclcms2colormgmtengineimpl.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/colormgmt/sclcms2colormgmtengineimpl.h
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sclcms2colormgmtengineimpl.h (original)
+++ trunk/Scribus/scribus/colormgmt/sclcms2colormgmtengineimpl.h Fri May 22 01:17:58 2020
@@ -47,7 +47,7 @@
const ScColorProfile& proofProfile , eRenderIntent renderIntent,
eRenderIntent proofingIntent, long transformFlags) override;
- protected:
+protected:
// Color profile cache
static QSharedPointer<ScColorProfileCache> m_profileCache;
Modified: trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.cpp
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.cpp (original)
+++ trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.cpp Fri May 22 01:17:58 2020
@@ -32,11 +32,38 @@
return ColorSpace_Unknown;
}
+eColorSpaceType ScLcms2ColorProfileImpl::connectionSpace() const
+{
+ if (m_profileHandle)
+ return ScLcms2ColorMgmtEngineImpl::translateLcmsColorSpaceType( cmsGetPCS(m_profileHandle) );
+ return ColorSpace_Unknown;
+}
+
eProfileClass ScLcms2ColorProfileImpl::deviceClass() const
{
if (m_profileHandle)
return ScLcms2ColorMgmtEngineImpl::translateLcmsProfileClass( cmsGetDeviceClass(m_profileHandle) );
return Class_Unknown;
+}
+
+int ScLcms2ColorProfileImpl::channelsOfColorSpace() const
+{
+ if (m_profileHandle)
+ {
+ eColorSpaceType colorspace = ScLcms2ColorMgmtEngineImpl::translateLcmsColorSpaceType( cmsGetColorSpace(m_profileHandle) );
+ return ScLcms2ColorMgmtEngineImpl::channelsOfColorspace(colorspace);
+ }
+ return 0;
+}
+
+int ScLcms2ColorProfileImpl::channelsOfConnectionSpace() const
+{
+ if (m_profileHandle)
+ {
+ eColorSpaceType colorspace = ScLcms2ColorMgmtEngineImpl::translateLcmsColorSpaceType( cmsGetPCS(m_profileHandle) );
+ return ScLcms2ColorMgmtEngineImpl::channelsOfColorspace(colorspace);
+ }
+ return 0;
}
bool ScLcms2ColorProfileImpl::isSuitableForOutput() const
Modified: trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.h
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.h (original)
+++ trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.h Fri May 22 01:17:58 2020
@@ -24,8 +24,13 @@
bool isNull() const override;
- eColorSpaceType colorSpace() const override;
+ eColorSpaceType colorSpace() const override;
+ eColorSpaceType connectionSpace() const override;
eProfileClass deviceClass() const override;
+
+ int channelsOfColorSpace() const override;
+ int channelsOfConnectionSpace() const override;
+
bool isSuitableForOutput() const override;
QString productDescription() const override;
bool save(QByteArray& profileData) const override;
Modified: trunk/Scribus/scribus/pdflib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/pdflib.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib.cpp (original)
+++ trunk/Scribus/scribus/pdflib.cpp Fri May 22 01:17:58 2020
@@ -8,15 +8,20 @@
Q_ASSERT(m_impl);
}
+PDFlib::PDFlib(ScribusDoc & docu, const PDFOptions& options)
+ : m_impl( new PDFLibCore(docu, options) )
+{
+
+}
+
PDFlib::~PDFlib()
{
delete static_cast<PDFLibCore*>(m_impl);
}
-bool PDFlib::doExport(const QString& fn, const QString& nam, int Components,
- const std::vector<int> & pageNs, const QMap<int, QImage>& thumbs)
+bool PDFlib::doExport(const QString& fn, const std::vector<int> & pageNs, const QMap<int, QImage>& thumbs)
{
- return static_cast<PDFLibCore*>(m_impl)->doExport(fn, nam, Components, pageNs, thumbs);
+ return static_cast<PDFLibCore*>(m_impl)->doExport(fn, pageNs, thumbs);
}
const QString& PDFlib::errorMessage()
Modified: trunk/Scribus/scribus/pdflib.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/pdflib.h
==============================================================================
--- trunk/Scribus/scribus/pdflib.h (original)
+++ trunk/Scribus/scribus/pdflib.h Fri May 22 01:17:58 2020
@@ -39,6 +39,7 @@
* \param docu Document to use in export process
*/
explicit PDFlib(ScribusDoc & docu);
+ explicit PDFlib(ScribusDoc & docu, const PDFOptions& options);
~PDFlib();
@@ -46,13 +47,10 @@
* Perform an export.
*
* \param fn Output file name
- * \param nam ??
- * \param Components ??
* \param pageNs List of pages from document to be exported as sequential PDF pages
* \param thumbs A mapping of input (document) page numbers to pre-rendered thumbnails.
*/
- bool doExport(const QString& fn, const QString& nam, int Components,
- const std::vector<int> & pageNs, const QMap<int, QImage>& thumbs);
+ bool doExport(const QString& fn, const std::vector<int> & pageNs, const QMap<int, QImage>& thumbs);
/**
* Return an error message in case export has failed.
Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Fri May 22 01:17:58 2020
@@ -525,10 +525,16 @@
};
PDFLibCore::PDFLibCore(ScribusDoc & docu)
+ : PDFLibCore(docu, docu.pdfOptions())
+{
+
+}
+
+PDFLibCore::PDFLibCore(ScribusDoc & docu, const PDFOptions& options)
: QObject(&docu),
doc(docu),
ActPageP(nullptr),
- Options(doc.pdfOptions()),
+ Options(options),
Bvie(nullptr),
ucs2Codec(nullptr),
ResNam("RE"),
@@ -543,11 +549,6 @@
bleedDisplacementX(0),
bleedDisplacementY(0)
{
-// KeyGen.resize(32);
-// OwnerKey.resize(32);
-// UserKey.resize(32);
-// FileID.resize(16);
-// EncryKey.resize(5);
Catalog.Outlines = 2;
Catalog.PageTree = 3;
Catalog.Dest = 4;
@@ -556,11 +557,7 @@
Outlines.Count = 0;
pageData.ObjNum = 0;
pageData.Thumb = 0;
-// int kg_array[] = {0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa,
-// 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe,
-// 0x64, 0x53, 0x69, 0x7a};
-// for (int a = 0; a < 32; ++a)
-// KeyGen[a] = kg_array[a];
+
if (usingGUI)
{
progressDialog = new MultiProgressDialog( tr("Saving PDF"), CommonStrings::tr_Cancel, doc.scMW());
@@ -603,8 +600,7 @@
return false;
}
-bool PDFLibCore::doExport(const QString& fn, const QString& nam, int Components,
- const std::vector<int> & pageNs, const QMap<int, QImage> & thumbs)
+bool PDFLibCore::doExport(const QString& fn, const std::vector<int> & pageNs, const QMap<int, QImage> & thumbs)
{
QImage thumb;
bool ret = false, error = false;
@@ -687,7 +683,7 @@
if (!abortExport)
{
if (PDF_IsPDFX(doc.pdfOptions().Version))
- ret = PDF_End_Doc(ScCore->PrinterProfiles[doc.pdfOptions().PrintProf], nam, Components);
+ ret = PDF_End_Doc(ScCore->PrinterProfiles[doc.pdfOptions().PrintProf]);
else
ret = PDF_End_Doc();
}
@@ -1004,8 +1000,6 @@
delete rc4Encode;
return (succeed ? bytesWritten : 0);
}
-
-
bool PDFLibCore::PDF_Begin_Doc(const QString& fn, SCFonts &AllFonts, const QMap<QString, QMap<uint, FPointArray> >& DocFonts, BookMView* vi)
{
@@ -10911,7 +10905,7 @@
return true;
}
-bool PDFLibCore::PDF_End_Doc(const QString& PrintPr, const QString& Name, int Components)
+bool PDFLibCore::PDF_End_Doc(const QString& outputProfilePath)
{
PDF_End_Bookmarks();
PDF_End_Resources();
@@ -10922,7 +10916,9 @@
PDF_End_JavaScripts();
PDF_End_Articles();
PDF_End_Layers();
- PDF_End_OutputProfile(PrintPr, Name, Components);
+ bool success = PDF_End_OutputProfile(outputProfilePath);
+ if (!success)
+ return false;
PDF_End_Metadata();
return PDF_End_XRefAndTrailer();
}
@@ -11304,51 +11300,50 @@
}
}
-void PDFLibCore::PDF_End_OutputProfile(const QString& PrintPr, const QString& Name, int Components)
-{
- if (PDF_IsPDFX())
- {
- PdfId profileObj =writer.startObj();
- QByteArray dataP;
- loadRawBytes(PrintPr, dataP);
- PutDoc("<<\n");
- if (Options.Compress)
- {
- QByteArray compData = CompressArray(dataP);
- if (compData.size() > 0)
- {
- PutDoc("/Filter /FlateDecode\n");
- dataP = compData;
- }
- }
- PutDoc("/Length " + Pdf::toPdf(dataP.size() + 1) + "\n");
- PutDoc("/N " + Pdf::toPdf(Components) + "\n");
- PutDoc(">>\nstream\n");
- PutDoc(dataP);
- PutDoc("\nendstream");
- writer.endObj(profileObj);
-
-// if ((Options.Version == PDFVersion::PDF_X4) && (Options.useLayers))
-// {
-// XRef[9] = bytesWritten();
-// PutDoc("10 0 obj\n");
-// }
-// if ((Options.Version == PDFVersion::PDF_X3) || (Options.Version == PDFVersion::PDF_X1a) || ((Options.Version == PDFVersion::PDF_X4) && !(Options.useLayers)))
-// {
-// XRef[8] = bytesWritten();
-// PutDoc("9 0 obj\n");
-// }
+bool PDFLibCore::PDF_End_OutputProfile(const QString& profilePath)
+{
+ if (!PDF_IsPDFX())
+ return true;
+
+ PdfId profileObj = writer.startObj();
+ QByteArray dataP;
+ if (!loadRawBytes(profilePath, dataP))
+ return false;
+
+ ScColorProfile colorProfile = doc.colorEngine.openProfileFromMem(dataP);
+ if (colorProfile.isNull())
+ return false;
+ QString profileDesc = colorProfile.productDescription();
+ int components = colorProfile.channelsOfColorSpace();
+
+ PutDoc("<<\n");
+ if (Options.Compress)
+ {
+ QByteArray compData = CompressArray(dataP);
+ if (compData.size() > 0)
+ {
+ PutDoc("/Filter /FlateDecode\n");
+ dataP = compData;
+ }
+ }
+ PutDoc("/Length " + Pdf::toPdf(dataP.size() + 1) + "\n");
+ PutDoc("/N " + Pdf::toPdf(components) + "\n");
+ PutDoc(">>\nstream\n");
+ PutDoc(dataP);
+ PutDoc("\nendstream");
+ writer.endObj(profileObj);
- writer.startObj(writer.OutputIntentObj);
-
- PutDoc("<<\n/Type /OutputIntent\n/S /GTS_PDFX\n");
- PutDoc("/DestOutputProfile " + Pdf::toObjRef(profileObj) + "\n");
- PutDoc("/OutputConditionIdentifier (Custom)\n");
- PutDoc("/Info " + Pdf::toLiteralString(Options.Info) + "\n");
- PutDoc("/OutputCondition " + Pdf::toLiteralString(Name) + "\n");
- PutDoc(">>");
- writer.endObj(writer.OutputIntentObj);
- }
+ writer.startObj(writer.OutputIntentObj);
+
+ PutDoc("<<\n/Type /OutputIntent\n/S /GTS_PDFX\n");
+ PutDoc("/DestOutputProfile " + Pdf::toObjRef(profileObj) + "\n");
+ PutDoc("/OutputConditionIdentifier (Custom)\n");
+ PutDoc("/Info " + Pdf::toLiteralString(Options.Info) + "\n");
+ PutDoc("/OutputCondition " + Pdf::toLiteralString(profileDesc) + "\n");
+ PutDoc(">>");
+ writer.endObj(writer.OutputIntentObj);
+
+ return true;
}
void PDFLibCore::PDF_End_Metadata()
Modified: trunk/Scribus/scribus/pdflib_core.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/pdflib_core.h
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.h (original)
+++ trunk/Scribus/scribus/pdflib_core.h Fri May 22 01:17:58 2020
@@ -65,8 +65,10 @@
public:
explicit PDFLibCore(ScribusDoc & docu);
+ explicit PDFLibCore(ScribusDoc & docu, const PDFOptions& options);
~PDFLibCore();
- bool doExport(const QString& fn, const QString& nam, int Components, const std::vector<int> & pageNs, const QMap<int, QImage> & thumbs);
+
+ bool doExport(const QString& fn, const std::vector<int> & pageNs, const QMap<int, QImage> & thumbs);
const QString& errorMessage() const;
bool exportAborted() const;
@@ -125,7 +127,7 @@
bool PDF_ProcessMasterElements(const ScLayer& layer, const ScPage* page, uint PNr);
bool PDF_ProcessPageElements(const ScLayer& layer, const ScPage* page, uint PNr);
- bool PDF_End_Doc(const QString& PrintPr = "", const QString& Name = "", int Components = 0);
+ bool PDF_End_Doc(const QString& outputProfilePath = QString());
void PDF_End_Bookmarks();
void PDF_End_Resources();
void PDF_End_Outlines();
@@ -135,7 +137,7 @@
void PDF_End_JavaScripts();
void PDF_End_Articles();
void PDF_End_Layers();
- void PDF_End_OutputProfile(const QString& PrintPr, const QString& Name, int Components);
+ bool PDF_End_OutputProfile(const QString& profilePath);
void PDF_End_Metadata();
bool PDF_End_XRefAndTrailer();
bool closeAndCleanup();
Modified: trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp Fri May 22 01:17:58 2020
@@ -1261,8 +1261,6 @@
// copied from file scribus.cpp
//void ScribusMainWindow::SaveAsPDF()
- int Components = 3;
- QString nam = "";
if (ScCore->primaryMainWindow()->bookmarkPalette->BView->topLevelItemCount() == 0)
pdfOptions.Bookmarks = false;
@@ -1457,15 +1455,6 @@
pdfOptions.Version == PDFVersion::PDF_X3 ||
pdfOptions.Version == PDFVersion::PDF_X4)
{
- ScColorProfile profile;
- profile = ScCore->defaultEngine.openProfileFromFile(ScCore->PrinterProfiles[pdfOptions.PrintProf]);
- nam = profile.productDescription();
- if (profile.colorSpace() == ColorSpace_Rgb)
- Components = 3;
- if (profile.colorSpace() == ColorSpace_Cmyk)
- Components = 4;
- if (profile.colorSpace() == ColorSpace_Cmy)
- Components = 3;
pdfOptions.Info = PyUnicode_asQString(self->info);
pdfOptions.Encrypt = false;
pdfOptions.PresentMode = false;
@@ -1523,7 +1512,7 @@
pdfOptions.firstUse = false;
QString errorMessage;
- bool success = ScCore->primaryMainWindow()->getPDFDriver(fn, nam, Components, pageNs, thumbs, errorMessage);
+ bool success = ScCore->primaryMainWindow()->getPDFDriver(fn, pageNs, thumbs, errorMessage);
if (!success) {
fn = "Cannot write the File: " + fn;
if (!errorMessage.isEmpty())
Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp Fri May 22 01:17:58 2020
@@ -336,7 +336,7 @@
QString tf = pdfOptions.fileName;
if (tf.isEmpty()) {
QFileInfo fi = QFileInfo(currentDoc->documentFileName());
- tf = fi.path()+"/"+fi.baseName()+".pdf";
+ tf = fi.path() + "/" + fi.baseName() + ".pdf";
}
PyObject *file = nullptr;
file = PyString_FromString(tf.toLatin1());
@@ -414,10 +414,9 @@
// set to print all pages
PyObject *pages = nullptr;
- int num = 0;
// which one should I use ???
// new = ScCore->primaryMainWindow()->view->Pages.count()
- num = currentDoc->Pages->count();
+ int num = currentDoc->Pages->count();
pages = PyList_New(num);
if (!pages){
PyErr_SetString(PyExc_SystemError, "Can not initialize 'pages' attribute");
@@ -485,7 +484,6 @@
self->presentation = pdfOptions.PresentMode;
// set effects values for all pages
PyObject *effval = nullptr;
- num = 0;
// which one should I use ???
// new = ScCore->primaryMainWindow()->view->Pages.count();
num = currentDoc->Pages->count();
@@ -933,7 +931,7 @@
return -1;
}
int n = PyInt_AsLong(value);
- if (n!=0 && (n<35 || n>PyInt_AsLong(self->resolution))) {
+ if (n != 0 && (n < 35 || n > PyInt_AsLong(self->resolution))) {
PyErr_SetString(PyExc_TypeError, "'downsample' value must be 0 or in interval from 35 to value of 'resolution'");
return -1;
}
@@ -1263,8 +1261,6 @@
// copied from file scribus.cpp
//void ScribusMainWindow::SaveAsPDF()
- int Components = 3;
- QString nam = "";
if (ScCore->primaryMainWindow()->bookmarkPalette->BView->topLevelItemCount() == 0)
pdfOptions.Bookmarks = false;
@@ -1330,7 +1326,7 @@
pdfOptions.fileName = fn;
// apply pages attribute
std::vector<int> pageNs;
- int nn=PyList_Size(self->pages);
+ int nn = PyList_Size(self->pages);
for (int i = 0; i < nn; ++i) {
pageNs.push_back((int)PyInt_AsLong(PyList_GetItem(self->pages, i)));
}
@@ -1404,8 +1400,7 @@
// return nullptr;
// }
// pdfOptions.LPISettings[QString(s)]=lpi;
- QString st;
- st = QString(PyString_AsString(PyList_GetItem(t,0)));
+ QString st = QString(PyString_AsString(PyList_GetItem(t,0)));
lpi.Frequency = PyInt_AsLong(PyList_GetItem(t, 1));
lpi.Angle = PyInt_AsLong(PyList_GetItem(t, 2));
lpi.SpotFunc = PyInt_AsLong(PyList_GetItem(t, 3));
@@ -1460,15 +1455,6 @@
pdfOptions.Version == PDFVersion::PDF_X3 ||
pdfOptions.Version == PDFVersion::PDF_X4)
{
- ScColorProfile profile;
- profile = ScCore->defaultEngine.openProfileFromFile(ScCore->PrinterProfiles[pdfOptions.PrintProf]);
- nam = profile.productDescription();
- if (profile.colorSpace() == ColorSpace_Rgb)
- Components = 3;
- if (profile.colorSpace() == ColorSpace_Cmyk)
- Components = 4;
- if (profile.colorSpace() == ColorSpace_Cmy)
- Components = 3;
pdfOptions.Info = PyString_AsString(self->info);
pdfOptions.Encrypt = false;
pdfOptions.PresentMode = false;
@@ -1526,7 +1512,7 @@
pdfOptions.firstUse = false;
QString errorMessage;
- bool success = ScCore->primaryMainWindow()->getPDFDriver(fn, nam, Components, pageNs, thumbs, errorMessage);
+ bool success = ScCore->primaryMainWindow()->getPDFDriver(fn, pageNs, thumbs, errorMessage);
if (!success) {
fn = "Cannot write the File: " + fn;
if (!errorMessage.isEmpty())
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Fri May 22 01:17:58 2020
@@ -7156,13 +7156,13 @@
}
}
-bool ScribusMainWindow::getPDFDriver(const QString &filename, const QString &name, int components, const std::vector<int> & pageNumbers,
+bool ScribusMainWindow::getPDFDriver(const QString &filename, const std::vector<int> & pageNumbers,
const QMap<int, QImage>& thumbs, QString& error, bool* cancelled)
{
ScCore->fileWatcher->forceScan();
ScCore->fileWatcher->stop();
PDFlib pdflib(*doc);
- bool ret = pdflib.doExport(filename, name, components, pageNumbers, thumbs);
+ bool ret = pdflib.doExport(filename, pageNumbers, thumbs);
if (!ret)
error = pdflib.errorMessage();
if (cancelled)
@@ -7248,8 +7248,6 @@
std::vector<int> pageNs;
uint pageNumbersSize;
QMap<int, QImage> allThumbs, thumbs;
- int components = dia.colorSpaceComponents();
- QString nam(dia.cmsDescriptor());
QString fileName = doc->pdfOptions().fileName;
QString errorMsg;
parsePagesString(pageString, &pageNs, doc->DocPages.count());
@@ -7305,8 +7303,8 @@
if (doc->pdfOptions().Thumbnails)
thumb = allThumbs[pageNs[aa]];
thumbs.insert(1, thumb);
- QString realName = QDir::toNativeSeparators(path+"/"+name+ tr("-Page%1").arg(pageNs[aa], 3, 10, QChar('0'))+"."+ext);
- if (!getPDFDriver(realName, nam, components, pageNs2, thumbs, errorMsg, &cancelled))
+ QString realName = QDir::toNativeSeparators(path + "/" + name + tr("-Page%1").arg(pageNs[aa], 3, 10, QChar('0')) + "." + ext);
+ if (!getPDFDriver(realName, pageNs2, thumbs, errorMsg, &cancelled))
{
qApp->restoreOverrideCursor();
QString message = tr("Cannot write the file: \n%1").arg(doc->pdfOptions().fileName);
@@ -7320,7 +7318,7 @@
}
else
{
- if (!getPDFDriver(fileName, nam, components, pageNs, allThumbs, errorMsg))
+ if (!getPDFDriver(fileName, pageNs, allThumbs, errorMsg))
{
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
QString message = tr("Cannot write the file: \n%1").arg(doc->pdfOptions().fileName);
Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Fri May 22 01:17:58 2020
@@ -164,7 +164,7 @@
void applyNewMaster(const QString& name);
void updateRecent(const QString& fn);
void doPasteRecent(const QString& data);
- bool getPDFDriver(const QString & filename, const QString & name, int components, const std::vector<int> & pageNumbers, const QMap<int, QImage> & thumbs, QString& error, bool* cancelled = nullptr);
+ bool getPDFDriver(const QString & filename, const std::vector<int> & pageNumbers, const QMap<int, QImage> & thumbs, QString& error, bool* cancelled = nullptr);
bool DoSaveAsEps(const QString& fn, QString& error);
QString CFileDialog(const QString& workingDirectory = ".", const QString& dialogCaption = "", const QString& fileFilter = "", const QString& defNa = "",
int optionFlags = fdExistingFiles, bool *useCompression = 0, bool *useFonts = 0, bool *useProfiles = 0);
Modified: trunk/Scribus/scribus/ui/pdfexportdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/ui/pdfexportdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pdfexportdialog.cpp (original)
+++ trunk/Scribus/scribus/ui/pdfexportdialog.cpp Fri May 22 01:17:58 2020
@@ -56,8 +56,6 @@
m_doc(currView->m_doc),
m_opts(pdfOptions),
m_unitRatio(currView->m_doc->unitRatio()),
- m_cmsDescriptor(""),
- m_components(3),
m_printerProfiles(printerProfiles)
{
setModal(true);
@@ -386,14 +384,6 @@
m_opts.PrintProf = Options->PrintProfC->currentText();
if ((m_opts.Version == PDFVersion::PDF_X3) || (m_opts.Version == PDFVersion::PDF_X1a) || (m_opts.Version == PDFVersion::PDF_X4))
{
- ScColorProfile hIn = m_doc->colorEngine.openProfileFromFile( m_printerProfiles[m_opts.PrintProf] );
- m_cmsDescriptor = hIn.productDescription();
- if (hIn.colorSpace() == ColorSpace_Rgb)
- m_components = 3;
- if (hIn.colorSpace() == ColorSpace_Cmyk)
- m_components = 4;
- if (hIn.colorSpace() == ColorSpace_Cmy)
- m_components = 3;
m_opts.Info = Options->InfoString->text();
m_opts.Encrypt = false;
m_opts.MirrorH = false;
@@ -412,16 +402,6 @@
}
}
-const QString& PDFExportDialog::cmsDescriptor()
-{
- return m_cmsDescriptor;
-}
-
-int PDFExportDialog::colorSpaceComponents()
-{
- return m_components;
-}
-
QString PDFExportDialog::getPagesString()
{
if (Options->AllPages->isChecked())
Modified: trunk/Scribus/scribus/ui/pdfexportdialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/ui/pdfexportdialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/pdfexportdialog.h (original)
+++ trunk/Scribus/scribus/ui/pdfexportdialog.h Fri May 22 01:17:58 2020
@@ -50,8 +50,6 @@
~PDFExportDialog() {};
void updateDocOptions();
- const QString &cmsDescriptor();
- int colorSpaceComponents();
QString getPagesString();
protected slots:
@@ -80,8 +78,6 @@
QList<PDFPresentationData> m_presEffects;
PDFOptions & m_opts;
double m_unitRatio;
- QString m_cmsDescriptor;
- int m_components;
const ProfilesL & m_printerProfiles;
};
Modified: trunk/Scribus/scribus/ui/tabpdfoptions.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23825&path=/trunk/Scribus/scribus/ui/tabpdfoptions.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/tabpdfoptions.cpp (original)
+++ trunk/Scribus/scribus/ui/tabpdfoptions.cpp Fri May 22 01:17:58 2020
@@ -462,10 +462,9 @@
hideToolBar->setChecked(Opts.hideToolBar);
hideMenuBar->setChecked(Opts.hideMenuBar);
fitWindow->setChecked(Opts.fitWindow);
- QMap<QString,QString>::Iterator itja;
actionCombo->clear();
actionCombo->addItem( tr("No Script"));
- for (itja = m_Doc->JavaScripts.begin(); itja != m_Doc->JavaScripts.end(); ++itja)
+ for (auto itja = m_Doc->JavaScripts.begin(); itja != m_Doc->JavaScripts.end(); ++itja)
actionCombo->addItem(itja.key());
if (m_Doc->JavaScripts.contains(Opts.openAction))
setCurrentComboItem(actionCombo, Opts.openAction);
More information about the scribus-commit
mailing list