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