Subversion Repositories Scribus

Rev

Rev 20103 | Rev 20185 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
19828 jghali 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
7
 
8
#include <QStandardItem>
9
#include <QAbstractItemView>
10
 
11
#include "ui/prefs_pdfexport.h"
12
#include "ui/createrange.h"
13
#include "prefsstructs.h"
14
 
15
#include "scribuscore.h"
16
#include "scribusdoc.h"
17
#include "scribusview.h"
18
#include "ui/scrspinbox.h"
19
#include "units.h"
20
#include "util.h"
21
#include "util_icon.h"
22
 
23
Prefs_PDFExport::Prefs_PDFExport(QWidget* parent, ScribusDoc* doc)
24
        : Prefs_Pane(parent),
25
        cmsEnabled(false),
26
        m_doc(doc),
27
        exportingPDF(false)
28
{
29
        setupUi(this);
30
        pageMirrorHorizontalToolButton->setIcon(QIcon(loadIcon("16/flip-object-horizontal.png")));
31
        pageMirrorVerticalToolButton->setIcon(QIcon(loadIcon("16/flip-object-vertical.png")));
32
        unitChange(0);
33
        languageChange();
20122 jghali 34
 
35
        connect(fontEmbeddingCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(EmbeddingModeChange()));
19828 jghali 36
        connect(exportChosenPagesRadioButton, SIGNAL(toggled(bool)), this, SLOT(enableRangeControls(bool)));
37
        connect(exportRangeMorePushButton, SIGNAL(clicked()), this, SLOT(createPageNumberRange()));
38
        connect(maxResolutionLimitCheckBox, SIGNAL(clicked()), this, SLOT(setMaximumResolution()));
39
        connect(outputIntentionComboBox, SIGNAL(activated(int)), this, SLOT(enableProfiles(int)));
40
        connect(useSolidColorProfileCheckBox, SIGNAL(clicked()), this, SLOT(enablePG()));
41
        connect(useImageProfileCheckBox, SIGNAL(clicked()), this, SLOT(enablePGI()));
42
        connect(doNotUseEmbeddedImageProfileCheckBox, SIGNAL(clicked()), this, SLOT(enablePGI2()));
43
        connect(pdfVersionComboBox, SIGNAL(activated(int)), this, SLOT(enablePDFX(int)));
44
        connect(useEncryptionCheckBox, SIGNAL(clicked(bool)), this, SLOT(enableSecurityControls(bool)));
45
        connect(useCustomRenderingCheckBox, SIGNAL(clicked()), this, SLOT(enableLPI2()));
46
        connect(customRenderingColorComboBox, SIGNAL(activated(int)), this, SLOT(SelLPIcol(int)));
47
 
48
        rotationComboBox->setToolTip( "<qt>" + tr( "Automatically rotate the exported pages" ) + "</qt>" );
49
        exportAllPagesRadioButton->setToolTip( "<qt>" + tr( "Export all pages to PDF" ) + "</qt>" );
50
        exportChosenPagesRadioButton->setToolTip( "<qt>" + tr( "Export a range of pages to PDF" ) );
51
        exportPageListLineEdit->setToolTip( "<qt>" + tr( "Insert a comma separated list of tokens where "
52
                                                                                        "a token can be * for all the pages, 1-5 for "
53
                                                                                        "a range of pages or a single page number.") + "</qt>" );
54
        exportRangeMorePushButton->setToolTip( "<qt>" + tr( "Create a range of pages" ) + "</qt>");
55
 
56
        pdfVersionComboBox->setToolTip( "<qt>" + tr( "Determines the PDF compatibility.<br/>The default is <b>PDF 1.3</b> which gives the widest compatibility.<br/>Choose <b>PDF 1.4</b> if your file uses features such as transparency or you require 128 bit encryption.<br/><b>PDF 1.5</b> is necessary when you wish to preserve objects in separate layers within the PDF.<br/><b>PDF/X-3</b> is for exporting the PDF when you want color managed RGB for commercial printing and is selectable when you have activated color management. Use only when advised by your printer or in some cases printing to a 4 color digital color laser printer.<br/><b>PDF/X-1a</b> is for blind exchange with colors strictly specified in CMYK or spot colors.<br/><b>PDF/X-4</b> is an extension of PDF/X-3 to support transparancy and layering." ) + "</qt>");
57
        pageBindingComboBox->setToolTip( "<qt>" + tr( "Determines the binding of pages in the PDF. Unless you know you need to change it leave the default choice - Left." ) + "</qt>" );
58
        generateThumbnailsCheckBox->setToolTip( "<qt>" + tr( "Generates thumbnails of each page in the PDF. Some viewers can use the thumbnails for navigation." ) + "</qt>" );
59
        saveLinkedTextFramesAsArticlesCheckBox->setToolTip( "<qt>" + tr( "Generate PDF Articles, which is useful for navigating linked articles in a PDF." ) + "</qt>" );
60
        includeLayersCheckBox->setToolTip( "<qt>" + tr( "Layers in your document are exported to the PDF Only available if PDF 1.5 is chosen." ) + "</qt>" );
61
        includeBookmarksCheckBox->setToolTip( "<qt>" + tr( "Embed the bookmarks you created in your document. These are useful for navigating long PDF documents." ) + "</qt>" );
62
        epsExportResolutionSpinBox->setToolTip( "<qt>" + tr( "Export resolution of text and vector graphics. This does not affect the resolution of bitmap images like photos." ) + "</qt>" );
63
        embedPDFAndEPSFilesCheckBox->setToolTip( "<qt>" + tr( "Export PDFs in image frames as embedded PDFs. This does *not* yet take care of colorspaces, so you should know what you are doing before setting this to 'true'." ) + "</qt>" );
64
        compressTextAndVectorGraphicsCheckBox->setToolTip( "<qt>" + tr( "Enables lossless compression of text and graphics. Unless you have a reason, leave this checked. This reduces PDF file size." ) + "</qt>" );
65
        imageCompressionMethodComboBox->setToolTip( "<qt>" + tr( "Method of compression to use for images. Automatic allows Scribus to choose the best method. ZIP is lossless and good for images with solid colors. JPEG is better at creating smaller PDF files which have many photos (with slight image quality loss possible). Leave it set to Automatic unless you have a need for special compression options." ) + "</qt>");
66
        imageCompressionQualityComboBox->setToolTip( "<qt>" + tr( "Compression quality levels for lossy compression methods: Minimum (25%), Low (50%), Medium (75%), High (85%), Maximum (95%). Note that a quality level does not directly determine the size of the resulting image - both size and quality loss vary from image to image at any given quality level. Even with Maximum selected, there is always some quality loss with jpeg." ) + "</qt>");
67
        maxResolutionLimitCheckBox->setToolTip( "<qt>" + tr( "Limits the resolution of your bitmap images to the selected DPI. Images with a lower resolution will be left untouched. Leaving this unchecked will render them at their native resolution. Enabling this will increase memory usage and slow down export." ) + "</qt>" );
68
        maxExportResolutionSpinBox->setToolTip( "<qt>" + tr( "DPI (Dots Per Inch) for image export.") + "</qt>" );
69
        useEncryptionCheckBox->setToolTip( "<qt>" + tr( "Enable the security features in your exported PDF. If you selected PDF 1.3, the PDF will be protected by 40 bit encryption. If you selected PDF 1.4, the PDF will be protected by 128 bit encryption. Disclaimer: PDF encryption is not as reliable as GPG or PGP encryption and does have some limitations." ) + "</qt>" );
70
        passwordOwnerLineEdit->setToolTip( "<qt>" + tr( "Choose an owner password which enables or disables all the security features in your exported PDF" ) + "</qt>" );
71
        passwordUserLineEdit->setToolTip( "<qt>" + tr( "Choose a password for users to be able to read your PDF." ) + "</qt>" );
72
        allowPrintingCheckBox->setToolTip( "<qt>" + tr( "Allow printing of the PDF. If un-checked, printing is prevented. " ) + "</qt>" );
73
        allowChangingCheckBox->setToolTip( "<qt>" + tr( "Allow modifying of the PDF. If un-checked, modifying the PDF is prevented." ) + "</qt>" );
74
        allowCopyingCheckBox->setToolTip( "<qt>" + tr( "Allow copying of text or graphics from the PDF. If unchecked, text and graphics cannot be copied." ) + "</qt>" );
75
        allowAnnotatingCheckBox->setToolTip( "<qt>" + tr( "Allow adding annotations and fields to the PDF. If unchecked, editing annotations and fields is prevented." ) + "</qt>" );
76
        outputIntentionComboBox->setToolTip( "<qt>" + tr( "Color model for the output of your PDF. Choose Screen/Web for PDFs which are used for screen display and for printing on typical inkjets. Choose Printer when printing to a true 4 color CMYK printer. Choose Grayscale when you want a grey scale PDF." ) + "</qt>" );
77
        useCustomRenderingCheckBox->setToolTip( "<qt>" + tr( "This is an advanced setting which is not enabled by default. This should only be enabled when specifically requested by your printer and they have given you the exact details needed. Otherwise, your exported PDF may not print properly and is truly not portable across systems." ) + "</qt>" );
78
        useSolidColorProfileCheckBox->setToolTip( "<qt>" + tr( "Embed a color profile for solid colors" ) + "</qt>" );
79
        solidColorProfileComboBox->setToolTip( "<qt>" + tr( "Color profile for solid colors" ) + "</qt>" );
80
        solidColorRenderingIntentComboBox->setToolTip( "<qt>" + tr( "Rendering intent for solid colors" ) + "</qt>" );
81
        useImageProfileCheckBox->setToolTip( "<qt>" + tr( "Embed a color profile for images" ) + "</qt>" );
82
        doNotUseEmbeddedImageProfileCheckBox->setToolTip( "<qt>" + tr( "Do not use color profiles that are embedded in source images" ) + "</qt>" );
83
        imageProfileComboBox->setToolTip( "<qt>" + tr( "Color profile for images" ) + "</qt>" );
84
        imageRenderingIntentComboBox->setToolTip( "<qt>" + tr( "Rendering intent for images" ) + "</qt>" );
85
        pageMirrorHorizontalToolButton->setToolTip( "<qt>" + tr( "Mirror Page(s) horizontally" ) + "</qt>" );
86
        pageMirrorVerticalToolButton->setToolTip( "<qt>" + tr( "Mirror Page(s) vertically" ) + "</qt>" );
87
        convertSpotsToProcessCheckBox->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>");
88
        clipToPrinterMarginsCheckBox->setToolTip( "<qt>" + tr( "Do not show objects outside the margins in the exported file" ) + "</qt>" );
89
        //PrePress tab
90
        printCropMarksCheckBox->setToolTip( "<qt>" + tr( "Creates crop marks in the PDF indicating where the paper should be cut or trimmed after printing" ) + "</qt>" );
91
        printBleedMarksCheckBox->setToolTip( "<qt>" + tr( "This creates bleed marks which are indicated by  _ . _ and show the bleed limit" ) + "</qt>" );
92
        printRegistrationMarksCheckBox->setToolTip( "<qt>" + tr( "Add registration marks to each separation" ) + "</qt>" );
93
        printColorBarsCheckBox->setToolTip( "<qt>" + tr( "Add color calibration bars" ) + "</qt>" );
94
        printPageInfoCheckBox->setToolTip( "<qt>" + tr( "Add document information which includes the document title and page numbers" ) + "</qt>" );
95
        markLengthSpinBox->setToolTip( "<qt>" + tr( "Length of crop marks" ) + "</qt>" );
96
        markOffsetSpinBox->setToolTip( "<qt>" + tr( "Indicate the distance offset for the registration marks" ) + "</qt>" );
97
//      BleedTop->setToolTip( "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" );
98
//      BleedBottom->setToolTip( "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" );
99
//      BleedLeft->setToolTip( "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" );
100
//      BleedRight->setToolTip( "<qt>" + tr( "Distance for bleed from the right of the physical page" )  + "</qt>");
101
        useDocumentBleedsCheckBox->setToolTip( "<qt>" + tr( "Use the existing bleed settings from the document preferences" ) + "</qt>" );
102
        pdfx3OutputProfileComboBox->setToolTip( "<qt>" + tr( "Output profile for printing. If possible, get some guidance from your printer on profile selection." ) + "</qt>" );
103
        pdfx3InfoStringLineEdit->setToolTip( "<qt>" + tr( "Mandatory string for PDF/X or the PDF will fail PDF/X conformance. We recommend you use the title of the document." ) + "</qt>" );
104
 
105
}
106
 
107
Prefs_PDFExport::~Prefs_PDFExport()
108
{
109
}
110
 
20122 jghali 111
PDFOptions::PDFFontEmbedding Prefs_PDFExport::fontEmbeddingMode()
112
{
113
        return (PDFOptions::PDFFontEmbedding) fontEmbeddingCombo->currentIndex();
114
}
115
 
19828 jghali 116
QStringList Prefs_PDFExport::fontsToEmbed()
117
{
20122 jghali 118
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingMode();
119
        if (embeddingMode != PDFOptions::EmbedFonts)
120
                return QStringList();
121
 
19828 jghali 122
        QStringList fonts;
20122 jghali 123
        for (int i = 0; i < embeddedFontsListWidget->count(); ++i)
124
                fonts.append(embeddedFontsListWidget->item(i)->text());
19828 jghali 125
        return fonts;
126
}
127
 
20103 avox 128
QStringList Prefs_PDFExport::fontsToSubset()
19828 jghali 129
{
20122 jghali 130
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingMode();
131
        if (embeddingMode != PDFOptions::EmbedFonts)
132
                return QStringList();
133
 
19828 jghali 134
        QStringList fonts;
20122 jghali 135
        for (int i = 0; i < subsettedFontsListWidget->count(); ++i)
136
                fonts.append(subsettedFontsListWidget->item(i)->text());
19828 jghali 137
        return fonts;
138
}
139
 
20103 avox 140
QStringList Prefs_PDFExport::fontsToOutline()
141
{
20122 jghali 142
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingMode();
143
        if (embeddingMode != PDFOptions::OutlineFonts)
144
                return QStringList();
145
 
146
        if (m_doc)
147
                return m_doc->usedFonts().keys();
148
        return QStringList();
20103 avox 149
}
150
 
20122 jghali 151
QListWidgetItem* Prefs_PDFExport::addFontItem(QString fontName, QListWidget* fontList)
152
{
153
        QListWidgetItem* item = 0;
154
        if (!AllFonts.contains(fontName))
155
                return 0;
156
 
157
        const ScFace face = AllFonts.value(fontName);
158
        if (face.isReplacement())
159
                item = new QListWidgetItem( QIcon(loadIcon("font_subst16.png")), fontName, fontList );
160
        else if (face.type() == ScFace::TYPE1)
161
                item = new QListWidgetItem( QIcon(loadIcon("font_type1_16.png")), fontName, fontList );
162
        else if (face.type() == ScFace::TTF)
163
                item = new QListWidgetItem( QIcon(loadIcon("font_truetype16.png")), fontName, fontList );
164
        else if (face.type() == ScFace::OTF)
165
                item = new QListWidgetItem( QIcon(loadIcon("font_otf16.png")), fontName, fontList );
166
 
167
        return item;
168
}
169
 
19828 jghali 170
void Prefs_PDFExport::unitChange(int unitIndex)
171
{
172
        unitRatio = unitGetRatioFromIndex(unitIndex);
173
 
174
        markLengthSpinBox->setNewUnit(unitIndex);
175
        markLengthSpinBox->setMinimum(0);
176
        markLengthSpinBox->setMaximum(3000 * unitRatio);
177
 
178
        markOffsetSpinBox->setNewUnit(unitIndex);
179
        markOffsetSpinBox->setMinimum(0);
180
        markOffsetSpinBox->setMaximum(3000 * unitRatio);
181
 
182
        bleedsWidget->setNewUnit(unitIndex);
183
}
184
 
185
void Prefs_PDFExport::languageChange()
186
{
187
        int i=0;
188
        i = rotationComboBox->currentIndex();
189
        rotationComboBox->clear();
190
        rotationComboBox->addItem(QString::fromUtf8("0 °"));
191
        rotationComboBox->addItem(QString::fromUtf8("90 °"));
192
        rotationComboBox->addItem(QString::fromUtf8("180 °"));
193
        rotationComboBox->addItem(QString::fromUtf8("270 °"));
194
        rotationComboBox->setCurrentIndex(i);
195
 
196
        i = imageCompressionMethodComboBox->currentIndex();
197
        imageCompressionMethodComboBox->clear();
198
        imageCompressionMethodComboBox->addItem( tr( "Automatic" ) );
199
        imageCompressionMethodComboBox->addItem( tr( "Lossy - JPEG" ) );
200
        imageCompressionMethodComboBox->addItem( tr( "Lossless - Zip" ) );
201
        imageCompressionMethodComboBox->addItem( tr( "None" ) );
202
        imageCompressionMethodComboBox->setCurrentIndex(i);
203
 
204
        i = imageCompressionQualityComboBox->currentIndex();
205
        imageCompressionQualityComboBox->clear();
206
        imageCompressionQualityComboBox->addItem( tr( "Maximum" ) );
207
        imageCompressionQualityComboBox->addItem( tr( "High" ) );
208
        imageCompressionQualityComboBox->addItem( tr( "Medium" ) );
209
        imageCompressionQualityComboBox->addItem( tr( "Low" ) );
210
        imageCompressionQualityComboBox->addItem( tr( "Minimum" ) );
211
        imageCompressionQualityComboBox->setCurrentIndex(i);
212
 
213
        addPDFVersions(true);//if (cmsEnabled)// && (!PDFXProfiles.isEmpty()))
214
 
215
        i = pageBindingComboBox->currentIndex();
216
        pageBindingComboBox->clear();
217
        pageBindingComboBox->addItem( tr("Left Margin"));
218
        pageBindingComboBox->addItem( tr("Right Margin"));
219
        pageBindingComboBox->setCurrentIndex(i);
220
 
221
        i = outputIntentionComboBox->currentIndex();
222
        outputIntentionComboBox->clear();
223
        outputIntentionComboBox->addItem( tr( "Screen / Web" ) );
224
        outputIntentionComboBox->addItem( tr( "Printer" ) );
225
        outputIntentionComboBox->addItem( tr( "Grayscale" ) );
226
        outputIntentionComboBox->setCurrentIndex(i);
227
 
228
        i = customRenderingSpotFunctionComboBox->currentIndex();
229
        customRenderingSpotFunctionComboBox->clear();
230
        customRenderingSpotFunctionComboBox->addItem( tr( "Simple Dot" ) );
231
        customRenderingSpotFunctionComboBox->addItem( tr( "Line" ) );
232
        customRenderingSpotFunctionComboBox->addItem( tr( "Round" ) );
233
        customRenderingSpotFunctionComboBox->addItem( tr( "Ellipse" ) );
234
        customRenderingSpotFunctionComboBox->setCurrentIndex(i);
235
        SelLPIcolor = customRenderingColorComboBox->currentText();
236
 
237
        i = solidColorRenderingIntentComboBox->currentIndex();
238
        int j=imageRenderingIntentComboBox->currentIndex();
239
        solidColorRenderingIntentComboBox->clear();
240
        imageRenderingIntentComboBox->clear();
241
        QString tmp_ip[] = { tr("Perceptual"), tr("Relative Colorimetric"), tr("Saturation"), tr("Absolute Colorimetric")};
242
        size_t ar_ip = sizeof(tmp_ip) / sizeof(*tmp_ip);
243
        for (uint a = 0; a < ar_ip; ++a)
244
                solidColorRenderingIntentComboBox->addItem(tmp_ip[a]);
245
        for (uint a = 0; a < ar_ip; ++a)
246
                imageRenderingIntentComboBox->addItem(tmp_ip[a]);
247
        solidColorRenderingIntentComboBox->setCurrentIndex(i);
248
        imageRenderingIntentComboBox->setCurrentIndex(j);
249
}
250
 
251
void Prefs_PDFExport::restoreDefaults(struct ApplicationPrefs *prefsData)
252
{
253
}
254
 
255
void Prefs_PDFExport::restoreDefaults(struct ApplicationPrefs *prefsData, const ProfilesL & PDFXProfiles, bool exporting)
256
{
257
        exportingPDF=exporting;
258
        enablePDFExportTabs(exportingPDF);
259
        AllFonts=prefsData->fontPrefs.AvailFonts;
260
        int unitIndex = prefsData->docSetupPrefs.docUnitIndex;
261
        unitRatio = unitGetRatioFromIndex(unitIndex);
262
        unitChange(unitIndex);
263
        Opts=prefsData->pdfPrefs;
264
        defaultSolidColorRGBProfile=prefsData->colorPrefs.DCMSset.DefaultSolidColorRGBProfile;
265
        defaultPrinterProfile=prefsData->colorPrefs.DCMSset.DefaultPrinterProfile;
266
        exportAllPagesRadioButton->setChecked(true);
267
        enableRangeControls(false);
268
        rotationComboBox->setCurrentIndex(prefsData->pdfPrefs.RotateDeg / 90);
269
        pageMirrorHorizontalToolButton->setChecked(prefsData->pdfPrefs.MirrorH);
270
        pageMirrorVerticalToolButton->setChecked(prefsData->pdfPrefs.MirrorV);
271
        clipToPrinterMarginsCheckBox->setChecked(prefsData->pdfPrefs.doClip);
272
        bool cmsUse = m_doc ? (ScCore->haveCMS() && m_doc->HasCMS) : false;
273
        int newCMSIndex=0;
274
        if (cmsUse)
275
        {
276
                if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X1a)
277
                        newCMSIndex=3;
278
                if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X3)
279
                        newCMSIndex=4;
280
                if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X4)
281
                        newCMSIndex=5;
282
        }
283
        if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_13)
284
                newCMSIndex=0;
285
        if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_14)
286
                newCMSIndex=1;
287
        if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_15)
288
                newCMSIndex=2;
289
        pdfVersionComboBox->setCurrentIndex(newCMSIndex);
290
        pageBindingComboBox->setCurrentIndex(prefsData->pdfPrefs.Binding);
291
        generateThumbnailsCheckBox->setChecked(prefsData->pdfPrefs.Thumbnails);
292
        saveLinkedTextFramesAsArticlesCheckBox->setChecked(prefsData->pdfPrefs.Articles);
293
        includeBookmarksCheckBox->setChecked(prefsData->pdfPrefs.Bookmarks);
294
        includeLayersCheckBox->setChecked(prefsData->pdfPrefs.useLayers);
295
        includeLayersCheckBox->setEnabled(prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_15 || prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X4);
296
 
297
        epsExportResolutionSpinBox->setValue(prefsData->pdfPrefs.Resolution);
298
        embedPDFAndEPSFilesCheckBox->setChecked(prefsData->pdfPrefs.embedPDF);
299
        compressTextAndVectorGraphicsCheckBox->setChecked( prefsData->pdfPrefs.Compress );
300
        imageCompressionMethodComboBox->setCurrentIndex(prefsData->pdfPrefs.CompressMethod);
301
        imageCompressionQualityComboBox->setCurrentIndex(prefsData->pdfPrefs.Quality);
302
        maxResolutionLimitCheckBox->setChecked(prefsData->pdfPrefs.RecalcPic);
303
        maxExportResolutionSpinBox->setValue(prefsData->pdfPrefs.PicRes);
304
        maxExportResolutionSpinBox->setEnabled(prefsData->pdfPrefs.RecalcPic);
305
 
306
        if (m_doc != 0 && exportingPDF)
307
        {
308
//      Build a list of all Fonts used in Annotations;
309
                PageItem *pgit;
310
                QList<PageItem*> allItems;
311
                for (QHash<int, PageItem*>::iterator it = m_doc->FrameItems.begin(); it != m_doc->FrameItems.end(); ++it)
312
                {
313
                        PageItem *currItem = it.value();
314
                        if (currItem->isGroup())
315
                                allItems = currItem->getItemList();
316
                        else
317
                                allItems.append(currItem);
318
                        for (int ii = 0; ii < allItems.count(); ii++)
319
                        {
320
                                pgit = allItems.at(ii);
321
                                if (((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) && (pgit->isAnnotation()) && (pgit->itemText.length() > 0))
322
                                        AnnotationFonts.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), "");
323
                        }
324
                        allItems.clear();
325
                }
326
                for (int a = 0; a < m_doc->MasterItems.count(); ++a)
327
                {
328
                        PageItem *currItem = m_doc->MasterItems.at(a);
329
                        if (currItem->isGroup())
330
                                allItems = currItem->getItemList();
331
                        else
332
                                allItems.append(currItem);
333
                        for (int ii = 0; ii < allItems.count(); ii++)
334
                        {
335
                                pgit = allItems.at(ii);
336
                                if (((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) && (pgit->isAnnotation()) && (pgit->itemText.length() > 0))
337
                                        AnnotationFonts.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), "");
338
                        }
339
                        allItems.clear();
340
                }
341
                for (int a = 0; a < m_doc->DocItems.count(); ++a)
342
                {
343
                        PageItem *currItem = m_doc->DocItems.at(a);
344
                        if (currItem->isGroup())
345
                                allItems = currItem->getItemList();
346
                        else
347
                                allItems.append(currItem);
348
                        for (int ii = 0; ii < allItems.count(); ii++)
349
                        {
350
                                pgit = allItems.at(ii);
351
                                if (((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) && (pgit->isAnnotation()) && (pgit->itemText.length() > 0))
352
                                        AnnotationFonts.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), "");
353
                        }
354
                        allItems.clear();
355
                }
20122 jghali 356
                toSubsetButton->setEnabled(false);
357
                fromSubsetButton->setEnabled(false);
20103 avox 358
 
20122 jghali 359
                if ((Opts.EmbedList.count() == 0) && (Opts.SubsetList.count() == 0) && (Opts.firstUse))
19828 jghali 360
                        EmbedAll();
361
                else
362
                {
20122 jghali 363
                        QStringList docFonts = m_doc->usedFonts().keys();
19828 jghali 364
                        embeddedFontsListWidget->clear();
20122 jghali 365
                        subsettedFontsListWidget->clear();
366
                        for (int fe = 0; fe < docFonts.count(); ++ fe)
19828 jghali 367
                        {
20122 jghali 368
                                QString fontName = docFonts.at(fe);
369
                                if (Opts.EmbedList.contains(fontName))
370
                                        addFontItem(fontName, embeddedFontsListWidget);
371
                                else
372
                                {
373
                                        addFontItem(fontName, subsettedFontsListWidget);
374
                                        if (!Opts.SubsetList.contains(fontName))
375
                                                Opts.SubsetList.append(fontName);
376
                                }
19828 jghali 377
                        }
378
                        QMap<QString, QString>::Iterator itAnn;
379
                        for (itAnn = AnnotationFonts.begin(); itAnn != AnnotationFonts.end(); ++itAnn)
380
                        {
381
                                QList<QListWidgetItem *> itEmbed = embeddedFontsListWidget->findItems(itAnn.key(), Qt::MatchExactly);
382
                                if (itEmbed.count() == 0)
383
                                {
20122 jghali 384
                                        QListWidgetItem* item = addFontItem(itAnn.key(), embeddedFontsListWidget);
385
                                        item->setFlags(Qt::ItemIsEnabled);
19828 jghali 386
                                }
20122 jghali 387
                                QList<QListWidgetItem *> itSubset = subsettedFontsListWidget->findItems(itAnn.key(), Qt::MatchExactly);
388
                                for (int itOut = 0; itOut < itSubset.count(); ++itOut)
19828 jghali 389
                                {
20122 jghali 390
                                        QListWidgetItem* item = itSubset[itOut];
391
                                        delete subsettedFontsListWidget->takeItem(subsettedFontsListWidget->row(item));
19828 jghali 392
                                }
393
                        }
394
                }
395
                enabledEffectsCheckBox->setChecked(Opts.PresentMode);
396
                showPagePreviewsCheckBox->setChecked(false);
397
                effectsPageListWidget->clear();
398
                QString tmp;
399
                for (int pg = 0; pg < m_doc->Pages->count(); ++pg)
400
                {
401
                        effectsPageListWidget->addItem( tr("Page")+" "+tmp.setNum(pg+1));
402
                        EffVal.append(m_doc->Pages->at(pg)->PresentVals);
403
                }
404
                displayDurationSpinBox->setValue(EffVal[0].pageViewDuration);
405
                effectDurationSpinBox->setValue(EffVal[0].pageEffectDuration);
406
                bool df = true;
407
                if ((Opts.displayBookmarks) || (Opts.displayFullscreen) || (Opts.displayLayers) || (Opts.displayThumbs))
408
                        df = false;
409
                if (df)
410
                        useViewerDefaultsRadioButton->setChecked(df);
411
                useFullScreenRadioButton->setChecked(Opts.displayFullscreen);
412
                useBookmarksRadioButton->setChecked(Opts.displayBookmarks);
413
                useThumbnailsRadioButton->setChecked(Opts.displayThumbs);
414
                useLayersRadioButton->setChecked(Opts.displayLayers);
415
                hideViewerToolBarCheckBox->setChecked(Opts.hideToolBar);
416
                hideViewerMenuBarCheckBox->setChecked(Opts.hideMenuBar);
417
                fitViewerWindowCheckBox->setChecked(Opts.fitWindow);
418
                QMap<QString,QString>::Iterator itja;
419
                startupJavascriptComboBox->clear();
420
                startupJavascriptComboBox->addItem( tr("No Script"));
421
                for (itja = m_doc->JavaScripts.begin(); itja != m_doc->JavaScripts.end(); ++itja)
422
                        startupJavascriptComboBox->addItem(itja.key());
423
                if (m_doc->JavaScripts.contains(Opts.openAction))
424
                        setCurrentComboItem(startupJavascriptComboBox, Opts.openAction);
425
                if (Opts.PageLayout == PDFOptions::SinglePage)
426
                        singlePageRadioButton->setChecked(true);
427
                else if (Opts.PageLayout == PDFOptions::OneColumn)
428
                        continuousPagesRadioButton->setChecked(true);
429
                else if (Opts.PageLayout == PDFOptions::TwoColumnLeft)
430
                        doublePageLeftRadioButton->setChecked(true);
431
                else if (Opts.PageLayout == PDFOptions::TwoColumnRight)
432
                        doublePageRightRadioButton->setChecked(true);
433
                if ((Opts.Version == PDFOptions::PDFVersion_15) || (Opts.Version == PDFOptions::PDFVersion_X4))
434
                        useLayersRadioButton->setEnabled(true);
435
                else
436
                        useLayersRadioButton->setEnabled(false);
437
        }
438
 
439
        useEncryptionCheckBox->setChecked( prefsData->pdfPrefs.Encrypt );
440
        passwordOwnerLineEdit->setText(prefsData->pdfPrefs.PassOwner);
441
        passwordUserLineEdit->setText(prefsData->pdfPrefs.PassUser);
442
        allowPrintingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 4 );
443
        allowChangingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 8 );
444
        allowCopyingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 16 );
445
        allowAnnotatingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 32 );
446
        enableSecurityControls(prefsData->pdfPrefs.Encrypt);
447
 
448
        if (prefsData->pdfPrefs.UseRGB)
449
                outputIntentionComboBox->setCurrentIndex(0);
450
        else
451
        {
452
                if (prefsData->pdfPrefs.isGrayscale)
453
                        outputIntentionComboBox->setCurrentIndex(2);
454
                else
455
                        outputIntentionComboBox->setCurrentIndex(1);
456
        }
457
        convertSpotsToProcessCheckBox->setChecked(!prefsData->pdfPrefs.UseSpotColors);
458
 
459
        bleedsWidget->setup(prefsData->pdfPrefs.bleeds, prefsData->docSetupPrefs.pagePositioning, prefsData->docSetupPrefs.docUnitIndex, false, false);
460
        bleedsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth);
461
        bleedsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight);
462
        bleedsWidget->setPageSize(prefsData->docSetupPrefs.pageSize);
463
        bleedsWidget->setMarginPreset(prefsData->docSetupPrefs.marginPreset);
464
//
465
        useCustomRenderingCheckBox->setChecked(prefsData->pdfPrefs.UseLPI);
466
        QMap<QString,LPIData>::Iterator itlp;
467
        customRenderingColorComboBox->clear();
468
        for (itlp = prefsData->pdfPrefs.LPISettings.begin(); itlp != prefsData->pdfPrefs.LPISettings.end(); ++itlp)
469
                customRenderingColorComboBox->addItem( itlp.key() );
470
        customRenderingColorComboBox->setCurrentIndex(0);
471
 
472
        customRenderingFrequencySpinBox->setValue(prefsData->pdfPrefs.LPISettings[customRenderingColorComboBox->currentText()].Frequency);
473
        customRenderingAngleSpinBox->setValue(prefsData->pdfPrefs.LPISettings[customRenderingColorComboBox->currentText()].Angle);
474
        customRenderingSpotFunctionComboBox->setCurrentIndex(prefsData->pdfPrefs.LPISettings[customRenderingColorComboBox->currentText()].SpotFunc);
475
        useSolidColorProfileCheckBox->setChecked(prefsData->pdfPrefs.UseProfiles);
476
        useImageProfileCheckBox->setChecked(prefsData->pdfPrefs.UseProfiles2);
477
        doNotUseEmbeddedImageProfileCheckBox->setChecked(prefsData->pdfPrefs.EmbeddedI);
478
        if ((prefsData->pdfPrefs.UseRGB) || (prefsData->pdfPrefs.isGrayscale))
479
        {
480
                //enableSolidsImagesWidgets(false);
481
                enableProfiles(0);
482
        }
483
        else
484
                enableProfiles(1);
485
        enablePG();
486
        enablePGI();
487
        QString tp(prefsData->pdfPrefs.SolidProf);
488
        if (!ScCore->InputProfiles.contains(tp))
489
        {
490
                if (m_doc != 0 && exportingPDF)
491
                        tp = m_doc->cmsSettings().DefaultSolidColorRGBProfile;
492
                else
493
                        tp = defaultSolidColorRGBProfile;
494
        }
495
        ProfilesL::Iterator itp;
496
        ProfilesL::Iterator itpend=ScCore->InputProfiles.end();
497
        solidColorProfileComboBox->clear();
498
        for (itp = ScCore->InputProfiles.begin(); itp != itpend; ++itp)
499
        {
500
                solidColorProfileComboBox->addItem(itp.key());
501
                if (itp.key() == tp)
502
                        solidColorProfileComboBox->setCurrentIndex(solidColorProfileComboBox->count()-1);
503
        }
504
        int solidIntent = Opts.Intent;
505
        if (Opts.Intent < 0)
506
                solidIntent = 1;
507
        solidColorRenderingIntentComboBox->setCurrentIndex(solidIntent);
508
        QString tp1 = Opts.ImageProf;
509
        if (!ScCore->InputProfiles.contains(tp1))
510
        {
511
                if (m_doc != 0 && exportingPDF)
512
                        tp1 = m_doc->cmsSettings().DefaultSolidColorRGBProfile;
513
                else
514
                        tp1 = defaultSolidColorRGBProfile;
515
        }
516
        ProfilesL::Iterator itp2;
517
        ProfilesL::Iterator itp2end=ScCore->InputProfiles.end();
518
        imageProfileComboBox->clear();
519
        for (itp2 = ScCore->InputProfiles.begin(); itp2 != itp2end; ++itp2)
520
        {
521
                imageProfileComboBox->addItem(itp2.key());
522
                if (itp2.key() == tp1)
523
                        imageProfileComboBox->setCurrentIndex(imageProfileComboBox->count()-1);
524
        }
525
        int imageIntent = Opts.Intent2;
526
        if (imageIntent < 0)
527
                imageIntent = 0;
528
        imageRenderingIntentComboBox->setCurrentIndex(imageIntent);
529
        if (!cmsUse)
530
        {
531
                //Disabling vis hiding
532
                //setSolidsImagesWidgetsShown(false);
533
                enableSolidsImagesWidgets(false);
534
        }
535
 
536
        ProfilesL::const_iterator itp3;
537
        QString tp3(Opts.PrintProf);
538
        if (!PDFXProfiles.contains(tp3))
539
        {
540
                if (m_doc != 0 && exportingPDF)
541
                        tp3 = m_doc->cmsSettings().DefaultPrinterProfile;
542
                else
543
                        tp3 = defaultPrinterProfile;
544
        }
545
        pdfx3OutputProfileComboBox->clear();
546
        for (itp3 = PDFXProfiles.constBegin(); itp3 != PDFXProfiles.constEnd(); ++itp3)
547
        {
548
                pdfx3OutputProfileComboBox->addItem(itp3.key());
549
                if (itp3.key() == tp3)
550
                        pdfx3OutputProfileComboBox->setCurrentIndex(pdfx3OutputProfileComboBox->count()-1);
551
        }
552
 
553
        if (!Opts.Info.isEmpty())
554
                pdfx3InfoStringLineEdit->setText(Opts.Info);
555
        else
556
        {
557
                if (m_doc != 0 && exporting)
558
                {
559
                        QFileInfo fi(m_doc->DocName);
560
                        pdfx3InfoStringLineEdit->setText(fi.fileName());
561
                }
562
                else
563
                        pdfx3InfoStringLineEdit->setText( tr("InfoString"));
564
        }
565
 
566
        if (m_doc != 0 && exportingPDF)
567
        {
568
                useDocumentBleedsCheckBox->setChecked(Opts.useDocBleeds);
569
                doDocBleeds();
570
        }
571
        else
572
                useDocumentBleedsCheckBox->hide();
573
 
574
        markLengthSpinBox->setValue(prefsData->pdfPrefs.markLength*unitRatio);
575
        markOffsetSpinBox->setValue(prefsData->pdfPrefs.markOffset*unitRatio);
576
        printCropMarksCheckBox->setChecked(prefsData->pdfPrefs.cropMarks);
577
        printBleedMarksCheckBox->setChecked(prefsData->pdfPrefs.bleedMarks);
578
        printRegistrationMarksCheckBox->setChecked(prefsData->pdfPrefs.registrationMarks);
579
        printColorBarsCheckBox->setChecked(prefsData->pdfPrefs.colorMarks);
580
        printPageInfoCheckBox->setChecked(prefsData->pdfPrefs.docInfoMarks);
581
        if (!cmsUse)
582
                enablePDFXWidgets(false);
583
        if (cmsUse && (Opts.Version == PDFOptions::PDFVersion_X1a) && (!PDFXProfiles.isEmpty()))
584
                enablePDFX(3);
585
        else if (cmsUse && (Opts.Version == PDFOptions::PDFVersion_X3) && (!PDFXProfiles.isEmpty()))
586
                enablePDFX(4);
587
        else if (cmsUse && (Opts.Version == PDFOptions::PDFVersion_X4) && (!PDFXProfiles.isEmpty()))
588
                enablePDFX(5);
589
        else
590
                enablePDFXWidgets(false);
591
 
592
        if (m_doc != 0  && exportingPDF)
593
        {
594
                effectTypeComboBox->clear();
595
                effectTypeComboBox->addItem( tr("No Effect"));
596
                effectTypeComboBox->addItem( tr("Blinds"));
597
                effectTypeComboBox->addItem( tr("Box"));
598
                effectTypeComboBox->addItem( tr("Dissolve"));
599
                effectTypeComboBox->addItem( tr("Glitter"));
600
                effectTypeComboBox->addItem( tr("Split"));
601
                effectTypeComboBox->addItem( tr("Wipe"));
602
                if (Opts.Version == PDFOptions::PDFVersion_15)
603
                {
604
                        effectTypeComboBox->addItem( tr("Push"));
605
                        effectTypeComboBox->addItem( tr("Cover"));
606
                        effectTypeComboBox->addItem( tr("Uncover"));
607
                        effectTypeComboBox->addItem( tr("Fade"));
608
                }
609
                effectsPageListWidget->setCurrentRow(0);
610
                SetEffOpts(0);
611
                effectsPageListWidget->setEnabled(false);
612
                enableEffects(false);
613
                showPagePreviewsCheckBox->setEnabled(false);
614
                if (enabledEffectsCheckBox->isChecked())
615
                {
616
                        displayDurationSpinBox->setValue(EffVal[0].pageViewDuration);
617
                        effectDurationSpinBox->setValue(EffVal[0].pageEffectDuration);
618
                        effectTypeComboBox->setCurrentIndex(EffVal[0].effectType);
619
                        effectMovingDirectionComboBox->setCurrentIndex(EffVal[0].Dm);
620
                        effectInOutComboBox->setCurrentIndex(EffVal[0].M);
621
                        effectDirectionComboBox->setCurrentIndex(EffVal[0].Di);
622
                        SetEffOpts(effectTypeComboBox->currentIndex());
623
                }
624
                /* Using margin widget, is this necessary?
625
                if (m_doc->currentPageLayout != 0)
626
                {
627
                        BleedTxt3->setText( tr( "Inside:" ) );
628
                        BleedTxt4->setText( tr( "Outside:" ) );
629
                }
630
                */
631
        }
632
 
633
        if (m_doc != 0 && exportingPDF)
634
        {
20122 jghali 635
                connect(embedAllButton, SIGNAL(clicked()), this, SLOT(EmbedAll()));
636
                connect(embeddedFontsListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SelEFont(QListWidgetItem*)));
637
                connect(subsetAllButton, SIGNAL(clicked()), this, SLOT(SubsetAll()));
638
                connect(subsettedFontsListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SelSFont(QListWidgetItem*)));
639
                connect(toSubsetButton, SIGNAL(clicked()), this, SLOT(PutToSubset()));
640
                connect(fromSubsetButton, SIGNAL(clicked()), this, SLOT(RemoveSubset()));
19828 jghali 641
                connect(showPagePreviewsCheckBox, SIGNAL(clicked()), this, SLOT(PagePr()));
642
                connect(effectsPageListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(SetPgEff()));
643
                connect(effectTypeComboBox, SIGNAL(activated(int)), this, SLOT(SetEffOpts(int)));
644
                connect(effectDirectionComboBox, SIGNAL(activated(int)), this, SLOT(ValidDI(int)));
645
                connect(enabledEffectsCheckBox, SIGNAL(clicked()), this, SLOT(DoEffects()));
646
                connect(applyEffectToAllPagesPushButton, SIGNAL(clicked()), this, SLOT(EffectOnAll()));
647
//              connect(pdfx3InfoStringLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(checkInfo()));
648
//              connect(pdfx3InfoStringLineEdit, SIGNAL(editingFinished()), this, SLOT(checkInfo()));
649
                connect(useDocumentBleedsCheckBox, SIGNAL(clicked()), this, SLOT(doDocBleeds()));
650
 
20122 jghali 651
                embedAllButton->setToolTip( "<qt>" + tr( "Embed fonts into the PDF. Embedding the fonts will preserve the layout and appearance of your document." ) + "</qt>");
19828 jghali 652
                enabledEffectsCheckBox->setToolTip( "<qt>" + tr( "Enables presentation effects when using Adobe&#174; Reader&#174; and other PDF viewers which support this in full screen mode." ) + "</qt>");
653
                showPagePreviewsCheckBox->setToolTip( "<qt>" + tr( "Show page previews of each page listed above." ) + "</qt>");
654
                effectDurationSpinBox->setToolTip( "<qt>" + tr( "Length of time the page is shown before the presentation starts on the selected page. Setting 0 will disable automatic page transition." ) + "</qt>" );
655
                effectDurationSpinBox->setToolTip( "<qt>" + tr( "Length of time the effect runs. A shorter time will speed up the effect, a longer one will slow it down." ) + "</qt>" );
656
                effectTypeComboBox->setToolTip( "<qt>" + tr( "Type of the display effect." ) + "</qt>" );
657
                effectMovingDirectionComboBox->setToolTip( "<qt>" + tr( "Direction of the effect of moving lines for the split and blind effects." ) + "</qt>" );
658
                effectInOutComboBox->setToolTip( "<qt>" + tr( "Starting position for the box and split effects." ) + "</qt>" );
659
                effectDirectionComboBox->setToolTip( "<qt>" + tr( "Direction of the glitter or wipe effects." ) + "</qt>" );
660
                applyEffectToAllPagesPushButton->setToolTip( "<qt>" + tr( "Apply the selected effect to all pages." ) + "</qt>" );
20122 jghali 661
                subsetAllButton->setToolTip( "<qt>" + tr("Embed only subset fonts with glyphs used in the document into the PDF.") + "</qt>");
19828 jghali 662
                singlePageRadioButton->setToolTip( "<qt>" + tr( "Show the document in single page mode" ) + "</qt>" );
663
                continuousPagesRadioButton->setToolTip( "<qt>" + tr( "Show the document in single page mode with the pages displayed continuously end to end like a scroll" ) + "</qt>" );
664
                doublePageLeftRadioButton->setToolTip( "<qt>" + tr( "Show the document with facing pages, starting with the first page displayed on the left" ) + "</qt>" );
665
                doublePageRightRadioButton->setToolTip( "<qt>" + tr( "Show the document with facing pages, starting with the first page displayed on the right" ) + "</qt>" );
666
                useViewerDefaultsRadioButton->setToolTip( "<qt>" + tr( "Use the viewer's defaults or the user's preferences if set differently from the viewer defaults" ) + "</qt>" );
667
                useFullScreenRadioButton->setToolTip( "<qt>" + tr( "Enables viewing the document in full screen" ) + "</qt>" );
668
                useBookmarksRadioButton->setToolTip( "<qt>" + tr( "Display the bookmarks upon opening" ) + "</qt>" );
669
                useThumbnailsRadioButton->setToolTip( "<qt>" + tr( "Display the page thumbnails upon opening" ) + "</qt>" );
670
                useLayersRadioButton->setToolTip( "<qt>" + tr( "Forces the displaying of layers. Useful only for PDF 1.5+." ) + "</qt>" );
671
                hideViewerToolBarCheckBox->setToolTip( "<qt>" + tr( "Hides the Tool Bar which has selection and other editing capabilities" ) + "</qt>" );
672
                hideViewerMenuBarCheckBox->setToolTip( "<qt>" + tr( "Hides the Menu Bar for the viewer, the PDF will display in a plain window. " ) + "</qt>" );
673
                fitViewerWindowCheckBox->setToolTip( "<qt>" + tr( "Fit the document page or pages to the available space in the viewer window." ) + "</qt>" );
674
        }
675
}
676
 
677
 
678
void Prefs_PDFExport::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
679
{
680
        prefsData->pdfPrefs.Thumbnails = generateThumbnailsCheckBox->isChecked();
681
        prefsData->pdfPrefs.Compress = compressTextAndVectorGraphicsCheckBox->isChecked();
682
        prefsData->pdfPrefs.CompressMethod = (PDFOptions::PDFCompression) imageCompressionMethodComboBox->currentIndex();
683
        prefsData->pdfPrefs.Quality = imageCompressionQualityComboBox->currentIndex();
684
        prefsData->pdfPrefs.Resolution = epsExportResolutionSpinBox->value();
685
        prefsData->pdfPrefs.RecalcPic = maxResolutionLimitCheckBox->isChecked();
686
        prefsData->pdfPrefs.PicRes = maxExportResolutionSpinBox->value();
687
        prefsData->pdfPrefs.embedPDF = embedPDFAndEPSFilesCheckBox->isChecked();
688
        prefsData->pdfPrefs.Bookmarks = includeBookmarksCheckBox->isChecked();
689
        prefsData->pdfPrefs.Binding = pageBindingComboBox->currentIndex();
690
        prefsData->pdfPrefs.MirrorH = pageMirrorHorizontalToolButton->isChecked();
691
        prefsData->pdfPrefs.MirrorV = pageMirrorVerticalToolButton->isChecked();
692
        prefsData->pdfPrefs.RotateDeg = rotationComboBox->currentIndex() * 90;
693
        prefsData->pdfPrefs.Articles = saveLinkedTextFramesAsArticlesCheckBox->isChecked();
20122 jghali 694
        prefsData->pdfPrefs.FontEmbedding = (PDFOptions::PDFFontEmbedding) fontEmbeddingCombo->currentIndex();
19828 jghali 695
        prefsData->pdfPrefs.Encrypt = useEncryptionCheckBox->isChecked();
696
        prefsData->pdfPrefs.UseLPI = useCustomRenderingCheckBox->isChecked();
697
        prefsData->pdfPrefs.UseSpotColors = !convertSpotsToProcessCheckBox->isChecked();
698
        prefsData->pdfPrefs.doMultiFile = false;
699
        prefsData->pdfPrefs.cropMarks  = printCropMarksCheckBox->isChecked();
700
        prefsData->pdfPrefs.bleedMarks = printBleedMarksCheckBox->isChecked();
701
        prefsData->pdfPrefs.registrationMarks = printRegistrationMarksCheckBox->isChecked();
702
        prefsData->pdfPrefs.colorMarks = printColorBarsCheckBox->isChecked();
703
        prefsData->pdfPrefs.docInfoMarks = printPageInfoCheckBox->isChecked();
704
        prefsData->pdfPrefs.markLength   = markLengthSpinBox->value() / unitRatio;
705
        prefsData->pdfPrefs.markOffset   = markOffsetSpinBox->value() / unitRatio;
706
        prefsData->pdfPrefs.useDocBleeds = useDocumentBleedsCheckBox->isChecked();
707
        prefsData->pdfPrefs.bleeds = bleedsWidget->margins();
708
        prefsData->pdfPrefs.doClip = clipToPrinterMarginsCheckBox->isChecked();
709
        if (useEncryptionCheckBox->isChecked())
710
        {
711
                int Perm = -64;
712
                if (pdfVersionComboBox->currentIndex() == 1)
713
                        Perm &= ~0x00240000;
714
                if (allowPrintingCheckBox->isChecked())
715
                        Perm += 4;
716
                if (allowChangingCheckBox->isChecked())
717
                        Perm += 8;
718
                if (allowCopyingCheckBox->isChecked())
719
                        Perm += 16;
720
                if (allowAnnotatingCheckBox->isChecked())
721
                        Perm += 32;
722
                prefsData->pdfPrefs.Permissions = Perm;
723
                prefsData->pdfPrefs.PassOwner = passwordOwnerLineEdit->text();
724
                prefsData->pdfPrefs.PassUser = passwordUserLineEdit->text();
725
        }
726
        if (pdfVersionComboBox->currentIndex() == 0)
727
                prefsData->pdfPrefs.Version = PDFOptions::PDFVersion_13;
728
        if (pdfVersionComboBox->currentIndex() == 1)
729
                prefsData->pdfPrefs.Version = PDFOptions::PDFVersion_14;
730
        if (pdfVersionComboBox->currentIndex() == 2)
731
                prefsData->pdfPrefs.Version = PDFOptions::PDFVersion_15;
732
        if (pdfVersionComboBox->currentIndex() == 3)
733
                prefsData->pdfPrefs.Version = PDFOptions::PDFVersion_X1a;
734
        if (pdfVersionComboBox->currentIndex() == 4)
735
                prefsData->pdfPrefs.Version = PDFOptions::PDFVersion_X3;
736
        if (pdfVersionComboBox->currentIndex() == 5)
737
                prefsData->pdfPrefs.Version = PDFOptions::PDFVersion_X4;
738
        if (outputIntentionComboBox->currentIndex() == 0)
739
        {
740
                prefsData->pdfPrefs.isGrayscale = false;
741
                prefsData->pdfPrefs.UseRGB = true;
742
                prefsData->pdfPrefs.UseProfiles = false;
743
                prefsData->pdfPrefs.UseProfiles2 = false;
744
        }
745
        else
746
        {
747
                if (outputIntentionComboBox->currentIndex() == 2)
748
                {
749
                        prefsData->pdfPrefs.isGrayscale = true;
750
                        prefsData->pdfPrefs.UseRGB = false;
751
                        prefsData->pdfPrefs.UseProfiles = false;
752
                        prefsData->pdfPrefs.UseProfiles2 = false;
753
                }
754
                else
755
                {
756
                        prefsData->pdfPrefs.isGrayscale = false;
757
                        prefsData->pdfPrefs.UseRGB = false;
758
                        if (/*CMSuse*/ ScCore->haveCMS())
759
                        {
760
                                prefsData->pdfPrefs.UseProfiles = useSolidColorProfileCheckBox->isChecked();
761
                                prefsData->pdfPrefs.UseProfiles2 = useImageProfileCheckBox->isChecked();
762
                                prefsData->pdfPrefs.Intent = solidColorRenderingIntentComboBox->currentIndex();
763
                                prefsData->pdfPrefs.Intent2 = imageRenderingIntentComboBox->currentIndex();
764
                                prefsData->pdfPrefs.EmbeddedI = doNotUseEmbeddedImageProfileCheckBox->isChecked();
765
                                prefsData->pdfPrefs.SolidProf = solidColorProfileComboBox->currentText();
766
                                prefsData->pdfPrefs.ImageProf = imageProfileComboBox->currentText();
767
                                prefsData->pdfPrefs.PrintProf = pdfx3OutputProfileComboBox->currentText();
768
                        }
769
                }
770
        }
771
}
772
 
773
 
774
void Prefs_PDFExport::SelLPIcol(int c)
775
{
776
        // XXX Optionen or Opts changed here
777
        Opts.LPISettings[SelLPIcolor].Frequency = customRenderingFrequencySpinBox->value();
778
        Opts.LPISettings[SelLPIcolor].Angle = customRenderingAngleSpinBox->value();
779
        Opts.LPISettings[SelLPIcolor].SpotFunc = customRenderingSpotFunctionComboBox->currentIndex();
780
        customRenderingFrequencySpinBox->setValue(Opts.LPISettings[customRenderingColorComboBox->itemText(c)].Frequency);
781
        customRenderingAngleSpinBox->setValue(Opts.LPISettings[customRenderingColorComboBox->itemText(c)].Angle);
782
        customRenderingSpotFunctionComboBox->setCurrentIndex(Opts.LPISettings[customRenderingColorComboBox->itemText(c)].SpotFunc);
783
        SelLPIcolor = customRenderingColorComboBox->itemText(c);
784
}
785
 
786
void Prefs_PDFExport::enableRangeControls(bool enabled)
787
{
788
        exportPageListLineEdit->setEnabled( enabled );
789
        exportRangeMorePushButton->setEnabled( enabled );
790
        if (enabled == false)
791
                includeBookmarksCheckBox->setChecked(false);
792
}
793
 
794
void Prefs_PDFExport::enableSecurityControls(bool enabled)
795
{
796
        passwordOwnerLineEdit->setEnabled(enabled);
797
        passwordUserLineEdit->setEnabled(enabled);
798
        allowPrintingCheckBox->setEnabled(enabled);
799
        allowChangingCheckBox->setEnabled(enabled);
800
        allowCopyingCheckBox->setEnabled(enabled);
801
        allowAnnotatingCheckBox->setEnabled(enabled);
802
}
803
 
804
 
805
void Prefs_PDFExport::enableCMS(bool enabled)
806
{
807
        cmsEnabled=enabled;
808
        addPDFVersions(enabled);
809
        enableProfiles(enabled);
810
}
811
 
812
void Prefs_PDFExport::enablePDFExportTabs(bool enabled)
813
{
814
        if (!enabled)
815
        {
816
                tabWidget->removeTab(tabWidget->indexOf(tabFonts));//Fonts
817
                tabWidget->removeTab(tabWidget->indexOf(tabExtras));//Extras
818
                tabWidget->removeTab(tabWidget->indexOf(tabViewer));//Viewer
819
        }
820
}
821
 
822
void Prefs_PDFExport::createPageNumberRange()
823
{
824
        if (m_doc!=0)
825
        {
826
                CreateRange cr(exportPageListLineEdit->text(), m_doc->DocPages.count(), this);
827
                if (cr.exec())
828
                {
829
                        CreateRangeData crData;
830
                        cr.getCreateRangeData(crData);
831
                        exportPageListLineEdit->setText(crData.pageRange);
832
                        return;
833
                }
834
        }
835
        exportPageListLineEdit->setText(QString::null);
836
}
837
 
838
void Prefs_PDFExport::setMaximumResolution()
839
{
840
        if (maxResolutionLimitCheckBox->isChecked())
841
        {
842
                maxExportResolutionSpinBox->setEnabled(true);
843
                if (maxExportResolutionSpinBox->value() > epsExportResolutionSpinBox->value())
844
                        maxExportResolutionSpinBox->setValue(epsExportResolutionSpinBox->value());
845
        }
846
        else
847
                maxExportResolutionSpinBox->setEnabled(false);
848
}
849
 
850
void Prefs_PDFExport::enableProfiles(int i)
851
{
852
        enableLPI(i);
853
        bool setter = false;
854
        if (i == 1 && pdfVersionComboBox->currentIndex() != 3)
855
                setter = true;
856
        enableSolidsImagesWidgets(setter);
857
}
858
 
859
void Prefs_PDFExport::enableLPI(int i)
860
{
861
        if (i == 1)
862
        {
863
                QString tp(Opts.SolidProf);
864
                if (!ScCore->InputProfiles.contains(tp))
865
                {
866
                        if (m_doc != 0)
867
                                tp = m_doc->cmsSettings().DefaultSolidColorRGBProfile;
868
                        else
869
                                tp = defaultSolidColorRGBProfile;
870
                }
871
                solidColorProfileComboBox->clear();
872
                ProfilesL::Iterator itp;
873
                ProfilesL::Iterator itpend=ScCore->InputProfiles.end();
874
                for (itp = ScCore->InputProfiles.begin(); itp != itpend; ++itp)
875
                {
876
                        solidColorProfileComboBox->addItem(itp.key());
877
                        if (itp.key() == tp)
878
                        {
879
                                if (cmsEnabled)
880
                                        solidColorProfileComboBox->setCurrentIndex(solidColorProfileComboBox->count()-1);
881
                        }
882
                }
883
                if (cmsEnabled)
884
                        solidColorRenderingIntentComboBox->setCurrentIndex(Opts.Intent);
885
                QString tp1 = Opts.ImageProf;
886
                if (!ScCore->InputProfiles.contains(tp1))
887
                {
888
                        if (m_doc != 0)
889
                                tp1 = m_doc->cmsSettings().DefaultSolidColorRGBProfile;
890
                        else
891
                                tp1 = defaultSolidColorRGBProfile;
892
                }
893
                imageProfileComboBox->clear();
894
                ProfilesL::Iterator itp2;
895
                ProfilesL::Iterator itp2end=ScCore->InputProfiles.end();
896
                for (itp2 = ScCore->InputProfiles.begin(); itp2 != itp2end; ++itp2)
897
                {
898
                        imageProfileComboBox->addItem(itp2.key());
899
                        if (itp2.key() == tp1)
900
                        {
901
                                if (cmsEnabled)
902
                                        imageProfileComboBox->setCurrentIndex(imageProfileComboBox->count()-1);
903
                        }
904
                }
905
                if (cmsEnabled)
906
                        imageRenderingIntentComboBox->setCurrentIndex(Opts.Intent2);
907
                //Disabling vs hiding
908
                enableSolidsImagesWidgets(cmsEnabled);
909
                convertSpotsToProcessCheckBox->setEnabled(true);
910
                if (m_doc!=0)
911
                {
912
                        useCustomRenderingCheckBox->setEnabled(true);
913
                        enableCustomRenderingWidgets(useCustomRenderingCheckBox->isChecked());
914
                }
915
        }
916
        else
917
        {
918
                convertSpotsToProcessCheckBox->setEnabled(false);
919
                useCustomRenderingCheckBox->setEnabled(false);
920
                enableCustomRenderingWidgets(false);
921
        }
922
}
923
 
924
 
925
void Prefs_PDFExport::enableLPI2()
926
{
927
        if (m_doc!=0)
928
                enableCustomRenderingWidgets(useCustomRenderingCheckBox->isChecked());
929
}
930
 
931
void Prefs_PDFExport::setCustomRenderingWidgetsShown(bool visible)
932
{
933
        useCustomRenderingCheckBox->setVisible(visible);
934
        customRenderingColorComboBox->setVisible(visible);
935
        customRenderingFrequencySpinBox->setVisible(visible);
936
        customRenderingAngleSpinBox->setVisible(visible);
937
        customRenderingSpotFunctionComboBox->setVisible(visible);
938
}
939
 
940
void Prefs_PDFExport::enableCustomRenderingWidgets(bool enabled)
941
{
942
        customRenderingColorComboBox->setEnabled(enabled);
943
        customRenderingFrequencySpinBox->setEnabled(enabled);
944
        customRenderingAngleSpinBox->setEnabled(enabled);
945
        customRenderingSpotFunctionComboBox->setEnabled(enabled);
946
}
947
 
948
void Prefs_PDFExport::setSolidsImagesWidgetsShown(bool visible)
949
{
950
        solidColorsLabel->setVisible(visible);
951
        solidColorsLine->setVisible(visible);
952
        useSolidColorProfileCheckBox->setVisible(visible);
953
        solidColorProfileComboBox->setVisible(visible);
954
        solidColorRenderingIntentComboBox->setVisible(visible);
955
        imagesLabel->setVisible(visible);
956
        imagesLine->setVisible(visible);
957
        useImageProfileCheckBox->setVisible(visible);
958
        doNotUseEmbeddedImageProfileCheckBox->setVisible(visible);
959
        imageProfileComboBox->setVisible(visible);
960
        imageRenderingIntentComboBox->setVisible(visible);
961
}
962
 
963
void Prefs_PDFExport::enableSolidsImagesWidgets(bool enabled)
964
{
965
        //if we want to show/hide instead
966
        //setSolidsImagesWidgetsShown(enabled);
967
        useSolidColorProfileCheckBox->setEnabled(enabled);
968
        solidColorProfileComboBox->setEnabled(enabled);
969
        solidColorRenderingIntentComboBox->setEnabled(enabled);
970
        useImageProfileCheckBox->setEnabled(enabled);
971
        doNotUseEmbeddedImageProfileCheckBox->setEnabled(enabled);
972
        imageProfileComboBox->setEnabled(enabled);
973
        imageRenderingIntentComboBox->setEnabled(enabled);
974
}
975
 
976
void Prefs_PDFExport::enablePDFXWidgets(bool enabled)
977
{
978
        pdfx3OutputProfileComboBox->setEnabled(enabled);
979
        pdfx3InfoStringLineEdit->setEnabled(enabled);
980
}
981
 
982
 
983
void Prefs_PDFExport::enablePGI()
984
{
985
        bool setter=false;
986
        if (useImageProfileCheckBox->isChecked())
987
                setter = doNotUseEmbeddedImageProfileCheckBox->isChecked() ? true : false;
988
        imageProfileComboBox->setEnabled(setter);
989
        imageRenderingIntentComboBox->setEnabled(setter);
990
        doNotUseEmbeddedImageProfileCheckBox->setEnabled(useImageProfileCheckBox->isChecked());
991
}
992
 
993
void Prefs_PDFExport::enablePGI2()
994
{
995
        bool setter = doNotUseEmbeddedImageProfileCheckBox->isChecked() ? true : false;
996
        imageProfileComboBox->setEnabled(setter);
997
        imageRenderingIntentComboBox->setEnabled(setter);
998
}
999
 
1000
void Prefs_PDFExport::enablePG()
1001
{
1002
        bool setter = useSolidColorProfileCheckBox->isChecked() ? true : false;
1003
 
1004
        solidColorProfileComboBox->setEnabled(setter);
1005
        solidColorRenderingIntentComboBox->setEnabled(setter);
1006
}
1007
 
1008
void Prefs_PDFExport::enablePDFX(int i)
1009
{
1010
        includeLayersCheckBox->setEnabled((i == 2) || (i == 5));
1011
        if (useLayersRadioButton)
1012
                useLayersRadioButton->setEnabled((i == 2) || (i == 5));
1013
        if (m_doc != 0 && exportingPDF)
1014
        {
1015
                int currentEff = effectTypeComboBox->currentIndex();
1016
                disconnect(effectTypeComboBox, SIGNAL(activated(int)), this, SLOT(SetEffOpts(int)));
1017
                effectTypeComboBox->clear();
1018
                effectTypeComboBox->addItem( tr("No Effect"));
1019
                effectTypeComboBox->addItem( tr("Blinds"));
1020
                effectTypeComboBox->addItem( tr("Box"));
1021
                effectTypeComboBox->addItem( tr("Dissolve"));
1022
                effectTypeComboBox->addItem( tr("Glitter"));
1023
                effectTypeComboBox->addItem( tr("Split"));
1024
                effectTypeComboBox->addItem( tr("Wipe"));
1025
                if (i == 2)
1026
                {
1027
                        effectTypeComboBox->addItem( tr("Push"));
1028
                        effectTypeComboBox->addItem( tr("Cover"));
1029
                        effectTypeComboBox->addItem( tr("Uncover"));
1030
                        effectTypeComboBox->addItem( tr("Fade"));
1031
                        effectTypeComboBox->setCurrentIndex(currentEff);
1032
                }
1033
                else
1034
                {
1035
                        if (currentEff > 6)
1036
                        {
1037
                                currentEff = 0;
1038
                                effectTypeComboBox->setCurrentIndex(0);
1039
                                SetEffOpts(0);
1040
                                for (int pg = 0; pg<m_doc->Pages->count(); ++pg)
1041
                                {
1042
                                        if (EffVal[pg].effectType > 6)
1043
                                                EffVal[pg].effectType = 0;
1044
                                }
1045
                        }
1046
                        else
1047
                                effectTypeComboBox->setCurrentIndex(currentEff);
1048
                }
1049
                connect(effectTypeComboBox, SIGNAL(activated(int)), this, SLOT(SetEffOpts(int)));
1050
        }
1051
 
1052
        if (i < 3)  // not PDF/X
1053
        {
20122 jghali 1054
                fontEmbeddingCombo->setEnabled(true);
19828 jghali 1055
                enablePDFXWidgets(false);
1056
                tabWidget->setTabEnabled(2, true);
1057
                outputIntentionComboBox->setEnabled(true);
1058
                useImageProfileCheckBox->setEnabled(true);
1059
                emit hasInfo();
1060
                if (m_doc != 0 && exportingPDF)
1061
                {
1062
                        enabledEffectsCheckBox->setEnabled(true);
20122 jghali 1063
                        embedAllButton->setEnabled(true);
19828 jghali 1064
                }
1065
 
1066
                return;
1067
        }
1068
        // PDF/X is selected
1069
        disconnect(outputIntentionComboBox, SIGNAL(activated(int)), this, SLOT(enableProfiles(int)));
1070
        outputIntentionComboBox->setCurrentIndex(1);
1071
        outputIntentionComboBox->setEnabled(false);
1072
        enableProfiles(1);
1073
        if ((i == 4) || (i == 5)) // X3 or X4, enforcing color profiles on images
1074
        {
1075
                useImageProfileCheckBox->setChecked(true);
1076
                useImageProfileCheckBox->setEnabled(false);
1077
        }
1078
        if (m_doc != 0 && exportingPDF)
1079
        {
1080
//              EmbedFonts->setChecked(true);
1081
                EmbedAll();
1082
                enabledEffectsCheckBox->setChecked(false);
1083
                enabledEffectsCheckBox->setEnabled(false);
1084
//              EmbedFonts->setEnabled(false);
1085
                if (pdfx3InfoStringLineEdit->text().isEmpty())
1086
                        emit noInfo();
1087
                else
1088
                        emit hasInfo();
1089
        }
20122 jghali 1090
 
1091
        fontEmbeddingCombo->setCurrentIndex(0);
1092
        fontEmbeddingCombo->setEnabled(false);
1093
 
1094
        embeddedFontsListWidget->setEnabled(true);
1095
        embedAllButton->setEnabled(true);
1096
        subsettedFontsListWidget->setEnabled(true);
1097
        subsetAllButton->setEnabled(true);
1098
        toSubsetButton->setEnabled(true);
1099
        fromSubsetButton->setEnabled(true);
1100
 
19828 jghali 1101
        enablePGI();
1102
        pdfx3OutputProfileComboBox->setEnabled(true);
1103
        pdfx3InfoStringLineEdit->setEnabled(true);
1104
        tabWidget->setTabEnabled(2, false);
1105
        connect(outputIntentionComboBox, SIGNAL(activated(int)), this, SLOT(enableProfiles(int)));
1106
}
1107
 
1108
void Prefs_PDFExport::addPDFVersions(bool addPDFXStrings)
1109
{
1110
        disconnect(pdfVersionComboBox, SIGNAL(activated(int)), this, SLOT(enablePDFX(int)));
1111
        int i = pdfVersionComboBox->currentIndex();
1112
        pdfVersionComboBox->clear();
1113
        pdfVersionComboBox->addItem("PDF 1.3 (Acrobat 4)");
1114
        pdfVersionComboBox->addItem("PDF 1.4 (Acrobat 5)");
1115
        pdfVersionComboBox->addItem("PDF 1.5 (Acrobat 6)");
1116
        if (addPDFXStrings)
1117
        {
1118
                pdfVersionComboBox->addItem("PDF/X-1a");
1119
                pdfVersionComboBox->addItem("PDF/X-3");
1120
                pdfVersionComboBox->addItem("PDF/X-4");
1121
        }
1122
        else
1123
                i=qMin(i,2);
1124
        pdfVersionComboBox->setCurrentIndex(i);
1125
        connect(pdfVersionComboBox, SIGNAL(activated(int)), this, SLOT(enablePDFX(int)));
1126
}
1127
 
1128
 
1129
void Prefs_PDFExport::enableEffects(bool enabled)
1130
{
1131
        effectsPageListWidget->setEnabled(enabled);
1132
        showPagePreviewsCheckBox->setEnabled(enabled);
1133
        displayDurationSpinBox->setEnabled(enabled);
1134
        effectDurationSpinBox->setEnabled(enabled);
1135
        effectTypeComboBox->setEnabled(enabled);
1136
        if (enabled)
1137
                SetEffOpts(effectTypeComboBox->currentIndex());
1138
        else
1139
        {
1140
                effectMovingDirectionComboBox->setEnabled(false);
1141
                effectInOutComboBox->setEnabled(false);
1142
                effectDirectionComboBox->setEnabled(false);
1143
                applyEffectToAllPagesPushButton->setEnabled(false);
1144
        }
1145
}
1146
 
20122 jghali 1147
void Prefs_PDFExport::EmbedAll()
20103 avox 1148
{
20122 jghali 1149
        embeddedFontsListWidget->clear();
1150
        subsettedFontsListWidget->clear();
1151
        toSubsetButton->setEnabled(false);
1152
        fromSubsetButton->setEnabled(false);
20103 avox 1153
 
20122 jghali 1154
        QStringList docFonts;
1155
        if (m_doc)
1156
                docFonts = m_doc->usedFonts().keys();
1157
 
1158
        for (int a=0; a < docFonts.count(); ++a)
19828 jghali 1159
        {
20122 jghali 1160
                QString fontName = docFonts.at(a);
1161
                if (!AllFonts[fontName].subset())
19828 jghali 1162
                {
20122 jghali 1163
                        QListWidgetItem* item = addFontItem(fontName, embeddedFontsListWidget);
19828 jghali 1164
                        if (AnnotationFonts.contains(item->text()))
20122 jghali 1165
                                item->setFlags(Qt::ItemIsEnabled);
19828 jghali 1166
                }
20122 jghali 1167
                else if (AnnotationFonts.contains(fontName))
1168
                {
1169
                        QListWidgetItem* item = addFontItem(fontName, embeddedFontsListWidget);
1170
                        item->setFlags(Qt::ItemIsEnabled);
1171
                }
19828 jghali 1172
                else
1173
                {
20122 jghali 1174
                        addFontItem(fontName, subsettedFontsListWidget);
19828 jghali 1175
                }
1176
        }
1177
}
1178
 
20122 jghali 1179
void Prefs_PDFExport::SubsetAll()
19828 jghali 1180
{
1181
        embeddedFontsListWidget->clear();
20122 jghali 1182
        subsettedFontsListWidget->clear();
1183
        toSubsetButton->setEnabled(false);
1184
        fromSubsetButton->setEnabled(false);
1185
 
1186
        QStringList docFonts;
1187
        if (m_doc)
1188
                docFonts = m_doc->usedFonts().keys();
1189
 
1190
        for (int a = 0; a < docFonts.count(); ++a)
19828 jghali 1191
        {
20122 jghali 1192
                QString fontName = docFonts.at(a);
1193
                if (AnnotationFonts.contains(fontName))
19828 jghali 1194
                {
20122 jghali 1195
                        QListWidgetItem* item = addFontItem(fontName, embeddedFontsListWidget);
1196
                        item->setFlags(Qt::ItemIsEnabled);
19828 jghali 1197
                }
1198
                else
1199
                {
20122 jghali 1200
                        addFontItem(fontName, subsettedFontsListWidget);
19828 jghali 1201
                }
1202
        }
1203
}
1204
 
20122 jghali 1205
void Prefs_PDFExport::OutlineAll()
1206
{
1207
        // Nothing to do at this point
1208
}
1209
 
19828 jghali 1210
void Prefs_PDFExport::doDocBleeds()
1211
{
1212
        if (useDocumentBleedsCheckBox->isChecked())
1213
        {
1214
                Opts.bleeds=bleedsWidget->margins();
1215
                bleedsWidget->setNewValues(m_doc->bleedsVal());
1216
                bleedsWidget->setEnabled(false);
1217
        }
1218
        else
1219
        {
1220
                bleedsWidget->setNewValues(Opts.bleeds);
1221
                bleedsWidget->setEnabled(true);
1222
        }
1223
}
1224
 
1225
 
1226
void Prefs_PDFExport::SetEffOpts(int nr)
1227
{
1228
        QStandardItem* si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(2));
1229
        if (si) si->setSelectable(false);
1230
        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(3));
1231
        if (si) si->setSelectable(false);
1232
        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(4));
1233
        if (si) si->setSelectable(false);
1234
        switch (nr)
1235
        {
1236
        case 0:
1237
        case 3:
1238
        case 10:
1239
                effectMovingDirectionComboBox->setEnabled(false);
1240
                effectInOutComboBox->setEnabled(false);
1241
                effectDirectionComboBox->setEnabled(false);
1242
                break;
1243
        case 1:
1244
                effectMovingDirectionComboBox->setEnabled(true);
1245
                effectInOutComboBox->setEnabled(false);
1246
                effectDirectionComboBox->setEnabled(false);
1247
                break;
1248
        case 2:
1249
                effectMovingDirectionComboBox->setEnabled(false);
1250
                effectInOutComboBox->setEnabled(true);
1251
                effectDirectionComboBox->setEnabled(false);
1252
                break;
1253
        case 4:
1254
        case 6:
1255
        case 7:
1256
        case 8:
1257
        case 9:
1258
                effectMovingDirectionComboBox->setEnabled(false);
1259
                effectInOutComboBox->setEnabled(false);
1260
                effectDirectionComboBox->setEnabled(true);
1261
                if (nr == 6)
1262
                {
1263
                        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(2));
1264
                        if (si) si->setSelectable(true);
1265
                        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(3));
1266
                        if (si) si->setSelectable(true);
1267
                }
1268
                else
1269
                {
1270
                        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(4));
1271
                        if (si) si->setSelectable(true);
1272
                }
1273
                break;
1274
        case 5:
1275
                effectMovingDirectionComboBox->setEnabled(true);
1276
                effectInOutComboBox->setEnabled(true);
1277
                effectDirectionComboBox->setEnabled(false);
1278
                break;
1279
        }
1280
}
1281
 
1282
void Prefs_PDFExport::SelEFont(QListWidgetItem *c)
1283
{
1284
        if (c != NULL)
1285
        {
1286
                if (c->flags() & Qt::ItemIsSelectable)
20122 jghali 1287
                        toSubsetButton->setEnabled(true);
1288
                fromSubsetButton->setEnabled(false);
1289
                subsettedFontsListWidget->clearSelection();
19828 jghali 1290
        }
1291
}
1292
 
1293
void Prefs_PDFExport::SelSFont(QListWidgetItem *c)
1294
{
1295
        if (c != NULL)
1296
        {
1297
                if (pdfVersionComboBox->currentIndex() == 4)
1298
                {
1299
                        if ((AllFonts[c->text()].type() == ScFace::OTF) || (AllFonts[c->text()].subset()))
20122 jghali 1300
                                fromSubsetButton->setEnabled(false);
19828 jghali 1301
                        else
20122 jghali 1302
                                fromSubsetButton->setEnabled(true);
19828 jghali 1303
                }
1304
                else
20122 jghali 1305
                        fromSubsetButton->setEnabled(true);
1306
                toSubsetButton->setEnabled(false);
19828 jghali 1307
                embeddedFontsListWidget->clearSelection();
1308
        }
1309
}
1310
 
1311
void Prefs_PDFExport::PagePr()
1312
{
1313
        disconnect(effectsPageListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(SetPgEff()));
1314
        QString tmp;
1315
        QPixmap pm;
1316
        int ci = effectsPageListWidget->currentRow();
1317
        int pgMaxX = 0;
1318
        int pgMaxY = 0;
1319
        effectsPageListWidget->clear();
1320
        if (showPagePreviewsCheckBox->isChecked())
1321
        {
1322
                for (int pg = 0; pg < m_doc->Pages->count(); ++pg)
1323
                {
1324
                        pm=QPixmap::fromImage(m_doc->view()->PageToPixmap(pg, 70));
1325
                        pgMaxX = qMax(pgMaxX, pm.width());
1326
                        pgMaxY = qMax(pgMaxY, pm.height());
1327
                        new QListWidgetItem( pm, tr("Page")+" "+tmp.setNum(pg+1), effectsPageListWidget);
1328
                }
1329
                effectsPageListWidget->setIconSize(QSize(pgMaxX, pgMaxY));
1330
        }
1331
        else
1332
        {
1333
                for (int pg = 0; pg < m_doc->Pages->count(); ++pg)
1334
                {
1335
                        new QListWidgetItem( tr("Page")+" "+tmp.setNum(pg+1), effectsPageListWidget);
1336
                }
1337
        }
1338
        if (ci != -1)
1339
                effectsPageListWidget->setCurrentRow(ci);
1340
        else
1341
                effectsPageListWidget->clearSelection();
1342
        connect(effectsPageListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(SetPgEff()));
1343
}
1344
 
1345
void Prefs_PDFExport::DoDownsample()
1346
{
1347
        if (maxResolutionLimitCheckBox->isChecked())
1348
        {
1349
                maxExportResolutionSpinBox->setEnabled(true);
1350
                if (maxExportResolutionSpinBox->value() > epsExportResolutionSpinBox->value())
1351
                        maxExportResolutionSpinBox->setValue(epsExportResolutionSpinBox->value());
1352
        }
1353
        else
1354
                maxExportResolutionSpinBox->setEnabled(false);
1355
}
1356
 
20122 jghali 1357
void Prefs_PDFExport::EmbeddingModeChange()
19828 jghali 1358
{
20122 jghali 1359
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingMode();
1360
 
1361
        embeddedFontsListWidget->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1362
        embedAllButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1363
        subsettedFontsListWidget->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1364
        subsetAllButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1365
        toSubsetButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1366
        fromSubsetButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
19828 jghali 1367
}
1368
 
20122 jghali 1369
void Prefs_PDFExport::RemoveSubset()
19828 jghali 1370
{
20122 jghali 1371
        QString currentFont = subsettedFontsListWidget->currentItem()->text();
1372
        const ScFace fontFace = AllFonts[currentFont];
1373
        if ((fontFace.type() != ScFace::OTF) && (!fontFace.subset()))
19828 jghali 1374
        {
20122 jghali 1375
                embeddedFontsListWidget->addItem(currentFont);
1376
                delete subsettedFontsListWidget->takeItem(subsettedFontsListWidget->currentRow());
19828 jghali 1377
        }
20122 jghali 1378
        subsettedFontsListWidget->clearSelection();
1379
        if (subsettedFontsListWidget->count() == 0)
1380
                fromSubsetButton->setEnabled(false);
19828 jghali 1381
}
1382
 
20122 jghali 1383
void Prefs_PDFExport::PutToSubset()
19828 jghali 1384
{
1385
        QString currentFont = embeddedFontsListWidget->currentItem()->text();
20122 jghali 1386
        if (subsettedFontsListWidget->count() != 0)
19828 jghali 1387
        {
20122 jghali 1388
                if (subsettedFontsListWidget->findItems(currentFont, Qt::MatchExactly).count() == 0)
1389
                        addFontItem(currentFont, subsettedFontsListWidget);
19828 jghali 1390
        }
1391
        else
1392
        {
20122 jghali 1393
                addFontItem(currentFont, subsettedFontsListWidget);
19828 jghali 1394
        }
1395
        delete embeddedFontsListWidget->takeItem(embeddedFontsListWidget->currentRow());
1396
        embeddedFontsListWidget->clearSelection();
1397
        if (embeddedFontsListWidget->count() == 0)
1398
        {
20122 jghali 1399
                toSubsetButton->setEnabled(false);
19828 jghali 1400
        }
20122 jghali 1401
        else if (!(embeddedFontsListWidget->currentItem()->flags() & Qt::ItemIsSelectable))
19828 jghali 1402
        {
20122 jghali 1403
                toSubsetButton->setEnabled(false);
19828 jghali 1404
        }
1405
}