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