Subversion Repositories Scribus

Rev

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