Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 6406 → Rev 6407

/branches/Version13x/Scribus/scribus/scribusXml.cpp
1070,9 → 1070,6
 
QString ScriXmlDoc::WriteElem(ScribusDoc *doc, ScribusView *view, Selection* selection)
{
// int te, te2, tsh, tsh2, tst, tst2, tsb, tsb2, tshs, tshs2;
// QString text, tf, tf2, tc, tc2, tcs, tcs2, tmp, tmpy;
// double ts, ts2, tsc, tsc2, tscv, tscv2, tb, tb2, tsx, tsx2, tsy, tsy2, tout, tout2, tulp, tulp2, tulw, tulw2, tstp, tstp2, tstw, tstw2, xp, yp;
double xp, yp;
QString tmp, tmpy;
PageItem *item;
1080,12 → 1077,9
QString st="<SCRIBUSELEMUTF8></SCRIBUSELEMUTF8>";
docu.setContent(st);
QDomElement elem=docu.documentElement();
//item = Selitems->at(0);
item = selection->itemAt(0);
QValueList<uint> ELL;
//for (uint cor=0; cor<Selitems->count(); ++cor)
for (uint cor=0; cor<selection->count(); ++cor)
//ELL.append(Selitems->at(cor)->ItemNr);
ELL.append(selection->itemAt(cor)->ItemNr);
qHeapSort(ELL);
if (selection->isMultipleSelection())
1097,14 → 1091,14
}
else
{
double minx = 99999.9;
double miny = 99999.9;
double maxx = -99999.9;
double maxy = -99999.9;
double xpo = item->xPos() - doc->currentPage()->xOffset();
double ypo = item->yPos() - doc->currentPage()->yOffset();
if (item->rotation() != 0)
{
double minx = 99999.9;
double miny = 99999.9;
double maxx = -99999.9;
double maxy = -99999.9;
double xpo = item->xPos() - doc->currentPage()->xOffset();
double ypo = item->yPos() - doc->currentPage()->yOffset();
FPointArray pb(4);
pb.setPoint(0, FPoint(xpo, ypo));
pb.setPoint(1, FPoint(item->width(), 0.0, xpo, ypo, item->rotation(), 1.0, 1.0));
1117,22 → 1111,19
maxx = QMAX(maxx, pb.point(pc).x());
maxy = QMAX(maxy, pb.point(pc).y());
}
elem.setAttribute("W", maxx - minx);
elem.setAttribute("H", maxy - miny);
}
else
{
minx = QMIN(minx, xpo);
miny = QMIN(miny, ypo);
maxx = QMAX(maxx, xpo + item->width());
maxy = QMAX(maxy, ypo + item->height());
elem.setAttribute("W", item->width());
elem.setAttribute("H", item->height());
}
xp = xpo - minx;
yp = ypo - miny;
elem.setAttribute("W", maxx - minx);
elem.setAttribute("H", maxy - miny);
xp = item->xPos() - doc->currentPage()->xOffset();
yp = item->yPos() - doc->currentPage()->yOffset();
}
elem.setAttribute("XP", xp);
elem.setAttribute("YP", yp);
//elem.setAttribute("COUNT", Selitems->count());
elem.setAttribute("COUNT", selection->count());
elem.setAttribute("Version", QString(VERSION));
QMap<QString,int>::Iterator itf;
/branches/Version13x/Scribus/scribus/patterndialog.cpp
44,6 → 44,7
{
dialogPatterns.insert(it.key(), it.data());
}
origPatterns = docPatterns->keys();
updatePatternList();
buttonRemove->setEnabled(false);
connect(buttonOK, SIGNAL(clicked()), this, SLOT(accept()));
174,8 → 175,13
if (!dialogPatterns.contains(patNam))
{
dialogPatterns.insert(patNam, pat);
updatePatternList();
}
for (QMap<QString, ScPattern>::Iterator it = m_doc->docPatterns.begin(); it != m_doc->docPatterns.end(); ++it)
{
if (!origPatterns.contains(it.key()))
dialogPatterns.insert(it.key(), it.data());
}
updatePatternList();
}
 
void PatternDialog::patternSelected(QIconViewItem* it)
194,7 → 200,47
QIconViewItem *it = patternView->currentItem();
if (it)
{
dialogPatterns.remove(it->text());
QStringList patterns2Del;
QStringList mainPatterns = dialogPatterns.keys();
for (uint a = 0; a < mainPatterns.count(); a++)
{
if (mainPatterns[a] != it->text())
{
QStringList subPatterns;
subPatterns = getUsedPatternsHelper(mainPatterns[a], subPatterns);
if (subPatterns.contains(it->text()))
patterns2Del.append(mainPatterns[a]);
}
}
QStringList subPatterns;
subPatterns = getUsedPatternsHelper(it->text(), subPatterns);
if (!subPatterns.isEmpty())
patterns2Del += subPatterns;
patterns2Del.append(it->text());
for (uint a = 0; a < patterns2Del.count(); a++)
{
dialogPatterns.remove(patterns2Del[a]);
}
updatePatternList();
}
}
 
QStringList PatternDialog::getUsedPatternsHelper(QString pattern, QStringList &results)
{
ScPattern *pat = &dialogPatterns[pattern];
QStringList pats;
pats.clear();
for (uint c = 0; c < pat->items.count(); ++c)
{
if ((!results.contains(pat->items.at(c)->pattern())) && (pat->items.at(c)->GrType == 8))
pats.append(pat->items.at(c)->pattern());
}
if (!pats.isEmpty())
{
for (uint c = 0; c < pats.count(); ++c)
{
getUsedPatternsHelper(pats[c], results);
}
}
return pats;
}
/branches/Version13x/Scribus/scribus/scribusdoc.cpp
2156,6 → 2156,50
colorsToUse.insert(it.key(), it.data());
continue;
}
QStringList patterns = getUsedPatterns();
for (uint c = 0; c < patterns.count(); ++c)
{
ScPattern pa = docPatterns[patterns[c]];
for (uint o = 0; o < pa.items.count(); o++)
{
ite = pa.items.at(o);
QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops();
for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
{
if (it.key() == cstops.at(cst)->name)
found = true;
if (found)
break;
}
if ((ite->itemType() == PageItem::TextFrame) || (ite->itemType() == PageItem::PathText))
{
for (int d=0; d<ite->itemText.length(); ++d)
{
/* PFJ - 29.02.04 - Merged if's */
if ((it.key() == ite->itemText.charStyle(d).fillColor()) || (it.key() == ite->itemText.charStyle(d).strokeColor()))
found = true;
if (found)
break;
}
}
/* PFJ - 29.02.04 - Merged if's */
if ((it.key() == ite->fillColor()) || (it.key() == ite->lineColor()))
found = true;
if (found)
break;
}
if (found)
{
if (spot)
{
if (it.data().isSpotColor())
colorsToUse.insert(it.key(), it.data());
}
else
colorsToUse.insert(it.key(), it.data());
continue;
}
}
}
}
 
2233,8 → 2277,6
void ScribusDoc::getUsedFonts(QMap<QString, QMap<uint, FPointArray> > & Really)
{
PageItem* it = NULL;
FPointArray gly;
QString chstr;
uint counter = 0;
for (uint lc = 0; lc < 3; ++lc)
{
2264,119 → 2306,135
it = FrameItems.at(d);
break;
}
if ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText))
checkItemForFonts(it, Really, lc);
}
}
QStringList patterns = getUsedPatterns();
for (uint c = 0; c < patterns.count(); ++c)
{
ScPattern pa = docPatterns[patterns[c]];
for (uint o = 0; o < pa.items.count(); o++)
{
checkItemForFonts(pa.items.at(o), Really, 3);
}
}
}
 
void ScribusDoc::checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc)
{
FPointArray gly;
QString chstr;
if ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText))
{
for (int e = 0; e < it->itemText.length(); ++e)
{
for (int e = 0; e < it->itemText.length(); ++e)
if (! Really.contains(it->itemText.charStyle(e).font().scName()) ) {
Really.insert(it->itemText.charStyle(e).font().scName(), QMap<uint, FPointArray>());
}
uint chr = it->itemText.text(e).unicode();
if ((chr == 13) || (chr == 32) || (chr == 29))
continue;
if (chr == 9)
{
for (uint t1 = 0; t1 < it->itemText.paragraphStyle(e).tabValues().count(); t1++)
{
if (! Really.contains(it->itemText.charStyle(e).font().scName()) ) {
Really.insert(it->itemText.charStyle(e).font().scName(), QMap<uint, FPointArray>());
}
uint chr = it->itemText.text(e).unicode();
if ((chr == 13) || (chr == 32) || (chr == 29))
if (it->itemText.paragraphStyle(e).tabValues()[t1].tabFillChar.isNull())
continue;
if (chr == 9)
chstr = QString(it->itemText.paragraphStyle(e).tabValues()[t1].tabFillChar);
if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
{
for (uint t1 = 0; t1 < it->itemText.paragraphStyle(e).tabValues().count(); t1++)
{
if (it->itemText.paragraphStyle(e).tabValues()[t1].tabFillChar.isNull())
continue;
chstr = QString(it->itemText.paragraphStyle(e).tabValues()[t1].tabFillChar);
if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
{
if (chstr.upper() != QString(it->itemText.paragraphStyle(e).tabValues()[t1].tabFillChar))
chstr = chstr.upper();
}
chr = chstr[0].unicode();
uint gl = it->itemText.charStyle(e).font().char2CMap(chstr[0]);
gly = it->itemText.charStyle(e).font().glyphOutline(gl);
Really[it->itemText.charStyle(e).font().scName()].insert(gl, gly);
}
for (uint t1 = 0; t1 < it->TabValues.count(); t1++)
{
if (it->TabValues[t1].tabFillChar.isNull())
continue;
chstr = QString(it->TabValues[t1].tabFillChar);
if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
{
if (chstr.upper() != QString(it->TabValues[t1].tabFillChar))
chstr = chstr.upper();
}
chr = chstr[0].unicode();
uint gl = it->itemText.charStyle(e).font().char2CMap(chstr[0]);
gly = it->itemText.charStyle(e).font().glyphOutline(gl);
Really[it->itemText.charStyle(e).font().scName()].insert(gl, gly);
}
if (chstr.upper() != QString(it->itemText.paragraphStyle(e).tabValues()[t1].tabFillChar))
chstr = chstr.upper();
}
chr = chstr[0].unicode();
uint gl = it->itemText.charStyle(e).font().char2CMap(chstr[0]);
gly = it->itemText.charStyle(e).font().glyphOutline(gl);
Really[it->itemText.charStyle(e).font().scName()].insert(gl, gly);
}
for (uint t1 = 0; t1 < it->TabValues.count(); t1++)
{
if (it->TabValues[t1].tabFillChar.isNull())
continue;
}
if (chr == 30)
chstr = QString(it->TabValues[t1].tabFillChar);
if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
{
/* CB Removed forced loading of 0-9 for section based numbering
for (uint numco = 0x30; numco < 0x3A; ++numco)
{
if (it->itemText.charStyle(e)->cfont->CharWidth.contains(numco))
{
gly = it->itemText.charStyle(e)->cfont->GlyphArray[numco].Outlines.copy();
it->itemText.charStyle(e)->cfont->RealGlyphs.insert(numco, gly);
}
}*/
//Our page number collection string
QString pageNumberText(QString::null);
//If not on a master page just get the page number for the page and the text
if (lc!=0)
pageNumberText=getSectionPageNumberForPageIndex(it->OwnPage);
else
{
//Else, for a page number in a text frame on a master page we must scan
//all pages to see which ones use this page and get their page numbers.
//We only add each character of the pages' page number text if its nothing
//already in the pageNumberText variable. No need to add glyphs twice.
QString newText;
uint docPageCount=DocPages.count();
for (uint a = 0; a < docPageCount; ++a)
{
if (DocPages.at(a)->MPageNam == it->OnMasterPage)
{
newText=getSectionPageNumberForPageIndex(a);
for (uint nti=0;nti<newText.length();++nti)
if (pageNumberText.find(newText[nti])==-1)
pageNumberText+=newText[nti];
}
}
}
//Now scan and add any glyphs used in page numbers
for (uint pnti=0;pnti<pageNumberText.length(); ++pnti)
{
uint chr = pageNumberText[pnti].unicode();
if (it->itemText.charStyle(e).font().canRender(chr))
{
uint gl = it->itemText.charStyle(e).font().char2CMap(pageNumberText[pnti]);
FPointArray gly(it->itemText.charStyle(e).font().glyphOutline(gl));
Really[it->itemText.charStyle(e).font().scName()].insert(gl, gly);
}
}
continue;
if (chstr.upper() != QString(it->TabValues[t1].tabFillChar))
chstr = chstr.upper();
}
if (it->itemText.charStyle(e).effects() & ScStyle_SmartHyphenVisible)
chr = chstr[0].unicode();
uint gl = it->itemText.charStyle(e).font().char2CMap(chstr[0]);
gly = it->itemText.charStyle(e).font().glyphOutline(gl);
Really[it->itemText.charStyle(e).font().scName()].insert(gl, gly);
}
continue;
}
if (chr == 30)
{
/* CB Removed forced loading of 0-9 for section based numbering
for (uint numco = 0x30; numco < 0x3A; ++numco)
{
if (it->itemText.charStyle(e)->cfont->CharWidth.contains(numco))
{
uint gl = it->itemText.charStyle(e).font().char2CMap(QChar('-'));
FPointArray gly(it->itemText.charStyle(e).font().glyphOutline(gl));
Really[it->itemText.charStyle(e).font().scName()].insert(gl, gly);
gly = it->itemText.charStyle(e)->cfont->GlyphArray[numco].Outlines.copy();
it->itemText.charStyle(e)->cfont->RealGlyphs.insert(numco, gly);
}
if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
}*/
//Our page number collection string
QString pageNumberText(QString::null);
//If not on a master page just get the page number for the page and the text
if (lc!=0)
pageNumberText=getSectionPageNumberForPageIndex(it->OwnPage);
else
{
//Else, for a page number in a text frame on a master page we must scan
//all pages to see which ones use this page and get their page numbers.
//We only add each character of the pages' page number text if its nothing
//already in the pageNumberText variable. No need to add glyphs twice.
QString newText;
uint docPageCount=DocPages.count();
for (uint a = 0; a < docPageCount; ++a)
{
chstr = it->itemText.text(e, 1);
if (chstr.upper() != it->itemText.text(e, 1))
chstr = chstr.upper();
chr = chstr[0].unicode();
if (DocPages.at(a)->MPageNam == it->OnMasterPage)
{
newText=getSectionPageNumberForPageIndex(a);
for (uint nti=0;nti<newText.length();++nti)
if (pageNumberText.find(newText[nti])==-1)
pageNumberText+=newText[nti];
}
}
}
//Now scan and add any glyphs used in page numbers
for (uint pnti=0;pnti<pageNumberText.length(); ++pnti)
{
uint chr = pageNumberText[pnti].unicode();
if (it->itemText.charStyle(e).font().canRender(chr))
{
uint gl = it->itemText.charStyle(e).font().char2CMap(chr);
gly = it->itemText.charStyle(e).font().glyphOutline(gl);
uint gl = it->itemText.charStyle(e).font().char2CMap(pageNumberText[pnti]);
FPointArray gly(it->itemText.charStyle(e).font().glyphOutline(gl));
Really[it->itemText.charStyle(e).font().scName()].insert(gl, gly);
}
}
continue;
}
if (it->itemText.charStyle(e).effects() & ScStyle_SmartHyphenVisible)
{
uint gl = it->itemText.charStyle(e).font().char2CMap(QChar('-'));
FPointArray gly(it->itemText.charStyle(e).font().glyphOutline(gl));
Really[it->itemText.charStyle(e).font().scName()].insert(gl, gly);
}
if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
{
chstr = it->itemText.text(e, 1);
if (chstr.upper() != it->itemText.text(e, 1))
chstr = chstr.upper();
chr = chstr[0].unicode();
}
if (it->itemText.charStyle(e).font().canRender(chr))
{
uint gl = it->itemText.charStyle(e).font().char2CMap(chr);
gly = it->itemText.charStyle(e).font().glyphOutline(gl);
Really[it->itemText.charStyle(e).font().scName()].insert(gl, gly);
}
}
}
}
/branches/Version13x/Scribus/scribus/pdflib.cpp
466,6 → 466,7
QFileInfo fd;
QString fext;
int a;
inPattern = 0;
Bvie = vi;
BookMinUse = false;
UsedFontsP.clear();
659,6 → 660,24
}
}
}
QStringList patterns = doc.getUsedPatterns();
for (uint c = 0; c < patterns.count(); ++c)
{
ScPattern pa = doc.docPatterns[patterns[c]];
for (uint o = 0; o < pa.items.count(); o++)
{
pgit = pa.items.at(o);
if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText))
{
if (pgit->isAnnotation())
StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], "");
for (uint e = 0; e < static_cast<uint>(pgit->itemText.length()); ++e)
{
ReallyUsed.insert(pgit->itemText.charStyle(e).font().scName(), DocFonts[pgit->itemText.charStyle(e).font().scName()]);
}
}
}
}
a = 0;
QMap<QString, QString>::Iterator itStd;
for (itStd = StdFonts.begin(); itStd != StdFonts.end(); ++itStd)
3856,7 → 3875,11
PageItem* item = pat->items.at(em);
tmp2 += "q\n";
tmp2 += "1 0 0 1 "+FToStr(item->gXpos)+" "+FToStr(-item->gYpos)+" cm\n";
item->setXYPos(item->xPos() + ActPageP->xOffset(), item->yPos() + ActPageP->yOffset(), true);
inPattern++;
tmp2 += PDF_ProcessItem(item, doc.Pages->at(0), 0, true, true);
item->setXYPos(item->xPos() - ActPageP->xOffset(), item->yPos() - ActPageP->yOffset(), true);
inPattern--;
tmp2 += "Q\n";
}
if ((Options.Compress) && (CompAvail))
3870,7 → 3893,8
PutDoc("/BBox [ 0 0 "+FToStr(pat->width)+" "+FToStr(-pat->height)+" ]\n");
QWMatrix mpa;
mpa.translate(currItem->xPos() - ActPageP->xOffset(), ActPageP->height() - (currItem->yPos() - ActPageP->yOffset()));
mpa.rotate(-currItem->rotation());
if (inPattern == 0)
mpa.rotate(-currItem->rotation());
PutDoc("/Matrix ["+FToStr(mpa.m11())+" "+FToStr(mpa.m12())+" "+FToStr(mpa.m21())+" "+FToStr(mpa.m22())+" "+FToStr(currItem->xPos() - ActPageP->xOffset())+" "+FToStr(ActPageP->height() - (currItem->yPos() - ActPageP->yOffset()))+"]\n");
PutDoc("/XStep "+FToStr(pat->width)+"\n");
PutDoc("/YStep "+FToStr(pat->height)+"\n");
/branches/Version13x/Scribus/scribus/scribusdoc.h
398,6 → 398,7
* @brief Returns a qmap of the fonts and their glyphs used within the document
*/
void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);
/*!
* @brief Builds a qmap of the colours used within the document
*/
/branches/Version13x/Scribus/scribus/pdflib.h
223,6 → 223,7
QMap<QString, SpotC> spotMap;
QString spotNam;
int spotCount;
int inPattern;
QTextStream outStream;
QMap<QString, QString> StdFonts;
MultiProgressDialog* progressDialog;
/branches/Version13x/Scribus/scribus/patterndialog.h
47,9 → 47,11
~PatternDialog() {};
void updatePatternList();
void loadVectors(QString data);
QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
ScribusDoc *m_doc;
ScribusMainWindow *mainWin;
QMap<QString, ScPattern> dialogPatterns;
QStringList origPatterns;
public slots:
void loadPattern();
void patternSelected(QIconViewItem* it);