00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "preview.h"
00024
00025 #include <QImage>
00026 #include <QApplication>
00027 #include <QDesktopWidget>
00028 #include <QHBoxLayout>
00029 #include <QVBoxLayout>
00030 #include <QSpacerItem>
00031 #include <QGroupBox>
00032 #include <QHeaderView>
00033 #include <QTableWidget>
00034 #include <QTableWidgetItem>
00035 #include <QLabel>
00036 #include <QScrollArea>
00037 #include <QPushButton>
00038 #include <QComboBox>
00039 #include <QPixmap>
00040 #include <QCursor>
00041 #include <QPainter>
00042 #include <QColor>
00043 #include <QToolTip>
00044 #include <QFile>
00045 #include <QTextStream>
00046
00047 #include <cstdlib>
00048 #include "pslib.h"
00049 #include "checkDocument.h"
00050 #include "cmsettings.h"
00051 #include "prefsfile.h"
00052 #include "prefscontext.h"
00053 #include "prefsmanager.h"
00054 #include "prefstable.h"
00055 #include "util.h"
00056 #include "util_icon.h"
00057 #include "sccolor.h"
00058 #include "scribusview.h"
00059 #include "scribusdoc.h"
00060 #include "scpaths.h"
00061 #include "pageselector.h"
00062 #include "util_printer.h"
00063 #include "util_ghostscript.h"
00064 #include "sccolorengine.h"
00065 #include "scribuscore.h"
00066
00067 #if defined(_WIN32)
00068 #include "scprintengine_gdi.h"
00069 #endif
00070
00071 extern bool printDinUse;
00072
00073 PPreview::PPreview( QWidget* parent, ScribusView *vin, ScribusDoc *docu, QString printer, PrintEngine engine ) : QDialog( parent )
00074 {
00075 setModal(true);
00076 setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));
00077 Q_ASSERT(!docu->masterPageMode());
00078 prefsManager=PrefsManager::instance();
00079 QString tmp;
00080 postscriptPreview = usePostscriptPreview(printer, engine);
00081 QString caption = tr("Print Preview");
00082 #ifdef _WIN32
00083 if (postscriptPreview)
00084 caption += " (Postscript)";
00085 else
00086 caption += " (GDI)";
00087 #endif
00088 setWindowTitle( caption );
00089 doc = docu;
00090 view = vin;
00091 HavePngAlpha = ScCore->havePNGAlpha();
00092 HaveTiffSep = postscriptPreview ? ScCore->haveTIFFSep() : false;
00093 APage = -1;
00094 CMode = false;
00095 GsAl = false;
00096 Trans = false;
00097 GMode = true;
00098 OMode = false;
00099 mHor = false;
00100 mVer = false;
00101 fClip = false;
00102 fSpot = true;
00103 fGray = false;
00104 fICC = false;
00105 scaleFactor = 1.0;
00106 SMode = 1;
00107 getNumericGSVersion(GsMajor, GsMinor);
00108 PLayout = new QVBoxLayout(this);
00109 PLayout->setMargin(0);
00110 PLayout->setSpacing(0);
00111 int tbWidth = 0;
00112 Layout5 = new QHBoxLayout;
00113 Layout5->setSpacing(3);
00114 Layout5->setMargin(0);
00115 Anzeige = new QScrollArea(this);
00116 Anzeige->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00117 Layout5->addWidget(Anzeige);
00118 settingsBarLayout = new QVBoxLayout;
00119 settingsBarLayout->setSpacing(3);
00120 settingsBarLayout->setMargin(0);
00121 devTitle = new QGroupBox( this );
00122 devTitle->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
00123 devTitle->setTitle( tr( "Display Settings" ) );
00124 Layout2 = new QVBoxLayout( devTitle );
00125 Layout2->setSpacing(5);
00126 Layout2->setMargin(5);
00127 Layout2->setAlignment( Qt::AlignTop );
00128 AntiAlias = new QCheckBox(devTitle);
00129 AntiAlias->setText( tr("Enable &Antialiasing"));
00130 AntiAlias->setChecked( postscriptPreview ? prefsManager->appPrefs.PrPr_AntiAliasing : false);
00131 AntiAlias->setEnabled( postscriptPreview );
00132 Layout2->addWidget(AntiAlias);
00133 AliasTr = new QCheckBox(devTitle);
00134 AliasTr->setText( tr("Display Trans&parency"));
00135 AliasTr->setChecked(prefsManager->appPrefs.PrPr_Transparency);
00136 AliasTr->setEnabled( postscriptPreview );
00137 Layout2->addWidget(AliasTr);
00138 EnableCMYK = new QCheckBox(devTitle);
00139 EnableCMYK->setText( tr("&Display CMYK"));
00140 EnableCMYK->setChecked( postscriptPreview ? prefsManager->appPrefs.PrPr_Mode : false);
00141 EnableCMYK->setEnabled( postscriptPreview );
00142 Layout2->addWidget(EnableCMYK);
00143 if (HaveTiffSep)
00144 {
00145 ColorList usedSpots;
00146 doc->getUsedColors(usedSpots, true);
00147 QStringList spots = usedSpots.keys();
00148
00149 Table = new QTableWidget(spots.count()+4, 2, devTitle );
00150 Table->setHorizontalHeaderItem(0, new QTableWidgetItem(QIcon(loadIcon("16/show-object.png")), ""));
00151 Table->setHorizontalHeaderItem(1, new QTableWidgetItem( tr("Separation Name")));
00152 QHeaderView *header = Table->horizontalHeader();
00153 header->setStretchLastSection(true);
00154 header->setMovable(false);
00155 header->setClickable(false);
00156 header->setResizeMode(QHeaderView::Fixed);
00157 Table->setColumnWidth(0, 24);
00158 Table->verticalHeader()->hide();
00159 Table->setSelectionMode( QAbstractItemView::NoSelection );
00160 Table->setEditTriggers(QAbstractItemView::NoEditTriggers);
00161 Table->setFocusPolicy(Qt::NoFocus);
00162 flagsVisible.clear();
00163 Table->setItem(0, 1, new QTableWidgetItem( tr("Cyan")));
00164 QCheckBox *cp = new QCheckBox(this);
00165 cp->setFocusPolicy(Qt::NoFocus);
00166 cp->setChecked(prefsManager->appPrefs.PrPr_C);
00167 connect(cp, SIGNAL(clicked()), this, SLOT(ToggleCMYK_Colour()));
00168 Table->setCellWidget(0, 0, cp);
00169 flagsVisible.insert("Cyan", cp);
00170 Table->setItem(1, 1, new QTableWidgetItem( tr("Magenta")));
00171 cp = new QCheckBox(this);
00172 cp->setFocusPolicy(Qt::NoFocus);
00173 cp->setChecked(prefsManager->appPrefs.PrPr_M);
00174 connect(cp, SIGNAL(clicked()), this, SLOT(ToggleCMYK_Colour()));
00175 Table->setCellWidget(1, 0, cp);
00176 flagsVisible.insert("Magenta", cp);
00177 Table->setItem(2, 1, new QTableWidgetItem( tr("Yellow")));
00178 cp = new QCheckBox(this);
00179 cp->setFocusPolicy(Qt::NoFocus);
00180 cp->setChecked(prefsManager->appPrefs.PrPr_Y);
00181 connect(cp, SIGNAL(clicked()), this, SLOT(ToggleCMYK_Colour()));
00182 Table->setCellWidget(2, 0, cp);
00183 flagsVisible.insert("Yellow", cp);
00184 Table->setItem(3, 1, new QTableWidgetItem( tr("Black")));
00185 cp = new QCheckBox(this);
00186 cp->setFocusPolicy(Qt::NoFocus);
00187 cp->setChecked(prefsManager->appPrefs.PrPr_K);
00188 connect(cp, SIGNAL(clicked()), this, SLOT(ToggleCMYK_Colour()));
00189 Table->setCellWidget(3, 0, cp);
00190 flagsVisible.insert("Black", cp);
00191 for (int sp = 0; sp < spots.count(); ++sp)
00192 {
00193 Table->setItem(sp+4, 1, new QTableWidgetItem(spots[sp]));
00194 cp = new QCheckBox(this);
00195 cp->setFocusPolicy(Qt::NoFocus);
00196 cp->setChecked(true);
00197 connect(cp, SIGNAL(clicked()), this, SLOT(ToggleCMYK_Colour()));
00198 Table->setCellWidget(sp+4, 0, cp);
00199 flagsVisible.insert(spots[sp], cp);
00200 }
00201 Layout2->addWidget(Table);
00202 tbWidth = Table->columnWidth(1);
00203 }
00204 else
00205 {
00206 EnableCMYK_C = new QCheckBox(devTitle);
00207 EnableCMYK_C->setText( tr("&C"));
00208 EnableCMYK_C->setChecked(postscriptPreview ? prefsManager->appPrefs.PrPr_C : true);
00209 EnableCMYK_C->setEnabled(postscriptPreview);
00210 Layout2->addWidget(EnableCMYK_C);
00211 EnableCMYK_M = new QCheckBox(devTitle);
00212 EnableCMYK_M->setText( tr("&M"));
00213 EnableCMYK_M->setChecked(postscriptPreview ? prefsManager->appPrefs.PrPr_M : true);
00214 EnableCMYK_M->setEnabled(postscriptPreview);
00215 Layout2->addWidget(EnableCMYK_M);
00216 EnableCMYK_Y = new QCheckBox(devTitle);
00217 EnableCMYK_Y->setText( tr("&Y"));
00218 EnableCMYK_Y->setChecked(postscriptPreview ? prefsManager->appPrefs.PrPr_Y : true);
00219 EnableCMYK_Y->setEnabled(postscriptPreview);
00220 Layout2->addWidget(EnableCMYK_Y);
00221 EnableCMYK_K = new QCheckBox(devTitle);
00222 EnableCMYK_K->setText( tr("&K"));
00223 EnableCMYK_K->setChecked(postscriptPreview ? prefsManager->appPrefs.PrPr_K : true);
00224 EnableCMYK_K->setEnabled(postscriptPreview);
00225 Layout2->addWidget(EnableCMYK_K);
00226 }
00227
00228 settingsBarLayout->addWidget(devTitle);
00229 jobTitle = new QGroupBox( this );
00230 jobTitle->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
00231 jobTitle->setTitle( tr( "Print Settings" ) );
00232 Layout1 = new QVBoxLayout( jobTitle );
00233 Layout1->setSpacing( 5 );
00234 Layout1->setMargin( 5 );
00235 Layout1->setAlignment( Qt::AlignTop );
00236
00237 MirrorHor = new QCheckBox( tr( "Mirror Page(s) Horizontal" ), jobTitle );
00238 Layout1->addWidget( MirrorHor );
00239
00240 MirrorVert = new QCheckBox( tr( "Mirror Page(s) Vertical" ), jobTitle );
00241 Layout1->addWidget( MirrorVert );
00242
00243 ClipMarg = new QCheckBox( tr( "Clip to Page Margins" ), jobTitle );
00244 Layout1->addWidget( ClipMarg );
00245
00246 useGray = new QCheckBox( tr("Print in Grayscale"), jobTitle);
00247 Layout1->addWidget(useGray);
00248
00249 EnableGCR = new QCheckBox( tr("&Under Color Removal"), jobTitle);
00250 Layout1->addWidget(EnableGCR);
00251
00252 EnableOverprint = new QCheckBox( tr("Force Overprint Mode"), jobTitle);
00253 Layout1->addWidget(EnableOverprint);
00254
00255 spotColors = new QCheckBox( tr( "Convert Spot Colors" ), jobTitle );
00256 Layout1->addWidget( spotColors );
00257
00258 UseICC = new QCheckBox( tr( "Apply Color Profiles" ), jobTitle );
00259 Layout1->addWidget( UseICC );
00260 if (!doc->HasCMS)
00261 UseICC->setEnabled(false);
00262
00263 settingsBarLayout->addWidget(jobTitle);
00264 QSpacerItem* spacerC = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding );
00265 settingsBarLayout->addItem( spacerC );
00266 Layout5->addLayout(settingsBarLayout);
00267 PLayout->addLayout(Layout5);
00268
00269 Layout6 = new QHBoxLayout;
00270 Layout6->setSpacing(0);
00271 Layout6->setMargin(0);
00272
00273 scaleLabel = new QLabel( tr("Scaling:"), this);
00274 scaleBox = new QComboBox(this);
00275 scaleBox->setEditable(false);
00276 scaleBox->setFocusPolicy(Qt::NoFocus);
00277 scaleBox->addItem("50%");
00278 scaleBox->addItem("100%");
00279 scaleBox->addItem("150%");
00280 scaleBox->addItem("200%");
00281 scaleBox->addItem( tr("Fit to Width"));
00282 scaleBox->addItem( tr("Fit to Height"));
00283 scaleBox->addItem( tr("Fit to Page"));
00284 scaleBox->setCurrentIndex(1);
00285 Layout6->addWidget(scaleLabel);
00286 Layout6->addWidget(scaleBox);
00287 QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
00288 Layout6->addItem( spacer );
00289 PGSel = new PageSelector(this, doc->DocPages.count());
00290 PGSel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00291 Layout6->addWidget(PGSel);
00292 QSpacerItem* spacer2 = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
00293 Layout6->addItem( spacer2 );
00294 closeButton = new QPushButton( tr("Close"), this);
00295 closeButton->setAutoDefault(false);
00296 Layout6->addWidget( closeButton );
00297 printButton = new QPushButton( tr("Print..."), this );
00298 printButton->setAutoDefault(false);
00299 printButton->setEnabled(!printDinUse);
00300 Layout6->addWidget( printButton );
00301 PLayout->addLayout(Layout6);
00302 setValues();
00303 Anz = new QLabel(this);
00304 Anz->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
00305
00306 Anz->setPixmap(CreatePreview(doc->currentPage()->pageNr(), 72));
00307 Anz->resize(Anz->pixmap()->size());
00308 Anzeige->setWidget(Anz);
00309 int w = Anz->width() + tbWidth + 50;
00310 resize(qMin(QApplication::desktop()->width()-30,w), 500);
00311 if (!PrefsManager::instance()->appPrefs.PrPr_Mode)
00312 {
00313 if (HaveTiffSep)
00314 Table->setEnabled(false);
00315 else
00316 {
00317 EnableCMYK_C->setEnabled(false);
00318 EnableCMYK_M->setEnabled(false);
00319 EnableCMYK_Y->setEnabled(false);
00320 EnableCMYK_K->setEnabled(false);
00321 }
00322 }
00323 PGSel->GotoPg(doc->currentPage()->pageNr());
00324
00325 AntiAlias->setToolTip( "<qt>" + tr( "Provides a more pleasant view of Type 1 fonts, TrueType Fonts, OpenType Fonts, EPS, PDF and vector graphics in the preview, at the expense of a slight slowdown in previewing" ) + "</qt>" );
00326 AliasTr->setToolTip( "<qt>" + tr( "Shows transparency and transparent items in your document. Requires Ghostscript 7.07 or later" ) + "</qt>");
00327 EnableCMYK->setToolTip( "<qt>" + tr( "Gives a print preview using simulations of generic CMYK inks, instead of RGB colors" ) + "</qt>");
00328 EnableGCR->setToolTip( "<qt>" + tr( "A way of switching off some of the gray shades which are composed of cyan, yellow and magenta and using black instead. UCR most affects parts of images which are neutral and/or dark tones which are close to the gray. Use of this may improve printing some images and some experimentation and testing is need on a case by case basis. UCR reduces the possibility of over saturation with CMY inks." ) + "</qt>" );
00329 scaleBox->setToolTip( "<qt>" + tr("Resize the scale of the page.") + "</qt>");
00330 spotColors->setToolTip("<qt>" + tr( "Enables Spot Colors to be converted to composite colors. Unless you are planning to print spot colors at a commercial printer, this is probably best left enabled." ) + "</qt>");
00331 EnableOverprint->setToolTip( "<qt>"+ tr("Enables global Overprint Mode for this document, overrides object settings") + "<qt>");
00332 UseICC->setToolTip("<qt>" + tr( "Allows you to embed color profiles in the print stream when color management is enabled" ) + "</qt>");
00333
00334
00335 connect(AntiAlias, SIGNAL(clicked()), this, SLOT(redisplay()));
00336 connect(AliasTr, SIGNAL(clicked()), this, SLOT(redisplay()));
00337 connect(EnableCMYK, SIGNAL(clicked()), this, SLOT(ToggleCMYK()));
00338 connect(EnableGCR, SIGNAL(clicked()), this, SLOT(redisplay()));
00339 connect(EnableOverprint, SIGNAL(clicked()), this, SLOT(redisplay()));
00340 connect(MirrorHor, SIGNAL(clicked()), this, SLOT(redisplay()));
00341 connect(MirrorVert, SIGNAL(clicked()), this, SLOT(redisplay()));
00342 connect(ClipMarg, SIGNAL(clicked()), this, SLOT(redisplay()));
00343 connect(spotColors, SIGNAL(clicked()), this, SLOT(redisplay()));
00344 connect(useGray, SIGNAL(clicked()), this, SLOT(redisplay()));
00345 connect(UseICC, SIGNAL(clicked()), this, SLOT(redisplay()));
00346 if (!HaveTiffSep)
00347 {
00348 connect(EnableCMYK_C, SIGNAL(clicked()), this, SLOT(ToggleCMYK_Colour()));
00349 connect(EnableCMYK_M, SIGNAL(clicked()), this, SLOT(ToggleCMYK_Colour()));
00350 connect(EnableCMYK_Y, SIGNAL(clicked()), this, SLOT(ToggleCMYK_Colour()));
00351 connect(EnableCMYK_K, SIGNAL(clicked()), this, SLOT(ToggleCMYK_Colour()));
00352 EnableCMYK_C->setToolTip( tr( "Enable/disable the C (Cyan) ink plate" ) );
00353 EnableCMYK_M->setToolTip( tr( "Enable/disable the M (Magenta) ink plate" ) );
00354 EnableCMYK_Y->setToolTip( tr( "Enable/disable the Y (Yellow) ink plate" ) );
00355 EnableCMYK_K->setToolTip( tr( "Enable/disable the K (Black) ink plate" ) );
00356 }
00357 connect(PGSel, SIGNAL(GotoPage(int)), this, SLOT(ToSeite(int)));
00358 connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
00359 connect(printButton, SIGNAL(clicked()), this, SIGNAL(doPrint()));
00360 connect(scaleBox, SIGNAL(activated(int)), this, SLOT(scaleBox_valueChanged(int)));
00361 }
00362
00363 void PPreview::setValues()
00364 {
00365 if ((printDinUse) || (!doc->Print_Options.firstUse))
00366 {
00367 EnableGCR->setChecked( postscriptPreview ? doc->Print_Options.doGCR : false);
00368 EnableGCR->setEnabled( postscriptPreview );
00369 EnableOverprint->setChecked( postscriptPreview ? doc->Print_Options.doOverprint : false);
00370 EnableOverprint->setEnabled( postscriptPreview );
00371 MirrorHor->setChecked(doc->Print_Options.mirrorH);
00372 MirrorVert->setChecked(doc->Print_Options.mirrorV);
00373 ClipMarg->setChecked(doc->Print_Options.doClip);
00374 spotColors->setChecked(!doc->Print_Options.useSpotColors);
00375 useGray->setChecked(!doc->Print_Options.useColor);
00376 if (doc->HasCMS)
00377 {
00378 UseICC->setChecked( postscriptPreview ? doc->Print_Options.useICC : false);
00379 UseICC->setEnabled( postscriptPreview );
00380 }
00381 }
00382 else
00383 {
00384 PrefsContext* prefs = PrefsManager::instance()->prefsFile->getContext("print_options");
00385 EnableGCR->setChecked( postscriptPreview ? prefs->getBool("DoGCR", false) : false);
00386 EnableGCR->setEnabled( postscriptPreview );
00387 EnableOverprint->setChecked( postscriptPreview ? prefs->getBool("doOverprint", false) : false);
00388 EnableOverprint->setEnabled( postscriptPreview );
00389 MirrorHor->setChecked(prefs->getBool("MirrorH", false));
00390 MirrorVert->setChecked(prefs->getBool("MirrorV", false));
00391 ClipMarg->setChecked(prefs->getBool("Clip", false));
00392 spotColors->setChecked(!prefs->getBool("doSpot", true));
00393 if (prefs->getInt("PrintColor", 0) == 1)
00394 useGray->setChecked(true);
00395 else
00396 useGray->setChecked(false);
00397 if (doc->HasCMS)
00398 {
00399 UseICC->setChecked( postscriptPreview ? prefs->getBool("ICCinUse", false) : false);
00400 UseICC->setEnabled( postscriptPreview );
00401 }
00402 }
00403 }
00404
00405 void PPreview::ToSeite(int num)
00406 {
00407 int n = num-1;
00408 if (n == APage)
00409 return;
00410 Anz->setPixmap(CreatePreview(n, qRound(72 * scaleFactor)));
00411 Anz->resize(Anz->pixmap()->size());
00412 }
00413
00414 void PPreview::redisplay()
00415 {
00416 Anz->setPixmap(CreatePreview(APage, qRound(72 * scaleFactor)));
00417 Anz->resize(Anz->pixmap()->size());
00418 }
00419
00420 void PPreview::ToggleCMYK()
00421 {
00422 bool c = EnableCMYK->isChecked() ? true : false;
00423 if (HaveTiffSep)
00424 Table->setEnabled(c);
00425 else
00426 {
00427 EnableCMYK_C->setEnabled(c);
00428 EnableCMYK_M->setEnabled(c);
00429 EnableCMYK_Y->setEnabled(c);
00430 EnableCMYK_K->setEnabled(c);
00431 }
00432
00433 Anz->setPixmap(CreatePreview(APage, qRound(72 * scaleFactor)));
00434 Anz->resize(Anz->pixmap()->size());
00435 }
00436
00437 void PPreview::ToggleCMYK_Colour()
00438 {
00439 if (EnableCMYK->isChecked())
00440 Anz->setPixmap(CreatePreview(APage, qRound(72 * scaleFactor)));
00441 Anz->resize(Anz->pixmap()->size());
00442 }
00443
00444 void PPreview::scaleBox_valueChanged(int value)
00445 {
00446 switch (value)
00447 {
00448 case 0:
00449 scaleFactor = 0.5;
00450 break;
00451 case 1:
00452 scaleFactor = 1.0;
00453 break;
00454 case 2:
00455 scaleFactor = 1.5;
00456 break;
00457 case 3:
00458 scaleFactor = 2.0;
00459 break;
00460 case 4:
00461 scaleFactor = Anzeige->viewport()->width() / doc->Pages->at(APage)->width();
00462 break;
00463 case 5:
00464 scaleFactor = Anzeige->viewport()->height() / doc->Pages->at(APage)->height();
00465 break;
00466 case 6:
00467 scaleFactor = qMin(Anzeige->viewport()->height() / doc->Pages->at(APage)->height(), Anzeige->viewport()->width() / doc->Pages->at(APage)->width());
00468 break;
00469 default:
00470 scaleFactor = 1.0;
00471 break;
00472 }
00473 Anz->setPixmap(CreatePreview(APage, qRound(72 * scaleFactor)));
00474 Anz->resize(Anz->pixmap()->size());
00475 }
00476
00477 int PPreview::RenderPreview(int Seite, int Res)
00478 {
00479 int ret = -1;
00480 QString cmd1, cmd2, cmd3;
00481 QMap<QString,QMap<uint, FPointArray> > ReallyUsed;
00482 #if defined _WIN32
00483 if ( !postscriptPreview )
00484 {
00485 QImage image;
00486 Page* page;
00487 ScPrintEngine_GDI winPrint;
00488 PrintOptions options;
00489 page = doc->Pages->at( Seite );
00490 options.copies = 1;
00491 options.doGCR = false;
00492
00493 options.mirrorH = MirrorHor->isChecked();
00494 options.mirrorV = MirrorVert->isChecked();
00495 options.outputSeparations = false;
00496 options.pageNumbers.push_back( Seite );
00497 options.prnEngine = WindowsGDI;
00498 options.separationName = "All";
00499 options.toFile = false;
00500 options.useColor = !useGray->isChecked();
00501 options.useICC = false;
00502 options.useSpotColors = false;
00503 options.doOverprint = false;
00504 bool done = winPrint.gdiPrintPreview(doc, page, &image, options, Res / 72.0);
00505 if ( done )
00506 image.save( ScPaths::getTempFileDir() + "/sc.png", "PNG" );
00507 return (done ? 0 : 1);
00508 }
00509 #endif
00510
00511 if ((Seite != APage) || (EnableGCR->isChecked() != GMode) || (EnableOverprint->isChecked() != OMode)
00512 || (useGray->isChecked() != fGray) || (MirrorHor->isChecked() != mHor) || (MirrorVert->isChecked() != mVer)
00513 || (ClipMarg->isChecked() != fClip) || (UseICC->isChecked() != fICC) || (spotColors->isChecked() != fSpot))
00514 {
00515 ReallyUsed.clear();
00516 doc->getUsedFonts(ReallyUsed);
00517 bool useIC = UseICC->isChecked();
00518 if (!doc->HasCMS)
00519 useIC = false;
00520 PrintOptions options;
00521 options.pageNumbers.push_back(Seite+1);
00522 options.outputSeparations = false;
00523 options.separationName = tr("All");
00524 options.allSeparations = QStringList();
00525 options.useColor = !useGray->isChecked();
00526 options.mirrorH = MirrorHor->isChecked();
00527 options.mirrorV = MirrorVert->isChecked();
00528 options.useICC = useIC;
00529 options.doGCR = EnableGCR->isChecked();
00530 options.setDevParam = false;
00531 options.doClip = ClipMarg->isChecked();
00532 options.doOverprint = EnableOverprint->isChecked();
00533 options.cropMarks = false;
00534 options.bleedMarks = false;
00535 options.registrationMarks = false;
00536 options.colorMarks = false;
00537 options.markOffset = 0.0;
00538 options.bleeds.Top = 0.0;
00539 options.bleeds.Left = 0.0;
00540 options.bleeds.Right = 0.0;
00541 options.bleeds.Bottom = 0.0;
00542 PSLib *dd = new PSLib(options, true, prefsManager->appPrefs.AvailFonts, ReallyUsed, doc->PageColors, false, !spotColors->isChecked());
00543 if (dd != NULL)
00544 {
00545 dd->PS_set_file( ScPaths::getTempFileDir() + "/tmp.ps");
00546 ret = dd->CreatePS(doc, options);
00547 delete dd;
00548 if (ret != 0) return 1;
00549 }
00550 else
00551 return ret;
00552 }
00553 QStringList args;
00554 QString tmp, tmp2, tmp3;
00555 double b = doc->Pages->at(Seite)->width() * Res / 72.0;
00556 double h = doc->Pages->at(Seite)->height() * Res / 72.0;
00557 args.append( "-q" );
00558 args.append( "-dNOPAUSE" );
00559 args.append( "-dPARANOIDSAFER" );
00560 args.append( QString("-r%1").arg(tmp.setNum(qRound(Res))) );
00561 args.append( QString("-g%1x%2").arg(tmp2.setNum(qRound(b))).arg(tmp3.setNum(qRound(h))) );
00562 if (EnableCMYK->isChecked())
00563 {
00564 if (HaveTiffSep)
00565 args.append( "-sDEVICE=tiffsep" );
00566 else
00567 {
00568 args.append( "-sDEVICE=bitcmyk" );
00569 args.append( "-dGrayValues=256" );
00570 }
00571 }
00572 else
00573 {
00574 if ((!AliasTr->isChecked()) || (!HavePngAlpha))
00575 args.append( "-sDEVICE=png16m" );
00576 else
00577 args.append( "-sDEVICE=pngalpha" );
00578 }
00579 if (AntiAlias->isChecked())
00580 {
00581 args.append( "-dTextAlphaBits=4" );
00582 args.append( "-dGraphicsAlphaBits=4" );
00583 }
00584
00585 PrefsContext *pc = prefsManager->prefsFile->getContext("Fonts");
00586 PrefsTable *extraFonts = pc->getTable("ExtraFontDirs");
00587 const char sep = ScPaths::envPathSeparator;
00588 if (extraFonts->getRowCount() >= 1)
00589 cmd1 = QString("-sFONTPATH=%1").arg(QDir::convertSeparators(extraFonts->get(0,0)));
00590 for (int i = 1; i < extraFonts->getRowCount(); ++i)
00591 cmd1 += QString("%1%2").arg(sep).arg(QDir::convertSeparators(extraFonts->get(i,0)));
00592 if( !cmd1.isEmpty() )
00593 args.append( cmd1 );
00594
00595 if ((EnableCMYK->isChecked()) && HaveTiffSep)
00596 args.append( QString("-sOutputFile=%1").arg(QDir::convertSeparators(ScPaths::getTempFileDir()+"/sc.tif")) );
00597 else
00598 args.append( QString("-sOutputFile=%1").arg(QDir::convertSeparators(ScPaths::getTempFileDir()+"/sc.png")) );
00599 args.append( QDir::convertSeparators(ScPaths::getTempFileDir()+"/tmp.ps") );
00600 args.append( "-c" );
00601 args.append( "showpage" );
00602 args.append( "-c" );
00603 args.append( "quit" );
00604 ret = System(getShortPathName(prefsManager->ghostscriptExecutable()), args);
00605 return ret;
00606 }
00607
00608 int PPreview::RenderPreviewSep(int Seite, int Res)
00609 {
00610 int ret = -1;
00611 QString cmd;
00612 QStringList args, args1, args2, args3;
00613 QMap<QString, QMap<uint, FPointArray> > ReallyUsed;
00614
00615 if ((Seite != APage) || (EnableGCR->isChecked() != GMode) || (EnableOverprint->isChecked() != OMode)
00616 || (useGray->isChecked() != fGray) || (MirrorHor->isChecked() != mHor) || (MirrorVert->isChecked() != mVer)
00617 || (ClipMarg->isChecked() != fClip) || (UseICC->isChecked() != fICC) || (spotColors->isChecked() != fSpot))
00618 {
00619 ReallyUsed.clear();
00620 doc->getUsedFonts(ReallyUsed);
00621 bool useIC = UseICC->isChecked();
00622 if (!doc->HasCMS)
00623 useIC = false;
00624 PrintOptions options;
00625 options.pageNumbers.push_back(Seite+1);
00626 options.outputSeparations = false;
00627 options.separationName = tr("All");
00628 options.allSeparations = QStringList();
00629 options.useColor = !useGray->isChecked();
00630 options.mirrorH = MirrorHor->isChecked();
00631 options.mirrorV = MirrorVert->isChecked();
00632 options.useICC = useIC;
00633 options.doGCR = EnableGCR->isChecked();
00634 options.setDevParam = false;
00635 options.doClip = ClipMarg->isChecked();
00636 options.doOverprint = EnableOverprint->isChecked();
00637 options.cropMarks = false;
00638 options.bleedMarks = false;
00639 options.registrationMarks = false;
00640 options.colorMarks = false;
00641 options.markOffset = 0.0;
00642 options.bleeds.Top = 0.0;
00643 options.bleeds.Left = 0.0;
00644 options.bleeds.Right = 0.0;
00645 options.bleeds.Bottom = 0.0;
00646 PSLib *dd = new PSLib(options, true, prefsManager->appPrefs.AvailFonts, ReallyUsed, doc->PageColors, false, !spotColors->isChecked());
00647 if (dd != NULL)
00648 {
00649 dd->PS_set_file(ScPaths::getTempFileDir()+"/tmp.ps");
00650 ret = dd->CreatePS(doc, options);
00651 delete dd;
00652 if (ret != 0) return 1;
00653 }
00654 else
00655 return ret;
00656 }
00657 QString tmp, tmp2, tmp3;
00658 double b = doc->Pages->at(Seite)->width() * Res / 72.0;
00659 double h = doc->Pages->at(Seite)->height() * Res / 72.0;
00660
00661 args1.append( "-q" );
00662 args1.append( "-dNOPAUSE" );
00663 args1.append( "-dPARANOIDSAFER" );
00664 args1.append( QString("-r%1").arg(tmp.setNum(qRound(Res))) );
00665 args1.append( QString("-g%1x%2").arg(tmp2.setNum(qRound(b))).arg(tmp3.setNum(qRound(h))) );
00666 if (AntiAlias->isChecked())
00667 {
00668 args1.append("-dTextAlphaBits=4");
00669 args1.append("-dGraphicsAlphaBits=4");
00670 }
00671
00672 PrefsContext *pc = prefsManager->prefsFile->getContext("Fonts");
00673 PrefsTable *extraFonts = pc->