Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
13761 cbradney 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
 
14448 cbradney 8
#include "ui/prefs_pdfexport.h"
14451 cbradney 9
#include "ui/createrange.h"
14448 cbradney 10
#include "prefsstructs.h"
13761 cbradney 11
 
14451 cbradney 12
#include "scribuscore.h"
13
#include "scribusdoc.h"
14
#include "ui/scrspinbox.h"
15
#include "units.h"
16
#include "util_icon.h"
17
 
13761 cbradney 18
Prefs_PDFExport::Prefs_PDFExport(QWidget* parent)
14451 cbradney 19
        : Prefs_Pane(parent),
20
        cmsEnabled(false),
21
        m_doc(NULL)
13761 cbradney 22
{
23
        setupUi(this);
14451 cbradney 24
        pageMirrorHorizontalToolButton->setIcon(QIcon(loadIcon("16/flip-object-horizontal.png")));
25
        pageMirrorVerticalToolButton->setIcon(QIcon(loadIcon("16/flip-object-vertical.png")));
26
        unitChange(0);
27
        languageChange();
13761 cbradney 28
 
14451 cbradney 29
        connect(exportChosenPagesRadioButton, SIGNAL(toggled(bool)), this, SLOT(enableRangeControls(bool)));
30
        connect(exportRangeMorePushButton, SIGNAL(clicked()), this, SLOT(createPageNumberRange()));
31
//      connect(DSColor, SIGNAL(clicked()), this, SLOT(DoDownsample()));
32
//      connect(MirrorH, SIGNAL(clicked()), this, SLOT(PDFMirror()));
33
//      connect(MirrorV, SIGNAL(clicked()), this, SLOT(PDFMirror()));
34
//      connect(RotateDeg, SIGNAL(activated(int)), this, SLOT(Rotation(int)));
35
//      connect(OutCombo, SIGNAL(activated(int)), this, SLOT(EnablePr(int)));
36
//      connect(EmbedProfs, SIGNAL(clicked()), this, SLOT(EnablePG()));
37
//      connect(EmbedProfs2, SIGNAL(clicked()), this, SLOT(EnablePGI()));
38
//      connect(NoEmbedded, SIGNAL(clicked()), this, SLOT(EnablePGI2()));
39
//      connect(PDFVersionCombo, SIGNAL(activated(int)), this, SLOT(EnablePDFX(int)));
40
        connect(useEncryptionCheckBox, SIGNAL(clicked(bool)), this, SLOT(enableSecurityControls(bool)));
13761 cbradney 41
}
42
 
43
Prefs_PDFExport::~Prefs_PDFExport()
44
{
45
}
46
 
14451 cbradney 47
 
48
void Prefs_PDFExport::unitChange(int unitIndex)
49
{
50
        double unitRatio = unitGetRatioFromIndex(unitIndex);
51
        registrationMarkOffsetSpinBox->setNewUnit(unitIndex);
52
        registrationMarkOffsetSpinBox->setMinimum(0);
53
        registrationMarkOffsetSpinBox->setMaximum(3000 * unitRatio);
54
}
55
 
14448 cbradney 56
void Prefs_PDFExport::languageChange()
57
{
14451 cbradney 58
        int i=0;
59
        i = rotationComboBox->currentIndex();
60
        rotationComboBox->clear();
61
        rotationComboBox->addItem(QString::fromUtf8("0 °"));
62
        rotationComboBox->addItem(QString::fromUtf8("90 °"));
63
        rotationComboBox->addItem(QString::fromUtf8("180 °"));
64
        rotationComboBox->addItem(QString::fromUtf8("270 °"));
65
        rotationComboBox->setCurrentIndex(i);
66
 
67
        i = imageCompressionMethodComboBox->currentIndex();
68
        imageCompressionMethodComboBox->clear();
69
        imageCompressionMethodComboBox->addItem( tr( "Automatic" ) );
70
        imageCompressionMethodComboBox->addItem( tr( "Lossy - JPEG" ) );
71
        imageCompressionMethodComboBox->addItem( tr( "Lossless - Zip" ) );
72
        imageCompressionMethodComboBox->addItem( tr( "None" ) );
73
        imageCompressionMethodComboBox->setCurrentIndex(i);
74
 
75
        i = imageCompressionQualityComboBox->currentIndex();
76
        imageCompressionQualityComboBox->clear();
77
        imageCompressionQualityComboBox->addItem( tr( "Maximum" ) );
78
        imageCompressionQualityComboBox->addItem( tr( "High" ) );
79
        imageCompressionQualityComboBox->addItem( tr( "Medium" ) );
80
        imageCompressionQualityComboBox->addItem( tr( "Low" ) );
81
        imageCompressionQualityComboBox->addItem( tr( "Minimum" ) );
82
        imageCompressionQualityComboBox->setCurrentIndex(i);
83
 
84
        i = pdfVersionComboBox->currentIndex();
85
        pdfVersionComboBox->clear();
86
        pdfVersionComboBox->addItem("PDF 1.3 (Acrobat 4)");
87
        pdfVersionComboBox->addItem("PDF 1.4 (Acrobat 5)");
88
        pdfVersionComboBox->addItem("PDF 1.5 (Acrobat 6)");
89
        if (cmsEnabled)// && (!PDFXProfiles.isEmpty()))
90
        {
91
                pdfVersionComboBox->addItem("PDF/X-1a");
92
                pdfVersionComboBox->addItem("PDF/X-3");
93
                pdfVersionComboBox->addItem("PDF/X-4");
94
        }
95
        pdfVersionComboBox->setCurrentIndex(i);
96
 
97
        i = pageBindingComboBox->currentIndex();
98
        pageBindingComboBox->clear();
99
        pageBindingComboBox->addItem( tr("Left Margin"));
100
        pageBindingComboBox->addItem( tr("Right Margin"));
101
        pageBindingComboBox->setCurrentIndex(i);
102
 
103
        i = outputIntentionCheckBox->currentIndex();
104
        outputIntentionCheckBox->clear();
105
        outputIntentionCheckBox->addItem( tr( "Screen / Web" ) );
106
        outputIntentionCheckBox->addItem( tr( "Printer" ) );
107
        outputIntentionCheckBox->addItem( tr( "Grayscale" ) );
108
        outputIntentionCheckBox->setCurrentIndex(i);
109
 
110
//      LPIfunc->clear();
111
//      LPIfunc->addItem( tr( "Simple Dot" ) );
112
//      LPIfunc->addItem( tr( "Line" ) );
113
//      LPIfunc->addItem( tr( "Round" ) );
114
//      LPIfunc->addItem( tr( "Ellipse" ) );
115
 
116
//      QString tmp_ip[] = { tr("Perceptual"), tr("Relative Colorimetric"), tr("Saturation"), tr("Absolute Colorimetric")};
117
//      size_t ar_ip = sizeof(tmp_ip) / sizeof(*tmp_ip);
118
//      for (uint a = 0; a < ar_ip; ++a)
119
//              IntendS->addItem(tmp_ip[a]);
120
//      for (uint a = 0; a < ar_ip; ++a)
121
//              IntendI->addItem(tmp_ip[a]);
14448 cbradney 122
}
123
 
124
void Prefs_PDFExport::restoreDefaults(struct ApplicationPrefs *prefsData)
125
{
14451 cbradney 126
        int unitIndex = prefsData->docSetupPrefs.docUnitIndex;
127
        double unitRatio = unitGetRatioFromIndex(unitIndex);
128
        unitChange(unitIndex);
129
/*
130
        tabPDF = new TabPDFOptions( prefsWidgets,
131
                                                                prefsData->pdfPrefs,
132
                                                                prefsData->fontPrefs.AvailFonts,
133
                                                                ScCore->PDFXProfiles,
134
                                                                DocFonts,
135
                                                                prefsData->pdfPrefs.PresentVals,
136
                                                                docUnitIndex,
137
                                                                prefsData->docSetupPrefs.pageHeight,
138
                                                                prefsData->docSetupPrefs.pageWidth,
139
 
14448 cbradney 140
 
14451 cbradney 141
void TabPDFOptions::restoreDefaults(PDFOptions & Optionen,
142
                                                                        const SCFonts &AllFonts,
143
                                                                        const ProfilesL & PDFXProfiles,
144
                                                                        const QMap<QString, int> & DocFonts,
145
                                                                        const QList<PDFPresentationData> & Eff,
146
                                                                        int unitIndex, double PageH, double PageB,
147
                                                                        ScribusDoc * mdoc, bool exporting)
148
*/
149
 
150
        exportAllPagesRadioButton->setChecked(true);
151
        enableRangeControls(false);
152
        rotationComboBox->setCurrentIndex(prefsData->pdfPrefs.RotateDeg / 90);
153
        pageMirrorHorizontalToolButton->setChecked(prefsData->pdfPrefs.MirrorH);
154
        pageMirrorVerticalToolButton->setChecked(prefsData->pdfPrefs.MirrorV);
155
        clipToPrinterMarginsCheckBox->setChecked(prefsData->pdfPrefs.doClip);
156
        bool cmsUse = m_doc ? (ScCore->haveCMS() && m_doc->HasCMS) : false;
157
        int newCMSIndex=0;
158
        if (cmsUse)
159
        {
160
                if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X1a)
161
                        newCMSIndex=3;
162
                if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X3)
163
                        newCMSIndex=4;
164
                if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X4)
165
                        newCMSIndex=5;
166
        }
167
        if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_13)
168
                newCMSIndex=0;
169
        if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_14)
170
                newCMSIndex=1;
171
        if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_15)
172
                newCMSIndex=2;
173
        pdfVersionComboBox->setCurrentIndex(newCMSIndex);
174
        pageBindingComboBox->setCurrentIndex(prefsData->pdfPrefs.Binding);
175
        generateThumbnailsCheckBox->setChecked(prefsData->pdfPrefs.Thumbnails);
176
        saveLinkedTextFramesAsArticlesCheckBox->setChecked(prefsData->pdfPrefs.Articles);
177
        includeBookmarksCheckBox->setChecked(prefsData->pdfPrefs.Bookmarks);
178
        includeLayersCheckBox->setChecked(prefsData->pdfPrefs.useLayers);
179
        includeLayersCheckBox->setEnabled(prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_15 || prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X4);
180
 
181
        epsExportResolutionSpinBox->setValue(prefsData->pdfPrefs.Resolution);
182
        embedPDFAndEPSFiles->setChecked(prefsData->pdfPrefs.embedPDF);
183
        compressTextAndVectorGraphicsCheckBox->setChecked( prefsData->pdfPrefs.Compress );
184
        imageCompressionMethodComboBox->setCurrentIndex(prefsData->pdfPrefs.CompressMethod);
185
        imageCompressionQualityComboBox->setCurrentIndex(prefsData->pdfPrefs.Quality);
186
        maxResolutionLimitCheckBox->setChecked(prefsData->pdfPrefs.RecalcPic);
187
        maxExportResolutionSpinBox->setValue(prefsData->pdfPrefs.PicRes);
188
        maxExportResolutionSpinBox->setEnabled(prefsData->pdfPrefs.RecalcPic);
189
 
190
        useEncryptionCheckBox->setChecked( prefsData->pdfPrefs.Encrypt );
191
        passwordOwnerLineEdit->setText(prefsData->pdfPrefs.PassOwner);
192
        passwordUserLineEdit->setText(prefsData->pdfPrefs.PassUser);
193
        allowPrintingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 4 );
194
        allowChangingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 8 );
195
        allowCopyingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 16 );
196
        allowAnnotatingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 32 );
197
        enableSecurityControls(prefsData->pdfPrefs.Encrypt);
198
 
199
        if (prefsData->pdfPrefs.UseRGB)
200
                outputIntentionCheckBox->setCurrentIndex(0);
201
        else
202
        {
203
                if (prefsData->pdfPrefs.isGrayscale)
204
                        outputIntentionCheckBox->setCurrentIndex(2);
205
                else
206
                        outputIntentionCheckBox->setCurrentIndex(1);
207
        }
208
        convertSpotsToProcessCheckBox->setChecked(!prefsData->pdfPrefs.UseSpotColors);
209
 
210
        bleedsWidget->setup(prefsData->pdfPrefs.bleeds, prefsData->docSetupPrefs.pagePositioning, prefsData->docSetupPrefs.docUnitIndex, false, false);
211
        bleedsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth);
212
        bleedsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight);
213
        bleedsWidget->setPageSize(prefsData->docSetupPrefs.pageSize);
214
        bleedsWidget->setMarginPreset(prefsData->docSetupPrefs.marginPreset);
215
 
216
        registrationMarkOffsetSpinBox->setValue(prefsData->pdfPrefs.markOffset*unitRatio);
217
        printCropMarksCheckBox->setChecked(prefsData->pdfPrefs.cropMarks);
218
        printBleedMarksCheckBox->setChecked(prefsData->pdfPrefs.bleedMarks);
219
        printRegistrationMarksCheckBox->setChecked(prefsData->pdfPrefs.registrationMarks);
220
        printColorBarsCheckBox->setChecked(prefsData->pdfPrefs.colorMarks);
221
        printPageInfoCheckBox->setChecked(prefsData->pdfPrefs.docInfoMarks);
14448 cbradney 222
}
223
 
224
 
225
void Prefs_PDFExport::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
226
{
227
 
228
}
14451 cbradney 229
 
230
void Prefs_PDFExport::enableRangeControls(bool enabled)
231
{
232
        exportPageListLineEdit->setEnabled( enabled );
233
        exportRangeMorePushButton->setEnabled( enabled );
234
        if (enabled == false)
235
                includeBookmarksCheckBox->setChecked(false);
236
}
237
 
238
void Prefs_PDFExport::enableSecurityControls(bool enabled)
239
{
240
        passwordOwnerLineEdit->setEnabled(enabled);
241
        passwordUserLineEdit->setEnabled(enabled);
242
        allowPrintingCheckBox->setEnabled(enabled);
243
        allowChangingCheckBox->setEnabled(enabled);
244
        allowCopyingCheckBox->setEnabled(enabled);
245
        allowAnnotatingCheckBox->setEnabled(enabled);
246
}
247
 
248
void Prefs_PDFExport::createPageNumberRange()
249
{
250
        if (m_doc!=0)
251
        {
252
                CreateRange cr(exportPageListLineEdit->text(), m_doc->DocPages.count(), this);
253
                if (cr.exec())
254
                {
255
                        CreateRangeData crData;
256
                        cr.getCreateRangeData(crData);
257
                        exportPageListLineEdit->setText(crData.pageRange);
258
                        return;
259
                }
260
        }
261
        exportPageListLineEdit->setText(QString::null);
262
}