1c142477cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3c142477cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4c142477cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5c142477cSAndrew Rist * distributed with this work for additional information 6c142477cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7c142477cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8c142477cSAndrew Rist * "License"); you may not use this file except in compliance 9c142477cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11c142477cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13c142477cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14c142477cSAndrew Rist * software distributed under the License is distributed on an 15c142477cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16c142477cSAndrew Rist * KIND, either express or implied. See the License for the 17c142477cSAndrew Rist * specific language governing permissions and limitations 18c142477cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20c142477cSAndrew Rist *************************************************************/ 21c142477cSAndrew Rist 22c142477cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sdext.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "optimizerdialog.hxx" 28cdf0e10cSrcweir #include "fileopendialog.hxx" 29cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> 30cdf0e10cSrcweir #include <com/sun/star/ucb/XSimpleFileAccess.hpp> 31cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XCloseBroadcaster_HPP_ 33cdf0e10cSrcweir #include <com/sun/star/util/XCloseBroadcaster.hpp> 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp> 36cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp> 37cdf0e10cSrcweir #include <osl/time.h> 38cdf0e10cSrcweir 39cdf0e10cSrcweir // ------------------- 40cdf0e10cSrcweir // - OPTIMIZERDIALOG - 41cdf0e10cSrcweir // ------------------- 42cdf0e10cSrcweir 43*880c69c6SAriel Constenla-Haile using namespace ::rtl; 44cdf0e10cSrcweir using namespace ::com::sun::star::io; 45cdf0e10cSrcweir using namespace ::com::sun::star::ui; 46cdf0e10cSrcweir using namespace ::com::sun::star::awt; 47cdf0e10cSrcweir using namespace ::com::sun::star::ucb; 48cdf0e10cSrcweir using namespace ::com::sun::star::uno; 49cdf0e10cSrcweir using namespace ::com::sun::star::util; 50cdf0e10cSrcweir using namespace ::com::sun::star::lang; 51cdf0e10cSrcweir using namespace ::com::sun::star::frame; 52cdf0e10cSrcweir using namespace ::com::sun::star::beans; 53cdf0e10cSrcweir using namespace ::com::sun::star::script; 54cdf0e10cSrcweir using namespace ::com::sun::star::container; 55cdf0e10cSrcweir 56cdf0e10cSrcweir 57cdf0e10cSrcweir // ----------------------------------------------------------------------------- 58cdf0e10cSrcweir 59cdf0e10cSrcweir void OptimizerDialog::InitDialog() 60cdf0e10cSrcweir { 61cdf0e10cSrcweir // setting the dialog properties 62cdf0e10cSrcweir OUString pNames[] = { 63cdf0e10cSrcweir TKGet( TK_Closeable ), 64cdf0e10cSrcweir TKGet( TK_Height ), 65cdf0e10cSrcweir TKGet( TK_Moveable ), 66cdf0e10cSrcweir TKGet( TK_PositionX ), 67cdf0e10cSrcweir TKGet( TK_PositionY ), 68cdf0e10cSrcweir TKGet( TK_Title ), 69cdf0e10cSrcweir TKGet( TK_Width ) }; 70cdf0e10cSrcweir 71cdf0e10cSrcweir Any pValues[] = { 72cdf0e10cSrcweir Any( sal_True ), 73cdf0e10cSrcweir Any( sal_Int32( DIALOG_HEIGHT ) ), 74cdf0e10cSrcweir Any( sal_True ), 75cdf0e10cSrcweir Any( sal_Int32( 200 ) ), 76cdf0e10cSrcweir Any( sal_Int32( 52 ) ), 77*880c69c6SAriel Constenla-Haile Any( getString( STR_SUN_OPTIMIZATION_WIZARD2 ) ), 78cdf0e10cSrcweir Any( sal_Int32( OD_DIALOG_WIDTH ) ) }; 79cdf0e10cSrcweir 80cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount ); 83cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount ); 84cdf0e10cSrcweir 85cdf0e10cSrcweir mxDialogModelMultiPropertySet->setPropertyValues( aNames, aValues ); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir // ----------------------------------------------------------------------------- 89cdf0e10cSrcweir 90cdf0e10cSrcweir void OptimizerDialog::InitRoadmap() 91cdf0e10cSrcweir { 92cdf0e10cSrcweir try 93cdf0e10cSrcweir { 94cdf0e10cSrcweir OUString pNames[] = { 95cdf0e10cSrcweir TKGet( TK_Height ), 96cdf0e10cSrcweir TKGet( TK_PositionX ), 97cdf0e10cSrcweir TKGet( TK_PositionY ), 98cdf0e10cSrcweir TKGet( TK_Step ), 99cdf0e10cSrcweir TKGet( TK_TabIndex ), 100cdf0e10cSrcweir TKGet( TK_Width ) }; 101cdf0e10cSrcweir 102cdf0e10cSrcweir Any pValues[] = { 103cdf0e10cSrcweir Any( sal_Int32( DIALOG_HEIGHT - 26 ) ), 104cdf0e10cSrcweir Any( sal_Int32( 0 ) ), 105cdf0e10cSrcweir Any( sal_Int32( 0 ) ), 106cdf0e10cSrcweir Any( sal_Int32( 0 ) ), 107cdf0e10cSrcweir Any( mnTabIndex++ ), 108cdf0e10cSrcweir Any( sal_Int32( 85 ) ) }; 109cdf0e10cSrcweir 110cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount ); 113cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir mxRoadmapControlModel = insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRoadmapModel" ) ), 116cdf0e10cSrcweir TKGet( TK_rdmNavi ), aNames, aValues ); 117cdf0e10cSrcweir 118cdf0e10cSrcweir Reference< XPropertySet > xPropertySet( mxRoadmapControlModel, UNO_QUERY_THROW ); 119cdf0e10cSrcweir xPropertySet->setPropertyValue( TKGet( TK_Name ), Any( TKGet( TK_rdmNavi ) ) ); 120cdf0e10cSrcweir mxRoadmapControl = mxDialogControlContainer->getControl( TKGet( TK_rdmNavi ) ); 121cdf0e10cSrcweir InsertRoadmapItem( 0, sal_True, getString( STR_INTRODUCTION ), ITEM_ID_INTRODUCTION ); 122cdf0e10cSrcweir InsertRoadmapItem( 1, sal_True, getString( STR_SLIDES ), ITEM_ID_SLIDES ); 123cdf0e10cSrcweir InsertRoadmapItem( 2, sal_True, getString( STR_IMAGE_OPTIMIZATION ), ITEM_ID_GRAPHIC_OPTIMIZATION ); 124cdf0e10cSrcweir InsertRoadmapItem( 3, sal_True, getString( STR_OLE_OBJECTS ), ITEM_ID_OLE_OPTIMIZATION ); 125cdf0e10cSrcweir InsertRoadmapItem( 4, sal_True, getString( STR_SUMMARY ), ITEM_ID_SUMMARY ); 126cdf0e10cSrcweir 127*880c69c6SAriel Constenla-Haile rtl::OUString sBitmapPath( getPath( TK_BitmapPath ) ); 128*880c69c6SAriel Constenla-Haile rtl::OUString sBitmap( isHighContrast() ? rtl::OUString::createFromAscii( "/minimizepresi_80_h.png" ) 129*880c69c6SAriel Constenla-Haile : rtl::OUString::createFromAscii( "/minimizepresi_80.png" ) ); 130*880c69c6SAriel Constenla-Haile rtl::OUString sURL( sBitmapPath += sBitmap ); 131cdf0e10cSrcweir 132*880c69c6SAriel Constenla-Haile xPropertySet->setPropertyValue( TKGet( TK_ImageURL ), Any( sURL ) ); 133cdf0e10cSrcweir xPropertySet->setPropertyValue( TKGet( TK_Activated ), Any( (sal_Bool)sal_True ) ); 134cdf0e10cSrcweir xPropertySet->setPropertyValue( TKGet( TK_Complete ), Any( (sal_Bool)sal_True ) ); 135cdf0e10cSrcweir xPropertySet->setPropertyValue( TKGet( TK_CurrentItemID ), Any( (sal_Int16)ITEM_ID_INTRODUCTION ) ); 136cdf0e10cSrcweir xPropertySet->setPropertyValue( TKGet( TK_Text ), Any( getString( STR_STEPS ) ) ); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir catch( Exception& ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir } 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir // ----------------------------------------------------------------------------- 144cdf0e10cSrcweir 145cdf0e10cSrcweir void OptimizerDialog::InsertRoadmapItem( const sal_Int32 nIndex, const sal_Bool bEnabled, const rtl::OUString& rLabel, const sal_Int32 nItemID ) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir try 148cdf0e10cSrcweir { 149cdf0e10cSrcweir Reference< XSingleServiceFactory > xSFRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW ); 150cdf0e10cSrcweir Reference< XIndexContainer > aIndexContainerRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW ); 151cdf0e10cSrcweir Reference< XInterface > xRoadmapItem( xSFRoadmap->createInstance(), UNO_QUERY_THROW ); 152cdf0e10cSrcweir Reference< XPropertySet > xPropertySet( xRoadmapItem, UNO_QUERY_THROW ); 153cdf0e10cSrcweir xPropertySet->setPropertyValue( TKGet( TK_Label ), Any( rLabel ) ); 154cdf0e10cSrcweir xPropertySet->setPropertyValue( TKGet( TK_Enabled ), Any( bEnabled ) ); 155cdf0e10cSrcweir xPropertySet->setPropertyValue( TKGet( TK_ID ), Any( nItemID ) ); 156cdf0e10cSrcweir aIndexContainerRoadmap->insertByIndex( nIndex, Any( xRoadmapItem ) ); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir catch( Exception& ) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir 161cdf0e10cSrcweir } 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir // ----------------------------------------------------------------------------- 165cdf0e10cSrcweir 166cdf0e10cSrcweir void OptimizerDialog::UpdateConfiguration() 167cdf0e10cSrcweir { 168cdf0e10cSrcweir sal_Int16 nInt16 = 0; 169cdf0e10cSrcweir OUString aString; 170cdf0e10cSrcweir Any aAny; 171cdf0e10cSrcweir 172cdf0e10cSrcweir Sequence< sal_Int16 > aSelectedItems; 173cdf0e10cSrcweir Sequence< OUString > aStringItemList; 174cdf0e10cSrcweir 175cdf0e10cSrcweir // page0 176cdf0e10cSrcweir aAny = getControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_SelectedItems ) ); 177cdf0e10cSrcweir if ( aAny >>= aSelectedItems ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir if ( aSelectedItems.getLength() ) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir sal_Int16 nSelectedItem = aSelectedItems[ 0 ]; 182cdf0e10cSrcweir aAny = getControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_StringItemList ) ); 183cdf0e10cSrcweir if ( aAny >>= aStringItemList ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir if ( aStringItemList.getLength() > nSelectedItem ) 186cdf0e10cSrcweir SetConfigProperty( TK_Name, Any( aStringItemList[ nSelectedItem ] ) ); 187cdf0e10cSrcweir } 188cdf0e10cSrcweir } 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir aAny = getControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ) ); 192cdf0e10cSrcweir if ( aAny >>= nInt16 ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir if ( nInt16 ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_SelectedItems ) ); 197cdf0e10cSrcweir if ( aAny >>= aSelectedItems ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir if ( aSelectedItems.getLength() ) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir sal_Int16 nSelectedItem = aSelectedItems[ 0 ]; 202cdf0e10cSrcweir aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_StringItemList ) ); 203cdf0e10cSrcweir if ( aAny >>= aStringItemList ) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir if ( aStringItemList.getLength() > nSelectedItem ) 206cdf0e10cSrcweir SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir } 209cdf0e10cSrcweir } 210cdf0e10cSrcweir } 211cdf0e10cSrcweir } 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir // ----------------------------------------------------------------------------- 215cdf0e10cSrcweir 216*880c69c6SAriel Constenla-Haile OptimizerDialog::OptimizerDialog( const Reference< XComponentContext > &rxMSF, Reference< XFrame >& rxFrame, Reference< XDispatch > rxStatusDispatcher ) : 217*880c69c6SAriel Constenla-Haile UnoDialog( rxMSF, rxFrame ), 218*880c69c6SAriel Constenla-Haile ConfigurationAccess( rxMSF, NULL ), 219*880c69c6SAriel Constenla-Haile mnCurrentStep( 0 ), 220*880c69c6SAriel Constenla-Haile mnTabIndex( 0 ), 221*880c69c6SAriel Constenla-Haile mxMSF( rxMSF ), 222*880c69c6SAriel Constenla-Haile mxFrame( rxFrame ), 223*880c69c6SAriel Constenla-Haile mxItemListener( new ItemListener( *this ) ), 224*880c69c6SAriel Constenla-Haile mxActionListener( new ActionListener( *this ) ), 225*880c69c6SAriel Constenla-Haile mxActionListenerListBox0Pg0( new ActionListenerListBox0Pg0( *this ) ), 226*880c69c6SAriel Constenla-Haile mxTextListenerFormattedField0Pg1( new TextListenerFormattedField0Pg1( *this ) ), 227*880c69c6SAriel Constenla-Haile mxTextListenerComboBox0Pg1( new TextListenerComboBox0Pg1( *this ) ), 228*880c69c6SAriel Constenla-Haile mxSpinListenerFormattedField0Pg1( new SpinListenerFormattedField0Pg1( *this ) ), 229*880c69c6SAriel Constenla-Haile mxStatusDispatcher( rxStatusDispatcher ) 230cdf0e10cSrcweir { 231*880c69c6SAriel Constenla-Haile Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY_THROW ); 232cdf0e10cSrcweir mbIsReadonly = xStorable->isReadonly(); 233cdf0e10cSrcweir 234cdf0e10cSrcweir InitDialog(); 235cdf0e10cSrcweir InitRoadmap(); 236cdf0e10cSrcweir InitNavigationBar(); 237cdf0e10cSrcweir InitPage0(); 238cdf0e10cSrcweir InitPage1(); 239cdf0e10cSrcweir InitPage2(); 240cdf0e10cSrcweir InitPage3(); 241cdf0e10cSrcweir InitPage4(); 242cdf0e10cSrcweir ActivatePage( 0 ); 243cdf0e10cSrcweir 244cdf0e10cSrcweir OptimizationStats aStats; 245*880c69c6SAriel Constenla-Haile aStats.InitializeStatusValuesFromDocument( mxController->getModel() ); 246cdf0e10cSrcweir Sequence< PropertyValue > aStatusSequence( aStats.GetStatusSequence() ); 247cdf0e10cSrcweir UpdateStatus( aStatusSequence ); 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir // ----------------------------------------------------------------------------- 251cdf0e10cSrcweir 252cdf0e10cSrcweir OptimizerDialog::~OptimizerDialog() 253cdf0e10cSrcweir { 254cdf0e10cSrcweir // not saving configuration if the dialog has been finished via cancel or close window 255cdf0e10cSrcweir if ( mbStatus ) 256cdf0e10cSrcweir SaveConfiguration(); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir 259cdf0e10cSrcweir // ----------------------------------------------------------------------------- 260cdf0e10cSrcweir 261cdf0e10cSrcweir sal_Bool OptimizerDialog::execute() 262cdf0e10cSrcweir { 263cdf0e10cSrcweir Reference< XItemEventBroadcaster > maRoadmapBroadcaster( mxRoadmapControl, UNO_QUERY_THROW ); 264*880c69c6SAriel Constenla-Haile maRoadmapBroadcaster->addItemListener( mxItemListener ); 265cdf0e10cSrcweir UnoDialog::execute(); 266cdf0e10cSrcweir UpdateConfiguration(); // taking actual control settings for the configuration 267*880c69c6SAriel Constenla-Haile maRoadmapBroadcaster->removeItemListener( mxItemListener ); 268cdf0e10cSrcweir return mbStatus; 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir // ----------------------------------------------------------------------------- 272cdf0e10cSrcweir 273cdf0e10cSrcweir void OptimizerDialog::SwitchPage( sal_Int16 nNewStep ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir if ( ( nNewStep != mnCurrentStep ) && ( ( nNewStep <= MAX_STEP ) || ( nNewStep >= 0 ) ) ) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir sal_Int16 nOldStep = mnCurrentStep; 278cdf0e10cSrcweir if ( nNewStep == 0 ) 279cdf0e10cSrcweir disableControl( TKGet( TK_btnNavBack ) ); 280cdf0e10cSrcweir else if ( nOldStep == 0 ) 281cdf0e10cSrcweir enableControl( TKGet( TK_btnNavBack ) ); 282cdf0e10cSrcweir 283cdf0e10cSrcweir if ( nNewStep == MAX_STEP ) 284cdf0e10cSrcweir disableControl( TKGet( TK_btnNavNext ) ); 285cdf0e10cSrcweir else if ( nOldStep == MAX_STEP ) 286cdf0e10cSrcweir enableControl( TKGet( TK_btnNavNext ) ); 287cdf0e10cSrcweir 288cdf0e10cSrcweir setControlProperty( TKGet( TK_rdmNavi ), TKGet( TK_CurrentItemID ), Any( nNewStep ) ); 289cdf0e10cSrcweir 290cdf0e10cSrcweir DeactivatePage( nOldStep ); 291cdf0e10cSrcweir UpdateControlStates( nNewStep ); 292cdf0e10cSrcweir 293cdf0e10cSrcweir ActivatePage( nNewStep ); 294cdf0e10cSrcweir mnCurrentStep = nNewStep; 295cdf0e10cSrcweir } 296cdf0e10cSrcweir } 297cdf0e10cSrcweir 298cdf0e10cSrcweir void OptimizerDialog::UpdateControlStates( sal_Int16 nPage ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir switch( nPage ) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir case 0 : UpdateControlStatesPage0(); break; 303cdf0e10cSrcweir case 1 : UpdateControlStatesPage1(); break; 304cdf0e10cSrcweir case 2 : UpdateControlStatesPage2(); break; 305cdf0e10cSrcweir case 3 : UpdateControlStatesPage3(); break; 306cdf0e10cSrcweir case 4 : UpdateControlStatesPage4(); break; 307cdf0e10cSrcweir default: 308cdf0e10cSrcweir { 309cdf0e10cSrcweir UpdateControlStatesPage0(); 310cdf0e10cSrcweir UpdateControlStatesPage1(); 311cdf0e10cSrcweir UpdateControlStatesPage2(); 312cdf0e10cSrcweir UpdateControlStatesPage3(); 313cdf0e10cSrcweir UpdateControlStatesPage4(); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir } 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir // ----------------------------------------------------------------------------- 319cdf0e10cSrcweir 320cdf0e10cSrcweir rtl::OUString OptimizerDialog::GetSelectedString( const PPPOptimizerTokenEnum eToken ) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir OUString aSelectedItem; 323cdf0e10cSrcweir Sequence< sal_Int16 > sSelectedItems; 324cdf0e10cSrcweir Sequence< OUString > sItemList; 325cdf0e10cSrcweir 326cdf0e10cSrcweir if ( ( getControlProperty( TKGet( eToken ), TKGet( TK_SelectedItems ) ) >>= sSelectedItems ) && 327cdf0e10cSrcweir ( getControlProperty( TKGet( eToken ), TKGet( TK_StringItemList ) ) >>= sItemList ) ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir if ( sSelectedItems.getLength() == 1 ) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir sal_Int16 nSelectedItem = sSelectedItems[ 0 ]; 332cdf0e10cSrcweir if ( nSelectedItem < sItemList.getLength() ) 333cdf0e10cSrcweir aSelectedItem = sItemList[ nSelectedItem ]; 334cdf0e10cSrcweir } 335cdf0e10cSrcweir } 336cdf0e10cSrcweir return aSelectedItem; 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir // ----------------------------------------------------------------------------- 340cdf0e10cSrcweir 341cdf0e10cSrcweir void OptimizerDialog::UpdateStatus( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rStatus ) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir if ( mxReschedule.is() ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir maStats.InitializeStatusValues( rStatus ); 346cdf0e10cSrcweir const Any* pVal( maStats.GetStatusValue( TK_Status ) ); 347cdf0e10cSrcweir if ( pVal ) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir rtl::OUString sStatus; 350cdf0e10cSrcweir if ( *pVal >>= sStatus ) 351cdf0e10cSrcweir { 352cdf0e10cSrcweir setControlProperty( TKGet( TK_FixedText1Pg4 ), TKGet( TK_Enabled ), Any( sal_True ) ); 353*880c69c6SAriel Constenla-Haile setControlProperty( TKGet( TK_FixedText1Pg4 ), TKGet( TK_Label ), Any( getString( TKGet( sStatus ) ) ) ); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir } 356cdf0e10cSrcweir pVal = maStats.GetStatusValue( TK_Progress ); 357cdf0e10cSrcweir if ( pVal ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir sal_Int32 nProgress = 0; 360cdf0e10cSrcweir if ( *pVal >>= nProgress ) 361cdf0e10cSrcweir setControlProperty( TKGet( TK_Progress ), TKGet( TK_ProgressValue ), Any( nProgress ) ); 362cdf0e10cSrcweir } 363cdf0e10cSrcweir pVal = maStats.GetStatusValue( TK_OpenNewDocument ); 364cdf0e10cSrcweir if ( pVal ) 365cdf0e10cSrcweir SetConfigProperty( TK_OpenNewDocument, *pVal ); 366cdf0e10cSrcweir 367cdf0e10cSrcweir mxReschedule->reschedule(); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir // ----------------------------------------------------------------------------- 372cdf0e10cSrcweir 373*880c69c6SAriel Constenla-Haile void ItemListener::itemStateChanged( const ItemEvent& Event ) 374cdf0e10cSrcweir throw ( RuntimeException ) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir try 377cdf0e10cSrcweir { 378cdf0e10cSrcweir sal_Int16 nState; 379cdf0e10cSrcweir OUString aControlName; 380cdf0e10cSrcweir Reference< XControl > xControl; 381cdf0e10cSrcweir Any aSource( Event.Source ); 382cdf0e10cSrcweir if ( aSource >>= xControl ) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir Reference< XPropertySet > xPropertySet( xControl->getModel(), UNO_QUERY_THROW ); 385cdf0e10cSrcweir xPropertySet->getPropertyValue( TKGet( TK_Name ) ) >>= aControlName; 386cdf0e10cSrcweir PPPOptimizerTokenEnum eControl( TKGet( aControlName ) ); 387cdf0e10cSrcweir switch( eControl ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir case TK_rdmNavi : 390cdf0e10cSrcweir { 391*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SwitchPage( static_cast< sal_Int16 >( Event.ItemId ) ); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir break; 394cdf0e10cSrcweir case TK_CheckBox1Pg1 : 395cdf0e10cSrcweir { 396cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 397*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_RemoveCropArea, Any( nState != 0 ) ); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir break; 400cdf0e10cSrcweir case TK_CheckBox2Pg1 : 401cdf0e10cSrcweir { 402cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 403*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_EmbedLinkedGraphics, Any( nState != 0 ) ); 404cdf0e10cSrcweir } 405cdf0e10cSrcweir break; 406cdf0e10cSrcweir case TK_CheckBox0Pg2 : 407cdf0e10cSrcweir { 408cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 409cdf0e10cSrcweir { 410*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_OLEOptimization, Any( nState != 0 ) ); 411*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); 412*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); 413cdf0e10cSrcweir } 414cdf0e10cSrcweir } 415cdf0e10cSrcweir break; 416cdf0e10cSrcweir case TK_RadioButton0Pg1 : 417cdf0e10cSrcweir { 418cdf0e10cSrcweir sal_Int16 nInt16 = 0; 419cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nInt16 ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir nInt16 ^= 1; 422*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nInt16 != 0 ) ); 423*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_FixedText1Pg1 ), TKGet( TK_Enabled ), Any( nInt16 != 0 ) ); 424*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_Enabled ), Any( nInt16 != 0 ) ); 425cdf0e10cSrcweir } 426cdf0e10cSrcweir } 427cdf0e10cSrcweir break; 428cdf0e10cSrcweir case TK_RadioButton1Pg1 : 429cdf0e10cSrcweir { 430cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 431cdf0e10cSrcweir { 432*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nState != 0 ) ); 433*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_FixedText1Pg1 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); 434*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir } 437cdf0e10cSrcweir break; 438cdf0e10cSrcweir case TK_RadioButton0Pg2 : 439cdf0e10cSrcweir { 440cdf0e10cSrcweir sal_Int16 nInt16; 441cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nInt16 ) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir nInt16 ^= 1; 444*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nInt16 ) ); 445cdf0e10cSrcweir } 446cdf0e10cSrcweir } 447cdf0e10cSrcweir break; 448cdf0e10cSrcweir case TK_RadioButton1Pg2 : 449cdf0e10cSrcweir { 450cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 451*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nState ) ); 452cdf0e10cSrcweir } 453cdf0e10cSrcweir break; 454cdf0e10cSrcweir case TK_CheckBox0Pg3 : 455cdf0e10cSrcweir { 456cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 457*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_DeleteUnusedMasterPages, Any( nState != 0 ) ); 458cdf0e10cSrcweir } 459cdf0e10cSrcweir break; 460cdf0e10cSrcweir case TK_CheckBox1Pg3 : 461cdf0e10cSrcweir { 462cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 463*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_DeleteNotesPages, Any( nState != 0 ) ); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir break; 466cdf0e10cSrcweir case TK_CheckBox2Pg3 : 467cdf0e10cSrcweir { 468cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 469*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_DeleteHiddenSlides, Any( nState != 0 ) ); 470cdf0e10cSrcweir } 471cdf0e10cSrcweir break; 472cdf0e10cSrcweir case TK_CheckBox3Pg3 : 473cdf0e10cSrcweir { 474cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 475*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); 476cdf0e10cSrcweir } 477cdf0e10cSrcweir break; 478cdf0e10cSrcweir case TK_CheckBox1Pg4 : 479cdf0e10cSrcweir { 480cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 481*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir break; 484cdf0e10cSrcweir case TK_RadioButton0Pg4 : 485cdf0e10cSrcweir case TK_RadioButton1Pg4 : 486cdf0e10cSrcweir { 487cdf0e10cSrcweir if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) 488*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_SaveAs, Any( eControl == TK_RadioButton1Pg4 ? nState != 0 : nState == 0 ) ); 489cdf0e10cSrcweir } 490cdf0e10cSrcweir break; 491cdf0e10cSrcweir default: 492cdf0e10cSrcweir break; 493cdf0e10cSrcweir } 494cdf0e10cSrcweir } 495cdf0e10cSrcweir } 496cdf0e10cSrcweir catch ( Exception& ) 497cdf0e10cSrcweir { 498*880c69c6SAriel Constenla-Haile 499cdf0e10cSrcweir } 500cdf0e10cSrcweir } 501*880c69c6SAriel Constenla-Haile void ItemListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) 502*880c69c6SAriel Constenla-Haile throw ( com::sun::star::uno::RuntimeException ) 503*880c69c6SAriel Constenla-Haile { 504*880c69c6SAriel Constenla-Haile } 505cdf0e10cSrcweir 506cdf0e10cSrcweir // ----------------------------------------------------------------------------- 507cdf0e10cSrcweir 508*880c69c6SAriel Constenla-Haile void ActionListener::actionPerformed( const ActionEvent& rEvent ) 509cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir switch( TKGet( rEvent.ActionCommand ) ) 512cdf0e10cSrcweir { 513*880c69c6SAriel Constenla-Haile case TK_btnNavHelp : 514*880c69c6SAriel Constenla-Haile { 515*880c69c6SAriel Constenla-Haile try 516*880c69c6SAriel Constenla-Haile { 517*880c69c6SAriel Constenla-Haile static Reference< XFrame > xHelpFrame; 518*880c69c6SAriel Constenla-Haile if ( !xHelpFrame.is() ) 519*880c69c6SAriel Constenla-Haile { 520*880c69c6SAriel Constenla-Haile rtl::OUString sHelpFile( mrOptimizerDialog.getPath( TK_HelpFile ) ); 521*880c69c6SAriel Constenla-Haile Reference< XDesktop > desktop( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithContext( 522*880c69c6SAriel Constenla-Haile OUString::createFromAscii( "com.sun.star.frame.Desktop" ), mrOptimizerDialog.GetComponentContext() ), UNO_QUERY_THROW ); 523*880c69c6SAriel Constenla-Haile Reference< XSimpleFileAccess > xSimpleFileAccess( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithContext( 524*880c69c6SAriel Constenla-Haile OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), mrOptimizerDialog.GetComponentContext() ), UNO_QUERY_THROW ); 525*880c69c6SAriel Constenla-Haile Reference< XInputStream > xInputStream( xSimpleFileAccess->openFileRead( sHelpFile ) ); 526*880c69c6SAriel Constenla-Haile Reference< XDesktop > xDesktop( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithContext( 527*880c69c6SAriel Constenla-Haile OUString::createFromAscii( "com.sun.star.frame.Desktop" ), mrOptimizerDialog.GetComponentContext() ), UNO_QUERY_THROW ); 528*880c69c6SAriel Constenla-Haile Reference< XFrame > xDesktopFrame( xDesktop, UNO_QUERY_THROW ); 529*880c69c6SAriel Constenla-Haile xHelpFrame = Reference< XFrame >( xDesktopFrame->findFrame( TKGet( TK__blank ), 0 ) ); 530*880c69c6SAriel Constenla-Haile Reference< XCloseBroadcaster > xCloseBroadcaster( xHelpFrame, UNO_QUERY_THROW ); 531*880c69c6SAriel Constenla-Haile xCloseBroadcaster->addCloseListener( new HelpCloseListener( xHelpFrame ) ); 532*880c69c6SAriel Constenla-Haile Reference< XComponentLoader > xLoader( xHelpFrame, UNO_QUERY_THROW ); 533*880c69c6SAriel Constenla-Haile 534*880c69c6SAriel Constenla-Haile Sequence< PropertyValue > aLoadProps( 2 ); 535*880c69c6SAriel Constenla-Haile aLoadProps[ 0 ].Name = TKGet( TK_ReadOnly ); 536*880c69c6SAriel Constenla-Haile aLoadProps[ 0 ].Value <<= (sal_Bool)( sal_True ); 537*880c69c6SAriel Constenla-Haile aLoadProps[ 1 ].Name = TKGet( TK_InputStream ); 538*880c69c6SAriel Constenla-Haile aLoadProps[ 1 ].Value <<= xInputStream; 539*880c69c6SAriel Constenla-Haile 540*880c69c6SAriel Constenla-Haile Reference< XComponent >( xLoader->loadComponentFromURL( OUString::createFromAscii( "private:stream" ), 541*880c69c6SAriel Constenla-Haile TKGet( TK__self ), 0, aLoadProps ) ); 542*880c69c6SAriel Constenla-Haile 543*880c69c6SAriel Constenla-Haile Reference< XPropertySet > xPropSet( xHelpFrame, UNO_QUERY_THROW ); 544*880c69c6SAriel Constenla-Haile Reference< XLayoutManager > xLayoutManager; 545*880c69c6SAriel Constenla-Haile if ( xPropSet->getPropertyValue( OUString::createFromAscii( "LayoutManager" ) ) >>= xLayoutManager ) 546*880c69c6SAriel Constenla-Haile { 547*880c69c6SAriel Constenla-Haile xLayoutManager->setVisible( sal_False ); 548*880c69c6SAriel Constenla-Haile xLayoutManager->hideElement( OUString::createFromAscii( "private:resource/menubar/menubar" ) ); 549*880c69c6SAriel Constenla-Haile xLayoutManager->destroyElement( OUString::createFromAscii( "private:resource/statusbar/statusbar" ) ); 550*880c69c6SAriel Constenla-Haile } 551*880c69c6SAriel Constenla-Haile } 552*880c69c6SAriel Constenla-Haile } 553*880c69c6SAriel Constenla-Haile catch( Exception& ) 554*880c69c6SAriel Constenla-Haile { 555*880c69c6SAriel Constenla-Haile 556*880c69c6SAriel Constenla-Haile } 557*880c69c6SAriel Constenla-Haile } 558*880c69c6SAriel Constenla-Haile break; 559*880c69c6SAriel Constenla-Haile case TK_btnNavBack : mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep - 1 ); break; 560*880c69c6SAriel Constenla-Haile case TK_btnNavNext : mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep + 1 ); break; 561cdf0e10cSrcweir case TK_btnNavFinish : 562cdf0e10cSrcweir { 563*880c69c6SAriel Constenla-Haile mrOptimizerDialog.UpdateConfiguration(); 564cdf0e10cSrcweir 565*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SwitchPage( ITEM_ID_SUMMARY ); 566*880c69c6SAriel Constenla-Haile mrOptimizerDialog.DisablePage( ITEM_ID_SUMMARY ); 567*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavHelp ), TKGet( TK_Enabled ), Any( sal_False ) ); 568*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavBack ), TKGet( TK_Enabled ), Any( sal_False ) ); 569*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavNext ), TKGet( TK_Enabled ), Any( sal_False ) ); 570*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavFinish ), TKGet( TK_Enabled ), Any( sal_False ) ); 571*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavCancel ), TKGet( TK_Enabled ), Any( sal_False ) ); 572*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_FixedText0Pg4 ), TKGet( TK_Enabled ), Any( sal_True ) ); 573cdf0e10cSrcweir 574cdf0e10cSrcweir // check if we have to open the FileDialog 575cdf0e10cSrcweir sal_Bool bSuccessfullyExecuted = sal_True; 576cdf0e10cSrcweir sal_Int16 nInt16 = 0; 577*880c69c6SAriel Constenla-Haile mrOptimizerDialog.getControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ) ) >>= nInt16; 578cdf0e10cSrcweir if ( nInt16 ) 579cdf0e10cSrcweir { 580cdf0e10cSrcweir rtl::OUString aSaveAsURL; 581*880c69c6SAriel Constenla-Haile FileOpenDialog aFileOpenDialog( ((UnoDialog&)mrOptimizerDialog).mxMSF ); 582cdf0e10cSrcweir 583cdf0e10cSrcweir // generating default file name 584*880c69c6SAriel Constenla-Haile Reference< XStorable > xStorable( mrOptimizerDialog.mxController->getModel(), UNO_QUERY ); 585cdf0e10cSrcweir if ( xStorable.is() && xStorable->hasLocation() ) 586cdf0e10cSrcweir { 587cdf0e10cSrcweir rtl::OUString aLocation( xStorable->getLocation() ); 588cdf0e10cSrcweir if ( aLocation.getLength() ) 589cdf0e10cSrcweir { 590cdf0e10cSrcweir sal_Int32 nIndex = aLocation.lastIndexOf( '/', aLocation.getLength() - 1 ); 591cdf0e10cSrcweir if ( nIndex >= 0 ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir if ( nIndex < aLocation.getLength() - 1 ) 594cdf0e10cSrcweir aLocation = aLocation.copy( nIndex + 1 ); 595cdf0e10cSrcweir 596cdf0e10cSrcweir // remove extension 597cdf0e10cSrcweir nIndex = aLocation.lastIndexOf( '.', aLocation.getLength() - 1 ); 598cdf0e10cSrcweir if ( nIndex >= 0 ) 599cdf0e10cSrcweir aLocation = aLocation.copy( 0, nIndex ); 600cdf0e10cSrcweir 601cdf0e10cSrcweir // adding .mini 602cdf0e10cSrcweir aLocation = aLocation.concat( OUString::createFromAscii( ".mini" ) ); 603cdf0e10cSrcweir aFileOpenDialog.setDefaultName( aLocation ); 604cdf0e10cSrcweir } 605cdf0e10cSrcweir } 606cdf0e10cSrcweir } 607cdf0e10cSrcweir sal_Bool bDialogExecuted = aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK; 608cdf0e10cSrcweir if ( bDialogExecuted ) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir aSaveAsURL = aFileOpenDialog.getURL(); 611*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_SaveAsURL, Any( aSaveAsURL ) ); 612*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_FilterName, Any( aFileOpenDialog.getFilterName() ) ); 613cdf0e10cSrcweir } 614cdf0e10cSrcweir if ( !aSaveAsURL.getLength() ) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir // something goes wrong... 617cdf0e10cSrcweir bSuccessfullyExecuted = sal_False; 618cdf0e10cSrcweir } 619cdf0e10cSrcweir 620cdf0e10cSrcweir // waiting for 500ms 621*880c69c6SAriel Constenla-Haile if ( mrOptimizerDialog.mxReschedule.is() ) 622cdf0e10cSrcweir { 623*880c69c6SAriel Constenla-Haile mrOptimizerDialog.mxReschedule->reschedule(); 624cdf0e10cSrcweir for ( sal_uInt32 i = osl_getGlobalTimer(); ( i + 500 ) > ( osl_getGlobalTimer() ); ) 625*880c69c6SAriel Constenla-Haile mrOptimizerDialog.mxReschedule->reschedule(); 626cdf0e10cSrcweir } 627cdf0e10cSrcweir } 628cdf0e10cSrcweir if ( bSuccessfullyExecuted ) 629cdf0e10cSrcweir { // now check if we have to store a session template 630cdf0e10cSrcweir nInt16 = 0; 631cdf0e10cSrcweir OUString aSettingsName; 632*880c69c6SAriel Constenla-Haile mrOptimizerDialog.getControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_State ) ) >>= nInt16; 633*880c69c6SAriel Constenla-Haile mrOptimizerDialog.getControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Text ) ) >>= aSettingsName; 634cdf0e10cSrcweir if ( nInt16 && aSettingsName.getLength() ) 635cdf0e10cSrcweir { 636*880c69c6SAriel Constenla-Haile std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSettingsName ) ); 637*880c69c6SAriel Constenla-Haile std::vector< OptimizerSettings >& rSettings( mrOptimizerDialog.GetOptimizerSettings() ); 638cdf0e10cSrcweir OptimizerSettings aNewSettings( rSettings[ 0 ] ); 639cdf0e10cSrcweir aNewSettings.maName = aSettingsName; 640cdf0e10cSrcweir if ( aIter == rSettings.end() ) 641cdf0e10cSrcweir rSettings.push_back( aNewSettings ); 642cdf0e10cSrcweir else 643cdf0e10cSrcweir *aIter = aNewSettings; 644cdf0e10cSrcweir } 645cdf0e10cSrcweir } 646cdf0e10cSrcweir if ( bSuccessfullyExecuted ) 647cdf0e10cSrcweir { 648cdf0e10cSrcweir Sequence< Any > aArgs( 1 ); 649*880c69c6SAriel Constenla-Haile aArgs[ 0 ] <<= mrOptimizerDialog.GetFrame(); 650cdf0e10cSrcweir 651*880c69c6SAriel Constenla-Haile Reference < XDispatch > xDispatch( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext( 652*880c69c6SAriel Constenla-Haile OUString::createFromAscii( "com.sun.star.comp.PPPOptimizer" ), aArgs, mrOptimizerDialog.GetComponentContext() ), UNO_QUERY ); 653cdf0e10cSrcweir 654cdf0e10cSrcweir URL aURL; 655cdf0e10cSrcweir aURL.Protocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.com.sun.star.comp.PPPOptimizer:" ) ); 656cdf0e10cSrcweir aURL.Path = OUString( RTL_CONSTASCII_USTRINGPARAM( "optimize" ) ); 657cdf0e10cSrcweir 658cdf0e10cSrcweir Sequence< PropertyValue > lArguments( 3 ); 659cdf0e10cSrcweir lArguments[ 0 ].Name = TKGet( TK_Settings ); 660*880c69c6SAriel Constenla-Haile lArguments[ 0 ].Value <<= mrOptimizerDialog.GetConfigurationSequence(); 661*880c69c6SAriel Constenla-Haile lArguments[ 1 ].Name = TKGet( TK_StatusDispatcher ); 662*880c69c6SAriel Constenla-Haile lArguments[ 1 ].Value <<= mrOptimizerDialog.GetStatusDispatcher(); 663*880c69c6SAriel Constenla-Haile lArguments[ 2 ].Name = TKGet( TK_InformationDialog ); 664*880c69c6SAriel Constenla-Haile lArguments[ 2 ].Value <<= mrOptimizerDialog.GetFrame(); 665cdf0e10cSrcweir 666cdf0e10cSrcweir if( xDispatch.is() ) 667cdf0e10cSrcweir xDispatch->dispatch( aURL, lArguments ); 668cdf0e10cSrcweir 669*880c69c6SAriel Constenla-Haile mrOptimizerDialog.endExecute( bSuccessfullyExecuted ); 670cdf0e10cSrcweir } 671cdf0e10cSrcweir else 672cdf0e10cSrcweir { 673*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavHelp ), TKGet( TK_Enabled ), Any( sal_True ) ); 674*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavBack ), TKGet( TK_Enabled ), Any( sal_True ) ); 675*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavNext ), TKGet( TK_Enabled ), Any( sal_False ) ); 676*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavFinish ), TKGet( TK_Enabled ), Any( sal_True ) ); 677*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavCancel ), TKGet( TK_Enabled ), Any( sal_True ) ); 678*880c69c6SAriel Constenla-Haile mrOptimizerDialog.EnablePage( ITEM_ID_SUMMARY ); 679cdf0e10cSrcweir } 680cdf0e10cSrcweir } 681cdf0e10cSrcweir break; 682*880c69c6SAriel Constenla-Haile case TK_btnNavCancel : mrOptimizerDialog.endExecute( sal_False ); break; 683cdf0e10cSrcweir case TK_Button0Pg0 : // delete configuration 684cdf0e10cSrcweir { 685*880c69c6SAriel Constenla-Haile OUString aSelectedItem( mrOptimizerDialog.GetSelectedString( TK_ListBox0Pg0 ) ); 686cdf0e10cSrcweir if ( aSelectedItem.getLength() ) 687cdf0e10cSrcweir { 688*880c69c6SAriel Constenla-Haile std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSelectedItem ) ); 689*880c69c6SAriel Constenla-Haile std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() ); 690cdf0e10cSrcweir if ( aIter != rList.end() ) 691cdf0e10cSrcweir { 692cdf0e10cSrcweir rList.erase( aIter ); 693*880c69c6SAriel Constenla-Haile mrOptimizerDialog.UpdateControlStates(); 694cdf0e10cSrcweir } 695cdf0e10cSrcweir } 696cdf0e10cSrcweir } 697cdf0e10cSrcweir break; 698*880c69c6SAriel Constenla-Haile default: break; 699*880c69c6SAriel Constenla-Haile } 700*880c69c6SAriel Constenla-Haile } 701*880c69c6SAriel Constenla-Haile void ActionListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) 702*880c69c6SAriel Constenla-Haile throw ( com::sun::star::uno::RuntimeException ) 703cdf0e10cSrcweir { 704cdf0e10cSrcweir } 705cdf0e10cSrcweir 706cdf0e10cSrcweir // ----------------------------------------------------------------------------- 707cdf0e10cSrcweir 708*880c69c6SAriel Constenla-Haile void ActionListenerListBox0Pg0::actionPerformed( const ActionEvent& rEvent ) 709cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ) 710cdf0e10cSrcweir { 711*880c69c6SAriel Constenla-Haile if ( rEvent.ActionCommand.getLength() ) 712e4a7f284SAriel Constenla-Haile { 713*880c69c6SAriel Constenla-Haile std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( rEvent.ActionCommand ) ); 714*880c69c6SAriel Constenla-Haile std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() ); 715*880c69c6SAriel Constenla-Haile if ( aIter != rList.end() ) 716*880c69c6SAriel Constenla-Haile rList[ 0 ] = *aIter; 717*880c69c6SAriel Constenla-Haile } 718*880c69c6SAriel Constenla-Haile mrOptimizerDialog.UpdateControlStates(); 719*880c69c6SAriel Constenla-Haile } 720*880c69c6SAriel Constenla-Haile void ActionListenerListBox0Pg0::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) 721*880c69c6SAriel Constenla-Haile throw ( com::sun::star::uno::RuntimeException ) 722*880c69c6SAriel Constenla-Haile { 723cdf0e10cSrcweir } 724cdf0e10cSrcweir 725*880c69c6SAriel Constenla-Haile // ----------------------------------------------------------------------------- 726*880c69c6SAriel Constenla-Haile 727*880c69c6SAriel Constenla-Haile void TextListenerFormattedField0Pg1::textChanged( const TextEvent& /* rEvent */ ) 728*880c69c6SAriel Constenla-Haile throw ( com::sun::star::uno::RuntimeException ) 729*880c69c6SAriel Constenla-Haile { 730*880c69c6SAriel Constenla-Haile double fDouble = 0; 731*880c69c6SAriel Constenla-Haile Any aAny = mrOptimizerDialog.getControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ) ); 732*880c69c6SAriel Constenla-Haile if ( aAny >>= fDouble ) 733*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) ); 734*880c69c6SAriel Constenla-Haile } 735*880c69c6SAriel Constenla-Haile void TextListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) 736*880c69c6SAriel Constenla-Haile throw ( com::sun::star::uno::RuntimeException ) 737*880c69c6SAriel Constenla-Haile { 738*880c69c6SAriel Constenla-Haile } 739*880c69c6SAriel Constenla-Haile 740*880c69c6SAriel Constenla-Haile // ----------------------------------------------------------------------------- 741*880c69c6SAriel Constenla-Haile 742*880c69c6SAriel Constenla-Haile void TextListenerComboBox0Pg1::textChanged( const TextEvent& /* rEvent */ ) 743*880c69c6SAriel Constenla-Haile throw ( com::sun::star::uno::RuntimeException ) 744cdf0e10cSrcweir { 745cdf0e10cSrcweir rtl::OUString aString; 746*880c69c6SAriel Constenla-Haile Any aAny = mrOptimizerDialog.getControlProperty( TKGet( TK_ComboBox0Pg1 ), TKGet( TK_Text ) ); 747cdf0e10cSrcweir if ( aAny >>= aString ) 748cdf0e10cSrcweir { 749cdf0e10cSrcweir sal_Int32 nI0, nI1, nI2, nI3, nI4; 750cdf0e10cSrcweir nI0 = nI1 = nI2 = nI3 = nI4 = 0; 751cdf0e10cSrcweir 752*880c69c6SAriel Constenla-Haile if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ) == aString ) 753*880c69c6SAriel Constenla-Haile aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI4 ); 754*880c69c6SAriel Constenla-Haile else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ) == aString ) 755*880c69c6SAriel Constenla-Haile aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI4 ); 756*880c69c6SAriel Constenla-Haile else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ) == aString ) 757*880c69c6SAriel Constenla-Haile aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI4 ); 758*880c69c6SAriel Constenla-Haile else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ) == aString ) 759*880c69c6SAriel Constenla-Haile aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI4 ); 760cdf0e10cSrcweir 761*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( aString.toInt32() ) ); 762cdf0e10cSrcweir } 763cdf0e10cSrcweir } 764*880c69c6SAriel Constenla-Haile void TextListenerComboBox0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) 765*880c69c6SAriel Constenla-Haile throw ( com::sun::star::uno::RuntimeException ) 766*880c69c6SAriel Constenla-Haile { 767cdf0e10cSrcweir } 768cdf0e10cSrcweir 769cdf0e10cSrcweir // ----------------------------------------------------------------------------- 770cdf0e10cSrcweir 771*880c69c6SAriel Constenla-Haile void SpinListenerFormattedField0Pg1::up( const SpinEvent& /* rEvent */ ) 772cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ) 773cdf0e10cSrcweir { 774cdf0e10cSrcweir double fDouble; 775*880c69c6SAriel Constenla-Haile Any aAny = mrOptimizerDialog.getControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ) ); 776cdf0e10cSrcweir if ( aAny >>= fDouble ) 777cdf0e10cSrcweir { 778cdf0e10cSrcweir fDouble += 9; 779cdf0e10cSrcweir if ( fDouble > 100 ) 780cdf0e10cSrcweir fDouble = 100; 781*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( fDouble ) ); 782*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) ); 783cdf0e10cSrcweir } 784cdf0e10cSrcweir } 785*880c69c6SAriel Constenla-Haile void SpinListenerFormattedField0Pg1::down( const SpinEvent& /* rEvent */ ) 786cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir double fDouble; 789*880c69c6SAriel Constenla-Haile Any aAny = mrOptimizerDialog.getControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ) ); 790cdf0e10cSrcweir if ( aAny >>= fDouble ) 791cdf0e10cSrcweir { 792cdf0e10cSrcweir fDouble -= 9; 793cdf0e10cSrcweir if ( fDouble < 0 ) 794cdf0e10cSrcweir fDouble = 0; 795*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( fDouble ) ); 796*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) ); 797cdf0e10cSrcweir } 798cdf0e10cSrcweir } 799*880c69c6SAriel Constenla-Haile void SpinListenerFormattedField0Pg1::first( const SpinEvent& /* rEvent */ ) 800e4a7f284SAriel Constenla-Haile throw ( com::sun::star::uno::RuntimeException ) 801e4a7f284SAriel Constenla-Haile { 802*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( static_cast< double >( 0 ) ) ); 803*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)0 ) ); 804e4a7f284SAriel Constenla-Haile } 805*880c69c6SAriel Constenla-Haile void SpinListenerFormattedField0Pg1::last( const SpinEvent& /* rEvent */ ) 806e4a7f284SAriel Constenla-Haile throw ( com::sun::star::uno::RuntimeException ) 807cdf0e10cSrcweir { 808*880c69c6SAriel Constenla-Haile mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( static_cast< double >( 100 ) ) ); 809*880c69c6SAriel Constenla-Haile mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)100 ) ); 810*880c69c6SAriel Constenla-Haile } 811*880c69c6SAriel Constenla-Haile void SpinListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) 812*880c69c6SAriel Constenla-Haile throw ( com::sun::star::uno::RuntimeException ) 813*880c69c6SAriel Constenla-Haile { 814cdf0e10cSrcweir } 815e4a7f284SAriel Constenla-Haile 816*880c69c6SAriel Constenla-Haile // ----------------------------------------------------------------------------- 817*880c69c6SAriel Constenla-Haile 818*880c69c6SAriel Constenla-Haile void HelpCloseListener::addCloseListener( const Reference < XCloseListener >& ) throw( RuntimeException ) 819*880c69c6SAriel Constenla-Haile { 820*880c69c6SAriel Constenla-Haile } 821*880c69c6SAriel Constenla-Haile void HelpCloseListener::removeCloseListener( const Reference < XCloseListener >& ) throw( RuntimeException ) 822*880c69c6SAriel Constenla-Haile { 823*880c69c6SAriel Constenla-Haile } 824*880c69c6SAriel Constenla-Haile void HelpCloseListener::queryClosing( const EventObject&, sal_Bool /* bDeliverOwnership */ ) 825*880c69c6SAriel Constenla-Haile throw ( RuntimeException, CloseVetoException ) 826*880c69c6SAriel Constenla-Haile { 827*880c69c6SAriel Constenla-Haile } 828*880c69c6SAriel Constenla-Haile void HelpCloseListener::notifyClosing( const EventObject& ) 829*880c69c6SAriel Constenla-Haile throw ( RuntimeException ) 830*880c69c6SAriel Constenla-Haile { 831*880c69c6SAriel Constenla-Haile } 832*880c69c6SAriel Constenla-Haile void HelpCloseListener::disposing( const EventObject& ) throw ( RuntimeException ) 833*880c69c6SAriel Constenla-Haile { 834*880c69c6SAriel Constenla-Haile mrXFrame = NULL; 835*880c69c6SAriel Constenla-Haile } 836