r19914 by craig - Clean up util.h/cpp a little
scribus-commit
scribus-commit at lists.scribus.net
Fri Mar 13 18:50:13 UTC 2015
Author: craig
Date: Fri Mar 13 18:50:13 2015
New Revision: 19914
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19914
Log:
Clean up util.h/cpp a little
Modified:
trunk/Scribus/scribus/pdflib_core.cpp
trunk/Scribus/scribus/ui/scrapbookpalette.cpp
trunk/Scribus/scribus/util.cpp
trunk/Scribus/scribus/util.h
Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19914&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Fri Mar 13 18:50:13 2015
@@ -38,6 +38,7 @@
#include "rc4.h"
#include <QByteArray>
+#include <QCryptographicHash>
#include <QDateTime>
#include <QDataStream>
#include <QDebug>
@@ -660,7 +661,7 @@
if (KeyLen > 5)
{
for (int kl = 0; kl < 50; ++kl)
- step1 = ComputeMD5Sum(&step1);
+ step1 = QCryptographicHash::hash(step1, QCryptographicHash::Md5);
}
QByteArray us(32, ' ');
QByteArray enk(16, ' ');
@@ -708,7 +709,7 @@
if (KeyLen > 5)
{
for (int kl = 0; kl < 50; ++kl)
- step1 = ComputeMD5Sum(&step1);
+ step1 = QCryptographicHash::hash(step1, QCryptographicHash::Md5);
EncryKey.resize(16);
}
for (int a2 = 0; a2 < KeyLen; ++a2)
@@ -745,7 +746,7 @@
QByteArray TBytes(inlen, ' ');
for (uint a = 0; a < inlen; ++a)
TBytes[a] = static_cast<uchar>(QChar(in.at(a)).cell());
- return ComputeMD5Sum(&TBytes);
+ return QCryptographicHash::hash(TBytes, QCryptographicHash::Md5);
}
QByteArray PDFLibCore::ComputeRC4Key(int ObjNum)
@@ -765,7 +766,7 @@
data[dlen++] = 0;
data[dlen++] = 0;
QByteArray rc4Key(16, ' ');
- rc4Key = ComputeMD5Sum(&data);
+ rc4Key = QCryptographicHash::hash(data, QCryptographicHash::Md5);
rc4Key.resize(qMin(KeyLen+5, 16));
return rc4Key;
}
Modified: trunk/Scribus/scribus/ui/scrapbookpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19914&path=/trunk/Scribus/scribus/ui/scrapbookpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scrapbookpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/scrapbookpalette.cpp Fri Mar 13 18:50:13 2015
@@ -469,11 +469,11 @@
QDomElement dc=DOC.toElement();
if (dc.tagName()=="OBJEKT")
{
- QFile fi(QDir::cleanPath(QDir::toNativeSeparators(newName + "/" + GetAttr(&dc, "NAME") + ".sce")));
+ QFile fi(QDir::cleanPath(QDir::toNativeSeparators(newName + "/" + dc.attribute("NAME", 0) + ".sce")));
if(!fi.open(QIODevice::WriteOnly))
continue ;
QDataStream s(&fi);
- QString fn = GetAttr(&dc, "DATA");
+ QString fn = dc.attribute("DATA", 0);
cf = isUtf8? fn.toUtf8() : fn.toLocal8Bit();
s.writeRawData(cf.data(), cf.length());
fi.close();
Modified: trunk/Scribus/scribus/util.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19914&path=/trunk/Scribus/scribus/util.cpp
==============================================================================
--- trunk/Scribus/scribus/util.cpp (original)
+++ trunk/Scribus/scribus/util.cpp Fri Mar 13 18:50:13 2015
@@ -72,8 +72,7 @@
}
if (cancel && (*cancel == true))
return -1;
- int ex = proc.exitCode();
- return ex;
+ return proc.exitCode();
}
// On Windows, return short path name, else return longPath;
@@ -115,12 +114,6 @@
#endif
return longPath;
}
-
-QString GetAttr(QDomElement *el, QString at, QString def)
-{
- return el->attribute(at, def);
-}
-
// Legacy implementation of LoadText with incorrect
// handling of unicode data. This should be retired.
@@ -265,17 +258,17 @@
char *toAscii85( quint32 value, bool& allZero )
{
- int digit, i;
+ int digit;
static char asciiVal[6];
allZero = true;
- for (i = 0; i < 5; ++i)
+ for (int i = 0; i < 5; ++i)
{
digit = value % 85;
if (digit != 0)
allZero = false;
asciiVal[4-i] = digit + 33;
value = (value - digit) / 85;
- }
+ }
asciiVal[5] = 0;
return asciiVal;
}
@@ -314,14 +307,6 @@
}
}
return out;
-}
-
-QByteArray ComputeMD5Sum(QByteArray *in)
-{
- return QCryptographicHash::hash(*in, QCryptographicHash::Md5);
-// QByteArray MDsum(16, ' ');
-// md5_buffer (in->data(), in->size(), reinterpret_cast<void*>(MDsum.data()));
-// return MDsum;
}
QString Path2Relative(QString Path, const QString& baseDir)
@@ -582,8 +567,7 @@
QString retVal("");
unsigned digits = 1;
unsigned offset = 0;
- uint column=i;
- --column;
+ uint column=i-1;
if( column > 4058115285U ) return QString("@");
@@ -707,7 +691,6 @@
{
QString tmp(pages);
QString token;
- int from, to, pageNr;
do
{
if (tmp.indexOf(",") == -1)
@@ -729,8 +712,8 @@
}
else if (token.indexOf("-") != -1) // import a range of source doc pages
{
- from = QString(token.left(token.indexOf("-"))).toInt();
- to = QString(token.right(token.length() - token.indexOf("-") - 1)).toInt();
+ int from = QString(token.left(token.indexOf("-"))).toInt();
+ int to = QString(token.right(token.length() - token.indexOf("-") - 1)).toInt();
if ((from != 0) && (to != 0))
{
if (from > sourcePageCount)
@@ -753,7 +736,7 @@
}
else // import single source doc page
{
- pageNr = token.toInt();
+ int pageNr = token.toInt();
if ((pageNr > 0) && (pageNr <= sourcePageCount))
pageNs->push_back(pageNr);
}
@@ -797,7 +780,7 @@
QString ret = "";
quint32 len;
s >> len;
- for (quint32 a = 0; a < len; a++)
+ for (quint32 i = 0; i < len; i++)
{
quint16 ch;
s >> ch;
@@ -812,10 +795,10 @@
QString dashString;
QVector<double> dashArray;
getDashArray(dashtype, linewidth, dashArray);
- for (int a = 0; a < dashArray.size(); ++a)
- {
- dashString += QString::number(dashArray.at(a));
- if (a < (dashArray.size() - 1))
+ for (int i = 0; i < dashArray.size(); ++i)
+ {
+ dashString += QString::number(dashArray.at(i));
+ if (i < (dashArray.size() - 1))
dashString += " ";
}
return dashString;
@@ -826,9 +809,8 @@
QVector<double> tmp;
getDashArray(dashtype, linewidth, tmp);
dashArray.clear();
- for (int i = 0; i < tmp.count(); ++i) {
+ for (int i = 0; i < tmp.count(); ++i)
dashArray << static_cast<float>(tmp[i]);
- }
}
void getDashArray(int dashtype, double linewidth, QVector<double> &dashArray)
@@ -972,9 +954,9 @@
// converted to standard groups (at least until we find a good way to process that case)
bool hasTableLinks = false;
bool hasTextLinks = false;
- for (int a = 0; a < gpL.count(); a++)
- {
- PageItem* it = gpL[a];
+ for (int i = 0; i < gpL.count(); i++)
+ {
+ PageItem* it = gpL[i];
it->isTableItem = false;
if (it->nextInChain() || it->prevInChain())
hasTextLinks = true;
@@ -986,9 +968,9 @@
return false;
PageItem *topLeft = NULL;
- for (int a = 0; a < gpL.count(); a++)
- {
- PageItem* it = gpL[a];
+ for (int i = 0; i < gpL.count(); i++)
+ {
+ PageItem* it = gpL[i];
if ((it->TopLink == NULL) && (it->LeftLink == NULL)) // we got the topleft item
{
topLeft = it;
Modified: trunk/Scribus/scribus/util.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19914&path=/trunk/Scribus/scribus/util.h
==============================================================================
--- trunk/Scribus/scribus/util.h (original)
+++ trunk/Scribus/scribus/util.h Fri Mar 13 18:50:13 2015
@@ -51,7 +51,6 @@
void SCRIBUS_API ReOrderText(ScribusDoc *currentDoc, ScribusView *view);
void SCRIBUS_API WordAndPara(PageItem *currItem, int *w, int *p, int *c, int *wN, int *pN, int *cN);
bool SCRIBUS_API overwrite(QWidget *parent, QString filename);
-QByteArray SCRIBUS_API ComputeMD5Sum(QByteArray *in);
QString SCRIBUS_API Path2Relative(QString Path, const QString& baseDir = QDir::currentPath());
QString SCRIBUS_API Relative2Path(QString File, const QString& baseDir = QDir::currentPath());
char SCRIBUS_API *toAscii85( quint32 value, bool& allZero );
@@ -68,7 +67,6 @@
old contents. */
bool SCRIBUS_API loadRawText(const QString & filename, QByteArray & buf);
bool SCRIBUS_API loadRawBytes(const QString & filename, QByteArray & buf);
-QString SCRIBUS_API GetAttr(QDomElement *el, QString at, QString def="0");
/**
* @brief Synchronously execute a new process, optionally saving its output
*
More information about the scribus-commit
mailing list