~ubuntu-branches/ubuntu/maverick/scribus-ng/maverick-backports

« back to all changes in this revision

Viewing changes to scribus/pslib.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oleksandr Moskalenko
  • Date: 2009-10-30 20:00:37 UTC
  • mfrom: (0.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20091030200037-tes6nzts7t35gg5h
Tags: 1.3.5.dfsg+svn20091030-1
* Upstream svn update with bugfixes. Prepare the tarball for uploading into
  Debian (Closes: #534510, #552026).
* debian/control:
  - Refresh arch list.
  - Update Standards-Version to 3.8.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 ***************************************************************************/
23
23
 
24
24
#include "pslib.h"
 
25
#include <cmath>
25
26
 
26
27
#include <QFileInfo>
27
28
#include <QImage>
40
41
#include "commonstrings.h"
41
42
#include "scconfig.h"
42
43
#include "pluginapi.h"
 
44
#include "multiprogressdialog.h"
 
45
#include "pageitem_latexframe.h"
43
46
#include "prefsmanager.h"
 
47
#include "scclocale.h"
 
48
#include "sccolorengine.h"
 
49
#include "scfonts.h"
 
50
#include "scribusapp.h"
44
51
#include "scribusdoc.h"
45
52
#include "scribus.h"
46
53
#include "scribuscore.h"
47
 
#include "scfonts.h"
48
54
#include "selection.h"
49
 
#include <cmath>
 
55
#include "scpattern.h"
 
56
#include "scstreamfilter_ascii85.h"
 
57
#include "scstreamfilter_flate.h"
50
58
#include "util.h"
 
59
#include "util_cms.h"
51
60
#include "util_formats.h"
52
61
#include "util_math.h"
53
 
#include "multiprogressdialog.h"
54
 
#include "pageitem_latexframe.h"
55
 
#include "scribusapp.h"
56
 
#include "scpattern.h"
57
 
#include "sccolorengine.h"
58
 
#include "scstreamfilter_ascii85.h"
59
 
#include "scstreamfilter_flate.h"
60
62
 
61
63
#include "text/nlsconfig.h"
62
64
 
95
97
        CMYKColor cmykValues;
96
98
        ColorList::Iterator itf;
97
99
        int c, m, y, k;
 
100
        int spotCount = 1;
98
101
        bool erst = true;
99
102
        colorsToUse = DocColors;
100
103
        spotMap.clear();
101
104
        colorDesc = "";
102
105
        for (itf = DocColors.begin(); itf != DocColors.end(); ++itf)
103
106
        {
104
 
                if (((DocColors[itf.key()].isSpotColor()) || (DocColors[itf.key()].isRegistrationColor())) && (useSpotColors))
 
107
                if (((itf->isSpotColor()) || (itf->isRegistrationColor())) && (useSpotColors))
105
108
                {
106
 
                        ScColorEngine::getCMYKValues(DocColors[itf.key()], DocColors.document(), cmykValues);
 
109
                        ScColorEngine::getCMYKValues(*itf, DocColors.document(), cmykValues);
107
110
                        cmykValues.getValues(c, m, y, k);
108
 
                        colorDesc += "/Spot"+PSEncode(itf.key())+" { [ /Separation (";
 
111
                        colorDesc += "/Spot"+QString::number(spotCount)+" { [ /Separation (";
109
112
                        if (DocColors[itf.key()].isRegistrationColor())
110
113
                                colorDesc += "All";
111
114
                        else
115
118
                        colorDesc += ToStr(static_cast<double>(m) / 255)+"\nmul exch dup ";
116
119
                        colorDesc += ToStr(static_cast<double>(y) / 255)+"\nmul exch ";
117
120
                        colorDesc += ToStr(static_cast<double>(k) / 255)+" mul }] setcolorspace setcolor} bind def\n";
118
 
                        spotMap.insert(itf.key(), "Spot"+PSEncode(itf.key()));
 
121
                        spotMap.insert(itf.key(), "Spot"+QString::number(spotCount));
 
122
                        ++spotCount;
119
123
                }
120
124
                if ((itf.key() != "Cyan") && (itf.key() != "Magenta") && (itf.key() != "Yellow") && (itf.key() != "Black") && DocColors[itf.key()].isSpotColor())
121
125
                {
132
136
                        erst = false;
133
137
                }
134
138
        }
 
139
        QMap<QString, QString> psNameMap;
135
140
        QMap<QString, QMap<uint, FPointArray> >::Iterator it;
136
141
        int a = 0;
137
142
        for (it = DocFonts.begin(); it != DocFonts.end(); ++it)
138
143
        {
139
 
/* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
140
 
                ScFace::FontType type = AllFonts[it.key()].type();
 
144
                // Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed
 
145
                // Subset also font whose postscript name conflicts with an already used font
 
146
                ScFace &face (AllFonts[it.key()]);
 
147
                ScFace::FontType type = face.type();
 
148
                QString encodedName = face.psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" );
141
149
 
142
 
                if ((type == ScFace::TTF) || (AllFonts[it.key()].isOTF()) || (AllFonts[it.key()].subset()))
 
150
                if ((type == ScFace::TTF) || (face.isOTF()) || (face.subset()) || psNameMap.contains(encodedName))
143
151
                {
144
152
                        QMap<uint, FPointArray>& RealGlyphs(it.value());
145
 
                        FontDesc += "/"+AllFonts[it.key()].psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+
146
 
                                        " "+IToStr(RealGlyphs.count()+1)+" dict def\n";
147
 
                        FontDesc += AllFonts[it.key()].psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+" begin\n";
 
153
                        // Handle possible PostScript name conflict in oft/ttf fonts
 
154
                        int psNameIndex = 1;
 
155
                        QString initialName = encodedName;
 
156
                        while (psNameMap.contains(encodedName))
 
157
                        {
 
158
                                encodedName = QString("%1-%2").arg(initialName).arg(psNameIndex);
 
159
                                ++psNameIndex;
 
160
                        }
 
161
                        FontDesc += "/" + encodedName + " " + IToStr(RealGlyphs.count()+1) + " dict def\n";
 
162
                        FontDesc += encodedName + " begin\n";
148
163
                        QMap<uint,FPointArray>::Iterator ig;
149
164
                        for (ig = RealGlyphs.begin(); ig != RealGlyphs.end(); ++ig)
150
165
                        {
178
193
                                FontDesc += "cl\n} bind def\n";
179
194
                        }
180
195
                        FontDesc += "end\n";
 
196
                        FontSubsetMap.insert(face.scName(), encodedName);
181
197
                }
182
198
                else
183
199
                {
184
200
                        UsedFonts.insert(it.key(), "/Fo"+IToStr(a));
185
 
                        Fonts += "/Fo"+IToStr(a)+" /"+AllFonts[it.key()].psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+" findfont definefont pop\n";
 
201
                        Fonts += "/Fo" + IToStr(a) + " /" + encodedName + " findfont definefont pop\n";
186
202
                        if (AllFonts[it.key()].embedPs())
187
203
                        {
188
204
                                QString tmp;
189
 
                                if(AllFonts[it.key()].EmbedFont(tmp))
 
205
                                if(face.EmbedFont(tmp))
190
206
                                {
191
 
                                        FontDesc += "%%BeginFont: " + AllFonts[it.key()].psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + "\n";
 
207
                                        FontDesc += "%%BeginFont: " + encodedName + "\n";
192
208
                                        FontDesc += tmp + "\n%%EndFont\n";
193
209
                                }
194
210
                        }
195
 
                        GListe gl;
196
 
                        AllFonts[it.key()].glyphNames(gl);
 
211
                        GlyphList gl;
 
212
                        face.glyphNames(gl);
197
213
                        GlyphsOfFont.insert(it.key(), gl);
198
214
                        a++;
199
215
                }
 
216
                psNameMap.insert(encodedName, face.scName());
200
217
        }
201
218
        Prolog = "%%BeginProlog\n";
202
219
        Prolog += "/Scribusdict 100 dict def\n";
251
268
 
252
269
void PSLib::PutStream(const QString& c)
253
270
{
254
 
        spoolStream.writeRawData(c.toUtf8().data(), c.length());
 
271
        QByteArray utf8Array = c.toUtf8();
 
272
        spoolStream.writeRawData(utf8Array.data(), utf8Array.length());
255
273
}
256
274
 
257
275
void PSLib::PutStream(const QByteArray& array, bool hexEnc)
436
454
        PutStream(Fonts);
437
455
        if (GraySc)
438
456
                PutStream(GrayCalc);
 
457
        Optimization optim = optimization;
 
458
        optimization = OptimizeSize;
439
459
        QStringList patterns = m_Doc->getUsedPatterns();
440
460
        for (int c = 0; c < patterns.count(); ++c)
441
461
        {
449
469
                                        return false;
450
470
                        }
451
471
                }
452
 
                PutStream("/Pattern"+patterns[c]+" 8 dict def\n");
453
 
                PutStream("Pattern"+patterns[c]+" begin\n");
 
472
                uint patHash = qHash(patterns[c]);
 
473
                PutStream("/Pattern"+QString::number(patHash)+" 8 dict def\n");
 
474
                PutStream("Pattern"+QString::number(patHash)+" begin\n");
454
475
                PutStream("/PatternType 1 def\n");
455
476
                PutStream("/PaintType 1 def\n");
456
477
                PutStream("/TilingType 1 def\n");
551
572
                PutStream("} def\n");
552
573
                PutStream("end\n");
553
574
        }
 
575
        optimization = optim;
554
576
//      PutStream("end\n");
555
577
//      PutStream("%%EndSetup\n");
556
578
        Prolog = "";
588
610
        double markOffs = 0.0;
589
611
        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
590
612
                markOffs = 20.0 + Options.markOffset;
591
 
        if (m_Doc->pageSets[m_Doc->currentPageLayout].Columns == 1)
592
 
        {
593
 
                bleedRight = Options.bleeds.Right;
594
 
                bleedLeft = Options.bleeds.Left;
595
 
        }
596
 
        else
597
 
        {
598
 
                if (m_Doc->locationOfPage(pg->pageNr()) == LeftPage)
599
 
                {
600
 
                        bleedRight = Options.bleeds.Right;
601
 
                        bleedLeft = Options.bleeds.Left;
602
 
                }
603
 
                else if (m_Doc->locationOfPage(pg->pageNr()) == RightPage)
604
 
                {
605
 
                        bleedRight = Options.bleeds.Left;
606
 
                        bleedLeft = Options.bleeds.Right;
607
 
                }
608
 
                else
609
 
                {
610
 
                        bleedRight = Options.bleeds.Left;
611
 
                        bleedLeft = Options.bleeds.Left;
612
 
                }
613
 
        }
 
613
        GetBleeds(pg, bleedLeft, bleedRight);
614
614
        double maxBoxX = pg->width()+bleedLeft+bleedRight+markOffs*2.0;
615
615
        double maxBoxY = pg->height()+Options.bleeds.Bottom+Options.bleeds.Top+markOffs*2.0;
616
616
        Seiten++;
634
634
        PutStream("%%PageBoundingBox: 0 0 "+IToStr(qRound(maxBoxX))+" "+IToStr(qRound(maxBoxY))+"\n");
635
635
        PutStream("%%PageCropBox: "+ToStr(bleedLeft+markOffs)+" "+ToStr(Options.bleeds.Bottom+markOffs)+" "+ToStr(maxBoxX-bleedRight-markOffs*2.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs*2.0)+"\n");
636
636
        PutStream("Scribusdict begin\n");
637
 
        PutStream("save\n");
638
 
        PutStream("/DeviceCMYK setcolorspace\n");
639
637
        if ((Art) && (Options.setDevParam))
640
638
        {
641
639
                PutStream("<< /PageSize [ "+ToStr(maxBoxX)+" "+ToStr(maxBoxY)+" ]\n");
642
640
                PutStream(">> setpagedevice\n");
643
641
        }
 
642
        PutStream("save\n");
 
643
        PutStream("/DeviceCMYK setcolorspace\n");
644
644
        PutStream(ToStr(bleedLeft+markOffs)+" "+ToStr(Options.bleeds.Bottom+markOffs)+" tr\n");
645
645
        ActPage = pg;
646
646
        if (Clipping)
659
659
        double markOffs = 0.0;
660
660
        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
661
661
                markOffs = 20.0 + Options.markOffset;
662
 
        double bleedRight;
663
 
        double bleedLeft;
664
 
        if (m_Doc->pageSets[m_Doc->currentPageLayout].Columns == 1)
665
 
        {
666
 
                bleedRight = Options.bleeds.Right;
667
 
                bleedLeft = Options.bleeds.Left;
668
 
        }
669
 
        else
670
 
        {
671
 
                if (m_Doc->locationOfPage(ActPage->pageNr()) == LeftPage)
672
 
                {
673
 
                        bleedRight = Options.bleeds.Right;
674
 
                        bleedLeft = Options.bleeds.Left;
675
 
                }
676
 
                else if (m_Doc->locationOfPage(ActPage->pageNr()) == RightPage)
677
 
                {
678
 
                        bleedRight = Options.bleeds.Left;
679
 
                        bleedLeft = Options.bleeds.Right;
680
 
                }
681
 
                else
682
 
                {
683
 
                        bleedRight = Options.bleeds.Left;
684
 
                        bleedLeft = Options.bleeds.Left;
685
 
                }
686
 
        }
 
662
        double bleedRight, bleedLeft;
 
663
        GetBleeds(ActPage, bleedLeft, bleedRight);
687
664
        double maxBoxX = ActPage->width()+bleedLeft+bleedRight+markOffs*2.0;
688
665
        double maxBoxY = ActPage->height()+Options.bleeds.Bottom+Options.bleeds.Top+markOffs*2.0;
689
666
        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
1154
1131
                        int pla = Plate - 1 < 0 ? 3 : Plate - 1;
1155
1132
                        QStringList cols1 = Colors[c+1].split(" ", QString::SkipEmptyParts);
1156
1133
                        QStringList cols2 = Colors[c].split(" ", QString::SkipEmptyParts);
1157
 
                        PutStream("/C1 ["+ToStr(1-cols1[pla].toDouble())+"]\n");
1158
 
                        PutStream("/C0 ["+ToStr(1-cols2[pla].toDouble())+"]\n");
 
1134
                        PutStream("/C1 ["+ToStr(1 - ScCLocale::toDoubleC(cols1[pla]))+"]\n");
 
1135
                        PutStream("/C0 ["+ToStr(1 - ScCLocale::toDoubleC(cols2[pla]))+"]\n");
1159
1136
                }
1160
1137
                else
1161
1138
                {
1336
1313
                        int pla = Plate - 1 < 0 ? 3 : Plate - 1;
1337
1314
                        QStringList cols1 = Colors[c].split(" ", QString::SkipEmptyParts);
1338
1315
                        QStringList cols2 = Colors[c+1].split(" ", QString::SkipEmptyParts);
1339
 
                        PutStream("/C1 ["+ToStr(1-cols1[pla].toDouble())+"]\n");
1340
 
                        PutStream("/C0 ["+ToStr(1-cols2[pla].toDouble())+"]\n");
 
1316
                        PutStream("/C1 ["+ToStr(1 - ScCLocale::toDoubleC(cols1[pla]))+"]\n");
 
1317
                        PutStream("/C0 ["+ToStr(1 - ScCLocale::toDoubleC(cols2[pla]))+"]\n");
1341
1318
                }
1342
1319
                else
1343
1320
                {
1820
1797
                PS_setGray();
1821
1798
        applyICC = Ic;
1822
1799
        if ((Doc->HasCMS) && (ScCore->haveCMS()) && (applyICC))
1823
 
                solidTransform = cmsCreateTransform(Doc->DocInputCMYKProf, TYPE_CMYK_16, Doc->DocPrinterProf, TYPE_CMYK_16, Doc->IntentColors, 0);
 
1800
                solidTransform = scCmsCreateTransform(Doc->DocInputCMYKProf, TYPE_CMYK_16, Doc->DocPrinterProf, TYPE_CMYK_16, Doc->IntentColors, 0);
1824
1801
        else
1825
1802
                applyICC = false;
1826
1803
        if (usingGUI)
1934
1911
                                                        ScQApp->processEvents();
1935
1912
                                                if ((it->LayerNr != ll.LNr) || (!it->printEnabled()))
1936
1913
                                                        continue;
1937
 
/*                                              int x = static_cast<int>(Doc->MasterPages.at(ap)->xOffset());
1938
 
                                                int y = static_cast<int>(Doc->MasterPages.at(ap)->yOffset());
1939
 
                                                int w = static_cast<int>(Doc->MasterPages.at(ap)->width());
1940
 
                                                int h = static_cast<int>(Doc->MasterPages.at(ap)->height());
1941
 
                                                double ilw=it->lineWidth();
1942
 
                                                int x2 = static_cast<int>(it->BoundingX - ilw / 2.0);
1943
 
                                                int y2 = static_cast<int>(it->BoundingY - ilw / 2.0);
1944
 
                                                int w2 = static_cast<int>(it->BoundingW + ilw);
1945
 
                                                int h2 = static_cast<int>(it->BoundingH + ilw);
1946
 
                                                if (!QRect(x, y, w, h).intersects(QRect(x2, y2, w2, h2)))
1947
 
                                                        continue; */
1948
 
                                                double x = Doc->MasterPages.at(ap)->xOffset();
1949
 
                                                double y = Doc->MasterPages.at(ap)->yOffset();
1950
 
                                                double w = Doc->MasterPages.at(ap)->width();
1951
 
                                                double h1 = Doc->MasterPages.at(ap)->height();
 
1914
                                                double bLeft, bRight, bBottom, bTop;
 
1915
                                                GetBleeds(Doc->MasterPages.at(ap), bLeft, bRight, bBottom, bTop);
 
1916
                                                double x  = Doc->MasterPages.at(ap)->xOffset() - bLeft;
 
1917
                                                double y  = Doc->MasterPages.at(ap)->yOffset() - bTop;
 
1918
                                                double w  = Doc->MasterPages.at(ap)->width() + bLeft + bRight;
 
1919
                                                double h1 = Doc->MasterPages.at(ap)->height()+ bBottom + bTop;
1952
1920
                                                double ilw = it->lineWidth();
1953
1921
                                                double x2 = it->BoundingX - ilw / 2.0;
1954
1922
                                                double y2 = it->BoundingY - ilw / 2.0;
1963
1931
                                                        errorOccured = !PS_ImageData(it, it->Pfile, it->itemName(), it->IProfile, it->UseEmbedded, Ic);
1964
1932
                                                        if (errorOccured) break;
1965
1933
                                                }
1966
 
                                                PS_TemplateStart(Doc->MasterPages.at(ap)->pageName() + tmps.setNum(it->ItemNr));
 
1934
                                                PS_TemplateStart(QString("mp_obj_%1_%2").arg(ap).arg(it->ItemNr));
1967
1935
                                                ProcessItem(Doc, Doc->MasterPages.at(ap), it, ap+1, sep, farb, Ic, gcr, true);
1968
1936
                                                PS_TemplateEnd();
1969
1937
                                        }
2062
2030
                                                                continue;
2063
2031
                                                        }
2064
2032
                                                        if (!(ite->asTextFrame()) && !(ite->asImageFrame()))
2065
 
                                                                PS_UseTemplate(Doc->Pages->at(a)->MPageNam + tmps.setNum(ite->ItemNr));
 
2033
                                                        {
 
2034
                                                                int mpIndex = Doc->MasterNames[Doc->Pages->at(a)->MPageNam];
 
2035
                                                                PS_UseTemplate(QString("mp_obj_%1_%2").arg(mpIndex).arg(ite->ItemNr));
 
2036
                                                        }
2066
2037
                                                        else if (ite->asImageFrame())
2067
2038
                                                        {
2068
2039
                                                                PS_save();
2477
2448
                        if (c->startArrowIndex() != 0)
2478
2449
                        {
2479
2450
                                QMatrix arrowTrans;
2480
 
                                FPointArray arrow = Doc->arrowStyles.at(c->startArrowIndex()-1).points.copy();
2481
 
                                arrowTrans.translate(0, 0);
2482
 
                                if (c->lineWidth() != 0.0)
2483
 
                                        arrowTrans.scale(c->lineWidth(), c->lineWidth());
2484
2451
                                arrowTrans.scale(-1,1);
2485
 
                                arrow.map(arrowTrans);
2486
 
                                SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
2487
 
                                PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2488
 
                                PS_newpath();
2489
 
                                SetClipPath(&arrow);
2490
 
                                PS_closepath();
2491
 
                                putColor(c->lineColor(), c->lineShade(), true);
 
2452
                                drawArrow(c, arrowTrans, c->startArrowIndex(), gcr);
2492
2453
                        }
2493
2454
                        if (c->endArrowIndex() != 0)
2494
2455
                        {
2495
2456
                                QMatrix arrowTrans;
2496
 
                                FPointArray arrow = Doc->arrowStyles.at(c->endArrowIndex()-1).points.copy();
2497
2457
                                arrowTrans.translate(c->width(), 0);
2498
 
                                if (c->lineWidth() != 0.0)
2499
 
                                        arrowTrans.scale(c->lineWidth(), c->lineWidth());
2500
 
                                arrow.map(arrowTrans);
2501
 
                                SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
2502
 
                                PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2503
 
                                PS_newpath();
2504
 
                                SetClipPath(&arrow);
2505
 
                                PS_closepath();
2506
 
                                putColor(c->lineColor(), c->lineShade(), true);
 
2458
                                drawArrow(c, arrowTrans, c->endArrowIndex(), gcr);
2507
2459
                        }
2508
2460
                        break;
2509
2461
                /* OBSOLETE CR 2005-02-06
2603
2555
                                        {
2604
2556
                                                double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
2605
2557
                                                QMatrix arrowTrans;
2606
 
                                                FPointArray arrow = Doc->arrowStyles.at(c->startArrowIndex()-1).points.copy();
2607
2558
                                                arrowTrans.translate(Start.x(), Start.y());
2608
2559
                                                arrowTrans.rotate(r);
2609
 
                                                if (c->lineWidth() != 0.0)
2610
 
                                                        arrowTrans.scale(c->lineWidth(), c->lineWidth());
2611
 
                                                arrow.map(arrowTrans);
2612
 
                                                SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
2613
 
                                                PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2614
 
                                                PS_newpath();
2615
 
                                                SetClipPath(&arrow);
2616
 
                                                PS_closepath();
2617
 
                                                putColor(c->lineColor(), c->lineShade(), true);
 
2560
                                                drawArrow(c, arrowTrans, c->startArrowIndex(), gcr);
2618
2561
                                                break;
2619
2562
                                        }
2620
2563
                                }
2629
2572
                                        {
2630
2573
                                                double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
2631
2574
                                                QMatrix arrowTrans;
2632
 
                                                FPointArray arrow = Doc->arrowStyles.at(c->endArrowIndex()-1).points.copy();
2633
2575
                                                arrowTrans.translate(End.x(), End.y());
2634
2576
                                                arrowTrans.rotate(r);
2635
 
                                                if (c->lineWidth() != 0.0)
2636
 
                                                        arrowTrans.scale(c->lineWidth(), c->lineWidth());
2637
 
                                                arrow.map(arrowTrans);
2638
 
                                                SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
2639
 
                                                PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2640
 
                                                PS_newpath();
2641
 
                                                SetClipPath(&arrow);
2642
 
                                                PS_closepath();
2643
 
                                                putColor(c->lineColor(), c->lineShade(), true);
 
2577
                                                drawArrow(c, arrowTrans, c->endArrowIndex(), gcr);
2644
2578
                                                break;
2645
2579
                                        }
2646
2580
                                }
2799
2733
                                        continue;
2800
2734
                                }
2801
2735
                                /* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
2802
 
                                ScFace::FontType type = style.font().type();
2803
 
                                if ((type == ScFace::TTF) ||  (style.font().isOTF()) || (style.font().subset()))
 
2736
                                if (FontSubsetMap.contains(style.font().scName()))
2804
2737
                                {
2805
2738
//                                      uint chr = chstr.unicode();
2806
2739
                                        uint chr = style.font().char2CMap(chstr);
2901
2834
                                                                                PutStream(ToStr(style.strokeShade() / 100.0)+" "+spotMap[style.strokeColor()]);
2902
2835
                                                                        else
2903
2836
                                                                                PutStream(FillColor + " cmyk");
2904
 
                                                                        PS_showSub(chr, style.font().psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ), tsz / 10.0, false);
 
2837
                                                                        PS_showSub(chr, FontSubsetMap[style.font().scName()], tsz / 10.0, false);
2905
2838
                                                                        PS_restore();
2906
2839
                                                                }
2907
2840
                                                                SetColor(style.fillColor(), style.fillShade(), &h, &s, &v, &k, gcr);
2910
2843
                                                                        PutStream(ToStr(style.fillShade() / 100.0)+" "+spotMap[style.fillColor()]);
2911
2844
                                                                else
2912
2845
                                                                        PutStream(FillColor + " cmyk");
2913
 
                                                                PS_showSub(chr, style.font().psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ), tsz / 10.0, false);
 
2846
                                                                PS_showSub(chr, FontSubsetMap[style.font().scName()], tsz / 10.0, false);
2914
2847
                                                                if ((style.effects() & ScStyle_Outline))
2915
2848
                                                                {
2916
2849
                                                                        if ((style.strokeColor() != CommonStrings::None) && ((tsz * style.outlineWidth() / 10000.0) != 0))
2923
2856
                                                                                        PutStream(ToStr(style.strokeShade() / 100.0)+" "+spotMap[style.strokeColor()]);
2924
2857
                                                                                else
2925
2858
                                                                                        PutStream(StrokeColor + " cmyk");
2926
 
                                                                                PS_showSub(chr, style.font().psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ), tsz / 10.0, true);
 
2859
                                                                                PS_showSub(chr, FontSubsetMap[style.font().scName()], tsz / 10.0, true);
2927
2860
                                                                                PS_restore();
2928
2861
                                                                        }
2929
2862
                                                                }
3184
3117
                                //if ((!Art) && (view->SelItem.count() != 0) && (!c->Select))
3185
3118
                                if ((!Art) && (!c->isSelected()) && (Doc->m_Selection->count() != 0))
3186
3119
                                        continue;
3187
 
                                double x = a->xOffset();
3188
 
                                double y = a->yOffset();
3189
 
                                double w = a->width();
3190
 
                                double h1 = a->height();
 
3120
                                double bLeft, bRight, bBottom, bTop;
 
3121
                                GetBleeds(a, bLeft, bRight, bBottom, bTop);
 
3122
                                double x  = a->xOffset() - bLeft;
 
3123
                                double y  = a->yOffset() - bTop;
 
3124
                                double w  = a->width() + bLeft + bRight;
 
3125
                                double h1 = a->height() + bBottom + bTop;
3191
3126
                                double ilw = c->lineWidth();
3192
3127
                                double x2 = c->BoundingX - ilw / 2.0;
3193
3128
                                double y2 = c->BoundingY - ilw / 2.0;
3237
3172
                                continue;
3238
3173
                        if ((!a->pageName().isEmpty()) && (c->asImageFrame()) && ((sep) || (!farb)))
3239
3174
                                continue;
3240
 
                        double x = a->xOffset();
3241
 
                        double y = a->yOffset();
3242
 
                        double w = a->width();
3243
 
                        double h1 = a->height();
 
3175
                        double bLeft, bRight, bBottom, bTop;
 
3176
                        GetBleeds(a, bLeft, bRight, bBottom, bTop);
 
3177
                        double x = a->xOffset() - bLeft;
 
3178
                        double y = a->yOffset() - bTop;
 
3179
                        double w = a->width() + bLeft + bRight;
 
3180
                        double h1 = a->height() + bBottom + bTop;
3244
3181
                        double ilw=c->lineWidth();
3245
3182
                        double x2 = c->BoundingX - ilw / 2.0;
3246
3183
                        double y2 = c->BoundingY - ilw / 2.0;
3371
3308
                        break;
3372
3309
                case 8:
3373
3310
                        pat = &m_Doc->docPatterns[c->pattern()];
 
3311
                        uint patHash = qHash(c->pattern());
3374
3312
                        c->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
3375
3313
                        patternMatrix.translate(patternOffsetX, -patternOffsetY);
3376
3314
                        patternMatrix.rotate(-patternRotation);
3377
3315
                        patternMatrix.scale(pat->scaleX, pat->scaleY);
3378
3316
                        patternMatrix.scale(patternScaleX / 100.0 , patternScaleY / 100.0);
3379
 
                        PutStream("Pattern"+c->pattern()+" ["+ToStr(patternMatrix.m11())+" "+ToStr(patternMatrix.m12())+" "+ToStr(patternMatrix.m21())+" "+ToStr(patternMatrix.m22())+" "+ToStr(patternMatrix.dx())+" "+ToStr(patternMatrix.dy())+"] makepattern setpattern\n");
 
3317
                        PutStream("Pattern"+QString::number(patHash)+" ["+ToStr(patternMatrix.m11())+" "+ToStr(patternMatrix.m12())+" "+ToStr(patternMatrix.m21())+" "+ToStr(patternMatrix.m22())+" "+ToStr(patternMatrix.dx())+" "+ToStr(patternMatrix.dy())+"] makepattern setpattern\n");
3380
3318
                        if (fillRule)
3381
3319
                                PutStream("eofill\n");
3382
3320
                        else
3445
3383
        }
3446
3384
}
3447
3385
 
 
3386
void PSLib::drawArrow(PageItem *ite, QMatrix &arrowTrans, int arrowIndex, bool gcr)
 
3387
{
 
3388
        int h, s, v, k;
 
3389
        QVector<double> dum;
 
3390
        FPointArray arrow = m_Doc->arrowStyles.at(arrowIndex-1).points.copy();
 
3391
        if (ite->NamedLStyle.isEmpty())
 
3392
        {
 
3393
                if (ite->lineWidth() != 0.0)
 
3394
                        arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
 
3395
        }
 
3396
        else
 
3397
        {
 
3398
                multiLine ml = m_Doc->MLineStyles[ite->NamedLStyle];
 
3399
                if (ml[ml.size()-1].Width != 0.0)
 
3400
                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
 
3401
        }
 
3402
        arrow.map(arrowTrans);
 
3403
        if (ite->NamedLStyle.isEmpty())
 
3404
        {
 
3405
                if (ite->lineColor() != CommonStrings::None)
 
3406
                {
 
3407
                        SetColor(ite->lineColor(), ite->lineShade(), &h, &s, &v, &k, gcr);
 
3408
                        PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
 
3409
                        PS_newpath();
 
3410
                        SetClipPath(&arrow);
 
3411
                        PS_closepath();
 
3412
                        putColor(ite->lineColor(), ite->lineShade(), true);
 
3413
                }
 
3414
        }
 
3415
        else
 
3416
        {
 
3417
                multiLine ml = m_Doc->MLineStyles[ite->NamedLStyle];
 
3418
                if (ml[0].Color != CommonStrings::None)
 
3419
                {
 
3420
                        SetColor(ml[0].Color, ml[0].Shade, &h, &s, &v, &k, gcr);
 
3421
                        PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
 
3422
                        PS_newpath();
 
3423
                        SetClipPath(&arrow);
 
3424
                        PS_closepath();
 
3425
                        putColor(ite->lineColor(), ite->lineShade(), true);
 
3426
                }
 
3427
                for (int it = ml.size()-1; it > 0; it--)
 
3428
                {
 
3429
                        if (ml[it].Color != CommonStrings::None)
 
3430
                        {
 
3431
                                SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
 
3432
                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
 
3433
                                PS_setlinewidth(ml[it].Width);
 
3434
                                PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
 
3435
                                PS_setdash(Qt::SolidLine, 0, dum);
 
3436
                                SetClipPath(&arrow);
 
3437
                                PS_closepath();
 
3438
                                putColor(ml[it].Color, ml[it].Shade, false);
 
3439
                        }
 
3440
                }
 
3441
        }
 
3442
}
 
3443
 
3448
3444
void PSLib::SetColor(const QString& farb, double shade, int *h, int *s, int *v, int *k, bool gcr)
3449
3445
{
3450
3446
        ScColor& col = m_Doc->PageColors[farb];
3509
3505
 
3510
3506
        for (uint ll=0; ll < ite->itemText.lines(); ++ll) {
3511
3507
                LineSpec ls = ite->itemText.line(ll);
3512
 
                colLeft = tabDist = ls.x;
 
3508
                colLeft = ls.colLeft;
 
3509
                tabDist = ls.x;
3513
3510
                double CurX = ls.x;
3514
3511
 
3515
3512
                for (int d = ls.firstItem; d <= ls.lastItem; ++d)
3528
3525
                        if ((hl->ch == SpecialChars::TAB) && (tTabValues.count() != 0))
3529
3526
                        {
3530
3527
                                QChar tabFillChar;
3531
 
                                double tCurX = CurX - colLeft + 1;
3532
 
                                for (int yg = static_cast<int>(tTabValues.count()-1); yg > -1; yg--)
3533
 
                                {
3534
 
                                        if (tCurX < tTabValues[yg].tabPosition)
3535
 
                                                tabFillChar = tTabValues[yg].tabFillChar;
3536
 
                                }
 
3528
                                const TabLayout* tabLayout = dynamic_cast<const TabLayout*>(hl->glyph.more);
 
3529
                                if (tabLayout)
 
3530
                                        tabFillChar = tabLayout->fillChar;
3537
3531
                                if (!tabFillChar.isNull())
3538
3532
                                {
3539
3533
                                        ScText hl2;
3761
3755
                                        PutStream(ToStr(hl->fillShade() / 100.0)+" "+spotMap[hl->fillColor()]);
3762
3756
                                else
3763
3757
                                        PutStream(FillColor + " cmyk");
3764
 
                                                PS_showSub(chr, hl->font().psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ), tsz / 10.0, false);
 
3758
                                                PS_showSub(chr, FontSubsetMap[hl->font().scName()], tsz / 10.0, false);
3765
3759
                        }
3766
3760
                        PS_restore();
3767
3761
                }
4155
4149
                        putColor(cstyle.fillColor(), cstyle.fillShade(), false);
4156
4150
                }
4157
4151
                /* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
4158
 
                ScFace::FontType ftype = cstyle.font().type();
4159
 
                if ((ftype == ScFace::TTF) || (cstyle.font().isOTF()) || (cstyle.font().subset()))
 
4152
                if (FontSubsetMap.contains(cstyle.font().scName()))
4160
4153
                {
4161
4154
                        if (glyph != 0 && glyph != cstyle.font().char2CMap(QChar(' ')) && (!SpecialChars::isBreak(chstr)))
4162
4155
                        {
4186
4179
                                                PutStream(ToStr(cstyle.fillShade() / 100.0)+" "+spotMap[cstyle.fillColor()]);
4187
4180
                                        else
4188
4181
                                                PutStream(FillColor + " cmyk");
4189
 
                                        PS_showSub(glyph, cstyle.font().psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ), tsz / 10.0, false);
 
4182
                                        PS_showSub(glyph, FontSubsetMap[cstyle.font().scName()], tsz / 10.0, false);
4190
4183
                                }
4191
4184
                                PS_restore();
4192
4185
                        }
4388
4381
        }
4389
4382
}
4390
4383
 
 
4384
void PSLib::GetBleeds(Page* page, double& left, double& right)
 
4385
{
 
4386
        MarginStruct values;
 
4387
        m_Doc->getBleeds(page, Options.bleeds, values);
 
4388
        left   = values.Left;
 
4389
        right  = values.Right;
 
4390
}
 
4391
 
 
4392
void PSLib::GetBleeds(Page* page, double& left, double& right, double& bottom, double& top)
 
4393
{
 
4394
        MarginStruct values;
 
4395
        m_Doc->getBleeds(page, Options.bleeds, values);
 
4396
        left   = values.Left;
 
4397
        right  = values.Right;
 
4398
        bottom = values.Bottom;
 
4399
        top    = values.Top;
 
4400
}
 
4401
 
4391
4402
void PSLib::SetClipPath(FPointArray *c, bool poly)
4392
4403
{
4393
4404
        FPoint np, np1, np2, np3;