bump product version to 4.1.6.2
[LibreOffice.git] / sdext / source / minimizer / optimizerdialogcontrols.cxx
blob0c54459401034413120b856f626bf91fac9aef12
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"
23 // -------------------
24 // - OptimizerDialog -
25 // -------------------
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 ::rtl;
38 using namespace ::com::sun::star::awt;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::util;
41 using namespace ::com::sun::star::lang;
42 using namespace ::com::sun::star::frame;
43 using namespace ::com::sun::star::beans;
44 using namespace ::com::sun::star::script;
45 using namespace ::com::sun::star::drawing;
46 using namespace ::com::sun::star::container;
47 using namespace ::com::sun::star::presentation;
49 // -----------------------------------------------------------------------------
51 void SetBold( OptimizerDialog& rOptimizerDialog, const OUString& rControl )
53 FontDescriptor aFontDescriptor;
54 if ( rOptimizerDialog.getControlProperty( rControl, TKGet( TK_FontDescriptor ) ) >>= aFontDescriptor )
56 aFontDescriptor.Weight = FontWeight::BOLD;
57 rOptimizerDialog.setControlProperty( rControl, TKGet( TK_FontDescriptor ), Any( aFontDescriptor ) );
61 // -----------------------------------------------------------------------------
63 OUString InsertSeparator( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, sal_Int32 nOrientation,
64 sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight )
66 OUString pNames[] = {
67 TKGet( TK_Height ),
68 TKGet( TK_Orientation ),
69 TKGet( TK_PositionX ),
70 TKGet( TK_PositionY ),
71 TKGet( TK_Step ),
72 TKGet( TK_Width ) };
74 Any pValues[] = {
75 Any( nHeight ),
76 Any( nOrientation ),
77 Any( nPosX ),
78 Any( nPosY ),
79 Any( sal_Int16( 0 ) ),
80 Any( nWidth ) };
82 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
84 Sequence< OUString > aNames( pNames, nCount );
85 Sequence< Any > aValues( pValues, nCount );
87 rOptimizerDialog.insertControlModel( OUString( "com.sun.star.awt.UnoControlFixedLineModel" ),
88 rControlName, aNames, aValues );
89 return rControlName;
92 // -----------------------------------------------------------------------------
94 OUString InsertButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, Reference< XActionListener >& xActionListener,
95 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex, sal_Bool bEnabled, PPPOptimizerTokenEnum nResID, sal_Int16 nPushButtonType )
97 OUString pNames[] = {
98 TKGet( TK_Enabled ),
99 TKGet( TK_Height ),
100 TKGet( TK_Label ),
101 TKGet( TK_PositionX ),
102 TKGet( TK_PositionY ),
103 TKGet( TK_PushButtonType ),
104 TKGet( TK_Step ),
105 TKGet( TK_TabIndex ),
106 TKGet( TK_Width ) };
108 Any pValues[] = {
109 Any( bEnabled ),
110 Any( nHeight ),
111 Any( rOptimizerDialog.getString( nResID ) ),
112 Any( nXPos ),
113 Any( nYPos ),
114 Any( nPushButtonType ),
115 Any( (sal_Int16)0 ),
116 Any( nTabIndex ),
117 Any( nWidth ) };
120 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
122 Sequence< OUString > aNames( pNames, nCount );
123 Sequence< Any > aValues( pValues, nCount );
125 rOptimizerDialog.insertButton( rControlName, xActionListener, aNames, aValues );
126 return rControlName;
129 // -----------------------------------------------------------------------------
131 OUString InsertFixedText( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, const OUString& rLabel,
132 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Bool bBold, sal_Int16 nTabIndex )
134 OUString pNames[] = {
135 TKGet( TK_Height ),
136 TKGet( TK_Label ),
137 TKGet( TK_MultiLine ),
138 TKGet( TK_PositionX ),
139 TKGet( TK_PositionY ),
140 TKGet( TK_Step ),
141 TKGet( TK_TabIndex ),
142 TKGet( TK_Width ) };
144 Any pValues[] = {
145 Any( nHeight ),
146 Any( rLabel ),
147 Any( bMultiLine ),
148 Any( nXPos ),
149 Any( nYPos ),
150 Any( (sal_Int16)0 ),
151 Any( nTabIndex ),
152 Any( nWidth ) };
154 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
156 Sequence< OUString > aNames( pNames, nCount );
157 Sequence< Any > aValues( pValues, nCount );
159 rOptimizerDialog.insertFixedText( rControlName, aNames, aValues );
160 if ( bBold )
161 SetBold( rOptimizerDialog, rControlName );
162 return rControlName;
165 // -----------------------------------------------------------------------------
167 OUString InsertCheckBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
168 const Reference< XItemListener > xItemListener, const OUString& rLabel,
169 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
171 OUString pNames[] = {
172 TKGet( TK_Enabled ),
173 TKGet( TK_Height ),
174 TKGet( TK_Label ),
175 TKGet( TK_PositionX ),
176 TKGet( TK_PositionY ),
177 TKGet( TK_Step ),
178 TKGet( TK_TabIndex ),
179 TKGet( TK_Width ) };
181 Any pValues[] = {
182 Any( sal_True ),
183 Any( nHeight ),
184 Any( rLabel ),
185 Any( nXPos ),
186 Any( nYPos ),
187 Any( (sal_Int16)0 ),
188 Any( nTabIndex ),
189 Any( nWidth ) };
191 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
193 Sequence< OUString > aNames( pNames, nCount );
194 Sequence< Any > aValues( pValues, nCount );
196 Reference< XCheckBox > xCheckBox( rOptimizerDialog.insertCheckBox( rControlName, aNames, aValues ) );
197 if ( xItemListener.is() )
198 xCheckBox->addItemListener( xItemListener );
199 return rControlName;
202 // -----------------------------------------------------------------------------
204 OUString InsertFormattedField( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
205 const Reference< XTextListener > xTextListener, const Reference< XSpinListener > xSpinListener, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth,
206 double fEffectiveMin, double fEffectiveMax, sal_Int16 nTabIndex )
208 OUString pNames[] = {
209 TKGet( TK_EffectiveMax ),
210 TKGet( TK_EffectiveMin ),
211 TKGet( TK_Enabled ),
212 TKGet( TK_Height ),
213 TKGet( TK_PositionX ),
214 TKGet( TK_PositionY ),
215 TKGet( TK_Repeat ),
216 TKGet( TK_Spin ),
217 TKGet( TK_Step ),
218 TKGet( TK_TabIndex ),
219 TKGet( TK_Width ) };
221 Any pValues[] = {
222 Any( fEffectiveMax ),
223 Any( fEffectiveMin ),
224 Any( sal_True ),
225 Any( (sal_Int32)12 ),
226 Any( nXPos ),
227 Any( nYPos ),
228 Any( (sal_Bool)sal_True ),
229 Any( (sal_Bool)sal_True ),
230 Any( (sal_Int16)0 ),
231 Any( nTabIndex ),
232 Any( nWidth ) };
234 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
236 Sequence< OUString > aNames( pNames, nCount );
237 Sequence< Any > aValues( pValues, nCount );
239 Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertFormattedField( rControlName, aNames, aValues ), UNO_QUERY_THROW );
240 if ( xTextListener.is() )
241 xTextComponent->addTextListener( xTextListener );
242 if ( xSpinListener.is() )
244 Reference< XSpinField > xSpinField( xTextComponent, UNO_QUERY_THROW );
245 xSpinField->addSpinListener( xSpinListener );
247 return rControlName;
250 // -----------------------------------------------------------------------------
252 OUString InsertComboBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
253 const Reference< XTextListener > xTextListener, const sal_Bool bEnabled, const Sequence< OUString >& rItemList,
254 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
256 OUString pNames[] = {
257 TKGet( TK_Dropdown ),
258 TKGet( TK_Enabled ),
259 TKGet( TK_Height ),
260 TKGet( TK_LineCount ),
261 TKGet( TK_PositionX ),
262 TKGet( TK_PositionY ),
263 TKGet( TK_Step ),
264 TKGet( TK_StringItemList ),
265 TKGet( TK_TabIndex ),
266 TKGet( TK_Width ) };
268 Any pValues[] = {
269 Any( sal_True ),
270 Any( bEnabled ),
271 Any( nHeight ),
272 Any( (sal_Int16)8),
273 Any( nXPos ),
274 Any( nYPos ),
275 Any( (sal_Int16)0 ),
276 Any( rItemList ),
277 Any( nTabIndex ),
278 Any( nWidth ) };
280 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
282 Sequence< OUString > aNames( pNames, nCount );
283 Sequence< Any > aValues( pValues, nCount );
285 Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertComboBox( rControlName, aNames, aValues ), UNO_QUERY_THROW );
286 if ( xTextListener.is() )
287 xTextComponent->addTextListener( xTextListener );
288 return rControlName;
291 // -----------------------------------------------------------------------------
293 OUString InsertRadioButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, const Reference< XItemListener > xItemListener,
294 const OUString& rLabel, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Int16 nTabIndex )
296 OUString pNames[] = {
297 TKGet( TK_Height ),
298 TKGet( TK_Label ),
299 TKGet( TK_MultiLine ),
300 TKGet( TK_PositionX ),
301 TKGet( TK_PositionY ),
302 TKGet( TK_Step ),
303 TKGet( TK_TabIndex ),
304 TKGet( TK_Width ) };
306 Any pValues[] = {
307 Any( nHeight ),
308 Any( rLabel ),
309 Any( bMultiLine ),
310 Any( nXPos ),
311 Any( nYPos ),
312 Any( (sal_Int16)0 ),
313 Any( nTabIndex ),
314 Any( nWidth ) };
316 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
318 Sequence< OUString > aNames( pNames, nCount );
319 Sequence< Any > aValues( pValues, nCount );
321 Reference< XRadioButton > xRadioButton( rOptimizerDialog.insertRadioButton( rControlName, aNames, aValues ) );
322 if ( xItemListener.is() )
323 xRadioButton->addItemListener( xItemListener );
324 return rControlName;
327 // -----------------------------------------------------------------------------
329 OUString InsertListBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
330 const Reference< XActionListener > xActionListener, const sal_Bool bEnabled, const Sequence< OUString >& rItemList,
331 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
333 OUString pNames[] = {
334 TKGet( TK_Dropdown ),
335 TKGet( TK_Enabled ),
336 TKGet( TK_Height ),
337 TKGet( TK_LineCount ),
338 TKGet( TK_MultiSelection ),
339 TKGet( TK_PositionX ),
340 TKGet( TK_PositionY ),
341 TKGet( TK_Step ),
342 TKGet( TK_StringItemList ),
343 TKGet( TK_TabIndex ),
344 TKGet( TK_Width ) };
346 Any pValues[] = {
347 Any( sal_True ),
348 Any( bEnabled ),
349 Any( nHeight ),
350 Any( (sal_Int16)8),
351 Any( sal_False ),
352 Any( nXPos ),
353 Any( nYPos ),
354 Any( (sal_Int16)0 ),
355 Any( rItemList ),
356 Any( nTabIndex ),
357 Any( nWidth ) };
359 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
361 Sequence< OUString > aNames( pNames, nCount );
362 Sequence< Any > aValues( pValues, nCount );
364 Reference< XListBox > xListBox( rOptimizerDialog.insertListBox( rControlName, aNames, aValues ) );
365 if ( xListBox.is() )
366 xListBox->addActionListener( xActionListener );
367 return rControlName;
370 // -----------------------------------------------------------------------------
372 void OptimizerDialog::InitNavigationBar()
374 sal_Int32 nCancelPosX = OD_DIALOG_WIDTH - BUTTON_WIDTH - 6;
375 sal_Int32 nFinishPosX = nCancelPosX - 6 - BUTTON_WIDTH;
376 sal_Int32 nNextPosX = nFinishPosX - 6 - BUTTON_WIDTH;
377 sal_Int32 nBackPosX = nNextPosX - 3 - BUTTON_WIDTH;
379 InsertSeparator( *this, TKGet( TK_lnNavSep1 ), 0, 0, DIALOG_HEIGHT - 26, OD_DIALOG_WIDTH, 1 );
380 InsertSeparator( *this, TKGet( TK_lnNavSep2 ), 1, 85, 0, 1, BUTTON_POS_Y - 6 );
382 InsertButton( *this, TKGet( TK_btnNavBack ), mxActionListener, nBackPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_False, STR_BACK, PushButtonType_STANDARD );
383 InsertButton( *this, TKGet( TK_btnNavNext ), mxActionListener, nNextPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_NEXT, PushButtonType_STANDARD );
384 InsertButton( *this, TKGet( TK_btnNavFinish ), mxActionListener, nFinishPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_FINISH, PushButtonType_STANDARD );
385 InsertButton( *this, TKGet( TK_btnNavCancel ), mxActionListener, nCancelPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_CANCEL, PushButtonType_STANDARD );
387 setControlProperty( TKGet( TK_btnNavNext ), TKGet( TK_DefaultButton ), Any( sal_True ) );
390 // -----------------------------------------------------------------------------
392 void OptimizerDialog::UpdateControlStatesPage0()
394 sal_uInt32 i;
395 short nSelectedItem = -1;
396 Sequence< OUString > aItemList;
397 const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
398 if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
400 aItemList.realloc( rList.size() - 1 );
401 for ( i = 1; i < rList.size(); i++ )
403 aItemList[ i - 1 ] = rList[ i ].maName;
404 if ( nSelectedItem < 0 )
406 if ( rList[ i ] == rList[ 0 ] )
407 nSelectedItem = static_cast< short >( i - 1 );
411 sal_Bool bRemoveButtonEnabled = sal_False;
412 Sequence< short > aSelectedItems;
413 if ( nSelectedItem >= 0 )
415 aSelectedItems.realloc( 1 );
416 aSelectedItems[ 0 ] = nSelectedItem;
417 if ( nSelectedItem > 2 ) // only allowing to delete custom themes, the first can|t be deleted
418 bRemoveButtonEnabled = sal_True;
420 setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_StringItemList ), Any( aItemList ) );
421 setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_SelectedItems ), Any( aSelectedItems ) );
422 setControlProperty( TKGet( TK_Button0Pg0 ), TKGet( TK_Enabled ), Any( bRemoveButtonEnabled ) );
424 void OptimizerDialog::InitPage0()
426 Sequence< OUString > aItemList;
427 std::vector< OUString > aControlList;
428 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++ ) );
429 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++ ) );
430 aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator1Pg0 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 66, PAGE_WIDTH - 12, 1 ) );
431 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++ ) );
432 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++ ) );
433 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 ) );
434 maControlPages.push_back( aControlList );
435 DeactivatePage( 0 );
436 UpdateControlStatesPage0();
439 // -----------------------------------------------------------------------------
441 void OptimizerDialog::UpdateControlStatesPage1()
443 sal_Bool bDeleteUnusedMasterPages( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) );
444 sal_Bool bDeleteHiddenSlides( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) );
445 sal_Bool bDeleteNotesPages( GetConfigProperty( TK_DeleteNotesPages, sal_False ) );
447 setControlProperty( TKGet( TK_CheckBox0Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteUnusedMasterPages ) );
448 setControlProperty( TKGet( TK_CheckBox1Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteNotesPages ) );
449 setControlProperty( TKGet( TK_CheckBox2Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteHiddenSlides ) );
451 void OptimizerDialog::InitPage1()
453 Sequence< OUString > aCustomShowList;
454 Reference< XModel > xModel( mxController->getModel() );
455 if ( xModel.is() )
457 Reference< XCustomPresentationSupplier > aXCPSup( xModel, UNO_QUERY_THROW );
458 Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
459 if ( aXCont.is() )
460 aCustomShowList = aXCont->getElementNames();
462 std::vector< OUString > aControlList;
463 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++ ) );
464 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++ ) );
465 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++ ) );
466 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++ ) );
467 aControlList.push_back( InsertListBox( *this, TKGet( TK_ListBox0Pg3 ), mxActionListener, sal_True, aCustomShowList, PAGE_POS_X + 14, PAGE_POS_Y + 54, 150, 12, mnTabIndex++ ) );
468 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++ ) );
469 maControlPages.push_back( aControlList );
470 DeactivatePage( 1 );
472 setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ), Any( sal_False ) );
473 setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_Enabled ), Any( aCustomShowList.getLength() != 0 ) );
474 setControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_Enabled ), Any( sal_False ) );
476 UpdateControlStatesPage1();
479 // -----------------------------------------------------------------------------
481 void OptimizerDialog::UpdateControlStatesPage2()
483 sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) );
484 sal_Bool bRemoveCropArea( GetConfigProperty( TK_RemoveCropArea, sal_False ) );
485 sal_Bool bEmbedLinkedGraphics( GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) );
486 sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
488 sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
490 sal_Int32 nI0, nI1, nI2, nI3;
491 nI0 = nI1 = nI2 = nI3 = 0;
492 OUString aResolutionText;
493 Sequence< OUString > aResolutionItemList( 4 );
494 aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
495 aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
496 aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
497 aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
498 nI0 = nI1 = nI2 = nI3 = 0;
499 if ( getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI0 ).toInt32() == nImageResolution )
500 aResolutionText = aResolutionItemList[ 0 ];
501 else if ( getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI1 ).toInt32() == nImageResolution )
502 aResolutionText = aResolutionItemList[ 1 ];
503 else if ( getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI2 ).toInt32() == nImageResolution )
504 aResolutionText = aResolutionItemList[ 2 ];
505 else if ( getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI3 ).toInt32() == nImageResolution )
506 aResolutionText = aResolutionItemList[ 3 ];
507 if ( aResolutionText.isEmpty() )
508 aResolutionText = OUString::valueOf( nImageResolution );
510 setControlProperty( TKGet( TK_RadioButton0Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_True ) ) );
511 setControlProperty( TKGet( TK_RadioButton1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_False ) ) );
512 setControlProperty( TKGet( TK_FixedText1Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) );
513 setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) );
514 setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( (double)nJPEGQuality ) );
515 setControlProperty( TKGet( TK_CheckBox1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bRemoveCropArea ) );
516 setControlProperty( TKGet( TK_ComboBox0Pg1 ), TKGet( TK_Text ), Any( aResolutionText ) );
517 setControlProperty( TKGet( TK_CheckBox2Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bEmbedLinkedGraphics ) );
519 void OptimizerDialog::InitPage2()
521 sal_Int32 nI0, nI1, nI2, nI3;
522 nI0 = nI1 = nI2 = nI3 = 0;
523 Sequence< OUString > aResolutionItemList( 4 );
524 aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
525 aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
526 aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
527 aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
529 std::vector< OUString > aControlList;
530 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++ ) );
531 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++ ) );
532 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++ ) );
533 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++ ) );
534 aControlList.push_back( InsertFormattedField( *this, TKGet( TK_FormattedField0Pg1 ), mxTextListenerFormattedField0Pg1, mxSpinListenerFormattedField0Pg1, PAGE_POS_X + 106, PAGE_POS_Y + 38, 50, 0, 100, mnTabIndex++ ) );
535 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++ ) );
536 aControlList.push_back( InsertComboBox( *this, TKGet( TK_ComboBox0Pg1 ), mxTextListenerComboBox0Pg1, sal_True, aResolutionItemList, PAGE_POS_X + 106, PAGE_POS_Y + 52, 100, 12, mnTabIndex++ ) );
537 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++ ) );
538 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++ ) );
539 maControlPages.push_back( aControlList );
540 DeactivatePage( 2 );
541 UpdateControlStatesPage2();
544 // -----------------------------------------------------------------------------
546 void OptimizerDialog::UpdateControlStatesPage3()
548 sal_Bool bConvertOLEObjects( GetConfigProperty( TK_OLEOptimization, sal_False ) );
549 sal_Int16 nOLEOptimizationType( GetConfigProperty( TK_OLEOptimizationType, (sal_Int16)0 ) );
551 setControlProperty( TKGet( TK_CheckBox0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)bConvertOLEObjects ) );
552 setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) );
553 setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 0 ) ) );
554 setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) );
555 setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 1 ) ) );
557 void OptimizerDialog::InitPage3()
559 int nOLECount = 0;
560 Reference< XModel > xModel( mxController->getModel() );
561 Reference< XDrawPagesSupplier > xDrawPagesSupplier( xModel, UNO_QUERY_THROW );
562 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
563 for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
565 Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
566 for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
568 const OUString sOLE2Shape( "com.sun.star.drawing.OLE2Shape" );
569 Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
570 if ( xShape->getShapeType() == sOLE2Shape )
571 nOLECount++;
575 std::vector< OUString > aControlList;
576 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++ ) );
577 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++ ) );
578 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++ ) );
579 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++ ) );
580 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++ ) );
581 maControlPages.push_back( aControlList );
582 DeactivatePage( 3 );
583 UpdateControlStatesPage3();
586 // -----------------------------------------------------------------------------
588 static OUString ImpValueOfInMB( const sal_Int64& rVal, sal_Unicode nSeparator = '.' )
590 double fVal( static_cast<double>( rVal ) );
591 fVal /= ( 1 << 20 );
592 fVal += 0.05;
593 OUStringBuffer aVal( OUString::valueOf( fVal ) );
594 sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) );
595 if ( nX >= 0 )
597 aVal.setLength( nX + 2 );
598 aVal[nX] = nSeparator;
600 aVal.append( OUString(" MB") );
601 return aVal.makeStringAndClear();
604 void OptimizerDialog::UpdateControlStatesPage4()
606 sal_Bool bSaveAs( GetConfigProperty( TK_SaveAs, sal_True ) );
607 if ( mbIsReadonly )
609 setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_False ) ) );
610 setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_True ) ) );
612 else
614 setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_False ) ) );
615 setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_True ) ) );
617 setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( sal_False ) );
619 sal_uInt32 w;
620 Sequence< OUString > aItemList;
621 const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
622 if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
624 aItemList.realloc( rList.size() - 1 );
625 for ( w = 1; w < rList.size(); w++ )
626 aItemList[ w - 1 ] = rList[ w ].maName;
628 setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_StringItemList ), Any( aItemList ) );
630 // now check if it is sensible to enable the combo box
631 sal_Bool bSaveSettingsEnabled = sal_True;
632 if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
634 for ( w = 1; w < rList.size(); w++ )
636 if ( rList[ w ] == rList[ 0 ] )
638 bSaveSettingsEnabled = sal_False;
639 break;
643 sal_Int16 nInt16 = 0;
644 getControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_State ) ) >>= nInt16;
645 setControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled ) );
646 setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled && nInt16 ) );
648 std::vector< OUString > aSummaryStrings;
650 // taking care of deleted slides
651 sal_Int32 nDeletedSlides = 0;
652 OUString aCustomShowName;
653 if ( getControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ) ) >>= nInt16 )
655 if ( nInt16 )
657 Sequence< short > aSelectedItems;
658 Sequence< OUString > aStringItemList;
659 Any aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_SelectedItems ) );
660 if ( aAny >>= aSelectedItems )
662 if ( aSelectedItems.getLength() )
664 sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
665 aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_StringItemList ) );
666 if ( aAny >>= aStringItemList )
668 if ( aStringItemList.getLength() > nSelectedItem )
669 SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) );
675 if ( !aCustomShowName.isEmpty() )
677 std::vector< Reference< XDrawPage > > vNonUsedPageList;
678 PageCollector::CollectNonCustomShowPages( mxController->getModel(), aCustomShowName, vNonUsedPageList );
679 nDeletedSlides += vNonUsedPageList.size();
681 if ( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) )
683 if ( !aCustomShowName.isEmpty() )
685 std::vector< Reference< XDrawPage > > vUsedPageList;
686 PageCollector::CollectCustomShowPages( mxController->getModel(), aCustomShowName, vUsedPageList );
687 std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
688 while( aIter != vUsedPageList.end() )
690 Reference< XPropertySet > xPropSet( *aIter, UNO_QUERY_THROW );
691 sal_Bool bVisible = sal_True;
692 const OUString sVisible( "Visible" );
693 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
695 if (!bVisible )
696 nDeletedSlides++;
698 ++aIter;
701 else
703 Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
704 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
705 for( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
707 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
708 Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY_THROW );
710 sal_Bool bVisible = sal_True;
711 const OUString sVisible( "Visible" );
712 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
714 if (!bVisible )
715 nDeletedSlides++;
720 if ( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) )
722 std::vector< PageCollector::MasterPageEntity > aMasterPageList;
723 PageCollector::CollectMasterPages( mxController->getModel(), aMasterPageList );
724 Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
725 Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
726 std::vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() );
727 while( aIter != aMasterPageList.end() )
729 if ( !aIter->bUsed )
730 nDeletedSlides++;
731 ++aIter;
734 if ( nDeletedSlides > 1 )
736 OUString aStr( getString( STR_DELETE_SLIDES ) );
737 OUString aPlaceholder( "%SLIDES" );
738 sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
739 if ( i >= 0 )
740 aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nDeletedSlides ) );
741 aSummaryStrings.push_back( aStr );
744 // generating graphic compression info
745 sal_Int32 nGraphics = 0;
746 sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) );
747 sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
748 sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
749 GraphicSettings aGraphicSettings( bJPEGCompression, nJPEGQuality, GetConfigProperty( TK_RemoveCropArea, sal_False ),
750 nImageResolution, GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) );
751 GraphicCollector::CountGraphics( mxMSF, mxController->getModel(), aGraphicSettings, nGraphics );
752 if ( nGraphics > 1 )
754 OUString aStr( getString( STR_OPTIMIZE_IMAGES ) );
755 OUString aImagePlaceholder( "%IMAGES" );
756 OUString aQualityPlaceholder( "%QUALITY" );
757 OUString aResolutionPlaceholder( "%RESOLUTION" );
758 sal_Int32 i = aStr.indexOf( aImagePlaceholder, 0 );
759 if ( i >= 0 )
760 aStr = aStr.replaceAt( i, aImagePlaceholder.getLength(), OUString::valueOf( nGraphics ) );
762 sal_Int32 j = aStr.indexOf( aQualityPlaceholder, 0 );
763 if ( j >= 0 )
764 aStr = aStr.replaceAt( j, aQualityPlaceholder.getLength(), OUString::valueOf( nJPEGQuality ) );
766 sal_Int32 k = aStr.indexOf( aResolutionPlaceholder, 0 );
767 if ( k >= 0 )
768 aStr = aStr.replaceAt( k, aResolutionPlaceholder.getLength(), OUString::valueOf( nImageResolution ) );
770 aSummaryStrings.push_back( aStr );
773 if ( GetConfigProperty( TK_OLEOptimization, sal_False ) )
775 sal_Int32 nOLEReplacements = 0;
776 Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
777 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
778 for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
780 Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
781 for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
783 const OUString sOLE2Shape( "com.sun.star.drawing.OLE2Shape" );
784 Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
785 if ( xShape->getShapeType() == sOLE2Shape )
786 nOLEReplacements++;
789 if ( nOLEReplacements > 1 )
791 OUString aStr( getString( STR_CREATE_REPLACEMENT ) );
792 OUString aPlaceholder( "%OLE" );
793 sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
794 if ( i >= 0 )
795 aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nOLEReplacements ) );
796 aSummaryStrings.push_back( aStr );
799 while( aSummaryStrings.size() < 3 )
800 aSummaryStrings.push_back( OUString() );
801 setControlProperty( TKGet( TK_FixedText4Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 0 ] ) );
802 setControlProperty( TKGet( TK_FixedText5Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 1 ] ) );
803 setControlProperty( TKGet( TK_FixedText6Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 2 ] ) );
805 sal_Int64 nCurrentFileSize = 0;
806 sal_Int64 nEstimatedFileSize = 0;
807 Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY );
808 if ( xStorable.is() && xStorable->hasLocation() )
809 nCurrentFileSize = PPPOptimizer::GetFileSize( xStorable->getLocation() );
811 if ( nCurrentFileSize )
813 double fE = static_cast< double >( nCurrentFileSize );
814 if ( nImageResolution )
816 double v = ( static_cast< double >( nImageResolution ) + 75.0 ) / 300.0;
817 if ( v < 1.0 )
818 fE *= v;
820 if ( bJPEGCompression )
822 double v = 0.75 - ( ( 100.0 - static_cast< double >( nJPEGQuality ) ) / 400.0 ) ;
823 fE *= v;
825 nEstimatedFileSize = static_cast< sal_Int64 >( fE );
827 sal_Unicode nSeparator = '.';
828 OUString aStr( getString( STR_FILESIZESEPARATOR ) );
829 if ( !aStr.isEmpty() )
830 nSeparator = aStr[ 0 ];
831 setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nCurrentFileSize, nSeparator ) ) );
832 setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nEstimatedFileSize, nSeparator ) ) );
833 SetConfigProperty( TK_EstimatedFileSize, Any( nEstimatedFileSize ) );
836 void OptimizerDialog::InitPage4()
838 { // creating progress bar:
839 OUString pNames[] = {
840 TKGet( TK_Height ),
841 TKGet( TK_Name ),
842 TKGet( TK_PositionX ),
843 TKGet( TK_PositionY ),
844 TKGet( TK_ProgressValue ),
845 TKGet( TK_ProgressValueMax ),
846 TKGet( TK_ProgressValueMin ),
847 TKGet( TK_Width ) };
849 Any pValues[] = {
850 Any( (sal_Int32)12 ),
851 Any( TKGet( STR_SAVE_AS ) ),
852 Any( (sal_Int32)( PAGE_POS_X + 6 ) ),
853 Any( (sal_Int32)( DIALOG_HEIGHT - 75 ) ),
854 Any( (sal_Int32)( 0 ) ),
855 Any( (sal_Int32)( 100 ) ),
856 Any( (sal_Int32)( 0 ) ),
857 Any( (sal_Int32)( PAGE_WIDTH - 12 ) ) };
859 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
861 Sequence< OUString > aNames( pNames, nCount );
862 Sequence< Any > aValues( pValues, nCount );
864 Reference< XMultiPropertySet > xMultiPropertySet( insertControlModel( OUString( "com.sun.star.awt.UnoControlProgressBarModel" ),
865 TKGet( TK_Progress ), aNames, aValues ), UNO_QUERY );
867 Reference< XTextListener > xTextListener;
868 Sequence< OUString > aItemList;
869 std::vector< OUString > aControlList;
870 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++ ) );
871 // aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator0Pg4 ), 0, PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 1 ) );
873 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++ ) );
874 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++ ) );
875 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++ ) );
877 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++ ) );
878 aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText7Pg4 ), OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 50, 30, 8, sal_False, sal_False, mnTabIndex++ ) );
879 setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) );
880 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++ ) );
881 aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText8Pg4 ), OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 58, 30, 8, sal_False, sal_False, mnTabIndex++ ) );
882 setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) );
884 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++ ) );
885 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++ ) );
886 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++ ) );
887 aControlList.push_back( TKGet( TK_Progress ) );
888 aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator1Pg4 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 58, PAGE_WIDTH - 12, 1 ) );
889 aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox1Pg4 ), mxItemListener, getString( STR_SAVE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 47, 100, 8, mnTabIndex++ ) );
890 aControlList.push_back( InsertComboBox( *this, TKGet( TK_ComboBox0Pg4 ), xTextListener, sal_True, aItemList, PAGE_POS_X + 106, DIALOG_HEIGHT - 48, 100, 12, mnTabIndex++ ) );
891 maControlPages.push_back( aControlList );
892 DeactivatePage( 4 );
894 // creating a default session name that hasn't been used yet
895 OUString aSettingsName;
896 OUString aDefault( getString( STR_MY_SETTINGS ) );
897 sal_Int32 nSession = 1;
898 sal_uInt32 i;
899 const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
902 OUString aTemp( aDefault.concat( OUString::valueOf( nSession++ ) ) );
903 for ( i = 1; i < rList.size(); i++ )
905 if ( rList[ i ].maName == aTemp )
906 break;
908 if ( i == rList.size() )
909 aSettingsName = aTemp;
911 while( aSettingsName.isEmpty() );
913 setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Text ), Any( aSettingsName ) );
914 setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) );
915 setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) );
917 UpdateControlStatesPage4();
920 // -----------------------------------------------------------------------------
921 void OptimizerDialog::EnablePage( sal_Int16 nStep )
923 std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
924 std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
925 while( aBeg != aEnd )
926 setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_True ) );
928 void OptimizerDialog::DisablePage( sal_Int16 nStep )
930 std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
931 std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
932 while( aBeg != aEnd )
933 setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_False ) );
935 void OptimizerDialog::ActivatePage( sal_Int16 nStep )
937 std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
938 std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
939 while( aBeg != aEnd )
940 setVisible( *aBeg++, sal_True );
942 void OptimizerDialog::DeactivatePage( sal_Int16 nStep )
944 std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
945 std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
946 while( aBeg != aEnd )
947 setVisible( *aBeg++, sal_False );
950 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */