fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sdext / source / minimizer / optimizerdialog.cxx
blob0a37e6b3e670d8b4291b22282f3c2a90f3f4b8d9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "optimizerdialog.hxx"
22 #include "pppoptimizer.hxx"
23 #include "fileopendialog.hxx"
24 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
25 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
26 #include <com/sun/star/io/XInputStream.hpp>
27 #include <com/sun/star/util/XCloseBroadcaster.hpp>
28 #include <com/sun/star/frame/XComponentLoader.hpp>
29 #include <com/sun/star/frame/XLayoutManager.hpp>
30 #include <sal/macros.h>
31 #include <osl/time.h>
34 // - OPTIMIZERDIALOG -
37 using namespace ::com::sun::star::io;
38 using namespace ::com::sun::star::ui;
39 using namespace ::com::sun::star::awt;
40 using namespace ::com::sun::star::ucb;
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::util;
43 using namespace ::com::sun::star::lang;
44 using namespace ::com::sun::star::frame;
45 using namespace ::com::sun::star::beans;
46 using namespace ::com::sun::star::script;
47 using namespace ::com::sun::star::container;
52 void OptimizerDialog::InitDialog()
54 // setting the dialog properties
55 OUString pNames[] = {
56 OUString("Closeable"),
57 OUString("Height"),
58 OUString("Moveable"),
59 OUString("PositionX"),
60 OUString("PositionY"),
61 OUString("Title"),
62 OUString("Width") };
64 Any pValues[] = {
65 Any( sal_True ),
66 Any( sal_Int32( DIALOG_HEIGHT ) ),
67 Any( sal_True ),
68 Any( sal_Int32( 200 ) ),
69 Any( sal_Int32( 52 ) ),
70 Any( getString( STR_SUN_OPTIMIZATION_WIZARD2 ) ),
71 Any( sal_Int32( OD_DIALOG_WIDTH ) ) };
73 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
75 Sequence< OUString > aNames( pNames, nCount );
76 Sequence< Any > aValues( pValues, nCount );
78 mxDialogModelMultiPropertySet->setPropertyValues( aNames, aValues );
83 void OptimizerDialog::InitRoadmap()
85 try
87 OUString pNames[] = {
88 OUString("Height"),
89 OUString("PositionX"),
90 OUString("PositionY"),
91 OUString("Step"),
92 OUString("TabIndex"),
93 OUString("Width") };
95 Any pValues[] = {
96 Any( sal_Int32( DIALOG_HEIGHT - 26 ) ),
97 Any( sal_Int32( 0 ) ),
98 Any( sal_Int32( 0 ) ),
99 Any( sal_Int32( 0 ) ),
100 Any( mnTabIndex++ ),
101 Any( sal_Int32( 85 ) ) };
103 sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
105 Sequence< OUString > aNames( pNames, nCount );
106 Sequence< Any > aValues( pValues, nCount );
108 mxRoadmapControlModel = insertControlModel( OUString( "com.sun.star.awt.UnoControlRoadmapModel" ),
109 "rdmNavi", aNames, aValues );
111 Reference< XPropertySet > xPropertySet( mxRoadmapControlModel, UNO_QUERY_THROW );
112 xPropertySet->setPropertyValue( "Name", Any( OUString("rdmNavi") ) );
113 mxRoadmapControl = mxDialog->getControl( "rdmNavi" );
114 InsertRoadmapItem( 0, true, getString( STR_INTRODUCTION ), ITEM_ID_INTRODUCTION );
115 InsertRoadmapItem( 1, true, getString( STR_SLIDES ), ITEM_ID_SLIDES );
116 InsertRoadmapItem( 2, true, getString( STR_IMAGE_OPTIMIZATION ), ITEM_ID_GRAPHIC_OPTIMIZATION );
117 InsertRoadmapItem( 3, true, getString( STR_OLE_OBJECTS ), ITEM_ID_OLE_OPTIMIZATION );
118 InsertRoadmapItem( 4, true, getString( STR_SUMMARY ), ITEM_ID_SUMMARY );
120 // Well, that's messy, but the
121 // BMP_PRESENTATION_MINIMIZER from sd module cannot be used here directly
122 // that UNO wizard dialog should be converted to ui
123 OUString sURL( "private:graphicrepository/sd/res/minimize_presi_80.png" );
125 xPropertySet->setPropertyValue( "ImageURL", Any( sURL ) );
126 xPropertySet->setPropertyValue( "Activated", Any( true ) );
127 xPropertySet->setPropertyValue( "Complete", Any( true ) );
128 xPropertySet->setPropertyValue( "CurrentItemID", Any( (sal_Int16)ITEM_ID_INTRODUCTION ) );
129 xPropertySet->setPropertyValue( "Text", Any( getString( STR_STEPS ) ) );
131 catch( Exception& )
138 void OptimizerDialog::InsertRoadmapItem( const sal_Int32 nIndex, const bool bEnabled, const OUString& rLabel, const sal_Int32 nItemID )
142 Reference< XSingleServiceFactory > xSFRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW );
143 Reference< XIndexContainer > aIndexContainerRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW );
144 Reference< XInterface > xRoadmapItem( xSFRoadmap->createInstance(), UNO_QUERY_THROW );
145 Reference< XPropertySet > xPropertySet( xRoadmapItem, UNO_QUERY_THROW );
146 xPropertySet->setPropertyValue( "Label", Any( rLabel ) );
147 xPropertySet->setPropertyValue( "Enabled", Any( bEnabled ) );
148 xPropertySet->setPropertyValue( "ID", Any( nItemID ) );
149 aIndexContainerRoadmap->insertByIndex( nIndex, Any( xRoadmapItem ) );
151 catch( Exception& )
159 void OptimizerDialog::UpdateConfiguration()
161 sal_Int16 nInt16 = 0;
162 Any aAny;
164 Sequence< sal_Int16 > aSelectedItems;
165 Sequence< OUString > aStringItemList;
167 // page0
168 aAny = getControlProperty( "ListBox0Pg0", "SelectedItems" );
169 if ( aAny >>= aSelectedItems )
171 if ( aSelectedItems.getLength() )
173 sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
174 aAny = getControlProperty( "ListBox0Pg0", "StringItemList" );
175 if ( aAny >>= aStringItemList )
177 if ( aStringItemList.getLength() > nSelectedItem )
178 SetConfigProperty( TK_Name, Any( aStringItemList[ nSelectedItem ] ) );
183 aAny = getControlProperty( "CheckBox3Pg3", "State" );
184 if ( aAny >>= nInt16 )
186 if ( nInt16 )
188 aAny = getControlProperty( "ListBox0Pg3", "SelectedItems" );
189 if ( aAny >>= aSelectedItems )
191 if ( aSelectedItems.getLength() )
193 sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
194 aAny = getControlProperty( "ListBox0Pg3", "StringItemList" );
195 if ( aAny >>= aStringItemList )
197 if ( aStringItemList.getLength() > nSelectedItem )
198 SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) );
208 OptimizerDialog::OptimizerDialog( const Reference< XComponentContext > &rxContext, Reference< XFrame >& rxFrame, Reference< XDispatch > rxStatusDispatcher ) :
209 UnoDialog( rxContext, rxFrame ),
210 ConfigurationAccess( rxContext, NULL ),
211 mnCurrentStep( 0 ),
212 mnTabIndex( 0 ),
213 mxFrame( rxFrame ),
214 mxItemListener( new ItemListener( *this ) ),
215 mxActionListener( new ActionListener( *this ) ),
216 mxActionListenerListBox0Pg0( new ActionListenerListBox0Pg0( *this ) ),
217 mxTextListenerFormattedField0Pg1( new TextListenerFormattedField0Pg1( *this ) ),
218 mxTextListenerComboBox0Pg1( new TextListenerComboBox0Pg1( *this ) ),
219 mxSpinListenerFormattedField0Pg1( new SpinListenerFormattedField0Pg1( *this ) ),
220 mxStatusDispatcher( rxStatusDispatcher )
222 Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY_THROW );
223 mbIsReadonly = xStorable->isReadonly();
225 InitDialog();
226 InitRoadmap();
227 InitNavigationBar();
228 InitPage0();
229 InitPage1();
230 InitPage2();
231 InitPage3();
232 InitPage4();
233 ActivatePage( 0 );
235 OptimizationStats aStats;
236 aStats.InitializeStatusValuesFromDocument( mxController->getModel() );
237 Sequence< PropertyValue > aStatusSequence( aStats.GetStatusSequence() );
238 UpdateStatus( aStatusSequence );
243 OptimizerDialog::~OptimizerDialog()
245 // not saving configuration if the dialog has been finished via cancel or close window
246 if ( mbStatus )
247 SaveConfiguration();
252 bool OptimizerDialog::execute()
254 Reference< XItemEventBroadcaster > maRoadmapBroadcaster( mxRoadmapControl, UNO_QUERY_THROW );
255 maRoadmapBroadcaster->addItemListener( mxItemListener );
256 UnoDialog::execute();
257 UpdateConfiguration(); // taking actual control settings for the configuration
258 maRoadmapBroadcaster->removeItemListener( mxItemListener );
259 return mbStatus;
264 void OptimizerDialog::SwitchPage( sal_Int16 nNewStep )
266 if ( ( nNewStep != mnCurrentStep ) && ( nNewStep <= MAX_STEP ) && ( nNewStep >= 0 ) )
268 sal_Int16 nOldStep = mnCurrentStep;
269 if ( nNewStep == 0 )
270 disableControl( "btnNavBack" );
271 else if ( nOldStep == 0 )
272 enableControl( "btnNavBack" );
274 if ( nNewStep == MAX_STEP )
275 disableControl( "btnNavNext" );
276 else if ( nOldStep == MAX_STEP )
277 enableControl( "btnNavNext" );
279 setControlProperty( "rdmNavi", "CurrentItemID", Any( nNewStep ) );
281 DeactivatePage( nOldStep );
282 UpdateControlStates( nNewStep );
284 ActivatePage( nNewStep );
285 mnCurrentStep = nNewStep;
289 void OptimizerDialog::UpdateControlStates( sal_Int16 nPage )
291 switch( nPage )
293 case 0 : UpdateControlStatesPage0(); break;
294 case 1 : UpdateControlStatesPage1(); break;
295 case 2 : UpdateControlStatesPage2(); break;
296 case 3 : UpdateControlStatesPage3(); break;
297 case 4 : UpdateControlStatesPage4(); break;
298 default:
300 UpdateControlStatesPage0();
301 UpdateControlStatesPage1();
302 UpdateControlStatesPage2();
303 UpdateControlStatesPage3();
304 UpdateControlStatesPage4();
311 OUString OptimizerDialog::GetSelectedString( OUString const & token )
313 OUString aSelectedItem;
314 Sequence< sal_Int16 > sSelectedItems;
315 Sequence< OUString > sItemList;
317 if ( ( getControlProperty( token, "SelectedItems" ) >>= sSelectedItems ) &&
318 ( getControlProperty( token, "StringItemList" ) >>= sItemList ) )
320 if ( sSelectedItems.getLength() == 1 )
322 sal_Int16 nSelectedItem = sSelectedItems[ 0 ];
323 if ( nSelectedItem < sItemList.getLength() )
324 aSelectedItem = sItemList[ nSelectedItem ];
327 return aSelectedItem;
332 void OptimizerDialog::UpdateStatus( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rStatus )
334 if ( mxReschedule.is() )
336 maStats.InitializeStatusValues( rStatus );
337 const Any* pVal( maStats.GetStatusValue( TK_Status ) );
338 if ( pVal )
340 OUString sStatus;
341 if ( *pVal >>= sStatus )
343 setControlProperty( "FixedText1Pg4", "Enabled", Any( sal_True ) );
344 setControlProperty( "FixedText1Pg4", "Label", Any( getString( TKGet( sStatus ) ) ) );
347 pVal = maStats.GetStatusValue( TK_Progress );
348 if ( pVal )
350 sal_Int32 nProgress = 0;
351 if ( *pVal >>= nProgress )
352 setControlProperty( "Progress", "ProgressValue", Any( nProgress ) );
354 pVal = maStats.GetStatusValue( TK_OpenNewDocument );
355 if ( pVal )
356 SetConfigProperty( TK_OpenNewDocument, *pVal );
358 mxReschedule->reschedule();
364 void ItemListener::itemStateChanged( const ItemEvent& Event )
365 throw ( RuntimeException, std::exception )
369 sal_Int16 nState;
370 OUString aControlName;
371 Reference< XControl > xControl;
372 Any aSource( Event.Source );
373 if ( aSource >>= xControl )
375 Reference< XPropertySet > xPropertySet( xControl->getModel(), UNO_QUERY_THROW );
376 xPropertySet->getPropertyValue( "Name" ) >>= aControlName;
377 PPPOptimizerTokenEnum eControl( TKGet( aControlName ) );
378 switch( eControl )
380 case TK_rdmNavi :
382 mrOptimizerDialog.SwitchPage( static_cast< sal_Int16 >( Event.ItemId ) );
384 break;
385 case TK_CheckBox1Pg1 :
387 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
388 mrOptimizerDialog.SetConfigProperty( TK_RemoveCropArea, Any( nState != 0 ) );
390 break;
391 case TK_CheckBox2Pg1 :
393 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
394 mrOptimizerDialog.SetConfigProperty( TK_EmbedLinkedGraphics, Any( nState != 0 ) );
396 break;
397 case TK_CheckBox0Pg2 :
399 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
401 mrOptimizerDialog.SetConfigProperty( TK_OLEOptimization, Any( nState != 0 ) );
402 mrOptimizerDialog.setControlProperty( "RadioButton0Pg2", "Enabled", Any( nState != 0 ) );
403 mrOptimizerDialog.setControlProperty( "RadioButton1Pg2", "Enabled", Any( nState != 0 ) );
406 break;
407 case TK_RadioButton0Pg1 :
409 sal_Int16 nInt16 = 0;
410 if ( xPropertySet->getPropertyValue( "State" ) >>= nInt16 )
412 nInt16 ^= 1;
413 mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nInt16 != 0 ) );
414 mrOptimizerDialog.setControlProperty( "FixedText1Pg1", "Enabled", Any( nInt16 != 0 ) );
415 mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "Enabled", Any( nInt16 != 0 ) );
418 break;
419 case TK_RadioButton1Pg1 :
421 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
423 mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nState != 0 ) );
424 mrOptimizerDialog.setControlProperty( "FixedText1Pg1", "Enabled", Any( nState != 0 ) );
425 mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "Enabled", Any( nState != 0 ) );
428 break;
429 case TK_RadioButton0Pg2 :
431 sal_Int16 nInt16;
432 if ( xPropertySet->getPropertyValue( "State" ) >>= nInt16 )
434 nInt16 ^= 1;
435 mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nInt16 ) );
438 break;
439 case TK_RadioButton1Pg2 :
441 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
442 mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nState ) );
444 break;
445 case TK_CheckBox0Pg3 :
447 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
448 mrOptimizerDialog.SetConfigProperty( TK_DeleteUnusedMasterPages, Any( nState != 0 ) );
450 break;
451 case TK_CheckBox1Pg3 :
453 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
454 mrOptimizerDialog.SetConfigProperty( TK_DeleteNotesPages, Any( nState != 0 ) );
456 break;
457 case TK_CheckBox2Pg3 :
459 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
460 mrOptimizerDialog.SetConfigProperty( TK_DeleteHiddenSlides, Any( nState != 0 ) );
462 break;
463 case TK_CheckBox3Pg3 :
465 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
466 mrOptimizerDialog.setControlProperty( "ListBox0Pg3", "Enabled", Any( nState != 0 ) );
468 break;
469 case TK_CheckBox1Pg4 :
471 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
472 mrOptimizerDialog.setControlProperty( "ComboBox0Pg4", "Enabled", Any( nState != 0 ) );
474 break;
475 case TK_RadioButton0Pg4 :
476 case TK_RadioButton1Pg4 :
478 if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
479 mrOptimizerDialog.SetConfigProperty( TK_SaveAs, Any( eControl == TK_RadioButton1Pg4 ? nState != 0 : nState == 0 ) );
481 break;
482 default:
483 break;
487 catch ( Exception& )
492 void ItemListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
493 throw ( com::sun::star::uno::RuntimeException, std::exception )
499 void ActionListener::actionPerformed( const ActionEvent& rEvent )
500 throw ( com::sun::star::uno::RuntimeException, std::exception )
502 switch( TKGet( rEvent.ActionCommand ) )
504 case TK_btnNavBack : mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep - 1 ); break;
505 case TK_btnNavNext : mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep + 1 ); break;
506 case TK_btnNavFinish :
508 mrOptimizerDialog.UpdateConfiguration();
510 mrOptimizerDialog.SwitchPage( ITEM_ID_SUMMARY );
511 mrOptimizerDialog.DisablePage( ITEM_ID_SUMMARY );
512 mrOptimizerDialog.setControlProperty( "btnNavBack", "Enabled", Any( sal_False ) );
513 mrOptimizerDialog.setControlProperty( "btnNavNext", "Enabled", Any( sal_False ) );
514 mrOptimizerDialog.setControlProperty( "btnNavFinish", "Enabled", Any( sal_False ) );
515 mrOptimizerDialog.setControlProperty( "btnNavCancel", "Enabled", Any( sal_False ) );
516 mrOptimizerDialog.setControlProperty( "FixedText0Pg4", "Enabled", Any( sal_True ) );
518 // check if we have to open the FileDialog
519 bool bSuccessfullyExecuted = true;
520 sal_Int16 nInt16 = 0;
521 mrOptimizerDialog.getControlProperty( "RadioButton1Pg4", "State" ) >>= nInt16;
522 if ( nInt16 )
524 OUString aSaveAsURL;
525 FileOpenDialog aFileOpenDialog( mrOptimizerDialog.GetComponentContext() );
527 // generating default file name
528 Reference< XStorable > xStorable( mrOptimizerDialog.mxController->getModel(), UNO_QUERY );
529 if ( xStorable.is() && xStorable->hasLocation() )
531 OUString aLocation( xStorable->getLocation() );
532 if ( !aLocation.isEmpty() )
534 sal_Int32 nIndex = aLocation.lastIndexOf( '/', aLocation.getLength() - 1 );
535 if ( nIndex >= 0 )
537 if ( nIndex < aLocation.getLength() - 1 )
538 aLocation = aLocation.copy( nIndex + 1 );
540 // remove extension
541 nIndex = aLocation.lastIndexOf( '.', aLocation.getLength() - 1 );
542 if ( nIndex >= 0 )
543 aLocation = aLocation.copy( 0, nIndex );
545 // adding .mini
546 aLocation = aLocation.concat( OUString(".mini") );
547 aFileOpenDialog.setDefaultName( aLocation );
551 bool bDialogExecuted = aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK;
552 if ( bDialogExecuted )
554 aSaveAsURL = aFileOpenDialog.getURL();
555 mrOptimizerDialog.SetConfigProperty( TK_SaveAsURL, Any( aSaveAsURL ) );
556 mrOptimizerDialog.SetConfigProperty( TK_FilterName, Any( aFileOpenDialog.getFilterName() ) );
558 if ( aSaveAsURL.isEmpty() )
560 // something goes wrong...
561 bSuccessfullyExecuted = false;
564 // waiting for 500ms
565 if ( mrOptimizerDialog.mxReschedule.is() )
567 mrOptimizerDialog.mxReschedule->reschedule();
568 for ( sal_uInt32 i = osl_getGlobalTimer(); ( i + 500 ) > ( osl_getGlobalTimer() ); )
569 mrOptimizerDialog.mxReschedule->reschedule();
572 if ( bSuccessfullyExecuted )
573 { // now check if we have to store a session template
574 nInt16 = 0;
575 OUString aSettingsName;
576 mrOptimizerDialog.getControlProperty( "CheckBox1Pg4", "State" ) >>= nInt16;
577 mrOptimizerDialog.getControlProperty( "ComboBox0Pg4", "Text" ) >>= aSettingsName;
578 if ( nInt16 && !aSettingsName.isEmpty() )
580 std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSettingsName ) );
581 std::vector< OptimizerSettings >& rSettings( mrOptimizerDialog.GetOptimizerSettings() );
582 OptimizerSettings aNewSettings( rSettings[ 0 ] );
583 aNewSettings.maName = aSettingsName;
584 if ( aIter == rSettings.end() )
585 rSettings.push_back( aNewSettings );
586 else
587 *aIter = aNewSettings;
590 if ( bSuccessfullyExecuted )
592 Reference < XDispatch > xDispatch(
593 new PPPOptimizer(
594 mrOptimizerDialog.GetComponentContext(),
595 mrOptimizerDialog.GetFrame()));
597 URL aURL;
598 aURL.Protocol = "vnd.com.sun.star.comp.PPPOptimizer:";
599 aURL.Path = "optimize";
601 Sequence< PropertyValue > lArguments( 3 );
602 lArguments[ 0 ].Name = "Settings";
603 lArguments[ 0 ].Value <<= mrOptimizerDialog.GetConfigurationSequence();
604 lArguments[ 1 ].Name = "StatusDispatcher";
605 lArguments[ 1 ].Value <<= mrOptimizerDialog.GetStatusDispatcher();
606 lArguments[ 2 ].Name = "InformationDialog";
607 lArguments[ 2 ].Value <<= mrOptimizerDialog.GetFrame();
609 xDispatch->dispatch( aURL, lArguments );
611 mrOptimizerDialog.endExecute( bSuccessfullyExecuted );
613 else
615 mrOptimizerDialog.setControlProperty( "btnNavBack", "Enabled", Any( sal_True ) );
616 mrOptimizerDialog.setControlProperty( "btnNavNext", "Enabled", Any( sal_False ) );
617 mrOptimizerDialog.setControlProperty( "btnNavFinish", "Enabled", Any( sal_True ) );
618 mrOptimizerDialog.setControlProperty( "btnNavCancel", "Enabled", Any( sal_True ) );
619 mrOptimizerDialog.EnablePage( ITEM_ID_SUMMARY );
622 break;
623 case TK_btnNavCancel : mrOptimizerDialog.endExecute( false ); break;
624 case TK_Button0Pg0 : // delete configuration
626 OUString aSelectedItem( mrOptimizerDialog.GetSelectedString( "ListBox0Pg0" ) );
627 if ( !aSelectedItem.isEmpty() )
629 std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSelectedItem ) );
630 std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() );
631 if ( aIter != rList.end() )
633 rList.erase( aIter );
634 mrOptimizerDialog.UpdateControlStates();
638 break;
639 default: break;
642 void ActionListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
643 throw ( com::sun::star::uno::RuntimeException, std::exception )
649 void ActionListenerListBox0Pg0::actionPerformed( const ActionEvent& rEvent )
650 throw ( com::sun::star::uno::RuntimeException, std::exception )
652 if ( !rEvent.ActionCommand.isEmpty() )
654 std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( rEvent.ActionCommand ) );
655 std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() );
656 if ( aIter != rList.end() )
657 rList[ 0 ] = *aIter;
659 mrOptimizerDialog.UpdateControlStates();
661 void ActionListenerListBox0Pg0::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
662 throw ( com::sun::star::uno::RuntimeException, std::exception )
668 void TextListenerFormattedField0Pg1::textChanged( const TextEvent& /* rEvent */ )
669 throw ( com::sun::star::uno::RuntimeException, std::exception )
671 double fDouble = 0;
672 Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
673 if ( aAny >>= fDouble )
674 mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
676 void TextListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
677 throw ( com::sun::star::uno::RuntimeException, std::exception )
683 void TextListenerComboBox0Pg1::textChanged( const TextEvent& /* rEvent */ )
684 throw ( com::sun::star::uno::RuntimeException, std::exception )
686 OUString aString;
687 Any aAny = mrOptimizerDialog.getControlProperty( "ComboBox0Pg1", "Text" );
688 if ( aAny >>= aString )
690 sal_Int32 nI0, nI1, nI2, nI3, nI4;
691 nI0 = nI1 = nI2 = nI3 = nI4 = 0;
693 if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ) == aString )
694 aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI4 );
695 else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ) == aString )
696 aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI4 );
697 else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ) == aString )
698 aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI4 );
699 else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ) == aString )
700 aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI4 );
702 mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( aString.toInt32() ) );
705 void TextListenerComboBox0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
706 throw ( com::sun::star::uno::RuntimeException, std::exception )
712 void SpinListenerFormattedField0Pg1::up( const SpinEvent& /* rEvent */ )
713 throw ( com::sun::star::uno::RuntimeException, std::exception )
715 double fDouble;
716 Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
717 if ( aAny >>= fDouble )
719 fDouble += 9;
720 if ( fDouble > 100 )
721 fDouble = 100;
722 mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( fDouble ) );
723 mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
726 void SpinListenerFormattedField0Pg1::down( const SpinEvent& /* rEvent */ )
727 throw ( com::sun::star::uno::RuntimeException, std::exception )
729 double fDouble;
730 Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
731 if ( aAny >>= fDouble )
733 fDouble -= 9;
734 if ( fDouble < 0 )
735 fDouble = 0;
736 mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( fDouble ) );
737 mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
740 void SpinListenerFormattedField0Pg1::first( const SpinEvent& /* rEvent */ )
741 throw ( com::sun::star::uno::RuntimeException, std::exception )
743 mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast< double >( 0 ) ) );
744 mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)0 ) );
746 void SpinListenerFormattedField0Pg1::last( const SpinEvent& /* rEvent */ )
747 throw ( com::sun::star::uno::RuntimeException, std::exception )
749 mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast< double >( 100 ) ) );
750 mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)100 ) );
752 void SpinListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
753 throw ( com::sun::star::uno::RuntimeException, std::exception )
757 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */