xref: /trunk/main/filter/source/pdf/impdialog.cxx (revision 9e0fc027)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_filter.hxx"
26 
27 #include "impdialog.hxx"
28 #include "impdialog.hrc"
29 #include "vcl/svapp.hxx"
30 #include "vcl/msgbox.hxx"
31 #include "sfx2/passwd.hxx"
32 
33 #include "comphelper/storagehelper.hxx"
34 
35 #include "com/sun/star/text/XTextRange.hpp"
36 #include "com/sun/star/drawing/XShapes.hpp"
37 #include "com/sun/star/container/XIndexAccess.hpp"
38 #include "com/sun/star/frame/XController.hpp"
39 #include "com/sun/star/view/XSelectionSupplier.hpp"
40 
41 #include <boost/shared_ptr.hpp>
42 
43 static ResMgr& getPDFFilterResMgr()
44 {
45     static ResMgr *pRes = ResMgr::CreateResMgr( "pdffilter", Application::GetSettings().GetUILocale());
46     return *pRes;
47 }
48 
49 PDFFilterResId::PDFFilterResId( sal_uInt32 nId ) : ResId( nId, getPDFFilterResMgr() )
50 {
51 }
52 
53 // ----------------
54 // - ImpPDFDialog -
55 // ----------------
56 
57 using namespace ::com::sun::star;
58 
59 //////////////////////////////////////////////////////////////////////////////////////////////////////
60 // tabbed PDF dialog implementation
61 // please note: the default used here are the same as per specification,
62 // they should be the same in  PDFFilter::implExport and  in PDFExport::PDFExport
63 // -----------------------------------------------------------------------------
64 ImpPDFTabDialog::ImpPDFTabDialog( Window* pParent,
65                                   Sequence< PropertyValue >& rFilterData,
66                                   const Reference< XComponent >& rxDoc,
67                                   const Reference< lang::XMultiServiceFactory >& xFact
68                                   ) :
69     SfxTabDialog( pParent, PDFFilterResId( RID_PDF_EXPORT_DLG ), 0, sal_False, 0 ),
70     mxMSF( xFact ),
71     maConfigItem( String( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/PDF/Export/" ) ), &rFilterData ),
72     maConfigI18N( String( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/I18N/CTL/" ) ) ),
73     mbIsPresentation( sal_False ),
74     mbIsWriter( sal_False ),
75 
76     mbSelectionPresent( sal_False ),
77     mbUseCTLFont( sal_False ),
78     mbUseLosslessCompression( sal_True ),
79     mnQuality( 90 ),
80     mbReduceImageResolution( sal_False ),
81     mnMaxImageResolution( 300 ),
82     mbUseTaggedPDF( sal_False ),
83     mbExportNotes( sal_True ),
84 	mbExportNotesPages( sal_False ),
85     mbUseTransitionEffects( sal_False ),
86     mbIsSkipEmptyPages( sal_True ),
87     mbAddStream( sal_False ),
88     mbEmbedStandardFonts( sal_False ),
89     mnFormsType( 0 ),
90     mbExportFormFields( sal_True ),
91     mbAllowDuplicateFieldNames( sal_False ),
92     mbExportBookmarks( sal_True ),
93     mnOpenBookmarkLevels( -1 ),
94 
95     mbHideViewerToolbar( sal_False ),
96     mbHideViewerMenubar( sal_False ),
97     mbHideViewerWindowControls( sal_False ),
98     mbResizeWinToInit( sal_False ),
99     mbCenterWindow( sal_False ),
100     mbOpenInFullScreenMode( sal_False ),
101     mbDisplayPDFDocumentTitle( sal_False ),
102     mnMagnification( 0 ),
103     mnInitialView( 0 ),
104     mnZoom( 0 ),
105     mnInitialPage( 1 ),
106     mnPageLayout( 0 ),
107     mbFirstPageLeft( sal_False ),
108 
109     mbEncrypt( false ),
110 	mbRestrictPermissions( false ),
111     mnPrint( 0 ),
112     mnChangesAllowed( 0 ),
113     mbCanCopyOrExtract( false ),
114     mbCanExtractForAccessibility( true ),
115 
116     mbIsRangeChecked( sal_False ),
117     msPageRange( ' ' ),
118 
119     mbSelectionIsChecked( sal_False ),
120     mbExportRelativeFsysLinks( sal_False ),
121     mnViewPDFMode( 0 ),
122     mbConvertOOoTargets( sal_False ),
123     mbExportBmkToPDFDestination( sal_False )
124 {
125     FreeResource();
126 // check for selection
127     try
128     {
129         Reference< frame::XController > xController( Reference< frame::XModel >( rxDoc, UNO_QUERY )->getCurrentController() );
130         if( xController.is() )
131         {
132             Reference< view::XSelectionSupplier > xView( xController, UNO_QUERY );
133             if( xView.is() )
134                 xView->getSelection() >>= maSelection;
135         }
136     }
137     catch( RuntimeException )
138     {
139     }
140     mbSelectionPresent = maSelection.hasValue();
141     if ( mbSelectionPresent )
142     {
143         Reference< drawing::XShapes > xShapes;
144         if ( ( maSelection >>= xShapes ) == sal_False )	// XShapes is always a selection
145         {
146             // even if nothing is selected in writer the selection is not empty
147             Reference< container::XIndexAccess > xIndexAccess;
148             if ( maSelection >>= xIndexAccess )
149             {
150                 sal_Int32 nLen = xIndexAccess->getCount();
151                 if ( !nLen )
152                     mbSelectionPresent = sal_False;
153                 else if ( nLen == 1 )
154                 {
155                     Reference< text::XTextRange > xTextRange( xIndexAccess->getByIndex( 0 ), UNO_QUERY );
156                     if ( xTextRange.is() && ( xTextRange->getString().getLength() == 0 ) )
157                         mbSelectionPresent = sal_False;
158                 }
159             }
160         }
161     }
162 
163 // check if source document is a presentation
164     try
165     {
166         Reference< XServiceInfo > xInfo( rxDoc, UNO_QUERY );
167         if ( xInfo.is() )
168         {
169             if ( xInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) ) )
170                 mbIsPresentation = sal_True;
171             if ( xInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.GenericTextDocument" ) ) ) )
172                 mbIsWriter = sal_True;
173         }
174     }
175     catch( RuntimeException )
176     {
177     }
178 
179 //get the CTL (Complex Text Layout) from general options, returns sal_True if we have a CTL font on our hands.
180     mbUseCTLFont = maConfigI18N.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "CTLFont" ) ), sal_False );
181 
182     mbUseLosslessCompression = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseLosslessCompression" ) ), sal_False );
183     mnQuality = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Quality" ) ), 90 );
184     mbReduceImageResolution = maConfigItem.ReadBool(  OUString( RTL_CONSTASCII_USTRINGPARAM( "ReduceImageResolution" ) ), sal_False );
185     mnMaxImageResolution = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxImageResolution" ) ), 300 );
186 
187     mbUseTaggedPDF = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseTaggedPDF" ) ), sal_False );
188     mnPDFTypeSelection =  maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectPdfVersion" ) ), 0 );
189     if ( mbIsPresentation )
190         mbExportNotesPages = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotesPages"  ) ), sal_False );
191 	mbExportNotes = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotes"  ) ), sal_False );
192 
193     mbExportBookmarks = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportBookmarks" ) ), sal_True );
194     mnOpenBookmarkLevels = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenBookmarkLevels" ) ), -1 );
195     mbUseTransitionEffects = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseTransitionEffects"  ) ), sal_True );
196     mbIsSkipEmptyPages = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages"  ) ), sal_False );
197     mbAddStream = maConfigItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( "IsAddStream" ) ), sal_False );
198     mbEmbedStandardFonts = maConfigItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( "EmbedStandardFonts" ) ), sal_False );
199 
200     mnFormsType = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "FormsType" ) ), 0 );
201     mbExportFormFields = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportFormFields" ) ), sal_True );
202     if ( ( mnFormsType < 0 ) || ( mnFormsType > 3 ) )
203         mnFormsType = 0;
204     mbAllowDuplicateFieldNames = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowDuplicateFieldNames" ) ), sal_False );
205 
206 //prepare values for the Viewer tab page
207     mbHideViewerToolbar = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerToolbar" ) ), sal_False );
208     mbHideViewerMenubar = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerMenubar" ) ), sal_False );
209     mbHideViewerWindowControls = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerWindowControls" ) ), sal_False );
210     mbResizeWinToInit = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ResizeWindowToInitialPage" ) ), sal_False );
211     mbCenterWindow = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "CenterWindow" ) ), sal_False );
212     mbOpenInFullScreenMode = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenInFullScreenMode" ) ), sal_False );
213     mbDisplayPDFDocumentTitle = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "DisplayPDFDocumentTitle" ) ), sal_True );
214 
215     mnInitialView = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "InitialView" ) ), 0 );
216     mnMagnification = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Magnification" ) ), 0 );
217     mnZoom = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) ), 100 );
218     mnPageLayout = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "PageLayout" ) ), 0 );
219     mbFirstPageLeft = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "FirstPageOnLeft" ) ), sal_False );
220     mnInitialPage = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "InitialPage" ) ), 1 );
221     if( mnInitialPage < 1 )
222         mnInitialPage = 1;
223 
224 //prepare values for the security tab page
225     mnPrint = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Printing" ) ), 2 );
226     mnChangesAllowed = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Changes" ) ), 4 );
227     mbCanCopyOrExtract = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableCopyingOfContent" ) ), sal_True );
228     mbCanExtractForAccessibility = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableTextAccessForAccessibilityTools" ) ), sal_True );
229 
230 //prepare values for relative links
231 	mbExportRelativeFsysLinks = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportLinksRelativeFsys" ) ), sal_False );
232 
233 	mnViewPDFMode = maConfigItem.ReadInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "PDFViewSelection" ) ), 0 );
234 
235     mbConvertOOoTargets = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ConvertOOoTargetToPDFTarget" ) ), sal_False );
236     mbExportBmkToPDFDestination = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportBookmarksToPDFDestination" ) ), sal_False );
237 
238 //queue the tab pages for later creation (created when first shown)
239     AddTabPage( RID_PDF_TAB_SECURITY, ImpPDFTabSecurityPage::Create, 0 );
240 	AddTabPage( RID_PDF_TAB_LINKS, ImpPDFTabLinksPage::Create, 0 );
241     AddTabPage( RID_PDF_TAB_VPREFER, ImpPDFTabViewerPage::Create, 0 );
242     AddTabPage( RID_PDF_TAB_OPNFTR, ImpPDFTabOpnFtrPage::Create, 0 );
243 
244 //last queued is the first to be displayed (or so it seems..)
245     AddTabPage( RID_PDF_TAB_GENER, ImpPDFTabGeneralPage::Create, 0 );
246 
247 //get the string property value (from sfx2/source/dialog/mailmodel.cxx) to overwrite the text for the Ok button
248     ::rtl::OUString sOkButtonText = maConfigItem.ReadString( OUString( RTL_CONSTASCII_USTRINGPARAM( "_OkButtonString" ) ), OUString() );
249 
250 //change text on the Ok button: get the relevant string from resources, update it on the button
251 //according to the exported pdf file destination: send as e-mail or write to file?
252     GetOKButton().SetText( ( sOkButtonText.getLength() > 0 ) ?
253                             sOkButtonText : OUString( String( PDFFilterResId( STR_PDF_EXPORT ) ) ));
254 
255 //remove the reset button, not needed in this tabbed dialog
256     RemoveResetButton();
257 /////////////////
258 }
259 
260 // -----------------------------------------------------------------------------
261 ImpPDFTabDialog::~ImpPDFTabDialog()
262 {
263 //delete the pages, needed because otherwise the child tab pages
264 //don't get destroyed
265     RemoveTabPage( RID_PDF_TAB_GENER );
266     RemoveTabPage( RID_PDF_TAB_VPREFER );
267     RemoveTabPage( RID_PDF_TAB_OPNFTR );
268     RemoveTabPage( RID_PDF_TAB_LINKS );
269     RemoveTabPage( RID_PDF_TAB_SECURITY );
270 }
271 
272 // -----------------------------------------------------------------------------
273 void ImpPDFTabDialog::PageCreated( sal_uInt16 _nId,
274                                    SfxTabPage& _rPage )
275 {
276     switch( _nId )
277     {
278     case RID_PDF_TAB_GENER:
279         ( ( ImpPDFTabGeneralPage* )&_rPage )->SetFilterConfigItem( this );
280         break;
281     case RID_PDF_TAB_VPREFER:
282         ( ( ImpPDFTabViewerPage* )&_rPage )->SetFilterConfigItem( this );
283         break;
284     case RID_PDF_TAB_OPNFTR:
285         ( ( ImpPDFTabOpnFtrPage* )&_rPage )->SetFilterConfigItem( this );
286         break;
287     case RID_PDF_TAB_LINKS:
288         ( ( ImpPDFTabLinksPage* )&_rPage )->SetFilterConfigItem( this );
289         break;
290     case RID_PDF_TAB_SECURITY:
291         ( ( ImpPDFTabSecurityPage* )&_rPage )->SetFilterConfigItem( this );
292         break;
293     }
294 }
295 
296 // -----------------------------------------------------------------------------
297 short ImpPDFTabDialog::Ok( )
298 {
299 //here the whole mechanism of the base class is not used
300 //when Ok is hit, the user means 'convert to PDF', so simply close with ok
301     return RET_OK;
302 }
303 
304 // -----------------------------------------------------------------------------
305 Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
306 {
307 // updating the FilterData sequence and storing FilterData to configuration
308     if( GetTabPage( RID_PDF_TAB_GENER ) )
309         ( ( ImpPDFTabGeneralPage* )GetTabPage( RID_PDF_TAB_GENER ) )->GetFilterConfigItem( this );
310     if( GetTabPage( RID_PDF_TAB_VPREFER ) )
311         ( ( ImpPDFTabViewerPage* )GetTabPage( RID_PDF_TAB_VPREFER ) )->GetFilterConfigItem( this );
312     if( GetTabPage( RID_PDF_TAB_OPNFTR ) )
313         ( ( ImpPDFTabOpnFtrPage* )GetTabPage( RID_PDF_TAB_OPNFTR ) )->GetFilterConfigItem( this );
314     if( GetTabPage( RID_PDF_TAB_LINKS ) )
315         ( ( ImpPDFTabLinksPage* )GetTabPage( RID_PDF_TAB_LINKS ) )->GetFilterConfigItem( this );
316     if( GetTabPage( RID_PDF_TAB_SECURITY ) )
317         ( ( ImpPDFTabSecurityPage* )GetTabPage( RID_PDF_TAB_SECURITY ) )->GetFilterConfigItem( this );
318 
319 //prepare the items to be returned
320     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseLosslessCompression" ) ), mbUseLosslessCompression );
321     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Quality" ) ), mnQuality );
322     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ReduceImageResolution" ) ), mbReduceImageResolution );
323     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxImageResolution" ) ), mnMaxImageResolution );
324 
325     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseTaggedPDF" ) ), mbUseTaggedPDF );
326     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectPdfVersion" ) ), mnPDFTypeSelection );
327 
328     if ( mbIsPresentation )
329         maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotesPages" ) ), mbExportNotesPages );
330 	maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotes" ) ), mbExportNotes );
331 
332     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportBookmarks" ) ), mbExportBookmarks );
333     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseTransitionEffects" ) ), mbUseTransitionEffects );
334     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ), mbIsSkipEmptyPages );
335     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "IsAddStream" ) ), mbAddStream );
336     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "EmbedStandardFonts" ) ), mbEmbedStandardFonts );
337 
338     /*
339     * FIXME: the entries are only implicitly defined by the resource file. Should there
340     * ever be an additional form submit format this could get invalid.
341     */
342     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "FormsType" ) ), mnFormsType );
343     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportFormFields" ) ), mbExportFormFields );
344     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowDuplicateFieldNames" ) ), mbAllowDuplicateFieldNames );
345 
346     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerToolbar" ) ), mbHideViewerToolbar );
347     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerMenubar" ) ), mbHideViewerMenubar );
348     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "HideViewerWindowControls" ) ), mbHideViewerWindowControls );
349     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ResizeWindowToInitialPage" ) ), mbResizeWinToInit );
350     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "CenterWindow" ) ), mbCenterWindow );
351     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenInFullScreenMode" ) ), mbOpenInFullScreenMode );
352     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "DisplayPDFDocumentTitle" ) ), mbDisplayPDFDocumentTitle );
353     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "InitialView" ) ), mnInitialView );
354     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Magnification" ) ), mnMagnification);
355     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) ), mnZoom );
356     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "InitialPage" ) ), mnInitialPage );
357     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "PageLayout" ) ), mnPageLayout );
358     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "FirstPageOnLeft" ) ), mbFirstPageLeft );
359     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenBookmarkLevels" ) ), mnOpenBookmarkLevels );
360 
361     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportLinksRelativeFsys" ) ), mbExportRelativeFsysLinks );
362 	maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "PDFViewSelection" ) ), mnViewPDFMode );
363 	maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ConvertOOoTargetToPDFTarget" ) ), mbConvertOOoTargets );
364 	maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportBookmarksToPDFDestination" ) ), mbExportBmkToPDFDestination );
365 
366     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Printing" ) ), mnPrint );
367     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Changes" ) ), mnChangesAllowed );
368     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableCopyingOfContent" ) ), mbCanCopyOrExtract );
369     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableTextAccessForAccessibilityTools" ) ), mbCanExtractForAccessibility );
370 
371     Sequence< PropertyValue > aRet( maConfigItem.GetFilterData() );
372 
373 	int nElementAdded = 5;
374 
375     aRet.realloc( aRet.getLength() + nElementAdded );
376 
377 // add the encryption enable flag
378 	aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EncryptFile" ) );
379 	aRet[ aRet.getLength() - nElementAdded ].Value <<= mbEncrypt;
380 	nElementAdded--;
381 
382 // add the open password
383 	aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PreparedPasswords" ) );
384 	aRet[ aRet.getLength() - nElementAdded ].Value <<= mxPreparedPasswords;
385 	nElementAdded--;
386 
387 //the restrict permission flag (needed to have the scripting consistent with the dialog)
388 	aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "RestrictPermissions" ) );
389 	aRet[ aRet.getLength() - nElementAdded ].Value <<= mbRestrictPermissions;
390 	nElementAdded--;
391 
392 //add the permission password
393 	aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PreparedPermissionPassword" ) );
394 	aRet[ aRet.getLength() - nElementAdded ].Value <<= maPreparedOwnerPassword;
395 	nElementAdded--;
396 
397 // this should be the last added...
398     if( mbIsRangeChecked )
399     {
400         aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) );
401         aRet[ aRet.getLength() - nElementAdded ].Value <<= OUString( msPageRange );
402     }
403     else if( mbSelectionIsChecked )
404     {
405         aRet[ aRet.getLength() - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Selection" ) );
406         aRet[ aRet.getLength() - nElementAdded ].Value <<= maSelection;
407     }
408 
409     return aRet;
410 }
411 
412 // -----------------------------------------------------------------------------
413 ImpPDFTabGeneralPage::ImpPDFTabGeneralPage( Window* pParent,
414                                             const SfxItemSet& rCoreSet
415                                             ) :
416     SfxTabPage( pParent, PDFFilterResId( RID_PDF_TAB_GENER ), rCoreSet ),
417 
418     maFlPages( this, PDFFilterResId( FL_PAGES ) ),
419     maRbAll( this, PDFFilterResId( RB_ALL ) ),
420     maRbRange( this, PDFFilterResId( RB_RANGE ) ),
421     maRbSelection( this, PDFFilterResId( RB_SELECTION ) ),
422     maEdPages( this, PDFFilterResId( ED_PAGES ) ),
423 
424     maFlCompression( this, PDFFilterResId( FL_IMAGES ) ),
425     maRbLosslessCompression( this, PDFFilterResId( RB_LOSSLESSCOMPRESSION ) ),
426     maRbJPEGCompression( this, PDFFilterResId( RB_JPEGCOMPRESSION ) ),
427     maFtQuality( this, PDFFilterResId( FT_QUALITY ) ),
428     maNfQuality( this, PDFFilterResId( NF_QUALITY ) ),
429     maCbReduceImageResolution( this, PDFFilterResId( CB_REDUCEIMAGERESOLUTION ) ),
430     maCoReduceImageResolution( this, PDFFilterResId( CO_REDUCEIMAGERESOLUTION ) ),
431 
432     maFlGeneral( this, PDFFilterResId( FL_GENERAL ) ),
433     maCbPDFA1b( this, PDFFilterResId( CB_PDFA_1B_SELECT ) ),
434 
435     maCbTaggedPDF( this, PDFFilterResId( CB_TAGGEDPDF ) ),
436     mbTaggedPDFUserSelection( sal_False ),
437 
438     maCbExportFormFields( this, PDFFilterResId( CB_EXPORTFORMFIELDS ) ),
439     mbExportFormFieldsUserSelection( sal_False ),
440     mbEmbedStandardFontsUserSelection( sal_False ),
441     maFtFormsFormat( this, PDFFilterResId( FT_FORMSFORMAT ) ),
442     maLbFormsFormat( this, PDFFilterResId( LB_FORMSFORMAT ) ),
443     maCbAllowDuplicateFieldNames( this, PDFFilterResId( CB_ALLOWDUPLICATEFIELDNAMES ) ),
444 
445     maCbExportBookmarks( this, PDFFilterResId( CB_EXPORTBOOKMARKS ) ),
446     maCbExportNotes( this, PDFFilterResId( CB_EXPORTNOTES ) ),
447     maCbExportNotesPages( this, PDFFilterResId( CB_EXPORTNOTESPAGES ) ),
448     maCbExportEmptyPages( this, PDFFilterResId( CB_EXPORTEMPTYPAGES ) ),
449     maCbAddStream( this, PDFFilterResId( CB_ADDSTREAM ) ),
450     maCbEmbedStandardFonts( this, PDFFilterResId( CB_EMBEDSTANDARDFONTS ) ),
451     mbIsPresentation( sal_False ),
452 	mbIsWriter( sal_False),
453     mpaParent( 0 )
454 {
455     FreeResource();
456 
457     // pb: #i91991# maCbExportEmptyPages double-spaced if necessary
458     Size aSize = maCbExportEmptyPages.GetSizePixel();
459     Size aMinSize = maCbExportEmptyPages.CalcMinimumSize();
460     if ( aSize.Width() > aMinSize.Width() )
461     {
462         Size aNewSize = maCbExportNotes.GetSizePixel();
463         long nDelta = aSize.Height() - aNewSize.Height();
464         maCbExportEmptyPages.SetSizePixel( aNewSize );
465         Point aNewPos = maCbAddStream.GetPosPixel();
466         aNewPos.Y() -= nDelta;
467         maCbAddStream.SetPosPixel( aNewPos );
468         aNewPos = maCbEmbedStandardFonts.GetPosPixel();
469         aNewPos.Y() -= nDelta;
470         maCbEmbedStandardFonts.SetPosPixel( aNewPos );
471     }
472 
473 	maEdPages.SetAccessibleName(maRbRange.GetText());
474 	maEdPages.SetAccessibleRelationLabeledBy(&maRbRange);
475 
476     maCbExportEmptyPages.SetStyle( maCbExportEmptyPages.GetStyle() | WB_VCENTER );
477 }
478 
479 // -----------------------------------------------------------------------------
480 ImpPDFTabGeneralPage::~ImpPDFTabGeneralPage()
481 {
482 }
483 
484 // -----------------------------------------------------------------------------
485 void ImpPDFTabGeneralPage::SetFilterConfigItem( const ImpPDFTabDialog* paParent )
486 {
487     mpaParent = paParent;
488 
489 //init this class data
490     maRbRange.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, TogglePagesHdl ) );
491 
492     maRbAll.Check();
493     TogglePagesHdl( NULL );
494 
495     maNfQuality.SetUnit( FUNIT_PERCENT );
496     maNfQuality.SetMin( 1, FUNIT_PERCENT );
497     maNfQuality.SetMax( 100, FUNIT_PERCENT );
498 
499     maRbSelection.Enable( paParent->mbSelectionPresent );
500     mbIsPresentation = paParent->mbIsPresentation;
501     mbIsWriter = paParent->mbIsWriter;
502 
503     maCbExportEmptyPages.Enable( mbIsWriter );
504 
505     maRbLosslessCompression.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleCompressionHdl ) );
506     const sal_Bool bUseLosslessCompression = paParent->mbUseLosslessCompression;
507     if ( bUseLosslessCompression )
508         maRbLosslessCompression.Check();
509 	else
510         maRbJPEGCompression.Check();
511 
512     maNfQuality.SetValue( paParent->mnQuality, FUNIT_PERCENT );
513     maNfQuality.Enable( bUseLosslessCompression == sal_False );
514 
515     maCbReduceImageResolution.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleReduceImageResolutionHdl ) );
516     const sal_Bool	bReduceImageResolution = paParent->mbReduceImageResolution;
517     maCbReduceImageResolution.Check( bReduceImageResolution );
518     String aStrRes( String::CreateFromInt32( paParent->mnMaxImageResolution ) );
519     aStrRes.Append( String( RTL_CONSTASCII_USTRINGPARAM( " DPI" ) ) );
520     maCoReduceImageResolution.SetText( aStrRes );
521     maCoReduceImageResolution.Enable( bReduceImageResolution );
522 
523     maCbPDFA1b.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleExportPDFAHdl) );
524     switch( paParent->mnPDFTypeSelection )
525     {
526     default:
527     case 0: maCbPDFA1b.Check( sal_False ); // PDF 1.4
528         break;
529     case 1: maCbPDFA1b.Check(); // PDF/A-1a
530         break;
531     }
532     ToggleExportPDFAHdl( NULL );
533 
534     maCbExportFormFields.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleExportFormFieldsHdl ) );
535 
536 // get the form values, for use with PDF/A-1 selection interface
537     mbTaggedPDFUserSelection = paParent->mbUseTaggedPDF;
538     mbExportFormFieldsUserSelection = paParent->mbExportFormFields;
539     mbEmbedStandardFontsUserSelection = paParent->mbEmbedStandardFonts;
540 
541     if( !maCbPDFA1b.IsChecked() )
542     {// the value for PDF/A set by the ToggleExportPDFAHdl method called before
543         maCbTaggedPDF.Check( mbTaggedPDFUserSelection  );
544         maCbExportFormFields.Check( mbExportFormFieldsUserSelection );
545         maCbEmbedStandardFonts.Check( mbEmbedStandardFontsUserSelection );
546     }
547 
548     maLbFormsFormat.SelectEntryPos( (sal_uInt16)paParent->mnFormsType );
549     maLbFormsFormat.Enable( paParent->mbExportFormFields );
550     maCbAllowDuplicateFieldNames.Check( paParent->mbAllowDuplicateFieldNames );
551     maCbAllowDuplicateFieldNames.Enable( paParent->mbExportFormFields );
552 
553 	maCbExportBookmarks.Check( paParent->mbExportBookmarks );
554 
555 	maCbExportNotes.Check( paParent->mbExportNotes );
556 
557 	if ( mbIsPresentation )
558 	{
559 		maCbExportNotesPages.Show( sal_True );
560         maCbExportNotesPages.Check( paParent->mbExportNotesPages );
561 	}
562 	else
563 	{
564 	    long nCheckBoxHeight =
565 		    maCbExportNotesPages.LogicToPixel( Size( 13, 13 ), MAP_APPFONT ).Height();
566 
567 		Point aPos = maCbExportEmptyPages.GetPosPixel();
568 		maCbExportEmptyPages.SetPosPixel( Point( aPos.X(), aPos.Y() - nCheckBoxHeight ) );
569 		aPos = maCbAddStream.GetPosPixel();
570 		maCbAddStream.SetPosPixel( Point( aPos.X(), aPos.Y() - nCheckBoxHeight ) );
571 		aPos = maCbEmbedStandardFonts.GetPosPixel();
572 		maCbEmbedStandardFonts.SetPosPixel( Point( aPos.X(), aPos.Y() - nCheckBoxHeight ) );
573 		maCbExportNotesPages.Show( sal_False );
574 		maCbExportNotesPages.Check( sal_False );
575 	}
576 
577     maCbExportEmptyPages.Check( !paParent->mbIsSkipEmptyPages );
578 
579     Reference< XMultiServiceFactory > xFactory = paParent->getServiceFactory();
580     Reference< XInterface > xIfc;
581     if( xFactory.is() )
582     {
583         xIfc = xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.documents.PDFDetector" ) ) );
584     }
585     if( xIfc.is() )
586     {
587         maCbAddStream.Show( sal_True );
588         maCbAddStream.Check( paParent->mbAddStream );
589     }
590     else
591     {
592         maCbAddStream.Show( sal_False );
593         maCbAddStream.Check( sal_False );
594     }
595     maCbAddStream.SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleAddStreamHdl ) );
596     // init addstream dependencies
597     ToggleAddStreamHdl( NULL );
598 }
599 
600 // -----------------------------------------------------------------------------
601 void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* paParent )
602 {
603 // updating the FilterData sequence and storing FilterData to configuration
604     paParent->mbUseLosslessCompression = maRbLosslessCompression.IsChecked();
605     paParent->mnQuality = static_cast<sal_Int32>(maNfQuality.GetValue());
606     paParent->mbReduceImageResolution = maCbReduceImageResolution.IsChecked();
607     paParent->mnMaxImageResolution = maCoReduceImageResolution.GetText().ToInt32();
608     paParent->mbExportNotes = maCbExportNotes.IsChecked();
609 	if ( mbIsPresentation )
610 		paParent->mbExportNotesPages = maCbExportNotesPages.IsChecked();
611     paParent->mbExportBookmarks = maCbExportBookmarks.IsChecked();
612 
613     paParent->mbIsSkipEmptyPages =  !maCbExportEmptyPages.IsChecked();
614     paParent->mbAddStream = maCbAddStream.IsVisible() && maCbAddStream.IsChecked();
615 
616     paParent->mbIsRangeChecked = sal_False;
617     if( maRbRange.IsChecked() )
618     {
619         paParent->mbIsRangeChecked = sal_True;
620         paParent->msPageRange = String( maEdPages.GetText() ); //FIXME all right on other languages ?
621     }
622     else if( maRbSelection.IsChecked() )
623     {
624         paParent->mbSelectionIsChecked = maRbSelection.IsChecked();
625     }
626 
627     paParent->mnPDFTypeSelection = 0;
628     if( maCbPDFA1b.IsChecked() )
629     {
630         paParent->mnPDFTypeSelection = 1;
631         paParent->mbUseTaggedPDF =  mbTaggedPDFUserSelection;
632         paParent->mbExportFormFields = mbExportFormFieldsUserSelection;
633         paParent->mbEmbedStandardFonts = mbEmbedStandardFontsUserSelection;
634     }
635     else
636     {
637         paParent->mbUseTaggedPDF =  maCbTaggedPDF.IsChecked();
638         paParent->mbExportFormFields = maCbExportFormFields.IsChecked();
639         paParent->mbEmbedStandardFonts = maCbEmbedStandardFonts.IsChecked();
640     }
641 
642     /*
643     * FIXME: the entries are only implicitly defined by the resource file. Should there
644     * ever be an additional form submit format this could get invalid.
645     */
646     paParent->mnFormsType = (sal_Int32) maLbFormsFormat.GetSelectEntryPos();
647     paParent->mbAllowDuplicateFieldNames = maCbAllowDuplicateFieldNames.IsChecked();
648 }
649 
650 // -----------------------------------------------------------------------------
651 SfxTabPage*  ImpPDFTabGeneralPage::Create( Window* pParent,
652                                            const SfxItemSet& rAttrSet)
653 {
654 	return ( new  ImpPDFTabGeneralPage( pParent, rAttrSet ) );
655 }
656 
657 // -----------------------------------------------------------------------------
658 IMPL_LINK( ImpPDFTabGeneralPage, TogglePagesHdl, void*, EMPTYARG )
659 {
660     maEdPages.Enable( maRbRange.IsChecked() );
661     //Sym2_5805, When the control is disabled, it is also readonly. So here, it is not necessary to set it as readonly.
662     //maEdPages.SetReadOnly( !maRbRange.IsChecked() );
663     return 0;
664 }
665 
666 // -----------------------------------------------------------------------------
667 IMPL_LINK( ImpPDFTabGeneralPage, ToggleExportFormFieldsHdl, void*, EMPTYARG )
668 {
669     maLbFormsFormat.Enable( maCbExportFormFields.IsChecked() );
670     maCbAllowDuplicateFieldNames.Enable( maCbExportFormFields.IsChecked() );
671     return 0;
672 }
673 
674 // -----------------------------------------------------------------------------
675 IMPL_LINK( ImpPDFTabGeneralPage, ToggleCompressionHdl, void*, EMPTYARG )
676 {
677     maNfQuality.Enable( maRbJPEGCompression.IsChecked() );
678     return 0;
679 }
680 
681 // -----------------------------------------------------------------------------
682 IMPL_LINK( ImpPDFTabGeneralPage, ToggleReduceImageResolutionHdl, void*, EMPTYARG )
683 {
684     maCoReduceImageResolution.Enable( maCbReduceImageResolution.IsChecked() );
685     return 0;
686 }
687 
688 // -----------------------------------------------------------------------------
689 IMPL_LINK( ImpPDFTabGeneralPage, ToggleAddStreamHdl, void*, EMPTYARG )
690 {
691     if( maCbAddStream.IsVisible() )
692     {
693         if( maCbAddStream.IsChecked() )
694         {
695             maRbAll.Check();
696             maRbRange.Enable( sal_False );
697             maRbSelection.Enable( sal_False );
698             maEdPages.Enable( sal_False );
699 	    	//Sym2_5805, When the control is disabled, it is also readonly. So here, it is not necessary to set it as readonly.
700             //maEdPages.SetReadOnly( sal_True );
701             maRbAll.Enable( sal_False );
702         }
703         else
704         {
705             maRbAll.Enable( sal_True );
706             maRbRange.Enable( sal_True );
707             maRbSelection.Enable( sal_True );
708         }
709     }
710     return 0;
711 }
712 
713 // -----------------------------------------------------------------------------
714 IMPL_LINK( ImpPDFTabGeneralPage, ToggleExportPDFAHdl, void*, EMPTYARG )
715 {
716     ImpPDFTabSecurityPage* pSecPage = NULL;
717 //set the security page status (and its controls as well)
718     if( mpaParent && mpaParent->GetTabPage( RID_PDF_TAB_SECURITY ) )
719     {
720         pSecPage = static_cast<ImpPDFTabSecurityPage*>(mpaParent->GetTabPage( RID_PDF_TAB_SECURITY ));
721         pSecPage->ImplPDFASecurityControl( !maCbPDFA1b.IsChecked() );
722     }
723 
724 //PDF/A-1 needs tagged PDF, so  force disable the control, will be forced in pdfexport.
725     sal_Bool bPDFA1Sel = maCbPDFA1b.IsChecked();
726     maFtFormsFormat.Enable( !bPDFA1Sel );
727     maLbFormsFormat.Enable( !bPDFA1Sel );
728     maCbAllowDuplicateFieldNames.Enable( !bPDFA1Sel );
729     if(bPDFA1Sel)
730     {
731 //store the values of subordinate controls
732         mbTaggedPDFUserSelection = maCbTaggedPDF.IsChecked();
733         maCbTaggedPDF.Check();
734         maCbTaggedPDF.Enable( sal_False );
735         mbExportFormFieldsUserSelection = maCbExportFormFields.IsChecked();
736         maCbExportFormFields.Check( sal_False );
737         maCbExportFormFields.Enable( sal_False );
738         mbEmbedStandardFontsUserSelection = maCbEmbedStandardFonts.IsChecked();
739         maCbEmbedStandardFonts.Check( sal_True );
740         maCbEmbedStandardFonts.Enable( sal_False );
741     }
742     else
743     {
744 //retrieve the values of subordinate controls
745         maCbTaggedPDF.Enable();
746         maCbTaggedPDF.Check( mbTaggedPDFUserSelection );
747         maCbExportFormFields.Check( mbExportFormFieldsUserSelection );
748         maCbExportFormFields.Enable();
749         maCbEmbedStandardFonts.Check( mbEmbedStandardFontsUserSelection );
750         maCbEmbedStandardFonts.Enable();
751     }
752 // PDF/A-1 doesn't allow launch action, so enable/disable the selection on
753 // Link page
754     if( mpaParent && mpaParent->GetTabPage( RID_PDF_TAB_LINKS ) )
755         ( ( ImpPDFTabLinksPage* )mpaParent->GetTabPage( RID_PDF_TAB_LINKS ) )->ImplPDFALinkControl( !maCbPDFA1b.IsChecked() );
756 
757     // if a password was set, inform the user that this will not be used in PDF/A case
758     if( maCbPDFA1b.IsChecked() && pSecPage && pSecPage->hasPassword() )
759     {
760         WarningBox aBox( this, PDFFilterResId( RID_PDF_WARNPDFAPASSWORD ) );
761         aBox.Execute();
762     }
763 
764     return 0;
765 }
766 
767 /////////////////////////////////////////////////////////////////
768 // the option features tab page
769 // -----------------------------------------------------------------------------
770 ImpPDFTabOpnFtrPage::ImpPDFTabOpnFtrPage( Window* pParent,
771                                           const SfxItemSet& rCoreSet ) :
772     SfxTabPage( pParent, PDFFilterResId( RID_PDF_TAB_OPNFTR ), rCoreSet ),
773 
774     maFlInitialView( this, PDFFilterResId( FL_INITVIEW ) ),
775     maRbOpnPageOnly( this, PDFFilterResId( RB_OPNMODE_PAGEONLY ) ),
776     maRbOpnOutline( this, PDFFilterResId( RB_OPNMODE_OUTLINE ) ),
777     maRbOpnThumbs( this, PDFFilterResId( RB_OPNMODE_THUMBS ) ),
778     maFtInitialPage( this, PDFFilterResId( FT_MAGNF_INITIAL_PAGE ) ),
779     maNumInitialPage( this, PDFFilterResId( NUM_MAGNF_INITIAL_PAGE ) ),
780 
781     maFlMagnification( this, PDFFilterResId( FL_MAGNIFICATION ) ),
782     maRbMagnDefault( this, PDFFilterResId( RB_MAGNF_DEFAULT ) ),
783     maRbMagnFitWin( this, PDFFilterResId( RB_MAGNF_WIND ) ),
784     maRbMagnFitWidth( this, PDFFilterResId( RB_MAGNF_WIDTH ) ),
785     maRbMagnFitVisible( this, PDFFilterResId( RB_MAGNF_VISIBLE ) ),
786     maRbMagnZoom( this, PDFFilterResId( RB_MAGNF_ZOOM ) ),
787     maNumZoom( this, PDFFilterResId( NUM_MAGNF_ZOOM ) ),
788 
789     maFlPageLayout( this, PDFFilterResId( FL_PAGE_LAYOUT ) ),
790     maRbPgLyDefault( this, PDFFilterResId( RB_PGLY_DEFAULT ) ),
791     maRbPgLySinglePage( this, PDFFilterResId( RB_PGLY_SINGPG ) ),
792     maRbPgLyContinue( this, PDFFilterResId( RB_PGLY_CONT ) ),
793     maRbPgLyContinueFacing( this, PDFFilterResId( RB_PGLY_CONTFAC ) ),
794     maCbPgLyFirstOnLeft( this, PDFFilterResId( CB_PGLY_FIRSTLEFT ) ),
795     mbUseCTLFont( sal_False )
796 {
797     FreeResource();
798 
799     maRbMagnDefault.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
800     maRbMagnFitWin.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
801     maRbMagnFitWidth.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
802     maRbMagnFitVisible.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
803     maRbMagnZoom.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
804 	maNumZoom.SetAccessibleName(maRbMagnZoom.GetText());
805 	maNumZoom.SetAccessibleRelationLabeledBy(&maRbMagnZoom);
806 }
807 
808 // -----------------------------------------------------------------------------
809 ImpPDFTabOpnFtrPage::~ImpPDFTabOpnFtrPage()
810 {
811 }
812 
813 // -----------------------------------------------------------------------------
814 SfxTabPage*  ImpPDFTabOpnFtrPage::Create( Window* pParent,
815                                           const SfxItemSet& rAttrSet)
816 {
817     return ( new  ImpPDFTabOpnFtrPage( pParent, rAttrSet ) );
818 }
819 
820 // -----------------------------------------------------------------------------
821 void ImpPDFTabOpnFtrPage::GetFilterConfigItem( ImpPDFTabDialog* paParent  )
822 {
823     paParent->mnInitialView = 0;
824     if( maRbOpnOutline.IsChecked() )
825         paParent->mnInitialView = 1;
826     else if( maRbOpnThumbs.IsChecked() )
827         paParent->mnInitialView = 2;
828 
829     paParent->mnMagnification = 0;
830     if( maRbMagnFitWin.IsChecked() )
831         paParent->mnMagnification = 1;
832     else if( maRbMagnFitWidth.IsChecked() )
833         paParent->mnMagnification = 2;
834     else if( maRbMagnFitVisible.IsChecked() )
835         paParent->mnMagnification = 3;
836     else if( maRbMagnZoom.IsChecked() )
837     {
838         paParent->mnMagnification = 4;
839         paParent->mnZoom = static_cast<sal_Int32>(maNumZoom.GetValue());
840     }
841 
842     paParent->mnInitialPage = static_cast<sal_Int32>(maNumInitialPage.GetValue());
843 
844     paParent->mnPageLayout = 0;
845     if( maRbPgLySinglePage.IsChecked() )
846         paParent->mnPageLayout = 1;
847     else if( maRbPgLyContinue.IsChecked() )
848         paParent->mnPageLayout = 2;
849     else if( maRbPgLyContinueFacing.IsChecked() )
850         paParent->mnPageLayout = 3;
851 
852     paParent->mbFirstPageLeft = ( mbUseCTLFont ) ? maCbPgLyFirstOnLeft.IsChecked() : sal_False;
853 }
854 
855 // -----------------------------------------------------------------------------
856 void ImpPDFTabOpnFtrPage::SetFilterConfigItem( const  ImpPDFTabDialog* paParent )
857 {
858     mbUseCTLFont = paParent->mbUseCTLFont;
859     switch( paParent->mnPageLayout )
860     {
861     default:
862     case 0:
863         maRbPgLyDefault.Check();
864         break;
865     case 1:
866         maRbPgLySinglePage.Check();
867         break;
868     case 2:
869         maRbPgLyContinue.Check();
870         break;
871     case 3:
872         maRbPgLyContinueFacing.Check();
873         break;
874     };
875 
876     switch( paParent->mnInitialView )
877     {
878     default:
879     case 0:
880         maRbOpnPageOnly.Check();
881         break;
882     case 1:
883         maRbOpnOutline.Check();
884         break;
885     case 2:
886         maRbOpnThumbs.Check();
887         break;
888     };
889 
890     switch( paParent->mnMagnification )
891     {
892     default:
893     case 0:
894         maRbMagnDefault.Check();
895         maNumZoom.Enable( sal_False );
896         break;
897     case 1:
898         maRbMagnFitWin.Check();
899         maNumZoom.Enable( sal_False );
900         break;
901     case 2:
902         maRbMagnFitWidth.Check();
903         maNumZoom.Enable( sal_False );
904         break;
905     case 3:
906         maRbMagnFitVisible.Check();
907         maNumZoom.Enable( sal_False );
908         break;
909     case 4:
910         maRbMagnZoom.Check();
911         maNumZoom.Enable( sal_True );
912         break;
913     };
914 
915     maNumZoom.SetValue( paParent->mnZoom );
916     maNumInitialPage.SetValue( paParent->mnInitialPage );
917 
918     if( !mbUseCTLFont )
919         maCbPgLyFirstOnLeft.Hide( );
920     else
921     {
922         maRbPgLyContinueFacing.SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbPgLyContinueFacingHdl ) );
923         maCbPgLyFirstOnLeft.Check( paParent->mbFirstPageLeft );
924         ToggleRbPgLyContinueFacingHdl( NULL );
925     }
926 }
927 
928 IMPL_LINK( ImpPDFTabOpnFtrPage, ToggleRbPgLyContinueFacingHdl, void*, EMPTYARG )
929 {
930     maCbPgLyFirstOnLeft.Enable( maRbPgLyContinueFacing.IsChecked() );
931     return 0;
932 }
933 
934 IMPL_LINK( ImpPDFTabOpnFtrPage, ToggleRbMagnHdl, void*, )
935 {
936     maNumZoom.Enable( maRbMagnZoom.IsChecked() );
937     return 0;
938 }
939 
940 ////////////////////////////////////////////////////////
941 // The Viewer preferences tab page
942 // -----------------------------------------------------------------------------
943 ImpPDFTabViewerPage::ImpPDFTabViewerPage( Window* pParent,
944                                           const SfxItemSet& rCoreSet ) :
945     SfxTabPage( pParent, PDFFilterResId( RID_PDF_TAB_VPREFER ), rCoreSet ),
946 
947     maFlWindowOptions( this, PDFFilterResId( FL_WINOPT ) ),
948     maCbResWinInit( this, PDFFilterResId( CB_WNDOPT_RESINIT ) ),
949     maCbCenterWindow( this, PDFFilterResId( CB_WNDOPT_CNTRWIN ) ),
950     maCbOpenFullScreen( this, PDFFilterResId( CB_WNDOPT_OPNFULL ) ),
951     maCbDispDocTitle( this, PDFFilterResId( CB_DISPDOCTITLE ) ),
952 
953     maFlUIOptions( this, PDFFilterResId( FL_USRIFOPT ) ),
954     maCbHideViewerMenubar( this, PDFFilterResId( CB_UOP_HIDEVMENUBAR ) ),
955     maCbHideViewerToolbar( this, PDFFilterResId( CB_UOP_HIDEVTOOLBAR ) ),
956     maCbHideViewerWindowControls( this, PDFFilterResId( CB_UOP_HIDEVWINCTRL ) ),
957     maFlTransitions( this, PDFFilterResId( FL_TRANSITIONS ) ),
958     maCbTransitionEffects( this, PDFFilterResId( CB_TRANSITIONEFFECTS ) ),
959     mbIsPresentation( sal_True ),
960     maFlBookmarks( this, PDFFilterResId( FL_BOOKMARKS ) ),
961     maRbAllBookmarkLevels( this, PDFFilterResId( RB_ALLBOOKMARKLEVELS ) ),
962     maRbVisibleBookmarkLevels( this, PDFFilterResId( RB_VISIBLEBOOKMARKLEVELS ) ),
963     maNumBookmarkLevels( this, PDFFilterResId( NUM_BOOKMARKLEVELS ) )
964 {
965     FreeResource();
966     maRbAllBookmarkLevels.SetToggleHdl( LINK( this, ImpPDFTabViewerPage, ToggleRbBookmarksHdl ) );
967     maRbVisibleBookmarkLevels.SetToggleHdl( LINK( this, ImpPDFTabViewerPage, ToggleRbBookmarksHdl ) );
968     maNumBookmarkLevels.SetAccessibleName(maRbVisibleBookmarkLevels.GetText());
969     maNumBookmarkLevels.SetAccessibleRelationLabeledBy(&maRbVisibleBookmarkLevels);
970 }
971 
972 // -----------------------------------------------------------------------------
973 ImpPDFTabViewerPage::~ImpPDFTabViewerPage()
974 {
975 }
976 
977 // -----------------------------------------------------------------------------
978 IMPL_LINK( ImpPDFTabViewerPage, ToggleRbBookmarksHdl, void*, )
979 {
980     maNumBookmarkLevels.Enable( maRbVisibleBookmarkLevels.IsChecked() );
981     return 0;
982 }
983 // -----------------------------------------------------------------------------
984 SfxTabPage*  ImpPDFTabViewerPage::Create( Window* pParent,
985                                           const SfxItemSet& rAttrSet)
986 {
987     return ( new  ImpPDFTabViewerPage( pParent, rAttrSet ) );
988 }
989 
990 // -----------------------------------------------------------------------------
991 void ImpPDFTabViewerPage::GetFilterConfigItem( ImpPDFTabDialog* paParent  )
992 {
993     paParent->mbHideViewerMenubar = maCbHideViewerMenubar.IsChecked();
994     paParent->mbHideViewerToolbar = maCbHideViewerToolbar.IsChecked( );
995     paParent->mbHideViewerWindowControls = maCbHideViewerWindowControls.IsChecked();
996     paParent->mbResizeWinToInit = maCbResWinInit.IsChecked();
997     paParent->mbOpenInFullScreenMode = maCbOpenFullScreen.IsChecked();
998     paParent->mbCenterWindow = maCbCenterWindow.IsChecked();
999     paParent->mbDisplayPDFDocumentTitle = maCbDispDocTitle.IsChecked();
1000     paParent->mbUseTransitionEffects = maCbTransitionEffects.IsChecked();
1001     paParent->mnOpenBookmarkLevels = maRbAllBookmarkLevels.IsChecked() ?
1002                                      -1 : static_cast<sal_Int32>(maNumBookmarkLevels.GetValue());
1003 }
1004 
1005 // -----------------------------------------------------------------------------
1006 void ImpPDFTabViewerPage::SetFilterConfigItem( const  ImpPDFTabDialog* paParent )
1007 {
1008     maCbHideViewerMenubar.Check( paParent->mbHideViewerMenubar );
1009     maCbHideViewerToolbar.Check( paParent->mbHideViewerToolbar );
1010     maCbHideViewerWindowControls.Check( paParent->mbHideViewerWindowControls );
1011 
1012     maCbResWinInit.Check( paParent->mbResizeWinToInit );
1013     maCbOpenFullScreen.Check( paParent->mbOpenInFullScreenMode );
1014     maCbCenterWindow.Check( paParent->mbCenterWindow );
1015     maCbDispDocTitle.Check( paParent->mbDisplayPDFDocumentTitle );
1016     mbIsPresentation = paParent->mbIsPresentation;
1017     maCbTransitionEffects.Check( paParent->mbUseTransitionEffects );
1018     maCbTransitionEffects.Enable( mbIsPresentation );
1019     if( paParent->mnOpenBookmarkLevels < 0 )
1020     {
1021         maRbAllBookmarkLevels.Check( sal_True );
1022         maNumBookmarkLevels.Enable( sal_False );
1023     }
1024     else
1025     {
1026         maRbVisibleBookmarkLevels.Check( sal_True );
1027         maNumBookmarkLevels.Enable( sal_True );
1028         maNumBookmarkLevels.SetValue( paParent->mnOpenBookmarkLevels );
1029     }
1030 }
1031 
1032 ////////////////////////////////////////////////////////
1033 // The Security preferences tab page
1034 // -----------------------------------------------------------------------------
1035 ImpPDFTabSecurityPage::ImpPDFTabSecurityPage( Window* i_pParent,
1036 											  const SfxItemSet& i_rCoreSet ) :
1037 	SfxTabPage( i_pParent, PDFFilterResId( RID_PDF_TAB_SECURITY ), i_rCoreSet ),
1038 	maFlGroup( this, PDFFilterResId( FL_PWD_GROUP ) ),
1039 	maPbSetPwd( this, PDFFilterResId( BTN_SET_PWD ) ),
1040 	maFtUserPwd( this, PDFFilterResId( FT_USER_PWD ) ),
1041     maUserPwdSet( PDFFilterResId( STR_USER_PWD_SET ) ),
1042     maUserPwdUnset( PDFFilterResId( STR_USER_PWD_UNSET ) ),
1043     maUserPwdPdfa( PDFFilterResId( STR_USER_PWD_PDFA ) ),
1044 
1045     maStrSetPwd( PDFFilterResId( STR_SET_PWD ) ),
1046 	maFtOwnerPwd( this, PDFFilterResId( FT_OWNER_PWD ) ),
1047     maOwnerPwdSet( PDFFilterResId( STR_OWNER_PWD_SET ) ),
1048     maOwnerPwdUnset( PDFFilterResId( STR_OWNER_PWD_UNSET ) ),
1049     maOwnerPwdPdfa( PDFFilterResId( STR_OWNER_PWD_PDFA ) ),
1050 
1051 	maFlPrintPermissions( this, PDFFilterResId( FL_PRINT_PERMISSIONS ) ),
1052 	maRbPrintNone( this, PDFFilterResId( RB_PRINT_NONE ) ),
1053 	maRbPrintLowRes( this, PDFFilterResId( RB_PRINT_LOWRES ) ),
1054 	maRbPrintHighRes( this, PDFFilterResId( RB_PRINT_HIGHRES ) ),
1055 
1056 	maFlChangesAllowed( this, PDFFilterResId( FL_CHANGES_ALLOWED ) ),
1057 	maRbChangesNone( this, PDFFilterResId( RB_CHANGES_NONE ) ),
1058 	maRbChangesInsDel( this, PDFFilterResId( RB_CHANGES_INSDEL ) ),
1059 	maRbChangesFillForm( this, PDFFilterResId( RB_CHANGES_FILLFORM ) ),
1060 	maRbChangesComment( this, PDFFilterResId( RB_CHANGES_COMMENT ) ),
1061 	maRbChangesAnyNoCopy( this, PDFFilterResId( RB_CHANGES_ANY_NOCOPY ) ),
1062 
1063 	maCbEnableCopy( this, PDFFilterResId( CB_ENDAB_COPY ) ),
1064 	maCbEnableAccessibility( this, PDFFilterResId( CB_ENAB_ACCESS ) ),
1065 
1066 	msUserPwdTitle( PDFFilterResId( STR_PDF_EXPORT_UDPWD ) ),
1067 	mbHaveOwnerPassword( false ),
1068 	mbHaveUserPassword( false ),
1069 
1070 	msOwnerPwdTitle( PDFFilterResId( STR_PDF_EXPORT_ODPWD ) )
1071 {
1072     maUserPwdSet.Append( sal_Unicode( '\n' ) );
1073     maUserPwdSet.Append( String( PDFFilterResId( STR_USER_PWD_ENC ) ) );
1074 
1075     maUserPwdUnset.Append( sal_Unicode( '\n' ) );
1076     maUserPwdUnset.Append( String( PDFFilterResId( STR_USER_PWD_UNENC ) ) );
1077 
1078     maOwnerPwdSet.Append( sal_Unicode( '\n' ) );
1079     maOwnerPwdSet.Append( String( PDFFilterResId( STR_OWNER_PWD_REST ) ) );
1080 
1081     maOwnerPwdUnset.Append( sal_Unicode( '\n' ) );
1082     maOwnerPwdUnset.Append( String( PDFFilterResId( STR_OWNER_PWD_UNREST ) ) );
1083 
1084 	FreeResource();
1085 
1086     maFtUserPwd.SetText( maUserPwdUnset );
1087     maFtOwnerPwd.SetText( maOwnerPwdUnset );
1088 
1089     // pb: #i91991# maRbChangesComment double-spaced if necessary
1090     Size aSize = maRbChangesComment.GetSizePixel();
1091     Size aMinSize = maRbChangesComment.CalcMinimumSize();
1092     if ( aSize.Width() > aMinSize.Width() )
1093     {
1094         Size aNewSize = maRbChangesFillForm.GetSizePixel();
1095         long nDelta = aSize.Height() - aNewSize.Height();
1096         maRbChangesComment.SetSizePixel( aNewSize );
1097         Window* pWins[] =
1098             { &maRbChangesAnyNoCopy, &maCbEnableCopy, &maCbEnableAccessibility, NULL };
1099         Window** pCurrent = pWins;
1100         while ( *pCurrent )
1101         {
1102             Point aNewPos = (*pCurrent)->GetPosPixel();
1103             aNewPos.Y() -= nDelta;
1104             (*pCurrent++)->SetPosPixel( aNewPos );
1105         }
1106     }
1107 
1108     maPbSetPwd.SetClickHdl( LINK( this, ImpPDFTabSecurityPage, ClickmaPbSetPwdHdl ) );
1109 }
1110 
1111 // -----------------------------------------------------------------------------
1112 ImpPDFTabSecurityPage::~ImpPDFTabSecurityPage()
1113 {
1114 }
1115 
1116 // -----------------------------------------------------------------------------
1117 SfxTabPage*  ImpPDFTabSecurityPage::Create( Window* pParent,
1118                                           const SfxItemSet& rAttrSet)
1119 {
1120 	return ( new  ImpPDFTabSecurityPage( pParent, rAttrSet ) );
1121 }
1122 
1123 // -----------------------------------------------------------------------------
1124 void ImpPDFTabSecurityPage::GetFilterConfigItem( ImpPDFTabDialog* paParent  )
1125 {
1126 // please note that in PDF/A-1a mode even if this are copied back,
1127 // the security settings are forced disabled in PDFExport::Export
1128 	paParent->mbEncrypt = mbHaveUserPassword;
1129 	paParent->mxPreparedPasswords = mxPreparedPasswords;
1130 
1131 	paParent->mbRestrictPermissions = mbHaveOwnerPassword;
1132 	paParent->maPreparedOwnerPassword = maPreparedOwnerPassword;
1133 
1134 //verify print status
1135 	paParent->mnPrint = 0;
1136 	if( maRbPrintLowRes.IsChecked() )
1137 		paParent->mnPrint = 1;
1138 	else if( maRbPrintHighRes.IsChecked() )
1139 		paParent->mnPrint = 2;
1140 
1141 //verify changes permitted
1142 	paParent->mnChangesAllowed = 0;
1143 
1144 	if( maRbChangesInsDel.IsChecked() )
1145 		paParent->mnChangesAllowed = 1;
1146 	else if( maRbChangesFillForm.IsChecked() )
1147 		paParent->mnChangesAllowed = 2;
1148 	else if( maRbChangesComment.IsChecked() )
1149 		paParent->mnChangesAllowed = 3;
1150 	else if( maRbChangesAnyNoCopy.IsChecked() )
1151 		paParent->mnChangesAllowed = 4;
1152 
1153 	paParent->mbCanCopyOrExtract = maCbEnableCopy.IsChecked();
1154 	paParent->mbCanExtractForAccessibility = maCbEnableAccessibility.IsChecked();
1155 }
1156 
1157 
1158 // -----------------------------------------------------------------------------
1159 void ImpPDFTabSecurityPage::SetFilterConfigItem( const  ImpPDFTabDialog* paParent )
1160 {
1161 	switch( paParent->mnPrint )
1162 	{
1163 	default:
1164 	case 0:
1165 		maRbPrintNone.Check();
1166 		break;
1167 	case 1:
1168 		maRbPrintLowRes.Check();
1169 		break;
1170 	case 2:
1171 		maRbPrintHighRes.Check();
1172 		break;
1173 	};
1174 
1175 	switch( paParent->mnChangesAllowed )
1176 	{
1177 	default:
1178 	case 0:
1179 		maRbChangesNone.Check();
1180 		break;
1181 	case 1:
1182 		maRbChangesInsDel.Check();
1183 		break;
1184 	case 2:
1185 		maRbChangesFillForm.Check();
1186 		break;
1187 	case 3:
1188 		maRbChangesComment.Check();
1189 		break;
1190 	case 4:
1191 		maRbChangesAnyNoCopy.Check();
1192 		break;
1193 	};
1194 
1195 	maCbEnableCopy.Check( paParent->mbCanCopyOrExtract );
1196 	maCbEnableAccessibility.Check( paParent->mbCanExtractForAccessibility );
1197 
1198 // set the status of this windows, according to the PDFA selection
1199     enablePermissionControls();
1200 
1201     if( paParent && paParent->GetTabPage( RID_PDF_TAB_GENER ) )
1202         ImplPDFASecurityControl(
1203             !( ( ImpPDFTabGeneralPage* )paParent->GetTabPage( RID_PDF_TAB_GENER ) )->IsPdfaSelected() );
1204 }
1205 
1206 IMPL_LINK( ImpPDFTabSecurityPage, ClickmaPbSetPwdHdl, void*, EMPTYARG )
1207 {
1208 	SfxPasswordDialog aPwdDialog( this, &msUserPwdTitle );
1209 	aPwdDialog.SetMinLen( 0 );
1210 	aPwdDialog.ShowExtras( SHOWEXTRAS_CONFIRM | SHOWEXTRAS_PASSWORD2 | SHOWEXTRAS_CONFIRM2 );
1211 	aPwdDialog.SetText( maStrSetPwd );
1212 	aPwdDialog.SetGroup2Text( msOwnerPwdTitle );
1213     aPwdDialog.AllowAsciiOnly();
1214 	if( aPwdDialog.Execute() == RET_OK )  //OK issued get password and set it
1215 	{
1216 	    rtl::OUString aUserPW( aPwdDialog.GetPassword() );
1217 	    rtl::OUString aOwnerPW( aPwdDialog.GetPassword2() );
1218 
1219 	    mbHaveUserPassword = (aUserPW.getLength() != 0);
1220 	    mbHaveOwnerPassword = (aOwnerPW.getLength() != 0);
1221 
1222 	    mxPreparedPasswords = vcl::PDFWriter::InitEncryption( aOwnerPW, aUserPW, true );
1223 
1224 	    if( mbHaveOwnerPassword )
1225 	    {
1226 	        maPreparedOwnerPassword = comphelper::OStorageHelper::CreatePackageEncryptionData( aOwnerPW );
1227 	    }
1228 	    else
1229 	        maPreparedOwnerPassword = Sequence< NamedValue >();
1230 
1231 	    // trash clear text passwords string memory
1232 	    rtl_zeroMemory( (void*)aUserPW.getStr(), aUserPW.getLength() );
1233 	    rtl_zeroMemory( (void*)aOwnerPW.getStr(), aOwnerPW.getLength() );
1234 	}
1235     enablePermissionControls();
1236 	return 0;
1237 }
1238 
1239 void ImpPDFTabSecurityPage::enablePermissionControls()
1240 {
1241     sal_Bool bIsPDFASel =  sal_False;
1242     ImpPDFTabDialog* pParent = static_cast<ImpPDFTabDialog*>(GetTabDialog());
1243     if( pParent && pParent->GetTabPage( RID_PDF_TAB_GENER ) )
1244         bIsPDFASel = ( ( ImpPDFTabGeneralPage* )pParent->
1245                        GetTabPage( RID_PDF_TAB_GENER ) )->IsPdfaSelected();
1246     if( bIsPDFASel )
1247         maFtUserPwd.SetText( maUserPwdPdfa );
1248     else
1249         maFtUserPwd.SetText( (mbHaveUserPassword && IsEnabled()) ? maUserPwdSet : maUserPwdUnset );
1250 
1251 	sal_Bool bLocalEnable = mbHaveOwnerPassword && IsEnabled();
1252 	if( bIsPDFASel )
1253 	    maFtOwnerPwd.SetText( maOwnerPwdPdfa );
1254 	else
1255 	    maFtOwnerPwd.SetText( bLocalEnable ? maOwnerPwdSet : maOwnerPwdUnset );
1256 
1257 	maFlPrintPermissions.Enable( bLocalEnable );
1258 	maRbPrintNone.Enable( bLocalEnable );
1259 	maRbPrintLowRes.Enable( bLocalEnable );
1260 	maRbPrintHighRes.Enable( bLocalEnable );
1261 
1262 	maFlChangesAllowed.Enable( bLocalEnable );
1263 	maRbChangesNone.Enable( bLocalEnable );
1264 	maRbChangesInsDel.Enable( bLocalEnable );
1265 	maRbChangesFillForm.Enable( bLocalEnable );
1266 	maRbChangesComment.Enable( bLocalEnable );
1267 	maRbChangesAnyNoCopy.Enable( bLocalEnable );
1268 
1269 	maCbEnableCopy.Enable( bLocalEnable );
1270 	maCbEnableAccessibility.Enable( bLocalEnable );
1271 }
1272 
1273 ////////////////////////////////////////////////////////
1274 // This tab page is under control of the PDF/A-1a checkbox:
1275 // implement a method to do it.
1276 // -----------------------------------------------------------------------------
1277 void    ImpPDFTabSecurityPage::ImplPDFASecurityControl( sal_Bool bEnableSecurity )
1278 {
1279     if( bEnableSecurity )
1280     {
1281         Enable();
1282 //after enable, check the status of control as if the dialog was initialized
1283     }
1284     else
1285         Enable( sal_False );
1286 
1287     enablePermissionControls();
1288 }
1289 
1290 ////////////////////////////////////////////////////////
1291 // The link preferences tab page (relative and other stuff)
1292 // -----------------------------------------------------------------------------
1293 ImpPDFTabLinksPage::ImpPDFTabLinksPage( Window* pParent,
1294 											  const SfxItemSet& rCoreSet ) :
1295 	SfxTabPage( pParent, PDFFilterResId( RID_PDF_TAB_LINKS ), rCoreSet ),
1296 
1297     maCbExprtBmkrToNmDst( this, PDFFilterResId( CB_EXP_BMRK_TO_DEST ) ),
1298     maCbOOoToPDFTargets( this,  PDFFilterResId( CB_CNV_OOO_DOCTOPDF ) ),
1299  	maCbExportRelativeFsysLinks( this, PDFFilterResId( CB_ENAB_RELLINKFSYS ) ),
1300 
1301     maFlDefaultTitle( this,  PDFFilterResId( FL_DEFAULT_LINK_ACTION ) ),
1302     maRbOpnLnksDefault( this, PDFFilterResId( CB_VIEW_PDF_DEFAULT ) ),
1303     mbOpnLnksDefaultUserState( sal_False ),
1304 	maRbOpnLnksLaunch( this, PDFFilterResId( CB_VIEW_PDF_APPLICATION ) ),
1305     mbOpnLnksLaunchUserState( sal_False ),
1306     maRbOpnLnksBrowser( this,  PDFFilterResId( CB_VIEW_PDF_BROWSER ) ),
1307     mbOpnLnksBrowserUserState( sal_False )
1308 {
1309 	FreeResource();
1310 
1311     // pb: #i91991# checkboxes only double-spaced if necessary
1312     long nDelta = 0;
1313     Size aSize = maCbExprtBmkrToNmDst.GetSizePixel();
1314     Size aMinSize = maCbExprtBmkrToNmDst.CalcMinimumSize();
1315     long nLineHeight =
1316         maCbExprtBmkrToNmDst.LogicToPixel( Size( 10, 10 ), MAP_APPFONT ).Height();
1317     if ( aSize.Width() > aMinSize.Width() )
1318     {
1319         Size aNewSize( aSize.Width(), nLineHeight );
1320         nDelta += ( aSize.Height() - nLineHeight );
1321         maCbExprtBmkrToNmDst.SetSizePixel( aNewSize );
1322         Point aNewPos = maCbOOoToPDFTargets.GetPosPixel();
1323         aNewPos.Y() -= nDelta;
1324         maCbOOoToPDFTargets.SetPosPixel( aNewPos );
1325     }
1326 
1327     aSize = maCbOOoToPDFTargets.GetSizePixel();
1328     aMinSize = maCbOOoToPDFTargets.CalcMinimumSize();
1329     if ( aSize.Width() > aMinSize.Width() )
1330     {
1331         Size aNewSize( aSize.Width(), nLineHeight );
1332         nDelta += ( aSize.Height() - nLineHeight );
1333         maCbOOoToPDFTargets.SetSizePixel( aNewSize );
1334         Point aNewPos = maCbExportRelativeFsysLinks.GetPosPixel();
1335         aNewPos.Y() -= nDelta;
1336         maCbExportRelativeFsysLinks.SetPosPixel( aNewPos );
1337     }
1338 
1339     aSize = maCbExportRelativeFsysLinks.GetSizePixel();
1340     aMinSize = maCbExportRelativeFsysLinks.CalcMinimumSize();
1341     if ( aSize.Width() > aMinSize.Width() )
1342     {
1343         Size aNewSize( aSize.Width(), nLineHeight );
1344         nDelta += ( aSize.Height() - nLineHeight );
1345         maCbExportRelativeFsysLinks.SetSizePixel( aNewSize );
1346     }
1347 
1348     if ( nDelta > 0 )
1349     {
1350         Window* pWins[] =
1351             { &maFlDefaultTitle, &maRbOpnLnksDefault, &maRbOpnLnksLaunch, &maRbOpnLnksBrowser, NULL };
1352         Window** pCurrent = pWins;
1353         while ( *pCurrent )
1354         {
1355             Point aNewPos = (*pCurrent)->GetPosPixel();
1356             aNewPos.Y() -= nDelta;
1357             (*pCurrent++)->SetPosPixel( aNewPos );
1358         }
1359     }
1360 }
1361 
1362 // -----------------------------------------------------------------------------
1363 ImpPDFTabLinksPage::~ImpPDFTabLinksPage()
1364 {
1365 }
1366 
1367 // -----------------------------------------------------------------------------
1368 SfxTabPage*  ImpPDFTabLinksPage::Create( Window* pParent,
1369                                           const SfxItemSet& rAttrSet)
1370 {
1371 	return ( new  ImpPDFTabLinksPage( pParent, rAttrSet ) );
1372 }
1373 
1374 // -----------------------------------------------------------------------------
1375 void ImpPDFTabLinksPage::GetFilterConfigItem( ImpPDFTabDialog* paParent  )
1376 {
1377 	paParent->mbExportRelativeFsysLinks = maCbExportRelativeFsysLinks.IsChecked();
1378 
1379     sal_Bool bIsPDFASel =  sal_False;
1380     if( paParent && paParent->GetTabPage( RID_PDF_TAB_GENER ) )
1381         bIsPDFASel = ( ( ImpPDFTabGeneralPage* )paParent->
1382                        GetTabPage( RID_PDF_TAB_GENER ) )->IsPdfaSelected();
1383 // if PDF/A-1 was not selected while exiting dialog...
1384     if( !bIsPDFASel )
1385     {
1386 // ...get the control states
1387         mbOpnLnksDefaultUserState = maRbOpnLnksDefault.IsChecked();
1388         mbOpnLnksLaunchUserState =  maRbOpnLnksLaunch.IsChecked();
1389         mbOpnLnksBrowserUserState = maRbOpnLnksBrowser.IsChecked();
1390     }
1391 // the control states, or the saved is used
1392 // to form the stored selection
1393     paParent->mnViewPDFMode = 0;
1394     if(	mbOpnLnksBrowserUserState )
1395         paParent->mnViewPDFMode = 2;
1396     else if( mbOpnLnksLaunchUserState )
1397         paParent->mnViewPDFMode = 1;
1398 
1399 	paParent->mbConvertOOoTargets = maCbOOoToPDFTargets.IsChecked();
1400 	paParent->mbExportBmkToPDFDestination = maCbExprtBmkrToNmDst.IsChecked();
1401 }
1402 
1403 // -----------------------------------------------------------------------------
1404 void ImpPDFTabLinksPage::SetFilterConfigItem( const  ImpPDFTabDialog* paParent )
1405 {
1406     maCbOOoToPDFTargets.Check( paParent->mbConvertOOoTargets );
1407 	maCbExprtBmkrToNmDst.Check( paParent->mbExportBmkToPDFDestination );
1408 
1409     maRbOpnLnksDefault.SetClickHdl( LINK( this, ImpPDFTabLinksPage, ClickRbOpnLnksDefaultHdl ) );
1410     maRbOpnLnksBrowser.SetClickHdl( LINK( this, ImpPDFTabLinksPage, ClickRbOpnLnksBrowserHdl ) );
1411 
1412 	maCbExportRelativeFsysLinks.Check( paParent->mbExportRelativeFsysLinks );
1413     switch( paParent->mnViewPDFMode )
1414     {
1415     default:
1416     case 0:
1417         maRbOpnLnksDefault.Check();
1418         mbOpnLnksDefaultUserState = sal_True;
1419         break;
1420     case 1:
1421         maRbOpnLnksLaunch.Check();
1422         mbOpnLnksLaunchUserState = sal_True;
1423         break;
1424     case 2:
1425         maRbOpnLnksBrowser.Check();
1426         mbOpnLnksBrowserUserState = sal_True;
1427         break;
1428     }
1429 // now check the status of PDF/A selection
1430 // and set the link action accordingly
1431 // PDF/A-1 doesn't allow launch action on links
1432 //
1433     if( paParent && paParent->GetTabPage( RID_PDF_TAB_GENER ) )
1434         ImplPDFALinkControl(
1435             !( ( ImpPDFTabGeneralPage* )paParent->
1436                GetTabPage( RID_PDF_TAB_GENER ) )->maCbPDFA1b.IsChecked() );
1437 }
1438 
1439 // -----------------------------------------------------------------------------
1440 // called from general tab, with PDFA/1 selection status
1441 // retrieves/store the status of Launch action selection
1442 void ImpPDFTabLinksPage::ImplPDFALinkControl( sal_Bool bEnableLaunch )
1443 {
1444 // set the value and position of link type selection
1445     if( bEnableLaunch )
1446     {
1447         maRbOpnLnksLaunch.Enable();
1448 //restore user state with no PDF/A-1 selected
1449         maRbOpnLnksDefault.Check( mbOpnLnksDefaultUserState );
1450         maRbOpnLnksLaunch.Check( mbOpnLnksLaunchUserState );
1451         maRbOpnLnksBrowser.Check( mbOpnLnksBrowserUserState );
1452     }
1453     else
1454     {
1455 //save user state with no PDF/A-1 selected
1456         mbOpnLnksDefaultUserState = maRbOpnLnksDefault.IsChecked();
1457         mbOpnLnksLaunchUserState = maRbOpnLnksLaunch.IsChecked();
1458         mbOpnLnksBrowserUserState = maRbOpnLnksBrowser.IsChecked();
1459         maRbOpnLnksLaunch.Enable( sal_False );
1460         if( mbOpnLnksLaunchUserState )
1461             maRbOpnLnksBrowser.Check();
1462     }
1463 }
1464 
1465 // -----------------------------------------------------------------------------
1466 // reset the memory of Launch action present
1467 // when PDF/A-1 was requested
1468 IMPL_LINK( ImpPDFTabLinksPage, ClickRbOpnLnksDefaultHdl, void*, EMPTYARG )
1469 {
1470     mbOpnLnksDefaultUserState = maRbOpnLnksDefault.IsChecked();
1471     mbOpnLnksLaunchUserState = maRbOpnLnksLaunch.IsChecked();
1472     mbOpnLnksBrowserUserState = maRbOpnLnksBrowser.IsChecked();
1473     return 0;
1474 }
1475 
1476 // -----------------------------------------------------------------------------
1477 // reset the memory of a launch action present
1478 // when PDF/A-1 was requested
1479 IMPL_LINK( ImpPDFTabLinksPage, ClickRbOpnLnksBrowserHdl, void*, EMPTYARG )
1480 {
1481     mbOpnLnksDefaultUserState = maRbOpnLnksDefault.IsChecked();
1482     mbOpnLnksLaunchUserState = maRbOpnLnksLaunch.IsChecked();
1483     mbOpnLnksBrowserUserState = maRbOpnLnksBrowser.IsChecked();
1484     return 0;
1485 }
1486 
1487 ImplErrorDialog::ImplErrorDialog( const std::set< vcl::PDFWriter::ErrorCode >& rErrors ) :
1488     ModalDialog( NULL, PDFFilterResId( RID_PDF_ERROR_DLG ) ),
1489     maFI( this, 0 ),
1490     maProcessText( this, PDFFilterResId( FT_PROCESS ) ),
1491     maErrors( this, WB_BORDER | WB_AUTOVSCROLL ),
1492     maExplanation( this, WB_WORDBREAK ),
1493     maButton( this, WB_DEFBUTTON )
1494 
1495 {
1496     // load images
1497     Image aWarnImg( BitmapEx( PDFFilterResId( IMG_WARN ) ) );
1498     Image aErrImg( BitmapEx( PDFFilterResId( IMG_ERR ) ) );
1499 
1500     for( std::set<vcl::PDFWriter::ErrorCode>::const_iterator it = rErrors.begin();
1501          it != rErrors.end(); ++it )
1502     {
1503         switch( *it )
1504         {
1505         case vcl::PDFWriter::Warning_Transparency_Omitted_PDFA:
1506         {
1507             sal_uInt16 nPos = maErrors.InsertEntry( String( PDFFilterResId( STR_WARN_TRANSP_PDFA_SHORT ) ),
1508                                                 aWarnImg );
1509             maErrors.SetEntryData( nPos, new String( PDFFilterResId( STR_WARN_TRANSP_PDFA ) ) );
1510         }
1511         break;
1512         case vcl::PDFWriter::Warning_Transparency_Omitted_PDF13:
1513         {
1514             sal_uInt16 nPos = maErrors.InsertEntry( String( PDFFilterResId( STR_WARN_TRANSP_VERSION_SHORT ) ),
1515                                                 aWarnImg );
1516             maErrors.SetEntryData( nPos, new String( PDFFilterResId( STR_WARN_TRANSP_VERSION ) ) );
1517         }
1518         break;
1519         case vcl::PDFWriter::Warning_FormAction_Omitted_PDFA:
1520         {
1521             sal_uInt16 nPos = maErrors.InsertEntry( String( PDFFilterResId( STR_WARN_FORMACTION_PDFA_SHORT ) ),
1522                                                 aWarnImg );
1523             maErrors.SetEntryData( nPos, new String( PDFFilterResId( STR_WARN_FORMACTION_PDFA ) ) );
1524         }
1525         break;
1526         case vcl::PDFWriter::Warning_Transparency_Converted:
1527         {
1528             sal_uInt16 nPos = maErrors.InsertEntry( String( PDFFilterResId( STR_WARN_TRANSP_CONVERTED_SHORT ) ),
1529                                                 aWarnImg );
1530             maErrors.SetEntryData( nPos, new String( PDFFilterResId( STR_WARN_TRANSP_CONVERTED ) ) );
1531         }
1532         break;
1533         default:
1534             break;
1535         }
1536     }
1537 
1538     FreeResource();
1539 
1540     if( maErrors.GetEntryCount() > 0 )
1541     {
1542         maErrors.SelectEntryPos( 0 );
1543         String* pStr = reinterpret_cast<String*>(maErrors.GetEntryData( 0 ));
1544         maExplanation.SetText( pStr ? *pStr : String() );
1545     }
1546 
1547     // adjust layout
1548     Image aWarnImage( WarningBox::GetStandardImage() );
1549     Size aImageSize( aWarnImage.GetSizePixel() );
1550     Size aDlgSize( GetSizePixel() );
1551     aImageSize.Width() += 6;
1552     aImageSize.Height() += 6;
1553     maFI.SetImage( aWarnImage );
1554     maFI.SetPosSizePixel( Point( 5, 5 ), aImageSize );
1555     maFI.Show();
1556 
1557     maProcessText.SetStyle( maProcessText.GetStyle() | WB_VCENTER );
1558     maProcessText.SetPosSizePixel( Point( aImageSize.Width() + 10, 5 ),
1559                                    Size(  aDlgSize.Width() - aImageSize.Width() - 15, aImageSize.Height() ) );
1560 
1561     Point aErrorLBPos( 5, aImageSize.Height() + 10 );
1562     Size aErrorLBSize( aDlgSize.Width()/2 - 10, aDlgSize.Height() - aErrorLBPos.Y() - 35 );
1563     maErrors.SetPosSizePixel( aErrorLBPos, aErrorLBSize );
1564     maErrors.SetSelectHdl( LINK( this, ImplErrorDialog, SelectHdl ) );
1565     maErrors.Show();
1566 
1567     maExplanation.SetPosSizePixel( Point( aErrorLBPos.X() + aErrorLBSize.Width() + 5, aErrorLBPos.Y() ),
1568                                    Size( aDlgSize.Width() - aErrorLBPos.X() - aErrorLBSize.Width() - 10, aErrorLBSize.Height() ) );
1569     maExplanation.Show();
1570 
1571     maButton.SetPosSizePixel( Point( (aDlgSize.Width() - 50)/2, aDlgSize.Height() - 30 ),
1572                               Size( 50, 25 ) );
1573     maButton.Show();
1574 }
1575 
1576 ImplErrorDialog::~ImplErrorDialog()
1577 {
1578     // free strings again
1579     for( sal_uInt16 n = 0; n < maErrors.GetEntryCount(); n++ )
1580         delete (String*)maErrors.GetEntryData( n );
1581 }
1582 
1583 IMPL_LINK( ImplErrorDialog, SelectHdl, ListBox*, EMPTYARG )
1584 {
1585     String* pStr = reinterpret_cast<String*>(maErrors.GetEntryData( maErrors.GetSelectEntryPos() ));
1586     maExplanation.SetText( pStr ? *pStr : String() );
1587     return 0;
1588 }
1589