Subversion Repositories Scribus

Rev

Rev 14451 | Rev 14736 | 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)");
14729 cbradney 89
        //if (cmsEnabled)// && (!PDFXProfiles.isEmpty()))
14451 cbradney 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);
14448 cbradney 129
 
14451 cbradney 130
        exportAllPagesRadioButton->setChecked(true);
131
        enableRangeControls(false);
132
        rotationComboBox->setCurrentIndex(prefsData->pdfPrefs.RotateDeg / 90);
133
        pageMirrorHorizontalToolButton->setChecked(prefsData->pdfPrefs.MirrorH);
134
        pageMirrorVerticalToolButton->setChecked(prefsData->pdfPrefs.MirrorV);
135
        clipToPrinterMarginsCheckBox->setChecked(prefsData->pdfPrefs.doClip);
136
        bool cmsUse = m_doc ? (ScCore->haveCMS() && m_doc->HasCMS) : false;
137
        int newCMSIndex=0;
138
        if (cmsUse)
139
        {
140
                if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X1a)
141
                        newCMSIndex=3;
142
                if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X3)
143
                        newCMSIndex=4;
144
                if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X4)
145
                        newCMSIndex=5;
146
        }
147
        if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_13)
148
                newCMSIndex=0;
149
        if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_14)
150
                newCMSIndex=1;
151
        if (prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_15)
152
                newCMSIndex=2;
153
        pdfVersionComboBox->setCurrentIndex(newCMSIndex);
154
        pageBindingComboBox->setCurrentIndex(prefsData->pdfPrefs.Binding);
155
        generateThumbnailsCheckBox->setChecked(prefsData->pdfPrefs.Thumbnails);
156
        saveLinkedTextFramesAsArticlesCheckBox->setChecked(prefsData->pdfPrefs.Articles);
157
        includeBookmarksCheckBox->setChecked(prefsData->pdfPrefs.Bookmarks);
158
        includeLayersCheckBox->setChecked(prefsData->pdfPrefs.useLayers);
159
        includeLayersCheckBox->setEnabled(prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_15 || prefsData->pdfPrefs.Version == PDFOptions::PDFVersion_X4);
160
 
161
        epsExportResolutionSpinBox->setValue(prefsData->pdfPrefs.Resolution);
162
        embedPDFAndEPSFiles->setChecked(prefsData->pdfPrefs.embedPDF);
163
        compressTextAndVectorGraphicsCheckBox->setChecked( prefsData->pdfPrefs.Compress );
164
        imageCompressionMethodComboBox->setCurrentIndex(prefsData->pdfPrefs.CompressMethod);
165
        imageCompressionQualityComboBox->setCurrentIndex(prefsData->pdfPrefs.Quality);
166
        maxResolutionLimitCheckBox->setChecked(prefsData->pdfPrefs.RecalcPic);
167
        maxExportResolutionSpinBox->setValue(prefsData->pdfPrefs.PicRes);
168
        maxExportResolutionSpinBox->setEnabled(prefsData->pdfPrefs.RecalcPic);
169
 
170
        useEncryptionCheckBox->setChecked( prefsData->pdfPrefs.Encrypt );
171
        passwordOwnerLineEdit->setText(prefsData->pdfPrefs.PassOwner);
172
        passwordUserLineEdit->setText(prefsData->pdfPrefs.PassUser);
173
        allowPrintingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 4 );
174
        allowChangingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 8 );
175
        allowCopyingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 16 );
176
        allowAnnotatingCheckBox->setChecked( prefsData->pdfPrefs.Permissions & 32 );
177
        enableSecurityControls(prefsData->pdfPrefs.Encrypt);
178
 
179
        if (prefsData->pdfPrefs.UseRGB)
180
                outputIntentionCheckBox->setCurrentIndex(0);
181
        else
182
        {
183
                if (prefsData->pdfPrefs.isGrayscale)
184
                        outputIntentionCheckBox->setCurrentIndex(2);
185
                else
186
                        outputIntentionCheckBox->setCurrentIndex(1);
187
        }
188
        convertSpotsToProcessCheckBox->setChecked(!prefsData->pdfPrefs.UseSpotColors);
189
 
190
        bleedsWidget->setup(prefsData->pdfPrefs.bleeds, prefsData->docSetupPrefs.pagePositioning, prefsData->docSetupPrefs.docUnitIndex, false, false);
191
        bleedsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth);
192
        bleedsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight);
193
        bleedsWidget->setPageSize(prefsData->docSetupPrefs.pageSize);
194
        bleedsWidget->setMarginPreset(prefsData->docSetupPrefs.marginPreset);
195
 
196
        registrationMarkOffsetSpinBox->setValue(prefsData->pdfPrefs.markOffset*unitRatio);
197
        printCropMarksCheckBox->setChecked(prefsData->pdfPrefs.cropMarks);
198
        printBleedMarksCheckBox->setChecked(prefsData->pdfPrefs.bleedMarks);
199
        printRegistrationMarksCheckBox->setChecked(prefsData->pdfPrefs.registrationMarks);
200
        printColorBarsCheckBox->setChecked(prefsData->pdfPrefs.colorMarks);
201
        printPageInfoCheckBox->setChecked(prefsData->pdfPrefs.docInfoMarks);
14448 cbradney 202
}
203
 
204
 
205
void Prefs_PDFExport::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
206
{
207
 
208
}
14451 cbradney 209
 
210
void Prefs_PDFExport::enableRangeControls(bool enabled)
211
{
212
        exportPageListLineEdit->setEnabled( enabled );
213
        exportRangeMorePushButton->setEnabled( enabled );
214
        if (enabled == false)
215
                includeBookmarksCheckBox->setChecked(false);
216
}
217
 
218
void Prefs_PDFExport::enableSecurityControls(bool enabled)
219
{
220
        passwordOwnerLineEdit->setEnabled(enabled);
221
        passwordUserLineEdit->setEnabled(enabled);
222
        allowPrintingCheckBox->setEnabled(enabled);
223
        allowChangingCheckBox->setEnabled(enabled);
224
        allowCopyingCheckBox->setEnabled(enabled);
225
        allowAnnotatingCheckBox->setEnabled(enabled);
226
}
227
 
228
void Prefs_PDFExport::createPageNumberRange()
229
{
230
        if (m_doc!=0)
231
        {
232
                CreateRange cr(exportPageListLineEdit->text(), m_doc->DocPages.count(), this);
233
                if (cr.exec())
234
                {
235
                        CreateRangeData crData;
236
                        cr.getCreateRangeData(crData);
237
                        exportPageListLineEdit->setText(crData.pageRange);
238
                        return;
239
                }
240
        }
241
        exportPageListLineEdit->setText(QString::null);
242
}