tdf#158624 - Improve warning dialogue for non-recommended formats during save
[LibreOffice.git] / filter / source / pdf / impdialog.hxx
blobfba49c8f03013e8d539b6d68790f2486ed901aaf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <sfx2/tabdlg.hxx>
23 #include <sfx2/passwd.hxx>
25 #include <vcl/pdfwriter.hxx>
26 #include <vcl/FilterConfigItem.hxx>
27 #include <vcl/weld.hxx>
29 #include <com/sun/star/beans/NamedValue.hpp>
30 #include <com/sun/star/lang/XComponent.hpp>
32 class ImpPDFTabGeneralPage;
33 class ImpPDFTabViewerPage;
34 class ImpPDFTabOpnFtrPage;
35 class ImpPDFTabLinksPage;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::beans;
39 using namespace ::com::sun::star::lang;
41 class ImplErrorDialog : public weld::MessageDialogController
43 private:
44 std::unique_ptr<weld::TreeView> m_xErrors;
45 std::unique_ptr<weld::Label> m_xExplanation;
47 DECL_LINK(SelectHdl, weld::TreeView&, void);
49 public:
50 explicit ImplErrorDialog(weld::Window* pParent, const std::set<vcl::PDFWriter::ErrorCode>& rErrorCodes);
54 class ImpPDFTabSecurityPage;
55 class ImpPDFTabLinksPage;
58 /// Class tabbed dialog
59 class ImpPDFTabDialog final : public SfxTabDialogController
61 css::uno::Reference<css::lang::XComponent> mrDoc;
63 FilterConfigItem maConfigItem;
64 FilterConfigItem maConfigI18N;
66 Any maSelection;
68 DECL_LINK(CancelHdl, weld::Button&, void);
69 DECL_LINK(OkHdl, weld::Button&, void);
71 // the following data are the configuration used throughout the dialog and pages
72 bool mbIsPresentation = false;
73 bool mbIsSpreadsheet = false;
74 bool mbIsWriter = false;
75 bool mbSelectionPresent = false;
76 bool mbUseCTLFont = false;
77 bool mbUseLosslessCompression = true;
78 sal_Int32 mnQuality = 90;
79 bool mbReduceImageResolution = false;
80 sal_Int32 mnMaxImageResolution = 300;
81 bool mbUseTaggedPDF = false;
82 bool mbUseTaggedPDFUserSelection = false;
83 sal_Int32 mnPDFTypeSelection;
84 bool mbPDFUACompliance;
85 bool mbExportNotes = true;
86 bool mbExportNotesInMargin = false;
87 bool mbViewPDF = false;
88 bool mbUseReferenceXObject = false;
89 bool mbUseReferenceXObjectUserSelection = false;
90 bool mbExportNotesPages = false;
91 bool mbExportOnlyNotesPages = false;
92 bool mbUseTransitionEffects = false;
93 bool mbIsSkipEmptyPages = true;
94 bool mbIsExportPlaceholders = false;
95 bool mbAddStream = false;
96 sal_Int32 mnFormsType = 0;
97 bool mbExportFormFields = false;
98 bool mbAllowDuplicateFieldNames = false;
99 bool mbExportBookmarks = true;
100 bool mbExportBookmarksUserSelection = true;
101 bool mbExportHiddenSlides = false;
102 bool mbSinglePageSheets = false;
103 sal_Int32 mnOpenBookmarkLevels = -1;
105 bool mbHideViewerToolbar = false;
106 bool mbHideViewerMenubar = false;
107 bool mbHideViewerWindowControls = false;
108 bool mbResizeWinToInit = false;
109 bool mbCenterWindow = false;
110 bool mbOpenInFullScreenMode = false;
111 bool mbDisplayPDFDocumentTitle = false;
112 sal_Int32 mnMagnification = 0;
113 sal_Int32 mnInitialView = 1;
114 sal_Int32 mnInitialViewUserSelection;
115 sal_Int32 mnZoom = 0;
116 sal_Int32 mnInitialPage = 1;
118 sal_Int32 mnPageLayout = 0;
119 bool mbFirstPageLeft = false;
121 bool mbEncrypt = false;
123 bool mbRestrictPermissions = false;
124 css::uno::Sequence< css::beans::NamedValue > maPreparedOwnerPassword;
125 sal_Int32 mnPrint = 0;
126 sal_Int32 mnChangesAllowed = 0;
127 bool mbCanCopyOrExtract = false;
128 bool mbCanExtractForAccessibility = true;
129 css::uno::Reference< css::beans::XMaterialHolder > mxPreparedPasswords;
131 bool mbIsPageRangeChecked = false;
132 OUString msPageRange = OUString(' ');
133 bool mbIsSheetRangeChecked = false;
134 OUString msSheetRange = OUString(' ');
135 bool mbSelectionIsChecked = false;
137 bool mbExportRelativeFsysLinks = false;
138 sal_Int32 mnViewPDFMode = 0;
139 bool mbConvertOOoTargets = false;
140 bool mbExportBmkToPDFDestination = false;
142 bool mbSignPDF = false;
143 OUString msSignPassword;
144 OUString msSignLocation;
145 OUString msSignContact;
146 OUString msSignReason;
147 css::uno::Reference<css::security::XCertificate> maSignCertificate;
148 OUString msSignTSA;
150 OUString maWatermarkText;
152 public:
154 friend class ImpPDFTabGeneralPage;
155 friend class ImpPDFTabViewerPage;
156 friend class ImpPDFTabOpnFtrPage;
157 friend class ImpPDFTabSecurityPage;
158 friend class ImpPDFTabLinksPage;
159 friend class ImpPDFTabSigningPage;
161 ImpPDFTabDialog(weld::Window* pParent, const Sequence< PropertyValue >& rFilterData,
162 const css::uno::Reference< XComponent >& rDoc);
163 virtual ~ImpPDFTabDialog() override;
165 Sequence< PropertyValue > GetFilterData();
167 ImpPDFTabOpnFtrPage* getOpenPage() const;
168 ImpPDFTabSecurityPage* getSecurityPage() const;
169 ImpPDFTabLinksPage* getLinksPage() const;
170 ImpPDFTabGeneralPage* getGeneralPage() const;
172 private:
173 virtual void PageCreated(const OUString& rId, SfxTabPage& rPage) override;
177 /// Class tab page general
178 class ImpPDFTabGeneralPage : public SfxTabPage
180 friend class ImpPDFTabLinksPage;
182 bool mbUseTaggedPDFUserSelection;
183 bool mbIsPresentation;
184 bool mbIsSpreadsheet;
185 bool mbIsWriter;
186 ImpPDFTabDialog* mpParent;
188 std::unique_ptr<weld::RadioButton> mxRbAll;
189 std::unique_ptr<weld::RadioButton> mxRbPageRange;
190 std::unique_ptr<weld::RadioButton> mxRbSheetRange;
191 std::unique_ptr<weld::RadioButton> mxRbSelection;
192 std::unique_ptr<weld::Entry> mxEdPages;
193 std::unique_ptr<weld::Entry> mxEdSheets;
194 std::unique_ptr<weld::RadioButton> mxRbLosslessCompression;
195 std::unique_ptr<weld::RadioButton> mxRbJPEGCompression;
196 std::unique_ptr<weld::Widget> mxQualityFrame;
197 std::unique_ptr<weld::MetricSpinButton> mxNfQuality;
198 std::unique_ptr<weld::CheckButton> mxCbReduceImageResolution;
199 std::unique_ptr<weld::ComboBox> mxCoReduceImageResolution;
200 std::unique_ptr<weld::CheckButton> mxCbPDFUA;
201 std::unique_ptr<weld::ComboBox> mxRbPDFVersion;
202 std::unique_ptr<weld::CheckButton> mxCbTaggedPDF;
203 std::unique_ptr<weld::CheckButton> mxCbExportFormFields;
204 std::unique_ptr<weld::Widget> mxFormsFrame;
205 std::unique_ptr<weld::ComboBox> mxLbFormsFormat;
206 std::unique_ptr<weld::CheckButton> mxCbAllowDuplicateFieldNames;
207 std::unique_ptr<weld::CheckButton> mxCbExportBookmarks;
208 std::unique_ptr<weld::CheckButton> mxCbExportHiddenSlides;
209 std::unique_ptr<weld::CheckButton> mxCbSinglePageSheets;
210 std::unique_ptr<weld::CheckButton> mxCbExportNotes;
211 std::unique_ptr<weld::CheckButton> mxCbExportNotesInMargin;
212 std::unique_ptr<weld::CheckButton> mxCbViewPDF;
213 std::unique_ptr<weld::CheckButton> mxCbUseReferenceXObject;
214 std::unique_ptr<weld::CheckButton> mxCbExportNotesPages;
215 std::unique_ptr<weld::CheckButton> mxCbExportOnlyNotesPages;
216 std::unique_ptr<weld::CheckButton> mxCbExportEmptyPages;
217 std::unique_ptr<weld::CheckButton> mxCbExportPlaceholders;
218 std::unique_ptr<weld::CheckButton> mxCbAddStream;
219 std::unique_ptr<weld::CheckButton> mxCbWatermark;
220 std::unique_ptr<weld::Label> mxFtWatermark;
221 std::unique_ptr<weld::Entry> mxEdWatermark;
222 std::unique_ptr<weld::Label> mxSlidesFt;
223 std::unique_ptr<weld::Label> mxSheetsSelectionFt;
225 DECL_LINK(ToggleAllHdl, weld::Toggleable&, void);
226 DECL_LINK(TogglePagesHdl, weld::Toggleable&, void);
227 DECL_LINK(ToggleSheetsHdl, weld::Toggleable&, void);
228 DECL_LINK(ToggleSelectionHdl, weld::Toggleable&, void);
229 DECL_LINK(ToggleCompressionHdl, weld::Toggleable&, void);
230 DECL_LINK(ToggleReduceImageResolutionHdl, weld::Toggleable&, void);
231 DECL_LINK(ToggleWatermarkHdl, weld::Toggleable&, void);
232 DECL_LINK(ToggleAddStreamHdl, weld::Toggleable&, void);
233 DECL_LINK(ToggleExportFormFieldsHdl, weld::Toggleable&, void);
234 DECL_LINK(ToggleExportNotesPagesHdl, weld::Toggleable&, void);
236 void TogglePagesHdl();
237 void ToggleSheetsHdl();
238 void EnableExportNotesPages();
240 DECL_LINK(TogglePDFUniversalAccessibilityHandle, weld::Toggleable&, void);
241 DECL_LINK(SelectPDFVersion, weld::ComboBox&, void);
243 std::shared_ptr<weld::MessageDialog> mxPasswordUnusedWarnDialog;
245 bool IsReadOnlyProperty(const OUString& rPropertyName) const
247 return mpParent && mpParent->maConfigItem.IsReadOnly(rPropertyName);
250 void thePDFVersionChanged();
252 public:
254 ImpPDFTabGeneralPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
255 virtual ~ImpPDFTabGeneralPage() override;
257 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet);
259 void GetFilterConfigItem(ImpPDFTabDialog* paParent);
260 void SetFilterConfigItem(ImpPDFTabDialog* paParent);
261 bool IsPdfaSelected() const;
262 bool IsPDFAVersionSelected(sal_Int32 nVersion) const;
263 bool IsPdfUaSelected() const { return mxCbPDFUA->get_active(); }
266 /// Class tab page viewer
267 class ImpPDFTabOpnFtrPage : public SfxTabPage
269 friend class ImpPDFTabGeneralPage;
271 bool mbUseCTLFont;
273 std::unique_ptr<weld::RadioButton> mxRbOpnPageOnly;
274 std::unique_ptr<weld::RadioButton> mxRbOpnOutline;
275 std::unique_ptr<weld::RadioButton> mxRbOpnThumbs;
276 std::unique_ptr<weld::SpinButton> mxNumInitialPage;
277 std::unique_ptr<weld::RadioButton> mxRbMagnDefault;
278 std::unique_ptr<weld::RadioButton> mxRbMagnFitWin;
279 std::unique_ptr<weld::RadioButton> mxRbMagnFitWidth;
280 std::unique_ptr<weld::RadioButton> mxRbMagnFitVisible;
281 std::unique_ptr<weld::RadioButton> mxRbMagnZoom;
282 std::unique_ptr<weld::SpinButton> mxNumZoom;
283 std::unique_ptr<weld::RadioButton> mxRbPgLyDefault;
284 std::unique_ptr<weld::RadioButton> mxRbPgLySinglePage;
285 std::unique_ptr<weld::RadioButton> mxRbPgLyContinue;
286 std::unique_ptr<weld::RadioButton> mxRbPgLyContinueFacing;
287 std::unique_ptr<weld::CheckButton> mxCbPgLyFirstOnLeft;
289 DECL_LINK(ToggleRbPgLyContinueFacingHdl, weld::Toggleable&, void);
290 DECL_LINK(ToggleRbMagnHdl, weld::Toggleable&, void);
292 void ToggleRbPgLyContinueFacingHdl();
293 void ToggleInitialView(ImpPDFTabDialog & rParent);
295 public:
296 ImpPDFTabOpnFtrPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
297 virtual ~ImpPDFTabOpnFtrPage() override;
299 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet );
301 void GetFilterConfigItem( ImpPDFTabDialog* paParent);
302 void SetFilterConfigItem(ImpPDFTabDialog* pParent);
305 /// Class tab page viewer
306 class ImpPDFTabViewerPage : public SfxTabPage
308 bool mbIsPresentation;
310 std::unique_ptr<weld::CheckButton> m_xCbResWinInit;
311 std::unique_ptr<weld::CheckButton> m_xCbCenterWindow;
312 std::unique_ptr<weld::CheckButton> m_xCbOpenFullScreen;
313 std::unique_ptr<weld::CheckButton> m_xCbDispDocTitle;
314 std::unique_ptr<weld::CheckButton> m_xCbHideViewerMenubar;
315 std::unique_ptr<weld::CheckButton> m_xCbHideViewerToolbar;
316 std::unique_ptr<weld::CheckButton> m_xCbHideViewerWindowControls;
317 std::unique_ptr<weld::CheckButton> m_xCbTransitionEffects;
318 std::unique_ptr<weld::RadioButton> m_xRbAllBookmarkLevels;
319 std::unique_ptr<weld::RadioButton> m_xRbVisibleBookmarkLevels;
320 std::unique_ptr<weld::SpinButton>m_xNumBookmarkLevels;
322 DECL_LINK(ToggleRbBookmarksHdl, weld::Toggleable&, void);
324 public:
325 ImpPDFTabViewerPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
326 virtual ~ImpPDFTabViewerPage() override;
328 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet );
330 void GetFilterConfigItem( ImpPDFTabDialog* paParent);
331 void SetFilterConfigItem( const ImpPDFTabDialog* paParent );
334 /// Class security tab page
335 class ImpPDFTabSecurityPage : public SfxTabPage
337 OUString msStrSetPwd;
338 OUString msUserPwdTitle;
339 bool mbHaveOwnerPassword;
340 bool mbHaveUserPassword;
341 css::uno::Sequence< css::beans::NamedValue > maPreparedOwnerPassword;
342 OUString msOwnerPwdTitle;
344 css::uno::Reference< css::beans::XMaterialHolder > mxPreparedPasswords;
346 std::unique_ptr<weld::Button> mxPbSetPwd;
347 std::unique_ptr<weld::Widget> mxUserPwdSet;
348 std::unique_ptr<weld::Widget> mxUserPwdUnset;
349 std::unique_ptr<weld::Widget> mxUserPwdPdfa;
350 std::unique_ptr<weld::Widget> mxOwnerPwdSet;
351 std::unique_ptr<weld::Widget> mxOwnerPwdUnset;
352 std::unique_ptr<weld::Widget> mxOwnerPwdPdfa;
353 std::unique_ptr<weld::Widget> mxPrintPermissions;
354 std::unique_ptr<weld::RadioButton> mxRbPrintNone;
355 std::unique_ptr<weld::RadioButton> mxRbPrintLowRes;
356 std::unique_ptr<weld::RadioButton> mxRbPrintHighRes;
357 std::unique_ptr<weld::Widget> mxChangesAllowed;
358 std::unique_ptr<weld::RadioButton> mxRbChangesNone;
359 std::unique_ptr<weld::RadioButton> mxRbChangesInsDel;
360 std::unique_ptr<weld::RadioButton> mxRbChangesFillForm;
361 std::unique_ptr<weld::RadioButton> mxRbChangesComment;
362 std::unique_ptr<weld::RadioButton> mxRbChangesAnyNoCopy;
363 std::unique_ptr<weld::Widget> mxContent;
364 std::unique_ptr<weld::CheckButton> mxCbEnableCopy;
365 std::unique_ptr<weld::CheckButton> mxCbEnableAccessibility;
366 std::unique_ptr<weld::Label> mxPasswordTitle;
367 std::unique_ptr<weld::Label> mxPermissionTitle;
369 std::shared_ptr< SfxPasswordDialog > mpPasswordDialog;
370 std::shared_ptr< weld::MessageDialog > mpUnsupportedMsgDialog;
372 DECL_LINK(ClickmaPbSetPwdHdl, weld::Button&, void);
374 void enablePermissionControls();
376 public:
377 ImpPDFTabSecurityPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
378 virtual ~ImpPDFTabSecurityPage() override;
380 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet);
382 void GetFilterConfigItem( ImpPDFTabDialog* paParent);
383 void SetFilterConfigItem( const ImpPDFTabDialog* paParent );
384 void ImplPDFASecurityControl();
385 bool hasPassword() const { return mbHaveOwnerPassword || mbHaveUserPassword; }
388 /// Implements the relative link stuff
389 class ImpPDFTabLinksPage : public SfxTabPage
391 bool mbOpnLnksDefaultUserState;
392 bool mbOpnLnksLaunchUserState;
393 bool mbOpnLnksBrowserUserState;
395 std::unique_ptr<weld::CheckButton> m_xCbExprtBmkrToNmDst;
396 std::unique_ptr<weld::CheckButton> m_xCbOOoToPDFTargets;
397 std::unique_ptr<weld::CheckButton> m_xCbExportRelativeFsysLinks;
398 std::unique_ptr<weld::RadioButton> m_xRbOpnLnksDefault;
399 std::unique_ptr<weld::RadioButton> m_xRbOpnLnksLaunch;
400 std::unique_ptr<weld::RadioButton> m_xRbOpnLnksBrowser;
402 DECL_LINK(ClickRbOpnLnksDefaultHdl, weld::Toggleable&, void);
403 DECL_LINK(ClickRbOpnLnksBrowserHdl, weld::Toggleable&, void);
405 public:
406 ImpPDFTabLinksPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
407 virtual ~ImpPDFTabLinksPage() override;
409 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet);
411 void GetFilterConfigItem( ImpPDFTabDialog* paParent);
412 void SetFilterConfigItem( const ImpPDFTabDialog* paParent );
414 void ImplPDFALinkControl( bool bEnableLaunch );
417 //class to implement the digital signing
418 class ImpPDFTabSigningPage : public SfxTabPage
420 css::uno::Reference< css::security::XCertificate > maSignCertificate;
422 std::unique_ptr<weld::Entry> mxEdSignCert;
423 std::unique_ptr<weld::Button> mxPbSignCertSelect;
424 std::unique_ptr<weld::Button> mxPbSignCertClear;
425 std::unique_ptr<weld::Entry> mxEdSignPassword;
426 std::unique_ptr<weld::Entry> mxEdSignLocation;
427 std::unique_ptr<weld::Entry> mxEdSignContactInfo;
428 std::unique_ptr<weld::Entry> mxEdSignReason;
429 std::unique_ptr<weld::ComboBox> mxLBSignTSA;
431 DECL_LINK(ClickmaPbSignCertSelect, weld::Button&, void);
432 DECL_LINK(ClickmaPbSignCertClear, weld::Button&, void);
434 public:
435 ImpPDFTabSigningPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
436 virtual ~ImpPDFTabSigningPage() override;
438 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet );
440 void GetFilterConfigItem( ImpPDFTabDialog* paParent);
441 void SetFilterConfigItem( const ImpPDFTabDialog* paParent );
444 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */