Subversion Repositories Scribus

Rev

Rev 22832 | Rev 23054 | 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
 
22635 craig 151
QListWidgetItem* Prefs_PDFExport::addFontItem(const QString& fontName, QListWidget* fontList)
20122 jghali 152
{
22601 craig 153
        QListWidgetItem* item = nullptr;
20122 jghali 154
        if (!AllFonts.contains(fontName))
22601 craig 155
                return nullptr;
20122 jghali 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);
22601 craig 293
        if (m_doc != nullptr && exportingPDF)
19828 jghali 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
                        {
22601 craig 355
                                const QString& fontName = docFonts.at(fe);
20122 jghali 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
        {
22601 craig 477
                if (m_doc != nullptr && exportingPDF)
19828 jghali 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
        {
22601 craig 498
                if (m_doc != nullptr && exportingPDF)
19828 jghali 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
        {
22601 craig 527
                if (m_doc != nullptr && exportingPDF)
19828 jghali 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
        {
22601 craig 544
                if (m_doc != nullptr && exporting)
19828 jghali 545
                {
22832 craig 546
                        QFileInfo fi(m_doc->documentFileName());
19828 jghali 547
                        pdfx3InfoStringLineEdit->setText(fi.fileName());
548
                }
549
                else
550
                        pdfx3InfoStringLineEdit->setText( tr("InfoString"));
551
        }
552
 
22601 craig 553
        if (m_doc != nullptr && exportingPDF)
19828 jghali 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
 
22601 craig 579
        if (m_doc != nullptr  && exportingPDF)
19828 jghali 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
 
22601 craig 620
        if (m_doc != nullptr && exportingPDF)
19828 jghali 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()));
22601 craig 629
                connect(effectsPageListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SetPgEff()));
19828 jghali 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 );
22601 craig 766
        if (!enabled)
19828 jghali 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
{
22601 craig 800
        if (m_doc!=nullptr)
19828 jghali 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
        }
23049 craig 811
        exportPageListLineEdit->setText(QString());
19828 jghali 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
                {
22601 craig 842
                        if (m_doc != nullptr)
19828 jghali 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
                {
22601 craig 864
                        if (m_doc != nullptr)
19828 jghali 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);
22601 craig 886
                if (m_doc!=nullptr)
19828 jghali 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
{
22601 craig 903
        if (m_doc!=nullptr)
19828 jghali 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())
22639 craig 972
                setter = doNotUseEmbeddedImageProfileCheckBox->isChecked();
19828 jghali 973
        imageProfileComboBox->setEnabled(setter);
974
        imageRenderingIntentComboBox->setEnabled(setter);
975
        doNotUseEmbeddedImageProfileCheckBox->setEnabled(useImageProfileCheckBox->isChecked());
976
}
977
 
978
void Prefs_PDFExport::enablePGI2()
979
{
22601 craig 980
        bool setter = doNotUseEmbeddedImageProfileCheckBox->isChecked();
19828 jghali 981
        imageProfileComboBox->setEnabled(setter);
982
        imageRenderingIntentComboBox->setEnabled(setter);
983
}
984
 
985
void Prefs_PDFExport::enablePG()
986
{
22601 craig 987
        bool setter = useSolidColorProfileCheckBox->isChecked();
19828 jghali 988
        solidColorProfileComboBox->setEnabled(setter);
989
        solidColorRenderingIntentComboBox->setEnabled(setter);
990
}
991
 
992
void Prefs_PDFExport::enablePDFX(int i)
993
{
994
        includeLayersCheckBox->setEnabled((i == 2) || (i == 5));
995
        if (useLayersRadioButton)
996
                useLayersRadioButton->setEnabled((i == 2) || (i == 5));
22601 craig 997
        if (m_doc != nullptr && exportingPDF)
19828 jghali 998
        {
999
                int currentEff = effectTypeComboBox->currentIndex();
1000
                disconnect(effectTypeComboBox, SIGNAL(activated(int)), this, SLOT(SetEffOpts(int)));
1001
                effectTypeComboBox->clear();
1002
                effectTypeComboBox->addItem( tr("No Effect"));
1003
                effectTypeComboBox->addItem( tr("Blinds"));
1004
                effectTypeComboBox->addItem( tr("Box"));
1005
                effectTypeComboBox->addItem( tr("Dissolve"));
1006
                effectTypeComboBox->addItem( tr("Glitter"));
1007
                effectTypeComboBox->addItem( tr("Split"));
1008
                effectTypeComboBox->addItem( tr("Wipe"));
1009
                if (i == 2)
1010
                {
1011
                        effectTypeComboBox->addItem( tr("Push"));
1012
                        effectTypeComboBox->addItem( tr("Cover"));
1013
                        effectTypeComboBox->addItem( tr("Uncover"));
1014
                        effectTypeComboBox->addItem( tr("Fade"));
1015
                        effectTypeComboBox->setCurrentIndex(currentEff);
1016
                }
1017
                else
1018
                {
1019
                        if (currentEff > 6)
1020
                        {
1021
                                currentEff = 0;
1022
                                effectTypeComboBox->setCurrentIndex(0);
1023
                                SetEffOpts(0);
1024
                                for (int pg = 0; pg<m_doc->Pages->count(); ++pg)
1025
                                {
1026
                                        if (EffVal[pg].effectType > 6)
1027
                                                EffVal[pg].effectType = 0;
1028
                                }
1029
                        }
1030
                        else
1031
                                effectTypeComboBox->setCurrentIndex(currentEff);
1032
                }
1033
                connect(effectTypeComboBox, SIGNAL(activated(int)), this, SLOT(SetEffOpts(int)));
1034
        }
1035
 
1036
        if (i < 3)  // not PDF/X
1037
        {
22218 jghali 1038
                fontEmbeddingCombo->setNoEmbeddingEnabled(true);
19828 jghali 1039
                enablePDFXWidgets(false);
1040
                tabWidget->setTabEnabled(2, true);
1041
                outputIntentionComboBox->setEnabled(true);
1042
                useImageProfileCheckBox->setEnabled(true);
1043
                emit hasInfo();
22601 craig 1044
                if (m_doc != nullptr && exportingPDF)
19828 jghali 1045
                {
1046
                        enabledEffectsCheckBox->setEnabled(true);
20122 jghali 1047
                        embedAllButton->setEnabled(true);
19828 jghali 1048
                }
1049
 
1050
                return;
1051
        }
1052
        // PDF/X is selected
1053
        disconnect(outputIntentionComboBox, SIGNAL(activated(int)), this, SLOT(enableProfiles(int)));
1054
        outputIntentionComboBox->setCurrentIndex(1);
1055
        outputIntentionComboBox->setEnabled(false);
1056
        enableProfiles(1);
1057
        if ((i == 4) || (i == 5)) // X3 or X4, enforcing color profiles on images
1058
        {
1059
                useImageProfileCheckBox->setChecked(true);
1060
                useImageProfileCheckBox->setEnabled(false);
1061
        }
22601 craig 1062
        if (m_doc != nullptr && exportingPDF)
19828 jghali 1063
        {
1064
//              EmbedFonts->setChecked(true);
1065
                EmbedAll();
1066
                enabledEffectsCheckBox->setChecked(false);
1067
                enabledEffectsCheckBox->setEnabled(false);
1068
//              EmbedFonts->setEnabled(false);
1069
                if (pdfx3InfoStringLineEdit->text().isEmpty())
1070
                        emit noInfo();
1071
                else
1072
                        emit hasInfo();
1073
        }
20122 jghali 1074
 
22218 jghali 1075
        PDFOptions::PDFFontEmbedding oldEmbeddingMode = fontEmbeddingCombo->embeddingMode();
1076
        fontEmbeddingCombo->setNoEmbeddingEnabled(false);
1077
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingCombo->embeddingMode();
20122 jghali 1078
 
22218 jghali 1079
        if (oldEmbeddingMode != embeddingMode)
1080
                embeddedFontsListWidget->clearSelection();
1081
        embeddedFontsListWidget->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1082
        embedAllButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1083
        if (oldEmbeddingMode != embeddingMode)
1084
                subsettedFontsListWidget->clearSelection();
1085
        subsettedFontsListWidget->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1086
        subsetAllButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
20122 jghali 1087
        toSubsetButton->setEnabled(true);
1088
        fromSubsetButton->setEnabled(true);
1089
 
19828 jghali 1090
        enablePGI();
1091
        pdfx3OutputProfileComboBox->setEnabled(true);
1092
        pdfx3InfoStringLineEdit->setEnabled(true);
1093
        tabWidget->setTabEnabled(2, false);
1094
        connect(outputIntentionComboBox, SIGNAL(activated(int)), this, SLOT(enableProfiles(int)));
1095
}
1096
 
1097
void Prefs_PDFExport::addPDFVersions(bool addPDFXStrings)
1098
{
1099
        disconnect(pdfVersionComboBox, SIGNAL(activated(int)), this, SLOT(enablePDFX(int)));
22438 jghali 1100
        PDFOptions::PDFVersion currVersion = pdfVersionComboBox->version();
1101
        pdfVersionComboBox->setPDFXEnabled(addPDFXStrings);
1102
        if (!addPDFXStrings)
1103
                currVersion = qMax(PDFOptions::PDFVersion_13, qMin(currVersion, PDFOptions::PDFVersion_15));
1104
        pdfVersionComboBox->setVersion(currVersion);
19828 jghali 1105
        connect(pdfVersionComboBox, SIGNAL(activated(int)), this, SLOT(enablePDFX(int)));
1106
}
1107
 
1108
 
1109
void Prefs_PDFExport::enableEffects(bool enabled)
1110
{
1111
        effectsPageListWidget->setEnabled(enabled);
1112
        showPagePreviewsCheckBox->setEnabled(enabled);
1113
        displayDurationSpinBox->setEnabled(enabled);
1114
        effectDurationSpinBox->setEnabled(enabled);
1115
        effectTypeComboBox->setEnabled(enabled);
1116
        if (enabled)
1117
                SetEffOpts(effectTypeComboBox->currentIndex());
1118
        else
1119
        {
1120
                effectMovingDirectionComboBox->setEnabled(false);
1121
                effectInOutComboBox->setEnabled(false);
1122
                effectDirectionComboBox->setEnabled(false);
1123
                applyEffectToAllPagesPushButton->setEnabled(false);
1124
        }
1125
}
1126
 
20122 jghali 1127
void Prefs_PDFExport::EmbedAll()
20103 avox 1128
{
20122 jghali 1129
        embeddedFontsListWidget->clear();
1130
        subsettedFontsListWidget->clear();
1131
        toSubsetButton->setEnabled(false);
1132
        fromSubsetButton->setEnabled(false);
20103 avox 1133
 
20122 jghali 1134
        QStringList docFonts;
1135
        if (m_doc)
1136
                docFonts = m_doc->usedFonts().keys();
1137
 
1138
        for (int a=0; a < docFonts.count(); ++a)
19828 jghali 1139
        {
22601 craig 1140
                const QString& fontName = docFonts.at(a);
20122 jghali 1141
                if (!AllFonts[fontName].subset())
19828 jghali 1142
                {
20122 jghali 1143
                        QListWidgetItem* item = addFontItem(fontName, embeddedFontsListWidget);
19828 jghali 1144
                        if (AnnotationFonts.contains(item->text()))
20122 jghali 1145
                                item->setFlags(Qt::ItemIsEnabled);
19828 jghali 1146
                }
20122 jghali 1147
                else if (AnnotationFonts.contains(fontName))
1148
                {
1149
                        QListWidgetItem* item = addFontItem(fontName, embeddedFontsListWidget);
1150
                        item->setFlags(Qt::ItemIsEnabled);
1151
                }
19828 jghali 1152
                else
1153
                {
20122 jghali 1154
                        addFontItem(fontName, subsettedFontsListWidget);
19828 jghali 1155
                }
1156
        }
1157
}
1158
 
20122 jghali 1159
void Prefs_PDFExport::SubsetAll()
19828 jghali 1160
{
1161
        embeddedFontsListWidget->clear();
20122 jghali 1162
        subsettedFontsListWidget->clear();
1163
        toSubsetButton->setEnabled(false);
1164
        fromSubsetButton->setEnabled(false);
1165
 
1166
        QStringList docFonts;
1167
        if (m_doc)
1168
                docFonts = m_doc->usedFonts().keys();
1169
 
1170
        for (int a = 0; a < docFonts.count(); ++a)
19828 jghali 1171
        {
22601 craig 1172
                const QString& fontName = docFonts.at(a);
20122 jghali 1173
                if (AnnotationFonts.contains(fontName))
19828 jghali 1174
                {
20122 jghali 1175
                        QListWidgetItem* item = addFontItem(fontName, embeddedFontsListWidget);
1176
                        item->setFlags(Qt::ItemIsEnabled);
19828 jghali 1177
                }
1178
                else
1179
                {
20122 jghali 1180
                        addFontItem(fontName, subsettedFontsListWidget);
19828 jghali 1181
                }
1182
        }
1183
}
1184
 
20122 jghali 1185
void Prefs_PDFExport::OutlineAll()
1186
{
1187
        // Nothing to do at this point
1188
}
1189
 
19828 jghali 1190
void Prefs_PDFExport::doDocBleeds()
1191
{
1192
        if (useDocumentBleedsCheckBox->isChecked())
1193
        {
1194
                Opts.bleeds=bleedsWidget->margins();
1195
                bleedsWidget->setNewValues(m_doc->bleedsVal());
1196
                bleedsWidget->setEnabled(false);
1197
        }
1198
        else
1199
        {
1200
                bleedsWidget->setNewValues(Opts.bleeds);
1201
                bleedsWidget->setEnabled(true);
1202
        }
1203
}
1204
 
1205
 
1206
void Prefs_PDFExport::SetEffOpts(int nr)
1207
{
1208
        QStandardItem* si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(2));
1209
        if (si) si->setSelectable(false);
1210
        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(3));
1211
        if (si) si->setSelectable(false);
1212
        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(4));
1213
        if (si) si->setSelectable(false);
1214
        switch (nr)
1215
        {
1216
        case 0:
1217
        case 3:
1218
        case 10:
1219
                effectMovingDirectionComboBox->setEnabled(false);
1220
                effectInOutComboBox->setEnabled(false);
1221
                effectDirectionComboBox->setEnabled(false);
1222
                break;
1223
        case 1:
1224
                effectMovingDirectionComboBox->setEnabled(true);
1225
                effectInOutComboBox->setEnabled(false);
1226
                effectDirectionComboBox->setEnabled(false);
1227
                break;
1228
        case 2:
1229
                effectMovingDirectionComboBox->setEnabled(false);
1230
                effectInOutComboBox->setEnabled(true);
1231
                effectDirectionComboBox->setEnabled(false);
1232
                break;
1233
        case 4:
1234
        case 6:
1235
        case 7:
1236
        case 8:
1237
        case 9:
1238
                effectMovingDirectionComboBox->setEnabled(false);
1239
                effectInOutComboBox->setEnabled(false);
1240
                effectDirectionComboBox->setEnabled(true);
1241
                if (nr == 6)
1242
                {
1243
                        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(2));
1244
                        if (si) si->setSelectable(true);
1245
                        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(3));
1246
                        if (si) si->setSelectable(true);
1247
                }
1248
                else
1249
                {
1250
                        si = dynamic_cast<QStandardItem*>(effectDirectionComboBox->view()->children().at(4));
1251
                        if (si) si->setSelectable(true);
1252
                }
1253
                break;
1254
        case 5:
1255
                effectMovingDirectionComboBox->setEnabled(true);
1256
                effectInOutComboBox->setEnabled(true);
1257
                effectDirectionComboBox->setEnabled(false);
1258
                break;
1259
        }
1260
}
1261
 
1262
void Prefs_PDFExport::SelEFont(QListWidgetItem *c)
1263
{
22521 craig 1264
        if (c != nullptr)
19828 jghali 1265
        {
1266
                if (c->flags() & Qt::ItemIsSelectable)
20122 jghali 1267
                        toSubsetButton->setEnabled(true);
1268
                fromSubsetButton->setEnabled(false);
1269
                subsettedFontsListWidget->clearSelection();
19828 jghali 1270
        }
1271
}
1272
 
1273
void Prefs_PDFExport::SelSFont(QListWidgetItem *c)
1274
{
22438 jghali 1275
        if (!c)
1276
                return;
1277
 
1278
        if (pdfVersionComboBox->versionIsPDFX())
19828 jghali 1279
        {
22438 jghali 1280
                if ((AllFonts[c->text()].type() == ScFace::OTF) || (AllFonts[c->text()].subset()))
1281
                        fromSubsetButton->setEnabled(false);
19828 jghali 1282
                else
20122 jghali 1283
                        fromSubsetButton->setEnabled(true);
19828 jghali 1284
        }
22438 jghali 1285
        else
1286
                fromSubsetButton->setEnabled(true);
1287
        toSubsetButton->setEnabled(false);
1288
        embeddedFontsListWidget->clearSelection();
19828 jghali 1289
}
1290
 
1291
void Prefs_PDFExport::PagePr()
1292
{
1293
        disconnect(effectsPageListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(SetPgEff()));
1294
        QString tmp;
1295
        QPixmap pm;
1296
        int ci = effectsPageListWidget->currentRow();
1297
        int pgMaxX = 0;
1298
        int pgMaxY = 0;
1299
        effectsPageListWidget->clear();
1300
        if (showPagePreviewsCheckBox->isChecked())
1301
        {
1302
                for (int pg = 0; pg < m_doc->Pages->count(); ++pg)
1303
                {
1304
                        pm=QPixmap::fromImage(m_doc->view()->PageToPixmap(pg, 70));
1305
                        pgMaxX = qMax(pgMaxX, pm.width());
1306
                        pgMaxY = qMax(pgMaxY, pm.height());
1307
                        new QListWidgetItem( pm, tr("Page")+" "+tmp.setNum(pg+1), effectsPageListWidget);
1308
                }
1309
                effectsPageListWidget->setIconSize(QSize(pgMaxX, pgMaxY));
1310
        }
1311
        else
1312
        {
1313
                for (int pg = 0; pg < m_doc->Pages->count(); ++pg)
1314
                {
1315
                        new QListWidgetItem( tr("Page")+" "+tmp.setNum(pg+1), effectsPageListWidget);
1316
                }
1317
        }
1318
        if (ci != -1)
1319
                effectsPageListWidget->setCurrentRow(ci);
1320
        else
1321
                effectsPageListWidget->clearSelection();
22601 craig 1322
        connect(effectsPageListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SetPgEff()));
19828 jghali 1323
}
1324
 
1325
void Prefs_PDFExport::DoDownsample()
1326
{
1327
        if (maxResolutionLimitCheckBox->isChecked())
1328
        {
1329
                maxExportResolutionSpinBox->setEnabled(true);
1330
                if (maxExportResolutionSpinBox->value() > epsExportResolutionSpinBox->value())
1331
                        maxExportResolutionSpinBox->setValue(epsExportResolutionSpinBox->value());
1332
        }
1333
        else
1334
                maxExportResolutionSpinBox->setEnabled(false);
1335
}
1336
 
20122 jghali 1337
void Prefs_PDFExport::EmbeddingModeChange()
19828 jghali 1338
{
22218 jghali 1339
        PDFOptions::PDFFontEmbedding embeddingMode = fontEmbeddingCombo->embeddingMode();
20122 jghali 1340
 
1341
        embeddedFontsListWidget->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1342
        embedAllButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1343
        subsettedFontsListWidget->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1344
        subsetAllButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1345
        toSubsetButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
1346
        fromSubsetButton->setEnabled(embeddingMode == PDFOptions::EmbedFonts);
19828 jghali 1347
}
1348
 
20122 jghali 1349
void Prefs_PDFExport::RemoveSubset()
19828 jghali 1350
{
20122 jghali 1351
        QString currentFont = subsettedFontsListWidget->currentItem()->text();
1352
        const ScFace fontFace = AllFonts[currentFont];
1353
        if ((fontFace.type() != ScFace::OTF) && (!fontFace.subset()))
19828 jghali 1354
        {
20122 jghali 1355
                embeddedFontsListWidget->addItem(currentFont);
1356
                delete subsettedFontsListWidget->takeItem(subsettedFontsListWidget->currentRow());
19828 jghali 1357
        }
20122 jghali 1358
        subsettedFontsListWidget->clearSelection();
1359
        if (subsettedFontsListWidget->count() == 0)
1360
                fromSubsetButton->setEnabled(false);
19828 jghali 1361
}
1362
 
20122 jghali 1363
void Prefs_PDFExport::PutToSubset()
19828 jghali 1364
{
1365
        QString currentFont = embeddedFontsListWidget->currentItem()->text();
20122 jghali 1366
        if (subsettedFontsListWidget->count() != 0)
19828 jghali 1367
        {
20122 jghali 1368
                if (subsettedFontsListWidget->findItems(currentFont, Qt::MatchExactly).count() == 0)
1369
                        addFontItem(currentFont, subsettedFontsListWidget);
19828 jghali 1370
        }
1371
        else
1372
        {
20122 jghali 1373
                addFontItem(currentFont, subsettedFontsListWidget);
19828 jghali 1374
        }
1375
        delete embeddedFontsListWidget->takeItem(embeddedFontsListWidget->currentRow());
1376
        embeddedFontsListWidget->clearSelection();
1377
        if (embeddedFontsListWidget->count() == 0)
1378
        {
20122 jghali 1379
                toSubsetButton->setEnabled(false);
19828 jghali 1380
        }
20122 jghali 1381
        else if (!(embeddedFontsListWidget->currentItem()->flags() & Qt::ItemIsSelectable))
19828 jghali 1382
        {
20122 jghali 1383
                toSubsetButton->setEnabled(false);
19828 jghali 1384
        }
1385
}