xref: /AOO41X/main/sdext/source/minimizer/optimizerdialogcontrols.cxx (revision 54628ca40d27d15cc98fe861da7fff7e60c2f7d6)
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_sdext.hxx"
26 
27 #include "optimizerdialog.hxx"
28 
29 // -------------------
30 // - OptimizerDialog -
31 // -------------------
32 #include "pppoptimizer.hxx"
33 #include "graphiccollector.hxx"
34 #include "pagecollector.hxx"
35 #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
36 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
37 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
38 #include <com/sun/star/awt/FontDescriptor.hpp>
39 #ifndef _COM_SUN_STAR_AWT_XFONTWEIGHT_HPP_
40 #include <com/sun/star/awt/FontWeight.hpp>
41 #endif
42 #include <rtl/ustrbuf.hxx>
43 
44 using namespace ::rtl;
45 using namespace ::com::sun::star::awt;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::util;
48 using namespace ::com::sun::star::lang;
49 using namespace ::com::sun::star::frame;
50 using namespace ::com::sun::star::beans;
51 using namespace ::com::sun::star::script;
52 using namespace ::com::sun::star::drawing;
53 using namespace ::com::sun::star::container;
54 using namespace ::com::sun::star::presentation;
55 
56 // -----------------------------------------------------------------------------
57 
58 void SetBold( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControl )
59 {
60     FontDescriptor aFontDescriptor;
61     if ( rOptimizerDialog.getControlProperty( rControl, TKGet( TK_FontDescriptor ) ) >>= aFontDescriptor )
62     {
63         aFontDescriptor.Weight = FontWeight::BOLD;
64         rOptimizerDialog.setControlProperty( rControl, TKGet( TK_FontDescriptor ), Any( aFontDescriptor ) );
65     }
66 }
67 
68 // -----------------------------------------------------------------------------
69 
70 rtl::OUString InsertSeparator( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, sal_Int32 nOrientation,
71                         sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight )
72 {
73     OUString pNames[] = {
74         TKGet( TK_Height ),
75         TKGet( TK_Orientation ),
76         TKGet( TK_PositionX ),
77         TKGet( TK_PositionY ),
78         TKGet( TK_Step ),
79         TKGet( TK_Width ) };
80 
81     Any pValues[] = {
82         Any( nHeight ),
83         Any( nOrientation ),
84         Any( nPosX ),
85         Any( nPosY ),
86         Any( sal_Int16( 0 ) ),
87         Any( nWidth ) };
88 
89     sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
90 
91     Sequence< rtl::OUString >   aNames( pNames, nCount );
92     Sequence< Any >             aValues( pValues, nCount );
93 
94     rOptimizerDialog.insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" ) ),
95         rControlName, aNames, aValues );
96     return rControlName;
97 }
98 
99 // -----------------------------------------------------------------------------
100 
101 rtl::OUString InsertButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, Reference< XActionListener >& xActionListener,
102     sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex, sal_Bool bEnabled, PPPOptimizerTokenEnum nResID, sal_Int16 nPushButtonType )
103 {
104     OUString pNames[] = {
105         TKGet( TK_Enabled ),
106         TKGet( TK_Height ),
107         TKGet( TK_Label ),
108         TKGet( TK_PositionX ),
109         TKGet( TK_PositionY ),
110         TKGet( TK_PushButtonType ),
111         TKGet( TK_Step ),
112         TKGet( TK_TabIndex ),
113         TKGet( TK_Width ) };
114 
115     Any pValues[] = {
116         Any( bEnabled  ),
117         Any( nHeight ),
118         Any( rOptimizerDialog.getString( nResID ) ),
119         Any( nXPos ),
120         Any( nYPos ),
121         Any( nPushButtonType ),
122         Any( (sal_Int16)0 ),
123         Any( nTabIndex ),
124         Any( nWidth ) };
125 
126 
127     sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
128 
129     Sequence< rtl::OUString >   aNames( pNames, nCount );
130     Sequence< Any >             aValues( pValues, nCount );
131 
132     rOptimizerDialog.insertButton( rControlName, xActionListener, aNames, aValues );
133     return rControlName;
134 }
135 
136 // -----------------------------------------------------------------------------
137 
138 rtl::OUString InsertFixedText( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControlName, const OUString& rLabel,
139                                 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Bool bBold, sal_Int16 nTabIndex )
140 {
141     OUString pNames[] = {
142         TKGet( TK_Height ),
143         TKGet( TK_Label ),
144         TKGet( TK_MultiLine ),
145         TKGet( TK_PositionX ),
146         TKGet( TK_PositionY ),
147         TKGet( TK_Step ),
148         TKGet( TK_TabIndex ),
149         TKGet( TK_Width ) };
150 
151     Any pValues[] = {
152         Any( nHeight ),
153         Any( rLabel ),
154         Any( bMultiLine ),
155         Any( nXPos ),
156         Any( nYPos ),
157         Any( (sal_Int16)0 ),
158         Any( nTabIndex ),
159         Any( nWidth ) };
160 
161     sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
162 
163     Sequence< rtl::OUString >   aNames( pNames, nCount );
164     Sequence< Any >             aValues( pValues, nCount );
165 
166     rOptimizerDialog.insertFixedText( rControlName, aNames, aValues );
167     if ( bBold )
168         SetBold( rOptimizerDialog, rControlName );
169     return rControlName;
170 }
171 
172 // -----------------------------------------------------------------------------
173 
174 rtl::OUString InsertCheckBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
175     const Reference< XItemListener > xItemListener, const OUString& rLabel,
176         sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
177 {
178     OUString pNames[] = {
179         TKGet( TK_Enabled ),
180         TKGet( TK_Height ),
181         TKGet( TK_Label ),
182         TKGet( TK_PositionX ),
183         TKGet( TK_PositionY ),
184         TKGet( TK_Step ),
185         TKGet( TK_TabIndex ),
186         TKGet( TK_Width ) };
187 
188     Any pValues[] = {
189         Any( sal_True ),
190         Any( nHeight ),
191         Any( rLabel ),
192         Any( nXPos ),
193         Any( nYPos ),
194         Any( (sal_Int16)0 ),
195         Any( nTabIndex ),
196         Any( nWidth ) };
197 
198     sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
199 
200     Sequence< rtl::OUString >   aNames( pNames, nCount );
201     Sequence< Any >             aValues( pValues, nCount );
202 
203     Reference< XCheckBox > xCheckBox( rOptimizerDialog.insertCheckBox( rControlName, aNames, aValues ) );
204     if ( xItemListener.is() )
205         xCheckBox->addItemListener( xItemListener );
206     return rControlName;
207 }
208 
209 // -----------------------------------------------------------------------------
210 
211 rtl::OUString InsertFormattedField( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
212         const Reference< XTextListener > xTextListener, const Reference< XSpinListener > xSpinListener, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth,
213             double fEffectiveMin, double fEffectiveMax, sal_Int16 nTabIndex )
214 {
215     OUString pNames[] = {
216         TKGet( TK_EffectiveMax ),
217         TKGet( TK_EffectiveMin ),
218         TKGet( TK_Enabled ),
219         TKGet( TK_Height ),
220         TKGet( TK_PositionX ),
221         TKGet( TK_PositionY ),
222         TKGet( TK_Repeat ),
223         TKGet( TK_Spin ),
224         TKGet( TK_Step ),
225         TKGet( TK_TabIndex ),
226         TKGet( TK_Width ) };
227 
228     Any pValues[] = {
229         Any( fEffectiveMax ),
230         Any( fEffectiveMin ),
231         Any( sal_True ),
232         Any( (sal_Int32)12 ),
233         Any( nXPos ),
234         Any( nYPos ),
235         Any( (sal_Bool)sal_True ),
236         Any( (sal_Bool)sal_True ),
237         Any( (sal_Int16)0 ),
238         Any( nTabIndex ),
239         Any( nWidth ) };
240 
241     sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
242 
243     Sequence< rtl::OUString >   aNames( pNames, nCount );
244     Sequence< Any >             aValues( pValues, nCount );
245 
246     Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertFormattedField( rControlName, aNames, aValues ), UNO_QUERY_THROW );
247     if ( xTextListener.is() )
248         xTextComponent->addTextListener( xTextListener );
249     if ( xSpinListener.is() )
250     {
251         Reference< XSpinField > xSpinField( xTextComponent, UNO_QUERY_THROW );
252         xSpinField->addSpinListener( xSpinListener );
253     }
254     return rControlName;
255 }
256 
257 // -----------------------------------------------------------------------------
258 
259 rtl::OUString InsertComboBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
260     const Reference< XTextListener > xTextListener, const sal_Bool bEnabled, const Sequence< OUString >& rItemList,
261         sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
262 {
263     OUString pNames[] = {
264         TKGet( TK_Dropdown ),
265         TKGet( TK_Enabled ),
266         TKGet( TK_Height ),
267         TKGet( TK_LineCount ),
268         TKGet( TK_PositionX ),
269         TKGet( TK_PositionY ),
270         TKGet( TK_Step ),
271         TKGet( TK_StringItemList ),
272         TKGet( TK_TabIndex ),
273         TKGet( TK_Width ) };
274 
275     Any pValues[] = {
276         Any( sal_True ),
277         Any( bEnabled ),
278         Any( nHeight ),
279         Any( (sal_Int16)8),
280         Any( nXPos ),
281         Any( nYPos ),
282         Any( (sal_Int16)0 ),
283         Any( rItemList ),
284         Any( nTabIndex ),
285         Any( nWidth ) };
286 
287     sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
288 
289     Sequence< rtl::OUString >   aNames( pNames, nCount );
290     Sequence< Any >             aValues( pValues, nCount );
291 
292     Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertComboBox( rControlName, aNames, aValues ), UNO_QUERY_THROW );
293     if ( xTextListener.is() )
294         xTextComponent->addTextListener( xTextListener );
295     return rControlName;
296 }
297 
298 // -----------------------------------------------------------------------------
299 
300 rtl::OUString InsertRadioButton( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControlName, const Reference< XItemListener > xItemListener,
301     const OUString& rLabel, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Int16 nTabIndex )
302 {
303     OUString pNames[] = {
304         TKGet( TK_Height ),
305         TKGet( TK_Label ),
306         TKGet( TK_MultiLine ),
307         TKGet( TK_PositionX ),
308         TKGet( TK_PositionY ),
309         TKGet( TK_Step ),
310         TKGet( TK_TabIndex ),
311         TKGet( TK_Width ) };
312 
313     Any pValues[] = {
314         Any( nHeight ),
315         Any( rLabel ),
316         Any( bMultiLine ),
317         Any( nXPos ),
318         Any( nYPos ),
319         Any( (sal_Int16)0 ),
320         Any( nTabIndex ),
321         Any( nWidth ) };
322 
323     sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
324 
325     Sequence< rtl::OUString >   aNames( pNames, nCount );
326     Sequence< Any >             aValues( pValues, nCount );
327 
328     Reference< XRadioButton > xRadioButton( rOptimizerDialog.insertRadioButton( rControlName, aNames, aValues ) );
329     if ( xItemListener.is() )
330         xRadioButton->addItemListener( xItemListener );
331     return rControlName;
332 }
333 
334 // -----------------------------------------------------------------------------
335 
336 rtl::OUString InsertListBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
337     const Reference< XActionListener > xActionListener, const sal_Bool bEnabled, const Sequence< OUString >& rItemList,
338         sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
339 {
340     OUString pNames[] = {
341         TKGet( TK_Dropdown ),
342         TKGet( TK_Enabled ),
343         TKGet( TK_Height ),
344         TKGet( TK_LineCount ),
345         TKGet( TK_MultiSelection ),
346         TKGet( TK_PositionX ),
347         TKGet( TK_PositionY ),
348         TKGet( TK_Step ),
349         TKGet( TK_StringItemList ),
350         TKGet( TK_TabIndex ),
351         TKGet( TK_Width ) };
352 
353     Any pValues[] = {
354         Any( sal_True ),
355         Any( bEnabled ),
356         Any( nHeight ),
357         Any( (sal_Int16)8),
358         Any( sal_False ),
359         Any( nXPos ),
360         Any( nYPos ),
361         Any( (sal_Int16)0 ),
362         Any( rItemList ),
363         Any( nTabIndex ),
364         Any( nWidth ) };
365 
366     sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
367 
368     Sequence< rtl::OUString >   aNames( pNames, nCount );
369     Sequence< Any >             aValues( pValues, nCount );
370 
371     Reference< XListBox > xListBox( rOptimizerDialog.insertListBox( rControlName, aNames, aValues ) );
372     if ( xListBox.is() )
373         xListBox->addActionListener( xActionListener );
374     return rControlName;
375 }
376 
377 // -----------------------------------------------------------------------------
378 
379 void OptimizerDialog::InitNavigationBar()
380 {
381     sal_Int32   nCancelPosX = OD_DIALOG_WIDTH - BUTTON_WIDTH - 6;
382     sal_Int32   nFinishPosX = nCancelPosX - 6 - BUTTON_WIDTH;
383     sal_Int32   nNextPosX = nFinishPosX - 6 - BUTTON_WIDTH;
384     sal_Int32   nBackPosX = nNextPosX - 3 - BUTTON_WIDTH;
385 
386     InsertSeparator( *this, TKGet( TK_lnNavSep1 ), 0, 0, DIALOG_HEIGHT - 26, OD_DIALOG_WIDTH, 1 );
387     InsertSeparator( *this, TKGet( TK_lnNavSep2 ), 1, 85, 0, 1, BUTTON_POS_Y - 6 );
388 
389     InsertButton( *this, TKGet( TK_btnNavHelp ), mxActionListener, 8, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_HELP, PushButtonType_STANDARD );
390     InsertButton( *this, TKGet( TK_btnNavBack ), mxActionListener, nBackPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_False, STR_BACK, PushButtonType_STANDARD );
391     InsertButton( *this, TKGet( TK_btnNavNext ), mxActionListener, nNextPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_NEXT, PushButtonType_STANDARD );
392     InsertButton( *this, TKGet( TK_btnNavFinish ), mxActionListener, nFinishPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_FINISH, PushButtonType_STANDARD );
393     InsertButton( *this, TKGet( TK_btnNavCancel ), mxActionListener, nCancelPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_CANCEL, PushButtonType_STANDARD );
394 
395     setControlProperty( TKGet( TK_btnNavNext ), TKGet( TK_DefaultButton ), Any( sal_True ) );
396 }
397 
398 // -----------------------------------------------------------------------------
399 
400 void OptimizerDialog::UpdateControlStatesPage0()
401 {
402     sal_uInt32 i;
403     short nSelectedItem = -1;
404     Sequence< OUString > aItemList;
405     const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
406     if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
407     {
408         aItemList.realloc( rList.size() - 1 );
409         for ( i = 1; i < rList.size(); i++ )
410         {
411             aItemList[ i - 1 ] = rList[ i ].maName;
412             if ( nSelectedItem < 0 )
413             {
414                 if ( rList[ i ] == rList[ 0 ] )
415                     nSelectedItem = static_cast< short >( i - 1 );
416             }
417         }
418     }
419     sal_Bool bRemoveButtonEnabled = sal_False;
420     Sequence< short > aSelectedItems;
421     if ( nSelectedItem >= 0 )
422     {
423         aSelectedItems.realloc( 1 );
424         aSelectedItems[ 0 ] = nSelectedItem;
425         if ( nSelectedItem > 2 )    // only allowing to delete custom themes, the first can|t be deleted
426             bRemoveButtonEnabled = sal_True;
427     }
428     setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_StringItemList ), Any( aItemList ) );
429     setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_SelectedItems ), Any( aSelectedItems ) );
430     setControlProperty( TKGet( TK_Button0Pg0 ), TKGet( TK_Enabled ), Any( bRemoveButtonEnabled ) );
431 }
432 void OptimizerDialog::InitPage0()
433 {
434     Sequence< OUString > aItemList;
435     std::vector< rtl::OUString > aControlList;
436     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText0Pg0 ), getString( STR_INTRODUCTION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) );
437     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText1Pg0 ), getString( STR_INTRODUCTION_T ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 100, sal_True, sal_False, mnTabIndex++ ) );
438     aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator1Pg0 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 66, PAGE_WIDTH - 12, 1 ) );
439     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText2Pg0 ), getString( STR_CHOSE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 60, PAGE_WIDTH - 12, 8, sal_True, sal_False, mnTabIndex++ ) );
440     aControlList.push_back( InsertListBox(  *this, TKGet( TK_ListBox0Pg0 ), mxActionListenerListBox0Pg0, sal_True, aItemList, PAGE_POS_X + 6, DIALOG_HEIGHT - 48, ( OD_DIALOG_WIDTH - 50 ) - ( PAGE_POS_X + 6 ), 12, mnTabIndex++ ) );
441     aControlList.push_back( InsertButton( *this, TKGet( TK_Button0Pg0 ), mxActionListener, OD_DIALOG_WIDTH - 46, DIALOG_HEIGHT - 49, 40, 14, mnTabIndex++, sal_True, STR_REMOVE, PushButtonType_STANDARD ) );
442     maControlPages.push_back( aControlList );
443     DeactivatePage( 0 );
444     UpdateControlStatesPage0();
445 }
446 
447 // -----------------------------------------------------------------------------
448 
449 void OptimizerDialog::UpdateControlStatesPage1()
450 {
451     sal_Bool bDeleteUnusedMasterPages( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) );
452     sal_Bool bDeleteHiddenSlides( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) );
453     sal_Bool bDeleteNotesPages( GetConfigProperty( TK_DeleteNotesPages, sal_False ) );
454 
455     setControlProperty( TKGet( TK_CheckBox0Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteUnusedMasterPages ) );
456     setControlProperty( TKGet( TK_CheckBox1Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteNotesPages ) );
457     setControlProperty( TKGet( TK_CheckBox2Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteHiddenSlides ) );
458 }
459 void OptimizerDialog::InitPage1()
460 {
461     Sequence< OUString > aCustomShowList;
462     Reference< XModel > xModel( mxController->getModel() );
463     if ( xModel.is() )
464     {
465         Reference< XCustomPresentationSupplier > aXCPSup( xModel, UNO_QUERY_THROW );
466         Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
467         if ( aXCont.is() )
468             aCustomShowList = aXCont->getElementNames();
469     }
470     std::vector< rtl::OUString > aControlList;
471     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText0Pg3 ), getString( STR_CHOOSE_SLIDES ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) );
472     aControlList.push_back( InsertCheckBox(  *this, TKGet( TK_CheckBox0Pg3 ), mxItemListener, getString( STR_DELETE_MASTER_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
473     aControlList.push_back( InsertCheckBox(  *this, TKGet( TK_CheckBox2Pg3 ), mxItemListener, getString( STR_DELETE_HIDDEN_SLIDES ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
474     aControlList.push_back( InsertCheckBox(  *this, TKGet( TK_CheckBox3Pg3 ), mxItemListener, getString( STR_CUSTOM_SHOW ), PAGE_POS_X + 6, PAGE_POS_Y + 42, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
475     aControlList.push_back( InsertListBox(  *this, TKGet( TK_ListBox0Pg3 ), mxActionListener, sal_True, aCustomShowList, PAGE_POS_X + 14, PAGE_POS_Y + 54, 150, 12, mnTabIndex++ ) );
476     aControlList.push_back( InsertCheckBox(  *this, TKGet( TK_CheckBox1Pg3 ), mxItemListener, getString( STR_DELETE_NOTES_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 70, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
477     maControlPages.push_back( aControlList );
478     DeactivatePage( 1 );
479 
480     setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ), Any( sal_False ) );
481     setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_Enabled ), Any( aCustomShowList.getLength() != 0 ) );
482     setControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_Enabled ), Any( sal_False ) );
483 
484     UpdateControlStatesPage1();
485 }
486 
487 // -----------------------------------------------------------------------------
488 
489 void OptimizerDialog::UpdateControlStatesPage2()
490 {
491     sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) );
492     sal_Bool bRemoveCropArea( GetConfigProperty( TK_RemoveCropArea, sal_False ) );
493     sal_Bool bEmbedLinkedGraphics( GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) );
494     sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
495 
496     sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
497 
498     sal_Int32 nI0, nI1, nI2, nI3;
499     nI0 = nI1 = nI2 = nI3 = 0;
500     OUString aResolutionText;
501     Sequence< OUString > aResolutionItemList( 4 );
502     aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
503     aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
504     aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
505     aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
506     nI0 = nI1 = nI2 = nI3 = 0;
507     if ( getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI0 ).toInt32() == nImageResolution )
508         aResolutionText = aResolutionItemList[ 0 ];
509     else if ( getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI1 ).toInt32() == nImageResolution )
510         aResolutionText = aResolutionItemList[ 1 ];
511     else if ( getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI2 ).toInt32() == nImageResolution )
512         aResolutionText = aResolutionItemList[ 2 ];
513     else if ( getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI3 ).toInt32() == nImageResolution )
514         aResolutionText = aResolutionItemList[ 3 ];
515     if ( !aResolutionText.getLength() )
516         aResolutionText = OUString::valueOf( nImageResolution );
517 
518     setControlProperty( TKGet( TK_RadioButton0Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_True ) ) );
519     setControlProperty( TKGet( TK_RadioButton1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_False ) ) );
520     setControlProperty( TKGet( TK_FixedText1Pg1  ), TKGet( TK_Enabled ), Any( bJPEGCompression ) );
521     setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) );
522     setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( (double)nJPEGQuality ) );
523     setControlProperty( TKGet( TK_CheckBox1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bRemoveCropArea ) );
524     setControlProperty( TKGet( TK_ComboBox0Pg1 ), TKGet( TK_Text ), Any( aResolutionText ) );
525     setControlProperty( TKGet( TK_CheckBox2Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bEmbedLinkedGraphics ) );
526 }
527 void OptimizerDialog::InitPage2()
528 {
529     sal_Int32 nI0, nI1, nI2, nI3;
530     nI0 = nI1 = nI2 = nI3 = 0;
531     Sequence< OUString > aResolutionItemList( 4 );
532     aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
533     aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
534     aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
535     aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
536 
537     std::vector< rtl::OUString > aControlList;
538     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText0Pg1 ), getString( STR_GRAPHIC_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) );
539     aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton0Pg1 ), mxItemListener, getString( STR_LOSSLESS_COMPRESSION ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) );
540     aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton1Pg1 ), mxItemListener, getString( STR_JPEG_COMPRESSION ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) );
541     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText1Pg1 ), getString( STR_QUALITY ), PAGE_POS_X + 20, PAGE_POS_Y + 40, 72, 8, sal_False, sal_False, mnTabIndex++ ) );
542     aControlList.push_back( InsertFormattedField( *this, TKGet( TK_FormattedField0Pg1 ), mxTextListenerFormattedField0Pg1, mxSpinListenerFormattedField0Pg1, PAGE_POS_X + 106, PAGE_POS_Y + 38, 50, 0, 100, mnTabIndex++ ) );
543     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText2Pg1 ), getString( STR_IMAGE_RESOLUTION ), PAGE_POS_X + 6, PAGE_POS_Y + 54, 94, 8, sal_False, sal_False, mnTabIndex++ ) );
544     aControlList.push_back( InsertComboBox(  *this, TKGet( TK_ComboBox0Pg1 ), mxTextListenerComboBox0Pg1, sal_True, aResolutionItemList, PAGE_POS_X + 106, PAGE_POS_Y + 52, 100, 12, mnTabIndex++ ) );
545     aControlList.push_back( InsertCheckBox(  *this, TKGet( TK_CheckBox1Pg1 ), mxItemListener, getString( STR_REMOVE_CROP_AREA ), PAGE_POS_X + 6, PAGE_POS_Y + 68, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
546     aControlList.push_back( InsertCheckBox(  *this, TKGet( TK_CheckBox2Pg1 ), mxItemListener, getString( STR_EMBED_LINKED_GRAPHICS ), PAGE_POS_X + 6, PAGE_POS_Y + 82, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
547     maControlPages.push_back( aControlList );
548     DeactivatePage( 2 );
549     UpdateControlStatesPage2();
550 }
551 
552 // -----------------------------------------------------------------------------
553 
554 void OptimizerDialog::UpdateControlStatesPage3()
555 {
556     sal_Bool bConvertOLEObjects( GetConfigProperty( TK_OLEOptimization, sal_False ) );
557     sal_Int16 nOLEOptimizationType( GetConfigProperty( TK_OLEOptimizationType, (sal_Int16)0 ) );
558 
559     setControlProperty( TKGet( TK_CheckBox0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)bConvertOLEObjects ) );
560     setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) );
561     setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 0 ) ) );
562     setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) );
563     setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 1 ) ) );
564 }
565 void OptimizerDialog::InitPage3()
566 {
567     int nOLECount = 0;
568     Reference< XModel > xModel( mxController->getModel() );
569     Reference< XDrawPagesSupplier > xDrawPagesSupplier( xModel, UNO_QUERY_THROW );
570     Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
571     for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
572     {
573         Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
574         for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
575         {
576             const OUString sOLE2Shape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.OLE2Shape" ) );
577             Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
578             if ( xShape->getShapeType() == sOLE2Shape )
579                 nOLECount++;
580         }
581     }
582 
583     std::vector< rtl::OUString > aControlList;
584     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText0Pg2 ), getString( STR_OLE_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) );
585     aControlList.push_back( InsertCheckBox(  *this, TKGet( TK_CheckBox0Pg2 ), mxItemListener, getString( STR_OLE_REPLACE ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
586     aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton0Pg2 ), mxItemListener, getString( STR_ALL_OLE_OBJECTS ), PAGE_POS_X + 14, PAGE_POS_Y + 28, PAGE_WIDTH - 22, 8, sal_False, mnTabIndex++ ) );
587     aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton1Pg2 ), mxItemListener, getString( STR_ALIEN_OLE_OBJECTS_ONLY ), PAGE_POS_X + 14, PAGE_POS_Y + 40, PAGE_WIDTH - 22, 8, sal_False, mnTabIndex++ ) );
588     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText1Pg2 ), nOLECount ? getString( STR_OLE_OBJECTS_DESC ) : getString( STR_NO_OLE_OBJECTS_DESC ), PAGE_POS_X + 6, PAGE_POS_Y + 64, PAGE_WIDTH - 22, 50, sal_True, sal_False, mnTabIndex++ ) );
589     maControlPages.push_back( aControlList );
590     DeactivatePage( 3 );
591     UpdateControlStatesPage3();
592 }
593 
594 // -----------------------------------------------------------------------------
595 
596 static OUString ImpValueOfInMB( const sal_Int64& rVal, sal_Unicode nSeparator = '.' )
597 {
598     double fVal( static_cast<double>( rVal ) );
599     fVal /= ( 1 << 20 );
600     fVal += 0.05;
601     rtl::OUStringBuffer aVal( OUString::valueOf( fVal ) );
602     sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) );
603     if ( nX >= 0 )
604     {
605         aVal.setLength( nX + 2 );
606         aVal.setCharAt( nX, nSeparator );
607     }
608     aVal.append( OUString::createFromAscii( " MB" ) );
609     return aVal.makeStringAndClear();
610 }
611 
612 void OptimizerDialog::UpdateControlStatesPage4()
613 {
614     sal_Bool bSaveAs( GetConfigProperty( TK_SaveAs, sal_True ) );
615     if ( mbIsReadonly )
616     {
617         setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_False ) ) );
618         setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_True ) ) );
619     }
620     else
621     {
622         setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_False ) ) );
623         setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_True ) ) );
624     }
625     setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( sal_False ) );
626 
627     sal_uInt32 w;
628     Sequence< OUString > aItemList;
629     const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
630     if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
631     {
632         aItemList.realloc( rList.size() - 1 );
633         for ( w = 1; w < rList.size(); w++ )
634             aItemList[ w - 1 ] = rList[ w ].maName;
635     }
636     setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_StringItemList ), Any( aItemList ) );
637 
638     // now check if it is sensible to enable the combo box
639     sal_Bool bSaveSettingsEnabled = sal_True;
640     if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
641     {
642         for ( w = 1; w < rList.size(); w++ )
643         {
644             if ( rList[ w ] == rList[ 0 ] )
645             {
646                 bSaveSettingsEnabled = sal_False;
647                 break;
648             }
649         }
650     }
651     sal_Int16 nInt16 = 0;
652     getControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_State ) ) >>= nInt16;
653     setControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled ) );
654     setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled && nInt16 ) );
655 
656     std::vector< OUString > aSummaryStrings;
657 
658     // taking care of deleted slides
659     sal_Int32 nDeletedSlides = 0;
660     rtl::OUString aCustomShowName;
661     if ( getControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ) ) >>= nInt16 )
662     {
663         if ( nInt16 )
664         {
665             Sequence< short > aSelectedItems;
666             Sequence< OUString > aStringItemList;
667             Any aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_SelectedItems ) );
668             if ( aAny >>= aSelectedItems )
669             {
670                 if ( aSelectedItems.getLength() )
671                 {
672                     sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
673                     aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_StringItemList ) );
674                     if ( aAny >>= aStringItemList )
675                     {
676                         if ( aStringItemList.getLength() > nSelectedItem )
677                             SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) );
678                     }
679                 }
680             }
681         }
682     }
683     if ( aCustomShowName.getLength() )
684     {
685         std::vector< Reference< XDrawPage > > vNonUsedPageList;
686         PageCollector::CollectNonCustomShowPages( mxController->getModel(), aCustomShowName, vNonUsedPageList );
687         nDeletedSlides += vNonUsedPageList.size();
688     }
689     if ( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) )
690     {
691         if ( aCustomShowName.getLength() )
692         {
693             std::vector< Reference< XDrawPage > > vUsedPageList;
694             PageCollector::CollectCustomShowPages( mxController->getModel(), aCustomShowName, vUsedPageList );
695             std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
696             while( aIter != vUsedPageList.end() )
697             {
698                 Reference< XPropertySet > xPropSet( *aIter, UNO_QUERY_THROW );
699                 sal_Bool bVisible = sal_True;
700                 const OUString sVisible( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) );
701                 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
702                 {
703                     if (!bVisible )
704                         nDeletedSlides++;
705                 }
706                 aIter++;
707             }
708         }
709         else
710         {
711             Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
712             Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
713             for( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
714             {
715                 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
716                 Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY_THROW );
717 
718                 sal_Bool bVisible = sal_True;
719                 const OUString sVisible( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) );
720                 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
721                 {
722                     if (!bVisible )
723                         nDeletedSlides++;
724                 }
725             }
726         }
727     }
728     if ( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) )
729     {
730         std::vector< PageCollector::MasterPageEntity > aMasterPageList;
731         PageCollector::CollectMasterPages( mxController->getModel(), aMasterPageList );
732         Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
733         Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
734         std::vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() );
735         while( aIter != aMasterPageList.end() )
736         {
737             if ( !aIter->bUsed )
738                 nDeletedSlides++;
739             aIter++;
740         }
741     }
742     if ( nDeletedSlides > 1 )
743     {
744         OUString aStr( getString( STR_DELETE_SLIDES ) );
745         OUString aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%SLIDES" ) );
746         sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
747         if ( i >= 0 )
748             aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nDeletedSlides ) );
749         aSummaryStrings.push_back( aStr );
750     }
751 
752 // generating graphic compression info
753     sal_Int32 nGraphics = 0;
754     sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) );
755     sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
756     sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
757     GraphicSettings aGraphicSettings( bJPEGCompression, nJPEGQuality, GetConfigProperty( TK_RemoveCropArea, sal_False ),
758                                         nImageResolution, GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) );
759     GraphicCollector::CountGraphics( mxMSF, mxController->getModel(), aGraphicSettings, nGraphics );
760     if ( nGraphics > 1 )
761     {
762         OUString aStr( getString( STR_OPTIMIZE_IMAGES ) );
763         OUString aImagePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%IMAGES" ) );
764         OUString aQualityPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%QUALITY" ) );
765         OUString aResolutionPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%RESOLUTION" ) );
766         sal_Int32 i = aStr.indexOf( aImagePlaceholder, 0 );
767         if ( i >= 0 )
768             aStr = aStr.replaceAt( i, aImagePlaceholder.getLength(), OUString::valueOf( nGraphics ) );
769 
770         sal_Int32 j = aStr.indexOf( aQualityPlaceholder, 0 );
771         if ( j >= 0 )
772             aStr = aStr.replaceAt( j, aQualityPlaceholder.getLength(), OUString::valueOf( nJPEGQuality ) );
773 
774         sal_Int32 k = aStr.indexOf( aResolutionPlaceholder, 0 );
775         if ( k >= 0 )
776             aStr = aStr.replaceAt( k, aResolutionPlaceholder.getLength(), OUString::valueOf( nImageResolution ) );
777 
778         aSummaryStrings.push_back( aStr );
779     }
780 
781     if ( GetConfigProperty( TK_OLEOptimization, sal_False ) )
782     {
783         sal_Int32 nOLEReplacements = 0;
784         Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
785         Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
786         for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
787         {
788             Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
789             for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
790             {
791                 const OUString sOLE2Shape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.OLE2Shape" ) );
792                 Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
793                 if ( xShape->getShapeType() == sOLE2Shape )
794                     nOLEReplacements++;
795             }
796         }
797         if ( nOLEReplacements > 1 )
798         {
799             OUString aStr( getString( STR_CREATE_REPLACEMENT ) );
800             OUString aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%OLE" ) );
801             sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
802             if ( i >= 0 )
803                 aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nOLEReplacements ) );
804             aSummaryStrings.push_back( aStr );
805         }
806     }
807     while( aSummaryStrings.size() < 3 )
808         aSummaryStrings.push_back( OUString() );
809     setControlProperty( TKGet( TK_FixedText4Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 0 ] ) );
810     setControlProperty( TKGet( TK_FixedText5Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 1 ] ) );
811     setControlProperty( TKGet( TK_FixedText6Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 2 ] ) );
812 
813     sal_Int64 nCurrentFileSize = 0;
814     sal_Int64 nEstimatedFileSize = 0;
815     Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY );
816     if ( xStorable.is() && xStorable->hasLocation() )
817         nCurrentFileSize = PPPOptimizer::GetFileSize( xStorable->getLocation() );
818 
819     if ( nCurrentFileSize )
820     {
821         double fE = static_cast< double >( nCurrentFileSize );
822         if ( nImageResolution )
823         {
824             double v = ( static_cast< double >( nImageResolution ) + 75.0 ) / 300.0;
825             if ( v < 1.0 )
826                 fE *= v;
827         }
828         if ( bJPEGCompression )
829         {
830             double v = 0.75 - ( ( 100.0 - static_cast< double >( nJPEGQuality ) ) / 400.0 ) ;
831             fE *= v;
832         }
833         nEstimatedFileSize = static_cast< sal_Int64 >( fE );
834     }
835     sal_Unicode nSeparator = '.';
836     OUString aStr( getString( STR_FILESIZESEPARATOR ) );
837     if ( aStr.getLength() )
838         nSeparator = aStr[ 0 ];
839     setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nCurrentFileSize, nSeparator ) ) );
840     setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nEstimatedFileSize, nSeparator ) ) );
841     SetConfigProperty( TK_EstimatedFileSize, Any( nEstimatedFileSize ) );
842 }
843 
844 void OptimizerDialog::InitPage4()
845 {
846     {   // creating progress bar:
847         OUString pNames[] = {
848             TKGet( TK_Height ),
849             TKGet( TK_Name ),
850             TKGet( TK_PositionX ),
851             TKGet( TK_PositionY ),
852             TKGet( TK_ProgressValue ),
853             TKGet( TK_ProgressValueMax ),
854             TKGet( TK_ProgressValueMin ),
855             TKGet( TK_Width ) };
856 
857         Any pValues[] = {
858             Any( (sal_Int32)12 ),
859             Any( TKGet( STR_SAVE_AS ) ),
860             Any( (sal_Int32)( PAGE_POS_X + 6 ) ),
861             Any( (sal_Int32)( DIALOG_HEIGHT - 75 ) ),
862             Any( (sal_Int32)( 0 ) ),
863             Any( (sal_Int32)( 100 ) ),
864             Any( (sal_Int32)( 0 ) ),
865             Any( (sal_Int32)( PAGE_WIDTH - 12 ) ) };
866 
867         sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
868 
869         Sequence< rtl::OUString >   aNames( pNames, nCount );
870         Sequence< Any >             aValues( pValues, nCount );
871 
872         Reference< XMultiPropertySet > xMultiPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlProgressBarModel" ) ),
873             TKGet( TK_Progress ), aNames, aValues ), UNO_QUERY );
874     }
875     Reference< XTextListener > xTextListener;
876     Sequence< OUString > aItemList;
877     std::vector< rtl::OUString > aControlList;
878     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText0Pg4 ), getString( STR_SUMMARY_TITLE ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) );
879 //  aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator0Pg4 ), 0, PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 1 ) );
880 
881     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText4Pg4 ), OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, sal_False, sal_False, mnTabIndex++ ) );
882     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText5Pg4 ), OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 22, PAGE_WIDTH - 12, 8, sal_False, sal_False, mnTabIndex++ ) );
883     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText6Pg4 ), OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 30, PAGE_WIDTH - 12, 8, sal_False, sal_False, mnTabIndex++ ) );
884 
885     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText2Pg4 ), getString( STR_CURRENT_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 50, 88, 8, sal_False, sal_False, mnTabIndex++ ) );
886     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText7Pg4 ), OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 50, 30, 8, sal_False, sal_False, mnTabIndex++ ) );
887     setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) );
888     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText3Pg4 ), getString( STR_ESTIMATED_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 58, 88, 8, sal_False, sal_False, mnTabIndex++ ) );
889     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText8Pg4 ), OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 58, 30, 8, sal_False, sal_False, mnTabIndex++ ) );
890     setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) );
891 
892     aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton0Pg4 ), mxItemListener, getString(  STR_APPLY_TO_CURRENT ), PAGE_POS_X + 6, PAGE_POS_Y + 78, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) );
893     aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton1Pg4 ), mxItemListener, getString( STR_SAVE_AS ), PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) );
894     aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText1Pg4 ), OUString(), PAGE_POS_X + 6, DIALOG_HEIGHT - 87, PAGE_WIDTH - 12, 8, sal_True, sal_False, mnTabIndex++ ) );
895     aControlList.push_back( TKGet( TK_Progress ) );
896     aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator1Pg4 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 58, PAGE_WIDTH - 12, 1 ) );
897     aControlList.push_back( InsertCheckBox(  *this, TKGet( TK_CheckBox1Pg4 ), mxItemListener, getString( STR_SAVE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 47, 100, 8, mnTabIndex++ ) );
898     aControlList.push_back( InsertComboBox(  *this, TKGet( TK_ComboBox0Pg4 ), xTextListener, sal_True, aItemList, PAGE_POS_X + 106, DIALOG_HEIGHT - 48, 100, 12, mnTabIndex++ ) );
899     maControlPages.push_back( aControlList );
900     DeactivatePage( 4 );
901 
902     // creating a default session name that hasn't been used yet
903     OUString aSettingsName;
904     OUString aDefault( getString( STR_MY_SETTINGS ) );
905     sal_Int32 nSession = 1;
906     sal_uInt32 i;
907     const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
908     do
909     {
910         OUString aTemp( aDefault.concat( OUString::valueOf( nSession++ ) ) );
911         for ( i = 1; i < rList.size(); i++ )
912         {
913             if ( rList[ i ].maName == aTemp )
914                 break;
915         }
916         if ( i == rList.size() )
917             aSettingsName = aTemp;
918     }
919     while( !aSettingsName.getLength() );
920 
921     setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Text ), Any( aSettingsName ) );
922     setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) );
923     setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) );
924 
925     UpdateControlStatesPage4();
926 }
927 
928 // -----------------------------------------------------------------------------
929 void OptimizerDialog::EnablePage( sal_Int16 nStep )
930 {
931     std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
932     std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
933     while( aBeg != aEnd )
934         setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_True ) );
935 }
936 void OptimizerDialog::DisablePage( sal_Int16 nStep )
937 {
938     std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
939     std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
940     while( aBeg != aEnd )
941         setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_False ) );
942 }
943 void OptimizerDialog::ActivatePage( sal_Int16 nStep )
944 {
945     std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
946     std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
947     while( aBeg != aEnd )
948         setVisible( *aBeg++, sal_True );
949 }
950 void OptimizerDialog::DeactivatePage( sal_Int16 nStep )
951 {
952     std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
953     std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
954     while( aBeg != aEnd )
955         setVisible( *aBeg++, sal_False );
956 }
957