merge the formfield patch from ooo-build
[ooovba.git] / filter / source / pdf / impdialog.cxx
blobdff72eb8d0d8c95e665d1e540573c8feb26953c0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: impdialog.cxx,v $
10 * $Revision: 1.35.28.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_filter.hxx"
34 #include "impdialog.hxx"
35 #include "impdialog.hrc"
36 #include <vcl/svapp.hxx>
37 #include <vcl/msgbox.hxx>
38 #include <sfx2/passwd.hxx>
39 #include <com/sun/star/uno/Sequence.h>
40 #include <com/sun/star/text/XTextRange.hpp>
41 #include <com/sun/star/drawing/XShapes.hpp>
42 #include <com/sun/star/container/XIndexAccess.hpp>
43 #include <com/sun/star/frame/XController.hpp>
44 #include <com/sun/star/view/XSelectionSupplier.hpp>
46 // ----------------
47 // - ImpPDFDialog -
48 // ----------------
50 using namespace ::com::sun::star;
52 //////////////////////////////////////////////////////////////////////////////////////////////////////
53 // tabbed PDF dialog implementation
54 // please note: the default used here are the same as per specification,
55 // they should be the same in PDFFilter::implExport and in PDFExport::PDFExport
56 // -----------------------------------------------------------------------------
57 ImpPDFTabDialog::ImpPDFTabDialog( Window* pParent,
58 ResMgr& rResMgr,
59 Sequence< PropertyValue >& rFilterData,
60 const Reference< XComponent >& rxDoc,
61 const Reference< lang::XMultiServiceFactory >& xFact
62 ) :
63 SfxTabDialog( pParent, ResId( RID_PDF_EXPORT_DLG, rResMgr ), 0, FALSE, 0 ),
64 mxMSF( xFact ),
65 maConfigItem( String( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/PDF/Export/" ) ), &rFilterData ),
66 maConfigI18N( String( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/I18N/CTL/" ) ) ),
67 mbIsPresentation( sal_False ),
68 mbIsWriter( sal_False ),
70 mbSelectionPresent( sal_False ),
71 mbUseCTLFont( sal_False ),
72 mbUseLosslessCompression( sal_True ),
73 mnQuality( 90 ),
74 mbReduceImageResolution( sal_False ),
75 mnMaxImageResolution( 300 ),
76 mbUseTaggedPDF( sal_False ),
77 mbExportNotesBoth( sal_True ),
78 mbUseTransitionEffects( sal_False ),
79 mbIsSkipEmptyPages( sal_True ),
80 mnFormsType( 0 ),
81 mbExportFormFields( sal_True ),
82 mbExportBookmarks( sal_True ),
83 mnOpenBookmarkLevels( -1 ),
85 mbHideViewerToolbar( sal_False ),
86 mbHideViewerMenubar( sal_False ),
87 mbHideViewerWindowControls( sal_False ),
88 mbResizeWinToInit( sal_False ),
89 mbCenterWindow( sal_False ),
90 mbOpenInFullScreenMode( sal_False ),
91 mbDisplayPDFDocumentTitle( sal_False ),
92 mnMagnification( 0 ),
93 mnInitialView( 0 ),
94 mnZoom( 0 ),
95 mnInitialPage( 1 ),
96 mnPageLayout( 0 ),
97 mbFirstPageLeft( sal_False ),
99 mbEncrypt( false ),
100 mbRestrictPermissions( false ),
101 mnPrint( 0 ),
102 mnChangesAllowed( 0 ),
103 mbCanCopyOrExtract( false ),
104 mbCanExtractForAccessibility( true ),
106 mbIsRangeChecked( sal_False ),
107 msPageRange( ' ' ),
109 mbSelectionIsChecked( sal_False ),
110 mbExportRelativeFsysLinks( sal_False ),
111 mnViewPDFMode( 0 ),
112 mbConvertOOoTargets( sal_False ),
113 mbExportBmkToPDFDestination( sal_False )
115 FreeResource();
116 mprResMgr = &rResMgr;
117 // check for selection
120 Reference< frame::XController > xController( Reference< frame::XModel >( rxDoc, UNO_QUERY )->getCurrentController() );
121 if( xController.is() )
123 Reference< view::XSelectionSupplier > xView( xController, UNO_QUERY );
124 if( xView.is() )
125 xView->getSelection() >>= maSelection;
128 catch( RuntimeException )
131 mbSelectionPresent = maSelection.hasValue();
132 if ( mbSelectionPresent )
134 Reference< drawing::XShapes > xShapes;
135 if ( ( maSelection >>= xShapes ) == sal_False ) // XShapes is always a selection
137 // even if nothing is selected in writer the selection is not empty
138 Reference< container::XIndexAccess > xIndexAccess;
139 if ( maSelection >>= xIndexAccess )
141 sal_Int32 nLen = xIndexAccess->getCount();
142 if ( !nLen )
143 mbSelectionPresent = sal_False;
144 else if ( nLen == 1 )
146 Reference< text::XTextRange > xTextRange( xIndexAccess->getByIndex( 0 ), UNO_QUERY );
147 if ( xTextRange.is() && ( xTextRange->getString().getLength() == 0 ) )
148 mbSelectionPresent = sal_False;
154 // check if source document is a presentation
157 Reference< XServiceInfo > xInfo( rxDoc, UNO_QUERY );
158 if ( xInfo.is() )
160 if ( xInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) ) )
161 mbIsPresentation = sal_True;
162 if ( xInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.GenericTextDocument" ) ) ) )
163 mbIsWriter = sal_True;
166 catch( RuntimeException )
170 //get the CTL (Complex Text Layout) from general options, returns TRUE if we have a CTL font on our hands.
171 mbUseCTLFont = maConfigI18N.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "CTLFont" ) ), sal_False );
173 mbUseLosslessCompression = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseLosslessCompression" ) ), sal_False );
174 mnQuality = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Quality" ) ), 90 );
175 mbReduceImageResolution = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ReduceImageResolution" ) ), sal_False );
176 mnMaxImageResolution = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxImageResolution" ) ), 300 );
178 mbUseTaggedPDF = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseTaggedPDF" ) ), sal_False );
179 mnPDFTypeSelection = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectPdfVersion" ) ), 0 );
180 if ( mbIsPresentation )
181 mbExportNotesBoth = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotesPages" ) ), sal_False );
182 else
183 mbExportNotesBoth = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotes" ) ), sal_True );
185 mbExportBookmarks = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportBookmarks" ) ), sal_True );
186 mnOpenBookmarkLevels = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenBookmarkLevels" ) ), -1 );
187 mbUseTransitionEffects = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseTransitionEffects" ) ), sal_True );
188 mbIsSkipEmptyPages = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ), sal_False );
189 mbAddStream = maConfigItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( "IsAddStream" ) ), sal_False );
191 mnFormsType = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "FormsType" ) ), 0 );
192 mbExportFormFields = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportFormFields" ) ), sal_True );
193 if ( ( mnFormsType < 0 ) || ( mnFormsType > 3 ) )
194 mnFormsType = 0;
196 //prepare values for the Viewer tab page
197 mbHideViewerToolbar = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerToolbar" ) ), sal_False );
198 mbHideViewerMenubar = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerMenubar" ) ), sal_False );
199 mbHideViewerWindowControls = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerWindowControls" ) ), sal_False );
200 mbResizeWinToInit = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ResizeWindowToInitialPage" ) ), sal_False );
201 mbCenterWindow = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "CenterWindow" ) ), sal_False );
202 mbOpenInFullScreenMode = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenInFullScreenMode" ) ), sal_False );
203 mbDisplayPDFDocumentTitle = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "DisplayPDFDocumentTitle" ) ), sal_True );
205 mnInitialView = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "InitialView" ) ), 0 );
206 mnMagnification = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Magnification" ) ), 0 );
207 mnZoom = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) ), 100 );
208 mnPageLayout = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "PageLayout" ) ), 0 );
209 mbFirstPageLeft = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "FirstPageOnLeft" ) ), sal_False );
210 mnInitialPage = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "InitialPage" ) ), 1 );
211 if( mnInitialPage < 1 )
212 mnInitialPage = 1;
214 //prepare values for the security tab page
215 mnPrint = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Printing" ) ), 2 );
216 mnChangesAllowed = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Changes" ) ), 4 );
217 mbCanCopyOrExtract = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableCopyingOfContent" ) ), sal_True );
218 mbCanExtractForAccessibility = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableTextAccessForAccessibilityTools" ) ), sal_True );
220 //prepare values for relative links
221 mbExportRelativeFsysLinks = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportLinksRelativeFsys" ) ), sal_False );
223 mnViewPDFMode = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "PDFViewSelection" ) ), 0 );
225 mbConvertOOoTargets = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ConvertOOoTargetToPDFTarget" ) ), sal_False );
226 mbExportBmkToPDFDestination = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportBookmarksToPDFDestination" ) ), sal_False );
228 //queue the tab pages for later creation (created when first shown)
229 AddTabPage( RID_PDF_TAB_SECURITY, ImpPDFTabSecurityPage::Create, 0 );
230 AddTabPage( RID_PDF_TAB_LINKS, ImpPDFTabLinksPage::Create, 0 );
231 AddTabPage( RID_PDF_TAB_VPREFER, ImpPDFTabViewerPage::Create, 0 );
232 AddTabPage( RID_PDF_TAB_OPNFTR, ImpPDFTabOpnFtrPage::Create, 0 );
234 //last queued is the first to be displayed (or so it seems..)
235 AddTabPage( RID_PDF_TAB_GENER, ImpPDFTabGeneralPage::Create, 0 );
237 //get the string property value (from sfx2/source/dialog/mailmodel.cxx) to overwrite the text for the Ok button
238 ::rtl::OUString sOkButtonText = maConfigItem.ReadString( OUString( RTL_CONSTASCII_USTRINGPARAM( "_OkButtonString" ) ), OUString() );
240 //change text on the Ok button: get the relevant string from resources, update it on the button
241 //according to the exported pdf file destination: send as e-mail or write to file?
242 GetOKButton().SetText( ( sOkButtonText.getLength() > 0 ) ?
243 sOkButtonText : OUString( String( ResId( STR_PDF_EXPORT, rResMgr ) ) ));
245 //remove the reset button, not needed in this tabbed dialog
246 RemoveResetButton();
247 /////////////////
250 // -----------------------------------------------------------------------------
251 ImpPDFTabDialog::~ImpPDFTabDialog()
253 //delete the pages, needed because otherwise the child tab pages
254 //don't get destroyed
255 RemoveTabPage( RID_PDF_TAB_GENER );
256 RemoveTabPage( RID_PDF_TAB_VPREFER );
257 RemoveTabPage( RID_PDF_TAB_OPNFTR );
258 RemoveTabPage( RID_PDF_TAB_LINKS );
259 RemoveTabPage( RID_PDF_TAB_SECURITY );
262 // -----------------------------------------------------------------------------
263 void ImpPDFTabDialog::PageCreated( USHORT _nId,
264 SfxTabPage& _rPage )
266 switch( _nId )
268 case RID_PDF_TAB_GENER:
269 ( ( ImpPDFTabGeneralPage* )&_rPage )->SetFilterConfigItem( this );
270 break;
271 case RID_PDF_TAB_VPREFER:
272 ( ( ImpPDFTabViewerPage* )&_rPage )->SetFilterConfigItem( this );
273 break;
274 case RID_PDF_TAB_OPNFTR:
275 ( ( ImpPDFTabOpnFtrPage* )&_rPage )->SetFilterConfigItem( this );
276 break;
277 case RID_PDF_TAB_LINKS:
278 ( ( ImpPDFTabLinksPage* )&_rPage )->SetFilterConfigItem( this );
279 break;
280 case RID_PDF_TAB_SECURITY:
281 ( ( ImpPDFTabSecurityPage* )&_rPage )->SetFilterConfigItem( this );
282 break;
286 // -----------------------------------------------------------------------------
287 short ImpPDFTabDialog::Ok( )
289 //here the whole mechanism of the base class is not used
290 //when Ok is hit, the user means 'convert to PDF', so simply close with ok
291 return RET_OK;
294 // -----------------------------------------------------------------------------
295 Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
297 // updating the FilterData sequence and storing FilterData to configuration
298 if( GetTabPage( RID_PDF_TAB_GENER ) )
299 ( ( ImpPDFTabGeneralPage* )GetTabPage( RID_PDF_TAB_GENER ) )->GetFilterConfigItem( this );
301 //prepare the items to be returned
302 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseLosslessCompression" ) ), mbUseLosslessCompression );
303 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Quality" ) ), mnQuality );
304 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ReduceImageResolution" ) ), mbReduceImageResolution );
305 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxImageResolution" ) ), mnMaxImageResolution );
307 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseTaggedPDF" ) ), mbUseTaggedPDF );
308 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectPdfVersion" ) ), mnPDFTypeSelection );
310 if ( mbIsPresentation )
311 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotesPages" ) ), mbExportNotesBoth );
312 else
313 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotes" ) ), mbExportNotesBoth );
315 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportBookmarks" ) ), mbExportBookmarks );
316 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseTransitionEffects" ) ), mbUseTransitionEffects );
317 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ), mbIsSkipEmptyPages );
318 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsAddStream" ) ), mbAddStream );
321 * FIXME: the entries are only implicitly defined by the resource file. Should there
322 * ever be an additional form submit format this could get invalid.
324 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "FormsType" ) ), mnFormsType );
325 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportFormFields" ) ), mbExportFormFields );
327 if( GetTabPage( RID_PDF_TAB_VPREFER ) )
328 ( ( ImpPDFTabViewerPage* )GetTabPage( RID_PDF_TAB_VPREFER ) )->GetFilterConfigItem( this );
330 if( GetTabPage( RID_PDF_TAB_OPNFTR ) )
331 ( ( ImpPDFTabOpnFtrPage* )GetTabPage( RID_PDF_TAB_OPNFTR ) )->GetFilterConfigItem( this );
333 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerToolbar" ) ), mbHideViewerToolbar );
334 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerMenubar" ) ), mbHideViewerMenubar );
335 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerWindowControls" ) ), mbHideViewerWindowControls );
336 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ResizeWindowToInitialPage" ) ), mbResizeWinToInit );
337 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "CenterWindow" ) ), mbCenterWindow );
338 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenInFullScreenMode" ) ), mbOpenInFullScreenMode );
339 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "DisplayPDFDocumentTitle" ) ), mbDisplayPDFDocumentTitle );
340 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "InitialView" ) ), mnInitialView );
341 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Magnification" ) ), mnMagnification);
342 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) ), mnZoom );
343 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "InitialPage" ) ), mnInitialPage );
344 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "PageLayout" ) ), mnPageLayout );
345 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "FirstPageOnLeft" ) ), mbFirstPageLeft );
346 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenBookmarkLevels" ) ), mnOpenBookmarkLevels );
348 if( GetTabPage( RID_PDF_TAB_LINKS ) )
349 ( ( ImpPDFTabLinksPage* )GetTabPage( RID_PDF_TAB_LINKS ) )->GetFilterConfigItem( this );
351 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportLinksRelativeFsys" ) ), mbExportRelativeFsysLinks );
352 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "PDFViewSelection" ) ), mnViewPDFMode );
353 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ConvertOOoTargetToPDFTarget" ) ), mbConvertOOoTargets );
354 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportBookmarksToPDFDestination" ) ), mbExportBmkToPDFDestination );
356 if( GetTabPage( RID_PDF_TAB_SECURITY ) )
357 ( ( ImpPDFTabSecurityPage* )GetTabPage( RID_PDF_TAB_SECURITY ) )->GetFilterConfigItem( this );
359 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Printing" ) ), mnPrint );
360 maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Changes" ) ), mnChangesAllowed );
361 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableCopyingOfContent" ) ), mbCanCopyOrExtract );
362 maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableTextAccessForAccessibilityTools" ) ), mbCanExtractForAccessibility );
364 Sequence< PropertyValue > aRet( maConfigItem.GetFilterData() );
366 int nElementAdded = 5;
368 aRet.realloc( aRet.getLength() + nElementAdded );
370 // add the encryption enable flag
371 aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EncryptFile" ) );
372 aRet[ aRet.getLength() - nElementAdded ].Value <<= mbEncrypt;
373 nElementAdded--;
375 // add the open password
376 aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "DocumentOpenPassword" ) );
377 aRet[ aRet.getLength() - nElementAdded ].Value <<= OUString( msUserPassword );
378 nElementAdded--;
380 //the restrict permission flag (needed to have the scripting consistent with the dialog)
381 aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "RestrictPermissions" ) );
382 aRet[ aRet.getLength() - nElementAdded ].Value <<= mbRestrictPermissions;
383 nElementAdded--;
385 //add the permission password
386 aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PermissionPassword" ) );
387 aRet[ aRet.getLength() - nElementAdded ].Value <<= OUString( msOwnerPassword );
388 nElementAdded--;
390 // this should be the last added...
391 if( mbIsRangeChecked )
393 aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) );
394 aRet[ aRet.getLength() - nElementAdded ].Value <<= OUString( msPageRange );
396 else if( mbSelectionIsChecked )
398 aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Selection" ) );
399 aRet[ aRet.getLength() - nElementAdded ].Value <<= maSelection;
402 return aRet;
405 // -----------------------------------------------------------------------------
406 ImpPDFTabGeneralPage::ImpPDFTabGeneralPage( Window* pParent,
407 const SfxItemSet& rCoreSet,
408 ResMgr* paResMgr ) :
409 SfxTabPage( pParent, ResId( RID_PDF_TAB_GENER, *paResMgr ), rCoreSet ),
411 maFlPages( this, ResId( FL_PAGES, *paResMgr ) ),
412 maRbAll( this, ResId( RB_ALL, *paResMgr) ),
413 maRbRange( this, ResId( RB_RANGE, *paResMgr ) ),
414 maRbSelection( this, ResId( RB_SELECTION, *paResMgr ) ),
415 maEdPages( this, ResId( ED_PAGES, *paResMgr ) ),
417 maFlCompression( this, ResId( FL_IMAGES, *paResMgr ) ),
418 maRbLosslessCompression( this, ResId( RB_LOSSLESSCOMPRESSION, *paResMgr ) ),
419 maRbJPEGCompression( this, ResId( RB_JPEGCOMPRESSION, *paResMgr ) ),
420 maFtQuality( this, ResId( FT_QUALITY, *paResMgr ) ),
421 maNfQuality( this, ResId( NF_QUALITY, *paResMgr ) ),
422 maCbReduceImageResolution( this, ResId( CB_REDUCEIMAGERESOLUTION, *paResMgr ) ),
423 maCoReduceImageResolution( this, ResId( CO_REDUCEIMAGERESOLUTION, *paResMgr ) ),
425 maFlGeneral( this, ResId( FL_GENERAL, *paResMgr ) ),
426 maCbPDFA1b( this, ResId( CB_PDFA_1B_SELECT, *paResMgr ) ),
428 maCbTaggedPDF( this, ResId( CB_TAGGEDPDF, *paResMgr ) ),
429 mbTaggedPDFUserSelection( sal_False ),
431 maCbExportFormFields( this, ResId( CB_EXPORTFORMFIELDS, *paResMgr ) ),
432 mbExportFormFieldsUserSelection( sal_False ),
433 maFtFormsFormat( this, ResId( FT_FORMSFORMAT, *paResMgr ) ),
434 maLbFormsFormat( this, ResId( LB_FORMSFORMAT, *paResMgr ) ),
436 maCbExportBookmarks( this, ResId( CB_EXPORTBOOKMARKS, *paResMgr ) ),
437 maCbExportNotes( this, ResId( CB_EXPORTNOTES, *paResMgr ) ),
438 maCbExportEmptyPages( this, ResId( CB_EXPORTEMPTYPAGES, *paResMgr ) ),
439 maCbAddStream( this, ResId( CB_ADDSTREAM, *paResMgr ) ),
440 mbIsPresentation( sal_False ),
441 mbIsWriter( sal_False),
442 mpaParent( 0 )
444 mpaResMgr = paResMgr;
445 FreeResource();
447 // pb: #i91991# maCbExportEmptyPages double-spaced if necessary
448 Size aSize = maCbExportEmptyPages.GetSizePixel();
449 Size aMinSize = maCbExportEmptyPages.CalcMinimumSize();
450 if ( aSize.Width() > aMinSize.Width() )
452 Size aNewSize = maCbExportNotes.GetSizePixel();
453 long nDelta = aSize.Height() - aNewSize.Height();
454 maCbExportEmptyPages.SetSizePixel( aNewSize );
455 Point aNewPos = maCbAddStream.GetPosPixel();
456 aNewPos.Y() -= nDelta;
457 maCbAddStream.SetPosPixel( aNewPos );
461 // -----------------------------------------------------------------------------
462 ImpPDFTabGeneralPage::~ImpPDFTabGeneralPage()
464 delete mpaResMgr;
467 // -----------------------------------------------------------------------------
468 void ImpPDFTabGeneralPage::SetFilterConfigItem( const ImpPDFTabDialog* paParent )
470 mpaParent = paParent;
472 //init this class data
473 maRbRange.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, TogglePagesHdl ) );
475 maRbAll.Check();
476 TogglePagesHdl( NULL );
478 maNfQuality.SetUnit( FUNIT_PERCENT );
479 maNfQuality.SetMin( 1, FUNIT_PERCENT );
480 maNfQuality.SetMax( 100, FUNIT_PERCENT );
482 maRbSelection.Enable( paParent->mbSelectionPresent );
483 mbIsPresentation = paParent->mbIsPresentation;
484 mbIsWriter = paParent->mbIsWriter;
486 maCbExportEmptyPages.Enable( mbIsWriter );
488 // SJ: Dont know if there are Notes available also for writer.
489 // maCbExportNotes.Enable( paParent->mbIsPresentation );
491 maRbLosslessCompression.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleCompressionHdl ) );
492 const sal_Bool bUseLosslessCompression = paParent->mbUseLosslessCompression;
493 if ( bUseLosslessCompression )
494 maRbLosslessCompression.Check();
495 else
496 maRbJPEGCompression.Check();
498 maNfQuality.SetValue( paParent->mnQuality, FUNIT_PERCENT );
499 maNfQuality.Enable( bUseLosslessCompression == sal_False );
501 maCbReduceImageResolution.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleReduceImageResolutionHdl ) );
502 const sal_Bool bReduceImageResolution = paParent->mbReduceImageResolution;
503 maCbReduceImageResolution.Check( bReduceImageResolution );
504 String aStrRes( String::CreateFromInt32( paParent->mnMaxImageResolution ) );
505 aStrRes.Append( String( RTL_CONSTASCII_USTRINGPARAM( " DPI" ) ) );
506 maCoReduceImageResolution.SetText( aStrRes );
507 maCoReduceImageResolution.Enable( bReduceImageResolution );
509 maCbPDFA1b.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleExportPDFAHdl) );
510 switch( paParent->mnPDFTypeSelection )
512 default:
513 case 0: maCbPDFA1b.Check( FALSE ); // PDF 1.4
514 break;
515 case 1: maCbPDFA1b.Check(); // PDF/A-1a
516 break;
518 ToggleExportPDFAHdl( NULL );
520 maCbExportFormFields.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleExportFormFieldsHdl ) );
522 // get the form values, for use with PDF/A-1 selection interface
523 mbTaggedPDFUserSelection = paParent->mbUseTaggedPDF;
524 mbExportFormFieldsUserSelection = paParent->mbExportFormFields;
526 if( !maCbPDFA1b.IsChecked() )
527 {// the value for PDF/A set by the ToggleExportPDFAHdl method called before
528 maCbTaggedPDF.Check( mbTaggedPDFUserSelection );
529 maCbExportFormFields.Check( mbExportFormFieldsUserSelection );
532 maLbFormsFormat.SelectEntryPos( (sal_uInt16)paParent->mnFormsType );
533 maLbFormsFormat.Enable( paParent->mbExportFormFields );
535 if ( mbIsPresentation )
536 maCbExportNotes.Check( paParent->mbExportNotesBoth );
537 else
538 maCbExportNotes.Check( paParent->mbExportNotesBoth );
540 maCbExportBookmarks.Check( paParent->mbExportBookmarks );
542 maCbExportEmptyPages.Check( !paParent->mbIsSkipEmptyPages );
544 Reference< XMultiServiceFactory > xFactory = paParent->getServiceFactory();
545 Reference< XInterface > xIfc;
546 if( xFactory.is() )
548 xIfc = xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.documents.PDFDetector" ) ) );
550 if( xIfc.is() )
552 maCbAddStream.Show( TRUE );
553 maCbAddStream.Check( paParent->mbAddStream );
555 else
557 maCbAddStream.Show( FALSE );
558 maCbAddStream.Check( FALSE );
560 maCbAddStream.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleAddStreamHdl ) );
561 // init addstream dependencies
562 ToggleAddStreamHdl( NULL );
565 // -----------------------------------------------------------------------------
566 void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* paParent )
568 // updating the FilterData sequence and storing FilterData to configuration
569 paParent->mbUseLosslessCompression = maRbLosslessCompression.IsChecked();
570 paParent->mnQuality = static_cast<sal_Int32>(maNfQuality.GetValue());
571 paParent->mbReduceImageResolution = maCbReduceImageResolution.IsChecked();
572 paParent->mnMaxImageResolution = maCoReduceImageResolution.GetText().ToInt32();
573 paParent->mbExportNotesBoth = maCbExportNotes.IsChecked();
574 paParent->mbExportBookmarks = maCbExportBookmarks.IsChecked();
576 paParent->mbIsSkipEmptyPages = !maCbExportEmptyPages.IsChecked();
577 paParent->mbAddStream = maCbAddStream.IsVisible() && maCbAddStream.IsChecked();
579 paParent->mbIsRangeChecked = sal_False;
580 if( maRbRange.IsChecked() )
582 paParent->mbIsRangeChecked = sal_True;
583 paParent->msPageRange = String( maEdPages.GetText() ); //FIXME all right on other languages ?
585 else if( maRbSelection.IsChecked() )
587 paParent->mbSelectionIsChecked = maRbSelection.IsChecked();
590 paParent->mnPDFTypeSelection = 0;
591 if( maCbPDFA1b.IsChecked() )
593 paParent->mnPDFTypeSelection = 1;
594 paParent->mbUseTaggedPDF = mbTaggedPDFUserSelection;
595 paParent->mbExportFormFields = mbExportFormFieldsUserSelection;
597 else
599 paParent->mbUseTaggedPDF = maCbTaggedPDF.IsChecked();
600 paParent->mbExportFormFields = maCbExportFormFields.IsChecked();
604 * FIXME: the entries are only implicitly defined by the resource file. Should there
605 * ever be an additional form submit format this could get invalid.
607 paParent->mnFormsType = (sal_Int32) maLbFormsFormat.GetSelectEntryPos();
610 // -----------------------------------------------------------------------------
611 SfxTabPage* ImpPDFTabGeneralPage::Create( Window* pParent,
612 const SfxItemSet& rAttrSet)
614 ByteString aResMgrName( "pdffilter" );
615 ResMgr* paResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
616 return ( new ImpPDFTabGeneralPage( pParent, rAttrSet, paResMgr ) );
619 // -----------------------------------------------------------------------------
620 IMPL_LINK( ImpPDFTabGeneralPage, TogglePagesHdl, void*, EMPTYARG )
622 maEdPages.Enable( maRbRange.IsChecked() );
623 maEdPages.SetReadOnly( !maRbRange.IsChecked() );
624 return 0;
627 // -----------------------------------------------------------------------------
628 IMPL_LINK( ImpPDFTabGeneralPage, ToggleExportFormFieldsHdl, void*, EMPTYARG )
630 maLbFormsFormat.Enable( maCbExportFormFields.IsChecked() );
631 return 0;
634 // -----------------------------------------------------------------------------
635 IMPL_LINK( ImpPDFTabGeneralPage, ToggleCompressionHdl, void*, EMPTYARG )
637 maNfQuality.Enable( maRbJPEGCompression.IsChecked() );
638 return 0;
641 // -----------------------------------------------------------------------------
642 IMPL_LINK( ImpPDFTabGeneralPage, ToggleReduceImageResolutionHdl, void*, EMPTYARG )
644 maCoReduceImageResolution.Enable( maCbReduceImageResolution.IsChecked() );
645 return 0;
648 // -----------------------------------------------------------------------------
649 IMPL_LINK( ImpPDFTabGeneralPage, ToggleAddStreamHdl, void*, EMPTYARG )
651 if( maCbAddStream.IsVisible() )
653 if( maCbAddStream.IsChecked() )
655 maRbAll.Check();
656 maRbRange.Enable( FALSE );
657 maRbSelection.Enable( FALSE );
658 maEdPages.Enable( FALSE );
659 maEdPages.SetReadOnly( TRUE );
660 maRbAll.Enable( FALSE );
662 else
664 maRbAll.Enable( TRUE );
665 maRbRange.Enable( TRUE );
666 maRbSelection.Enable( TRUE );
669 return 0;
672 // -----------------------------------------------------------------------------
673 IMPL_LINK( ImpPDFTabGeneralPage, ToggleExportPDFAHdl, void*, EMPTYARG )
675 //set the security page status (and its controls as well)
676 if( mpaParent && mpaParent->GetTabPage( RID_PDF_TAB_SECURITY ) )
677 ( ( ImpPDFTabSecurityPage* )mpaParent->GetTabPage( RID_PDF_TAB_SECURITY ) )->ImplPDFASecurityControl( !maCbPDFA1b.IsChecked() );
679 //PDF/A-1 needs tagged PDF, so force disable the control, will be forced in pdfexport.
680 sal_Bool bPDFA1Sel = maCbPDFA1b.IsChecked();
681 maFtFormsFormat.Enable( !bPDFA1Sel );
682 maLbFormsFormat.Enable( !bPDFA1Sel );
683 if(bPDFA1Sel)
685 //store the values of subordinate controls
686 mbTaggedPDFUserSelection = maCbTaggedPDF.IsChecked();
687 maCbTaggedPDF.Check();
688 maCbTaggedPDF.Enable( sal_False );
689 mbExportFormFieldsUserSelection = maCbExportFormFields.IsChecked();
690 maCbExportFormFields.Check( sal_False );
691 maCbExportFormFields.Enable( sal_False );
693 else
695 //retrieve the values of subordinate controls
696 maCbTaggedPDF.Enable();
697 maCbTaggedPDF.Check( mbTaggedPDFUserSelection );
698 maCbExportFormFields.Check( mbExportFormFieldsUserSelection );
699 maCbExportFormFields.Enable();
701 // PDF/A-1 doesn't allow launch action, so enable/disable the selection on
702 // Link page
703 if( mpaParent && mpaParent->GetTabPage( RID_PDF_TAB_LINKS ) )
704 ( ( ImpPDFTabLinksPage* )mpaParent->GetTabPage( RID_PDF_TAB_LINKS ) )->ImplPDFALinkControl( !maCbPDFA1b.IsChecked() );
706 return 0;
709 /////////////////////////////////////////////////////////////////
710 // the option features tab page
711 // -----------------------------------------------------------------------------
712 ImpPDFTabOpnFtrPage::ImpPDFTabOpnFtrPage( Window* pParent,
713 const SfxItemSet& rCoreSet,
714 ResMgr* paResMgr ) :
715 SfxTabPage( pParent, ResId( RID_PDF_TAB_OPNFTR, *paResMgr ), rCoreSet ),
717 maFlInitialView( this, ResId( FL_INITVIEW, *paResMgr ) ),
718 maRbOpnPageOnly( this, ResId( RB_OPNMODE_PAGEONLY, *paResMgr ) ),
719 maRbOpnOutline( this, ResId( RB_OPNMODE_OUTLINE, *paResMgr ) ),
720 maRbOpnThumbs( this, ResId( RB_OPNMODE_THUMBS, *paResMgr ) ),
721 maFtInitialPage( this, ResId( FT_MAGNF_INITIAL_PAGE, *paResMgr ) ),
722 maNumInitialPage( this, ResId( NUM_MAGNF_INITIAL_PAGE, *paResMgr ) ),
724 maFlMagnification( this, ResId( FL_MAGNIFICATION, *paResMgr ) ),
725 maRbMagnDefault( this, ResId( RB_MAGNF_DEFAULT, *paResMgr ) ),
726 maRbMagnFitWin( this, ResId( RB_MAGNF_WIND, *paResMgr ) ),
727 maRbMagnFitWidth( this, ResId( RB_MAGNF_WIDTH, *paResMgr ) ),
728 maRbMagnFitVisible( this, ResId( RB_MAGNF_VISIBLE, *paResMgr ) ),
729 maRbMagnZoom( this, ResId( RB_MAGNF_ZOOM, *paResMgr ) ),
730 maNumZoom( this, ResId( NUM_MAGNF_ZOOM, *paResMgr ) ),
732 maFlPageLayout( this, ResId( FL_PAGE_LAYOUT, *paResMgr ) ),
733 maRbPgLyDefault( this, ResId( RB_PGLY_DEFAULT, *paResMgr ) ),
734 maRbPgLySinglePage( this, ResId( RB_PGLY_SINGPG, *paResMgr ) ),
735 maRbPgLyContinue( this, ResId( RB_PGLY_CONT, *paResMgr ) ),
736 maRbPgLyContinueFacing( this, ResId( RB_PGLY_CONTFAC, *paResMgr ) ),
737 maCbPgLyFirstOnLeft( this, ResId( CB_PGLY_FIRSTLEFT, *paResMgr ) ),
738 mbUseCTLFont( sal_False )
740 mpaResMgr = paResMgr;
741 FreeResource();
743 maRbMagnDefault.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
744 maRbMagnFitWin.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
745 maRbMagnFitWidth.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
746 maRbMagnFitVisible.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
747 maRbMagnZoom.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
750 // -----------------------------------------------------------------------------
751 ImpPDFTabOpnFtrPage::~ImpPDFTabOpnFtrPage()
753 delete mpaResMgr;
756 // -----------------------------------------------------------------------------
757 SfxTabPage* ImpPDFTabOpnFtrPage::Create( Window* pParent,
758 const SfxItemSet& rAttrSet)
760 ByteString aResMgrName( "pdffilter" );
761 ResMgr* paResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
762 return ( new ImpPDFTabOpnFtrPage( pParent, rAttrSet, paResMgr ) );
765 // -----------------------------------------------------------------------------
766 void ImpPDFTabOpnFtrPage::GetFilterConfigItem( ImpPDFTabDialog* paParent )
768 paParent->mnInitialView = 0;
769 if( maRbOpnOutline.IsChecked() )
770 paParent->mnInitialView = 1;
771 else if( maRbOpnThumbs.IsChecked() )
772 paParent->mnInitialView = 2;
774 paParent->mnMagnification = 0;
775 if( maRbMagnFitWin.IsChecked() )
776 paParent->mnMagnification = 1;
777 else if( maRbMagnFitWidth.IsChecked() )
778 paParent->mnMagnification = 2;
779 else if( maRbMagnFitVisible.IsChecked() )
780 paParent->mnMagnification = 3;
781 else if( maRbMagnZoom.IsChecked() )
783 paParent->mnMagnification = 4;
784 paParent->mnZoom = static_cast<sal_Int32>(maNumZoom.GetValue());
787 paParent->mnInitialPage = static_cast<sal_Int32>(maNumInitialPage.GetValue());
789 paParent->mnPageLayout = 0;
790 if( maRbPgLySinglePage.IsChecked() )
791 paParent->mnPageLayout = 1;
792 else if( maRbPgLyContinue.IsChecked() )
793 paParent->mnPageLayout = 2;
794 else if( maRbPgLyContinueFacing.IsChecked() )
795 paParent->mnPageLayout = 3;
797 paParent->mbFirstPageLeft = ( mbUseCTLFont ) ? maCbPgLyFirstOnLeft.IsChecked() : sal_False;
800 // -----------------------------------------------------------------------------
801 void ImpPDFTabOpnFtrPage::SetFilterConfigItem( const ImpPDFTabDialog* paParent )
803 mbUseCTLFont = paParent->mbUseCTLFont;
804 switch( paParent->mnPageLayout )
806 default:
807 case 0:
808 maRbPgLyDefault.Check();
809 break;
810 case 1:
811 maRbPgLySinglePage.Check();
812 break;
813 case 2:
814 maRbPgLyContinue.Check();
815 break;
816 case 3:
817 maRbPgLyContinueFacing.Check();
818 break;
821 switch( paParent->mnInitialView )
823 default:
824 case 0:
825 maRbOpnPageOnly.Check();
826 break;
827 case 1:
828 maRbOpnOutline.Check();
829 break;
830 case 2:
831 maRbOpnThumbs.Check();
832 break;
835 switch( paParent->mnMagnification )
837 default:
838 case 0:
839 maRbMagnDefault.Check();
840 maNumZoom.Enable( FALSE );
841 break;
842 case 1:
843 maRbMagnFitWin.Check();
844 maNumZoom.Enable( FALSE );
845 break;
846 case 2:
847 maRbMagnFitWidth.Check();
848 maNumZoom.Enable( FALSE );
849 break;
850 case 3:
851 maRbMagnFitVisible.Check();
852 maNumZoom.Enable( FALSE );
853 break;
854 case 4:
855 maRbMagnZoom.Check();
856 maNumZoom.Enable( TRUE );
857 break;
860 maNumZoom.SetValue( paParent->mnZoom );
861 maNumInitialPage.SetValue( paParent->mnInitialPage );
863 if( !mbUseCTLFont )
864 maCbPgLyFirstOnLeft.Hide( );
865 else
867 maRbPgLyContinueFacing.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbPgLyContinueFacingHdl ) );
868 maCbPgLyFirstOnLeft.Check( paParent->mbFirstPageLeft );
869 ToggleRbPgLyContinueFacingHdl( NULL );
873 IMPL_LINK( ImpPDFTabOpnFtrPage, ToggleRbPgLyContinueFacingHdl, void*, p )
875 p = p; //for compiler warning
876 maCbPgLyFirstOnLeft.Enable( maRbPgLyContinueFacing.IsChecked() );
877 return 0;
880 IMPL_LINK( ImpPDFTabOpnFtrPage, ToggleRbMagnHdl, void*, )
882 maNumZoom.Enable( maRbMagnZoom.IsChecked() );
883 return 0;
886 ////////////////////////////////////////////////////////
887 // The Viewer preferences tab page
888 // -----------------------------------------------------------------------------
889 ImpPDFTabViewerPage::ImpPDFTabViewerPage( Window* pParent,
890 const SfxItemSet& rCoreSet,
891 ResMgr* paResMgr ) :
892 SfxTabPage( pParent, ResId( RID_PDF_TAB_VPREFER, *paResMgr ), rCoreSet ),
894 maFlWindowOptions( this, ResId( FL_WINOPT, *paResMgr ) ),
895 maCbResWinInit( this, ResId( CB_WNDOPT_RESINIT, *paResMgr ) ),
896 maCbCenterWindow( this, ResId( CB_WNDOPT_CNTRWIN, *paResMgr ) ),
897 maCbOpenFullScreen( this, ResId( CB_WNDOPT_OPNFULL, *paResMgr ) ),
898 maCbDispDocTitle( this, ResId( CB_DISPDOCTITLE, *paResMgr ) ),
900 maFlUIOptions( this, ResId( FL_USRIFOPT, *paResMgr ) ),
901 maCbHideViewerMenubar( this, ResId( CB_UOP_HIDEVMENUBAR, *paResMgr ) ),
902 maCbHideViewerToolbar( this, ResId( CB_UOP_HIDEVTOOLBAR, *paResMgr ) ),
903 maCbHideViewerWindowControls( this, ResId( CB_UOP_HIDEVWINCTRL, *paResMgr ) ),
904 maFlTransitions( this, ResId( FL_TRANSITIONS, *paResMgr ) ),
905 maCbTransitionEffects( this, ResId( CB_TRANSITIONEFFECTS, *paResMgr ) ),
906 mbIsPresentation( sal_True ),
907 maFlBookmarks( this, ResId( FL_BOOKMARKS, *paResMgr ) ),
908 maRbAllBookmarkLevels( this, ResId( RB_ALLBOOKMARKLEVELS, *paResMgr ) ),
909 maRbVisibleBookmarkLevels( this, ResId( RB_VISIBLEBOOKMARKLEVELS, *paResMgr ) ),
910 maNumBookmarkLevels( this, ResId( NUM_BOOKMARKLEVELS, *paResMgr ) )
912 mpaResMgr = paResMgr;
913 FreeResource();
914 maRbAllBookmarkLevels.SetToggleHdl( LINK( this, ImpPDFTabViewerPage, ToggleRbBookmarksHdl ) );
915 maRbVisibleBookmarkLevels.SetToggleHdl( LINK( this, ImpPDFTabViewerPage, ToggleRbBookmarksHdl ) );
918 // -----------------------------------------------------------------------------
919 ImpPDFTabViewerPage::~ImpPDFTabViewerPage()
921 delete mpaResMgr;
924 // -----------------------------------------------------------------------------
925 IMPL_LINK( ImpPDFTabViewerPage, ToggleRbBookmarksHdl, void*, )
927 maNumBookmarkLevels.Enable( maRbVisibleBookmarkLevels.IsChecked() );
928 return 0;
930 // -----------------------------------------------------------------------------
931 SfxTabPage* ImpPDFTabViewerPage::Create( Window* pParent,
932 const SfxItemSet& rAttrSet)
934 ByteString aResMgrName( "pdffilter" );
935 ResMgr* paResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
936 return ( new ImpPDFTabViewerPage( pParent, rAttrSet, paResMgr ) );
939 // -----------------------------------------------------------------------------
940 void ImpPDFTabViewerPage::GetFilterConfigItem( ImpPDFTabDialog* paParent )
942 paParent->mbHideViewerMenubar = maCbHideViewerMenubar.IsChecked();
943 paParent->mbHideViewerToolbar = maCbHideViewerToolbar.IsChecked( );
944 paParent->mbHideViewerWindowControls = maCbHideViewerWindowControls.IsChecked();
945 paParent->mbResizeWinToInit = maCbResWinInit.IsChecked();
946 paParent->mbOpenInFullScreenMode = maCbOpenFullScreen.IsChecked();
947 paParent->mbCenterWindow = maCbCenterWindow.IsChecked();
948 paParent->mbDisplayPDFDocumentTitle = maCbDispDocTitle.IsChecked();
949 paParent->mbUseTransitionEffects = maCbTransitionEffects.IsChecked();
950 paParent->mnOpenBookmarkLevels = maRbAllBookmarkLevels.IsChecked() ?
951 -1 : static_cast<sal_Int32>(maNumBookmarkLevels.GetValue());
954 // -----------------------------------------------------------------------------
955 void ImpPDFTabViewerPage::SetFilterConfigItem( const ImpPDFTabDialog* paParent )
957 maCbHideViewerMenubar.Check( paParent->mbHideViewerMenubar );
958 maCbHideViewerToolbar.Check( paParent->mbHideViewerToolbar );
959 maCbHideViewerWindowControls.Check( paParent->mbHideViewerWindowControls );
961 maCbResWinInit.Check( paParent->mbResizeWinToInit );
962 maCbOpenFullScreen.Check( paParent->mbOpenInFullScreenMode );
963 maCbCenterWindow.Check( paParent->mbCenterWindow );
964 maCbDispDocTitle.Check( paParent->mbDisplayPDFDocumentTitle );
965 mbIsPresentation = paParent->mbIsPresentation;
966 maCbTransitionEffects.Check( paParent->mbUseTransitionEffects );
967 maCbTransitionEffects.Enable( mbIsPresentation );
968 if( paParent->mnOpenBookmarkLevels < 0 )
970 maRbAllBookmarkLevels.Check( TRUE );
971 maNumBookmarkLevels.Enable( FALSE );
973 else
975 maRbVisibleBookmarkLevels.Check( TRUE );
976 maNumBookmarkLevels.Enable( TRUE );
977 maNumBookmarkLevels.SetValue( paParent->mnOpenBookmarkLevels );
981 ////////////////////////////////////////////////////////
982 // The Security preferences tab page
983 // -----------------------------------------------------------------------------
984 ImpPDFTabSecurityPage::ImpPDFTabSecurityPage( Window* i_pParent,
985 const SfxItemSet& i_rCoreSet,
986 ResMgr* i_pResMgr ) :
987 SfxTabPage( i_pParent, ResId( RID_PDF_TAB_SECURITY, *i_pResMgr ), i_rCoreSet ),
988 maPbUserPwd( this, ResId( BTN_USER_PWD, *i_pResMgr ) ),
989 maFtUserPwd( this, ResId( FT_USER_PWD, *i_pResMgr ) ),
990 maUserPwdSet( ResId( STR_USER_PWD_SET, *i_pResMgr ) ),
991 maUserPwdUnset( ResId( STR_USER_PWD_UNSET, *i_pResMgr ) ),
993 maPbOwnerPwd( this, ResId( BTN_OWNER_PWD, *i_pResMgr ) ),
994 maFtOwnerPwd( this, ResId( FT_OWNER_PWD, *i_pResMgr ) ),
995 maOwnerPwdSet( ResId( STR_OWNER_PWD_SET, *i_pResMgr ) ),
996 maOwnerPwdUnset( ResId( STR_OWNER_PWD_UNSET, *i_pResMgr ) ),
998 maFlPrintPermissions( this, ResId( FL_PRINT_PERMISSIONS , *i_pResMgr ) ),
999 maRbPrintNone( this, ResId( RB_PRINT_NONE, *i_pResMgr ) ),
1000 maRbPrintLowRes( this, ResId( RB_PRINT_LOWRES , *i_pResMgr ) ),
1001 maRbPrintHighRes( this, ResId( RB_PRINT_HIGHRES , *i_pResMgr ) ),
1003 maFlChangesAllowed( this, ResId( FL_CHANGES_ALLOWED , *i_pResMgr ) ),
1004 maRbChangesNone( this, ResId( RB_CHANGES_NONE , *i_pResMgr ) ),
1005 maRbChangesInsDel( this, ResId( RB_CHANGES_INSDEL , *i_pResMgr ) ),
1006 maRbChangesFillForm( this, ResId( RB_CHANGES_FILLFORM , *i_pResMgr ) ),
1007 maRbChangesComment( this, ResId( RB_CHANGES_COMMENT , *i_pResMgr ) ),
1008 maRbChangesAnyNoCopy( this, ResId( RB_CHANGES_ANY_NOCOPY , *i_pResMgr ) ),
1010 maCbEnableCopy( this, ResId( CB_ENDAB_COPY , *i_pResMgr ) ),
1011 maCbEnableAccessibility( this, ResId( CB_ENAB_ACCESS , *i_pResMgr ) ),
1013 msUserPwdTitle( ResId( STR_PDF_EXPORT_UDPWD, *i_pResMgr ) ),
1015 msOwnerPwdTitle( ResId( STR_PDF_EXPORT_ODPWD, *i_pResMgr ) )
1017 mpaResMgr = i_pResMgr;
1019 maUserPwdSet.Append( sal_Unicode( '\n' ) );
1020 maUserPwdSet.Append( String( ResId( STR_USER_PWD_ENC, *i_pResMgr ) ) );
1022 maUserPwdUnset.Append( sal_Unicode( '\n' ) );
1023 maUserPwdUnset.Append( String( ResId( STR_USER_PWD_UNENC, *i_pResMgr ) ) );
1025 maOwnerPwdSet.Append( sal_Unicode( '\n' ) );
1026 maOwnerPwdSet.Append( String( ResId( STR_OWNER_PWD_REST, *i_pResMgr ) ) );
1028 maOwnerPwdUnset.Append( sal_Unicode( '\n' ) );
1029 maOwnerPwdUnset.Append( String( ResId( STR_OWNER_PWD_UNREST, *i_pResMgr ) ) );
1031 FreeResource();
1033 maFtUserPwd.SetText( maUserPwdUnset );
1034 maFtOwnerPwd.SetText( maOwnerPwdUnset );
1036 // pb: #i91991# maRbChangesComment double-spaced if necessary
1037 Size aSize = maRbChangesComment.GetSizePixel();
1038 Size aMinSize = maRbChangesComment.CalcMinimumSize();
1039 if ( aSize.Width() > aMinSize.Width() )
1041 Size aNewSize = maRbChangesFillForm.GetSizePixel();
1042 long nDelta = aSize.Height() - aNewSize.Height();
1043 maRbChangesComment.SetSizePixel( aNewSize );
1044 Window* pWins[] =
1045 { &maRbChangesAnyNoCopy, &maCbEnableCopy, &maCbEnableAccessibility, NULL };
1046 Window** pCurrent = pWins;
1047 while ( *pCurrent )
1049 Point aNewPos = (*pCurrent)->GetPosPixel();
1050 aNewPos.Y() -= nDelta;
1051 (*pCurrent++)->SetPosPixel( aNewPos );
1056 // -----------------------------------------------------------------------------
1057 ImpPDFTabSecurityPage::~ImpPDFTabSecurityPage()
1059 delete mpaResMgr;
1062 // -----------------------------------------------------------------------------
1063 SfxTabPage* ImpPDFTabSecurityPage::Create( Window* pParent,
1064 const SfxItemSet& rAttrSet)
1066 ByteString aResMgrName( "pdffilter" );
1067 ResMgr* paResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
1068 return ( new ImpPDFTabSecurityPage( pParent, rAttrSet, paResMgr ) );
1071 // -----------------------------------------------------------------------------
1072 void ImpPDFTabSecurityPage::GetFilterConfigItem( ImpPDFTabDialog* paParent )
1074 // please note that in PDF/A-1a mode even if this are copied back,
1075 // the security settings are forced disabled in PDFExport::Export
1076 paParent->mbEncrypt = (msUserPassword.Len() > 0);
1077 if( paParent->mbEncrypt )
1078 paParent->msUserPassword = msUserPassword;
1080 paParent->mbRestrictPermissions = (msOwnerPassword.Len() > 0);
1081 if( msOwnerPassword.Len() > 0 )
1082 paParent->msOwnerPassword = msOwnerPassword;
1084 //verify print status
1085 paParent->mnPrint = 0;
1086 if( maRbPrintLowRes.IsChecked() )
1087 paParent->mnPrint = 1;
1088 else if( maRbPrintHighRes.IsChecked() )
1089 paParent->mnPrint = 2;
1091 //verify changes permitted
1092 paParent->mnChangesAllowed = 0;
1094 if( maRbChangesInsDel.IsChecked() )
1095 paParent->mnChangesAllowed = 1;
1096 else if( maRbChangesFillForm.IsChecked() )
1097 paParent->mnChangesAllowed = 2;
1098 else if( maRbChangesComment.IsChecked() )
1099 paParent->mnChangesAllowed = 3;
1100 else if( maRbChangesAnyNoCopy.IsChecked() )
1101 paParent->mnChangesAllowed = 4;
1103 paParent->mbCanCopyOrExtract = maCbEnableCopy.IsChecked();
1104 paParent->mbCanExtractForAccessibility = maCbEnableAccessibility.IsChecked();
1108 // -----------------------------------------------------------------------------
1109 void ImpPDFTabSecurityPage::SetFilterConfigItem( const ImpPDFTabDialog* paParent )
1111 maPbUserPwd.SetClickHdl( LINK( this, ImpPDFTabSecurityPage, ClickmaPbUserPwdHdl ) );
1113 maPbOwnerPwd.SetClickHdl( LINK( this, ImpPDFTabSecurityPage, ClickmaPbOwnerPwdHdl ) );
1115 switch( paParent->mnPrint )
1117 default:
1118 case 0:
1119 maRbPrintNone.Check();
1120 break;
1121 case 1:
1122 maRbPrintLowRes.Check();
1123 break;
1124 case 2:
1125 maRbPrintHighRes.Check();
1126 break;
1129 switch( paParent->mnChangesAllowed )
1131 default:
1132 case 0:
1133 maRbChangesNone.Check();
1134 break;
1135 case 1:
1136 maRbChangesInsDel.Check();
1137 break;
1138 case 2:
1139 maRbChangesFillForm.Check();
1140 break;
1141 case 3:
1142 maRbChangesComment.Check();
1143 break;
1144 case 4:
1145 maRbChangesAnyNoCopy.Check();
1146 break;
1149 maCbEnableCopy.Check( paParent->mbCanCopyOrExtract );
1150 maCbEnableAccessibility.Check( paParent->mbCanExtractForAccessibility );
1152 // set the status of this windows, according to the PDFA selection
1153 enablePermissionControls();
1155 if( paParent && paParent->GetTabPage( RID_PDF_TAB_GENER ) )
1156 ImplPDFASecurityControl(
1157 !( ( ImpPDFTabGeneralPage* )paParent->GetTabPage( RID_PDF_TAB_GENER ) )->IsPdfaSelected() );
1160 //method common to both the password entry procedures
1161 void ImpPDFTabSecurityPage::ImplPwdPushButton( const String & i_rDlgTitle, String & io_rDestPassword )
1163 // string needed: dialog title, message box text, depending on the button clicked
1164 SfxPasswordDialog aPwdDialog( this );
1165 aPwdDialog.SetMinLen( 0 );
1166 aPwdDialog.ShowExtras( SHOWEXTRAS_CONFIRM );
1167 aPwdDialog.SetText( i_rDlgTitle );
1168 if( aPwdDialog.Execute() == RET_OK ) //OK issued get password and set it
1169 io_rDestPassword = aPwdDialog.GetPassword();
1170 enablePermissionControls();
1173 IMPL_LINK( ImpPDFTabSecurityPage, ClickmaPbUserPwdHdl, void*, EMPTYARG )
1175 ImplPwdPushButton(msUserPwdTitle, msUserPassword );
1176 return 0;
1179 IMPL_LINK( ImpPDFTabSecurityPage, ClickmaPbOwnerPwdHdl, void*, EMPTYARG )
1181 ImplPwdPushButton( msOwnerPwdTitle, msOwnerPassword );
1183 return 0;
1186 void ImpPDFTabSecurityPage::enablePermissionControls()
1188 maFtUserPwd.SetText( (msUserPassword.Len() > 0 && IsEnabled()) ? maUserPwdSet : maUserPwdUnset );
1190 sal_Bool bLocalEnable = (msOwnerPassword.Len() > 0) && IsEnabled();
1192 maFtOwnerPwd.SetText( bLocalEnable ? maOwnerPwdSet : maOwnerPwdUnset );
1194 maFlPrintPermissions.Enable( bLocalEnable );
1195 maRbPrintNone.Enable( bLocalEnable );
1196 maRbPrintLowRes.Enable( bLocalEnable );
1197 maRbPrintHighRes.Enable( bLocalEnable );
1199 maFlChangesAllowed.Enable( bLocalEnable );
1200 maRbChangesNone.Enable( bLocalEnable );
1201 maRbChangesInsDel.Enable( bLocalEnable );
1202 maRbChangesFillForm.Enable( bLocalEnable );
1203 maRbChangesComment.Enable( bLocalEnable );
1204 maRbChangesAnyNoCopy.Enable( bLocalEnable );
1206 maCbEnableCopy.Enable( bLocalEnable );
1207 maCbEnableAccessibility.Enable( bLocalEnable );
1210 ////////////////////////////////////////////////////////
1211 // This tab page is under control of the PDF/A-1a checkbox:
1212 // implement a method to do it.
1213 // -----------------------------------------------------------------------------
1214 void ImpPDFTabSecurityPage::ImplPDFASecurityControl( sal_Bool bEnableSecurity )
1216 if( bEnableSecurity )
1218 Enable();
1219 //after enable, check the status of control as if the dialog was initialized
1221 else
1222 Enable( sal_False );
1224 enablePermissionControls();
1227 ////////////////////////////////////////////////////////
1228 // The link preferences tab page (relative and other stuff)
1229 // -----------------------------------------------------------------------------
1230 ImpPDFTabLinksPage::ImpPDFTabLinksPage( Window* pParent,
1231 const SfxItemSet& rCoreSet,
1232 ResMgr& rResMgr ) :
1233 SfxTabPage( pParent, ResId( RID_PDF_TAB_LINKS, rResMgr ), rCoreSet ),
1235 maCbExprtBmkrToNmDst( this, ResId( CB_EXP_BMRK_TO_DEST , rResMgr ) ),
1236 maCbOOoToPDFTargets( this, ResId( CB_CNV_OOO_DOCTOPDF , rResMgr ) ),
1237 maCbExportRelativeFsysLinks( this, ResId( CB_ENAB_RELLINKFSYS , rResMgr ) ),
1239 maFlDefaultTitle( this, ResId( FL_DEFAULT_LINK_ACTION , rResMgr ) ),
1240 maRbOpnLnksDefault( this, ResId( CB_VIEW_PDF_DEFAULT , rResMgr ) ),
1241 mbOpnLnksDefaultUserState( sal_False ),
1242 maRbOpnLnksLaunch( this, ResId( CB_VIEW_PDF_APPLICATION , rResMgr ) ),
1243 mbOpnLnksLaunchUserState( sal_False ),
1244 maRbOpnLnksBrowser( this, ResId( CB_VIEW_PDF_BROWSER , rResMgr ) ),
1245 mbOpnLnksBrowserUserState( sal_False )
1247 mpaResMgr = &rResMgr;
1248 FreeResource();
1250 // pb: #i91991# checkboxes only double-spaced if necessary
1251 long nDelta = 0;
1252 Size aSize = maCbExprtBmkrToNmDst.GetSizePixel();
1253 Size aMinSize = maCbExprtBmkrToNmDst.CalcMinimumSize();
1254 long nLineHeight =
1255 maCbExprtBmkrToNmDst.LogicToPixel( Size( 10, 10 ), MAP_APPFONT ).Height();
1256 if ( aSize.Width() > aMinSize.Width() )
1258 Size aNewSize( aSize.Width(), nLineHeight );
1259 nDelta += ( aSize.Height() - nLineHeight );
1260 maCbExprtBmkrToNmDst.SetSizePixel( aNewSize );
1261 Point aNewPos = maCbOOoToPDFTargets.GetPosPixel();
1262 aNewPos.Y() -= nDelta;
1263 maCbOOoToPDFTargets.SetPosPixel( aNewPos );
1266 aSize = maCbOOoToPDFTargets.GetSizePixel();
1267 aMinSize = maCbOOoToPDFTargets.CalcMinimumSize();
1268 if ( aSize.Width() > aMinSize.Width() )
1270 Size aNewSize( aSize.Width(), nLineHeight );
1271 nDelta += ( aSize.Height() - nLineHeight );
1272 maCbOOoToPDFTargets.SetSizePixel( aNewSize );
1273 Point aNewPos = maCbExportRelativeFsysLinks.GetPosPixel();
1274 aNewPos.Y() -= nDelta;
1275 maCbExportRelativeFsysLinks.SetPosPixel( aNewPos );
1278 aSize = maCbExportRelativeFsysLinks.GetSizePixel();
1279 aMinSize = maCbExportRelativeFsysLinks.CalcMinimumSize();
1280 if ( aSize.Width() > aMinSize.Width() )
1282 Size aNewSize( aSize.Width(), nLineHeight );
1283 nDelta += ( aSize.Height() - nLineHeight );
1284 maCbExportRelativeFsysLinks.SetSizePixel( aNewSize );
1287 if ( nDelta > 0 )
1289 Window* pWins[] =
1290 { &maFlDefaultTitle, &maRbOpnLnksDefault, &maRbOpnLnksLaunch, &maRbOpnLnksBrowser, NULL };
1291 Window** pCurrent = pWins;
1292 while ( *pCurrent )
1294 Point aNewPos = (*pCurrent)->GetPosPixel();
1295 aNewPos.Y() -= nDelta;
1296 (*pCurrent++)->SetPosPixel( aNewPos );
1301 // -----------------------------------------------------------------------------
1302 ImpPDFTabLinksPage::~ImpPDFTabLinksPage()
1304 delete mpaResMgr;
1307 // -----------------------------------------------------------------------------
1308 SfxTabPage* ImpPDFTabLinksPage::Create( Window* pParent,
1309 const SfxItemSet& rAttrSet)
1311 ByteString aResMgrName( "pdffilter" );
1312 ResMgr * paResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
1313 return ( new ImpPDFTabLinksPage( pParent, rAttrSet, *paResMgr ) );
1316 // -----------------------------------------------------------------------------
1317 void ImpPDFTabLinksPage::GetFilterConfigItem( ImpPDFTabDialog* paParent )
1319 paParent->mbExportRelativeFsysLinks = maCbExportRelativeFsysLinks.IsChecked();
1321 sal_Bool bIsPDFASel = sal_False;
1322 if( paParent && paParent->GetTabPage( RID_PDF_TAB_GENER ) )
1323 bIsPDFASel = ( ( ImpPDFTabGeneralPage* )paParent->
1324 GetTabPage( RID_PDF_TAB_GENER ) )->IsPdfaSelected();
1325 // if PDF/A-1 was not selected while exiting dialog...
1326 if( !bIsPDFASel )
1328 // ...get the control states
1329 mbOpnLnksDefaultUserState = maRbOpnLnksDefault.IsChecked();
1330 mbOpnLnksLaunchUserState = maRbOpnLnksLaunch.IsChecked();
1331 mbOpnLnksBrowserUserState = maRbOpnLnksBrowser.IsChecked();
1333 // the control states, or the saved is used
1334 // to form the stored selection
1335 paParent->mnViewPDFMode = 0;
1336 if( mbOpnLnksBrowserUserState )
1337 paParent->mnViewPDFMode = 2;
1338 else if( mbOpnLnksLaunchUserState )
1339 paParent->mnViewPDFMode = 1;
1341 paParent->mbConvertOOoTargets = maCbOOoToPDFTargets.IsChecked();
1342 paParent->mbExportBmkToPDFDestination = maCbExprtBmkrToNmDst.IsChecked();
1345 // -----------------------------------------------------------------------------
1346 void ImpPDFTabLinksPage::SetFilterConfigItem( const ImpPDFTabDialog* paParent )
1348 maCbOOoToPDFTargets.Check( paParent->mbConvertOOoTargets );
1349 maCbExprtBmkrToNmDst.Check( paParent->mbExportBmkToPDFDestination );
1351 maRbOpnLnksDefault.SetClickHdl( LINK( this, ImpPDFTabLinksPage, ClickRbOpnLnksDefaultHdl ) );
1352 maRbOpnLnksBrowser.SetClickHdl( LINK( this, ImpPDFTabLinksPage, ClickRbOpnLnksBrowserHdl ) );
1354 maCbExportRelativeFsysLinks.Check( paParent->mbExportRelativeFsysLinks );
1355 switch( paParent->mnViewPDFMode )
1357 default:
1358 case 0:
1359 maRbOpnLnksDefault.Check();
1360 mbOpnLnksDefaultUserState = sal_True;
1361 break;
1362 case 1:
1363 maRbOpnLnksLaunch.Check();
1364 mbOpnLnksLaunchUserState = sal_True;
1365 break;
1366 case 2:
1367 maRbOpnLnksBrowser.Check();
1368 mbOpnLnksBrowserUserState = sal_True;
1369 break;
1371 // now check the status of PDF/A selection
1372 // and set the link action accordingly
1373 // PDF/A-1 doesn't allow launch action on links
1375 if( paParent && paParent->GetTabPage( RID_PDF_TAB_GENER ) )
1376 ImplPDFALinkControl(
1377 !( ( ImpPDFTabGeneralPage* )paParent->
1378 GetTabPage( RID_PDF_TAB_GENER ) )->maCbPDFA1b.IsChecked() );
1381 // -----------------------------------------------------------------------------
1382 // called from general tab, with PDFA/1 selection status
1383 // retrieves/store the status of Launch action selection
1384 void ImpPDFTabLinksPage::ImplPDFALinkControl( sal_Bool bEnableLaunch )
1386 // set the value and position of link type selection
1387 if( bEnableLaunch )
1389 maRbOpnLnksLaunch.Enable();
1390 //restore user state with no PDF/A-1 selected
1391 maRbOpnLnksDefault.Check( mbOpnLnksDefaultUserState );
1392 maRbOpnLnksLaunch.Check( mbOpnLnksLaunchUserState );
1393 maRbOpnLnksBrowser.Check( mbOpnLnksBrowserUserState );
1395 else
1397 //save user state with no PDF/A-1 selected
1398 mbOpnLnksDefaultUserState = maRbOpnLnksDefault.IsChecked();
1399 mbOpnLnksLaunchUserState = maRbOpnLnksLaunch.IsChecked();
1400 mbOpnLnksBrowserUserState = maRbOpnLnksBrowser.IsChecked();
1401 maRbOpnLnksLaunch.Enable( sal_False );
1402 if( mbOpnLnksLaunchUserState )
1403 maRbOpnLnksBrowser.Check();
1407 // -----------------------------------------------------------------------------
1408 // reset the memory of Launch action present
1409 // when PDF/A-1 was requested
1410 IMPL_LINK( ImpPDFTabLinksPage, ClickRbOpnLnksDefaultHdl, void*, EMPTYARG )
1412 mbOpnLnksDefaultUserState = maRbOpnLnksDefault.IsChecked();
1413 mbOpnLnksLaunchUserState = maRbOpnLnksLaunch.IsChecked();
1414 mbOpnLnksBrowserUserState = maRbOpnLnksBrowser.IsChecked();
1415 return 0;
1418 // -----------------------------------------------------------------------------
1419 // reset the memory of a launch action present
1420 // when PDF/A-1 was requested
1421 IMPL_LINK( ImpPDFTabLinksPage, ClickRbOpnLnksBrowserHdl, void*, EMPTYARG )
1423 mbOpnLnksDefaultUserState = maRbOpnLnksDefault.IsChecked();
1424 mbOpnLnksLaunchUserState = maRbOpnLnksLaunch.IsChecked();
1425 mbOpnLnksBrowserUserState = maRbOpnLnksBrowser.IsChecked();
1426 return 0;
1429 ImplErrorDialog::ImplErrorDialog( const std::set< vcl::PDFWriter::ErrorCode >& rErrors, ResMgr& rResMgr ) :
1430 ModalDialog( NULL, ResId( RID_PDF_ERROR_DLG, rResMgr ) ),
1431 maFI( this, 0 ),
1432 maProcessText( this, ResId( FT_PROCESS, rResMgr ) ),
1433 maErrors( this, WB_BORDER | WB_AUTOVSCROLL ),
1434 maExplanation( this, WB_WORDBREAK ),
1435 maButton( this, WB_DEFBUTTON )
1438 // load images
1439 Image aWarnImg = Image ( BitmapEx( ResId( IMG_WARN, rResMgr ) ) );
1440 Image aErrImg= Image ( BitmapEx( ResId( IMG_ERR, rResMgr ) ) );
1442 for( std::set<vcl::PDFWriter::ErrorCode>::const_iterator it = rErrors.begin();
1443 it != rErrors.end(); ++it )
1445 switch( *it )
1447 case vcl::PDFWriter::Warning_Transparency_Omitted_PDFA:
1449 USHORT nPos = maErrors.InsertEntry( String( ResId( STR_WARN_TRANSP_PDFA_SHORT, rResMgr ) ),
1450 aWarnImg );
1451 maErrors.SetEntryData( nPos, new String( ResId( STR_WARN_TRANSP_PDFA, rResMgr ) ) );
1453 break;
1454 case vcl::PDFWriter::Warning_Transparency_Omitted_PDF13:
1456 USHORT nPos = maErrors.InsertEntry( String( ResId( STR_WARN_TRANSP_VERSION_SHORT, rResMgr ) ),
1457 aWarnImg );
1458 maErrors.SetEntryData( nPos, new String( ResId( STR_WARN_TRANSP_VERSION, rResMgr ) ) );
1460 break;
1461 case vcl::PDFWriter::Warning_FormAction_Omitted_PDFA:
1463 USHORT nPos = maErrors.InsertEntry( String( ResId( STR_WARN_FORMACTION_PDFA_SHORT, rResMgr ) ),
1464 aWarnImg );
1465 maErrors.SetEntryData( nPos, new String( ResId( STR_WARN_FORMACTION_PDFA, rResMgr ) ) );
1467 break;
1468 case vcl::PDFWriter::Warning_Transparency_Converted:
1470 USHORT nPos = maErrors.InsertEntry( String( ResId( STR_WARN_TRANSP_CONVERTED_SHORT, rResMgr ) ),
1471 aWarnImg );
1472 maErrors.SetEntryData( nPos, new String( ResId( STR_WARN_TRANSP_CONVERTED, rResMgr ) ) );
1474 break;
1475 default:
1476 break;
1480 FreeResource();
1482 if( maErrors.GetEntryCount() > 0 )
1484 maErrors.SelectEntryPos( 0 );
1485 String* pStr = reinterpret_cast<String*>(maErrors.GetEntryData( 0 ));
1486 maExplanation.SetText( pStr ? *pStr : String() );
1489 // adjust layout
1490 Image aWarnImage( WarningBox::GetStandardImage() );
1491 Size aImageSize( aWarnImage.GetSizePixel() );
1492 Size aDlgSize( GetSizePixel() );
1493 aImageSize.Width() += 6;
1494 aImageSize.Height() += 6;
1495 maFI.SetImage( aWarnImage );
1496 maFI.SetPosSizePixel( Point( 5, 5 ), aImageSize );
1497 maFI.Show();
1499 maProcessText.SetStyle( maProcessText.GetStyle() | WB_VCENTER );
1500 maProcessText.SetPosSizePixel( Point( aImageSize.Width() + 10, 5 ),
1501 Size( aDlgSize.Width() - aImageSize.Width() - 15, aImageSize.Height() ) );
1503 Point aErrorLBPos( 5, aImageSize.Height() + 10 );
1504 Size aErrorLBSize( aDlgSize.Width()/2 - 10, aDlgSize.Height() - aErrorLBPos.Y() - 35 );
1505 maErrors.SetPosSizePixel( aErrorLBPos, aErrorLBSize );
1506 maErrors.SetSelectHdl( LINK( this, ImplErrorDialog, SelectHdl ) );
1507 maErrors.Show();
1509 maExplanation.SetPosSizePixel( Point( aErrorLBPos.X() + aErrorLBSize.Width() + 5, aErrorLBPos.Y() ),
1510 Size( aDlgSize.Width() - aErrorLBPos.X() - aErrorLBSize.Width() - 10, aErrorLBSize.Height() ) );
1511 maExplanation.Show();
1513 maButton.SetPosSizePixel( Point( (aDlgSize.Width() - 50)/2, aDlgSize.Height() - 30 ),
1514 Size( 50, 25 ) );
1515 maButton.Show();
1518 ImplErrorDialog::~ImplErrorDialog()
1520 // free strings again
1521 for( USHORT n = 0; n < maErrors.GetEntryCount(); n++ )
1522 delete (String*)maErrors.GetEntryData( n );
1525 IMPL_LINK( ImplErrorDialog, SelectHdl, ListBox*, EMPTYARG )
1527 String* pStr = reinterpret_cast<String*>(maErrors.GetEntryData( maErrors.GetSelectEntryPos() ));
1528 maExplanation.SetText( pStr ? *pStr : String() );
1529 return 0;