update dev300-m58
[ooovba.git] / sdext / source / minimizer / optimizerdialogcontrols.cxx
bloba93804dccc6f275705f94918c9f9c75882f21648
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: optimizerdialogcontrols.cxx,v $
11 * $Revision: 1.14 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #include "optimizerdialog.hxx"
37 // -------------------
38 // - OptimizerDialog -
39 // -------------------
40 #include "pppoptimizer.hxx"
41 #include "graphiccollector.hxx"
42 #include "pagecollector.hxx"
43 #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
44 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
45 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
46 #include <com/sun/star/awt/FontDescriptor.hpp>
47 #ifndef _COM_SUN_STAR_AWT_XFONTWEIGHT_HPP_
48 #include <com/sun/star/awt/FontWeight.hpp>
49 #endif
50 #include <rtl/ustrbuf.hxx>
52 using namespace ::rtl;
53 using namespace ::com::sun::star::awt;
54 using namespace ::com::sun::star::uno;
55 using namespace ::com::sun::star::util;
56 using namespace ::com::sun::star::lang;
57 using namespace ::com::sun::star::frame;
58 using namespace ::com::sun::star::beans;
59 using namespace ::com::sun::star::script;
60 using namespace ::com::sun::star::drawing;
61 using namespace ::com::sun::star::container;
62 using namespace ::com::sun::star::presentation;
64 // -----------------------------------------------------------------------------
66 void SetBold( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControl )
68 FontDescriptor aFontDescriptor;
69 if ( rOptimizerDialog.getControlProperty( rControl, TKGet( TK_FontDescriptor ) ) >>= aFontDescriptor )
71 aFontDescriptor.Weight = FontWeight::BOLD;
72 rOptimizerDialog.setControlProperty( rControl, TKGet( TK_FontDescriptor ), Any( aFontDescriptor ) );
76 // -----------------------------------------------------------------------------
78 rtl::OUString InsertSeparator( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, sal_Int32 nOrientation,
79 sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight )
81 OUString pNames[] = {
82 TKGet( TK_Height ),
83 TKGet( TK_Orientation ),
84 TKGet( TK_PositionX ),
85 TKGet( TK_PositionY ),
86 TKGet( TK_Step ),
87 TKGet( TK_Width ) };
89 Any pValues[] = {
90 Any( nHeight ),
91 Any( nOrientation ),
92 Any( nPosX ),
93 Any( nPosY ),
94 Any( sal_Int16( 0 ) ),
95 Any( nWidth ) };
97 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
99 Sequence< rtl::OUString > aNames( pNames, nCount );
100 Sequence< Any > aValues( pValues, nCount );
102 rOptimizerDialog.insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" ) ),
103 rControlName, aNames, aValues );
104 return rControlName;
107 // -----------------------------------------------------------------------------
109 rtl::OUString InsertButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, Reference< XActionListener >& xActionListener,
110 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex, sal_Bool bEnabled, PPPOptimizerTokenEnum nResID, sal_Int16 nPushButtonType )
112 OUString pNames[] = {
113 TKGet( TK_Enabled ),
114 TKGet( TK_Height ),
115 TKGet( TK_Label ),
116 TKGet( TK_PositionX ),
117 TKGet( TK_PositionY ),
118 TKGet( TK_PushButtonType ),
119 TKGet( TK_Step ),
120 TKGet( TK_TabIndex ),
121 TKGet( TK_Width ) };
123 Any pValues[] = {
124 Any( bEnabled ),
125 Any( nHeight ),
126 Any( rOptimizerDialog.getString( nResID ) ),
127 Any( nXPos ),
128 Any( nYPos ),
129 Any( nPushButtonType ),
130 Any( (sal_Int16)0 ),
131 Any( nTabIndex ),
132 Any( nWidth ) };
135 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
137 Sequence< rtl::OUString > aNames( pNames, nCount );
138 Sequence< Any > aValues( pValues, nCount );
140 rOptimizerDialog.insertButton( rControlName, xActionListener, aNames, aValues );
141 return rControlName;
144 // -----------------------------------------------------------------------------
146 rtl::OUString InsertFixedText( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControlName, const OUString& rLabel,
147 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Bool bBold, sal_Int16 nTabIndex )
149 OUString pNames[] = {
150 TKGet( TK_Height ),
151 TKGet( TK_Label ),
152 TKGet( TK_MultiLine ),
153 TKGet( TK_PositionX ),
154 TKGet( TK_PositionY ),
155 TKGet( TK_Step ),
156 TKGet( TK_TabIndex ),
157 TKGet( TK_Width ) };
159 Any pValues[] = {
160 Any( nHeight ),
161 Any( rLabel ),
162 Any( bMultiLine ),
163 Any( nXPos ),
164 Any( nYPos ),
165 Any( (sal_Int16)0 ),
166 Any( nTabIndex ),
167 Any( nWidth ) };
169 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
171 Sequence< rtl::OUString > aNames( pNames, nCount );
172 Sequence< Any > aValues( pValues, nCount );
174 rOptimizerDialog.insertFixedText( rControlName, aNames, aValues );
175 if ( bBold )
176 SetBold( rOptimizerDialog, rControlName );
177 return rControlName;
180 // -----------------------------------------------------------------------------
182 rtl::OUString InsertCheckBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
183 const Reference< XItemListener > xItemListener, const OUString& rLabel,
184 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
186 OUString pNames[] = {
187 TKGet( TK_Enabled ),
188 TKGet( TK_Height ),
189 TKGet( TK_Label ),
190 TKGet( TK_PositionX ),
191 TKGet( TK_PositionY ),
192 TKGet( TK_Step ),
193 TKGet( TK_TabIndex ),
194 TKGet( TK_Width ) };
196 Any pValues[] = {
197 Any( sal_True ),
198 Any( nHeight ),
199 Any( rLabel ),
200 Any( nXPos ),
201 Any( nYPos ),
202 Any( (sal_Int16)0 ),
203 Any( nTabIndex ),
204 Any( nWidth ) };
206 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
208 Sequence< rtl::OUString > aNames( pNames, nCount );
209 Sequence< Any > aValues( pValues, nCount );
211 Reference< XCheckBox > xCheckBox( rOptimizerDialog.insertCheckBox( rControlName, aNames, aValues ) );
212 if ( xItemListener.is() )
213 xCheckBox->addItemListener( xItemListener );
214 return rControlName;
217 // -----------------------------------------------------------------------------
219 rtl::OUString InsertFormattedField( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
220 const Reference< XTextListener > xTextListener, const Reference< XSpinListener > xSpinListener, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth,
221 double fEffectiveMin, double fEffectiveMax, sal_Int16 nTabIndex )
223 OUString pNames[] = {
224 TKGet( TK_EffectiveMax ),
225 TKGet( TK_EffectiveMin ),
226 TKGet( TK_Enabled ),
227 TKGet( TK_Height ),
228 TKGet( TK_PositionX ),
229 TKGet( TK_PositionY ),
230 TKGet( TK_Repeat ),
231 TKGet( TK_Spin ),
232 TKGet( TK_Step ),
233 TKGet( TK_TabIndex ),
234 TKGet( TK_Width ) };
236 Any pValues[] = {
237 Any( fEffectiveMax ),
238 Any( fEffectiveMin ),
239 Any( sal_True ),
240 Any( (sal_Int32)12 ),
241 Any( nXPos ),
242 Any( nYPos ),
243 Any( (sal_Bool)sal_True ),
244 Any( (sal_Bool)sal_True ),
245 Any( (sal_Int16)0 ),
246 Any( nTabIndex ),
247 Any( nWidth ) };
249 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
251 Sequence< rtl::OUString > aNames( pNames, nCount );
252 Sequence< Any > aValues( pValues, nCount );
254 Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertFormattedField( rControlName, aNames, aValues ), UNO_QUERY_THROW );
255 if ( xTextListener.is() )
256 xTextComponent->addTextListener( xTextListener );
257 if ( xSpinListener.is() )
259 Reference< XSpinField > xSpinField( xTextComponent, UNO_QUERY_THROW );
260 xSpinField->addSpinListener( xSpinListener );
262 return rControlName;
265 // -----------------------------------------------------------------------------
267 rtl::OUString InsertComboBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
268 const Reference< XTextListener > xTextListener, const sal_Bool bEnabled, const Sequence< OUString >& rItemList,
269 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
271 OUString pNames[] = {
272 TKGet( TK_Dropdown ),
273 TKGet( TK_Enabled ),
274 TKGet( TK_Height ),
275 TKGet( TK_LineCount ),
276 TKGet( TK_PositionX ),
277 TKGet( TK_PositionY ),
278 TKGet( TK_Step ),
279 TKGet( TK_StringItemList ),
280 TKGet( TK_TabIndex ),
281 TKGet( TK_Width ) };
283 Any pValues[] = {
284 Any( sal_True ),
285 Any( bEnabled ),
286 Any( nHeight ),
287 Any( (sal_Int16)8),
288 Any( nXPos ),
289 Any( nYPos ),
290 Any( (sal_Int16)0 ),
291 Any( rItemList ),
292 Any( nTabIndex ),
293 Any( nWidth ) };
295 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
297 Sequence< rtl::OUString > aNames( pNames, nCount );
298 Sequence< Any > aValues( pValues, nCount );
300 Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertComboBox( rControlName, aNames, aValues ), UNO_QUERY_THROW );
301 if ( xTextListener.is() )
302 xTextComponent->addTextListener( xTextListener );
303 return rControlName;
306 // -----------------------------------------------------------------------------
308 rtl::OUString InsertRadioButton( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControlName, const Reference< XItemListener > xItemListener,
309 const OUString& rLabel, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Int16 nTabIndex )
311 OUString pNames[] = {
312 TKGet( TK_Height ),
313 TKGet( TK_Label ),
314 TKGet( TK_MultiLine ),
315 TKGet( TK_PositionX ),
316 TKGet( TK_PositionY ),
317 TKGet( TK_Step ),
318 TKGet( TK_TabIndex ),
319 TKGet( TK_Width ) };
321 Any pValues[] = {
322 Any( nHeight ),
323 Any( rLabel ),
324 Any( bMultiLine ),
325 Any( nXPos ),
326 Any( nYPos ),
327 Any( (sal_Int16)0 ),
328 Any( nTabIndex ),
329 Any( nWidth ) };
331 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
333 Sequence< rtl::OUString > aNames( pNames, nCount );
334 Sequence< Any > aValues( pValues, nCount );
336 Reference< XRadioButton > xRadioButton( rOptimizerDialog.insertRadioButton( rControlName, aNames, aValues ) );
337 if ( xItemListener.is() )
338 xRadioButton->addItemListener( xItemListener );
339 return rControlName;
342 // -----------------------------------------------------------------------------
344 rtl::OUString InsertListBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
345 const Reference< XActionListener > xActionListener, const sal_Bool bEnabled, const Sequence< OUString >& rItemList,
346 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
348 OUString pNames[] = {
349 TKGet( TK_Dropdown ),
350 TKGet( TK_Enabled ),
351 TKGet( TK_Height ),
352 TKGet( TK_LineCount ),
353 TKGet( TK_MultiSelection ),
354 TKGet( TK_PositionX ),
355 TKGet( TK_PositionY ),
356 TKGet( TK_Step ),
357 TKGet( TK_StringItemList ),
358 TKGet( TK_TabIndex ),
359 TKGet( TK_Width ) };
361 Any pValues[] = {
362 Any( sal_True ),
363 Any( bEnabled ),
364 Any( nHeight ),
365 Any( (sal_Int16)8),
366 Any( sal_False ),
367 Any( nXPos ),
368 Any( nYPos ),
369 Any( (sal_Int16)0 ),
370 Any( rItemList ),
371 Any( nTabIndex ),
372 Any( nWidth ) };
374 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
376 Sequence< rtl::OUString > aNames( pNames, nCount );
377 Sequence< Any > aValues( pValues, nCount );
379 Reference< XListBox > xListBox( rOptimizerDialog.insertListBox( rControlName, aNames, aValues ) );
380 if ( xListBox.is() )
381 xListBox->addActionListener( xActionListener );
382 return rControlName;
385 // -----------------------------------------------------------------------------
387 void OptimizerDialog::InitNavigationBar()
389 sal_Int32 nCancelPosX = OD_DIALOG_WIDTH - BUTTON_WIDTH - 6;
390 sal_Int32 nFinishPosX = nCancelPosX - 6 - BUTTON_WIDTH;
391 sal_Int32 nNextPosX = nFinishPosX - 6 - BUTTON_WIDTH;
392 sal_Int32 nBackPosX = nNextPosX - 3 - BUTTON_WIDTH;
394 InsertSeparator( *this, TKGet( TK_lnNavSep1 ), 0, 0, DIALOG_HEIGHT - 26, OD_DIALOG_WIDTH, 1 );
395 InsertSeparator( *this, TKGet( TK_lnNavSep2 ), 1, 85, 0, 1, BUTTON_POS_Y - 6 );
397 InsertButton( *this, TKGet( TK_btnNavHelp ), mxActionListener, 8, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_HELP, PushButtonType_STANDARD );
398 InsertButton( *this, TKGet( TK_btnNavBack ), mxActionListener, nBackPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_False, STR_BACK, PushButtonType_STANDARD );
399 InsertButton( *this, TKGet( TK_btnNavNext ), mxActionListener, nNextPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_NEXT, PushButtonType_STANDARD );
400 InsertButton( *this, TKGet( TK_btnNavFinish ), mxActionListener, nFinishPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_FINISH, PushButtonType_STANDARD );
401 InsertButton( *this, TKGet( TK_btnNavCancel ), mxActionListener, nCancelPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_CANCEL, PushButtonType_STANDARD );
403 setControlProperty( TKGet( TK_btnNavNext ), TKGet( TK_DefaultButton ), Any( sal_True ) );
406 // -----------------------------------------------------------------------------
408 void OptimizerDialog::UpdateControlStatesPage0()
410 sal_uInt32 i;
411 short nSelectedItem = -1;
412 Sequence< OUString > aItemList;
413 const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
414 if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
416 aItemList.realloc( rList.size() - 1 );
417 for ( i = 1; i < rList.size(); i++ )
419 aItemList[ i - 1 ] = rList[ i ].maName;
420 if ( nSelectedItem < 0 )
422 if ( rList[ i ] == rList[ 0 ] )
423 nSelectedItem = static_cast< short >( i - 1 );
427 sal_Bool bRemoveButtonEnabled = sal_False;
428 Sequence< short > aSelectedItems;
429 if ( nSelectedItem >= 0 )
431 aSelectedItems.realloc( 1 );
432 aSelectedItems[ 0 ] = nSelectedItem;
433 if ( nSelectedItem > 2 ) // only allowing to delete custom themes, the first can|t be deleted
434 bRemoveButtonEnabled = sal_True;
436 setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_StringItemList ), Any( aItemList ) );
437 setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_SelectedItems ), Any( aSelectedItems ) );
438 setControlProperty( TKGet( TK_Button0Pg0 ), TKGet( TK_Enabled ), Any( bRemoveButtonEnabled ) );
440 void OptimizerDialog::InitPage0()
442 Sequence< OUString > aItemList;
443 std::vector< rtl::OUString > aControlList;
444 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++ ) );
445 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++ ) );
446 aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator1Pg0 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 66, PAGE_WIDTH - 12, 1 ) );
447 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++ ) );
448 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++ ) );
449 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 ) );
450 maControlPages.push_back( aControlList );
451 DeactivatePage( 0 );
452 UpdateControlStatesPage0();
455 // -----------------------------------------------------------------------------
457 void OptimizerDialog::UpdateControlStatesPage1()
459 sal_Bool bDeleteUnusedMasterPages( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) );
460 sal_Bool bDeleteHiddenSlides( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) );
461 sal_Bool bDeleteNotesPages( GetConfigProperty( TK_DeleteNotesPages, sal_False ) );
463 setControlProperty( TKGet( TK_CheckBox0Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteUnusedMasterPages ) );
464 setControlProperty( TKGet( TK_CheckBox1Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteNotesPages ) );
465 setControlProperty( TKGet( TK_CheckBox2Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteHiddenSlides ) );
467 void OptimizerDialog::InitPage1()
469 Sequence< OUString > aCustomShowList;
470 Reference< XModel > xModel( mxController->getModel() );
471 if ( xModel.is() )
473 Reference< XCustomPresentationSupplier > aXCPSup( xModel, UNO_QUERY_THROW );
474 Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
475 if ( aXCont.is() )
476 aCustomShowList = aXCont->getElementNames();
478 std::vector< rtl::OUString > aControlList;
479 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++ ) );
480 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++ ) );
481 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++ ) );
482 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++ ) );
483 aControlList.push_back( InsertListBox( *this, TKGet( TK_ListBox0Pg3 ), mxActionListener, sal_True, aCustomShowList, PAGE_POS_X + 14, PAGE_POS_Y + 54, 150, 12, mnTabIndex++ ) );
484 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++ ) );
485 maControlPages.push_back( aControlList );
486 DeactivatePage( 1 );
488 setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ), Any( sal_False ) );
489 setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_Enabled ), Any( aCustomShowList.getLength() != 0 ) );
490 setControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_Enabled ), Any( sal_False ) );
492 UpdateControlStatesPage1();
495 // -----------------------------------------------------------------------------
497 void OptimizerDialog::UpdateControlStatesPage2()
499 sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) );
500 sal_Bool bRemoveCropArea( GetConfigProperty( TK_RemoveCropArea, sal_False ) );
501 sal_Bool bEmbedLinkedGraphics( GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) );
502 sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
504 sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
506 sal_Int32 nI0, nI1, nI2, nI3;
507 nI0 = nI1 = nI2 = nI3 = 0;
508 OUString aResolutionText;
509 Sequence< OUString > aResolutionItemList( 4 );
510 aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
511 aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
512 aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
513 aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
514 nI0 = nI1 = nI2 = nI3 = 0;
515 if ( getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI0 ).toInt32() == nImageResolution )
516 aResolutionText = aResolutionItemList[ 0 ];
517 else if ( getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI1 ).toInt32() == nImageResolution )
518 aResolutionText = aResolutionItemList[ 1 ];
519 else if ( getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI2 ).toInt32() == nImageResolution )
520 aResolutionText = aResolutionItemList[ 2 ];
521 else if ( getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI3 ).toInt32() == nImageResolution )
522 aResolutionText = aResolutionItemList[ 3 ];
523 if ( !aResolutionText.getLength() )
524 aResolutionText = OUString::valueOf( nImageResolution );
526 setControlProperty( TKGet( TK_RadioButton0Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_True ) ) );
527 setControlProperty( TKGet( TK_RadioButton1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_False ) ) );
528 setControlProperty( TKGet( TK_FixedText1Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) );
529 setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) );
530 setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( (double)nJPEGQuality ) );
531 setControlProperty( TKGet( TK_CheckBox1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bRemoveCropArea ) );
532 setControlProperty( TKGet( TK_ComboBox0Pg1 ), TKGet( TK_Text ), Any( aResolutionText ) );
533 setControlProperty( TKGet( TK_CheckBox2Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bEmbedLinkedGraphics ) );
535 void OptimizerDialog::InitPage2()
537 sal_Int32 nI0, nI1, nI2, nI3;
538 nI0 = nI1 = nI2 = nI3 = 0;
539 Sequence< OUString > aResolutionItemList( 4 );
540 aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
541 aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
542 aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
543 aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
545 std::vector< rtl::OUString > aControlList;
546 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++ ) );
547 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++ ) );
548 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++ ) );
549 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++ ) );
550 aControlList.push_back( InsertFormattedField( *this, TKGet( TK_FormattedField0Pg1 ), mxTextListenerFormattedField0Pg1, mxSpinListenerFormattedField0Pg1, PAGE_POS_X + 106, PAGE_POS_Y + 38, 50, 0, 100, mnTabIndex++ ) );
551 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++ ) );
552 aControlList.push_back( InsertComboBox( *this, TKGet( TK_ComboBox0Pg1 ), mxTextListenerComboBox0Pg1, sal_True, aResolutionItemList, PAGE_POS_X + 106, PAGE_POS_Y + 52, 100, 12, mnTabIndex++ ) );
553 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++ ) );
554 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++ ) );
555 maControlPages.push_back( aControlList );
556 DeactivatePage( 2 );
557 UpdateControlStatesPage2();
560 // -----------------------------------------------------------------------------
562 void OptimizerDialog::UpdateControlStatesPage3()
564 sal_Bool bConvertOLEObjects( GetConfigProperty( TK_OLEOptimization, sal_False ) );
565 sal_Int16 nOLEOptimizationType( GetConfigProperty( TK_OLEOptimizationType, (sal_Int16)0 ) );
567 setControlProperty( TKGet( TK_CheckBox0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)bConvertOLEObjects ) );
568 setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) );
569 setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 0 ) ) );
570 setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) );
571 setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 1 ) ) );
573 void OptimizerDialog::InitPage3()
575 int nOLECount = 0;
576 Reference< XModel > xModel( mxController->getModel() );
577 Reference< XDrawPagesSupplier > xDrawPagesSupplier( xModel, UNO_QUERY_THROW );
578 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
579 for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
581 Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
582 for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
584 const OUString sOLE2Shape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.OLE2Shape" ) );
585 Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
586 if ( xShape->getShapeType() == sOLE2Shape )
587 nOLECount++;
591 std::vector< rtl::OUString > aControlList;
592 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++ ) );
593 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++ ) );
594 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++ ) );
595 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++ ) );
596 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++ ) );
597 maControlPages.push_back( aControlList );
598 DeactivatePage( 3 );
599 UpdateControlStatesPage3();
602 // -----------------------------------------------------------------------------
604 static OUString ImpValueOfInMB( const sal_Int64& rVal, sal_Unicode nSeparator = '.' )
606 double fVal( static_cast<double>( rVal ) );
607 fVal /= ( 1 << 20 );
608 fVal += 0.05;
609 rtl::OUStringBuffer aVal( OUString::valueOf( fVal ) );
610 sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) );
611 if ( nX >= 0 )
613 aVal.setLength( nX + 2 );
614 aVal.setCharAt( nX, nSeparator );
616 aVal.append( OUString::createFromAscii( " MB" ) );
617 return aVal.makeStringAndClear();
620 void OptimizerDialog::UpdateControlStatesPage4()
622 sal_Bool bSaveAs( GetConfigProperty( TK_SaveAs, sal_True ) );
623 if ( mbIsReadonly )
625 setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_False ) ) );
626 setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_True ) ) );
628 else
630 setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_False ) ) );
631 setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_True ) ) );
633 setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( sal_False ) );
635 sal_uInt32 w;
636 Sequence< OUString > aItemList;
637 const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
638 if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
640 aItemList.realloc( rList.size() - 1 );
641 for ( w = 1; w < rList.size(); w++ )
642 aItemList[ w - 1 ] = rList[ w ].maName;
644 setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_StringItemList ), Any( aItemList ) );
646 // now check if it is sensible to enable the combo box
647 sal_Bool bSaveSettingsEnabled = sal_True;
648 if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
650 for ( w = 1; w < rList.size(); w++ )
652 if ( rList[ w ] == rList[ 0 ] )
654 bSaveSettingsEnabled = sal_False;
655 break;
659 sal_Int16 nInt16 = 0;
660 getControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_State ) ) >>= nInt16;
661 setControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled ) );
662 setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled && nInt16 ) );
664 std::vector< OUString > aSummaryStrings;
666 // taking care of deleted slides
667 sal_Int32 nDeletedSlides = 0;
668 rtl::OUString aCustomShowName;
669 if ( getControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ) ) >>= nInt16 )
671 if ( nInt16 )
673 Sequence< short > aSelectedItems;
674 Sequence< OUString > aStringItemList;
675 Any aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_SelectedItems ) );
676 if ( aAny >>= aSelectedItems )
678 if ( aSelectedItems.getLength() )
680 sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
681 aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_StringItemList ) );
682 if ( aAny >>= aStringItemList )
684 if ( aStringItemList.getLength() > nSelectedItem )
685 SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) );
691 if ( aCustomShowName.getLength() )
693 std::vector< Reference< XDrawPage > > vNonUsedPageList;
694 PageCollector::CollectNonCustomShowPages( mxController->getModel(), aCustomShowName, vNonUsedPageList );
695 nDeletedSlides += vNonUsedPageList.size();
697 if ( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) )
699 if ( aCustomShowName.getLength() )
701 std::vector< Reference< XDrawPage > > vUsedPageList;
702 PageCollector::CollectCustomShowPages( mxController->getModel(), aCustomShowName, vUsedPageList );
703 std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
704 while( aIter != vUsedPageList.end() )
706 Reference< XPropertySet > xPropSet( *aIter, UNO_QUERY_THROW );
707 sal_Bool bVisible = sal_True;
708 const OUString sVisible( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) );
709 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
711 if (!bVisible )
712 nDeletedSlides++;
714 aIter++;
717 else
719 Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
720 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
721 for( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
723 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
724 Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY_THROW );
726 sal_Bool bVisible = sal_True;
727 const OUString sVisible( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) );
728 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
730 if (!bVisible )
731 nDeletedSlides++;
736 if ( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) )
738 std::vector< PageCollector::MasterPageEntity > aMasterPageList;
739 PageCollector::CollectMasterPages( mxController->getModel(), aMasterPageList );
740 Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
741 Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
742 std::vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() );
743 while( aIter != aMasterPageList.end() )
745 if ( !aIter->bUsed )
746 nDeletedSlides++;
747 aIter++;
750 if ( nDeletedSlides > 1 )
752 OUString aStr( getString( STR_DELETE_SLIDES ) );
753 OUString aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%SLIDES" ) );
754 sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
755 if ( i >= 0 )
756 aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nDeletedSlides ) );
757 aSummaryStrings.push_back( aStr );
760 // generating graphic compression info
761 sal_Int32 nGraphics = 0;
762 sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) );
763 sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
764 sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
765 GraphicSettings aGraphicSettings( bJPEGCompression, nJPEGQuality, GetConfigProperty( TK_RemoveCropArea, sal_False ),
766 nImageResolution, GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) );
767 GraphicCollector::CountGraphics( mxMSF, mxController->getModel(), aGraphicSettings, nGraphics );
768 if ( nGraphics > 1 )
770 OUString aStr( getString( STR_OPTIMIZE_IMAGES ) );
771 OUString aImagePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%IMAGES" ) );
772 OUString aQualityPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%QUALITY" ) );
773 OUString aResolutionPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%RESOLUTION" ) );
774 sal_Int32 i = aStr.indexOf( aImagePlaceholder, 0 );
775 if ( i >= 0 )
776 aStr = aStr.replaceAt( i, aImagePlaceholder.getLength(), OUString::valueOf( nGraphics ) );
778 sal_Int32 j = aStr.indexOf( aQualityPlaceholder, 0 );
779 if ( j >= 0 )
780 aStr = aStr.replaceAt( j, aQualityPlaceholder.getLength(), OUString::valueOf( nJPEGQuality ) );
782 sal_Int32 k = aStr.indexOf( aResolutionPlaceholder, 0 );
783 if ( k >= 0 )
784 aStr = aStr.replaceAt( k, aResolutionPlaceholder.getLength(), OUString::valueOf( nImageResolution ) );
786 aSummaryStrings.push_back( aStr );
789 if ( GetConfigProperty( TK_OLEOptimization, sal_False ) )
791 sal_Int32 nOLEReplacements = 0;
792 Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
793 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
794 for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
796 Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
797 for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
799 const OUString sOLE2Shape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.OLE2Shape" ) );
800 Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
801 if ( xShape->getShapeType() == sOLE2Shape )
802 nOLEReplacements++;
805 if ( nOLEReplacements > 1 )
807 OUString aStr( getString( STR_CREATE_REPLACEMENT ) );
808 OUString aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%OLE" ) );
809 sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
810 if ( i >= 0 )
811 aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nOLEReplacements ) );
812 aSummaryStrings.push_back( aStr );
815 while( aSummaryStrings.size() < 3 )
816 aSummaryStrings.push_back( OUString() );
817 setControlProperty( TKGet( TK_FixedText4Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 0 ] ) );
818 setControlProperty( TKGet( TK_FixedText5Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 1 ] ) );
819 setControlProperty( TKGet( TK_FixedText6Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 2 ] ) );
821 sal_Int64 nCurrentFileSize = 0;
822 sal_Int64 nEstimatedFileSize = 0;
823 Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY );
824 if ( xStorable.is() && xStorable->hasLocation() )
825 nCurrentFileSize = PPPOptimizer::GetFileSize( xStorable->getLocation() );
827 if ( nCurrentFileSize )
829 double fE = static_cast< double >( nCurrentFileSize );
830 if ( nImageResolution )
832 double v = ( static_cast< double >( nImageResolution ) + 75.0 ) / 300.0;
833 if ( v < 1.0 )
834 fE *= v;
836 if ( bJPEGCompression )
838 double v = 0.75 - ( ( 100.0 - static_cast< double >( nJPEGQuality ) ) / 400.0 ) ;
839 fE *= v;
841 nEstimatedFileSize = static_cast< sal_Int64 >( fE );
843 sal_Unicode nSeparator = '.';
844 OUString aStr( getString( STR_FILESIZESEPARATOR ) );
845 if ( aStr.getLength() )
846 nSeparator = aStr[ 0 ];
847 setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nCurrentFileSize, nSeparator ) ) );
848 setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nEstimatedFileSize, nSeparator ) ) );
849 SetConfigProperty( TK_EstimatedFileSize, Any( nEstimatedFileSize ) );
852 void OptimizerDialog::InitPage4()
854 { // creating progress bar:
855 OUString pNames[] = {
856 TKGet( TK_Height ),
857 TKGet( TK_Name ),
858 TKGet( TK_PositionX ),
859 TKGet( TK_PositionY ),
860 TKGet( TK_ProgressValue ),
861 TKGet( TK_ProgressValueMax ),
862 TKGet( TK_ProgressValueMin ),
863 TKGet( TK_Width ) };
865 Any pValues[] = {
866 Any( (sal_Int32)12 ),
867 Any( TKGet( STR_SAVE_AS ) ),
868 Any( (sal_Int32)( PAGE_POS_X + 6 ) ),
869 Any( (sal_Int32)( DIALOG_HEIGHT - 75 ) ),
870 Any( (sal_Int32)( 0 ) ),
871 Any( (sal_Int32)( 100 ) ),
872 Any( (sal_Int32)( 0 ) ),
873 Any( (sal_Int32)( PAGE_WIDTH - 12 ) ) };
875 sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
877 Sequence< rtl::OUString > aNames( pNames, nCount );
878 Sequence< Any > aValues( pValues, nCount );
880 Reference< XMultiPropertySet > xMultiPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlProgressBarModel" ) ),
881 TKGet( TK_Progress ), aNames, aValues ), UNO_QUERY );
883 Reference< XTextListener > xTextListener;
884 Sequence< OUString > aItemList;
885 std::vector< rtl::OUString > aControlList;
886 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++ ) );
887 // aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator0Pg4 ), 0, PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 1 ) );
889 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++ ) );
890 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++ ) );
891 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++ ) );
893 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++ ) );
894 aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText7Pg4 ), OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 50, 30, 8, sal_False, sal_False, mnTabIndex++ ) );
895 setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) );
896 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++ ) );
897 aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText8Pg4 ), OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 58, 30, 8, sal_False, sal_False, mnTabIndex++ ) );
898 setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) );
900 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++ ) );
901 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++ ) );
902 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++ ) );
903 aControlList.push_back( TKGet( TK_Progress ) );
904 aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator1Pg4 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 58, PAGE_WIDTH - 12, 1 ) );
905 aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox1Pg4 ), mxItemListener, getString( STR_SAVE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 47, 100, 8, mnTabIndex++ ) );
906 aControlList.push_back( InsertComboBox( *this, TKGet( TK_ComboBox0Pg4 ), xTextListener, sal_True, aItemList, PAGE_POS_X + 106, DIALOG_HEIGHT - 48, 100, 12, mnTabIndex++ ) );
907 maControlPages.push_back( aControlList );
908 DeactivatePage( 4 );
910 // creating a default session name that hasn't been used yet
911 OUString aSettingsName;
912 OUString aDefault( getString( STR_MY_SETTINGS ) );
913 sal_Int32 nSession = 1;
914 sal_uInt32 i;
915 const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
918 OUString aTemp( aDefault.concat( OUString::valueOf( nSession++ ) ) );
919 for ( i = 1; i < rList.size(); i++ )
921 if ( rList[ i ].maName == aTemp )
922 break;
924 if ( i == rList.size() )
925 aSettingsName = aTemp;
927 while( !aSettingsName.getLength() );
929 setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Text ), Any( aSettingsName ) );
930 setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) );
931 setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) );
933 UpdateControlStatesPage4();
936 // -----------------------------------------------------------------------------
937 void OptimizerDialog::EnablePage( sal_Int16 nStep )
939 std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
940 std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
941 while( aBeg != aEnd )
942 setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_True ) );
944 void OptimizerDialog::DisablePage( sal_Int16 nStep )
946 std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
947 std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
948 while( aBeg != aEnd )
949 setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_False ) );
951 void OptimizerDialog::ActivatePage( sal_Int16 nStep )
953 std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
954 std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
955 while( aBeg != aEnd )
956 setVisible( *aBeg++, sal_True );
958 void OptimizerDialog::DeactivatePage( sal_Int16 nStep )
960 std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
961 std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
962 while( aBeg != aEnd )
963 setVisible( *aBeg++, sal_False );