Subversion Repositories Scribus

Rev

Rev 22509 | Rev 22601 | 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
 
20185 craig 11
#include "iconmanager.h"
19828 jghali 12
#include "prefsstructs.h"
13
#include "scribuscore.h"
14
#include "scribusdoc.h"
15
#include "scribusview.h"
20185 craig 16
#include "ui/createrange.h"
17
#include "ui/prefs_pdfexport.h"
19828 jghali 18
#include "ui/scrspinbox.h"
19
#include "units.h"
20
#include "util.h"
21
 
22
Prefs_PDFExport::Prefs_PDFExport(QWidget* parent, ScribusDoc* doc)
23
        : Prefs_Pane(parent),
24
        cmsEnabled(false),
25
        m_doc(doc),
26
        exportingPDF(false)
27
{
28
        setupUi(this);
21018 craig 29
        exportRangeMorePushButton->setIcon(IconManager::instance()->loadIcon("ellipsis.png"));
20185 craig 30
        pageMirrorHorizontalToolButton->setIcon(IconManager::instance()->loadIcon("16/flip-object-horizontal.png"));
31
        pageMirrorVerticalToolButton->setIcon(IconManager::instance()->loadIcon("16/flip-object-vertical.png"));
19828 jghali 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 "
20267 craig 53
                                                                                        "a range of pages or a single page number") + "</qt>" );
19828 jghali 54
        exportRangeMorePushButton->setToolTip( "<qt>" + tr( "Create a range of pages" ) + "</qt>");
55
 
21032 craig 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-1a</b> is for blind exchange with colors strictly specified in CMYK or spot colors.<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-4</b> is an extension of PDF/X-3 to support transparency and layering." ) + "</qt>");
19828 jghali 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>" );
20267 craig 59
        saveLinkedTextFramesAsArticlesCheckBox->setToolTip( "<qt>" + tr( "Generate PDF Articles, which is useful for navigating linked articles in a PDF" ) + "</qt>" );
20270 craig 60
        includeLayersCheckBox->setToolTip( "<qt>" + tr( "Layers in your document are exported to the PDF. Only available if PDF 1.5 is chosen." ) + "</qt>" );
19828 jghali 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>" );
20267 craig 68
        maxExportResolutionSpinBox->setToolTip( "<qt>" + tr( "DPI (Dots Per Inch) for image export") + "</qt>" );
19828 jghali 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>" );
20267 craig 71
        passwordUserLineEdit->setToolTip( "<qt>" + tr( "Choose a password for users to be able to read your PDF" ) + "</qt>" );
20337 craig 72
        allowPrintingCheckBox->setToolTip( "<qt>" + tr( "Allow printing of the PDF. If unchecked, printing is prevented." ) + "</qt>" );
20267 craig 73
        allowChangingCheckBox->setToolTip( "<qt>" + tr( "Allow modifying of the PDF. If unchecked, modifying the PDF is prevented." ) + "</qt>" );
19828 jghali 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
{
22218 jghali 113
        return fontEmbeddingCombo->embeddingMode();
20122 jghali 114
}
115
 
19828 jghali 116
QStringList Prefs_PDFExport::fontsToEmbed()
117
{
22218 jghali 118
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingCombo->embeddingMode();
20122 jghali 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
{
22218 jghali 130
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingCombo->embeddingMode();
20122 jghali 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
{
22218 jghali 142
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingCombo->embeddingMode();
20122 jghali 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())
20185 craig 159
                item = new QListWidgetItem( IconManager::instance()->loadIcon("font_subst16.png"), fontName, fontList );
20122 jghali 160
        else if (face.type() == ScFace::TYPE1)
20185 craig 161
                item = new QListWidgetItem( IconManager::instance()->loadIcon("font_type1_16.png"), fontName, fontList );
20122 jghali 162
        else if (face.type() == ScFace::TTF)
20185 craig 163
                item = new QListWidgetItem( IconManager::instance()->loadIcon("font_truetype16.png"), fontName, fontList );
20122 jghali 164
        else if (face.type() == ScFace::OTF)
20185 craig 165
                item = new QListWidgetItem( IconManager::instance()->loadIcon("font_otf16.png"), fontName, fontList );
20122 jghali 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;
22438 jghali 273
        if (!cmsUse)
274
                pdfVersionComboBox->setVersion(PDFOptions::PDFVersion_14);
275
        pdfVersionComboBox->setVersion(prefsData->pdfPrefs.Version);
19828 jghali 276
        pageBindingComboBox->setCurrentIndex(prefsData->pdfPrefs.Binding);
277
        generateThumbnailsCheckBox->setChecked(prefsData->pdfPrefs.Thumbnails);
278
        saveLinkedTextFramesAsArticlesCheckBox->setChecked(prefsData->pdfPrefs.Articles);
279
        includeBookmarksCheckBox->setChecked(prefsData->pdfPrefs.Bookmarks);
280
        includeLayersCheckBox->setChecked(prefsData->pdfPrefs.useLayers);
281
        includeLayersCheckBox->setEnabled(prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_15 || prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X4);
282
 
283
        epsExportResolutionSpinBox->setValue(prefsData->pdfPrefs.Resolution);
284
        embedPDFAndEPSFilesCheckBox->setChecked(prefsData->pdfPrefs.embedPDF);
285
        compressTextAndVectorGraphicsCheckBox->setChecked( prefsData->pdfPrefs.Compress );
286
        imageCompressionMethodComboBox->setCurrentIndex(prefsData->pdfPrefs.CompressMethod);
287
        imageCompressionQualityComboBox->setCurrentIndex(prefsData->pdfPrefs.Quality);
288
        maxResolutionLimitCheckBox->setChecked(prefsData->pdfPrefs.RecalcPic);
289
        maxExportResolutionSpinBox->setValue(prefsData->pdfPrefs.PicRes);
290
        maxExportResolutionSpinBox->setEnabled(prefsData->pdfPrefs.RecalcPic);
291
 
22218 jghali 292
        fontEmbeddingCombo->setEmbeddingMode(prefsData->pdfPrefs.FontEmbedding);
19828 jghali 293
        if (m_doc != 0 && exportingPDF)
294
        {
295
//      Build a list of all Fonts used in Annotations;
296
                PageItem *pgit;
297
                QList<PageItem*> allItems;
22509 jghali 298
                for (auto it = m_doc->FrameItems.begin(); it != m_doc->FrameItems.end(); ++it)
19828 jghali 299
                {
300
                        PageItem *currItem = it.value();
301
                        if (currItem->isGroup())
22224 jghali 302
                                allItems = currItem->getAllChildren();
19828 jghali 303
                        else
304
                                allItems.append(currItem);
305
                        for (int ii = 0; ii < allItems.count(); ii++)
306
                        {
307
                                pgit = allItems.at(ii);
308
                                if (((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) && (pgit->isAnnotation()) && (pgit->itemText.length() > 0))
309
                                        AnnotationFonts.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), "");
310
                        }
311
                        allItems.clear();
312
                }
313
                for (int a = 0; a < m_doc->MasterItems.count(); ++a)
314
                {
315
                        PageItem *currItem = m_doc->MasterItems.at(a);
316
                        if (currItem->isGroup())
22224 jghali 317
                                allItems = currItem->getAllChildren();
19828 jghali 318
                        else
319
                                allItems.append(currItem);
320
                        for (int ii = 0; ii < allItems.count(); ii++)
321
                        {
322
                                pgit = allItems.at(ii);
323
                                if (((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) && (pgit->isAnnotation()) && (pgit->itemText.length() > 0))
324
                                        AnnotationFonts.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), "");
325
                        }
326
                        allItems.clear();
327
                }
328
                for (int a = 0; a < m_doc->DocItems.count(); ++a)
329
                {
330
                        PageItem *currItem = m_doc->DocItems.at(a);
331
                        if (currItem->isGroup())
22224 jghali 332
                                allItems = currItem->getAllChildren();
19828 jghali 333
                        else
334
                                allItems.append(currItem);
335
                        for (int ii = 0; ii < allItems.count(); ii++)
336
                        {
337
                                pgit = allItems.at(ii);
338
                                if (((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) && (pgit->isAnnotation()) && (pgit->itemText.length() > 0))
339
                                        AnnotationFonts.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), "");
340
                        }
341
                        allItems.clear();
342
                }
20122 jghali 343
                toSubsetButton->setEnabled(false);
344
                fromSubsetButton->setEnabled(false);
20103 avox 345
 
20122 jghali 346
                if ((Opts.EmbedList.count() == 0) && (Opts.SubsetList.count() == 0) && (Opts.firstUse))
19828 jghali 347
                        EmbedAll();
348
                else
349
                {
20122 jghali 350
                        QStringList docFonts = m_doc->usedFonts().keys();
19828 jghali 351
                        embeddedFontsListWidget->clear();
20122 jghali 352
                        subsettedFontsListWidget->clear();
353
                        for (int fe = 0; fe < docFonts.count(); ++ fe)
19828 jghali 354
                        {
20122 jghali 355
                                QString fontName = docFonts.at(fe);
356
                                if (Opts.EmbedList.contains(fontName))
357
                                        addFontItem(fontName, embeddedFontsListWidget);
358
                                else
359
                                {
360
                                        addFontItem(fontName, subsettedFontsListWidget);
361
                                        if (!Opts.SubsetList.contains(fontName))
362
                                                Opts.SubsetList.append(fontName);
363
                                }
19828 jghali 364
                        }
365
                        QMap<QString, QString>::Iterator itAnn;
366
                        for (itAnn = AnnotationFonts.begin(); itAnn != AnnotationFonts.end(); ++itAnn)
367
                        {
368
                                QList<QListWidgetItem *> itEmbed = embeddedFontsListWidget->findItems(itAnn.key(), Qt::MatchExactly);
369
                                if (itEmbed.count() == 0)
370
                                {
20122 jghali 371
                                        QListWidgetItem* item = addFontItem(itAnn.key(), embeddedFontsListWidget);
372
                                        item->setFlags(Qt::ItemIsEnabled);
19828 jghali 373
                                }
20122 jghali 374
                                QList<QListWidgetItem *> itSubset = subsettedFontsListWidget->findItems(itAnn.key(), Qt::MatchExactly);
375
                                for (int itOut = 0; itOut < itSubset.count(); ++itOut)
19828 jghali 376
                                {
20122 jghali 377
                                        QListWidgetItem* item = itSubset[itOut];
378
                                        delete subsettedFontsListWidget->takeItem(subsettedFontsListWidget->row(item));
19828 jghali 379
                                }
380
                        }
381
                }
382
                enabledEffectsCheckBox->setChecked(Opts.PresentMode);
383
                showPagePreviewsCheckBox->setChecked(false);
384
                effectsPageListWidget->clear();
385
                QString tmp;
386
                for (int pg = 0; pg < m_doc->Pages->count(); ++pg)
387
                {
388
                        effectsPageListWidget->addItem( tr("Page")+" "+tmp.setNum(pg+1));
389
                        EffVal.append(m_doc->Pages->at(pg)->PresentVals);
390
                }
391
                displayDurationSpinBox->setValue(EffVal[0].pageViewDuration);
392
                effectDurationSpinBox->setValue(EffVal[0].pageEffectDuration);
393
                bool df = true;
394
                if ((Opts.displayBookmarks) || (Opts.displayFullscreen) || (Opts.displayLayers) || (Opts.displayThumbs))
395
                        df = false;
396
                if (df)
397
                        useViewerDefaultsRadioButton->setChecked(df);
398
                useFullScreenRadioButton->setChecked(Opts.displayFullscreen);
399
                useBookmarksRadioButton->setChecked(Opts.displayBookmarks);
400
                useThumbnailsRadioButton->setChecked(Opts.displayThumbs);
401
                useLayersRadioButton->setChecked(Opts.displayLayers);
402
                hideViewerToolBarCheckBox->setChecked(Opts.hideToolBar);
403
                hideViewerMenuBarCheckBox->setChecked(Opts.hideMenuBar);
404
                fitViewerWindowCheckBox->setChecked(Opts.fitWindow);
405
                QMap<QString,QString>::Iterator itja;
406
                startupJavascriptComboBox->clear();
407
                startupJavascriptComboBox->addItem( tr("No Script"));
408
                for (itja = m_doc->JavaScripts.begin(); itja != m_doc->JavaScripts.end(); ++itja)
409
                        startupJavascriptComboBox->addItem(itja.key());
410
                if (m_doc->JavaScripts.contains(Opts.openAction))
411
                        setCurrentComboItem(startupJavascriptComboBox, Opts.openAction);
412
                if (Opts.PageLayout == PDFOptions::SinglePage)
413
                        singlePageRadioButton->setChecked(true);
414
                else if (Opts.PageLayout == PDFOptions::OneColumn)
415
                        continuousPagesRadioButton->setChecked(true);
416
                else if (Opts.PageLayout == PDFOptions::TwoColumnLeft)
21491 craig 417
                        facingPagesLeftRadioButton->setChecked(true);
19828 jghali 418
                else if (Opts.PageLayout == PDFOptions::TwoColumnRight)
21491 craig 419
                        facingPagesRightRadioButton->setChecked(true);
19828 jghali 420
                if ((Opts.Version == PDFOptions::PDFVersion_15) || (Opts.Version == PDFOptions::PDFVersion_X4))
421
                        useLayersRadioButton->setEnabled(true);
422
                else
423
                        useLayersRadioButton->setEnabled(false);
424
        }
425
 
426
        useEncryptionCheckBox->setChecked( prefsData->pdfPrefs.Encrypt );
427
        passwordOwnerLineEdit->setText(prefsData->pdfPrefs.PassOwner);
428
        passwordUserLineEdit->setText(prefsData->pdfPrefs.PassUser);
429
        allowPrintingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 4 );
430
        allowChangingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 8 );
431
        allowCopyingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 16 );
432
        allowAnnotatingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 32 );
433
        enableSecurityControls(prefsData->pdfPrefs.Encrypt);
434
 
435
        if (prefsData->pdfPrefs.UseRGB)
436
                outputIntentionComboBox->setCurrentIndex(0);
437
        else
438
        {
439
                if (prefsData->pdfPrefs.isGrayscale)
440
                        outputIntentionComboBox->setCurrentIndex(2);
441
                else
442
                        outputIntentionComboBox->setCurrentIndex(1);
443
        }
444
        convertSpotsToProcessCheckBox->setChecked(!prefsData->pdfPrefs.UseSpotColors);
445
 
20371 jghali 446
        bleedsWidget->setup(prefsData->pdfPrefs.bleeds, prefsData->docSetupPrefs.pagePositioning, prefsData->docSetupPrefs.docUnitIndex, NewMarginWidget::BleedWidgetFlags);
19828 jghali 447
        bleedsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth);
448
        bleedsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight);
449
        bleedsWidget->setPageSize(prefsData->docSetupPrefs.pageSize);
450
        bleedsWidget->setMarginPreset(prefsData->docSetupPrefs.marginPreset);
451
//
452
        useCustomRenderingCheckBox->setChecked(prefsData->pdfPrefs.UseLPI);
453
        QMap<QString,LPIData>::Iterator itlp;
454
        customRenderingColorComboBox->clear();
455
        for (itlp = prefsData->pdfPrefs.LPISettings.begin(); itlp != prefsData->pdfPrefs.LPISettings.end(); ++itlp)
456
                customRenderingColorComboBox->addItem( itlp.key() );
457
        customRenderingColorComboBox->setCurrentIndex(0);
458
 
459
        customRenderingFrequencySpinBox->setValue(prefsData->pdfPrefs.LPISettings[customRenderingColorComboBox->currentText()].Frequency);
460
        customRenderingAngleSpinBox->setValue(prefsData->pdfPrefs.LPISettings[customRenderingColorComboBox->currentText()].Angle);
461
        customRenderingSpotFunctionComboBox->setCurrentIndex(prefsData->pdfPrefs.LPISettings[customRenderingColorComboBox->currentText()].SpotFunc);
462
        useSolidColorProfileCheckBox->setChecked(prefsData->pdfPrefs.UseProfiles);
463
        useImageProfileCheckBox->setChecked(prefsData->pdfPrefs.UseProfiles2);
464
        doNotUseEmbeddedImageProfileCheckBox->setChecked(prefsData->pdfPrefs.EmbeddedI);
465
        if ((prefsData->pdfPrefs.UseRGB) || (prefsData->pdfPrefs.isGrayscale))
466
        {
467
                //enableSolidsImagesWidgets(false);
468
                enableProfiles(0);
469
        }
470
        else
471
                enableProfiles(1);
472
        enablePG();
473
        enablePGI();
474
        QString tp(prefsData->pdfPrefs.SolidProf);
475
        if (!ScCore->InputProfiles.contains(tp))
476
        {
477
                if (m_doc != 0 && exportingPDF)
478
                        tp = m_doc->cmsSettings().DefaultSolidColorRGBProfile;
479
                else
480
                        tp = defaultSolidColorRGBProfile;
481
        }
482
        ProfilesL::Iterator itp;
483
        ProfilesL::Iterator itpend=ScCore->InputProfiles.end();
484
        solidColorProfileComboBox->clear();
485
        for (itp = ScCore->InputProfiles.begin(); itp != itpend; ++itp)
486
        {
487
                solidColorProfileComboBox->addItem(itp.key());
488
                if (itp.key() == tp)
489
                        solidColorProfileComboBox->setCurrentIndex(solidColorProfileComboBox->count()-1);
490
        }
491
        int solidIntent = Opts.Intent;
492
        if (Opts.Intent < 0)
493
                solidIntent = 1;
494
        solidColorRenderingIntentComboBox->setCurrentIndex(solidIntent);
495
        QString tp1 = Opts.ImageProf;
496
        if (!ScCore->InputProfiles.contains(tp1))
497
        {
498
                if (m_doc != 0 && exportingPDF)
499
                        tp1 = m_doc->cmsSettings().DefaultSolidColorRGBProfile;
500
                else
501
                        tp1 = defaultSolidColorRGBProfile;
502
        }
503
        ProfilesL::Iterator itp2;
504
        ProfilesL::Iterator itp2end=ScCore->InputProfiles.end();
505
        imageProfileComboBox->clear();
506
        for (itp2 = ScCore->InputProfiles.begin(); itp2 != itp2end; ++itp2)
507
        {
508
                imageProfileComboBox->addItem(itp2.key());
509
                if (itp2.key() == tp1)
510
                        imageProfileComboBox->setCurrentIndex(imageProfileComboBox->count()-1);
511
        }
512
        int imageIntent = Opts.Intent2;
513
        if (imageIntent < 0)
514
                imageIntent = 0;
515
        imageRenderingIntentComboBox->setCurrentIndex(imageIntent);
516
        if (!cmsUse)
517
        {
518
                //Disabling vis hiding
519
                //setSolidsImagesWidgetsShown(false);
520
                enableSolidsImagesWidgets(false);
521
        }
522
 
523
        ProfilesL::const_iterator itp3;
524
        QString tp3(Opts.PrintProf);
525
        if (!PDFXProfiles.contains(tp3))
526
        {
527
                if (m_doc != 0 && exportingPDF)
528
                        tp3 = m_doc->cmsSettings().DefaultPrinterProfile;
529
                else
530
                        tp3 = defaultPrinterProfile;
531
        }
532
        pdfx3OutputProfileComboBox->clear();
533
        for (itp3 = PDFXProfiles.constBegin(); itp3 != PDFXProfiles.constEnd(); ++itp3)
534
        {
535
                pdfx3OutputProfileComboBox->addItem(itp3.key());
536
                if (itp3.key() == tp3)
537
                        pdfx3OutputProfileComboBox->setCurrentIndex(pdfx3OutputProfileComboBox->count()-1);
538
        }
539
 
540
        if (!Opts.Info.isEmpty())
541
                pdfx3InfoStringLineEdit->setText(Opts.Info);
542
        else
543
        {
544
                if (m_doc != 0 && exporting)
545
                {
546
                        QFileInfo fi(m_doc->DocName);
547
                        pdfx3InfoStringLineEdit->setText(fi.fileName());
548
                }
549
                else
550
                        pdfx3InfoStringLineEdit->setText( tr("InfoString"));
551
        }
552
 
553
        if (m_doc != 0 && exportingPDF)
554
        {
555
                useDocumentBleedsCheckBox->setChecked(Opts.useDocBleeds);
556
                doDocBleeds();
557
        }
558
        else
559
                useDocumentBleedsCheckBox->hide();
560
 
561
        markLengthSpinBox->setValue(prefsData->pdfPrefs.markLength*unitRatio);
562
        markOffsetSpinBox->setValue(prefsData->pdfPrefs.markOffset*unitRatio);
563
        printCropMarksCheckBox->setChecked(prefsData->pdfPrefs.cropMarks);
564
        printBleedMarksCheckBox->setChecked(prefsData->pdfPrefs.bleedMarks);
565
        printRegistrationMarksCheckBox->setChecked(prefsData->pdfPrefs.registrationMarks);
566
        printColorBarsCheckBox->setChecked(prefsData->pdfPrefs.colorMarks);
567
        printPageInfoCheckBox->setChecked(prefsData->pdfPrefs.docInfoMarks);
568
        if (!cmsUse)
569
                enablePDFXWidgets(false);
570
        if (cmsUse && (Opts.Version == PDFOptions::PDFVersion_X1a) && (!PDFXProfiles.isEmpty()))
571
                enablePDFX(3);
572
        else if (cmsUse && (Opts.Version == PDFOptions::PDFVersion_X3) && (!PDFXProfiles.isEmpty()))
573
                enablePDFX(4);
574
        else if (cmsUse && (Opts.Version == PDFOptions::PDFVersion_X4) && (!PDFXProfiles.isEmpty()))
575
                enablePDFX(5);
576
        else
577
                enablePDFXWidgets(false);
578
 
579
        if (m_doc != 0  && exportingPDF)
580
        {
581
                effectTypeComboBox->clear();
582
                effectTypeComboBox->addItem( tr("No Effect"));
583
                effectTypeComboBox->addItem( tr("Blinds"));
584
                effectTypeComboBox->addItem( tr("Box"));
585
                effectTypeComboBox->addItem( tr("Dissolve"));
586
                effectTypeComboBox->addItem( tr("Glitter"));
587
                effectTypeComboBox->addItem( tr("Split"));
588
                effectTypeComboBox->addItem( tr("Wipe"));
589
                if (Opts.Version == PDFOptions::PDFVersion_15)
590
                {
591
                        effectTypeComboBox->addItem( tr("Push"));
592
                        effectTypeComboBox->addItem( tr("Cover"));
593
                        effectTypeComboBox->addItem( tr("Uncover"));
594
                        effectTypeComboBox->addItem( tr("Fade"));
595
                }
596
                effectsPageListWidget->setCurrentRow(0);
597
                SetEffOpts(0);
598
                effectsPageListWidget->setEnabled(false);
599
                enableEffects(false);
600
                showPagePreviewsCheckBox->setEnabled(false);
601
                if (enabledEffectsCheckBox->isChecked())
602
                {
603
                        displayDurationSpinBox->setValue(EffVal[0].pageViewDuration);
604
                        effectDurationSpinBox->setValue(EffVal[0].pageEffectDuration);
605
                        effectTypeComboBox->setCurrentIndex(EffVal[0].effectType);
606
                        effectMovingDirectionComboBox->setCurrentIndex(EffVal[0].Dm);
607
                        effectInOutComboBox->setCurrentIndex(EffVal[0].M);
608
                        effectDirectionComboBox->setCurrentIndex(EffVal[0].Di);
609
                        SetEffOpts(effectTypeComboBox->currentIndex());
610
                }
611
                /* Using margin widget, is this necessary?
612
                if (m_doc->currentPageLayout != 0)
613
                {
614
                        BleedTxt3->setText( tr( "Inside:" ) );
615
                        BleedTxt4->setText( tr( "Outside:" ) );
616
                }
617
                */
618
        }
619
 
620
        if (m_doc != 0 && exportingPDF)
621
        {
20122 jghali 622
                connect(embedAllButton, SIGNAL(clicked()), this, SLOT(EmbedAll()));
623
                connect(embeddedFontsListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SelEFont(QListWidgetItem*)));
624
                connect(subsetAllButton, SIGNAL(clicked()), this, SLOT(SubsetAll()));
625
                connect(subsettedFontsListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SelSFont(QListWidgetItem*)));
626
                connect(toSubsetButton, SIGNAL(clicked()), this, SLOT(PutToSubset()));
627
                connect(fromSubsetButton, SIGNAL(clicked()), this, SLOT(RemoveSubset()));
19828 jghali 628
                connect(showPagePreviewsCheckBox, SIGNAL(clicked()), this, SLOT(PagePr()));
629
                connect(effectsPageListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(SetPgEff()));
630
                connect(effectTypeComboBox, SIGNAL(activated(int)), this, SLOT(SetEffOpts(int)));
631
                connect(effectDirectionComboBox, SIGNAL(activated(int)), this, SLOT(ValidDI(int)));
632
                connect(enabledEffectsCheckBox, SIGNAL(clicked()), this, SLOT(DoEffects()));
633
                connect(applyEffectToAllPagesPushButton, SIGNAL(clicked()), this, SLOT(EffectOnAll()));
634
//              connect(pdfx3InfoStringLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(checkInfo()));
635
//              connect(pdfx3InfoStringLineEdit, SIGNAL(editingFinished()), this, SLOT(checkInfo()));
636
                connect(useDocumentBleedsCheckBox, SIGNAL(clicked()), this, SLOT(doDocBleeds()));
637
 
20122 jghali 638
                embedAllButton->setToolTip( "<qt>" + tr( "Embed fonts into the PDF. Embedding the fonts will preserve the layout and appearance of your document." ) + "</qt>");
19828 jghali 639
                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>");
640
                showPagePreviewsCheckBox->setToolTip( "<qt>" + tr( "Show page previews of each page listed above." ) + "</qt>");
641
                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>" );
642
                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>" );
20272 craig 643
                effectTypeComboBox->setToolTip( "<qt>" + tr( "Type of the display effect" ) + "</qt>" );
644
                effectMovingDirectionComboBox->setToolTip( "<qt>" + tr( "Direction of the effect of moving lines for the split and blind effects" ) + "</qt>" );
645
                effectInOutComboBox->setToolTip( "<qt>" + tr( "Starting position for the box and split effects" ) + "</qt>" );
646
                effectDirectionComboBox->setToolTip( "<qt>" + tr( "Direction of the glitter or wipe effects" ) + "</qt>" );
647
                applyEffectToAllPagesPushButton->setToolTip( "<qt>" + tr( "Apply the selected effect to all pages" ) + "</qt>" );
20286 craig 648
                subsetAllButton->setToolTip( "<qt>" + tr("Embed only subset fonts with glyphs used in the document into the PDF") + "</qt>");
19828 jghali 649
                singlePageRadioButton->setToolTip( "<qt>" + tr( "Show the document in single page mode" ) + "</qt>" );
650
                continuousPagesRadioButton->setToolTip( "<qt>" + tr( "Show the document in single page mode with the pages displayed continuously end to end like a scroll" ) + "</qt>" );
21491 craig 651
                facingPagesLeftRadioButton->setToolTip( "<qt>" + tr( "Show the document with facing pages, starting with the first page displayed on the left" ) + "</qt>" );
652
                facingPagesRightRadioButton->setToolTip( "<qt>" + tr( "Show the document with facing pages, starting with the first page displayed on the right" ) + "</qt>" );
19828 jghali 653
                useViewerDefaultsRadioButton->setToolTip( "<qt>" + tr( "Use the viewer's defaults or the user's preferences if set differently from the viewer defaults" ) + "</qt>" );
654
                useFullScreenRadioButton->setToolTip( "<qt>" + tr( "Enables viewing the document in full screen" ) + "</qt>" );
655
                useBookmarksRadioButton->setToolTip( "<qt>" + tr( "Display the bookmarks upon opening" ) + "</qt>" );
656
                useThumbnailsRadioButton->setToolTip( "<qt>" + tr( "Display the page thumbnails upon opening" ) + "</qt>" );
657
                useLayersRadioButton->setToolTip( "<qt>" + tr( "Forces the displaying of layers. Useful only for PDF 1.5+." ) + "</qt>" );
658
                hideViewerToolBarCheckBox->setToolTip( "<qt>" + tr( "Hides the Tool Bar which has selection and other editing capabilities" ) + "</qt>" );
20272 craig 659
                hideViewerMenuBarCheckBox->setToolTip( "<qt>" + tr( "Hides the Menu Bar for the viewer, the PDF will display in a plain window" ) + "</qt>" );
660
                fitViewerWindowCheckBox->setToolTip( "<qt>" + tr( "Fit the document page or pages to the available space in the viewer window" ) + "</qt>" );
19828 jghali 661
        }
662
}
663
 
664
 
665
void Prefs_PDFExport::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
666
{
667
        prefsData->pdfPrefs.Thumbnails = generateThumbnailsCheckBox->isChecked();
668
        prefsData->pdfPrefs.Compress = compressTextAndVectorGraphicsCheckBox->isChecked();
669
        prefsData->pdfPrefs.CompressMethod = (PDFOptions::PDFCompression) imageCompressionMethodComboBox->currentIndex();
670
        prefsData->pdfPrefs.Quality = imageCompressionQualityComboBox->currentIndex();
671
        prefsData->pdfPrefs.Resolution = epsExportResolutionSpinBox->value();
672
        prefsData->pdfPrefs.RecalcPic = maxResolutionLimitCheckBox->isChecked();
673
        prefsData->pdfPrefs.PicRes = maxExportResolutionSpinBox->value();
674
        prefsData->pdfPrefs.embedPDF = embedPDFAndEPSFilesCheckBox->isChecked();
675
        prefsData->pdfPrefs.Bookmarks = includeBookmarksCheckBox->isChecked();
676
        prefsData->pdfPrefs.Binding = pageBindingComboBox->currentIndex();
677
        prefsData->pdfPrefs.MirrorH = pageMirrorHorizontalToolButton->isChecked();
678
        prefsData->pdfPrefs.MirrorV = pageMirrorVerticalToolButton->isChecked();
679
        prefsData->pdfPrefs.RotateDeg = rotationComboBox->currentIndex() * 90;
680
        prefsData->pdfPrefs.Articles = saveLinkedTextFramesAsArticlesCheckBox->isChecked();
22218 jghali 681
        prefsData->pdfPrefs.FontEmbedding = fontEmbeddingCombo->embeddingMode();
19828 jghali 682
        prefsData->pdfPrefs.Encrypt = useEncryptionCheckBox->isChecked();
683
        prefsData->pdfPrefs.UseLPI = useCustomRenderingCheckBox->isChecked();
684
        prefsData->pdfPrefs.UseSpotColors = !convertSpotsToProcessCheckBox->isChecked();
685
        prefsData->pdfPrefs.doMultiFile = false;
686
        prefsData->pdfPrefs.cropMarks  = printCropMarksCheckBox->isChecked();
687
        prefsData->pdfPrefs.bleedMarks = printBleedMarksCheckBox->isChecked();
688
        prefsData->pdfPrefs.registrationMarks = printRegistrationMarksCheckBox->isChecked();
689
        prefsData->pdfPrefs.colorMarks = printColorBarsCheckBox->isChecked();
690
        prefsData->pdfPrefs.docInfoMarks = printPageInfoCheckBox->isChecked();
691
        prefsData->pdfPrefs.markLength   = markLengthSpinBox->value() / unitRatio;
692
        prefsData->pdfPrefs.markOffset   = markOffsetSpinBox->value() / unitRatio;
693
        prefsData->pdfPrefs.useDocBleeds = useDocumentBleedsCheckBox->isChecked();
694
        prefsData->pdfPrefs.bleeds = bleedsWidget->margins();
695
        prefsData->pdfPrefs.doClip = clipToPrinterMarginsCheckBox->isChecked();
696
        if (useEncryptionCheckBox->isChecked())
697
        {
698
                int Perm = -64;
699
                if (pdfVersionComboBox->currentIndex() == 1)
700
                        Perm &= ~0x00240000;
701
                if (allowPrintingCheckBox->isChecked())
702
                        Perm += 4;
703
                if (allowChangingCheckBox->isChecked())
704
                        Perm += 8;
705
                if (allowCopyingCheckBox->isChecked())
706
                        Perm += 16;
707
                if (allowAnnotatingCheckBox->isChecked())
708
                        Perm += 32;
709
                prefsData->pdfPrefs.Permissions = Perm;
710
                prefsData->pdfPrefs.PassOwner = passwordOwnerLineEdit->text();
711
                prefsData->pdfPrefs.PassUser = passwordUserLineEdit->text();
712
        }
22438 jghali 713
        prefsData->pdfPrefs.Version = pdfVersionComboBox->version();
19828 jghali 714
        if (outputIntentionComboBox->currentIndex() == 0)
715
        {
716
                prefsData->pdfPrefs.isGrayscale = false;
717
                prefsData->pdfPrefs.UseRGB = true;
718
                prefsData->pdfPrefs.UseProfiles = false;
719
                prefsData->pdfPrefs.UseProfiles2 = false;
720
        }
721
        else
722
        {
723
                if (outputIntentionComboBox->currentIndex() == 2)
724
                {
725
                        prefsData->pdfPrefs.isGrayscale = true;
726
                        prefsData->pdfPrefs.UseRGB = false;
727
                        prefsData->pdfPrefs.UseProfiles = false;
728
                        prefsData->pdfPrefs.UseProfiles2 = false;
729
                }
730
                else
731
                {
732
                        prefsData->pdfPrefs.isGrayscale = false;
733
                        prefsData->pdfPrefs.UseRGB = false;
734
                        if (/*CMSuse*/ ScCore->haveCMS())
735
                        {
736
                                prefsData->pdfPrefs.UseProfiles = useSolidColorProfileCheckBox->isChecked();
737
                                prefsData->pdfPrefs.UseProfiles2 = useImageProfileCheckBox->isChecked();
738
                                prefsData->pdfPrefs.Intent = solidColorRenderingIntentComboBox->currentIndex();
739
                                prefsData->pdfPrefs.Intent2 = imageRenderingIntentComboBox->currentIndex();
740
                                prefsData->pdfPrefs.EmbeddedI = doNotUseEmbeddedImageProfileCheckBox->isChecked();
741
                                prefsData->pdfPrefs.SolidProf = solidColorProfileComboBox->currentText();
742
                                prefsData->pdfPrefs.ImageProf = imageProfileComboBox->currentText();
743
                                prefsData->pdfPrefs.PrintProf = pdfx3OutputProfileComboBox->currentText();
744
                        }
745
                }
746
        }
747
}
748
 
749
 
750
void Prefs_PDFExport::SelLPIcol(int c)
751
{
752
        // XXX Optionen or Opts changed here
753
        Opts.LPISettings[SelLPIcolor].Frequency = customRenderingFrequencySpinBox->value();
754
        Opts.LPISettings[SelLPIcolor].Angle = customRenderingAngleSpinBox->value();
755
        Opts.LPISettings[SelLPIcolor].SpotFunc = customRenderingSpotFunctionComboBox->currentIndex();
756
        customRenderingFrequencySpinBox->setValue(Opts.LPISettings[customRenderingColorComboBox->itemText(c)].Frequency);
757
        customRenderingAngleSpinBox->setValue(Opts.LPISettings[customRenderingColorComboBox->itemText(c)].Angle);
758
        customRenderingSpotFunctionComboBox->setCurrentIndex(Opts.LPISettings[customRenderingColorComboBox->itemText(c)].SpotFunc);
759
        SelLPIcolor = customRenderingColorComboBox->itemText(c);
760
}
761
 
762
void Prefs_PDFExport::enableRangeControls(bool enabled)
763
{
764
        exportPageListLineEdit->setEnabled( enabled );
765
        exportRangeMorePushButton->setEnabled( enabled );
766
        if (enabled == false)
767
                includeBookmarksCheckBox->setChecked(false);
768
}
769
 
770
void Prefs_PDFExport::enableSecurityControls(bool enabled)
771
{
772
        passwordOwnerLineEdit->setEnabled(enabled);
773
        passwordUserLineEdit->setEnabled(enabled);
774
        allowPrintingCheckBox->setEnabled(enabled);
775
        allowChangingCheckBox->setEnabled(enabled);
776
        allowCopyingCheckBox->setEnabled(enabled);
777
        allowAnnotatingCheckBox->setEnabled(enabled);
778
}
779
 
780
 
781
void Prefs_PDFExport::enableCMS(bool enabled)
782
{
783
        cmsEnabled=enabled;
784
        addPDFVersions(enabled);
21147 jghali 785
        enableProfiles(outputIntentionComboBox->currentIndex());
19828 jghali 786
}
787
 
788
void Prefs_PDFExport::enablePDFExportTabs(bool enabled)
789
{
790
        if (!enabled)
791
        {
792
                tabWidget->removeTab(tabWidget->indexOf(tabFonts));//Fonts
793
                tabWidget->removeTab(tabWidget->indexOf(tabExtras));//Extras
794
                tabWidget->removeTab(tabWidget->indexOf(tabViewer));//Viewer
795
        }
796
}
797
 
798
void Prefs_PDFExport::createPageNumberRange()
799
{
800
        if (m_doc!=0)
801
        {
802
                CreateRange cr(exportPageListLineEdit->text(), m_doc->DocPages.count(), this);
803
                if (cr.exec())
804
                {
805
                        CreateRangeData crData;
806
                        cr.getCreateRangeData(crData);
807
                        exportPageListLineEdit->setText(crData.pageRange);
808
                        return;
809
                }
810
        }
811
        exportPageListLineEdit->setText(QString::null);
812
}
813
 
814
void Prefs_PDFExport::setMaximumResolution()
815
{
816
        if (maxResolutionLimitCheckBox->isChecked())
817
        {
818
                maxExportResolutionSpinBox->setEnabled(true);
819
                if (maxExportResolutionSpinBox->value() > epsExportResolutionSpinBox->value())
820
                        maxExportResolutionSpinBox->setValue(epsExportResolutionSpinBox->value());
821
        }
822
        else
823
                maxExportResolutionSpinBox->setEnabled(false);
824
}
825
 
826
void Prefs_PDFExport::enableProfiles(int i)
827
{
828
        enableLPI(i);
829
        bool setter = false;
22438 jghali 830
        if (i == 1 && (!pdfVersionComboBox->versionIs(PDFOptions::PDFVersion_X1a)))
19828 jghali 831
                setter = true;
832
        enableSolidsImagesWidgets(setter);
833
}
834
 
835
void Prefs_PDFExport::enableLPI(int i)
836
{
837
        if (i == 1)
838
        {
839
                QString tp(Opts.SolidProf);
840
                if (!ScCore->InputProfiles.contains(tp))
841
                {
842
                        if (m_doc != 0)
843
                                tp = m_doc->cmsSettings().DefaultSolidColorRGBProfile;
844
                        else
845
                                tp = defaultSolidColorRGBProfile;
846
                }
847
                solidColorProfileComboBox->clear();
848
                ProfilesL::Iterator itp;
849
                ProfilesL::Iterator itpend=ScCore->InputProfiles.end();
850
                for (itp = ScCore->InputProfiles.begin(); itp != itpend; ++itp)
851
                {
852
                        solidColorProfileComboBox->addItem(itp.key());
853
                        if (itp.key() == tp)
854
                        {
855
                                if (cmsEnabled)
856
                                        solidColorProfileComboBox->setCurrentIndex(solidColorProfileComboBox->count()-1);
857
                        }
858
                }
859
                if (cmsEnabled)
860
                        solidColorRenderingIntentComboBox->setCurrentIndex(Opts.Intent);
861
                QString tp1 = Opts.ImageProf;
862
                if (!ScCore->InputProfiles.contains(tp1))
863
                {
864
                        if (m_doc != 0)
865
                                tp1 = m_doc->cmsSettings().DefaultSolidColorRGBProfile;
866
                        else
867
                                tp1 = defaultSolidColorRGBProfile;
868
                }
869
                imageProfileComboBox->clear();
870
                ProfilesL::Iterator itp2;
871
                ProfilesL::Iterator itp2end=ScCore->InputProfiles.end();
872
                for (itp2 = ScCore->InputProfiles.begin(); itp2 != itp2end; ++itp2)
873
                {
874
                        imageProfileComboBox->addItem(itp2.key());
875
                        if (itp2.key() == tp1)
876
                        {
877
                                if (cmsEnabled)
878
                                        imageProfileComboBox->setCurrentIndex(imageProfileComboBox->count()-1);
879
                        }
880
                }
881
                if (cmsEnabled)
882
                        imageRenderingIntentComboBox->setCurrentIndex(Opts.Intent2);
883
                //Disabling vs hiding
884
                enableSolidsImagesWidgets(cmsEnabled);
885
                convertSpotsToProcessCheckBox->setEnabled(true);
886
                if (m_doc!=0)
887
                {
888
                        useCustomRenderingCheckBox->setEnabled(true);
889
                        enableCustomRenderingWidgets(useCustomRenderingCheckBox->isChecked());
890
                }
891
        }
892
        else
893
        {
894
                convertSpotsToProcessCheckBox->setEnabled(false);
895
                useCustomRenderingCheckBox->setEnabled(false);
896
                enableCustomRenderingWidgets(false);
897
        }
898
}
899
 
900
 
901
void Prefs_PDFExport::enableLPI2()
902
{
903
        if (m_doc!=0)
904
                enableCustomRenderingWidgets(useCustomRenderingCheckBox->isChecked());
905
}
906
 
907
void Prefs_PDFExport::setCustomRenderingWidgetsShown(bool visible)
908
{
909
        useCustomRenderingCheckBox->setVisible(visible);
910
        customRenderingColorComboBox->setVisible(visible);
911
        customRenderingFrequencySpinBox->setVisible(visible);
912
        customRenderingAngleSpinBox->setVisible(visible);
913
        customRenderingSpotFunctionComboBox->setVisible(visible);
914
}
915
 
916
void Prefs_PDFExport::enableCustomRenderingWidgets(bool enabled)
917
{
918
        customRenderingColorComboBox->setEnabled(enabled);
919
        customRenderingFrequencySpinBox->setEnabled(enabled);
920
        customRenderingAngleSpinBox->setEnabled(enabled);
921
        customRenderingSpotFunctionComboBox->setEnabled(enabled);
922
}
923
 
924
void Prefs_PDFExport::setSolidsImagesWidgetsShown(bool visible)
925
{
926
        solidColorsLabel->setVisible(visible);
927
        solidColorsLine->setVisible(visible);
928
        useSolidColorProfileCheckBox->setVisible(visible);
929
        solidColorProfileComboBox->setVisible(visible);
930
        solidColorRenderingIntentComboBox->setVisible(visible);
931
        imagesLabel->setVisible(visible);
932
        imagesLine->setVisible(visible);
933
        useImageProfileCheckBox->setVisible(visible);
934
        doNotUseEmbeddedImageProfileCheckBox->setVisible(visible);
935
        imageProfileComboBox->setVisible(visible);
936
        imageRenderingIntentComboBox->setVisible(visible);
937
}
938
 
939
void Prefs_PDFExport::enableSolidsImagesWidgets(bool enabled)
940
{
941
        //if we want to show/hide instead
942
        //setSolidsImagesWidgetsShown(enabled);
21147 jghali 943
        bool enableSolidWidgets = false;
19828 jghali 944
        useSolidColorProfileCheckBox->setEnabled(enabled);
21147 jghali 945
        if (enabled)
946
                enableSolidWidgets = useSolidColorProfileCheckBox->isChecked();
947
        solidColorProfileComboBox->setEnabled(enableSolidWidgets);
948
        solidColorRenderingIntentComboBox->setEnabled(enableSolidWidgets);
949
 
950
        bool enableImageWidgets = false;
19828 jghali 951
        useImageProfileCheckBox->setEnabled(enabled);
21147 jghali 952
        if (enabled)
953
                enableImageWidgets = useImageProfileCheckBox->isChecked();
954
        doNotUseEmbeddedImageProfileCheckBox->setEnabled(enableImageWidgets);
955
        if (enableImageWidgets)
956
                enableImageWidgets = doNotUseEmbeddedImageProfileCheckBox->isChecked();
957
        imageProfileComboBox->setEnabled(enableImageWidgets);
958
        imageRenderingIntentComboBox->setEnabled(enableImageWidgets);
19828 jghali 959
}
960
 
961
void Prefs_PDFExport::enablePDFXWidgets(bool enabled)
962
{
963
        pdfx3OutputProfileComboBox->setEnabled(enabled);
964
        pdfx3InfoStringLineEdit->setEnabled(enabled);
965
}
966
 
967
 
968
void Prefs_PDFExport::enablePGI()
969
{
970
        bool setter=false;
971
        if (useImageProfileCheckBox->isChecked())
972
                setter = doNotUseEmbeddedImageProfileCheckBox->isChecked() ? true : false;
973
        imageProfileComboBox->setEnabled(setter);
974
        imageRenderingIntentComboBox->setEnabled(setter);
975
        doNotUseEmbeddedImageProfileCheckBox->setEnabled(useImageProfileCheckBox->isChecked());
976
}
977
 
978
void Prefs_PDFExport::enablePGI2()
979
{
980
        bool setter = doNotUseEmbeddedImageProfileCheckBox->isChecked() ? true : false;
981
        imageProfileComboBox->setEnabled(setter);
982
        imageRenderingIntentComboBox->setEnabled(setter);
983
}
984
 
985
void Prefs_PDFExport::enablePG()
986
{
987
        bool setter = useSolidColorProfileCheckBox->isChecked() ? true : false;
988
 
989
        solidColorProfileComboBox->setEnabled(setter);
990
        solidColorRenderingIntentComboBox->setEnabled(setter);
991
}
992
 
993
void Prefs_PDFExport::enablePDFX(int i)
994
{
995
        includeLayersCheckBox->setEnabled((i == 2) || (i == 5));
996
        if (useLayersRadioButton)
997
                useLayersRadioButton->setEnabled((i == 2) || (i == 5));
998
        if (m_doc != 0 && exportingPDF)
999
        {
1000
                int currentEff = effectTypeComboBox->currentIndex();
1001
                disconnect(effectTypeComboBox, SIGNAL(activated(int)), this, SLOT(SetEffOpts(int)));
1002
                effectTypeComboBox->clear();
1003
                effectTypeComboBox->addItem( tr("No Effect"));
1004
                effectTypeComboBox->addItem( tr("Blinds"));
1005
                effectTypeComboBox->addItem( tr("Box"));
1006
                effectTypeComboBox->addItem( tr("Dissolve"));
1007
                effectTypeComboBox->addItem( tr("Glitter"));
1008
                effectTypeComboBox->addItem( tr("Split"));
1009
                effectTypeComboBox->addItem( tr("Wipe"));
1010
                if (i == 2)
1011
                {
1012
                        effectTypeComboBox->addItem( tr("Push"));
1013
                        effectTypeComboBox->addItem( tr("Cover"));
1014
                        effectTypeComboBox->addItem( tr("Uncover"));
1015
                        effectTypeComboBox->addItem( tr("Fade"));
1016
                        effectTypeComboBox->setCurrentIndex(currentEff);
1017
                }
1018
                else
1019
                {
1020
                        if (currentEff > 6)
1021
                        {
1022
                                currentEff = 0;
1023
                                effectTypeComboBox->setCurrentIndex(0);
1024
                                SetEffOpts(0);
1025
                                for (int pg = 0; pg<m_doc->Pages->count(); ++pg)
1026
                                {
1027
                                        if (EffVal[pg].effectType > 6)
1028
                                                EffVal[pg].effectType = 0;
1029
                                }
1030
                        }
1031
                        else
1032
                                effectTypeComboBox->setCurrentIndex(currentEff);
1033
                }
1034
                connect(effectTypeComboBox, SIGNAL(activated(int)), this, SLOT(SetEffOpts(int)));
1035
        }
1036
 
1037
        if (i < 3)  // not PDF/X
1038
        {
22218 jghali 1039
                fontEmbeddingCombo->setNoEmbeddingEnabled(true);
19828 jghali 1040
                enablePDFXWidgets(false);
1041
                tabWidget->setTabEnabled(2, true);
1042
                outputIntentionComboBox->setEnabled(true);
1043
                useImageProfileCheckBox->setEnabled(true);
1044
                emit hasInfo();
1045
                if (m_doc != 0 && exportingPDF)
1046
                {
1047
                        enabledEffectsCheckBox->setEnabled(true);
20122 jghali 1048
                        embedAllButton->setEnabled(true);
19828 jghali 1049
                }
1050
 
1051
                return;
1052
        }
1053
        // PDF/X is selected
1054
        disconnect(outputIntentionComboBox, SIGNAL(activated(int)), this, SLOT(enableProfiles(int)));
1055
        outputIntentionComboBox->setCurrentIndex(1);
1056
        outputIntentionComboBox->setEnabled(false);
1057
        enableProfiles(1);
1058
        if ((i == 4) || (i == 5)) // X3 or X4, enforcing color profiles on images
1059
        {
1060
                useImageProfileCheckBox->setChecked(true);
1061
                useImageProfileCheckBox->setEnabled(false);
1062
        }
1063
        if (m_doc != 0 && exportingPDF)
1064
        {
1065
//              EmbedFonts->setChecked(true);
1066
                EmbedAll();
1067
                enabledEffectsCheckBox->setChecked(false);
1068
                enabledEffectsCheckBox->setEnabled(false);
1069
//              EmbedFonts->setEnabled(false);
1070
                if (pdfx3InfoStringLineEdit->text().isEmpty())
1071
                        emit noInfo();
1072
                else
1073
                        emit hasInfo();
1074
        }
20122 jghali 1075
 
22218 jghali 1076
        PDFOptions::PDFFontEmbedding oldEmbeddingMode = fontEmbeddingCombo->embeddingMode();
1077
        fontEmbeddingCombo->setNoEmbeddingEnabled(false);
1078
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingCombo->embeddingMode();
20122 jghali 1079
 
22218 jghali 1080
        if (oldEmbeddingMode != embeddingMode)
1081
                embeddedFontsListWidget->clearSelection();
1082
        embeddedFontsListWidget->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1083
        embedAllButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1084
        if (oldEmbeddingMode != embeddingMode)
1085
                subsettedFontsListWidget->clearSelection();
1086
        subsettedFontsListWidget->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1087
        subsetAllButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
20122 jghali 1088
        toSubsetButton->setEnabled(true);
1089
        fromSubsetButton->setEnabled(true);
1090
 
19828 jghali 1091
        enablePGI();
1092
        pdfx3OutputProfileComboBox->setEnabled(true);
1093
        pdfx3InfoStringLineEdit->setEnabled(true);
1094
        tabWidget->setTabEnabled(2, false);
1095
        connect(outputIntentionComboBox, SIGNAL(activated(int)), this, SLOT(enableProfiles(int)));
1096
}
1097
 
1098
void Prefs_PDFExport::addPDFVersions(bool addPDFXStrings)
1099
{
1100
        disconnect(pdfVersionComboBox, SIGNAL(activated(int)), this, SLOT(enablePDFX(int)));
22438 jghali 1101
        PDFOptions::PDFVersion currVersion = pdfVersionComboBox->version();
1102
        pdfVersionComboBox->setPDFXEnabled(addPDFXStrings);
1103
        if (!addPDFXStrings)
1104
                currVersion = qMax(PDFOptions::PDFVersion_13, qMin(currVersion, PDFOptions::PDFVersion_15));
1105
        pdfVersionComboBox->setVersion(currVersion);
19828 jghali 1106
        connect(pdfVersionComboBox, SIGNAL(activated(int)), this, SLOT(enablePDFX(int)));
1107
}
1108
 
1109
 
1110
void Prefs_PDFExport::enableEffects(bool enabled)
1111
{
1112
        effectsPageListWidget->setEnabled(enabled);
1113
        showPagePreviewsCheckBox->setEnabled(enabled);
1114
        displayDurationSpinBox->setEnabled(enabled);
1115
        effectDurationSpinBox->setEnabled(enabled);
1116
        effectTypeComboBox->setEnabled(enabled);
1117
        if (enabled)
1118
                SetEffOpts(effectTypeComboBox->currentIndex());
1119
        else
1120
        {
1121
                effectMovingDirectionComboBox->setEnabled(false);
1122
                effectInOutComboBox->setEnabled(false);
1123
                effectDirectionComboBox->setEnabled(false);
1124
                applyEffectToAllPagesPushButton->setEnabled(false);
1125
        }
1126
}
1127
 
20122 jghali 1128
void Prefs_PDFExport::EmbedAll()
20103 avox 1129
{
20122 jghali 1130
        embeddedFontsListWidget->clear();
1131
        subsettedFontsListWidget->clear();
1132
        toSubsetButton->setEnabled(false);
1133
        fromSubsetButton->setEnabled(false);
20103 avox 1134
 
20122 jghali 1135
        QStringList docFonts;
1136
        if (m_doc)
1137
                docFonts = m_doc->usedFonts().keys();
1138
 
1139
        for (int a=0; a < docFonts.count(); ++a)
19828 jghali 1140
        {
20122 jghali 1141
                QString fontName = docFonts.at(a);
1142
                if (!AllFonts[fontName].subset())
19828 jghali 1143
                {
20122 jghali 1144
                        QListWidgetItem* item = addFontItem(fontName, embeddedFontsListWidget);
19828 jghali 1145
                        if (AnnotationFonts.contains(item->text()))
20122 jghali 1146
                                item->setFlags(Qt::ItemIsEnabled);
19828 jghali 1147
                }
20122 jghali 1148
                else if (AnnotationFonts.contains(fontName))
1149
                {
1150
                        QListWidgetItem* item = addFontItem(fontName, embeddedFontsListWidget);
1151
                        item->setFlags(Qt::ItemIsEnabled);
1152
                }
19828 jghali 1153
                else
1154
                {
20122 jghali 1155
                        addFontItem(fontName, subsettedFontsListWidget);
19828 jghali 1156
                }
1157
        }
1158
}
1159
 
20122 jghali 1160
void Prefs_PDFExport::SubsetAll()
19828 jghali 1161
{
1162
        embeddedFontsListWidget->clear();
20122 jghali 1163
        subsettedFontsListWidget->clear();
1164
        toSubsetButton->setEnabled(false);
1165
        fromSubsetButton->setEnabled(false);
1166
 
1167
        QStringList docFonts;
1168
        if (m_doc)
1169
                docFonts = m_doc->usedFonts().keys();
1170
 
1171
        for (int a = 0; a < docFonts.count(); ++a)
19828 jghali 1172
        {
20122 jghali 1173
                QString fontName = docFonts.at(a);
1174
                if (AnnotationFonts.contains(fontName))
19828 jghali 1175
                {
20122 jghali 1176
                        QListWidgetItem* item = addFontItem(fontName, embeddedFontsListWidget);
1177
                        item->setFlags(Qt::ItemIsEnabled);
19828 jghali 1178
                }
1179
                else
1180
                {
20122 jghali 1181
                        addFontItem(fontName, subsettedFontsListWidget);
19828 jghali 1182
                }
1183
        }
1184
}
1185
 
20122 jghali 1186
void Prefs_PDFExport::OutlineAll()
1187
{
1188
        // Nothing to do at this point
1189
}
1190
 
19828 jghali 1191
void Prefs_PDFExport::doDocBleeds()
1192
{
1193
        if (useDocumentBleedsCheckBox->isChecked())
1194
        {
1195
                Opts.bleeds=bleedsWidget->margins();
1196
                bleedsWidget->setNewValues(m_doc->bleedsVal());
1197
                bleedsWidget->setEnabled(false);
1198
        }
1199
        else
1200
        {
1201
                bleedsWidget->setNewValues(Opts.bleeds);
1202
                bleedsWidget->setEnabled(true);
1203
        }
1204
}
1205
 
1206
 
1207
void Prefs_PDFExport::SetEffOpts(int nr)
1208
{
1209
        QStandardItem* si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(2));
1210
        if (si) si->setSelectable(false);
1211
        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(3));
1212
        if (si) si->setSelectable(false);
1213
        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(4));
1214
        if (si) si->setSelectable(false);
1215
        switch (nr)
1216
        {
1217
        case 0:
1218
        case 3:
1219
        case 10:
1220
                effectMovingDirectionComboBox->setEnabled(false);
1221
                effectInOutComboBox->setEnabled(false);
1222
                effectDirectionComboBox->setEnabled(false);
1223
                break;
1224
        case 1:
1225
                effectMovingDirectionComboBox->setEnabled(true);
1226
                effectInOutComboBox->setEnabled(false);
1227
                effectDirectionComboBox->setEnabled(false);
1228
                break;
1229
        case 2:
1230
                effectMovingDirectionComboBox->setEnabled(false);
1231
                effectInOutComboBox->setEnabled(true);
1232
                effectDirectionComboBox->setEnabled(false);
1233
                break;
1234
        case 4:
1235
        case 6:
1236
        case 7:
1237
        case 8:
1238
        case 9:
1239
                effectMovingDirectionComboBox->setEnabled(false);
1240
                effectInOutComboBox->setEnabled(false);
1241
                effectDirectionComboBox->setEnabled(true);
1242
                if (nr == 6)
1243
                {
1244
                        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(2));
1245
                        if (si) si->setSelectable(true);
1246
                        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(3));
1247
                        if (si) si->setSelectable(true);
1248
                }
1249
                else
1250
                {
1251
                        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(4));
1252
                        if (si) si->setSelectable(true);
1253
                }
1254
                break;
1255
        case 5:
1256
                effectMovingDirectionComboBox->setEnabled(true);
1257
                effectInOutComboBox->setEnabled(true);
1258
                effectDirectionComboBox->setEnabled(false);
1259
                break;
1260
        }
1261
}
1262
 
1263
void Prefs_PDFExport::SelEFont(QListWidgetItem *c)
1264
{
22521 craig 1265
        if (c != nullptr)
19828 jghali 1266
        {
1267
                if (c->flags() & Qt::ItemIsSelectable)
20122 jghali 1268
                        toSubsetButton->setEnabled(true);
1269
                fromSubsetButton->setEnabled(false);
1270
                subsettedFontsListWidget->clearSelection();
19828 jghali 1271
        }
1272
}
1273
 
1274
void Prefs_PDFExport::SelSFont(QListWidgetItem *c)
1275
{
22438 jghali 1276
        if (!c)
1277
                return;
1278
 
1279
        if (pdfVersionComboBox->versionIsPDFX())
19828 jghali 1280
        {
22438 jghali 1281
                if ((AllFonts[c->text()].type() == ScFace::OTF) || (AllFonts[c->text()].subset()))
1282
                        fromSubsetButton->setEnabled(false);
19828 jghali 1283
                else
20122 jghali 1284
                        fromSubsetButton->setEnabled(true);
19828 jghali 1285
        }
22438 jghali 1286
        else
1287
                fromSubsetButton->setEnabled(true);
1288
        toSubsetButton->setEnabled(false);
1289
        embeddedFontsListWidget->clearSelection();
19828 jghali 1290
}
1291
 
1292
void Prefs_PDFExport::PagePr()
1293
{
1294
        disconnect(effectsPageListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(SetPgEff()));
1295
        QString tmp;
1296
        QPixmap pm;
1297
        int ci = effectsPageListWidget->currentRow();
1298
        int pgMaxX = 0;
1299
        int pgMaxY = 0;
1300
        effectsPageListWidget->clear();
1301
        if (showPagePreviewsCheckBox->isChecked())
1302
        {
1303
                for (int pg = 0; pg < m_doc->Pages->count(); ++pg)
1304
                {
1305
                        pm=QPixmap::fromImage(m_doc->view()->PageToPixmap(pg, 70));
1306
                        pgMaxX = qMax(pgMaxX, pm.width());
1307
                        pgMaxY = qMax(pgMaxY, pm.height());
1308
                        new QListWidgetItem( pm, tr("Page")+" "+tmp.setNum(pg+1), effectsPageListWidget);
1309
                }
1310
                effectsPageListWidget->setIconSize(QSize(pgMaxX, pgMaxY));
1311
        }
1312
        else
1313
        {
1314
                for (int pg = 0; pg < m_doc->Pages->count(); ++pg)
1315
                {
1316
                        new QListWidgetItem( tr("Page")+" "+tmp.setNum(pg+1), effectsPageListWidget);
1317
                }
1318
        }
1319
        if (ci != -1)
1320
                effectsPageListWidget->setCurrentRow(ci);
1321
        else
1322
                effectsPageListWidget->clearSelection();
1323
        connect(effectsPageListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(SetPgEff()));
1324
}
1325
 
1326
void Prefs_PDFExport::DoDownsample()
1327
{
1328
        if (maxResolutionLimitCheckBox->isChecked())
1329
        {
1330
                maxExportResolutionSpinBox->setEnabled(true);
1331
                if (maxExportResolutionSpinBox->value() > epsExportResolutionSpinBox->value())
1332
                        maxExportResolutionSpinBox->setValue(epsExportResolutionSpinBox->value());
1333
        }
1334
        else
1335
                maxExportResolutionSpinBox->setEnabled(false);
1336
}
1337
 
20122 jghali 1338
void Prefs_PDFExport::EmbeddingModeChange()
19828 jghali 1339
{
22218 jghali 1340
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingCombo->embeddingMode();
20122 jghali 1341
 
1342
        embeddedFontsListWidget->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1343
        embedAllButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1344
        subsettedFontsListWidget->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1345
        subsetAllButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1346
        toSubsetButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1347
        fromSubsetButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
19828 jghali 1348
}
1349
 
20122 jghali 1350
void Prefs_PDFExport::RemoveSubset()
19828 jghali 1351
{
20122 jghali 1352
        QString currentFont = subsettedFontsListWidget->currentItem()->text();
1353
        const ScFace fontFace = AllFonts[currentFont];
1354
        if ((fontFace.type() != ScFace::OTF) && (!fontFace.subset()))
19828 jghali 1355
        {
20122 jghali 1356
                embeddedFontsListWidget->addItem(currentFont);
1357
                delete subsettedFontsListWidget->takeItem(subsettedFontsListWidget->currentRow());
19828 jghali 1358
        }
20122 jghali 1359
        subsettedFontsListWidget->clearSelection();
1360
        if (subsettedFontsListWidget->count() == 0)
1361
                fromSubsetButton->setEnabled(false);
19828 jghali 1362
}
1363
 
20122 jghali 1364
void Prefs_PDFExport::PutToSubset()
19828 jghali 1365
{
1366
        QString currentFont = embeddedFontsListWidget->currentItem()->text();
20122 jghali 1367
        if (subsettedFontsListWidget->count() != 0)
19828 jghali 1368
        {
20122 jghali 1369
                if (subsettedFontsListWidget->findItems(currentFont, Qt::MatchExactly).count() == 0)
1370
                        addFontItem(currentFont, subsettedFontsListWidget);
19828 jghali 1371
        }
1372
        else
1373
        {
20122 jghali 1374
                addFontItem(currentFont, subsettedFontsListWidget);
19828 jghali 1375
        }
1376
        delete embeddedFontsListWidget->takeItem(embeddedFontsListWidget->currentRow());
1377
        embeddedFontsListWidget->clearSelection();
1378
        if (embeddedFontsListWidget->count() == 0)
1379
        {
20122 jghali 1380
                toSubsetButton->setEnabled(false);
19828 jghali 1381
        }
20122 jghali 1382
        else if (!(embeddedFontsListWidget->currentItem()->flags() & Qt::ItemIsSelectable))
19828 jghali 1383
        {
20122 jghali 1384
                toSubsetButton->setEnabled(false);
19828 jghali 1385
        }
1386
}