fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sdext / source / minimizer / optimizerdialogcontrols.cxx
blobe8d3eb09bb21e808927c6e283315ad76ba8768af
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "optimizerdialog.hxx"
24 // - OptimizerDialog -
26 #include "pppoptimizer.hxx"
27 #include "graphiccollector.hxx"
28 #include "pagecollector.hxx"
29 #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
30 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
31 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
32 #include <com/sun/star/awt/FontDescriptor.hpp>
33 #include <com/sun/star/awt/FontWeight.hpp>
34 #include <rtl/ustrbuf.hxx>
35 #include <sal/macros.h>
37 using namespace ::com::sun::star::awt;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::util;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::frame;
42 using namespace ::com::sun::star::beans;
43 using namespace ::com::sun::star::script;
44 using namespace ::com::sun::star::drawing;
45 using namespace ::com::sun::star::container;
46 using namespace ::com::sun::star::presentation;
50 void SetBold( OptimizerDialog& rOptimizerDialog, const OUString& rControl )
52 FontDescriptor aFontDescriptor;
53 if ( rOptimizerDialog.getControlProperty( rControl, "FontDescriptor" ) >>= aFontDescriptor )
55 aFontDescriptor.Weight = FontWeight::BOLD;
56 rOptimizerDialog.setControlProperty( rControl, "FontDescriptor", Any( aFontDescriptor ) );
62 OUString InsertSeparator( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, sal_Int32 nOrientation,
63 sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight )
65 OUString pNames[] = {
66 OUString("Height"),
67 OUString("Orientation"),
68 OUString("PositionX"),
69 OUString("PositionY"),
70 OUString("Step"),
71 OUString("Width") };
73 Any pValues[] = {
74 Any( nHeight ),
75 Any( nOrientation ),
76 Any( nPosX ),
77 Any( nPosY ),
78 Any( sal_Int16( 0 ) ),
79 Any( nWidth ) };
81 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
83 Sequence< OUString > aNames( pNames, nCount );
84 Sequence< Any > aValues( pValues, nCount );
86 rOptimizerDialog.insertControlModel( OUString( "com.sun.star.awt.UnoControlFixedLineModel" ),
87 rControlName, aNames, aValues );
88 return rControlName;
93 OUString InsertButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, Reference< XActionListener >& xActionListener,
94 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex, bool bEnabled, PPPOptimizerTokenEnum nResID, sal_Int16 nPushButtonType )
96 OUString pNames[] = {
97 OUString("Enabled"),
98 OUString("Height"),
99 OUString("Label"),
100 OUString("PositionX"),
101 OUString("PositionY"),
102 OUString("PushButtonType"),
103 OUString("Step"),
104 OUString("TabIndex"),
105 OUString("Width") };
107 Any pValues[] = {
108 Any( bEnabled ),
109 Any( nHeight ),
110 Any( rOptimizerDialog.getString( nResID ) ),
111 Any( nXPos ),
112 Any( nYPos ),
113 Any( nPushButtonType ),
114 Any( (sal_Int16)0 ),
115 Any( nTabIndex ),
116 Any( nWidth ) };
119 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
121 Sequence< OUString > aNames( pNames, nCount );
122 Sequence< Any > aValues( pValues, nCount );
124 rOptimizerDialog.insertButton( rControlName, xActionListener, aNames, aValues );
125 return rControlName;
130 OUString InsertFixedText( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, const OUString& rLabel,
131 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, bool bMultiLine, bool bBold, sal_Int16 nTabIndex )
133 OUString pNames[] = {
134 OUString("Height"),
135 OUString("Label"),
136 OUString("MultiLine"),
137 OUString("PositionX"),
138 OUString("PositionY"),
139 OUString("Step"),
140 OUString("TabIndex"),
141 OUString("Width") };
143 Any pValues[] = {
144 Any( nHeight ),
145 Any( rLabel ),
146 Any( bMultiLine ),
147 Any( nXPos ),
148 Any( nYPos ),
149 Any( (sal_Int16)0 ),
150 Any( nTabIndex ),
151 Any( nWidth ) };
153 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
155 Sequence< OUString > aNames( pNames, nCount );
156 Sequence< Any > aValues( pValues, nCount );
158 rOptimizerDialog.insertFixedText( rControlName, aNames, aValues );
159 if ( bBold )
160 SetBold( rOptimizerDialog, rControlName );
161 return rControlName;
166 OUString InsertCheckBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
167 const Reference< XItemListener >& xItemListener, const OUString& rLabel,
168 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
170 OUString pNames[] = {
171 OUString("Enabled"),
172 OUString("Height"),
173 OUString("Label"),
174 OUString("PositionX"),
175 OUString("PositionY"),
176 OUString("Step"),
177 OUString("TabIndex"),
178 OUString("Width") };
180 Any pValues[] = {
181 Any( true ),
182 Any( nHeight ),
183 Any( rLabel ),
184 Any( nXPos ),
185 Any( nYPos ),
186 Any( (sal_Int16)0 ),
187 Any( nTabIndex ),
188 Any( nWidth ) };
190 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
192 Sequence< OUString > aNames( pNames, nCount );
193 Sequence< Any > aValues( pValues, nCount );
195 Reference< XCheckBox > xCheckBox( rOptimizerDialog.insertCheckBox( rControlName, aNames, aValues ) );
196 if ( xItemListener.is() )
197 xCheckBox->addItemListener( xItemListener );
198 return rControlName;
203 OUString InsertFormattedField( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
204 const Reference< XTextListener >& xTextListener, const Reference< XSpinListener >& xSpinListener, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth,
205 double fEffectiveMin, double fEffectiveMax, sal_Int16 nTabIndex )
207 OUString pNames[] = {
208 OUString("EffectiveMax"),
209 OUString("EffectiveMin"),
210 OUString("Enabled"),
211 OUString("Height"),
212 OUString("PositionX"),
213 OUString("PositionY"),
214 OUString("Repeat"),
215 OUString("Spin"),
216 OUString("Step"),
217 OUString("TabIndex"),
218 OUString("Width") };
220 Any pValues[] = {
221 Any( fEffectiveMax ),
222 Any( fEffectiveMin ),
223 Any( true ),
224 Any( (sal_Int32)12 ),
225 Any( nXPos ),
226 Any( nYPos ),
227 Any( true ),
228 Any( true ),
229 Any( (sal_Int16)0 ),
230 Any( nTabIndex ),
231 Any( nWidth ) };
233 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
235 Sequence< OUString > aNames( pNames, nCount );
236 Sequence< Any > aValues( pValues, nCount );
238 Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertFormattedField( rControlName, aNames, aValues ), UNO_QUERY_THROW );
239 if ( xTextListener.is() )
240 xTextComponent->addTextListener( xTextListener );
241 if ( xSpinListener.is() )
243 Reference< XSpinField > xSpinField( xTextComponent, UNO_QUERY_THROW );
244 xSpinField->addSpinListener( xSpinListener );
246 return rControlName;
251 OUString InsertComboBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
252 const Reference< XTextListener >& rTextListener, const bool bEnabled, const Sequence< OUString >& rItemList,
253 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
255 OUString pNames[] = {
256 OUString("Dropdown"),
257 OUString("Enabled"),
258 OUString("Height"),
259 OUString("LineCount"),
260 OUString("PositionX"),
261 OUString("PositionY"),
262 OUString("Step"),
263 OUString("StringItemList"),
264 OUString("TabIndex"),
265 OUString("Width") };
267 Any pValues[] = {
268 Any( true ),
269 Any( bEnabled ),
270 Any( nHeight ),
271 Any( (sal_Int16)8),
272 Any( nXPos ),
273 Any( nYPos ),
274 Any( (sal_Int16)0 ),
275 Any( rItemList ),
276 Any( nTabIndex ),
277 Any( nWidth ) };
279 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
281 Sequence< OUString > aNames( pNames, nCount );
282 Sequence< Any > aValues( pValues, nCount );
284 Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertComboBox( rControlName, aNames, aValues ), UNO_QUERY_THROW );
285 if ( rTextListener.is() )
286 xTextComponent->addTextListener( rTextListener );
287 return rControlName;
292 OUString InsertRadioButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, const Reference< XItemListener >& rItemListener,
293 const OUString& rLabel, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, bool bMultiLine, sal_Int16 nTabIndex )
295 OUString pNames[] = {
296 OUString("Height"),
297 OUString("Label"),
298 OUString("MultiLine"),
299 OUString("PositionX"),
300 OUString("PositionY"),
301 OUString("Step"),
302 OUString("TabIndex"),
303 OUString("Width") };
305 Any pValues[] = {
306 Any( nHeight ),
307 Any( rLabel ),
308 Any( bMultiLine ),
309 Any( nXPos ),
310 Any( nYPos ),
311 Any( (sal_Int16)0 ),
312 Any( nTabIndex ),
313 Any( nWidth ) };
315 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
317 Sequence< OUString > aNames( pNames, nCount );
318 Sequence< Any > aValues( pValues, nCount );
320 Reference< XRadioButton > xRadioButton( rOptimizerDialog.insertRadioButton( rControlName, aNames, aValues ) );
321 if ( rItemListener.is() )
322 xRadioButton->addItemListener( rItemListener );
323 return rControlName;
328 OUString InsertListBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
329 const Reference< XActionListener >& rActionListener, const bool bEnabled, const Sequence< OUString >& rItemList,
330 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
332 OUString pNames[] = {
333 OUString("Dropdown"),
334 OUString("Enabled"),
335 OUString("Height"),
336 OUString("LineCount"),
337 OUString("MultiSelection"),
338 OUString("PositionX"),
339 OUString("PositionY"),
340 OUString("Step"),
341 OUString("StringItemList"),
342 OUString("TabIndex"),
343 OUString("Width") };
345 Any pValues[] = {
346 Any( true ),
347 Any( bEnabled ),
348 Any( nHeight ),
349 Any( (sal_Int16)8),
350 Any( false ),
351 Any( nXPos ),
352 Any( nYPos ),
353 Any( (sal_Int16)0 ),
354 Any( rItemList ),
355 Any( nTabIndex ),
356 Any( nWidth ) };
358 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
360 Sequence< OUString > aNames( pNames, nCount );
361 Sequence< Any > aValues( pValues, nCount );
363 Reference< XListBox > xListBox( rOptimizerDialog.insertListBox( rControlName, aNames, aValues ) );
364 if ( xListBox.is() )
365 xListBox->addActionListener( rActionListener );
366 return rControlName;
371 void OptimizerDialog::InitNavigationBar()
373 sal_Int32 nCancelPosX = OD_DIALOG_WIDTH - BUTTON_WIDTH - 6;
374 sal_Int32 nFinishPosX = nCancelPosX - 6 - BUTTON_WIDTH;
375 sal_Int32 nNextPosX = nFinishPosX - 6 - BUTTON_WIDTH;
376 sal_Int32 nBackPosX = nNextPosX - 3 - BUTTON_WIDTH;
378 InsertSeparator( *this, "lnNavSep1", 0, 0, DIALOG_HEIGHT - 26, OD_DIALOG_WIDTH, 1 );
379 InsertSeparator( *this, "lnNavSep2", 1, 85, 0, 1, BUTTON_POS_Y - 6 );
381 InsertButton( *this, "btnNavBack", mxActionListener, nBackPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, false, STR_BACK, PushButtonType_STANDARD );
382 InsertButton( *this, "btnNavNext", mxActionListener, nNextPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, true, STR_NEXT, PushButtonType_STANDARD );
383 InsertButton( *this, "btnNavFinish", mxActionListener, nFinishPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, true, STR_FINISH, PushButtonType_STANDARD );
384 InsertButton( *this, "btnNavCancel", mxActionListener, nCancelPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, true, STR_CANCEL, PushButtonType_STANDARD );
386 setControlProperty( "btnNavNext", "DefaultButton", Any( true ) );
391 void OptimizerDialog::UpdateControlStatesPage0()
393 sal_uInt32 i;
394 short nSelectedItem = -1;
395 Sequence< OUString > aItemList;
396 const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
397 if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
399 aItemList.realloc( rList.size() - 1 );
400 for ( i = 1; i < rList.size(); i++ )
402 aItemList[ i - 1 ] = rList[ i ].maName;
403 if ( nSelectedItem < 0 )
405 if ( rList[ i ] == rList[ 0 ] )
406 nSelectedItem = static_cast< short >( i - 1 );
410 bool bRemoveButtonEnabled = false;
411 Sequence< short > aSelectedItems;
412 if ( nSelectedItem >= 0 )
414 aSelectedItems.realloc( 1 );
415 aSelectedItems[ 0 ] = nSelectedItem;
416 if ( nSelectedItem > 2 ) // only allowing to delete custom themes, the first can|t be deleted
417 bRemoveButtonEnabled = true;
419 setControlProperty( "ListBox0Pg0", "StringItemList", Any( aItemList ) );
420 setControlProperty( "ListBox0Pg0", "SelectedItems", Any( aSelectedItems ) );
421 setControlProperty( "Button0Pg0", "Enabled", Any( bRemoveButtonEnabled ) );
423 void OptimizerDialog::InitPage0()
425 Sequence< OUString > aItemList;
426 std::vector< OUString > aControlList;
427 aControlList.push_back( InsertFixedText( *this, "FixedText0Pg0", getString( STR_INTRODUCTION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ) );
428 aControlList.push_back( InsertFixedText( *this, "FixedText1Pg0", getString( STR_INTRODUCTION_T ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 100, true, false, mnTabIndex++ ) );
429 aControlList.push_back( InsertSeparator( *this, "Separator1Pg0", 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 66, PAGE_WIDTH - 12, 1 ) );
430 aControlList.push_back( InsertFixedText( *this, "FixedText2Pg0", getString( STR_CHOSE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 60, PAGE_WIDTH - 12, 8, true, false, mnTabIndex++ ) );
431 aControlList.push_back( InsertListBox( *this, "ListBox0Pg0", mxActionListenerListBox0Pg0, true, aItemList, PAGE_POS_X + 6, DIALOG_HEIGHT - 48, ( OD_DIALOG_WIDTH - 50 ) - ( PAGE_POS_X + 6 ), 12, mnTabIndex++ ) );
432 aControlList.push_back( InsertButton( *this, "Button0Pg0", mxActionListener, OD_DIALOG_WIDTH - 46, DIALOG_HEIGHT - 49, 40, 14, mnTabIndex++, true, STR_REMOVE, PushButtonType_STANDARD ) );
433 maControlPages.push_back( aControlList );
434 DeactivatePage( 0 );
435 UpdateControlStatesPage0();
440 void OptimizerDialog::UpdateControlStatesPage1()
442 bool bDeleteUnusedMasterPages( GetConfigProperty( TK_DeleteUnusedMasterPages, false ) );
443 bool bDeleteHiddenSlides( GetConfigProperty( TK_DeleteHiddenSlides, false ) );
444 bool bDeleteNotesPages( GetConfigProperty( TK_DeleteNotesPages, false ) );
446 setControlProperty( "CheckBox0Pg3", "State", Any( (sal_Int16)bDeleteUnusedMasterPages ) );
447 setControlProperty( "CheckBox1Pg3", "State", Any( (sal_Int16)bDeleteNotesPages ) );
448 setControlProperty( "CheckBox2Pg3", "State", Any( (sal_Int16)bDeleteHiddenSlides ) );
450 void OptimizerDialog::InitPage1()
452 Sequence< OUString > aCustomShowList;
453 Reference< XModel > xModel( mxController->getModel() );
454 if ( xModel.is() )
456 Reference< XCustomPresentationSupplier > aXCPSup( xModel, UNO_QUERY_THROW );
457 Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
458 if ( aXCont.is() )
459 aCustomShowList = aXCont->getElementNames();
461 std::vector< OUString > aControlList;
462 aControlList.push_back( InsertFixedText( *this, "FixedText0Pg3", getString( STR_CHOOSE_SLIDES ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ) );
463 aControlList.push_back( InsertCheckBox( *this, "CheckBox0Pg3", mxItemListener, getString( STR_DELETE_MASTER_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
464 aControlList.push_back( InsertCheckBox( *this, "CheckBox2Pg3", mxItemListener, getString( STR_DELETE_HIDDEN_SLIDES ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
465 aControlList.push_back( InsertCheckBox( *this, "CheckBox3Pg3", mxItemListener, getString( STR_CUSTOM_SHOW ), PAGE_POS_X + 6, PAGE_POS_Y + 42, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
466 aControlList.push_back( InsertListBox( *this, "ListBox0Pg3", mxActionListener, true, aCustomShowList, PAGE_POS_X + 14, PAGE_POS_Y + 54, 150, 12, mnTabIndex++ ) );
467 aControlList.push_back( InsertCheckBox( *this, "CheckBox1Pg3", mxItemListener, getString( STR_DELETE_NOTES_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 70, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
468 maControlPages.push_back( aControlList );
469 DeactivatePage( 1 );
471 setControlProperty( "CheckBox3Pg3", "State", Any( false ) );
472 setControlProperty( "CheckBox3Pg3", "Enabled", Any( aCustomShowList.getLength() != 0 ) );
473 setControlProperty( "ListBox0Pg3", "Enabled", Any( false ) );
475 UpdateControlStatesPage1();
480 void OptimizerDialog::UpdateControlStatesPage2()
482 bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, false ) );
483 bool bRemoveCropArea( GetConfigProperty( TK_RemoveCropArea, false ) );
484 bool bEmbedLinkedGraphics( GetConfigProperty( TK_EmbedLinkedGraphics, true ) );
485 sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
487 sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
489 sal_Int32 nI0, nI1, nI2, nI3;
490 nI0 = nI1 = nI2 = nI3 = 0;
491 OUString aResolutionText;
492 Sequence< OUString > aResolutionItemList( 4 );
493 aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
494 aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
495 aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
496 aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
497 nI0 = nI1 = nI2 = nI3 = 0;
498 if ( getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI0 ).toInt32() == nImageResolution )
499 aResolutionText = aResolutionItemList[ 0 ];
500 else if ( getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI1 ).toInt32() == nImageResolution )
501 aResolutionText = aResolutionItemList[ 1 ];
502 else if ( getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI2 ).toInt32() == nImageResolution )
503 aResolutionText = aResolutionItemList[ 2 ];
504 else if ( getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI3 ).toInt32() == nImageResolution )
505 aResolutionText = aResolutionItemList[ 3 ];
506 if ( aResolutionText.isEmpty() )
507 aResolutionText = OUString::number( nImageResolution );
509 setControlProperty( "RadioButton0Pg1", "State", Any( (sal_Int16)( !bJPEGCompression ) ) );
510 setControlProperty( "RadioButton1Pg1", "State", Any( (sal_Int16)( bJPEGCompression ) ) );
511 setControlProperty( "FixedText1Pg1", "Enabled", Any( bJPEGCompression ) );
512 setControlProperty( "FormattedField0Pg1", "Enabled", Any( bJPEGCompression ) );
513 setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( (double)nJPEGQuality ) );
514 setControlProperty( "CheckBox1Pg1", "State", Any( (sal_Int16)bRemoveCropArea ) );
515 setControlProperty( "ComboBox0Pg1", "Text", Any( aResolutionText ) );
516 setControlProperty( "CheckBox2Pg1", "State", Any( (sal_Int16)bEmbedLinkedGraphics ) );
518 void OptimizerDialog::InitPage2()
520 sal_Int32 nI0, nI1, nI2, nI3;
521 nI0 = nI1 = nI2 = nI3 = 0;
522 Sequence< OUString > aResolutionItemList( 4 );
523 aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
524 aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
525 aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
526 aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
528 std::vector< OUString > aControlList;
529 aControlList.push_back( InsertFixedText( *this, "FixedText0Pg1", getString( STR_GRAPHIC_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ) );
530 aControlList.push_back( InsertRadioButton( *this, "RadioButton0Pg1", mxItemListener, getString( STR_LOSSLESS_COMPRESSION ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, false, mnTabIndex++ ) );
531 aControlList.push_back( InsertRadioButton( *this, "RadioButton1Pg1", mxItemListener, getString( STR_JPEG_COMPRESSION ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, 8, false, mnTabIndex++ ) );
532 aControlList.push_back( InsertFixedText( *this, "FixedText1Pg1", getString( STR_QUALITY ), PAGE_POS_X + 20, PAGE_POS_Y + 40, 72, 8, false, false, mnTabIndex++ ) );
533 aControlList.push_back( InsertFormattedField( *this, "FormattedField0Pg1", mxTextListenerFormattedField0Pg1, mxSpinListenerFormattedField0Pg1, PAGE_POS_X + 106, PAGE_POS_Y + 38, 50, 0, 100, mnTabIndex++ ) );
534 aControlList.push_back( InsertFixedText( *this, "FixedText2Pg1", getString( STR_IMAGE_RESOLUTION ), PAGE_POS_X + 6, PAGE_POS_Y + 54, 94, 8, false, false, mnTabIndex++ ) );
535 aControlList.push_back( InsertComboBox( *this, "ComboBox0Pg1", mxTextListenerComboBox0Pg1, true, aResolutionItemList, PAGE_POS_X + 106, PAGE_POS_Y + 52, 100, 12, mnTabIndex++ ) );
536 aControlList.push_back( InsertCheckBox( *this, "CheckBox1Pg1", mxItemListener, getString( STR_REMOVE_CROP_AREA ), PAGE_POS_X + 6, PAGE_POS_Y + 68, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
537 aControlList.push_back( InsertCheckBox( *this, "CheckBox2Pg1", mxItemListener, getString( STR_EMBED_LINKED_GRAPHICS ), PAGE_POS_X + 6, PAGE_POS_Y + 82, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
538 maControlPages.push_back( aControlList );
539 DeactivatePage( 2 );
540 UpdateControlStatesPage2();
545 void OptimizerDialog::UpdateControlStatesPage3()
547 bool bConvertOLEObjects( GetConfigProperty( TK_OLEOptimization, false ) );
548 sal_Int16 nOLEOptimizationType( GetConfigProperty( TK_OLEOptimizationType, (sal_Int16)0 ) );
550 setControlProperty( "CheckBox0Pg2", "State", Any( (sal_Int16)bConvertOLEObjects ) );
551 setControlProperty( "RadioButton0Pg2", "Enabled", Any( bConvertOLEObjects ) );
552 setControlProperty( "RadioButton0Pg2", "State", Any( (sal_Int16)( nOLEOptimizationType == 0 ) ) );
553 setControlProperty( "RadioButton1Pg2", "Enabled", Any( bConvertOLEObjects ) );
554 setControlProperty( "RadioButton1Pg2", "State", Any( (sal_Int16)( nOLEOptimizationType == 1 ) ) );
556 void OptimizerDialog::InitPage3()
558 int nOLECount = 0;
559 Reference< XModel > xModel( mxController->getModel() );
560 Reference< XDrawPagesSupplier > xDrawPagesSupplier( xModel, UNO_QUERY_THROW );
561 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
562 for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
564 Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
565 for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
567 const OUString sOLE2Shape( "com.sun.star.drawing.OLE2Shape" );
568 Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
569 if ( xShape->getShapeType() == sOLE2Shape )
570 nOLECount++;
574 std::vector< OUString > aControlList;
575 aControlList.push_back( InsertFixedText( *this, "FixedText0Pg2", getString( STR_OLE_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ) );
576 aControlList.push_back( InsertCheckBox( *this, "CheckBox0Pg2", mxItemListener, getString( STR_OLE_REPLACE ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
577 aControlList.push_back( InsertRadioButton( *this, "RadioButton0Pg2", mxItemListener, getString( STR_ALL_OLE_OBJECTS ), PAGE_POS_X + 14, PAGE_POS_Y + 28, PAGE_WIDTH - 22, 8, false, mnTabIndex++ ) );
578 aControlList.push_back( InsertRadioButton( *this, "RadioButton1Pg2", mxItemListener, getString( STR_ALIEN_OLE_OBJECTS_ONLY ), PAGE_POS_X + 14, PAGE_POS_Y + 40, PAGE_WIDTH - 22, 8, false, mnTabIndex++ ) );
579 aControlList.push_back( InsertFixedText( *this, "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, true, false, mnTabIndex++ ) );
580 maControlPages.push_back( aControlList );
581 DeactivatePage( 3 );
582 UpdateControlStatesPage3();
587 static OUString ImpValueOfInMB( const sal_Int64& rVal, sal_Unicode nSeparator = '.' )
589 double fVal( static_cast<double>( rVal ) );
590 fVal /= ( 1 << 20 );
591 fVal += 0.05;
592 OUStringBuffer aVal( OUString::number( fVal ) );
593 sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) );
594 if ( nX >= 0 )
596 aVal.setLength( nX + 2 );
597 aVal[nX] = nSeparator;
599 aVal.append( " MB" );
600 return aVal.makeStringAndClear();
603 void OptimizerDialog::UpdateControlStatesPage4()
605 bool bSaveAs( GetConfigProperty( TK_SaveAs, true ) );
606 if ( mbIsReadonly )
608 setControlProperty( "RadioButton0Pg4", "State", Any( (sal_Int16)( sal_False ) ) );
609 setControlProperty( "RadioButton1Pg4", "State", Any( (sal_Int16)( sal_True ) ) );
611 else
613 setControlProperty( "RadioButton0Pg4", "State", Any( (sal_Int16)( !bSaveAs ) ) );
614 setControlProperty( "RadioButton1Pg4", "State", Any( (sal_Int16)( bSaveAs ) ) );
616 setControlProperty( "ComboBox0Pg4", "Enabled", Any( false ) );
618 sal_uInt32 w;
619 Sequence< OUString > aItemList;
620 const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
621 if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
623 aItemList.realloc( rList.size() - 1 );
624 for ( w = 1; w < rList.size(); w++ )
625 aItemList[ w - 1 ] = rList[ w ].maName;
627 setControlProperty( "ComboBox0Pg4", "StringItemList", Any( aItemList ) );
629 // now check if it is sensible to enable the combo box
630 bool bSaveSettingsEnabled = true;
631 if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
633 for ( w = 1; w < rList.size(); w++ )
635 if ( rList[ w ] == rList[ 0 ] )
637 bSaveSettingsEnabled = false;
638 break;
642 sal_Int16 nInt16 = 0;
643 getControlProperty( "CheckBox1Pg4", "State" ) >>= nInt16;
644 setControlProperty( "CheckBox1Pg4", "Enabled", Any( bSaveSettingsEnabled ) );
645 setControlProperty( "ComboBox0Pg4", "Enabled", Any( bSaveSettingsEnabled && nInt16 ) );
647 std::vector< OUString > aSummaryStrings;
649 // taking care of deleted slides
650 sal_Int32 nDeletedSlides = 0;
651 OUString aCustomShowName;
652 if ( getControlProperty( "CheckBox3Pg3", "State" ) >>= nInt16 )
654 if ( nInt16 )
656 Sequence< short > aSelectedItems;
657 Sequence< OUString > aStringItemList;
658 Any aAny = getControlProperty( "ListBox0Pg3", "SelectedItems" );
659 if ( aAny >>= aSelectedItems )
661 if ( aSelectedItems.getLength() )
663 sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
664 aAny = getControlProperty( "ListBox0Pg3", "StringItemList" );
665 if ( aAny >>= aStringItemList )
667 if ( aStringItemList.getLength() > nSelectedItem )
668 SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) );
674 if ( !aCustomShowName.isEmpty() )
676 std::vector< Reference< XDrawPage > > vNonUsedPageList;
677 PageCollector::CollectNonCustomShowPages( mxController->getModel(), aCustomShowName, vNonUsedPageList );
678 nDeletedSlides += vNonUsedPageList.size();
680 if ( GetConfigProperty( TK_DeleteHiddenSlides, false ) )
682 if ( !aCustomShowName.isEmpty() )
684 std::vector< Reference< XDrawPage > > vUsedPageList;
685 PageCollector::CollectCustomShowPages( mxController->getModel(), aCustomShowName, vUsedPageList );
686 std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
687 while( aIter != vUsedPageList.end() )
689 Reference< XPropertySet > xPropSet( *aIter, UNO_QUERY_THROW );
690 bool bVisible = true;
691 const OUString sVisible( "Visible" );
692 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
694 if (!bVisible )
695 nDeletedSlides++;
697 ++aIter;
700 else
702 Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
703 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
704 for( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
706 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
707 Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY_THROW );
709 bool bVisible = true;
710 const OUString sVisible( "Visible" );
711 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
713 if (!bVisible )
714 nDeletedSlides++;
719 if ( GetConfigProperty( TK_DeleteUnusedMasterPages, false ) )
721 std::vector< PageCollector::MasterPageEntity > aMasterPageList;
722 PageCollector::CollectMasterPages( mxController->getModel(), aMasterPageList );
723 Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
724 Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
725 std::vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() );
726 while( aIter != aMasterPageList.end() )
728 if ( !aIter->bUsed )
729 nDeletedSlides++;
730 ++aIter;
733 if ( nDeletedSlides > 1 )
735 OUString aStr( getString( STR_DELETE_SLIDES ) );
736 OUString aPlaceholder( "%SLIDES" );
737 sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
738 if ( i >= 0 )
739 aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::number( nDeletedSlides ) );
740 aSummaryStrings.push_back( aStr );
743 // generating graphic compression info
744 sal_Int32 nGraphics = 0;
745 bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, false ) );
746 sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
747 sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
748 GraphicSettings aGraphicSettings( bJPEGCompression, nJPEGQuality, GetConfigProperty( TK_RemoveCropArea, false ),
749 nImageResolution, GetConfigProperty( TK_EmbedLinkedGraphics, true ) );
750 GraphicCollector::CountGraphics( UnoDialog::mxContext, mxController->getModel(), aGraphicSettings, nGraphics );
751 if ( nGraphics > 1 )
753 OUString aStr( getString( STR_OPTIMIZE_IMAGES ) );
754 OUString aImagePlaceholder( "%IMAGES" );
755 OUString aQualityPlaceholder( "%QUALITY" );
756 OUString aResolutionPlaceholder( "%RESOLUTION" );
757 sal_Int32 i = aStr.indexOf( aImagePlaceholder, 0 );
758 if ( i >= 0 )
759 aStr = aStr.replaceAt( i, aImagePlaceholder.getLength(), OUString::number( nGraphics ) );
761 sal_Int32 j = aStr.indexOf( aQualityPlaceholder, 0 );
762 if ( j >= 0 )
763 aStr = aStr.replaceAt( j, aQualityPlaceholder.getLength(), OUString::number( nJPEGQuality ) );
765 sal_Int32 k = aStr.indexOf( aResolutionPlaceholder, 0 );
766 if ( k >= 0 )
767 aStr = aStr.replaceAt( k, aResolutionPlaceholder.getLength(), OUString::number( nImageResolution ) );
769 aSummaryStrings.push_back( aStr );
772 if ( GetConfigProperty( TK_OLEOptimization, false ) )
774 sal_Int32 nOLEReplacements = 0;
775 Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
776 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
777 for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
779 Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
780 for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
782 const OUString sOLE2Shape( "com.sun.star.drawing.OLE2Shape" );
783 Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
784 if ( xShape->getShapeType() == sOLE2Shape )
785 nOLEReplacements++;
788 if ( nOLEReplacements > 1 )
790 OUString aStr( getString( STR_CREATE_REPLACEMENT ) );
791 OUString aPlaceholder( "%OLE" );
792 sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
793 if ( i >= 0 )
794 aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::number( nOLEReplacements ) );
795 aSummaryStrings.push_back( aStr );
798 while( aSummaryStrings.size() < 3 )
799 aSummaryStrings.push_back( OUString() );
800 setControlProperty( "FixedText4Pg4", "Label", Any( aSummaryStrings[ 0 ] ) );
801 setControlProperty( "FixedText5Pg4", "Label", Any( aSummaryStrings[ 1 ] ) );
802 setControlProperty( "FixedText6Pg4", "Label", Any( aSummaryStrings[ 2 ] ) );
804 sal_Int64 nCurrentFileSize = 0;
805 sal_Int64 nEstimatedFileSize = 0;
806 Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY );
807 if ( xStorable.is() && xStorable->hasLocation() )
808 nCurrentFileSize = PPPOptimizer::GetFileSize( xStorable->getLocation() );
810 if ( nCurrentFileSize )
812 double fE = static_cast< double >( nCurrentFileSize );
813 if ( nImageResolution )
815 double v = ( static_cast< double >( nImageResolution ) + 75.0 ) / 300.0;
816 if ( v < 1.0 )
817 fE *= v;
819 if ( bJPEGCompression )
821 double v = 0.75 - ( ( 100.0 - static_cast< double >( nJPEGQuality ) ) / 400.0 ) ;
822 fE *= v;
824 nEstimatedFileSize = static_cast< sal_Int64 >( fE );
826 sal_Unicode nSeparator = '.';
827 OUString aStr( getString( STR_FILESIZESEPARATOR ) );
828 if ( !aStr.isEmpty() )
829 nSeparator = aStr[ 0 ];
830 setControlProperty( "FixedText7Pg4", "Label", Any( ImpValueOfInMB( nCurrentFileSize, nSeparator ) ) );
831 setControlProperty( "FixedText8Pg4", "Label", Any( ImpValueOfInMB( nEstimatedFileSize, nSeparator ) ) );
832 SetConfigProperty( TK_EstimatedFileSize, Any( nEstimatedFileSize ) );
835 void OptimizerDialog::InitPage4()
837 { // creating progress bar:
838 OUString pNames[] = {
839 OUString("Height"),
840 OUString("Name"),
841 OUString("PositionX"),
842 OUString("PositionY"),
843 OUString("ProgressValue"),
844 OUString("ProgressValueMax"),
845 OUString("ProgressValueMin"),
846 OUString("Width") };
848 Any pValues[] = {
849 Any( (sal_Int32)12 ),
850 Any( OUString("STR_SAVE_AS") ),
851 Any( (sal_Int32)( PAGE_POS_X + 6 ) ),
852 Any( (sal_Int32)( DIALOG_HEIGHT - 75 ) ),
853 Any( (sal_Int32)( 0 ) ),
854 Any( (sal_Int32)( 100 ) ),
855 Any( (sal_Int32)( 0 ) ),
856 Any( (sal_Int32)( PAGE_WIDTH - 12 ) ) };
858 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
860 Sequence< OUString > aNames( pNames, nCount );
861 Sequence< Any > aValues( pValues, nCount );
863 Reference< XMultiPropertySet > xMultiPropertySet( insertControlModel( OUString( "com.sun.star.awt.UnoControlProgressBarModel" ),
864 "Progress", aNames, aValues ), UNO_QUERY );
866 Reference< XTextListener > xTextListener;
867 Sequence< OUString > aItemList;
868 std::vector< OUString > aControlList;
869 aControlList.push_back( InsertFixedText( *this, "FixedText0Pg4", getString( STR_SUMMARY_TITLE ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ) );
870 // aControlList.push_back( InsertSeparator( *this, "Separator0Pg4", 0, PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 1 ) );
872 aControlList.push_back( InsertFixedText( *this, "FixedText4Pg4", OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, false, false, mnTabIndex++ ) );
873 aControlList.push_back( InsertFixedText( *this, "FixedText5Pg4", OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 22, PAGE_WIDTH - 12, 8, false, false, mnTabIndex++ ) );
874 aControlList.push_back( InsertFixedText( *this, "FixedText6Pg4", OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 30, PAGE_WIDTH - 12, 8, false, false, mnTabIndex++ ) );
876 aControlList.push_back( InsertFixedText( *this, "FixedText2Pg4", getString( STR_CURRENT_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 50, 88, 8, false, false, mnTabIndex++ ) );
877 aControlList.push_back( InsertFixedText( *this, "FixedText7Pg4", OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 50, 30, 8, false, false, mnTabIndex++ ) );
878 setControlProperty( "FixedText7Pg4", "Align", Any( static_cast< short >( 2 ) ) );
879 aControlList.push_back( InsertFixedText( *this, "FixedText3Pg4", getString( STR_ESTIMATED_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 58, 88, 8, false, false, mnTabIndex++ ) );
880 aControlList.push_back( InsertFixedText( *this, "FixedText8Pg4", OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 58, 30, 8, false, false, mnTabIndex++ ) );
881 setControlProperty( "FixedText8Pg4", "Align", Any( static_cast< short >( 2 ) ) );
883 aControlList.push_back( InsertRadioButton( *this, "RadioButton0Pg4", mxItemListener, getString( STR_APPLY_TO_CURRENT ), PAGE_POS_X + 6, PAGE_POS_Y + 78, PAGE_WIDTH - 12, 8, false, mnTabIndex++ ) );
884 aControlList.push_back( InsertRadioButton( *this, "RadioButton1Pg4", mxItemListener, getString( STR_SAVE_AS ), PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 8, false, mnTabIndex++ ) );
885 aControlList.push_back( InsertFixedText( *this, "FixedText1Pg4", OUString(), PAGE_POS_X + 6, DIALOG_HEIGHT - 87, PAGE_WIDTH - 12, 8, true, false, mnTabIndex++ ) );
886 aControlList.push_back( "Progress" );
887 aControlList.push_back( InsertSeparator( *this, "Separator1Pg4", 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 58, PAGE_WIDTH - 12, 1 ) );
888 aControlList.push_back( InsertCheckBox( *this, "CheckBox1Pg4", mxItemListener, getString( STR_SAVE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 47, 100, 8, mnTabIndex++ ) );
889 aControlList.push_back( InsertComboBox( *this, "ComboBox0Pg4", xTextListener, true, aItemList, PAGE_POS_X + 106, DIALOG_HEIGHT - 48, 100, 12, mnTabIndex++ ) );
890 maControlPages.push_back( aControlList );
891 DeactivatePage( 4 );
893 // creating a default session name that hasn't been used yet
894 OUString aSettingsName;
895 OUString aDefault( getString( STR_MY_SETTINGS ) );
896 sal_Int32 nSession = 1;
897 sal_uInt32 i;
898 const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
901 OUString aTemp( aDefault.concat( OUString::number( nSession++ ) ) );
902 for ( i = 1; i < rList.size(); i++ )
904 if ( rList[ i ].maName == aTemp )
905 break;
907 if ( i == rList.size() )
908 aSettingsName = aTemp;
910 while( aSettingsName.isEmpty() );
912 setControlProperty( "ComboBox0Pg4", "Text", Any( aSettingsName ) );
913 setControlProperty( "RadioButton0Pg4", "Enabled", Any( !mbIsReadonly ) );
914 setControlProperty( "RadioButton1Pg4", "Enabled", Any( !mbIsReadonly ) );
916 UpdateControlStatesPage4();
920 void OptimizerDialog::EnablePage( sal_Int16 nStep )
922 std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
923 std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
924 while( aBeg != aEnd )
925 setControlProperty( *aBeg++, "Enabled", Any( true ) );
927 void OptimizerDialog::DisablePage( sal_Int16 nStep )
929 std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
930 std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
931 while( aBeg != aEnd )
932 setControlProperty( *aBeg++, "Enabled", Any( false ) );
934 void OptimizerDialog::ActivatePage( sal_Int16 nStep )
936 std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
937 std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
938 while( aBeg != aEnd )
939 setVisible( *aBeg++, true );
941 void OptimizerDialog::DeactivatePage( sal_Int16 nStep )
943 std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
944 std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
945 while( aBeg != aEnd )
946 setVisible( *aBeg++, false );
949 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */