r24717 by jghali - Code cleanup
scribus-commit
scribus-commit at lists.scribus.net
Sat Oct 2 21:37:15 UTC 2021
Author: jghali
Date: Sat Oct 2 21:37:15 2021
New Revision: 24717
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24717
Log:
Code cleanup
Modified:
trunk/Scribus/scribus/pdflib_core.cpp
trunk/Scribus/scribus/pdflib_core.h
trunk/Scribus/scribus/pdfwriter.cpp
trunk/Scribus/scribus/pdfwriter.h
Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24717&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Sat Oct 2 21:37:15 2021
@@ -121,30 +121,24 @@
QByteArray m_backBuffer;
QByteArray m_glyphBuffer;
QByteArray m_pathBuffer;
-// PageItem* m_item;
QMap<QString, PdfFont> m_UsedFontsP;
PDFLibCore *m_pdf;
uint m_PNr;
const ScPage* m_page;
QByteArray m_prevFontName;
- int m_prevFontSize;
-
- QByteArray transformToStr(const QTransform& tr)
+ int m_prevFontSize { - 1 };
+
+ QByteArray transformToStr(const QTransform& tr) const
{
return FToStr(tr.m11()) + " " + FToStr(-tr.m12()) + " " + FToStr(-tr.m21()) + " " + FToStr(tr.m22()) + " " + FToStr(tr.dx()) + " " + FToStr(-tr.dy());
}
public:
- PdfPainter(PageItem *ite, PDFLibCore *pdf, uint num, const ScPage* pag) :
- m_backBuffer(),
- m_glyphBuffer(),
- m_pathBuffer(),
-// m_item(ite),
+ PdfPainter(PDFLibCore *pdf, uint num, const ScPage* pag) :
m_pdf(pdf),
m_PNr(num),
- m_page(pag),
- m_prevFontSize(-1)
+ m_page(pag)
{}
~PdfPainter() {}
@@ -533,21 +527,8 @@
PDFLibCore::PDFLibCore(ScribusDoc & docu, const PDFOptions& options)
: QObject(&docu),
doc(docu),
- ActPageP(nullptr),
Options(options),
- Bvie(nullptr),
- ucs2Codec(nullptr),
- ResNam("RE"),
- ResCount(0),
- NDnam("LI"),
- NDnum(0),
- spotNam("Spot"),
- spotCount(0),
- progressDialog(nullptr),
- abortExport(false),
- usingGUI(ScCore->usingGUI()),
- bleedDisplacementX(0),
- bleedDisplacementY(0)
+ usingGUI(ScCore->usingGUI())
{
Catalog.Outlines = 2;
Catalog.PageTree = 3;
@@ -578,7 +559,7 @@
}
-bool PDFLibCore::PDF_IsPDFX()
+bool PDFLibCore::PDF_IsPDFX() const
{
if (Options.Version == PDFVersion::PDF_X1a)
return true;
@@ -589,7 +570,7 @@
return false;
}
-bool PDFLibCore::PDF_IsPDFX(const PDFVersion& ver)
+bool PDFLibCore::PDF_IsPDFX(const PDFVersion& ver) const
{
if (ver == PDFVersion::PDF_X1a)
return true;
@@ -709,108 +690,62 @@
#define PutDoc(s) writer.write(s)
//#define newObject() writer.newObject()
-
-//void PDFLibCore::StartObj(PdfId nr)
-//{
-// for (int i=XRef.size(); i < nr; ++i)
-// XRef.append(0);
-// XRef[nr-1] = bytesWritten();
-// PutDoc(Pdf::toPdf(nr) + " 0 obj\n");
-//}
-
-//// Encode a string for inclusion in a
-//// PDF (literal) .
-//static QByteArray PDFEncode(const QString & in)
-//{
-// QByteArray tmp("");
-// for (int d = 0; d < in.length(); ++d)
-// {
-// QChar cc(in.at(d));
-// if ((cc == '(') || (cc == ')') || (cc == '\\'))
-// tmp += '\\';
-// else if ((cc == '\r') || (cc == '\n'))
-// {
-// tmp += (cc == '\r') ? "\\r" : "\\n";
-// continue;
-// }
-// tmp += cc;
-// }
-// return tmp;
-//}
-
static QByteArray blendMode(int code)
{
switch (code)
{
case 0:
- return("Normal");
+ return "Normal";
break;
case 1:
- return("Darken");
+ return "Darken";
break;
case 2:
- return("Lighten");
+ return "Lighten";
break;
case 3:
- return("Multiply");
+ return "Multiply";
break;
case 4:
- return("Screen");
+ return "Screen";
break;
case 5:
- return("Overlay");
+ return "Overlay";
break;
case 6:
- return("HardLight");
+ return "HardLight";
break;
case 7:
- return("SoftLight");
+ return "SoftLight";
break;
case 8:
- return("Difference");
+ return "Difference";
break;
case 9:
- return("Exclusion");
+ return "Exclusion";
break;
case 10:
- return("ColorDodge");
+ return "ColorDodge";
break;
case 11:
- return("ColorBurn");
+ return "ColorBurn";
break;
case 12:
- return("Hue");
+ return "Hue";
break;
case 13:
- return("Saturation");
+ return "Saturation";
break;
case 14:
- return("Color");
+ return "Color";
break;
case 15:
- return("Luminosity");
+ return "Luminosity";
break;
default:
return "";
}
}
-//
-//QByteArray PDFLibCore::EncodeUTF16(const QString &in)
-//{
-// QString tmp = in;
-// QByteArray cres = ucs2Codec->fromUnicode( tmp );
-//#ifndef WORDS_BIGENDIAN
-// // on little endian systems we need to swap bytes:
-// uchar sw;
-// for (int d = 0; d < cres.size() - 1; d += 2)
-// {
-// sw = cres[d];
-// cres[d] = cres[d+1];
-// cres[d+1] = sw;
-// }
-//#endif
-// return cres;
-//}
QByteArray PDFLibCore::EncStream(const QByteArray & in, PdfId ObjNum)
{
@@ -819,19 +754,6 @@
if (!Options.Encrypt)
return in;
return writer.encryptBytes(in, ObjNum);
-// rc4_context_t rc4;
-// QByteArray tmp(in);
-// QByteArray us(tmp.length(), ' ');
-// QByteArray ou(tmp.length(), ' ');
-// for (int a = 0; a < tmp.length(); ++a)
-// us[a] = (tmp.at(a));
-// QByteArray step1 = writer.ComputeRC4Key(ObjNum);
-// rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), qMin(KeyLen+5, 16));
-// rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), tmp.length());
-// QString uk = "";
-// for (int cl = 0; cl < tmp.length(); ++cl)
-// uk += QChar(ou[cl]);
-// return ou;
}
QByteArray PDFLibCore::EncString(const QByteArray & in, PdfId ObjNum)
@@ -840,21 +762,8 @@
return "<>";
if (!Options.Encrypt)
{
- //tmp = "(" + PDFEncode(in) + ")";
return Pdf::toLiteralString(in);
}
-
-// rc4_context_t rc4;
-// QByteArray us(in.length(), ' ');
-// QByteArray ou(in.length(), ' ');
-// for (int a = 0; a < in.length(); ++a)
-// us[a] = static_cast<uchar>(QChar(in.at(a)).cell());
-// QByteArray step1 = writer.ComputeRC4Key(ObjNum);
-// rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), qMin(KeyLen+5, 16));
-// rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), in.length());
-// QString uk = "";
-// for (int cl = 0; cl < in.length(); ++cl)
-// uk += QChar(ou[cl]);
return Pdf::toHexString(writer.encryptBytes(in, ObjNum));
}
@@ -866,20 +775,10 @@
if (!Options.Encrypt)
{
QByteArray us = Pdf::toUTF16(in);
-// QString uk = "";
-// for (int cl = 0; cl < us.size(); ++cl)
-// uk += QChar(us[cl]);
return Pdf::toHexString(us);
}
-// rc4_context_t rc4;
+
QByteArray us = Pdf::toUTF16(in);
-// QByteArray ou(us.size(), ' ');
-// QByteArray step1 = writer.ComputeRC4Key(ObjNum);
-// rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), qMin(KeyLen+5, 16));
-// rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), ou.size());
-// QString uk = "";
-// for (int cl = 0; cl < ou.size(); ++cl)
-// uk += QChar(ou[cl]);
QByteArray tmp = Pdf::toHexString(writer.encryptBytes(us, ObjNum));
return tmp;
}
@@ -4710,7 +4609,7 @@
radioButtonGroup.kids.append(kid);
break;
}
- if (!PDF_Annotation(ite, PNr))
+ if (!PDF_Annotation(ite))
return false;
break;
}
@@ -5760,37 +5659,6 @@
return tmp;
}
-/*CB 2982: cache code is borked somehow, original function is above
-QByteArray PDFLibCore::putColor(const QString & colorName, int shade, bool fill)
-{
- // Cache of last foreground and background colours We cache fg and bg
- // separately because they're alternated so much. The primary purpose of
- // this cache is to avoid re-caculating the fg and bg colors on each char
- // of text when the color doesn't change.
- static QString lastFGColorName, lastFGOutput, lastBGColorName, lastBGOutput;
- static int lastFGShade = -1, lastBGShade = -1;
- if (fill && colorName == lastBGColorName && shade == lastBGShade)
- return lastBGOutput;
- else if (colorName == lastFGColorName && shade == lastFGShade)
- return lastFGOutput;
- // Cache miss, generate the color
- else if (fill)
- {
- lastBGColorName = colorName;
- lastBGShade = shade;
- lastBGOutput = putColorUncached(colorName, shade, fill);
- return lastBGOutput;
- }
- else
- {
- lastFGColorName = colorName;
- lastFGShade = shade;
- lastFGOutput = putColorUncached(colorName, shade, fill);
- return lastFGOutput;
- }
-}
-*/
-
QByteArray PDFLibCore::putColorUncached(const QString& color, int shade, bool fill)
{
ScColor tmpC(doc.PageColors[color]);
@@ -5883,7 +5751,7 @@
return tmp;
}
-QByteArray PDFLibCore::setStrokeMulti(struct SingleLine *sl)
+QByteArray PDFLibCore::setStrokeMulti(const SingleLine *sl)
{
QByteArray tmp(
putColor(sl->Color, sl->Shade, false) +
@@ -5932,7 +5800,7 @@
ite->layout();
ite->OwnPage = savedOwnPage;
- PdfPainter p(ite, this, PNr, pag);
+ PdfPainter p(this, PNr, pag);
ite->textLayout.renderBackground(&p);
ite->textLayout.render(&p);
return p.getBuffer();
@@ -5976,38 +5844,32 @@
rgb.getValues(h, s, v);
tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v);
}
- else
- {
- if ((doc.HasCMS) && (Options.UseProfiles))
- {
- if (tmpC.getColorModel() == colorModelCMYK)
- {
- ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
- cmyk.getValues(h, s, v, k);
- tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v) + " " + FToStr(k);
- }
- else
- {
- if (Options.SComp == 3)
- {
- ScColorEngine::getShadeColorRGB(tmpC, &doc, rgb, Shade);
- rgb.getValues(h, s, v);
- tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v);
- }
- else
- {
- ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
- cmyk.getValues(h, s, v, k);
- tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v) + " " + FToStr(k);
- }
- }
- }
- else
+ else if ((doc.HasCMS) && (Options.UseProfiles))
+ {
+ if (tmpC.getColorModel() == colorModelCMYK)
{
ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
cmyk.getValues(h, s, v, k);
tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v) + " " + FToStr(k);
}
+ else if (Options.SComp == 3)
+ {
+ ScColorEngine::getShadeColorRGB(tmpC, &doc, rgb, Shade);
+ rgb.getValues(h, s, v);
+ tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v);
+ }
+ else
+ {
+ ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
+ cmyk.getValues(h, s, v, k);
+ tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v) + " " + FToStr(k);
+ }
+ }
+ else
+ {
+ ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
+ cmyk.getValues(h, s, v, k);
+ tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v) + " " + FToStr(k);
}
return tmp;
}
@@ -6023,18 +5885,15 @@
tmp = "0.0";
if (Options.UseRGB)
tmp = "0.0 0.0 0.0";
- else
- {
- if ((doc.HasCMS) && (Options.UseProfiles))
- {
- if (Options.SComp == 3)
- tmp = "0.0 0.0 0.0";
- else
- tmp = "0.0 0.0 0.0 0.0";
- }
+ else if ((doc.HasCMS) && (Options.UseProfiles))
+ {
+ if (Options.SComp == 3)
+ tmp = "0.0 0.0 0.0";
else
tmp = "0.0 0.0 0.0 0.0";
}
+ else
+ tmp = "0.0 0.0 0.0 0.0";
return tmp;
}
ScColor tmpC(doc.PageColors[farbe]);
@@ -6060,20 +5919,12 @@
ScColorEngine::getShadeColorRGB(tmpC, &doc, rgb, Shade);
tmp = FToStr(rgb.r) + " " + FToStr(rgb.g) + " " + FToStr(rgb.b);
}
- else
- {
- if ((doc.HasCMS) && (Options.UseProfiles))
- {
- if (Options.SComp == 3)
- {
- ScColorEngine::getShadeColorRGB(tmpC, &doc, rgb, Shade);
- tmp = FToStr(rgb.r) + " " + FToStr(rgb.g) + " " + FToStr(rgb.b);
- }
- else
- {
- ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
- tmp = FToStr(cmyk.c) + " " + FToStr(cmyk.m) + " " + FToStr(cmyk.y) + " " + FToStr(cmyk.k);
- }
+ else if ((doc.HasCMS) && (Options.UseProfiles))
+ {
+ if (Options.SComp == 3)
+ {
+ ScColorEngine::getShadeColorRGB(tmpC, &doc, rgb, Shade);
+ tmp = FToStr(rgb.r) + " " + FToStr(rgb.g) + " " + FToStr(rgb.b);
}
else
{
@@ -6081,10 +5932,15 @@
tmp = FToStr(cmyk.c) + " " + FToStr(cmyk.m) + " " + FToStr(cmyk.y) + " " + FToStr(cmyk.k);
}
}
+ else
+ {
+ ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
+ tmp = FToStr(cmyk.c) + " " + FToStr(cmyk.m) + " " + FToStr(cmyk.y) + " " + FToStr(cmyk.k);
+ }
return tmp;
}
-QByteArray PDFLibCore::SetClipPath(PageItem *ite, bool poly)
+QByteArray PDFLibCore::SetClipPath(const PageItem *ite, bool poly)
{
QByteArray tmp;
FPoint np, np1, np2, np3, np4, firstP;
@@ -6128,7 +5984,7 @@
return tmp;
}
-QByteArray PDFLibCore::SetClipPathArray(FPointArray *ite, bool poly)
+QByteArray PDFLibCore::SetClipPathArray(const FPointArray *ite, bool poly)
{
QByteArray tmp;
FPoint np, np1, np2, np3, np4, firstP;
@@ -6172,7 +6028,7 @@
return tmp;
}
-QByteArray PDFLibCore::SetClipPathImage(PageItem *ite)
+QByteArray PDFLibCore::SetClipPathImage(const PageItem *ite)
{
QByteArray tmp;
if (ite->imageClip.size() <= 3)
@@ -6809,19 +6665,19 @@
return true;
}
-quint32 PDFLibCore::encode32dVal(double val)
+quint32 PDFLibCore::encode32dVal(double val) const
{
quint32 res = static_cast<quint32>(((val - (-40000.0)) / 80000.0) * 0xFFFFFFFF);
return res;
}
-quint16 PDFLibCore::encode16dVal(double val)
+quint16 PDFLibCore::encode16dVal(double val) const
{
quint16 m = val * 0xFFFF;
return m;
}
-void PDFLibCore::encodeColor(QDataStream &vs, const QString& colName, int colShade, QStringList &spotColorSet, bool spotMode)
+void PDFLibCore::encodeColor(QDataStream &vs, const QString& colName, int colShade, const QStringList &spotColorSet, bool spotMode)
{
if (spotMode)
{
@@ -6870,12 +6726,7 @@
QStringList tmpAddedColors;
bool spotMode = false;
bool transparencyFound = false;
- StopVec.clear();
- TransVec.clear();
- Gcolors.clear();
- colorNames.clear();
- colorShades.clear();
- tmpAddedColors.clear();
+
for (int grow = 0; grow < c->meshGradientArray.count(); grow++)
{
for (int gcol = 0; gcol < c->meshGradientArray[grow].count(); gcol++)
@@ -7542,11 +7393,11 @@
}
Gcolors.append(SetGradientColor(cstops.at(cst)->name, cstops.at(cst)->shade));
}
- QPointF cP = QPointF(c->GrControl5.x(), -c->GrControl5.y());
- QLineF edge1 = QLineF(cP, QPointF(c->GrControl1.x(), -c->GrControl1.y()));
- QLineF edge2 = QLineF(cP, QPointF(c->GrControl2.x(), -c->GrControl2.y()));
- QLineF edge3 = QLineF(cP, QPointF(c->GrControl3.x(), -c->GrControl3.y()));
- QLineF edge4 = QLineF(cP, QPointF(c->GrControl4.x(), -c->GrControl4.y()));
+ QPointF cP(c->GrControl5.x(), -c->GrControl5.y());
+ QLineF edge1(cP, QPointF(c->GrControl1.x(), -c->GrControl1.y()));
+ QLineF edge2(cP, QPointF(c->GrControl2.x(), -c->GrControl2.y()));
+ QLineF edge3(cP, QPointF(c->GrControl3.x(), -c->GrControl3.y()));
+ QLineF edge4(cP, QPointF(c->GrControl4.x(), -c->GrControl4.y()));
QByteArray TRes("");
if (Options.supportsTransparency() && transparencyFound)
{
@@ -8353,7 +8204,8 @@
}
double lastStop = -1.0;
double actualStop = 0.0;
- bool isFirst = true, transparencyFound = false;
+ bool isFirst = true;
+ bool transparencyFound = false;
for (int cst = 0; cst < gradient.stops(); ++cst)
{
actualStop = cstops.at(cst)->rampPoint;
@@ -8692,7 +8544,7 @@
QByteArray tmp;
if (Options.supportsTransparency() && transparencyFound)
tmp += Pdf::toName(TRes) + " gs\n";
- if ((forArrow) || (!stroke))
+ if (forArrow || (!stroke))
{
tmp += "/Pattern cs\n";
tmp += "/Pattern" + Pdf::toPdf(patObject) + " scn\n";
@@ -9025,7 +8877,7 @@
return annotationObj;
}
-bool PDFLibCore::PDF_Annotation(PageItem *ite, uint PNr)
+bool PDFLibCore::PDF_Annotation(PageItem *ite)
{
ScImage img;
ScImage img2;
@@ -9909,7 +9761,7 @@
BookMinUse = true;
}
-bool PDFLibCore::PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN, ShIm& imgInfo, bool &fatalError)
+bool PDFLibCore::PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, ShIm& imgInfo, bool &fatalError)
{
if (!Options.embedPDF)
return false;
@@ -10346,13 +10198,12 @@
*/
bool PDFLibCore::PDF_Image(PageItem* item, const QString& fn, double sx, double sy, double x, double y, bool fromAN, const QString& Profil, bool Embedded, eRenderIntent Intent, QByteArray* output)
{
- QFileInfo fi = QFileInfo(fn);
+ QFileInfo fi(fn);
QString ext = fi.suffix().toLower();
if (ext.isEmpty())
ext = getImageType(fn);
ScImage img;
QString BBox;
-// QChar tc;
bool found = false;
bool alphaM = false;
bool realCMYK = false;
@@ -10407,13 +10258,13 @@
opts.append( "-dAutoRotatePages=/None" ); // #14289: otherwise EPS might come out rotated
if (convertPS2PDF(fn, tmpFile, opts) == 0)
{
- imageLoaded = PDF_EmbeddedPDF(item, tmpFile, sx, sy, x, y, fromAN, ImInfo, fatalError);
+ imageLoaded = PDF_EmbeddedPDF(item, tmpFile, sx, sy, x, y, ImInfo, fatalError);
QFile::remove(tmpFile);
}
pdfFile = tmpFile;
}
else
- imageLoaded = PDF_EmbeddedPDF(item, fn, sx, sy, x, y, fromAN, ImInfo, fatalError);
+ imageLoaded = PDF_EmbeddedPDF(item, fn, sx, sy, x, y, ImInfo, fatalError);
ImInfo.isEmbeddedPDF = true;
ImInfo.Page = item->pixm.imgInfo.actualPageNumber;
}
@@ -10861,7 +10712,7 @@
cm = PDFOptions::Compression_ZIP;
}*/
}
- if ((hasGrayProfile) && (doc.HasCMS) && (Options.UseProfiles2) && (!hasColorEffect))
+ if (hasGrayProfile && doc.HasCMS && Options.UseProfiles2 && (!hasColorEffect))
exportToGrayscale = true;
int bytesWritten = 0;
// Fixme: outType variable should be set directly in the if/else maze above.
@@ -10973,7 +10824,7 @@
{
if (item->imageRotation())
{
- embedPre += "1 0 0 1 " + FToStr(x*sx) + " " + FToStr((-ImInfo.Height * ImInfo.sya + y * sy)) + " cm\n";
+ embedPre += "1 0 0 1 " + FToStr(x*sx) + " " + FToStr(-ImInfo.Height * ImInfo.sya + y * sy) + " cm\n";
QTransform mpa;
mpa.rotate(-item->imageRotation());
embedPre += "1 0 0 1 0 " + FToStr(ImInfo.Height * ImInfo.sya) + " cm\n";
@@ -10982,7 +10833,7 @@
embedPre += FToStr(ImInfo.Width * ImInfo.sxa) + " 0 0 " + FToStr(ImInfo.Height * ImInfo.sya) + " 0 0 cm\n";
}
else
- embedPre += FToStr(ImInfo.Width * ImInfo.sxa) + " 0 0 " + FToStr(ImInfo.Height * ImInfo.sya) + " " + FToStr(x * sx) + " " + FToStr((-ImInfo.Height * ImInfo.sya + y * sy)) + " cm\n";
+ embedPre += FToStr(ImInfo.Width * ImInfo.sxa) + " 0 0 " + FToStr(ImInfo.Height * ImInfo.sya) + " " + FToStr(x * sx) + " " + FToStr(-ImInfo.Height * ImInfo.sya + y * sy) + " cm\n";
*output = embedPre + Pdf::toName(ResNam + "I" + Pdf::toPdf(ImInfo.ResNum)) + " Do\n";
}
else if (output)
Modified: trunk/Scribus/scribus/pdflib_core.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24717&path=/trunk/Scribus/scribus/pdflib_core.h
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.h (original)
+++ trunk/Scribus/scribus/pdflib_core.h Sat Oct 2 21:37:15 2021
@@ -92,8 +92,8 @@
QMap<int, ImageLoadRequest> RequestProps;
};
- bool PDF_IsPDFX();
- bool PDF_IsPDFX(const PDFVersion& ver);
+ bool PDF_IsPDFX() const;
+ bool PDF_IsPDFX(const PDFVersion& ver) const;
bool PDF_Begin_Doc(const QString& fn, SCFonts &AllFonts, const QMap<QString, QMap<uint, QString> >& DocFonts, BookmarkView* vi);
void PDF_Begin_Catalog();
@@ -150,7 +150,6 @@
void PDF_Error_MaskLoadFailure(const QString& fileName);
void PDF_Error_InsufficientMemory();
-// QByteArray EncodeUTF16(const QString &in);
QByteArray EncStream(const QByteArray & in, PdfId ObjNum);
QByteArray EncString(const QByteArray & in, PdfId ObjNum);
QByteArray EncStringUTF16(const QString & in, PdfId ObjNum);
@@ -165,15 +164,15 @@
// void CalcUserKey(const QString & User, int Permission);
// QString FitKey(const QString & pass);
- QByteArray SetClipPath(PageItem *ite, bool poly = true);
- QByteArray SetClipPathArray(FPointArray *ite, bool poly = true);
- QByteArray SetClipPathImage(PageItem *ite);
+ QByteArray SetClipPath(const PageItem *ite, bool poly = true);
+ QByteArray SetClipPathArray(const FPointArray *ite, bool poly = true);
+ QByteArray SetClipPathImage(const PageItem *ite);
QByteArray SetImagePathAndClip(PageItem *item);
QByteArray SetPathAndClip(PageItem *item);
QByteArray SetPathAndClip(PageItem *item, bool fillRule);
- QByteArray setStrokeMulti(struct SingleLine *sl);
+ QByteArray setStrokeMulti(const SingleLine *sl);
QByteArray SetColor(const QString& farbe, double Shade);
QByteArray SetColor(const ScColor& farbe, double Shade);
QByteArray SetGradientColor(const QString& farbe, double Shade);
@@ -193,7 +192,6 @@
// void PutDoc(const std::string & in) { outStream.writeRawData(in.c_str(), in.length()); }
void PutPage(const QByteArray & in) { Content += in; }
-// void StartObj(PdfId nr);
// uint newObject() { return ObjCounter++; }
uint WritePDFStream(const QByteArray& cc);
uint WritePDFStream(const QByteArray& cc, PdfId objId);
@@ -203,9 +201,6 @@
uint writeObject(const QByteArray& type, const QByteArray& dictionary);
uint writeGState(QByteArray dictionary) { return writeObject("/ExtGState", dictionary); }
uint writeActions(const Annotation&, uint annotationObj);
-// QString PDFEncode(const QString & in);
-// QByteArray ComputeMD5(const QString& in);
-// QByteArray ComputeRC4Key(PdfId ObjNum);
QByteArray PDF_PutSoftShadow(PageItem* ite);
bool PDF_ProcessItem(QByteArray& output, PageItem* ite, const ScPage* pag, uint PNr, bool embedded = false, bool pattern = false);
@@ -224,19 +219,19 @@
#endif
void PDF_RadioButtonGroups();
uint PDF_RadioButton(PageItem *ite, uint parent, const QString& parentName);
- bool PDF_Annotation(PageItem *ite, uint PNr);
+ bool PDF_Annotation(PageItem *ite);
void PDF_Form(const QByteArray& im);
void PDF_xForm(uint objNr, double w, double h, const QByteArray& im);
bool PDF_Image(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN = false, const QString& Profil = "", bool Embedded = false, eRenderIntent Intent = Intent_Relative_Colorimetric, QByteArray* output = nullptr);
- bool PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN, ShIm& imgInfo, bool &fatalError);
+ bool PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, ShIm& imgInfo, bool &fatalError);
#if HAVE_PODOFO
void copyPoDoFoObject(const PoDoFo::PdfObject* obj, uint scObjID, QMap<PoDoFo::PdfReference, uint>& importedObjects);
void copyPoDoFoDirect(const PoDoFo::PdfVariant* obj, QList<PoDoFo::PdfReference>& referencedObjects, QMap<PoDoFo::PdfReference, uint>& importedObjects);
#endif
- quint32 encode32dVal(double val);
- quint16 encode16dVal(double val);
- void encodeColor(QDataStream &vs, const QString& colName, int colShade, QStringList &spotColorSet, bool spotMode);
+ quint32 encode32dVal(double val) const;
+ quint16 encode16dVal(double val) const;
+ void encodeColor(QDataStream &vs, const QString& colName, int colShade, const QStringList &spotColorSet, bool spotMode);
QByteArray drawArrow(PageItem *ite, QTransform &arrowTrans, int arrowIndex);
QByteArray createBorderAppearance(PageItem *ite);
@@ -256,9 +251,9 @@
QByteArray Content;
QString ErrorMessage;
ScribusDoc & doc;
- const ScPage * ActPageP;
+ const ScPage * ActPageP { nullptr };
const PDFOptions & Options;
- BookmarkView* Bvie;
+ BookmarkView* Bvie { nullptr };
//int Dokument;
QMap<QString,ShIm> SharedImages;
QList<PdfDest> NamedDest;
@@ -268,35 +263,28 @@
Pdf::ResourceMap Transpar;
QMap<QString,PdfICCD> ICCProfiles;
QHash<QString, PdfOCGInfo> OCGEntries;
- QTextCodec* ucs2Codec;
- QByteArray ResNam;
- int ResCount;
- QByteArray NDnam;
+ QTextCodec* ucs2Codec { nullptr };
+ QByteArray ResNam { "RE" };
+ int ResCount { 0 };
+ QByteArray NDnam { "LI" };
QByteArray Datum;
- int NDnum;
+ int NDnum { 0 };
QMap<QString, PdfFont> UsedFontsP;
QMap<QString, PdfFont> UsedFontsF;
-// QByteArray KeyGen;
-// QByteArray OwnerKey;
-// QByteArray UserKey;
-// QByteArray FileID;
-// QByteArray EncryKey;
-// PdfId Encrypt;
-// int KeyLen;
QByteArray HTName;
- bool BookMinUse;
+ bool BookMinUse { false };
ColorList colorsToUse;
QMap<QString, PdfSpotC> spotMap;
QMap<QString, PdfSpotC> spotMapReg;
- QByteArray spotNam;
- int spotCount;
- int inPattern;
+ QByteArray spotNam { "Spot" };
+ int spotCount { 0 };
+ int inPattern { 0 };
QMap<QString, QString> StdFonts;
- MultiProgressDialog* progressDialog;
- bool abortExport;
+ MultiProgressDialog* progressDialog { nullptr };
+ bool abortExport { false };
bool usingGUI;
- double bleedDisplacementX;
- double bleedDisplacementY;
+ double bleedDisplacementX { 0.0 };
+ double bleedDisplacementY { 0.0 };
QByteArray xmpPacket;
QStack<QPointF> groupStackPos;
QStack<QPointF> patternStackPos;
Modified: trunk/Scribus/scribus/pdfwriter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24717&path=/trunk/Scribus/scribus/pdfwriter.cpp
==============================================================================
--- trunk/Scribus/scribus/pdfwriter.cpp (original)
+++ trunk/Scribus/scribus/pdfwriter.cpp Sat Oct 2 21:37:15 2021
@@ -65,29 +65,29 @@
switch (cell)
{
case 0x92:
- return (134);
+ return 134;
case 0x41:
- return (149);
+ return 149;
case 0x52:
- return (150);
+ return 150;
case 0x60:
- return (151);
+ return 151;
case 0x78:
- return (152);
+ return 152;
case 0x7d:
- return (153);
+ return 153;
case 0x31:
- return (154);
+ return 154;
case 0x42:
- return (155);
+ return 155;
case 0x53:
- return (156);
+ return 156;
case 0x61:
- return (157);
+ return 157;
case 0x7e:
- return (158);
+ return 158;
default:
- return (0);
+ return 0;
break;
}
break;
@@ -96,23 +96,23 @@
switch (cell)
{
case 0xc7:
- return (25);
+ return 25;
case 0xc6:
- return (26);
+ return 26;
case 0xd8:
- return (24);
+ return 24;
case 0xd9:
- return (27);
+ return 27;
case 0xda:
- return (30);
+ return 30;
case 0xdb:
- return (29);
+ return 29;
case 0xdc:
- return (31);
+ return 31;
case 0xdd:
- return (28);
+ return 28;
default:
- return (0);
+ return 0;
break;
}
break;
@@ -121,42 +121,42 @@
switch (cell)
{
case 0x13:
- return (133);
+ return 133;
case 0x14:
- return (132);
+ return 132;
case 0x18:
- return (143);
+ return 143;
case 0x19:
- return (144);
+ return 144;
case 0x1a:
- return (145);
+ return 145;
case 0x1c:
- return (141);
+ return 141;
case 0x1d:
- return (142);
+ return 142;
case 0x1e:
- return (140);
+ return 140;
case 0x20:
- return (129);
+ return 129;
case 0x21:
- return (130);
+ return 130;
case 0x22:
- return (128);
+ return 128;
case 0x26:
- return (131);
+ return 131;
case 0x30:
- return (139);
+ return 139;
case 0x39:
- return (136);
+ return 136;
case 0x3a:
- return (137);
+ return 137;
case 0x44:
- return (135);
+ return 135;
case 0xac:
- return (160);
+ return 160;
default:
- return (0);
+ return 0;
break;
}
break;
@@ -165,9 +165,9 @@
switch (cell)
{
case 0x22:
- return (146);
+ return 146;
default:
- return (0);
+ return 0;
break;
}
break;
@@ -176,9 +176,9 @@
switch (cell)
{
case 0x12:
- return (138);
+ return 138;
default:
- return (0);
+ return 0;
break;
}
break;
@@ -187,11 +187,11 @@
switch (cell)
{
case 0x01:
- return (147);
+ return 147;
case 0x02:
- return (148);
+ return 148;
default:
- return (0);
+ return 0;
break;
}
break;
@@ -470,26 +470,6 @@
Writer::Writer()
{
- CatalogObj = 1;
- InfoObj = 2;
- PagesObj = 3;
- AcroFormObj = 0;
- DestsObj = 0;
- OutlinesObj = 0;
- NamesObj = 0;
- ThreadsObj = 0;
-
- OCPropertiesObj = 0;
- OutputIntentObj = 0;
- EncryptObj = 0;
- MetaDataObj = 0;
- ResourcesObj = 0;
- OpenActionObj = 0;
-
- m_ObjCounter = 0;
- m_CurrentObj = 0;
-
- m_KeyLen = 5;
m_KeyGen.resize(32);
m_OwnerKey.resize(32);
m_UserKey.resize(32);
@@ -718,15 +698,6 @@
}
}
-// QByteArray PDFLibCore::ComputeMD5(const QString& in)
-// {
-// uint inlen=in.length();
-// QByteArray TBytes(inlen, ' ');
-// for (uint a = 0; a < inlen; ++a)
-// TBytes[a] = static_cast<uchar>(QChar(in.at(a)).cell());
-// return QCryptographicHash::hash(TBytes, QCryptographicHash::Md5);
-// }
-
void Writer::writeHeader(const PDFVersion& Version)
{
switch (Version)
Modified: trunk/Scribus/scribus/pdfwriter.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24717&path=/trunk/Scribus/scribus/pdfwriter.h
==============================================================================
--- trunk/Scribus/scribus/pdfwriter.h (original)
+++ trunk/Scribus/scribus/pdfwriter.h Sat Oct 2 21:37:15 2021
@@ -171,18 +171,12 @@
QByteArray encryptBytes(const QByteArray& in, PdfId objNum);
QByteArray ComputeRC4Key(PdfId ObjNum);
-private:
- void CalcOwnerKey(const QByteArray & Owner, const QByteArray & User);
- void CalcUserKey(const QByteArray & User, int Permission);
- QByteArray FitKey(const QByteArray & pass);
-public:
// writing
void writeHeader(const PDFVersion& vers);
void writeXrefAndTrailer();
void write(const QByteArray& bytes);
void write(const Pdf::ResourceDictionary& dict);
- void write(const PdfFont font);
// objects
PdfId objectCounter() const { return m_ObjCounter; }
@@ -202,24 +196,24 @@
// private:
- PdfId CatalogObj; // 1
- PdfId InfoObj; // 2
- PdfId PagesObj; // 3
- PdfId AcroFormObj;
- PdfId DestsObj;
- PdfId OutlinesObj;
- PdfId NamesObj;
- PdfId ThreadsObj;
- PdfId OCPropertiesObj; // (9)
- PdfId OutputIntentObj; // (9 or 10)
- PdfId EncryptObj;
- PdfId MetaDataObj;
- PdfId ResourcesObj;
- PdfId OpenActionObj;
+ PdfId CatalogObj { 1 }; // 1
+ PdfId InfoObj { 2 }; // 2
+ PdfId PagesObj { 3 }; // 3
+ PdfId AcroFormObj { 0 };
+ PdfId DestsObj { 0 };
+ PdfId OutlinesObj { 0 };
+ PdfId NamesObj { 0 };
+ PdfId ThreadsObj { 0 };
+ PdfId OCPropertiesObj { 0 }; // (9)
+ PdfId OutputIntentObj { 0 }; // (9 or 10)
+ PdfId EncryptObj { 0 };
+ PdfId MetaDataObj { 0 };
+ PdfId ResourcesObj { 0 };
+ PdfId OpenActionObj { 0 };
private:
- PdfId m_ObjCounter;
- PdfId m_CurrentObj;
+ PdfId m_ObjCounter { 0 };
+ PdfId m_CurrentObj { 0 };
QFile m_Spool;
QDataStream m_outStream;
@@ -231,8 +225,11 @@
QByteArray m_UserKey;
QByteArray m_FileID;
QByteArray m_EncryKey;
- int m_KeyLen;
-
+ int m_KeyLen { 5 };
+
+ void CalcOwnerKey(const QByteArray& Owner, const QByteArray& User);
+ void CalcUserKey(const QByteArray& User, int Permission);
+ QByteArray FitKey(const QByteArray& pass);
};
}
More information about the scribus-commit
mailing list