Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 94 → Rev 95

/trunk/Scribus/ChangeLogCVS
1,3 → 1,8
Changes since Version 1.1.2
02.10.2003 Reenabled the Fontpreview in the Preferences.
05.11.2003 Improved the Preview in the charselect plugin.
 
04.11.2003 When you resize a Textframe with the Mouse and press
CTRL+SHIFT the Text is scaled accordingly.
 
02.11.2003 Reenabled the Fontpreview in the Preferences.
Fixed Bug in the "SetText" Command of the Scripter.
/trunk/Scribus/scribus/util.cpp
63,6 → 63,7
 
bool overwrite(QWidget *parent, QString filename);
FPointArray traceChar(FT_Face face, uint chr, int chs, double *x, double *y);
FPoint GetMaxClipF(FPointArray Clip);
QPixmap FontSample(QString da, int s, QString ts, QColor back);
QString Path2Relative(QString Path);
QPixmap LoadPDF(QString fn, int Seite, int Size, int *w, int *h);
1234,23 → 1235,43
return pts2;
}
 
FPoint GetMaxClipF(FPointArray Clip)
{
FPoint np, rp;
double mx = 0;
double my = 0;
for (uint c = 0; c < Clip.size(); ++c)
{
np = Clip.point(c);
if (np.x() > 900000)
continue;
if (np.x() > mx)
mx = np.x();
if (np.y() > my)
my = np.y();
}
rp = FPoint(mx, my);
return rp;
}
 
QPixmap FontSample(QString da, int s, QString ts, QColor back)
{
FT_Face face;
FT_Library library;
double x, y, wid;
double x, y, ymax;
bool error;
int pen_x;
FPoint gp;
error = FT_Init_FreeType( &library );
error = FT_New_Face( library, da, 0, &face );
double uniEM = static_cast<double>(face->units_per_EM);
int h = qRound(face->height / uniEM) * s;
double a = static_cast<double>(face->descender) / uniEM * s;
int h = qRound(face->height / uniEM) * s + 1;
double a = static_cast<double>(face->descender) / uniEM * s + 1;
int w = qRound((face->bbox.xMax - face->bbox.xMin) / uniEM) * s * (ts.length()+1);
QPixmap pm(w, h);
pm.fill();
pen_x = 0;
wid = 0.0;
ymax = 0.0;
ScPainter *p = new ScPainter(&pm, pm.width(), pm.height());
p->setFillMode(1);
p->setLineWidth(0.0);
1264,14 → 1285,15
if (gly.size() > 3)
{
gly.translate(static_cast<double>(pen_x) / 64.0, a);
gp = GetMaxClipF(gly);
ymax = QMAX(ymax, gp.y());
p->setupPolygon(&gly);
p->fillPath();
}
pen_x += face->glyph->advance.x;
wid += face->glyph->metrics.horiAdvance / uniEM * s;
}
p->end();
pm.resize(QMIN(QMAX(qRound(wid), qRound(static_cast<double>(pen_x) / 64.0)), w), h);
pm.resize(QMIN(qRound(gp.x()), w), QMIN(qRound(ymax), h));
delete p;
FT_Done_FreeType( library );
return pm;
/trunk/Scribus/scribus/page.h
83,7 → 83,6
void MoveItemI(double newX, double newY, int ite);
bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
void UpdateClip(PageItem* b);
FPoint GetMaxClipF(FPointArray Clip);
FPoint GetMinClipF(FPointArray Clip);
QPoint GetMaxClip(QPointArray Clip);
QPoint GetMinClip(QPointArray Clip);
/trunk/Scribus/scribus/libabout/about.cpp
32,7 → 32,7
tabLayout1->addWidget( PixmapLabel1 );
BuildID = new QLabel( tab, "BB" );
BuildID->setAlignment(Qt::AlignCenter);
QString bu = "02. November 2003 ";
QString bu = "05. November 2003 ";
#ifdef HAVE_CMS
bu += "C";
#else
66,6 → 66,7
"<tr><td>Christian Töpp</td><td>mr-ct@gmx.de</td></tr>" +
"<tr><td>Alastair Robinson</td><td>blackfive@fakenhamweb.co.uk</td></tr>" +
"<tr><td>Paul Johnson</td><td>paul@all-the-johnsons.co.uk</td></tr>" +
"<tr><td>Craig Bradney</td><td>cbradney@zip.com.au</td></tr>" +
"<tr><td></td><td> </td></tr>" +
"<tr><td><b>" + tr("Documentation:") + "</b></td><td></td></tr>" +
"<tr><td>Peter Linnell</td><td>scribusdocs@atlantictechsolutions.com</td></tr>" +
/trunk/Scribus/scribus/scribus.cpp
172,6 → 172,8
else
{
HaveDoc = 0;
view = NULL;
doc = NULL;
BuildFontMenu();
SCFontsIterator it(Prefs.AvailFonts);
Prefs.DefFont = it.currentKey();
/trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
80,6 → 80,35
PyFloat_FromDouble(0.0);
}
 
PyObject *scribus_getframetext(PyObject *self, PyObject* args)
{
char *Name = "";
if (!PyArg_ParseTuple(args, "|s", &Name))
return NULL;
if (!Carrier->HaveDoc)
return PyString_FromString("");
int i = GetItem(QString(Name));
QString text = "";
PageItem *it;
if (i != -1)
{
it = doc->ActPage->Items.at(i);
for (uint a = 0; a < it->Ptext.count(); a++)
{
if (it->HasSel)
{
if (it->Ptext.at(a)->cselect)
text += it->Ptext.at(a)->ch;
}
else
text += it->Ptext.at(a)->ch;
}
return PyString_FromString(text);
}
else
return PyString_FromString("");
}
 
PyObject *scribus_gettext(PyObject *self, PyObject* args)
{
char *Name = "";
90,9 → 119,15
int i = GetItem(QString(Name));
QString text = "";
PageItem *it;
PageItem *is;
if (i != -1)
{
it = doc->ActPage->Items.at(i);
while (it->BackBox != 0)
{
is = doc->ActPage->Items.at(it->BackBox->ItemNr);
it = is;
}
for (uint a = 0; a < it->Ptext.count(); a++)
{
if (it->HasSel)
103,6 → 138,21
else
text += it->Ptext.at(a)->ch;
}
while (it->NextBox != 0)
{
is = doc->ActPage->Items.at(it->NextBox->ItemNr);
it = is;
for (uint a = 0; a < it->Ptext.count(); a++)
{
if (it->HasSel)
{
if (it->Ptext.at(a)->cselect)
text += it->Ptext.at(a)->ch;
}
else
text += it->Ptext.at(a)->ch;
}
}
return PyString_FromString(text);
}
else
/trunk/Scribus/scribus/plugins/scriptplugin/doc/en/Manual.lyx
32,7 → 32,7
Franz Schmid
\layout Date
 
18.07.2003
04.11.2003
\layout Abstract
 
This is the description how to use the Scripting Plugin for Scribus.
2701,6 → 2701,40
is not given the currently selected Item is used.
\layout Description
 
GetAllText
\begin_inset LatexCommand \index{GetText}
 
\end_inset
 
([
\begin_inset Quotes eld
\end_inset
 
name
\begin_inset Quotes erd
\end_inset
 
]) Returns the Text of the Textframe
\begin_inset Quotes eld
\end_inset
 
name
\begin_inset Quotes erd
\end_inset
 
and of all Textframes which are linked with this Frame.
If this Textframe has some Text selected, this Text is returned.
If
\begin_inset Quotes eld
\end_inset
 
name
\begin_inset Quotes erd
\end_inset
 
is not given the currently selected Item is used.
\layout Description
 
GetText
\begin_inset LatexCommand \index{GetText}
 
/trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h
6,6 → 6,7
PyObject *scribus_getfontsize(PyObject *self, PyObject* args);
PyObject *scribus_getfont(PyObject *self, PyObject* args);
PyObject *scribus_gettextsize(PyObject *self, PyObject* args);
PyObject *scribus_getframetext(PyObject *self, PyObject* args);
PyObject *scribus_gettext(PyObject *self, PyObject* args);
PyObject *scribus_getlinespace(PyObject *self, PyObject* args);
PyObject *scribus_setboxtext(PyObject *self, PyObject* args);
/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
352,7 → 352,8
{"GetTextColor", scribus_getlinecolor, METH_VARARGS},
{"GetTextShade", scribus_getlineshade, METH_VARARGS},
{"GetLineSpacing", scribus_getlinespace, METH_VARARGS},
{"GetText", scribus_gettext, METH_VARARGS},
{"GetText", scribus_getframetext, METH_VARARGS},
{"GetAllText", scribus_gettext, METH_VARARGS},
{"GetAllObjects", scribus_getallobj, METH_VARARGS},
{"SetGradientFill", scribus_setgradfill, METH_VARARGS},
{"SetFillColor", scribus_setfillcolor, METH_VARARGS},
/trunk/Scribus/scribus/plugins/scriptplugin/samples/plus_10_pourcent_group.py
0,0 → 1,2
from scribus import *
ScaleGroup(1.1)
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: trunk/Scribus/scribus/plugins/scriptplugin/samples/moins_10_pourcent_group.py
===================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/samples/moins_10_pourcent_group.py (nonexistent)
+++ trunk/Scribus/scribus/plugins/scriptplugin/samples/moins_10_pourcent_group.py (revision 95)
@@ -0,0 +1,2 @@
+from scribus import *
+ScaleGroup(0.9)
/trunk/Scribus/scribus/plugins/scriptplugin/samples/moins_10_pourcent_group.py
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: trunk/Scribus/scribus/plugins/scriptplugin/samples/legende.py
===================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/samples/legende.py (nonexistent)
+++ trunk/Scribus/scribus/plugins/scriptplugin/samples/legende.py (revision 95)
@@ -0,0 +1,11 @@
+from scribus import *
+import os
+SetUnit(1)
+x,y = GetPosition()
+l,h = GetSize()
+texte = GetImageFile()
+image = os.path.basename(texte)
+a = CreateText(x,y+h+2,l,8)
+InsertText(image,0,a)
+SetTextAlignment(2,a)
+SetFontSize(7,a)
\ No newline at end of file
/trunk/Scribus/scribus/plugins/scriptplugin/samples/legende.py
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: trunk/Scribus/scribus/plugins/libchar/charselect.h
===================================================================
--- trunk/Scribus/scribus/plugins/libchar/charselect.h (revision 94)
+++ trunk/Scribus/scribus/plugins/libchar/charselect.h (revision 95)
@@ -10,7 +10,7 @@
#define QUERY_H
#include <qdialog.h>
-#include <qlineedit.h>
+#include <qlabel.h>
#include <qpushbutton.h>
#include <qtable.h>
#include <qlayout.h>
@@ -53,7 +53,7 @@
ZAuswahl( QWidget* parent, preV *Vor, PageItem *item, ScribusApp *plug );
~ZAuswahl();
ChTable* ZTabelle;
- QLineEdit* Zeichen;
+ QLabel* Zeichen;
QPushButton* Einf;
QPushButton* Delete;
QPushButton* Close;
@@ -60,6 +60,7 @@
PageItem *ite;
ScribusApp *ap;
QValueList<uint> Zeich;
+ QString ChToIns;
int MaxCount;
public slots:
/trunk/Scribus/scribus/plugins/libchar/charselect.cpp
10,6 → 10,7
#include FT_GLYPH_H
 
extern QPixmap loadIcon(QString nam);
extern QPixmap FontSample(QString da, int s, QString ts, QColor back);
QString Name()
{
135,7 → 136,6
ZTabelle->setSelectionMode(QTable::NoSelection);
ZTabelle->setColumnMovingEnabled(false);
ZTabelle->setRowMovingEnabled(false);
ZTabelle->setFont(pl->doc->UsedFonts[pl->doc->CurrFont]);
int counter = 1;
FT_Face face;
FT_ULong charcode;
207,8 → 207,8
ZAuswahlLayout->addWidget( ZTabelle );
ZTabelle->MaxCount = MaxCount;
 
Zeichen = new QLineEdit( this, "Zeichen" );
Zeichen->setFont(pl->doc->UsedFonts[pl->doc->CurrFont]);
Zeichen = new QLabel( this, "Zeichen" );
DelEdit();
ZAuswahlLayout->addWidget( Zeichen );
 
Layout1 = new QHBoxLayout;
235,6 → 235,7
QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
Layout1->addItem( spacer_4 );
ZAuswahlLayout->addLayout( Layout1 );
Zeichen->setMaximumSize(width(), 50);
 
// signals and slots connections
connect(Close, SIGNAL(clicked()), this, SLOT(accept()));
250,22 → 251,28
void ZAuswahl::NeuesZeichen(int r, int c) // , int b, const QPoint &pp)
{
if ((r*32+c) < MaxCount)
Zeichen->insert(QChar(Zeich[r*32+c]));
{
ChToIns += QChar(Zeich[r*32+c]);
QString da = (*ap->doc->AllFonts)[ap->doc->CurrFont]->Datei;
Zeichen->setPixmap(FontSample(da, 28, ChToIns, paletteBackgroundColor()));
}
}
 
void ZAuswahl::DelEdit()
{
Zeichen->clear();
ChToIns = "";
QPixmap pm(1,28);
pm.fill(paletteBackgroundColor());
Zeichen->setPixmap(pm);
}
 
void ZAuswahl::InsChar()
{
struct Pti *hg;
QString Tex = Zeichen->text();
for (uint a=0; a<Tex.length(); a++)
for (uint a=0; a<ChToIns.length(); a++)
{
hg = new Pti;
hg->ch = Tex.at(a);
hg->ch = ChToIns.at(a);
if (hg->ch == QChar(10)) { hg->ch = QChar(13); }
if (hg->ch == QChar(9)) { hg->ch = " "; }
hg->cfont = ap->doc->CurrFont;
/trunk/Scribus/scribus/plugins/svgimplugin/svgplugin.cpp
16,6 → 16,7
extern bool loadText(QString nam, QString *Buffer);
extern QPixmap loadIcon(QString nam);
extern double Cwidth(ScribusDoc *doc, QString name, QString ch, int Siz, QString ch2 = " ");
extern FPoint GetMaxClipF(FPointArray Clip);
 
QString Name()
{
211,8 → 212,9
QWMatrix mm = QWMatrix();
mm.translate(x, y);
ite->PoLine.map(mm);
ite->Width = Doku->ActPage->GetMaxClipF(ite->PoLine).x();
ite->Height = Doku->ActPage->GetMaxClipF(ite->PoLine).y();
FPoint wh = GetMaxClipF(ite->PoLine);
ite->Width = wh.x();
ite->Height = wh.y();
}
else if( STag == "ellipse" )
{
228,8 → 230,9
QWMatrix mm = QWMatrix();
mm.translate(x, y);
ite->PoLine.map(mm);
ite->Width = Doku->ActPage->GetMaxClipF(ite->PoLine).x();
ite->Height = Doku->ActPage->GetMaxClipF(ite->PoLine).y();
FPoint wh = GetMaxClipF(ite->PoLine);
ite->Width = wh.x();
ite->Height = wh.y();
}
else if( STag == "circle" )
{
244,8 → 247,9
QWMatrix mm = QWMatrix();
mm.translate(x, y);
ite->PoLine.map(mm);
ite->Width = Doku->ActPage->GetMaxClipF(ite->PoLine).x();
ite->Height = Doku->ActPage->GetMaxClipF(ite->PoLine).y();
FPoint wh = GetMaxClipF(ite->PoLine);
ite->Width = wh.x();
ite->Height = wh.y();
}
else if( STag == "line" )
{
411,8 → 415,9
ite->FrameType = 3;
QWMatrix mm = gc->matrix;
ite->PoLine.map(mm);
ite->Width = Doku->ActPage->GetMaxClipF(ite->PoLine).x();
ite->Height = Doku->ActPage->GetMaxClipF(ite->PoLine).y();
FPoint wh = GetMaxClipF(ite->PoLine);
ite->Width = wh.x();
ite->Height = wh.y();
ite->Clip = FlattenPath(ite->PoLine, ite->Segments);
Doku->ActPage->AdjustItemSize(ite);
break;
/trunk/Scribus/scribus/page.cpp
64,6 → 64,7
extern double xy2Deg(double x, double y);
extern void BezierPoints(QPointArray *ar, QPoint n1, QPoint n2, QPoint n3, QPoint n4);
extern void Level2Layer(ScribusDoc *doc, struct Layer *ll, int Level);
extern FPoint GetMaxClipF(FPointArray Clip);
 
Page::Page(QWidget *pa, int x, int y, int b, int h, ScribusDoc *doc, QScrollView *view)
: QWidget(pa, "ps", WRepaintNoErase)
2184,6 → 2185,31
MoveItemI(0, (b->Height - b->OldH2)/b->LocalScY, b->ItemNr);
break;
}
if ((b->PType == 4) && (m->state() & ShiftButton) && (m->state() & ControlButton))
{
double scx = b->Width / b->OldB2;
double scy = b->Height / b->OldH2;
if (scx != scy)
scx = scx / scy;
else
scx = 1.0;
if (b->Ptext.count() != 0)
{
b->ISize = QMAX(qRound(b->ISize * scy), 1);
b->LineSp = (b->ISize * static_cast<double>(doku->AutoLine) / 100) + b->ISize;
b->TxtScale = QMIN(QMAX(qRound(b->TxtScale * scx), 25), 400);
doku->CurrTextScale = b->TxtScale;
doku->CurrFontSize = b->ISize;
emit ItemTextAttr(b->LineSp);
emit ItemTextSize(b->ISize);
emit ItemTextSca(b->TxtScale);
for (uint aa = 0; aa < b->Ptext.count(); ++aa)
{
b->Ptext.at(aa)->csize = QMAX(qRound(b->Ptext.at(aa)->csize*scy), 1);
b->Ptext.at(aa)->cscale = QMAX(QMIN(qRound(b->Ptext.at(aa)->cscale*scx), 400), 25);
}
}
}
if (b->PType == 2)
{
AdjustPictScale(b);
2769,7 → 2795,7
case 1:
p.begin(this);
Transform(b, &p);
if (m->state() & ShiftButton)
if ((m->state() & ShiftButton) && (!(m->state() & ControlButton)))
{
mop = QPoint(m->x(), static_cast<int>((b->Ypos + (newX - b->Xpos)) * sc));
QCursor::setPos(mapToGlobal(mop));
2776,7 → 2802,7
}
else
{
if (m->state() & ControlButton)
if ((m->state() & ControlButton) && (!(m->state() & ShiftButton)))
{
mop = QPoint(m->x(), static_cast<int>((b->Ypos + ((newX - b->Xpos) / b->OldB2 * b->OldH2)) * sc));
QCursor::setPos(mapToGlobal(mop));
3898,25 → 3924,6
return rp;
}
 
FPoint Page::GetMaxClipF(FPointArray Clip)
{
FPoint np, rp;
double mx = 0;
double my = 0;
for (uint c = 0; c < Clip.size(); ++c)
{
np = Clip.point(c);
if (np.x() > 900000)
continue;
if (np.x() > mx)
mx = np.x();
if (np.y() > my)
my = np.y();
}
rp = FPoint(mx, my);
return rp;
}
 
QPoint Page::GetMinClip(QPointArray Clip)
{
QPoint np, rp;
4453,19 → 4460,19
{
p.setPen(QPen(magenta, 8, SolidLine, RoundCap, MiterJoin));
cli.point(a+1, &x, &y);
p.drawLine(static_cast<int>(x), static_cast<int>(y), static_cast<int>(x), static_cast<int>(y));
p.drawLine(qRound(x), qRound(y), qRound(x), qRound(y));
p.setPen(QPen(blue, 8, SolidLine, RoundCap, MiterJoin));
cli.point(a, &x, &y);
p.drawLine(static_cast<int>(x), static_cast<int>(y), static_cast<int>(x), static_cast<int>(y));
p.drawLine(qRound(x), qRound(y), qRound(x), qRound(y));
}
else
{
p.setPen(QPen(blue, 8, SolidLine, RoundCap, MiterJoin));
cli.point(a, &x, &y);
p.drawLine(static_cast<int>(x), static_cast<int>(y), static_cast<int>(x), static_cast<int>(y));
p.drawLine(qRound(x), qRound(y), qRound(x), qRound(y));
p.setPen(QPen(magenta, 8, SolidLine, RoundCap, MiterJoin));
cli.point(a+1, &x, &y);
p.drawLine(static_cast<int>(x), static_cast<int>(y), static_cast<int>(x), static_cast<int>(y));
p.drawLine(qRound(x), qRound(y), qRound(x), qRound(y));
}
}
if (ClRe != -1)
4472,12 → 4479,12
{
p.setPen(QPen(red, 8, SolidLine, RoundCap, MiterJoin));
cli.point(ClRe, &x, &y);
p.drawLine(static_cast<int>(x), static_cast<int>(y), static_cast<int>(x), static_cast<int>(y));
p.drawLine(qRound(x), qRound(y), qRound(x), qRound(y));
QValueList<int>::Iterator itm;
for (itm = SelNode.begin(); itm != SelNode.end(); ++itm)
{
cli.point((*itm), &x, &y);
p.drawLine(static_cast<int>(x), static_cast<int>(y), static_cast<int>(x), static_cast<int>(y));
p.drawLine(qRound(x), qRound(y), qRound(x), qRound(y));
}
emit HavePoint(true, MoveSym);
}
/trunk/Scribus/scribus/libpdf/pdflib.cpp
39,6 → 39,7
extern char *toHex( uchar u );
extern QString String2Hex(QString *in, bool lang = true);
extern double Cwidth(ScribusDoc *doc, QString name, QString ch, int Siz, QString ch2 = " ");
extern FPoint GetMaxClipF(FPointArray Clip);
#ifdef HAVE_CMS
extern bool CMSuse;
#endif
202,25 → 203,21
 
QString PDFlib::EncStream(QString *in, int ObjNum)
{
rc4_context_t rc4;
if (in->length() < 1)
return "";
rc4_context_t rc4;
QString tmp = "";
int dlen = 0;
if (Options->Encrypt)
{
if (in->length() < 1)
return "";
tmp = *in;
QByteArray us(tmp.length());
QByteArray ou(tmp.length());
for (uint a = 0; a < tmp.length(); ++a)
{
us[a] = uchar(QChar(tmp.at(a)));
}
us[a] = uchar(QChar(tmp.at(a)));
QByteArray data(10);
if (KeyLen > 5)
{
data.resize(21);
}
for (int cd = 0; cd < KeyLen; ++cd)
{
data[cd] = EncryKey[cd];
233,13 → 230,11
data[dlen++] = 0;
QByteArray step1(16);
step1 = ComputeMD5Sum(&data);
rc4_init(&rc4, (uchar*)step1.data(), QMIN(KeyLen+5, 16));
rc4_encrypt(&rc4, (uchar*)us.data(), (uchar*)ou.data(), tmp.length());
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 (uint cl = 0; cl < tmp.length(); ++cl)
{
uk += ou[cl];
}
tmp = uk;
}
else
249,25 → 244,21
 
QString PDFlib::EncString(QString in, int ObjNum)
{
rc4_context_t rc4;
if (in.length() < 3)
return "<>";
rc4_context_t rc4;
QString tmp;
int dlen = 0;
if (Options->Encrypt)
{
if (in.length() < 3)
return "<>";
tmp = in.mid(1, in.length()-2);
QByteArray us(tmp.length());
QByteArray ou(tmp.length());
for (uint a = 0; a < tmp.length(); ++a)
{
us[a] = uchar(QChar(tmp.at(a)));
}
us[a] = static_cast<uchar>(QChar(tmp.at(a)));
QByteArray data(10);
if (KeyLen > 5)
{
data.resize(21);
}
data.resize(21);
for (int cd = 0; cd < KeyLen; ++cd)
{
data[cd] = EncryKey[cd];
284,9 → 275,7
rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), tmp.length());
QString uk = "";
for (uint cl = 0; cl < tmp.length(); ++cl)
{
uk += ou[cl];
}
tmp = "<"+String2Hex(&uk, false)+">";
}
else
301,9 → 290,7
{
uint l = pw.length();
for (uint a = 0; a < 32 - l; ++a)
{
pw.append(KeyGen[a]);
}
}
else
pw = pw.left(32);
325,9 → 312,7
if (KeyLen > 5)
{
for (int kl = 0; kl < 50; ++kl)
{
step1 = ComputeMD5Sum(&step1);
}
}
QByteArray us(32);
QByteArray enk(16);
334,15 → 319,11
if (KeyLen > 5)
{
for (uint a2 = 0; a2 < 32; ++a2)
{
OwnerKey[a2] = uchar(QChar(pw.at(a2)));
}
OwnerKey[a2] = static_cast<uchar>(QChar(pw.at(a2)));
for (int rl = 0; rl < 20; rl++)
{
for (int j = 0; j < 16; j ++)
{
enk[j] = step1[j] ^ rl;
}
rc4_init(&rc4, reinterpret_cast<uchar*>(enk.data()), 16);
rc4_encrypt(&rc4, reinterpret_cast<uchar*>(OwnerKey.data()), reinterpret_cast<uchar*>(OwnerKey.data()), 32);
}
350,13 → 331,10
else
{
for (uint a = 0; a < 32; ++a)
{
us[a] = uchar(QChar(pw.at(a)));
}
us[a] = static_cast<uchar>(QChar(pw.at(a)));
rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), 5);
rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(OwnerKey.data()), 32);
}
return;
}
 
void PDFlib::CalcUserKey(QString User, int Permission)
372,53 → 350,35
perm[2] = perm_value >> 16;
perm[3] = perm_value >> 24;
for (uint a = 0; a < 32; ++a)
{
pw += OwnerKey[a];
}
for (uint a1 = 0; a1 < 4; ++a1)
{
pw += perm[a1];
}
for (uint a3 = 0; a3 < 16; ++a3)
{
pw += FileID[a3];
}
step1 = ComputeMD5(pw);
if (KeyLen > 5)
{
for (int kl = 0; kl < 50; ++kl)
{
step1 = ComputeMD5Sum(&step1);
}
EncryKey.resize(16);
}
for (int a2 = 0; a2 < KeyLen; ++a2)
{
EncryKey[a2] = step1[a2];
}
if (KeyLen > 5)
{
QString pr2 = "";
for (int kl3 = 0; kl3 < 32; ++kl3)
{
pr2 += KeyGen[kl3];
}
for (uint a4 = 0; a4 < 16; ++a4)
{
pr2 += FileID[a4];
}
step1 = ComputeMD5(pr2);
QByteArray enk(16);
for (uint a3 = 0; a3 < 16; ++a3)
{
UserKey[a3] = step1[a3];
}
for (int rl = 0; rl < 20; rl++)
{
for (int j = 0; j < 16; j ++)
{
enk[j] = EncryKey[j] ^ rl;
}
rc4_init(&rc4, reinterpret_cast<uchar*>(enk.data()), 16);
rc4_encrypt(&rc4, reinterpret_cast<uchar*>(UserKey.data()), reinterpret_cast<uchar*>(UserKey.data()), 16);
}
428,7 → 388,6
rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), 5);
rc4_encrypt(&rc4, reinterpret_cast<uchar*>(KeyGen.data()), reinterpret_cast<uchar*>(UserKey.data()), 32);
}
return;
}
 
QByteArray PDFlib::ComputeMD5(QString in)
435,23 → 394,21
{
QByteArray TBytes(in.length());
for (uint a = 0; a < in.length(); ++a)
{
TBytes[a] = uchar(QChar(in.at(a)));
}
TBytes[a] = static_cast<uchar>(QChar(in.at(a)));
return ComputeMD5Sum(&TBytes);
}
 
bool PDFlib::PDF_Begin_Doc(QString fn, ScribusDoc *docu, ScribusView *vie, PDFOpt *opts, SCFonts &AllFonts, QMap<QString,QFont> DocFonts, BookMView* vi)
{
QString tmp;
Spool.setName(fn);
if (!Spool.open(IO_WriteOnly))
return false;
QString tmp;
QString ok = "";
QString uk = "";
QFileInfo fd;
QString fext;
int a;
Spool.setName(fn);
if (!Spool.open(IO_WriteOnly))
return false;
doc = docu;
view = vie;
Bvie = vi;
458,15 → 415,9
Options = opts;
UsedFontsP.clear();
ObjCounter = Options->Articles ? 9 : 8;
if (Options->Version == 12)
{
PutDoc("%PDF-1.3\n");
PutDoc(Options->Version <= 13 ? "%PDF-1.3\n" : "%PDF-1.4\n");
if (Options->Version == 12)
ObjCounter++;
}
if (Options->Version == 13)
PutDoc("%PDF-1.3\n");
if (Options->Version == 14)
PutDoc("%PDF-1.4\n");
PutDoc("%"+QString(QChar(199))+QString(QChar(236))+QString(QChar(143))+QString(QChar(162))+"\n");
StartObj(1);
PutDoc("<<\n/Type /Catalog\n/Outlines 3 0 R\n/Pages 4 0 R\n/Dests 5 0 R\n/AcroForm 6 0 R\n/Names 7 0 R\n");
491,26 → 442,18
CalcOwnerKey(Options->PassOwner, Options->PassUser);
CalcUserKey(Options->PassUser, Options->Permissions);
for (uint cl2 = 0; cl2 < 32; ++cl2)
{
ok += OwnerKey[cl2];
}
if (KeyLen > 5)
{
for (uint cl3 = 0; cl3 < 16; ++cl3)
{
uk += UserKey[cl3];
}
for (uint cl3r = 0; cl3r < 16; ++cl3r)
{
uk += KeyGen[cl3r];
}
}
else
{
for (uint cl = 0; cl < 32; ++cl)
{
uk += UserKey[cl];
}
}
}
QDate d = QDate::currentDate();
539,11 → 482,8
if (Options->Version == 12)
PutDoc("/GTS_PDFXVersion (PDF/X-3:2002)\n");
PutDoc("/Trapped /False\n>>\nendobj\n");
XRef.append(Dokument);
XRef.append(Dokument);
XRef.append(Dokument);
XRef.append(Dokument);
XRef.append(Dokument);
for (int t = 0; t < 5; ++t)
XRef.append(Dokument);
if (Options->Articles)
XRef.append(Dokument);
if (Options->Version == 12)
669,7 → 609,7
StartObj(ObjCounter);
ObjCounter++;
np = doc->ActPage->GetMinClipF(gly);
np1 = doc->ActPage->GetMaxClipF(gly);
np1 = GetMaxClipF(gly);
PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n");
PutDoc("/BBox [ "+FToStr(np.x())+" "+FToStr(-np.y())+" "+FToStr(np1.x())+" "+FToStr(-np1.y())+" ]\n");
PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
945,9 → 885,7
PutDoc("/XObject <<\n");
QMap<QString,int>::Iterator it;
for (it = Seite.XObjects.begin(); it != Seite.XObjects.end(); ++it)
{
PutDoc("/"+it.key()+" "+IToStr(it.data())+" 0 R\n");
}
PutDoc(">>\n");
}
if (Seite.FObjects.count() != 0)
955,9 → 893,7
PutDoc("/Font << \n");
QMap<QString,int>::Iterator it2;
for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
{
PutDoc("/"+it2.key()+" "+IToStr(it2.data())+" 0 R\n");
}
PutDoc(">>\n");
}
if (Shadings.count() != 0)
965,9 → 901,7
PutDoc("/Shading << \n");
QMap<QString,int>::Iterator it3;
for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3)
{
PutDoc("/"+it3.key()+" "+IToStr(it3.data())+" 0 R\n");
}
PutDoc(">>\n");
}
if (Transpar.count() != 0)
975,9 → 909,7
PutDoc("/ExtGState << \n");
QMap<QString,int>::Iterator it3t;
for (it3t = Transpar.begin(); it3t != Transpar.end(); ++it3t)
{
PutDoc("/"+it3t.key()+" "+IToStr(it3t.data())+" 0 R\n");
}
PutDoc(">>\n");
}
if (ICCProfiles.count() != 0)
985,9 → 917,7
PutDoc("/ColorSpace << \n");
QMap<QString,ICCD>::Iterator it3c;
for (it3c = ICCProfiles.begin(); it3c != ICCProfiles.end(); ++it3c)
{
PutDoc("/"+it3c.data().ResName+" "+IToStr(it3c.data().ResNum)+" 0 R\n");
}
PutDoc(">>\n");
}
PutDoc(">>\n");
1042,9 → 972,7
{
PutDoc("/Annots [ ");
for (uint b = 0; b < Seite.AObjects.count(); ++b)
{
PutDoc(IToStr(Seite.AObjects[b])+" 0 R ");
}
PutDoc("]\n");
}
if (Options->PresentMode)
1220,16 → 1148,11
PDF_Transparenz(ite);
if ((ite->isBookmark) && (Options->Bookmarks))
PDF_Bookmark(ite->BMnr, doc->PageH - ite->Ypos);
if (!ite->isPrintable)
if (!ite->isPrintable || ((ite->PType == 4) && (pag->PageNam != "")))
{
PutPage("Q\n");
continue;
}
if ((ite->PType == 4) && (pag->PageNam != ""))
{
PutPage("Q\n");
continue;
}
if (Options->UseRGB)
{
if (ite->Pcolor != "None")
1360,9 → 1283,7
if ((ite->flippedV % 2) != 0)
PutPage("1 0 0 -1 0 "+FToStr(-ite->Height)+" cm\n");
if ((ite->PicAvail) && (ite->Pfile != ""))
{
PDF_Image(ite->InvPict, ite->Pfile, ite->LocalScX, ite->LocalScY, ite->LocalX, -ite->LocalY, false, ite->IProfile, ite->UseEmbedded, ite->IRender);
}
PutPage("Q\n");
if ((ite->Pcolor2 != "None") || (ite->NamedLStyle != ""))
{
2412,9 → 2333,7
PutDoc(EncString(cnx,ObjCounter-1)+"\n");
PutDoc("/Opt [ ");
for (uint bmc = 0; bmc < bmst.count(); ++bmc)
{
PutDoc(EncString("("+bmst[bmc]+")",ObjCounter-1)+"\n");
}
PutDoc("]\n");
PutDoc("/AP << /N "+IToStr(ObjCounter)+" 0 R >>\n");
break;
2445,10 → 2364,7
{
if (ite->Pfile != "")
{
if (ite->pixm.hasAlphaBuffer())
IconOb += 3;
else
IconOb += 2;
IconOb += ite->pixm.hasAlphaBuffer() ? 3 : 2;
PutDoc("/I "+IToStr(ObjCounter+IconOb-1)+" 0 R ");
}
if (ite->Pfile2 != "")
2862,9 → 2778,7
PutDoc("/XObject <<\n");
QMap<QString,int>::Iterator it;
for (it = Seite.XObjects.begin(); it != Seite.XObjects.end(); ++it)
{
PutDoc("/"+it.key()+" "+IToStr(it.data())+" 0 R\n");
}
PutDoc(">>\n");
}
if (Seite.FObjects.count() != 0)
2872,9 → 2786,7
PutDoc("/Font << \n");
QMap<QString,int>::Iterator it2;
for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
{
PutDoc("/"+it2.key()+" "+IToStr(it2.data())+" 0 R\n");
}
PutDoc(">>\n");
}
PutDoc(">>\n");
2894,9 → 2806,7
PutDoc("/Font << \n");
QMap<QString,int>::Iterator it2;
for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
{
PutDoc("/"+it2.key()+" "+IToStr(it2.data())+" 0 R\n");
}
PutDoc(">>\n");
}
PutDoc(">>\n");
2944,9 → 2854,7
if (TIFFGetField(tif, TIFFTAG_ICCPROFILE, &EmbedLen, &EmbedBuffer))
{
for (uint el = 0; el < EmbedLen; ++el)
{
dataP += EmbedBuffer[el];
}
}
else
loadText(InputProfiles[Options->ImageProf], &dataP);
2962,12 → 2870,7
loadText(InputProfiles[Options->ImageProf], &dataP);
#endif
else
{
if (Embedded)
loadText(InputProfiles[Options->ImageProf], &dataP);
else
loadText(InputProfiles[Profil], &dataP);
}
loadText((Embedded ? InputProfiles[Options->ImageProf] : InputProfiles[Profil]), &dataP);
PutDoc("<<\n");
if ((Options->Compress) && (CompAvail))
{
3153,10 → 3056,7
else
{
#endif
if (Options->UseRGB)
PutDoc("/ColorSpace /DeviceRGB\n");
else
PutDoc("/ColorSpace /DeviceCMYK\n");
PutDoc(Options->UseRGB ? "/ColorSpace /DeviceRGB\n" : "/ColorSpace /DeviceCMYK\n");
#ifdef HAVE_CMS
}
#endif
3163,7 → 3063,7
PutDoc("/BitsPerComponent 8\n");
PutDoc("/Length "+IToStr(im.length())+"\n");
if (img.hasAlphaBuffer())
PutDoc("/Mask "+IToStr(ObjCounter-2)+" 0 R\n");
PutDoc("/Mask "+IToStr(ObjCounter-2)+" 0 R\n");
if ((Options->Compress) && (CompAvail))
PutDoc("/Filter /FlateDecode\n");
PutDoc(">>\nstream\n"+EncStream(&im, ObjCounter-1)+"\nendstream\nendobj\n");
3174,7 → 3074,6
Inhalt += "/"+ResNam+IToStr(ResCount)+" Do\n";
}
ResCount++;
return;
}
 
void PDFlib::PDF_End_Doc(QString PrintPr, QString Name, int Components)
3248,9 → 3147,7
PutDoc("/XObject <<\n");
QMap<QString,int>::Iterator it;
for (it = Seite.XObjects.begin(); it != Seite.XObjects.end(); ++it)
{
PutDoc("/"+it.key()+" "+IToStr(it.data())+" 0 R\n");
}
PutDoc(">>\n");
}
if (Seite.FObjects.count() != 0)
3258,9 → 3155,7
PutDoc("/Font << \n");
QMap<QString,int>::Iterator it2;
for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
{
PutDoc("/"+it2.key()+" "+IToStr(it2.data())+" 0 R\n");
}
PutDoc(">>\n");
}
if (Shadings.count() != 0)
3268,9 → 3163,7
PutDoc("/Shading << \n");
QMap<QString,int>::Iterator it3;
for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3)
{
PutDoc("/"+it3.key()+" "+IToStr(it3.data())+" 0 R\n");
}
PutDoc(">>\n");
}
if (Transpar.count() != 0)
3278,9 → 3171,7
PutDoc("/ExtGState << \n");
QMap<QString,int>::Iterator it3t;
for (it3t = Transpar.begin(); it3t != Transpar.end(); ++it3t)
{
PutDoc("/"+it3t.key()+" "+IToStr(it3t.data())+" 0 R\n");
}
PutDoc(">>\n");
}
if (ICCProfiles.count() != 0)
3288,9 → 3179,7
PutDoc("/ColorSpace << \n");
QMap<QString,ICCD>::Iterator it3c;
for (it3c = ICCProfiles.begin(); it3c != ICCProfiles.end(); ++it3c)
{
PutDoc("/"+it3c.data().ResName+" "+IToStr(it3c.data().ResNum)+" 0 R\n");
}
PutDoc(">>\n");
}
PutDoc(">>\nendobj\n");
3307,9 → 3196,7
XRef[3] = Dokument;
PutDoc("4 0 obj\n<<\n/Type /Pages\n/Kids [");
for (uint b = 0; b < PageTree.Kids.count(); ++b)
{
PutDoc(IToStr(PageTree.Kids[b])+" 0 R ");
}
PutDoc("]\n");
PutDoc("/Count "+IToStr(PageTree.Count)+"\n");
PutDoc("/Resources "+IToStr(ObjCounter-1)+" 0 R\n");
3331,9 → 3218,7
if (Seite.FormObjects.count() != 0)
{
for (uint fo = 0; fo < Seite.FormObjects.count(); ++fo)
{
PutDoc(IToStr(Seite.FormObjects[fo])+" 0 R ");
}
}
PutDoc(" ]\n");
if (CalcFields.count() != 0)
3340,9 → 3225,7
{
PutDoc("/CO [ ");
for (uint foc = 0; foc < CalcFields.count(); ++foc)
{
PutDoc(IToStr(CalcFields[foc])+" 0 R ");
}
PutDoc(" ]\n");
}
PutDoc("/NeedAppearances true\n/DR "+IToStr(ResO)+" 0 R\n>>\nendobj\n");
3351,9 → 3234,7
int Fjav0 = ObjCounter;
QMap<QString,QString>::Iterator itja0;
for (itja0 = doc->JavaScripts.begin(); itja0 != doc->JavaScripts.end(); ++itja0)
{
WritePDFStream(&itja0.data());
}
int Fjav = ObjCounter;
QMap<QString,QString>::Iterator itja;
for (itja = doc->JavaScripts.begin(); itja != doc->JavaScripts.end(); ++itja)
3439,16 → 3320,12
for (uint pgs = 0; pgs < view->Pages.count(); ++pgs)
{
for (uint ele = 0; ele < view->Pages.at(pgs)->Items.count(); ++ele)
{
view->Pages.at(pgs)->Items.at(ele)->Redrawn = false;
}
}
XRef[7] = Dokument;
PutDoc("8 0 obj\n[");
for (uint th = 0; th < Threads.count(); ++th)
{
PutDoc(IToStr(Threads[th])+" 0 R ");
}
PutDoc("]\nendobj\n");
}
if (Options->Version == 12)
3496,9 → 3373,7
PutDoc("trailer\n<<\n/Size "+IToStr(XRef.count()+1)+"\n");
QString IDs ="";
for (uint cl = 0; cl < 16; ++cl)
{
IDs += FileID[cl];
}
IDs = String2Hex(&IDs);
PutDoc("/Root 1 0 R\n/Info 2 0 R\n/ID [<"+IDs+"><"+IDs+">]\n");
if (Options->Encrypt)